Fix Capture Point duration and prevent Undead City chests from respawning
This commit is contained in:
parent
2efe422519
commit
de015c0943
@ -12,6 +12,8 @@ import mineplex.core.common.Pair;
|
|||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilTextTop;
|
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.common.util.UtilWorld;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
@ -21,7 +23,7 @@ import mineplex.game.clans.clans.worldevent.api.WorldEvent;
|
|||||||
|
|
||||||
public class CapturePointEvent extends 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 _capturing = null;
|
||||||
private Player _winner = null;
|
private Player _winner = null;
|
||||||
private Pair<Material, Byte> _resetData = null;
|
private Pair<Material, Byte> _resetData = null;
|
||||||
|
@ -11,12 +11,12 @@ public class CityChest
|
|||||||
private final boolean _enabled;
|
private final boolean _enabled;
|
||||||
private final Block _block;
|
private final Block _block;
|
||||||
private boolean _opened;
|
private boolean _opened;
|
||||||
private int _ticksSinceOpened;
|
|
||||||
|
|
||||||
public CityChest(Block block, boolean enabled)
|
public CityChest(Block block, boolean enabled)
|
||||||
{
|
{
|
||||||
_block = block;
|
_block = block;
|
||||||
_enabled = enabled;
|
_enabled = enabled;
|
||||||
|
_opened = false;
|
||||||
|
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
{
|
||||||
@ -29,34 +29,22 @@ public class CityChest
|
|||||||
return _enabled;
|
return _enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOpen()
|
||||||
|
{
|
||||||
|
return _opened;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void open()
|
public void open()
|
||||||
{
|
{
|
||||||
_opened = true;
|
|
||||||
_block.setType(Material.AIR);
|
_block.setType(Material.AIR);
|
||||||
_block.getWorld().playEffect(_block.getLocation(), Effect.STEP_SOUND, Material.ENDER_CHEST.getId());
|
_block.getWorld().playEffect(_block.getLocation(), Effect.STEP_SOUND, Material.ENDER_CHEST.getId());
|
||||||
ClansManager.getInstance().getLootManager().dropUndeadCity(_block.getLocation());
|
ClansManager.getInstance().getLootManager().dropUndeadCity(_block.getLocation());
|
||||||
}
|
_opened = true;
|
||||||
|
|
||||||
public void update()
|
|
||||||
{
|
|
||||||
if (_opened)
|
|
||||||
{
|
|
||||||
if (_ticksSinceOpened > (20 * 20))
|
|
||||||
{
|
|
||||||
revert();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_ticksSinceOpened++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void revert()
|
public void revert()
|
||||||
{
|
{
|
||||||
_opened = false;
|
|
||||||
_ticksSinceOpened = 0;
|
|
||||||
_block.setType(Material.ENDER_CHEST);
|
_block.setType(Material.ENDER_CHEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -98,7 +98,19 @@ public class UndeadCity extends WorldEvent
|
|||||||
{
|
{
|
||||||
return;
|
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()))
|
if (UtilTime.elapsed(_lastSpawn, 15000) && getCreatures().size() < Math.min(_maxMobs, _spawnSpots.size()))
|
||||||
{
|
{
|
||||||
Location loc = UtilMath.randomElement(_spawnSpots);
|
Location loc = UtilMath.randomElement(_spawnSpots);
|
||||||
|
Loading…
Reference in New Issue
Block a user