mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-03 06:28:51 +00:00
Ram logic update
This commit is contained in:
1 parent
11b7a404bf
commit
bc9dc24f1b
1 file changed
+39
-40
@@ -9,7 +9,6 @@ import me.ShermansWorld.AlathraWar.Siege;
|
|||||||
import me.ShermansWorld.AlathraWar.data.RaidData;
|
import me.ShermansWorld.AlathraWar.data.RaidData;
|
||||||
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
import me.ShermansWorld.AlathraWar.data.SiegeData;
|
||||||
import me.ShermansWorld.AlathraWar.items.WarItems;
|
import me.ShermansWorld.AlathraWar.items.WarItems;
|
||||||
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;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -41,56 +40,54 @@ public class PlayerInteractListener implements Listener {
|
|||||||
Block clicked = event.getClickedBlock();
|
Block clicked = event.getClickedBlock();
|
||||||
ItemStack item = player.getInventory().getItemInMainHand();
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (action == Action.LEFT_CLICK_BLOCK && clicked.getType().toString().contains("DOOR")) { // right click + any door types
|
if (action == Action.LEFT_CLICK_BLOCK) {
|
||||||
Door door = (Door) clicked.getState();
|
if (clicked != null) {
|
||||||
// lock door in the opposite position
|
if (clicked.getType().toString().contains("DOOR")) { // right click + any door types
|
||||||
if (item.getType() == Material.WOODEN_HOE && item.getItemMeta().getDisplayName().contains("Door Ram")) {
|
Door door = (Door) clicked.getState();
|
||||||
|
// lock door in the opposite position
|
||||||
boolean inSiegeOrRaid = false;
|
if (item.equals(WarItems.getOrNull("ram"))) {
|
||||||
//siege check
|
boolean inSiegeOrRaid = false;
|
||||||
for(Siege s : SiegeData.getSieges()) {
|
//siege check
|
||||||
for (TownBlock townBlock : s.getTown().getTownBlocks()) {
|
for (Siege s : SiegeData.getSieges()) {
|
||||||
if(WorldCoord.parseWorldCoord(clicked).equals(townBlock.getWorldCoord())) {
|
for (TownBlock townBlock : s.getTown().getTownBlocks()) {
|
||||||
// if we find one, just end no need to continue
|
if (WorldCoord.parseWorldCoord(clicked).equals(townBlock.getWorldCoord())) {
|
||||||
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
|
// if we find one, just end no need to continue
|
||||||
inSiegeOrRaid = true;
|
inSiegeOrRaid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//if it wasnt in a siege, then
|
||||||
|
if (!inSiegeOrRaid) {
|
||||||
if(inSiegeOrRaid) {
|
for (Raid r : RaidData.getRaids()) {
|
||||||
if (brokenDoors.get(door) != null && brokenDoors.get(door) > System.currentTimeMillis()) {
|
for (TownBlock townBlock : r.getRaidedTown().getTownBlocks()) {
|
||||||
player.sendMessage(Helper.chatLabel() + Helper.color("&cThe door is already broken!"));
|
if (WorldCoord.parseWorldCoord(clicked).equals(townBlock.getWorldCoord())) {
|
||||||
event.setCancelled(true);
|
// if we find one, just end no need to continue
|
||||||
return;
|
inSiegeOrRaid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(Helper.chatLabel() + Helper.color("&eBreak it down alright!"));
|
if (inSiegeOrRaid) {
|
||||||
brokenDoors.put(door, System.currentTimeMillis() + (1000L * Main.getInstance().getConfig().getInt("batteringRamEffectiveness")));
|
if (brokenDoors.get(door) != null && brokenDoors.get(door) > System.currentTimeMillis()) {
|
||||||
door.setOpen(!door.isOpen());
|
player.sendMessage(Helper.chatLabel() + Helper.color("&cThe door is already broken!"));
|
||||||
player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
} else {
|
player.sendMessage(Helper.chatLabel() + Helper.color("&eBreak it down alright!"));
|
||||||
player.sendMessage(Helper.chatLabel() + Helper.color("&cThis item can only be used in a siege or raid!"));
|
brokenDoors.put(door, System.currentTimeMillis() + (1000L * Main.getInstance().getConfig().getInt("batteringRamEffectiveness")));
|
||||||
event.setCancelled(true);
|
door.setOpen(!door.isOpen());
|
||||||
|
player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Helper.chatLabel() + Helper.color("&cThis item can only be used in a siege or raid!"));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == Action.RIGHT_CLICK_BLOCK) {
|
if (action == Action.RIGHT_CLICK_BLOCK) {
|
||||||
@@ -100,12 +97,14 @@ public class PlayerInteractListener implements Listener {
|
|||||||
if (brokenDoors.get(door) != null && brokenDoors.get(door) > System.currentTimeMillis()) {
|
if (brokenDoors.get(door) != null && brokenDoors.get(door) > System.currentTimeMillis()) {
|
||||||
player.sendMessage(Helper.chatLabel() + Helper.color("Door is broken! " + String.valueOf(System.currentTimeMillis()) + " " + brokenDoors.get(door)));
|
player.sendMessage(Helper.chatLabel() + Helper.color("Door is broken! " + String.valueOf(System.currentTimeMillis()) + " " + brokenDoors.get(door)));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(item.equals(WarItems.getOrNull("ram"))) {
|
if(item.equals(WarItems.getOrNull("ram"))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user