Improved block restore for Events

This commit is contained in:
Shaun Bennett 2015-06-30 22:30:49 -05:00
parent 0fce46f504
commit 9ccc85a79e
41 changed files with 312 additions and 285 deletions

View File

@ -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<Block> _changedBlocks;
private HashMap<Block, BlockData>[] _blocks;
public BlockRestoreMap()
{
_changedBlocks = new HashSet<Block>();
_blocks = new HashMap[256];
for (int i = 0; i < 256; i++)
{
_blocks[i] = new HashMap<Block, BlockData>();
}
}
private HashMap<Block, BlockData> getMap(int index)
{
return _blocks[index];
}
public HashSet<Block> 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<Block, BlockData> map = _blocks[i];
for (BlockData data : map.values())
{
data.restore();
}
map.clear();
}
}
private static class RestoreIterator implements Iterator<BlockData>
{
private BlockRestoreMap _map;
private Iterator<BlockData> _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();
}
}
}

View File

@ -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<BlockData> _blockIterator;
public BlockDataRunnable(JavaPlugin plugin, Iterator<BlockData> blockIterator, Runnable onComplete)
public BlockDataRunnable(JavaPlugin plugin, Iterator<BlockData> blockIterator, int blocksPerTick, Runnable onComplete)
{
_plugin = plugin;
_changedBlocks = new ArrayList<BlockData>();
_started = false;
_blocksPerTick = 400;
_blocksPerTick = blocksPerTick;
_onComplete = onComplete;
_blockIterator = blockIterator;
}

View File

@ -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<Block, BlockRestoreData> _blocks = new HashMap<Block, BlockRestoreData>();
private LinkedList<BlockRestoreMap> _restoreMaps;
public BlockRestore(JavaPlugin plugin)
{
super("Block Restore", plugin);
_restoreMaps = new LinkedList<BlockRestoreMap>();
}
@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<Location> RestoreBlockAround(Material type, Location location, int radius)
public HashSet<Location> restoreBlockAround(Material type, Location location, int radius)
{
HashSet<Location> restored = new HashSet<Location>();
@ -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<Block, BlockRestoreData> GetBlocks()
public HashMap<Block, BlockRestoreData> 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();
}
}
}

View File

@ -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<Block> _changedBlocks;
// A hashmap for each level, so we can quickly restore top down
private HashMap<Block, BlockData>[] _blocks;
protected BlockRestoreMap(BlockRestore blockRestore)
{
this(blockRestore, 200);
}
protected BlockRestoreMap(BlockRestore blockRestore, int blocksPerTick)
{
_blockRestore = blockRestore;
_blocksPerTick = blocksPerTick;
_changedBlocks = new HashSet<Block>();
_blocks = new HashMap[256];
// Populate Array
for (int i = 0; i < 256; i++)
{
_blocks[i] = new HashMap<Block, BlockData>();
}
}
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<Block> 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<Block, BlockData> 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<BlockData>
{
private Iterator<BlockData> _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();
}
}
}

View File

@ -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
{

View File

@ -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);
}
}

View File

@ -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

View File

@ -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);

View File

@ -176,7 +176,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> 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<ClientClan> 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();
}
}

View File

@ -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<WorldEvent>();
_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)
{

View File

@ -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<EventCreature>();
_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<String> 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);
}
}

View File

@ -75,6 +75,7 @@ public class UndeadWarrior extends EventCreature<Zombie>
if (dist <= 3 || dist > 16)
return;
double power = 0.8 + (1.2 * ((dist-3)/13d));
//Leap

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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());

View File

@ -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;

View File

@ -181,7 +181,7 @@ public class Blizzard extends SkillActive
HashMap<Block, Double> 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

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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();
}

View File

@ -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

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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())

View File

@ -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)));
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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))

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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);
}
}
}

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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));

View File

@ -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);
}
}

View File

@ -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