wolf tackle fix

HG furnace no use
This commit is contained in:
Chiss 2013-11-27 12:48:16 +11:00
parent 0d811272cc
commit f927f2c1be
2 changed files with 136 additions and 135 deletions

View File

@ -105,7 +105,7 @@ public class HungerGames extends SoloGame
private HashMap<Integer, HashMap<Integer, HashSet<Integer>>> _redMap = new HashMap<Integer, HashMap<Integer, HashSet<Integer>>>(); private HashMap<Integer, HashMap<Integer, HashSet<Integer>>> _redMap = new HashMap<Integer, HashMap<Integer, HashSet<Integer>>>();
private HashMap<Player, ArrayList<ChunkChange>> _redChunks = new HashMap<Player, ArrayList<ChunkChange>>(); private HashMap<Player, ArrayList<ChunkChange>> _redChunks = new HashMap<Player, ArrayList<ChunkChange>>();
//Supply Drop //Supply Drop
private ArrayList<Location> _supplyLocations = new ArrayList<Location>(); private ArrayList<Location> _supplyLocations = new ArrayList<Location>();
private Location _supplyCurrent = null; private Location _supplyCurrent = null;
@ -116,7 +116,7 @@ public class HungerGames extends SoloGame
private boolean _deathmatchCountdown = false; private boolean _deathmatchCountdown = false;
private boolean _deathmatchLive = false; private boolean _deathmatchLive = false;
private long _deathmatchTime = 0; private long _deathmatchTime = 0;
//Debug //Debug
private long totalTime = 0; private long totalTime = 0;
@ -148,7 +148,7 @@ public class HungerGames extends SoloGame
}); });
Manager.GetAntiStack().SetEnabled(false); Manager.GetAntiStack().SetEnabled(false);
this.WorldTimeSet = 0; this.WorldTimeSet = 0;
this.SpawnDistanceRequirement = 48; this.SpawnDistanceRequirement = 48;
@ -162,11 +162,11 @@ public class HungerGames extends SoloGame
this.ItemPickup = true; this.ItemPickup = true;
this.CompassEnabled = false; //XXX this.CompassEnabled = false; //XXX
//Blocks //Blocks
this.BlockBreakAllow.add(46); //TNT this.BlockBreakAllow.add(46); //TNT
this.BlockPlaceAllow.add(46); this.BlockPlaceAllow.add(46);
this.BlockBreakAllow.add(30); //Web this.BlockBreakAllow.add(30); //Web
this.BlockPlaceAllow.add(30); this.BlockPlaceAllow.add(30);
@ -184,7 +184,7 @@ public class HungerGames extends SoloGame
this.BlockBreakAllow.add(69); //Lever this.BlockBreakAllow.add(69); //Lever
this.BlockPlaceAllow.add(69); this.BlockPlaceAllow.add(69);
this.BlockBreakAllow.add(18); //Leaves this.BlockBreakAllow.add(18); //Leaves
//SPREAD //SPREAD
@ -232,14 +232,14 @@ public class HungerGames extends SoloGame
public void ParseData() public void ParseData()
{ {
_spawn = UtilWorld.averageLocation(this.GetTeamList().get(0).GetSpawns()); _spawn = UtilWorld.averageLocation(this.GetTeamList().get(0).GetSpawns());
for (Location loc : this.GetTeamList().get(0).GetSpawns()) for (Location loc : this.GetTeamList().get(0).GetSpawns())
loc.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(loc, _spawn))); loc.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(loc, _spawn)));
CreateChestCraftEnchant(); CreateChestCraftEnchant();
_supplyLocations = WorldData.GetDataLocs("WHITE"); _supplyLocations = WorldData.GetDataLocs("WHITE");
if (!WorldData.GetCustomLocs("VARS").isEmpty()) if (!WorldData.GetCustomLocs("VARS").isEmpty())
_maxSpreadRate = WorldData.GetCustomLocs("VARS").get(0).getBlockX(); _maxSpreadRate = WorldData.GetCustomLocs("VARS").get(0).getBlockX();
} }
@ -267,13 +267,13 @@ public class HungerGames extends SoloGame
} }
int spawn = 0; int spawn = 0;
//Chests //Chests
System.out.println("Chests: " + Math.min(250, chests.size())); System.out.println("Chests: " + Math.min(250, chests.size()));
for (int i=0 ; i<250 && !chests.isEmpty() ; i++) for (int i=0 ; i<250 && !chests.isEmpty() ; i++)
{ {
Location loc = chests.remove(UtilMath.r(chests.size())); Location loc = chests.remove(UtilMath.r(chests.size()));
if (UtilMath.offset2d(loc, _spawn) < 8) if (UtilMath.offset2d(loc, _spawn) < 8)
spawn++; spawn++;
} }
@ -285,7 +285,7 @@ public class HungerGames extends SoloGame
spawn++; spawn++;
continue; continue;
} }
loc.getBlock().setType(Material.AIR); loc.getBlock().setType(Material.AIR);
} }
} }
@ -332,7 +332,7 @@ public class HungerGames extends SoloGame
if (GetState() != GameState.Live) if (GetState() != GameState.Live)
return; return;
if (_openedChest.contains(event.getClickedBlock().getLocation())) if (_openedChest.contains(event.getClickedBlock().getLocation()))
return; return;
@ -347,7 +347,7 @@ public class HungerGames extends SoloGame
if (Math.random() > 0.65) count++; if (Math.random() > 0.65) count++;
if (Math.random() > 0.80) count++; if (Math.random() > 0.80) count++;
if (Math.random() > 0.95) count++; if (Math.random() > 0.95) count++;
if (UtilMath.offset(chest.getLocation(), _spawn) < 8) if (UtilMath.offset(chest.getLocation(), _spawn) < 8)
count += 3; count += 3;
@ -355,7 +355,7 @@ public class HungerGames extends SoloGame
{ {
count += UtilMath.r(3); count += UtilMath.r(3);
} }
if (_supplyChests.contains(event.getClickedBlock())) if (_supplyChests.contains(event.getClickedBlock()))
{ {
count = 2; count = 2;
@ -378,7 +378,7 @@ public class HungerGames extends SoloGame
for (int i = 0; i < 3; i++) _baseChestLoot.add(new ItemStack(Material.IRON_CHESTPLATE)); for (int i = 0; i < 3; i++) _baseChestLoot.add(new ItemStack(Material.IRON_CHESTPLATE));
for (int i = 0; i < 5; i++) _baseChestLoot.add(new ItemStack(Material.IRON_LEGGINGS)); for (int i = 0; i < 5; i++) _baseChestLoot.add(new ItemStack(Material.IRON_LEGGINGS));
for (int i = 0; i < 10; i++) _baseChestLoot.add(new ItemStack(Material.IRON_BOOTS)); for (int i = 0; i < 10; i++) _baseChestLoot.add(new ItemStack(Material.IRON_BOOTS));
for (int i = 0; i < 30; i++) _baseChestLoot.add(new ItemStack(Material.CHAINMAIL_HELMET)); for (int i = 0; i < 30; i++) _baseChestLoot.add(new ItemStack(Material.CHAINMAIL_HELMET));
for (int i = 0; i < 20; i++) _baseChestLoot.add(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); for (int i = 0; i < 20; i++) _baseChestLoot.add(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
for (int i = 0; i < 25; i++) _baseChestLoot.add(new ItemStack(Material.CHAINMAIL_LEGGINGS)); for (int i = 0; i < 25; i++) _baseChestLoot.add(new ItemStack(Material.CHAINMAIL_LEGGINGS));
@ -393,24 +393,24 @@ public class HungerGames extends SoloGame
for (int i = 0; i < 90; i++) _baseChestLoot.add(new ItemStack(Material.LEATHER_CHESTPLATE)); for (int i = 0; i < 90; i++) _baseChestLoot.add(new ItemStack(Material.LEATHER_CHESTPLATE));
for (int i = 0; i < 85; i++) _baseChestLoot.add(new ItemStack(Material.LEATHER_LEGGINGS)); for (int i = 0; i < 85; i++) _baseChestLoot.add(new ItemStack(Material.LEATHER_LEGGINGS));
for (int i = 0; i < 100; i++) _baseChestLoot.add(new ItemStack(Material.LEATHER_BOOTS)); for (int i = 0; i < 100; i++) _baseChestLoot.add(new ItemStack(Material.LEATHER_BOOTS));
//Weapons //Weapons
for (int i = 0; i < 70; i++) _baseChestLoot.add(new ItemStack(Material.WOOD_AXE)); for (int i = 0; i < 70; i++) _baseChestLoot.add(new ItemStack(Material.WOOD_AXE));
for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.GOLD_AXE)); for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.GOLD_AXE));
for (int i = 0; i < 35; i++) _baseChestLoot.add(new ItemStack(Material.STONE_AXE)); for (int i = 0; i < 35; i++) _baseChestLoot.add(new ItemStack(Material.STONE_AXE));
for (int i = 0; i < 15; i++) _baseChestLoot.add(new ItemStack(Material.IRON_AXE)); for (int i = 0; i < 15; i++) _baseChestLoot.add(new ItemStack(Material.IRON_AXE));
for (int i = 0; i < 60; i++) _baseChestLoot.add(new ItemStack(Material.WOOD_SWORD)); for (int i = 0; i < 60; i++) _baseChestLoot.add(new ItemStack(Material.WOOD_SWORD));
for (int i = 0; i < 35; i++) _baseChestLoot.add(new ItemStack(Material.GOLD_SWORD)); for (int i = 0; i < 35; i++) _baseChestLoot.add(new ItemStack(Material.GOLD_SWORD));
for (int i = 0; i < 25; i++) _baseChestLoot.add(new ItemStack(Material.STONE_SWORD)); for (int i = 0; i < 25; i++) _baseChestLoot.add(new ItemStack(Material.STONE_SWORD));
for (int i = 0; i < 8; i++) _baseChestLoot.add(new ItemStack(Material.IRON_SWORD)); for (int i = 0; i < 8; i++) _baseChestLoot.add(new ItemStack(Material.IRON_SWORD));
for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.BOW)); for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.BOW));
for (int i = 0; i < 55; i++) _baseChestLoot.add(new ItemStack(Material.ARROW, 4)); for (int i = 0; i < 55; i++) _baseChestLoot.add(new ItemStack(Material.ARROW, 4));
for (int i = 0; i < 15; i++) _baseChestLoot.add(new ItemStack(Material.TNT, 1)); for (int i = 0; i < 15; i++) _baseChestLoot.add(new ItemStack(Material.TNT, 1));
for (int i = 0; i < 30; i++) _baseChestLoot.add(new ItemStack(Material.WEB, 2)); for (int i = 0; i < 30; i++) _baseChestLoot.add(new ItemStack(Material.WEB, 2));
//Food //Food
for (int i = 0; i < 30; i++) _baseChestLoot.add(new ItemStack(Material.MUSHROOM_SOUP)); for (int i = 0; i < 30; i++) _baseChestLoot.add(new ItemStack(Material.MUSHROOM_SOUP));
for (int i = 0; i < 40; i++) _baseChestLoot.add(new ItemStack(Material.COOKED_CHICKEN)); for (int i = 0; i < 40; i++) _baseChestLoot.add(new ItemStack(Material.COOKED_CHICKEN));
@ -420,7 +420,7 @@ public class HungerGames extends SoloGame
for (int i = 0; i < 40; i++) _baseChestLoot.add(new ItemStack(Material.PUMPKIN_PIE)); for (int i = 0; i < 40; i++) _baseChestLoot.add(new ItemStack(Material.PUMPKIN_PIE));
for (int i = 0; i < 50; i++) _baseChestLoot.add(new ItemStack(Material.COOKIE)); for (int i = 0; i < 50; i++) _baseChestLoot.add(new ItemStack(Material.COOKIE));
for (int i = 0; i < 50; i++) _baseChestLoot.add(new ItemStack(Material.ROTTEN_FLESH)); for (int i = 0; i < 50; i++) _baseChestLoot.add(new ItemStack(Material.ROTTEN_FLESH));
for (int i = 0; i < 80; i++) _baseChestLoot.add(new ItemStack(Material.WHEAT, 6)); for (int i = 0; i < 80; i++) _baseChestLoot.add(new ItemStack(Material.WHEAT, 6));
//Misc //Misc
@ -434,16 +434,16 @@ public class HungerGames extends SoloGame
for (int i = 0; i < 80; i++) _baseChestLoot.add(new ItemStack(Material.FEATHER, 6)); for (int i = 0; i < 80; i++) _baseChestLoot.add(new ItemStack(Material.FEATHER, 6));
for (int i = 0; i < 40; i++) _baseChestLoot.add(new ItemStack(Material.BOAT)); for (int i = 0; i < 40; i++) _baseChestLoot.add(new ItemStack(Material.BOAT));
for (int i = 0; i < 70; i++) _baseChestLoot.add(new ItemStack(Material.FISHING_ROD)); for (int i = 0; i < 70; i++) _baseChestLoot.add(new ItemStack(Material.FISHING_ROD));
//Building Supplies //Building Supplies
for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.PISTON_BASE, 4)); for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.PISTON_BASE, 4));
for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.STRING, 4)); for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.STRING, 4));
for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.TRIPWIRE_HOOK, 4)); for (int i = 0; i < 45; i++) _baseChestLoot.add(new ItemStack(Material.TRIPWIRE_HOOK, 4));
/* /*
String material = _baseChestLoot.get(0).getType().toString(); String material = _baseChestLoot.get(0).getType().toString();
double count = 0; double count = 0;
for (int i = 0; i < _baseChestLoot.size(); i++) for (int i = 0; i < _baseChestLoot.size(); i++)
{ {
if (!_baseChestLoot.get(i).getType().toString().equalsIgnoreCase(material)) if (!_baseChestLoot.get(i).getType().toString().equalsIgnoreCase(material))
@ -457,9 +457,9 @@ public class HungerGames extends SoloGame
count++; count++;
} }
} }
System.out.println(material + " " + (count / _baseChestLoot.size() * 100) + "%"); System.out.println(material + " " + (count / _baseChestLoot.size() * 100) + "%");
*/ */
} }
if (_superChestLoot.isEmpty()) if (_superChestLoot.isEmpty())
@ -468,12 +468,12 @@ public class HungerGames extends SoloGame
for (int i = 0; i < 1; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_CHESTPLATE)); for (int i = 0; i < 1; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_CHESTPLATE));
for (int i = 0; i < 2; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_LEGGINGS)); for (int i = 0; i < 2; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_LEGGINGS));
for (int i = 0; i < 3; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_BOOTS)); for (int i = 0; i < 3; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_BOOTS));
for (int i = 0; i < 30; i++) _superChestLoot.add(new ItemStack(Material.IRON_HELMET)); for (int i = 0; i < 30; i++) _superChestLoot.add(new ItemStack(Material.IRON_HELMET));
for (int i = 0; i < 24; i++) _superChestLoot.add(new ItemStack(Material.IRON_CHESTPLATE)); for (int i = 0; i < 24; i++) _superChestLoot.add(new ItemStack(Material.IRON_CHESTPLATE));
for (int i = 0; i < 27; i++) _superChestLoot.add(new ItemStack(Material.IRON_LEGGINGS)); for (int i = 0; i < 27; i++) _superChestLoot.add(new ItemStack(Material.IRON_LEGGINGS));
for (int i = 0; i < 30; i++) _superChestLoot.add(new ItemStack(Material.IRON_BOOTS)); for (int i = 0; i < 30; i++) _superChestLoot.add(new ItemStack(Material.IRON_BOOTS));
for (int i = 0; i < 24; i++) _superChestLoot.add(new ItemStack(Material.IRON_SWORD)); for (int i = 0; i < 24; i++) _superChestLoot.add(new ItemStack(Material.IRON_SWORD));
for (int i = 0; i < 8; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_SWORD)); for (int i = 0; i < 8; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_SWORD));
for (int i = 0; i < 16; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_AXE)); for (int i = 0; i < 16; i++) _superChestLoot.add(new ItemStack(Material.DIAMOND_AXE));
@ -488,7 +488,7 @@ public class HungerGames extends SoloGame
if (stack.getType().getMaxStackSize() > 1) if (stack.getType().getMaxStackSize() > 1)
amount = Math.max(1, UtilMath.r(stack.getAmount())); amount = Math.max(1, UtilMath.r(stack.getAmount()));
if (stack.getTypeId() == 33) if (stack.getTypeId() == 33)
return ItemStackFactory.Instance.CreateStack(stack.getTypeId(), (byte)0, amount, "Barricade"); return ItemStackFactory.Instance.CreateStack(stack.getTypeId(), (byte)0, amount, "Barricade");
@ -505,7 +505,7 @@ public class HungerGames extends SoloGame
{ {
Manager.GetCondition().Factory().Speed("Start Speed", player, player, 30, 1, false, false, false); Manager.GetCondition().Factory().Speed("Start Speed", player, player, 30, 1, false, false, false);
Manager.GetCondition().Factory().HealthBoost("Start Health", player, player, 30, 1, false, false, false); Manager.GetCondition().Factory().HealthBoost("Start Health", player, player, 30, 1, false, false, false);
player.setHealth(player.getMaxHealth()); player.setHealth(player.getMaxHealth());
} }
} }
@ -568,7 +568,7 @@ public class HungerGames extends SoloGame
_redLocations.add(block.getLocation()); _redLocations.add(block.getLocation());
} }
} }
public int RedMax() public int RedMax()
{ {
return _maxSpreadRate;// + (24 - GetPlayers(true).size())*2; return _maxSpreadRate;// + (24 - GetPlayers(true).size())*2;
@ -582,7 +582,7 @@ public class HungerGames extends SoloGame
if (!IsLive()) if (!IsLive())
return; return;
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
if (_redLocations.isEmpty()) if (_redLocations.isEmpty())
@ -663,11 +663,11 @@ public class HungerGames extends SoloGame
{ {
if (block == null || block.getType() == Material.AIR) if (block == null || block.getType() == Material.AIR)
return false; return false;
//Inside Boundary //Inside Boundary
if (UtilMath.offset(_spawn, block.getLocation()) < 48) if (UtilMath.offset(_spawn, block.getLocation()) < 48)
return false; return false;
//Liquid //Liquid
if (block.isLiquid()) if (block.isLiquid())
{ {
@ -689,12 +689,12 @@ public class HungerGames extends SoloGame
} }
if (surroundedByWater) if (surroundedByWater)
return false; return false;
//Dont Spread to Moving //Dont Spread to Moving
if (block.getTypeId() == 9) if (block.getTypeId() == 9)
if (block.getData() != 0) if (block.getData() != 0)
return false; return false;
//Dont spread near moving //Dont spread near moving
for (Block other : UtilBlock.getSurrounding(block, false)) for (Block other : UtilBlock.getSurrounding(block, false))
{ {
@ -750,7 +750,7 @@ public class HungerGames extends SoloGame
{ {
if (!IsLive()) if (!IsLive())
return; return;
MapUtil.ChunkBlockChange(loc, id, data); MapUtil.ChunkBlockChange(loc, id, data);
//Old Style //Old Style
@ -764,14 +764,14 @@ public class HungerGames extends SoloGame
if (Math.abs(player.getLocation().getChunk().getZ() - loc.getChunk().getZ()) > UtilServer.getServer().getViewDistance()) if (Math.abs(player.getLocation().getChunk().getZ() - loc.getChunk().getZ()) > UtilServer.getServer().getViewDistance())
continue; continue;
player.sendBlockChange(loc, id, data); player.sendBlockChange(loc, id, data);
} }
return; return;
} }
*/ */
//Non-Queue //Non-Queue
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
@ -780,10 +780,10 @@ public class HungerGames extends SoloGame
if (Math.abs(player.getLocation().getChunk().getZ() - loc.getChunk().getZ()) > UtilServer.getServer().getViewDistance()) if (Math.abs(player.getLocation().getChunk().getZ() - loc.getChunk().getZ()) > UtilServer.getServer().getViewDistance())
continue; continue;
if (!_redChunks.containsKey(player)) if (!_redChunks.containsKey(player))
_redChunks.put(player, new ArrayList<ChunkChange>()); _redChunks.put(player, new ArrayList<ChunkChange>());
boolean added = false; boolean added = false;
for (ChunkChange change : _redChunks.get(player)) for (ChunkChange change : _redChunks.get(player))
{ {
@ -804,10 +804,10 @@ public class HungerGames extends SoloGame
{ {
if (event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FAST)
return; return;
if (!IsLive()) if (!IsLive())
return; return;
for (Player player : _redChunks.keySet()) for (Player player : _redChunks.keySet())
{ {
//Remove Far Away //Remove Far Away
@ -815,31 +815,31 @@ public class HungerGames extends SoloGame
while (chunkIterator.hasNext()) while (chunkIterator.hasNext())
{ {
ChunkChange change = chunkIterator.next(); ChunkChange change = chunkIterator.next();
if (Math.abs(player.getLocation().getChunk().getX() - change.Chunk.getX()) > UtilServer.getServer().getViewDistance() || if (Math.abs(player.getLocation().getChunk().getX() - change.Chunk.getX()) > UtilServer.getServer().getViewDistance() ||
Math.abs(player.getLocation().getChunk().getZ() - change.Chunk.getZ()) > UtilServer.getServer().getViewDistance()) Math.abs(player.getLocation().getChunk().getZ() - change.Chunk.getZ()) > UtilServer.getServer().getViewDistance())
{ {
chunkIterator.remove(); chunkIterator.remove();
} }
} }
if (_redChunks.get(player).isEmpty()) if (_redChunks.get(player).isEmpty())
continue; continue;
//Get Fittest Chunk to Update //Get Fittest Chunk to Update
int bestId = -1; int bestId = -1;
double bestScore = 0; double bestScore = 0;
for (int i=0 ; i<_redChunks.get(player).size() ; i++) for (int i=0 ; i<_redChunks.get(player).size() ; i++)
{ {
ChunkChange change = _redChunks.get(player).get(i); ChunkChange change = _redChunks.get(player).get(i);
//Base Score, 1 per block //Base Score, 1 per block
double score = change.Changes.size(); double score = change.Changes.size();
//Time Score, multiply block score by 1 + 0.5 per second //Time Score, multiply block score by 1 + 0.5 per second
score = score * (1 + (System.currentTimeMillis() - change.Time)/200d); score = score * (1 + (System.currentTimeMillis() - change.Time)/200d);
//Distance Divisor //Distance Divisor
double dist = 0.5; double dist = 0.5;
if (!player.getLocation().getChunk().equals(change.Chunk)) if (!player.getLocation().getChunk().equals(change.Chunk))
@ -849,20 +849,20 @@ public class HungerGames extends SoloGame
dist = Math.sqrt(x*x + z*z); dist = Math.sqrt(x*x + z*z);
} }
score = score/(dist*dist); score = score/(dist*dist);
if (bestId == -1 || score > bestScore) if (bestId == -1 || score > bestScore)
{ {
bestId = i; bestId = i;
bestScore = score; bestScore = score;
} }
} }
if (bestId == -1) if (bestId == -1)
continue; continue;
//Send MultiBlock or Chunk Update for Fittest Chunk //Send MultiBlock or Chunk Update for Fittest Chunk
ChunkChange change = _redChunks.get(player).remove(bestId); ChunkChange change = _redChunks.get(player).remove(bestId);
if (change.DirtyCount > 63) if (change.DirtyCount > 63)
MapUtil.SendChunkForPlayer(change.Chunk.getX(), change.Chunk.getZ(), player); MapUtil.SendChunkForPlayer(change.Chunk.getX(), change.Chunk.getZ(), player);
else else
@ -874,10 +874,10 @@ public class HungerGames extends SoloGame
{ {
if (!_redMap.containsKey(block.getX())) if (!_redMap.containsKey(block.getX()))
return false; return false;
if (!_redMap.get(block.getX()).containsKey(block.getY())) if (!_redMap.get(block.getX()).containsKey(block.getY()))
return false; return false;
return _redMap.get(block.getX()).get(block.getY()).contains(block.getZ()); return _redMap.get(block.getX()).get(block.getY()).contains(block.getZ());
} }
@ -889,9 +889,9 @@ public class HungerGames extends SoloGame
if (!_redMap.get(loc.getBlockX()).containsKey(loc.getBlockY())) if (!_redMap.get(loc.getBlockX()).containsKey(loc.getBlockY()))
_redMap.get(loc.getBlockX()).put(loc.getBlockY(), new HashSet<Integer>()); _redMap.get(loc.getBlockX()).put(loc.getBlockY(), new HashSet<Integer>());
_redMap.get(loc.getBlockX()).get(loc.getBlockY()).add(loc.getBlockZ()); _redMap.get(loc.getBlockX()).get(loc.getBlockY()).add(loc.getBlockZ());
//Red //Red
if (_spreadType == 0) if (_spreadType == 0)
{ {
@ -902,7 +902,7 @@ public class HungerGames extends SoloGame
{ {
if (loc.getBlock().getType() == Material.LEAVES) //RedChangeBlock(loc, 79, (byte)0); if (loc.getBlock().getType() == Material.LEAVES) //RedChangeBlock(loc, 79, (byte)0);
{ {
} }
else if (loc.getBlock().getTypeId() == 8 || loc.getBlock().getTypeId() == 9) RedChangeBlock(loc, 79, (byte)0); else if (loc.getBlock().getTypeId() == 8 || loc.getBlock().getTypeId() == 9) RedChangeBlock(loc, 79, (byte)0);
else if (loc.getBlock().getTypeId() == 10 || loc.getBlock().getTypeId() == 11) RedChangeBlock(loc, 49, (byte)0); else if (loc.getBlock().getTypeId() == 10 || loc.getBlock().getTypeId() == 11) RedChangeBlock(loc, 49, (byte)0);
@ -954,7 +954,7 @@ public class HungerGames extends SoloGame
{ {
if (Math.random() > 0.95) if (Math.random() > 0.95)
player.playEffect(block.getLocation().add(0, 1, 0), Effect.STEP_SOUND, Material.SNOW_BLOCK); player.playEffect(block.getLocation().add(0, 1, 0), Effect.STEP_SOUND, Material.SNOW_BLOCK);
if (Math.random() > 0.8) if (Math.random() > 0.8)
{ {
Vector traj = UtilAlg.getTrajectory(block.getLocation().add(0.5, 1.5, 0.5), player.getLocation()); Vector traj = UtilAlg.getTrajectory(block.getLocation().add(0.5, 1.5, 0.5), player.getLocation());
@ -989,7 +989,7 @@ public class HungerGames extends SoloGame
near = true; near = true;
} }
} }
if (!near) if (!near)
{ {
if (_deathmatchLive && UtilMath.offset(player.getLocation(), _spawn) > 48) if (_deathmatchLive && UtilMath.offset(player.getLocation(), _spawn) > 48)
@ -999,7 +999,7 @@ public class HungerGames extends SoloGame
if (near) if (near)
{ {
player.getWorld().playSound(player.getLocation(), Sound.AMBIENCE_RAIN, 0.5f, 0f); player.getWorld().playSound(player.getLocation(), Sound.AMBIENCE_RAIN, 0.5f, 0f);
if (!_redOutTime.containsKey(player)) if (!_redOutTime.containsKey(player))
{ {
_redOutTime.put(player, System.currentTimeMillis()); _redOutTime.put(player, System.currentTimeMillis());
@ -1075,7 +1075,7 @@ public class HungerGames extends SoloGame
{ {
if (_supplyLocations.isEmpty()) if (_supplyLocations.isEmpty())
return; return;
_supplyCurrent = _supplyLocations.remove(UtilMath.r(_supplyLocations.size())); _supplyCurrent = _supplyLocations.remove(UtilMath.r(_supplyLocations.size()));
//Remove Prior //Remove Prior
@ -1153,28 +1153,28 @@ public class HungerGames extends SoloGame
UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation().add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1); UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation().add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1);
} }
} }
@EventHandler @EventHandler
public void DeathmatchUpdate(UpdateEvent event) public void DeathmatchUpdate(UpdateEvent event)
{ {
if (!IsLive()) if (!IsLive())
return; return;
if (_deathmatchLive) if (_deathmatchLive)
{ {
if (event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
return; return;
if (_deathmatchTime <= 0) if (_deathmatchTime <= 0)
return; return;
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
for (Player other : GetPlayers(true)) for (Player other : GetPlayers(true))
{ {
player.hidePlayer(other); player.hidePlayer(other);
player.showPlayer(other); player.showPlayer(other);
} }
Announce(C.cRed + C.Bold + "Deathmatch in " + _deathmatchTime + "..."); Announce(C.cRed + C.Bold + "Deathmatch in " + _deathmatchTime + "...");
_deathmatchTime--; _deathmatchTime--;
} }
@ -1183,7 +1183,7 @@ public class HungerGames extends SoloGame
{ {
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; return;
long timeLeft = 60000 - (System.currentTimeMillis() - _deathmatchTime); long timeLeft = 60000 - (System.currentTimeMillis() - _deathmatchTime);
if (timeLeft > 0) if (timeLeft > 0)
@ -1198,14 +1198,14 @@ public class HungerGames extends SoloGame
ChatColor.WHITE + "§lDeathmatch"); ChatColor.WHITE + "§lDeathmatch");
_deathmatchLive = true; _deathmatchLive = true;
GetTeamList().get(0).SpawnTeleport(); GetTeamList().get(0).SpawnTeleport();
_redLocations.clear(); _redLocations.clear();
for (Block block : UtilBlock.getInRadius(_spawn, 52d).keySet()) for (Block block : UtilBlock.getInRadius(_spawn, 52d).keySet())
RedSpread(block); RedSpread(block);
_deathmatchTime = 10; _deathmatchTime = 10;
} }
} }
@ -1213,122 +1213,122 @@ public class HungerGames extends SoloGame
{ {
if (event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
return; return;
if (!UtilTime.elapsed(GetStateTime(), 360000)) if (!UtilTime.elapsed(GetStateTime(), 360000))
return; return;
if (GetPlayers(true).size() > 4) if (GetPlayers(true).size() > 4)
return; return;
if (!UtilTime.elapsed(_deathmatchTime, 60000)) if (!UtilTime.elapsed(_deathmatchTime, 60000))
return; return;
Announce(C.cGreen + C.Bold + "Type " + ChatColor.RESET + C.Bold + "/dm" + C.cGreen + C.Bold + " to start Deathmatch!"); Announce(C.cGreen + C.Bold + "Type " + ChatColor.RESET + C.Bold + "/dm" + C.cGreen + C.Bold + " to start Deathmatch!");
_deathmatchTime = System.currentTimeMillis(); _deathmatchTime = System.currentTimeMillis();
} }
} }
@EventHandler @EventHandler
public void DeathmatchMoveCancel(PlayerMoveEvent event) public void DeathmatchMoveCancel(PlayerMoveEvent event)
{ {
if (!_deathmatchLive) if (!_deathmatchLive)
return; return;
if (_deathmatchTime <= 0) if (_deathmatchTime <= 0)
return; return;
if (UtilMath.offset2d(event.getFrom(), event.getTo()) == 0) if (UtilMath.offset2d(event.getFrom(), event.getTo()) == 0)
return; return;
if (!IsAlive(event.getPlayer())) if (!IsAlive(event.getPlayer()))
return; return;
event.setTo(event.getFrom()); event.setTo(event.getFrom());
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void DeathmatchDamage(CustomDamageEvent event) public void DeathmatchDamage(CustomDamageEvent event)
{ {
if (!_deathmatchLive) if (!_deathmatchLive)
return; return;
if (_deathmatchTime <= 0) if (_deathmatchTime <= 0)
return; return;
event.SetCancelled("Deathmatch"); event.SetCancelled("Deathmatch");
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void DeathmatchStart(PlayerCommandPreprocessEvent event) public void DeathmatchStart(PlayerCommandPreprocessEvent event)
{ {
if (!event.getMessage().equalsIgnoreCase("/dm")) if (!event.getMessage().equalsIgnoreCase("/dm"))
return; return;
event.setCancelled(true); event.setCancelled(true);
if (!IsLive()) if (!IsLive())
{ {
UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now.")); UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now."));
return; return;
} }
if (!UtilTime.elapsed(GetStateTime(), 360000)) if (!UtilTime.elapsed(GetStateTime(), 360000))
{ {
UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now.")); UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now."));
return; return;
} }
if (GetPlayers(true).size() > 4) if (GetPlayers(true).size() > 4)
{ {
UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now.")); UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now."));
return; return;
} }
if (_deathmatchCountdown) if (_deathmatchCountdown)
{ {
UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now.")); UtilPlayer.message(event.getPlayer(), F.main("Game", "Deathmatch cannot be started now."));
return; return;
} }
_deathmatchCountdown = true; _deathmatchCountdown = true;
Announce(C.cGreen + C.Bold + event.getPlayer().getName() + " has initiated Deathmatch!"); Announce(C.cGreen + C.Bold + event.getPlayer().getName() + " has initiated Deathmatch!");
Announce(C.cGreen + C.Bold + "Deathmatch starting in 60 seconds..."); Announce(C.cGreen + C.Bold + "Deathmatch starting in 60 seconds...");
_deathmatchTime = System.currentTimeMillis(); _deathmatchTime = System.currentTimeMillis();
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 1f); player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 1f);
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void CropTrample(PlayerInteractEvent event) public void CropTrample(PlayerInteractEvent event)
{ {
if (event.getAction() != Action.PHYSICAL) if (event.getAction() != Action.PHYSICAL)
return; return;
if (event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.SOIL) if (event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.SOIL)
return; return;
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void CompassUpdate(UpdateEvent event) public void CompassUpdate(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
return; return;
if (!IsLive()) if (!IsLive())
return; return;
//Night Time > Drop Target //Night Time > Drop Target
if (WorldData.World.getTime() > 14000 && WorldData.World.getTime() < 23000 && _supplyCurrent != null) if (WorldData.World.getTime() > 14000 && WorldData.World.getTime() < 23000 && _supplyCurrent != null)
{ {
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
{ {
player.setCompassTarget(_supplyCurrent); player.setCompassTarget(_supplyCurrent);
for (int i : player.getInventory().all(Material.COMPASS).keySet()) for (int i : player.getInventory().all(Material.COMPASS).keySet())
{ {
ItemStack stack = player.getInventory().getItem(i); ItemStack stack = player.getInventory().getItem(i);
@ -1337,7 +1337,7 @@ public class HungerGames extends SoloGame
itemMeta.setDisplayName( itemMeta.setDisplayName(
C.cWhite + C.Bold + "Supply Drop Location: " + C.cYellow + UtilMath.trim(1, UtilMath.offset(player.getLocation(), _supplyCurrent))); C.cWhite + C.Bold + "Supply Drop Location: " + C.cYellow + UtilMath.trim(1, UtilMath.offset(player.getLocation(), _supplyCurrent)));
stack.setItemMeta(itemMeta); stack.setItemMeta(itemMeta);
player.getInventory().setItem(i, stack); player.getInventory().setItem(i, stack);
} }
} }
@ -1349,28 +1349,28 @@ public class HungerGames extends SoloGame
{ {
Player target = null; Player target = null;
double bestDist = 0; double bestDist = 0;
for (Player other : Manager.GetGame().GetPlayers(true)) for (Player other : Manager.GetGame().GetPlayers(true))
{ {
if (other.equals(player)) if (other.equals(player))
continue; continue;
if (other.isSneaking()) if (other.isSneaking())
continue; continue;
double dist = UtilMath.offset(player, other); double dist = UtilMath.offset(player, other);
if (target == null || dist < bestDist) if (target == null || dist < bestDist)
{ {
target = other; target = other;
bestDist = dist; bestDist = dist;
} }
} }
if (target != null) if (target != null)
{ {
player.setCompassTarget(target.getLocation()); player.setCompassTarget(target.getLocation());
for (int i : player.getInventory().all(Material.COMPASS).keySet()) for (int i : player.getInventory().all(Material.COMPASS).keySet())
{ {
ItemStack stack = player.getInventory().getItem(i); ItemStack stack = player.getInventory().getItem(i);
@ -1381,25 +1381,26 @@ public class HungerGames extends SoloGame
" " + C.cWhite + C.Bold + "Nearest Player: " + C.cYellow + target.getName() + " " + C.cWhite + C.Bold + "Nearest Player: " + C.cYellow + target.getName() +
" " + C.cWhite + C.Bold + "Distance: " + C.cYellow + UtilMath.trim(1, bestDist)); " " + C.cWhite + C.Bold + "Distance: " + C.cYellow + UtilMath.trim(1, bestDist));
stack.setItemMeta(itemMeta); stack.setItemMeta(itemMeta);
player.getInventory().setItem(i, stack); player.getInventory().setItem(i, stack);
} }
} }
} }
} }
} }
@EventHandler @EventHandler
public void DisallowBrewFurnace(PlayerInteractEvent event) public void DisallowBrewFurnace(PlayerInteractEvent event)
{ {
if (event.getClickedBlock() == null) if (event.getClickedBlock() == null)
return; return;
if (event.getClickedBlock().getType() == Material.BREWING_STAND || if (event.getClickedBlock().getType() == Material.BREWING_STAND ||
event.getClickedBlock().getType() == Material.FURNACE) event.getClickedBlock().getType() == Material.FURNACE ||
event.getClickedBlock().getType() == Material.BURNING_FURNACE)
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void CancelItemFrameBreak(HangingBreakEvent event) public void CancelItemFrameBreak(HangingBreakEvent event)
{ {
@ -1414,17 +1415,17 @@ public class HungerGames extends SoloGame
{ {
if (event.GetState() != GameState.Live) if (event.GetState() != GameState.Live)
return; return;
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
Recharge.Instance.useForce(player, "Throw TNT", 30000); Recharge.Instance.useForce(player, "Throw TNT", 30000);
} }
@EventHandler @EventHandler
public void TNTThrow(PlayerInteractEvent event) public void TNTThrow(PlayerInteractEvent event)
{ {
if (!IsLive()) if (!IsLive())
return; return;
if (!UtilEvent.isAction(event, ActionType.L)) if (!UtilEvent.isAction(event, ActionType.L))
return; return;
@ -1434,7 +1435,7 @@ public class HungerGames extends SoloGame
return; return;
event.setCancelled(true); event.setCancelled(true);
if (!Recharge.Instance.use(player, "Throw TNT", 0, true)) if (!Recharge.Instance.use(player, "Throw TNT", 0, true))
{ {
UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throw TNT") + " yet.")); UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throw TNT") + " yet."));
@ -1478,14 +1479,14 @@ public class HungerGames extends SoloGame
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (event.getItemInHand().getType() == Material.PISTON_BASE) if (event.getItemInHand().getType() == Material.PISTON_BASE)
{ {
_placedBlocks.add(event.getBlock().getLocation()); _placedBlocks.add(event.getBlock().getLocation());
event.setCancelled(false); event.setCancelled(false);
final Block block = event.getBlock(); final Block block = event.getBlock();
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable() UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{ {
public void run() public void run()
@ -1530,7 +1531,7 @@ public class HungerGames extends SoloGame
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void PlayerKillAward(CombatDeathEvent event) public void PlayerKillAward(CombatDeathEvent event)
{ {
@ -1539,11 +1540,11 @@ public class HungerGames extends SoloGame
if (!(event.GetEvent().getEntity() instanceof Player)) if (!(event.GetEvent().getEntity() instanceof Player))
return; return;
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.RED).with(Type.BALL_LARGE).trail(false).build(); FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.RED).with(Type.BALL_LARGE).trail(false).build();
for (int i=0 ; i<3 ; i++) for (int i=0 ; i<3 ; i++)
UtilFirework.launchFirework(event.GetEvent().getEntity().getLocation(), effect, null, 3); UtilFirework.launchFirework(event.GetEvent().getEntity().getLocation(), effect, null, 3);
if (event.GetLog().GetKiller() == null) if (event.GetLog().GetKiller() == null)
return; return;
@ -1556,25 +1557,25 @@ public class HungerGames extends SoloGame
killer.giveExpLevels(1); killer.giveExpLevels(1);
} }
@EventHandler @EventHandler
public void DisableDamageLevel(CustomDamageEvent event) public void DisableDamageLevel(CustomDamageEvent event)
{ {
event.SetDamageToLevel(false); event.SetDamageToLevel(false);
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void ExplosionDamageRemove(EntityExplodeEvent event) public void ExplosionDamageRemove(EntityExplodeEvent event)
{ {
event.blockList().clear(); event.blockList().clear();
} }
@EventHandler @EventHandler
public void FixClean(PlayerQuitEvent event) public void FixClean(PlayerQuitEvent event)
{ {
_redChunks.remove(event.getPlayer()); _redChunks.remove(event.getPlayer());
} }
private long _helpTimer = 0; private long _helpTimer = 0;
private int _helpIndex = 0; private int _helpIndex = 0;
private String[] _help = new String[] private String[] _help = new String[]

View File

@ -200,7 +200,7 @@ public class PerkWolfPet extends Perk
if (event.getPlayer().getItemInHand() == null) if (event.getPlayer().getItemInHand() == null)
return; return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE") && !event.getPlayer().getItemInHand().getType().toString().contains("_SWORD"))
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();