mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 22:14:45 +00:00
door bugfix and global msgs
This commit is contained in:
1 parent
0008d63fe9
commit
60a75c5f8b
4 files changed
+30
-7
No files matched your search
@@ -3,7 +3,7 @@
|
||||
|
||||
<groupId>me.ShermansWorld</groupId>
|
||||
<artifactId>AlathraWar</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>AlathraWar</name>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: AlathraWar
|
||||
version: 2.0.0
|
||||
version: 2.0.1
|
||||
api-version: 1.19
|
||||
author: ShermansWorld
|
||||
main: me.ShermansWorld.AlathraWar.Main
|
||||
|
||||
@@ -76,7 +76,7 @@ public class WarCommands implements CommandExecutor {
|
||||
WarData.addWar(war);
|
||||
war.save();
|
||||
|
||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "War created with the name " + args[1] + ", "
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "War created with the name " + args[1] + ", "
|
||||
+ args[2] + " vs. " + args[3]);
|
||||
Main.warLogger.log(p.getName() + " created a new war with the name " + args[1] + ", " + args[2]
|
||||
+ " vs. " + args[3]);
|
||||
@@ -113,7 +113,7 @@ public class WarCommands implements CommandExecutor {
|
||||
|
||||
WarData.removeWar(war);
|
||||
|
||||
p.sendMessage(String.valueOf(Helper.chatLabel()) + "War " + args[1] + " deleted.");
|
||||
Bukkit.broadcastMessage(String.valueOf(Helper.chatLabel()) + "War " + args[1] + " deleted.");
|
||||
Main.warLogger.log(p.getName() + " deleted " + args[1]);
|
||||
return;
|
||||
} else {
|
||||
@@ -212,6 +212,7 @@ public class WarCommands implements CommandExecutor {
|
||||
war.addNation(res.getNationOrNull(), args[2]);
|
||||
res.getPlayer().sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getNationOrNull().getName());
|
||||
p.sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getNationOrNull().getName());
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The nation of " + res.getNationOrNull().getName() + " has joined the war on the side of " + args[2] + "!");
|
||||
war.save();
|
||||
return;
|
||||
} else {
|
||||
@@ -225,6 +226,7 @@ public class WarCommands implements CommandExecutor {
|
||||
war.addTown(res.getTownOrNull(), args[2]);
|
||||
res.getPlayer().sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getTownOrNull().getName());
|
||||
p.sendMessage(Helper.chatLabel() + "You have joined the war for " + res.getTownOrNull().getName());
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The town of " + res.getTownOrNull().getName() + " has joined the war on the side of " + args[2] + "!");
|
||||
war.save();
|
||||
return;
|
||||
} else {
|
||||
@@ -266,6 +268,7 @@ public class WarCommands implements CommandExecutor {
|
||||
// Has nation surrender permission
|
||||
war.surrenderNation(res.getNationOrNull());
|
||||
p.sendMessage(Helper.chatLabel() + "You have surrendered the war for " + res.getNationOrNull().getName());
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The nation of " + res.getNationOrNull().getName() + " has surrendered! They were fighting for " + args[2] + ".");
|
||||
war.save();
|
||||
return;
|
||||
} else {
|
||||
@@ -278,6 +281,7 @@ public class WarCommands implements CommandExecutor {
|
||||
// Is in indepdenent town & has surrender perms
|
||||
war.surrenderTown(res.getTownOrNull().getName());
|
||||
p.sendMessage(Helper.chatLabel() + "You have surrendered the war for " + res.getTownOrNull().getName());
|
||||
Bukkit.broadcastMessage(Helper.chatLabel() + "The town of " + res.getTownOrNull().getName() + " has surrendered! They were fighting for " + args[2] + ".");
|
||||
war.save();
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -10,6 +10,7 @@ import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||
import me.ShermansWorld.AlathraWar.items.WarItemRegistry;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.block.data.type.Door;
|
||||
@@ -24,10 +25,28 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class PlayerInteractListener implements Listener {
|
||||
|
||||
|
||||
//predefined foor materials
|
||||
private static Set<Material> doors = new HashSet<Material>();
|
||||
|
||||
static {
|
||||
doors.add(Material.ACACIA_DOOR);
|
||||
doors.add(Material.BIRCH_DOOR);
|
||||
doors.add(Material.CRIMSON_DOOR);
|
||||
doors.add(Material.DARK_OAK_DOOR);
|
||||
doors.add(Material.IRON_DOOR);
|
||||
doors.add(Material.JUNGLE_DOOR);
|
||||
doors.add(Material.MANGROVE_DOOR);
|
||||
doors.add(Material.OAK_DOOR);
|
||||
doors.add(Material.SPRUCE_DOOR);
|
||||
doors.add(Material.WARPED_DOOR);
|
||||
}
|
||||
|
||||
//map of broken doors
|
||||
public Map<Location, Long> brokenDoors = new HashMap<Location, Long>();
|
||||
|
||||
@@ -45,7 +64,7 @@ public class PlayerInteractListener implements Listener {
|
||||
Block clicked = event.getClickedBlock();
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
if (clicked != null) {
|
||||
if (clicked.getType().toString().contains("DOOR")) { // left click + any door types
|
||||
if (doors.contains(clicked.getType())) { // left click + any door types
|
||||
Door door = (Door) clicked.getBlockData();
|
||||
// lock door in the opposite position
|
||||
if (item.equals(WarItemRegistry.getInstance().getOrNull("ram"))) {
|
||||
@@ -120,7 +139,7 @@ public class PlayerInteractListener implements Listener {
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
if (action == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (clicked != null) {
|
||||
if (clicked.getType().toString().contains("DOOR")) {
|
||||
if (doors.contains(clicked.getType())) {
|
||||
Door door = (Door) clicked.getBlockData();
|
||||
if (doorBroken(clicked, door)) {
|
||||
player.sendMessage(Helper.chatLabel() + Helper.color("Door is broken!"));
|
||||
|
||||
Reference in new issue
Block a user