diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 218d7947b..e5b721b4c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -9,6 +9,7 @@ import java.util.Set; import java.util.TimeZone; import java.util.UUID; +import mineplex.game.clans.clans.warpoints.WarPointEvasion; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -259,9 +260,9 @@ public class ClansManager extends MiniClientPluginimplements IRelati _itemMapManager = new ItemMapManager(this, _worldEvent); new TntGeneratorManager(plugin, this); new SupplyDropManager(plugin, this); - _explosion = new Explosion(plugin, blockRestore); - + new WarPointEvasion(plugin); + // new ClansLoginManager(getPlugin(), clientManager, _serverName); _clanShop = new ClanShop(this, clientManager, donationManager); @@ -608,6 +609,13 @@ public class ClansManager extends MiniClientPluginimplements IRelati { player.setOp(true); } + if(player.getInventory().getHelmet() != null) { //Reset helmet to fix 1 damage bug + ItemStack helmet = player.getInventory().getHelmet().clone(); + player.getInventory().setHelmet(null); + runSyncLater(() -> { + player.getInventory().setHelmet(helmet); + }, 5L); + } } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/warpoints/WarPointEvasion.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/warpoints/WarPointEvasion.java new file mode 100644 index 000000000..fb6e9bd87 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/warpoints/WarPointEvasion.java @@ -0,0 +1,58 @@ +package mineplex.game.clans.clans.warpoints; + +import com.google.common.collect.Maps; +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; +import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; +import org.bukkit.Chunk; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.HashMap; + +public class WarPointEvasion extends MiniPlugin{ + private HashMap _cooldown; + private final long COOLDOWN_TIME = 1000 * 60 * 30; + + public WarPointEvasion(JavaPlugin plugin) { + super("WP Evasion", plugin); + _cooldown = Maps.newHashMap(); + } + + @EventHandler + public void updateCooldown(UpdateEvent event) { + if(!event.getType().equals(UpdateType.SEC)) return; + + for(Chunk chunk : _cooldown.keySet()) { + if(UtilTime.elapsed(_cooldown.get(chunk), COOLDOWN_TIME)) { + _cooldown.remove(chunk); + } else { + _cooldown.put(chunk, _cooldown.get(chunk) - 1000); + } + } + } + + @EventHandler + public void onClaim(PlayerPreClaimTerritoryEvent event) { + Chunk chunk = event.getClaimedChunk(); + if(_cooldown.containsKey(chunk)) { + event.setCancelled(true); + event.getClaimer().sendMessage(F.main("Clans", "You cannot claim this chunk for another " + UtilTime.convertString(_cooldown.get(chunk), 1, UtilTime.TimeUnit.MINUTES))); + } + } + + @EventHandler + public void onunClaim(PlayerUnClaimTerritoryEvent event) { + Chunk chunk = event.getUnClaimedChunk(); + if(_cooldown.containsKey(chunk)) { + // Error maybe? + _cooldown.remove(chunk); + } + _cooldown.put(chunk, System.currentTimeMillis()); + + } +}