mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-03 22:15:24 +00:00
siege or raid check logic
This commit is contained in:
1 parent
acbefe71e8
commit
df0a66d089
2 files changed
+51
-13
No files matched your search
@@ -22,7 +22,8 @@ public class AdminTabCompletion implements TabCompleter {
|
|||||||
"load",
|
"load",
|
||||||
"load-all",
|
"load-all",
|
||||||
"save",
|
"save",
|
||||||
"save-all"
|
"save-all",
|
||||||
|
"item"
|
||||||
});
|
});
|
||||||
|
|
||||||
List<String> type = List.of(new String[]{
|
List<String> type = List.of(new String[]{
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
package me.ShermansWorld.AlathraWar.listeners;
|
package me.ShermansWorld.AlathraWar.listeners;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.object.TownBlock;
|
||||||
|
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||||
|
import me.ShermansWorld.AlathraWar.Helper;
|
||||||
import me.ShermansWorld.AlathraWar.Main;
|
import me.ShermansWorld.AlathraWar.Main;
|
||||||
|
import me.ShermansWorld.AlathraWar.Raid;
|
||||||
|
import me.ShermansWorld.AlathraWar.Siege;
|
||||||
|
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||||
|
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.type.Door;
|
import org.bukkit.block.data.type.Door;
|
||||||
@@ -33,21 +40,51 @@ public class PlayerInteractListener implements Listener {
|
|||||||
|
|
||||||
if (action == Action.LEFT_CLICK_BLOCK && clicked.getType().toString().contains("DOOR")) { // right click + any door types
|
if (action == Action.LEFT_CLICK_BLOCK && clicked.getType().toString().contains("DOOR")) { // right click + any door types
|
||||||
Door door = (Door) clicked.getBlockData();
|
Door door = (Door) clicked.getBlockData();
|
||||||
// lock door in the opposite position
|
|
||||||
if (item.getType() == Material.GUNPOWDER && item.getItemMeta().getDisplayName().contains("Door Ram")) {
|
boolean inSiegeOrRaid = false;
|
||||||
if (brokenDoors.get(door) != null && brokenDoors.get(door) > System.currentTimeMillis()) {
|
//siege check
|
||||||
player.sendMessage("The door is already broken!");
|
for(Siege s : SiegeData.getSieges()) {
|
||||||
event.setCancelled(true);
|
for (TownBlock townBlock : s.getTown().getTownBlocks()) {
|
||||||
|
if(WorldCoord.parseWorldCoord(clicked).equals(townBlock.getWorldCoord())) {
|
||||||
|
// if we find one, just end no need to continue
|
||||||
|
inSiegeOrRaid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//if it wasnt in a siege, then
|
||||||
|
if(!inSiegeOrRaid) {
|
||||||
|
for(Raid r : RaidData.getRaids()) {
|
||||||
|
for (TownBlock townBlock : r.getRaidedTown().getTownBlocks()) {
|
||||||
|
if(WorldCoord.parseWorldCoord(clicked).equals(townBlock.getWorldCoord())) {
|
||||||
|
// if we find one, just end no need to continue
|
||||||
|
inSiegeOrRaid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(inSiegeOrRaid) {
|
||||||
|
// lock door in the opposite position
|
||||||
|
if (item.getType() == Material.GUNPOWDER && item.getItemMeta().getDisplayName().contains("Door Ram")) {
|
||||||
|
if (brokenDoors.get(door) != null && brokenDoors.get(door) > System.currentTimeMillis()) {
|
||||||
|
player.sendMessage("The door is already broken!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage("Break it down alright!");
|
||||||
|
brokenDoors.put(door, System.currentTimeMillis() + (1000L * Main.getInstance().getConfig().getInt("batteringRamEffectiveness")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage("Break it down alright!");
|
if (brokenDoors.get(door) != null && brokenDoors.get(door) > System.currentTimeMillis()) {
|
||||||
brokenDoors.put(door, System.currentTimeMillis() + (1000L * Main.getInstance().getConfig().getInt("batteringRamEffectiveness")));
|
player.sendMessage(Helper.chatLabel() + Helper.color("Door is broken! " + String.valueOf(System.currentTimeMillis()) + " " + brokenDoors.get(door)));
|
||||||
return;
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (brokenDoors.get(door) != null && brokenDoors.get(door) > System.currentTimeMillis()) {
|
player.sendMessage(Helper.chatLabel() + Helper.color("&cThis item can only be used in a siege or raid!"));
|
||||||
player.sendMessage("Door is broken! " + String.valueOf(System.currentTimeMillis()) + " " + brokenDoors.get(door));
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user