From 9ccc85a79e87a1eae2a5bac3a7ac318501a8cbc9 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 30 Jun 2015 22:30:49 -0500 Subject: [PATCH] Improved block restore for Events --- .../core/common/block/BlockRestoreMap.java | 139 -------------- .../core/blockrestore}/BlockDataRunnable.java | 8 +- .../core/blockrestore/BlockRestore.java | 89 ++++++--- .../core/blockrestore/BlockRestoreMap.java | 175 ++++++++++++++++++ .../mineplex/core/explosion/Explosion.java | 4 +- .../core/gadget/gadgets/ItemPaintballGun.java | 4 +- .../clans/clans/ClansDataAccessLayer.java | 2 +- .../mineplex/game/clans/clans/ClansGame.java | 4 +- .../game/clans/clans/ClansManager.java | 3 +- .../clans/worldevent/WorldEventManager.java | 12 +- .../clans/worldevent/event/WorldEvent.java | 40 +--- .../event/undead/creature/UndeadWarrior.java | 1 + .../game/clans/gameplay/Gameplay.java | 9 +- .../mineplex/hub/modules/WorldManager.java | 2 +- .../classcombat/Skill/Brute/BlockToss.java | 3 +- .../classcombat/Skill/Mage/ArcticArmor.java | 9 +- .../game/classcombat/Skill/Mage/Blizzard.java | 4 +- .../classcombat/Skill/Mage/FissureData.java | 8 +- .../classcombat/Skill/Mage/FreezingBlast.java | 2 +- .../classcombat/Skill/Mage/IcePrison.java | 4 +- .../classcombat/Skill/Mage/LifeBonds.java | 9 +- .../game/classcombat/item/Throwable/Web.java | 2 +- .../game/games/castlesiege/CastleSiege.java | 2 +- .../game/games/dragonescape/DragonEscape.java | 6 +- .../game/games/halloween/waves/WaveBase.java | 8 +- .../game/games/minestrike/MineStrike.java | 3 +- .../items/grenades/FireGrenadeBase.java | 2 +- .../minestrike/items/grenades/Smoke.java | 2 +- .../arcade/game/games/wither/WitherGame.java | 2 +- .../game/arcade/kit/perks/PerkArcticAura.java | 2 +- .../game/arcade/kit/perks/PerkBlizzard.java | 2 +- .../game/arcade/kit/perks/PerkBlockToss.java | 2 +- .../game/arcade/kit/perks/PerkIcePath.java | 2 +- .../game/arcade/kit/perks/PerkIronShell.java | 2 +- .../arcade/kit/perks/PerkSpidersNest.java | 2 +- .../game/arcade/kit/perks/PerkWeb.java | 2 +- .../game/arcade/kit/perks/PerkWebShot.java | 4 +- .../game/arcade/kit/perks/PerkWitherWeb.java | 6 +- .../game/arcade/kit/perks/PerkWoolBomb.java | 3 +- .../game/arcade/kit/perks/PerkZombieRot.java | 3 +- .../arcade/kit/perks/data/FissureData.java | 9 +- 41 files changed, 312 insertions(+), 285 deletions(-) delete mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/BlockRestoreMap.java rename Plugins/{Mineplex.Core.Common/src/mineplex/core/common/block => Mineplex.Core/src/mineplex/core/blockrestore}/BlockDataRunnable.java (88%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/BlockRestoreMap.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/BlockRestoreMap.java deleted file mode 100644 index fe8b0d904..000000000 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/BlockRestoreMap.java +++ /dev/null @@ -1,139 +0,0 @@ -package mineplex.core.common.block; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.block.Block; -import org.bukkit.plugin.java.JavaPlugin; - -public class BlockRestoreMap implements Runnable -{ - private HashSet _changedBlocks; - private HashMap[] _blocks; - - public BlockRestoreMap() - { - _changedBlocks = new HashSet(); - _blocks = new HashMap[256]; - - for (int i = 0; i < 256; i++) - { - _blocks[i] = new HashMap(); - } - } - - private HashMap getMap(int index) - { - return _blocks[index]; - } - - public HashSet getChangedBlocks() - { - return _changedBlocks; - } - - public void addBlockData(BlockData blockData) - { - Block block = blockData.Block; - - if (!_blocks[block.getY()].containsKey(block)) - _blocks[block.getY()].put(block, blockData); - - _changedBlocks.add(blockData.Block); - } - - public void setBlock(Block block, int material, byte data) - { - addBlockData(new BlockData(block)); - - block.setTypeIdAndData(material, data, false); - } - - public void restoreTopDown(JavaPlugin plugin, final Runnable onComplete) - { - BlockDataRunnable run = new BlockDataRunnable(plugin, new RestoreIterator(this), new Runnable() - { - @Override - public void run() - { - clear(); - onComplete.run(); - } - }); - - run.setBlocksPerTick(20); - - run.start(); - } - - private void clear() - { - for (int i = 0; i < 256; i++) - { - _blocks[i].clear(); - } - } - - @Override - public void run() - { - - } - - public void restore() - { - for (int i = 0; i < 256; i++) - { - HashMap map = _blocks[i]; - for (BlockData data : map.values()) - { - data.restore(); - } - map.clear(); - } - } - - private static class RestoreIterator implements Iterator - { - private BlockRestoreMap _map; - private Iterator _currentIterator; - private int _currentIndex; - - public RestoreIterator(BlockRestoreMap map) - { - _map = map; - _currentIndex = 255; - updateIterator(); - } - - private void updateIterator() - { - _currentIterator = _map.getMap(_currentIndex).values().iterator(); - } - - @Override - public boolean hasNext() - { - while (!_currentIterator.hasNext() && _currentIndex > 0) - { - _currentIndex--; - updateIterator(); - } - - return _currentIterator.hasNext(); - } - - @Override - public BlockData next() - { - while (!_currentIterator.hasNext() && _currentIndex > 0) - { - _currentIndex--; - updateIterator(); - } - - return _currentIterator.next(); - } - } -} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/BlockDataRunnable.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockDataRunnable.java similarity index 88% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/BlockDataRunnable.java rename to Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockDataRunnable.java index 3f1cd1227..99feb9645 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/BlockDataRunnable.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockDataRunnable.java @@ -1,4 +1,4 @@ -package mineplex.core.common.block; +package mineplex.core.blockrestore; import java.util.ArrayList; import java.util.Iterator; @@ -8,6 +8,8 @@ import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; +import mineplex.core.common.block.BlockData; + public class BlockDataRunnable implements Runnable { private JavaPlugin _plugin; @@ -18,12 +20,12 @@ public class BlockDataRunnable implements Runnable private int _blocksPerTick; private Iterator _blockIterator; - public BlockDataRunnable(JavaPlugin plugin, Iterator blockIterator, Runnable onComplete) + public BlockDataRunnable(JavaPlugin plugin, Iterator blockIterator, int blocksPerTick, Runnable onComplete) { _plugin = plugin; _changedBlocks = new ArrayList(); _started = false; - _blocksPerTick = 400; + _blocksPerTick = blocksPerTick; _onComplete = onComplete; _blockIterator = blockIterator; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java index ed640c78f..29cf43003 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestore.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import mineplex.core.MiniPlugin; import mineplex.core.updater.event.UpdateEvent; @@ -26,28 +27,31 @@ import org.bukkit.plugin.java.JavaPlugin; public class BlockRestore extends MiniPlugin { private HashMap _blocks = new HashMap(); + private LinkedList _restoreMaps; public BlockRestore(JavaPlugin plugin) { super("Block Restore", plugin); + + _restoreMaps = new LinkedList(); } @EventHandler(priority=EventPriority.LOW) - public void BlockBreak(BlockBreakEvent event) + public void blockBreak(BlockBreakEvent event) { - if (Contains(event.getBlock())) + if (contains(event.getBlock())) event.setCancelled(true); } @EventHandler(priority=EventPriority.LOW) - public void BlockPlace(BlockPlaceEvent event) + public void blockPlace(BlockPlaceEvent event) { - if (Contains(event.getBlockPlaced())) + if (contains(event.getBlockPlaced())) event.setCancelled(true); } @EventHandler(priority=EventPriority.LOW) - public void Piston(BlockPistonExtendEvent event) + public void piston(BlockPistonExtendEvent event) { if (event.isCancelled()) return; @@ -60,7 +64,7 @@ public class BlockRestore extends MiniPlugin if (push.getType() == Material.AIR) return; - if (Contains(push)) + if (contains(push)) { push.getWorld().playEffect(push.getLocation(), Effect.STEP_SOUND, push.getTypeId()); event.setCancelled(true); @@ -70,7 +74,7 @@ public class BlockRestore extends MiniPlugin } @EventHandler - public void ExpireBlocks(UpdateEvent event) + public void expireBlocks(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; @@ -86,15 +90,15 @@ public class BlockRestore extends MiniPlugin _blocks.remove(cur); } - public void Restore(Block block) + public void restore(Block block) { - if (!Contains(block)) + if (!contains(block)) return; _blocks.remove(block).restore(); } - public void RestoreAll() + public void restoreAll() { for (BlockRestoreData data : _blocks.values()) data.restore(); @@ -102,7 +106,7 @@ public class BlockRestore extends MiniPlugin _blocks.clear(); } - public HashSet RestoreBlockAround(Material type, Location location, int radius) + public HashSet restoreBlockAround(Material type, Location location, int radius) { HashSet restored = new HashSet(); @@ -128,26 +132,26 @@ public class BlockRestore extends MiniPlugin return restored; } - public void Add(Block block, int toID, byte toData, long expireTime) + public void add(Block block, int toID, byte toData, long expireTime) { - Add(block, toID, toData, block.getTypeId(), block.getData(), expireTime); + add(block, toID, toData, block.getTypeId(), block.getData(), expireTime); } - public void Add(Block block, int toID, byte toData, int fromID, byte fromData, long expireTime) + public void add(Block block, int toID, byte toData, int fromID, byte fromData, long expireTime) { - if (!Contains(block)) GetBlocks().put(block, new BlockRestoreData(block, toID, toData, fromID, fromData, expireTime, 0)); - else GetData(block).update(toID, toData, expireTime); + if (!contains(block)) getBlocks().put(block, new BlockRestoreData(block, toID, toData, fromID, fromData, expireTime, 0)); + else getData(block).update(toID, toData, expireTime); } - public void Snow(Block block, byte heightAdd, byte heightMax, long expireTime, long meltDelay, int heightJumps) + public void snow(Block block, byte heightAdd, byte heightMax, long expireTime, long meltDelay, int heightJumps) { //Fill Above - if (((block.getTypeId() == 78 && block.getData() >= (byte)7) || block.getTypeId() == 80) && GetData(block) != null) + if (((block.getTypeId() == 78 && block.getData() >= (byte)7) || block.getTypeId() == 80) && getData(block) != null) { - GetData(block).update(78, heightAdd, expireTime, meltDelay); + getData(block).update(78, heightAdd, expireTime, meltDelay); - if (heightJumps > 0) Snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, heightJumps-1); - if (heightJumps == -1) Snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, -1); + if (heightJumps > 0) snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, heightJumps - 1); + if (heightJumps == -1) snow(block.getRelative(BlockFace.UP), heightAdd, heightMax, expireTime, meltDelay, -1); return; } @@ -187,30 +191,57 @@ public class BlockRestore extends MiniPlugin heightAdd = 0; //Snow - if (!Contains(block)) - GetBlocks().put(block, new BlockRestoreData(block, 78, (byte)Math.max(0, heightAdd-1), block.getTypeId(), block.getData(), expireTime, meltDelay)); + if (!contains(block)) + getBlocks().put(block, new BlockRestoreData(block, 78, (byte) Math.max(0, heightAdd - 1), block.getTypeId(), block.getData(), expireTime, meltDelay)); else - GetData(block).update(78, heightAdd, expireTime, meltDelay); + getData(block).update(78, heightAdd, expireTime, meltDelay); } - public boolean Contains(Block block) + public boolean contains(Block block) { - if (GetBlocks().containsKey(block)) + if (getBlocks().containsKey(block)) return true; + + for (BlockRestoreMap restoreMap : _restoreMaps) + { + if (restoreMap.contains(block)) + return true; + } + return false; } - public BlockRestoreData GetData(Block block) + public BlockRestoreData getData(Block block) { if (_blocks.containsKey(block)) return _blocks.get(block); return null; } - public HashMap GetBlocks() + public HashMap getBlocks() { return _blocks; } - + public BlockRestoreMap createMap() + { + BlockRestoreMap map = new BlockRestoreMap(this); + _restoreMaps.add(map); + return map; + } + + protected void removeMap(BlockRestoreMap blockRestore) + { + _restoreMaps.remove(blockRestore); + } + + @Override + public void disable() + { + // Clear all restore maps + for (BlockRestoreMap restoreMap : _restoreMaps) + { + restoreMap.restoreInstant(); + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java new file mode 100644 index 000000000..37de3d7d7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java @@ -0,0 +1,175 @@ +package mineplex.core.blockrestore; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.Material; +import org.bukkit.block.Block; + +import mineplex.core.common.block.BlockData; + +public class BlockRestoreMap +{ + private BlockRestore _blockRestore; + // The rate at which we restore blocks + private int _blocksPerTick; + // Easy access to all the blocks we have modified + private HashSet _changedBlocks; + // A hashmap for each level, so we can quickly restore top down + private HashMap[] _blocks; + + protected BlockRestoreMap(BlockRestore blockRestore) + { + this(blockRestore, 200); + } + + protected BlockRestoreMap(BlockRestore blockRestore, int blocksPerTick) + { + _blockRestore = blockRestore; + _blocksPerTick = blocksPerTick; + _changedBlocks = new HashSet(); + _blocks = new HashMap[256]; + + // Populate Array + for (int i = 0; i < 256; i++) + { + _blocks[i] = new HashMap(); + } + } + + public void addBlockData(BlockData blockData) + { + Block block = blockData.Block; + + if (!_blocks[block.getY()].containsKey(block)) + _blocks[block.getY()].put(block, blockData); + + _changedBlocks.add(blockData.Block); + } + + public void set(Block block, Material material) + { + set(block, material, (byte) 0); + } + + public void set(Block block, Material material, byte toData) + { + set(block, material.getId(), toData); + } + + public void set(Block block, int toId, byte toData) + { + addBlockData(new BlockData(block)); + + block.setTypeIdAndData(toId, toData, false); + } + + public boolean contains(Block block) + { + return _changedBlocks.contains(block); + } + + public HashSet getChangedBlocks() + { + return _changedBlocks; + } + + /** + * Restore all the blocks changed in this BlockRestoreMap + * NOTE: You should not use the same BlockRestoreMap instance after you run restore. + * You must initialize a new BlockRestoreMap from BlockRestore + */ + public void restore() + { + // The idea behind this is that the runnable will restore blocks over time + // If the server happens to shutdown while the runnable is running, we will still + // restore all our blocks with restoreInstant (as called by BlockRestore) + BlockDataRunnable runnable = new BlockDataRunnable(_blockRestore.getPlugin(), new RestoreIterator(), _blocksPerTick, new Runnable() + { + @Override + public void run() + { + clearMaps(); + _blockRestore.removeMap(BlockRestoreMap.this); + } + }); + runnable.start(); + } + + private void clearMaps() + { + for (int i = 0; i < 256; i++) + { + _blocks[i].clear(); + } + + _changedBlocks.clear(); + } + + public void restoreInstant() + { + for (int i = 0; i < 256; i++) + { + HashMap map = _blocks[i]; + for (BlockData data : map.values()) + { + data.restore(); + } + } + + clearMaps(); + } + + public int getBlocksPerTick() + { + return _blocksPerTick; + } + + public void setBlocksPerTick(int blocksPerTick) + { + _blocksPerTick = blocksPerTick; + } + + private class RestoreIterator implements Iterator + { + private Iterator _currentIterator; + private int _currentIndex; + + public RestoreIterator() + { + _currentIndex = 255; + updateIterator(); + } + + private void updateIterator() + { + _currentIterator = _blocks[_currentIndex].values().iterator(); + } + + @Override + public boolean hasNext() + { + while (!_currentIterator.hasNext() && _currentIndex > 0) + { + _currentIndex--; + updateIterator(); + } + + return _currentIterator.hasNext(); + } + + @Override + public BlockData next() + { + while (!_currentIterator.hasNext() && _currentIndex > 0) + { + _currentIndex--; + updateIterator(); + } + + return _currentIterator.next(); + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java index b53fccd66..c30bb11eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java @@ -134,7 +134,7 @@ public class Explosion extends MiniPlugin else { int heightDiff = cur.getLocation().getBlockY() - event.getEntity().getLocation().getBlockY(); - _blockRestore.Add(cur, 0, (byte)0, (long) (20000 + (heightDiff*3000) + Math.random()*2900)); + _blockRestore.add(cur, 0, (byte) 0, (long) (20000 + (heightDiff * 3000) + Math.random() * 2900)); } } @@ -239,7 +239,7 @@ public class Explosion extends MiniPlugin { if (_temporaryDebris) { - _blockRestore.Add(block, cur.getBlockId(), cur.getBlockData(), 10000); + _blockRestore.add(block, cur.getBlockId(), cur.getBlockData(), 10000); } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java index 34d4ed557..859f1e3e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintballGun.java @@ -96,9 +96,9 @@ public class ItemPaintballGun extends ItemGadget continue; if (block.getType() == Material.CARPET) - Manager.getBlockRestore().Add(block, 171, color, 4000); + Manager.getBlockRestore().add(block, 171, color, 4000); else - Manager.getBlockRestore().Add(block, 35, color, 4000); + Manager.getBlockRestore().add(block, 35, color, 4000); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java index 72eb662da..40d5a7d93 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java @@ -242,7 +242,7 @@ public class ClansDataAccessLayer Block down = UtilBlock.getHighest(c.getWorld(), c.getBlock(x, 0, z).getX(), c.getBlock(x, 0, z).getZ()).getRelative(BlockFace.DOWN); if (down.getTypeId() == 1 || down.getTypeId() == 2 || down.getTypeId() == 3 || down.getTypeId() == 12 || down.getTypeId() == 8) - _manager.getBlockRestore().Add(down, 89, (byte)0, 180000); + _manager.getBlockRestore().add(down, 89, (byte) 0, 180000); } //Log diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index 6b1f8d233..5b0a0ea4b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -156,9 +156,9 @@ public class ClansGame extends MiniPlugin { public void run() { - Clans.getBlockRestore().Add(block, 65, block.getData(), 30000); + Clans.getBlockRestore().add(block, 65, block.getData(), 30000); - BlockRestoreData data = Clans.getBlockRestore().GetData(block); + BlockRestoreData data = Clans.getBlockRestore().getData(block); if (data != null) { data.setFromId(0); 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 9243b8125..7a8de58c3 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 @@ -176,7 +176,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat ClanEnergyManager clanEnergyManager = new ClanEnergyManager(plugin, this, clientManager, donationManager); LootManager lootManager = new LootManager(gearManager, goldManager); - _worldEvent = new WorldEventManager(plugin, this, damageManager, lootManager); + _worldEvent = new WorldEventManager(plugin, this, damageManager, lootManager, blockRestore); for (ClanToken token : _clanDataAccess.getRepository().retrieveClans()) { @@ -606,6 +606,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat { // Kind of confusing, Clans.java calls this so that we can pass the disable event to WorldEventManager // This is so that we can prevent any permanent world changes with events + _blockRestore.onDisable(); _worldEvent.onDisable(); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index f6b85a046..f1150bf3d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -20,6 +20,7 @@ import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; +import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -44,11 +45,12 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement private EventTerrainFinder _terrainFinder; private DamageManager _damageManager; private LootManager _lootManager; + private BlockRestore _blockRestore; private long _lastEventEnd; private long _nextEventStart; - public WorldEventManager(JavaPlugin plugin, ClansManager clansManager, DamageManager damageManager, LootManager lootManager) + public WorldEventManager(JavaPlugin plugin, ClansManager clansManager, DamageManager damageManager, LootManager lootManager, BlockRestore blockRestore) { super("World Event", plugin); @@ -57,6 +59,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement _clansManager = clansManager; _damageManager = damageManager; _lootManager = lootManager; + _blockRestore = blockRestore; _events = new LinkedList(); _lastEventEnd = System.currentTimeMillis(); updateNextEventTime(); @@ -89,7 +92,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement iterator.remove(); // If the event was cancelled, we don't need to run a cleanup - if (worldEvent.getState() == EventState.COMPLETE) worldEvent.cleanup(false); + if (worldEvent.getState() == EventState.COMPLETE) worldEvent.cleanup(); removed = true; _lastEventEnd = System.currentTimeMillis(); @@ -237,6 +240,11 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return output; } + public BlockRestore getBlockRestore() + { + return _blockRestore; + } + @EventHandler public void gear(PlayerCommandPreprocessEvent event) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/WorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/WorldEvent.java index 431f50c4c..040dd76eb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/WorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/WorldEvent.java @@ -1,7 +1,6 @@ package mineplex.game.clans.clans.worldevent.event; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Random; @@ -12,16 +11,14 @@ import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockPhysicsEvent; -import mineplex.core.common.block.BlockRestoreMap; +import mineplex.core.blockrestore.BlockRestoreMap; import mineplex.core.common.block.schematic.SchematicRunnable; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; import mineplex.core.common.block.BlockData; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilWorld; import mineplex.core.updater.UpdateType; @@ -65,7 +62,7 @@ public abstract class WorldEvent implements Listener _ticks = 0; _creatures = new ArrayList(); - _blocks = new BlockRestoreMap(); + _blocks = eventManager.getBlockRestore().createMap(); _lastActive = System.currentTimeMillis(); } @@ -76,10 +73,10 @@ public abstract class WorldEvent implements Listener protected abstract void customStart(); - public final void cleanup(boolean quick) + public final void cleanup() { clearCreatures(); - restoreBlocks(quick); + restoreBlocks(); customCleanup(); } @@ -90,7 +87,7 @@ public abstract class WorldEvent implements Listener public final void cancel() { - cleanup(true); + cleanup(); setState(EventState.CANCELLED); customCancel(); } @@ -190,23 +187,9 @@ public abstract class WorldEvent implements Listener _creatures.clear(); } - public void restoreBlocks(boolean quick) + public void restoreBlocks() { - if (quick) - { - _blocks.restore(); - } - else - { - _blocks.restoreTopDown(_eventManager.getPlugin(), new Runnable() - { - @Override - public void run() - { - - } - }); - } + _blocks.restore(); } public long getLastActive() @@ -257,7 +240,7 @@ public abstract class WorldEvent implements Listener public void setBlock(Block block, int id, byte data) { - _blocks.setBlock(block, id, data); + _blocks.set(block, id, data); } public ArrayList getScoreboardLines() @@ -304,11 +287,4 @@ public abstract class WorldEvent implements Listener if (getTicks() > 6000) cancel(); } - - @EventHandler - public void onPhysics(BlockPhysicsEvent event) - { - if (_blocks.getChangedBlocks().contains(event.getBlock())) - event.setCancelled(true); - } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/creature/UndeadWarrior.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/creature/UndeadWarrior.java index 21c82dc69..e884b189c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/creature/UndeadWarrior.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/creature/UndeadWarrior.java @@ -75,6 +75,7 @@ public class UndeadWarrior extends EventCreature if (dist <= 3 || dist > 16) return; + double power = 0.8 + (1.2 * ((dist-3)/13d)); //Leap diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index 8b7e87d8f..2ea89a33f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.HashSet; import mineplex.core.MiniPlugin; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.core.itemstack.ItemStackFactory; @@ -12,7 +11,6 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilGear; @@ -24,9 +22,7 @@ import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.game.clans.clans.ClansManager; import org.bukkit.ChatColor; -import org.bukkit.Color; import org.bukkit.Effect; -import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Biome; @@ -46,7 +42,6 @@ import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.plugin.java.JavaPlugin; public class Gameplay extends MiniPlugin @@ -76,14 +71,14 @@ public class Gameplay extends MiniPlugin if (event.getBucket() == Material.WATER_BUCKET) { block.setTypeIdAndData(8, (byte)1, true); - _blockRestore.Add(event.getBlockClicked().getRelative(event.getBlockFace()), 8, (byte)0, 1000); + _blockRestore.add(event.getBlockClicked().getRelative(event.getBlockFace()), 8, (byte) 0, 1000); _bucketWater.put(block, System.currentTimeMillis()); } if (event.getBucket() == Material.LAVA_BUCKET) { block.setTypeIdAndData(10, (byte)6, true); - _blockRestore.Add(event.getBlockClicked().getRelative(event.getBlockFace()), 10, (byte)0, 2000); + _blockRestore.add(event.getBlockClicked().getRelative(event.getBlockFace()), 10, (byte) 0, 2000); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index c02a3c6a0..e43c8c360 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -248,7 +248,7 @@ public class WorldManager extends MiniPlugin for (Block block : UtilBlock.getInRadius(player.getLocation(), 3d).keySet()) { if (block.getType() == Material.PUMPKIN) - Manager.GetBlockRestore().Add(block, 91, block.getData(), 2000); + Manager.GetBlockRestore().add(block, 91, block.getData(), 2000); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java index 9bf9994fc..204129272 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java @@ -26,7 +26,6 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilServer; @@ -284,7 +283,7 @@ public class BlockToss extends SkillCharge implements IThrown block.setTypeIdAndData(0, (byte)0, false); //Block Replace - Factory.BlockRestore().Add(block, fall.getBlockId(), (byte)0, 10000); + Factory.BlockRestore().add(block, fall.getBlockId(), (byte) 0, 10000); //Effect block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java index dcd433766..6fc08942b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java @@ -3,8 +3,6 @@ package mineplex.minecraft.game.classcombat.Skill.Mage; import java.util.HashMap; import java.util.HashSet; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; @@ -27,7 +25,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; @@ -158,10 +155,10 @@ public class ArcticArmor extends Skill if (!block.getRelative(BlockFace.UP).isLiquid()) if (block.getLocation().getY() <= cur.getLocation().getY()) if (block.getTypeId() == 8 || block.getTypeId() == 9 || block.getTypeId() == 79) - Factory.BlockRestore().Add(block, 79, (byte)0, (long)(duration * (1 + blocks.get(block)))); + Factory.BlockRestore().add(block, 79, (byte) 0, (long) (duration * (1 + blocks.get(block)))); //Snow - Factory.BlockRestore().Snow(block, (byte)0, (byte)0, (long)(duration * (1 + blocks.get(block))), 250, 0); + Factory.BlockRestore().snow(block, (byte) 0, (byte) 0, (long) (duration * (1 + blocks.get(block))), 250, 0); } } } @@ -194,7 +191,7 @@ public class ArcticArmor extends Skill if (cur.getEyeLocation().getBlock().getType() == Material.ICE) { - if (!Factory.BlockRestore().Contains(cur.getEyeLocation().getBlock())) + if (!Factory.BlockRestore().contains(cur.getEyeLocation().getBlock())) continue; Player damager = null; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java index 5616119ee..ca7f8e68a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Blizzard.java @@ -181,7 +181,7 @@ public class Blizzard extends SkillActive HashMap blocks = UtilBlock.getInRadius(target.getLocation(), 2d, 1); for (Block block : blocks.keySet()) { - Factory.BlockRestore().Snow(block, (byte)(1 + (int)(2*blocks.get(block))), (byte)(7*level), 2500, 250, 3); + Factory.BlockRestore().snow(block, (byte) (1 + (int) (2 * blocks.get(block))), (byte) (7 * level), 2500, 250, 3); } //Effect @@ -221,7 +221,7 @@ public class Blizzard extends SkillActive if (_snowball.remove(event.getEntity()) == null) return; - Factory.BlockRestore().Snow(event.getEntity().getLocation().getBlock(), (byte)1, (byte)7, 2000, 250, 0); + Factory.BlockRestore().snow(event.getEntity().getLocation().getBlock(), (byte) 1, (byte) 7, 2000, 250, 0); } @EventHandler diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java index cdfb985fe..0d4682eca 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FissureData.java @@ -127,11 +127,11 @@ public class FissureData } //Boost Column - if (block.getTypeId() == 1) Host.Factory.BlockRestore().Add(block, 4, block.getData(), 14000); - if (block.getTypeId() == 2) Host.Factory.BlockRestore().Add(block, 3, block.getData(), 14000); - if (block.getTypeId() == 98) Host.Factory.BlockRestore().Add(block, 98, (byte)2, 14000); + if (block.getTypeId() == 1) Host.Factory.BlockRestore().add(block, 4, block.getData(), 14000); + if (block.getTypeId() == 2) Host.Factory.BlockRestore().add(block, 3, block.getData(), 14000); + if (block.getTypeId() == 98) Host.Factory.BlockRestore().add(block, 98, (byte) 2, 14000); - Host.Factory.BlockRestore().Add(up, block.getTypeId(), block.getData(), 10000 - (1000 * _height)); + Host.Factory.BlockRestore().add(up, block.getTypeId(), block.getData(), 10000 - (1000 * _height)); _height++; //Effect diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FreezingBlast.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FreezingBlast.java index 5a60452db..803094b5f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FreezingBlast.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/FreezingBlast.java @@ -121,7 +121,7 @@ public class FreezingBlast extends SkillActive implements IThrown { if (UtilBlock.airFoliage(cur) && UtilBlock.solid(cur.getRelative(BlockFace.DOWN))) { - Factory.BlockRestore().Snow(cur, (byte)(7 * blocks.get(cur)), (byte)7, (long)(15000 * (1 + blocks.get(cur))), 1000, 0); + Factory.BlockRestore().snow(cur, (byte) (7 * blocks.get(cur)), (byte) 7, (long) (15000 * (1 + blocks.get(cur))), 1000, 0); cur.getWorld().playEffect(cur.getLocation(), Effect.STEP_SOUND, 80); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java index 339669ce4..945431436 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/IcePrison.java @@ -3,11 +3,9 @@ package mineplex.minecraft.game.classcombat.Skill.Mage; import java.util.HashMap; import org.bukkit.Effect; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -154,7 +152,7 @@ public class IcePrison extends SkillActive implements IThrown time -= yDiff * 1000 - Math.random() * 1000; - Factory.BlockRestore().Add(freeze, 79, (byte)0, time); + Factory.BlockRestore().add(freeze, 79, (byte) 0, time); freeze.getWorld().playEffect(freeze.getLocation(), Effect.STEP_SOUND, 79); } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java index a8bce9d3c..243b135c3 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBonds.java @@ -1,11 +1,8 @@ package mineplex.minecraft.game.classcombat.Skill.Mage; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import org.bukkit.Effect; -import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Item; @@ -22,14 +19,10 @@ import mineplex.core.common.util.F; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; -import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; @@ -297,7 +290,7 @@ public class LifeBonds extends Skill if (cur.getItemStack().getData() != null) data = cur.getItemStack().getData().getData(); - Factory.BlockRestore().Add(block, cur.getItemStack().getTypeId(), data, 2000); + Factory.BlockRestore().add(block, cur.getItemStack().getTypeId(), data, 2000); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java index c8540af14..a45879306 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/Web.java @@ -74,7 +74,7 @@ public class Web extends ItemUsable if (!UtilBlock.airFoliage(ent.getLocation().getBlock())) return; - Factory.BlockRestore().Add(ent.getLocation().getBlock(), 30, (byte)0, 6000); + Factory.BlockRestore().add(ent.getLocation().getBlock(), 30, (byte) 0, 6000); ent.remove(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index 74f919373..b79178c34 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -884,7 +884,7 @@ public class CastleSiege extends TeamGame UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f); - Manager.GetBlockRestore().Add(event.getClickedBlock(), 0, (byte)0, 1000); + Manager.GetBlockRestore().add(event.getClickedBlock(), 0, (byte) 0, 1000); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index 9b9ba8816..d8b32a7eb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -582,7 +582,7 @@ public class DragonEscape extends SoloGame _tunneled.put(new BlockData(event.getBlock()), player); - Manager.GetBlockRestore().Add(event.getBlock(), 0, (byte)0, 2400); + Manager.GetBlockRestore().add(event.getBlock(), 0, (byte) 0, 2400); UtilInv.remove(player, Material.DIAMOND_PICKAXE, (byte)0, 1); } @@ -593,8 +593,8 @@ public class DragonEscape extends SoloGame if (event.isCancelled()) return; - Manager.GetBlockRestore().Add(event.getBlock(), - event.getPlayer().getItemInHand().getType().getId(), event.getPlayer().getItemInHand().getData().getData(), + Manager.GetBlockRestore().add(event.getBlock(), + event.getPlayer().getItemInHand().getType().getId(), event.getPlayer().getItemInHand().getData().getData(), event.getBlockReplacedState().getTypeId(), event.getBlockReplacedState().getRawData(), 2400); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java index 13d88b358..3a8a07c4a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/waves/WaveBase.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -15,7 +14,6 @@ import nautilus.game.arcade.game.games.halloween.HalloweenAudio; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilBlockText; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTextMiddle; @@ -104,18 +102,18 @@ public abstract class WaveBase //Beacon Block block = total.toLocation(locs.get(0).getWorld()).getBlock().getRelative(BlockFace.DOWN); - Host.Manager.GetBlockRestore().Add(block, 138, (byte)0, _duration); + Host.Manager.GetBlockRestore().add(block, 138, (byte) 0, _duration); for (int x=-1 ; x<=1 ; x++) for (int z=-1 ; z<=1 ; z++) - Host.Manager.GetBlockRestore().Add(block.getRelative(x, -1, z), 42, (byte)0, _duration); + Host.Manager.GetBlockRestore().add(block.getRelative(x, -1, z), 42, (byte) 0, _duration); //Clear Laser while (block.getY() < 250) { block = block.getRelative(BlockFace.UP); if (block.getType() != Material.AIR) - Host.Manager.GetBlockRestore().Add(block, 0, (byte)0, _duration); + Host.Manager.GetBlockRestore().add(block, 0, (byte) 0, _duration); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java index c4f5a47ed..8a44b18ae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java @@ -10,7 +10,6 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Effect; -import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -2109,7 +2108,7 @@ public class MineStrike extends TeamGame //Incendiary _incendiary.clear(); - Manager.GetBlockRestore().RestoreAll(); + Manager.GetBlockRestore().restoreAll(); //Restock Ammo for (Gun gun : _gunsEquipped.keySet()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FireGrenadeBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FireGrenadeBase.java index a94e0ee44..0e5feed9f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FireGrenadeBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FireGrenadeBase.java @@ -74,7 +74,7 @@ public abstract class FireGrenadeBase extends Grenade public void run() { if (round == game.getRound() && !game.isFreezeTime()) - game.Manager.GetBlockRestore().Add(block, 51, (byte)0, (long) (_baseTime + blocks.get(block) * _baseTime)); + game.Manager.GetBlockRestore().add(block, 51, (byte) 0, (long) (_baseTime + blocks.get(block) * _baseTime)); } }, 60 - (int)(60d * blocks.get(block))); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java index 1857f7a30..a526653d2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java @@ -36,7 +36,7 @@ public class Smoke extends Grenade ent.getWorld().playSound(ent.getLocation(), Sound.FIZZ, 0.1f, 0.1f); - for (Location loc : game.Manager.GetBlockRestore().RestoreBlockAround(Material.FIRE, ent.getLocation(), 5)) + for (Location loc : game.Manager.GetBlockRestore().restoreBlockAround(Material.FIRE, ent.getLocation(), 5)) { loc.getWorld().playSound(loc, Sound.FIZZ, 1f, 1f); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index e8ea4d5f3..e2ab3b724 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -443,7 +443,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer if (dist < radius) { - Manager.GetBlockRestore().Add(data.Block, 0, (byte)0, data.Material.getId(), data.Data, (long) (6000 * (dist/radius))); + Manager.GetBlockRestore().add(data.Block, 0, (byte) 0, data.Material.getId(), data.Data, (long) (6000 * (dist / radius))); dataIt.remove(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArcticAura.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArcticAura.java index ece2ee4b7..1919303f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArcticAura.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArcticAura.java @@ -41,7 +41,7 @@ public class PerkArcticAura extends Perk for (Block block : blocks.keySet()) { //Snow - Manager.GetBlockRestore().Snow(block, (byte)1, (byte)1, (long)(duration * (1 + blocks.get(block))), 250, 0); + Manager.GetBlockRestore().snow(block, (byte) 1, (byte) 1, (long) (duration * (1 + blocks.get(block))), 250, 0); } for (Player other : Manager.GetGame().GetPlayers(true)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java index 93b52fbda..cdc508084 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlizzard.java @@ -129,6 +129,6 @@ public class PerkBlizzard extends Perk if (_snowball.remove(event.getEntity()) == null) return; - Manager.GetBlockRestore().Snow(event.getEntity().getLocation().getBlock(), (byte)1, (byte)7, 2000, 250, 0); + Manager.GetBlockRestore().snow(event.getEntity().getLocation().getBlock(), (byte) 1, (byte) 7, 2000, 250, 0); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlockToss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlockToss.java index c65127338..0d949c174 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlockToss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlockToss.java @@ -75,7 +75,7 @@ public class PerkBlockToss extends SmashPerk implements IThrown if (UtilBlock.usable(grab)) return; - if (!UtilBlock.airFoliage(grab.getRelative(BlockFace.UP)) || Manager.GetBlockRestore().Contains(grab.getRelative(BlockFace.UP))) + if (!UtilBlock.airFoliage(grab.getRelative(BlockFace.UP)) || Manager.GetBlockRestore().contains(grab.getRelative(BlockFace.UP))) { UtilPlayer.message(player, F.main("Game", "You can only pick up blocks with Air above them.")); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIcePath.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIcePath.java index 61b79625a..c49b80976 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIcePath.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIcePath.java @@ -89,7 +89,7 @@ public class PerkIcePath extends Perk else { block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 79); - Manager.GetBlockRestore().Add(block, 79, (byte)0, 6000); + Manager.GetBlockRestore().add(block, 79, (byte) 0, 6000); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronShell.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronShell.java index dcdbbac20..269396b52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronShell.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronShell.java @@ -66,7 +66,7 @@ public class PerkIronShell extends Perk if (cur.getY() < block.getLocation().getY()) continue; - Manager.GetBlockRestore().Add(cur, 42, (byte)0, 12000); + Manager.GetBlockRestore().add(cur, 42, (byte) 0, 12000); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpidersNest.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpidersNest.java index 7f72477ce..0bd72c5a9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpidersNest.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpidersNest.java @@ -48,7 +48,7 @@ public class PerkSpidersNest extends SmashPerk if (block.getY() < player.getLocation().getY() - 10) continue; - Manager.GetBlockRestore().Add(block, 30, (byte)0, (long) (30000 + 5000 * Math.random())); + Manager.GetBlockRestore().add(block, 30, (byte) 0, (long) (30000 + 5000 * Math.random())); } //Regen diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWeb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWeb.java index e61587621..2e40fe70d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWeb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWeb.java @@ -134,6 +134,6 @@ public class PerkWeb extends Perk implements IThrown Location loc = data.GetThrown().getLocation(); data.GetThrown().remove(); - Manager.GetBlockRestore().Add(loc.getBlock(), 30, (byte)0, 4000); + Manager.GetBlockRestore().add(loc.getBlock(), 30, (byte) 0, 4000); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWebShot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWebShot.java index 699067767..f16829832 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWebShot.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWebShot.java @@ -93,7 +93,7 @@ public class PerkWebShot extends SmashPerk implements IThrown { data.GetThrown().remove(); - Manager.GetBlockRestore().Add(target.getLocation().getBlock(), 30, (byte)0, 3000); + Manager.GetBlockRestore().add(target.getLocation().getBlock(), 30, (byte) 0, 3000); //Damage Event Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, @@ -126,6 +126,6 @@ public class PerkWebShot extends SmashPerk implements IThrown data.GetThrown().remove(); if (data.GetThrown().getTicksLived() > 3) - Manager.GetBlockRestore().Add(loc.getBlock(), 30, (byte)0, 2000); + Manager.GetBlockRestore().add(loc.getBlock(), 30, (byte) 0, 2000); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherWeb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherWeb.java index 161e77251..9e270d6f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherWeb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherWeb.java @@ -7,8 +7,6 @@ import org.bukkit.block.Block; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -16,10 +14,8 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.itemstack.ItemStackFactory; @@ -106,6 +102,6 @@ public class PerkWitherWeb extends Perk implements IThrown data.GetThrown().remove(); if (data.GetThrown().getTicksLived() > 3) - Manager.GetBlockRestore().Add(loc.getBlock(), 30, (byte)0, 3000); + Manager.GetBlockRestore().add(loc.getBlock(), 30, (byte) 0, 3000); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java index 8615521fb..f9b96f0df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java @@ -22,7 +22,6 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -166,7 +165,7 @@ public class PerkWoolBomb extends Perk implements IThrown //Make Block Block block = thrown.getLocation().getBlock(); - Manager.GetBlockRestore().Restore(block); + Manager.GetBlockRestore().restore(block); _active.put(player, new WoolBombData(block)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieRot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieRot.java index d3da06539..a3869f76f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieRot.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkZombieRot.java @@ -10,7 +10,6 @@ import org.bukkit.event.EventHandler; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.kit.SmashPerk; @@ -47,7 +46,7 @@ public class PerkZombieRot extends SmashPerk continue; //Snow - Manager.GetBlockRestore().Add(block, 159, (byte)12, 3000); + Manager.GetBlockRestore().add(block, 159, (byte) 12, 3000); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/FissureData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/FissureData.java index 3c3b99a2a..c603782f7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/FissureData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/FissureData.java @@ -9,7 +9,6 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilWorld; import nautilus.game.arcade.kit.perks.PerkFissure; import org.bukkit.Effect; @@ -134,11 +133,11 @@ public class FissureData } //Boost Column - if (block.getTypeId() == 1) Host.Manager.GetBlockRestore().Add(block, 4, block.getData(), 14000); - if (block.getTypeId() == 2) Host.Manager.GetBlockRestore().Add(block, 3, block.getData(), 14000); - if (block.getTypeId() == 98) Host.Manager.GetBlockRestore().Add(block, 98, (byte)2, 14000); + if (block.getTypeId() == 1) Host.Manager.GetBlockRestore().add(block, 4, block.getData(), 14000); + if (block.getTypeId() == 2) Host.Manager.GetBlockRestore().add(block, 3, block.getData(), 14000); + if (block.getTypeId() == 98) Host.Manager.GetBlockRestore().add(block, 98, (byte) 2, 14000); - Host.Manager.GetBlockRestore().Add(up, block.getTypeId(), block.getData(), 10000 - (1000 * _height)); + Host.Manager.GetBlockRestore().add(up, block.getTypeId(), block.getData(), 10000 - (1000 * _height)); _height++; //Effect