From de015c0943d246547d88554b8b4e810f079cb1b4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 22 Sep 2017 02:53:48 -0400 Subject: [PATCH] Fix Capture Point duration and prevent Undead City chests from respawning --- .../capturepoint/CapturePointEvent.java | 4 ++- .../clans/worldevent/undead/CityChest.java | 26 +++++-------------- .../clans/worldevent/undead/UndeadCity.java | 14 +++++++++- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java index b694a31f2..e68e82c1a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/capturepoint/CapturePointEvent.java @@ -12,6 +12,8 @@ import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilTextTop; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilWorld; import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClansManager; @@ -21,7 +23,7 @@ import mineplex.game.clans.clans.worldevent.api.WorldEvent; public class CapturePointEvent extends WorldEvent { - private static final long MAX_TICKS = 20 * 10;//UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.SECONDS) * 20; + private static final long MAX_TICKS = UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.SECONDS) * 20; private Player _capturing = null; private Player _winner = null; private Pair _resetData = null; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CityChest.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CityChest.java index 6a262603c..de7068ca5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CityChest.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CityChest.java @@ -11,12 +11,12 @@ public class CityChest private final boolean _enabled; private final Block _block; private boolean _opened; - private int _ticksSinceOpened; public CityChest(Block block, boolean enabled) { _block = block; _enabled = enabled; + _opened = false; if (!enabled) { @@ -29,34 +29,22 @@ public class CityChest return _enabled; } + public boolean isOpen() + { + return _opened; + } + @SuppressWarnings("deprecation") public void open() { - _opened = true; _block.setType(Material.AIR); _block.getWorld().playEffect(_block.getLocation(), Effect.STEP_SOUND, Material.ENDER_CHEST.getId()); ClansManager.getInstance().getLootManager().dropUndeadCity(_block.getLocation()); - } - - public void update() - { - if (_opened) - { - if (_ticksSinceOpened > (20 * 20)) - { - revert(); - } - else - { - _ticksSinceOpened++; - } - } + _opened = true; } public void revert() { - _opened = false; - _ticksSinceOpened = 0; _block.setType(Material.ENDER_CHEST); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCity.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCity.java index 141ef8ce1..a856a08be 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCity.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/UndeadCity.java @@ -98,7 +98,19 @@ public class UndeadCity extends WorldEvent { return; } - _chests.values().forEach(CityChest::update); + int active = 0; + for (CityChest chest : _chests.values()) + { + if (chest.isEnabled() && chest.isOpen()) + { + active++; + } + } + if (active < 1) + { + stop(); + return; + } if (UtilTime.elapsed(_lastSpawn, 15000) && getCreatures().size() < Math.min(_maxMobs, _spawnSpots.size())) { Location loc = UtilMath.randomElement(_spawnSpots);