added WATER_DAMAGE support for maps
modified some bridges code
This commit is contained in:
parent
c6e4c5c5e4
commit
de36e3d8e4
@ -97,6 +97,9 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
//Lilly Pad Bridge
|
||||
private ArrayList<Location> _lillyPads = new ArrayList<Location>();
|
||||
|
||||
//Ice
|
||||
private ArrayList<Location> _iceBridge = new ArrayList<Location>();
|
||||
|
||||
private HashSet<BridgePart> _bridgeParts = new HashSet<BridgePart>();
|
||||
|
||||
//Animals
|
||||
@ -115,7 +118,6 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
|
||||
//Map Flags
|
||||
private int _buildHeight = -1;
|
||||
private int _iceForm = -1;
|
||||
|
||||
//Player Respawn
|
||||
private HashSet<String> _usedLife = new HashSet<String>();
|
||||
@ -211,7 +213,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
new TntMinerStatTracker(this),
|
||||
new KillFastStatTracker(this, 4, 10, "Rampage"),
|
||||
new DeathBomberStatTracker(this, 5)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -253,9 +255,6 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
@Override
|
||||
public void ParseData()
|
||||
{
|
||||
if (!WorldData.GetDataLocs("WHITE").isEmpty())
|
||||
WorldWaterDamage = 4;
|
||||
|
||||
ParseLavaBridge();
|
||||
ParseWoodBridge();
|
||||
ParseIceBridge();
|
||||
@ -651,10 +650,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
|
||||
private void ParseIceBridge()
|
||||
{
|
||||
if (WorldData.GetCustomLocs("WATER_HEIGHT").isEmpty())
|
||||
return;
|
||||
|
||||
_iceForm = WorldData.GetCustomLocs("WATER_HEIGHT").get(0).getBlockY();
|
||||
_iceBridge = WorldData.GetCustomLocs("LIGHT_BLUE");
|
||||
}
|
||||
|
||||
private void ParseLillyPad()
|
||||
@ -696,63 +692,6 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
BuildLillyPad();
|
||||
}
|
||||
|
||||
private void BuildIce()
|
||||
{
|
||||
if (_iceForm <= 0)
|
||||
return;
|
||||
|
||||
if (UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 120000))
|
||||
{
|
||||
WorldData.World.setStorm(false);
|
||||
return;
|
||||
}
|
||||
|
||||
WorldData.World.setStorm(true);
|
||||
|
||||
//Short Delay (so snow properly starts)
|
||||
if (!UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 6000))
|
||||
return;
|
||||
|
||||
int xVar = WorldData.MaxX - WorldData.MinX;
|
||||
int zVar = WorldData.MaxZ - WorldData.MinZ;
|
||||
|
||||
//do area
|
||||
BuildIceArea(WorldData.MinX, WorldData.MinX + xVar/2, WorldData.MinZ, WorldData.MinZ + zVar/2, Material.REDSTONE_BLOCK);
|
||||
BuildIceArea(WorldData.MinX + xVar/2, WorldData.MaxX, WorldData.MinZ, WorldData.MinZ + zVar/2, Material.GOLD_BLOCK);
|
||||
BuildIceArea(WorldData.MinX, WorldData.MinX + xVar/2, WorldData.MinZ + zVar/2, WorldData.MaxZ, Material.EMERALD_BLOCK);
|
||||
BuildIceArea(WorldData.MinX + xVar/2, WorldData.MaxX, WorldData.MinZ + zVar/2, WorldData.MaxZ, Material.DIAMOND_BLOCK);
|
||||
}
|
||||
|
||||
private void BuildIceArea(int xLow, int xHigh, int zLow, int zHigh, Material mat)
|
||||
{
|
||||
int attempts = 1000;
|
||||
int complete = 10;
|
||||
|
||||
//Team A
|
||||
while (attempts > 0 && complete > 0)
|
||||
{
|
||||
attempts--;
|
||||
|
||||
int x = xLow + UtilMath.r(xHigh - xLow);
|
||||
int z = zLow + UtilMath.r(zHigh - zLow);
|
||||
|
||||
Block block = WorldData.World.getBlockAt(x, _iceForm, z);
|
||||
|
||||
if (!block.isLiquid())
|
||||
continue;
|
||||
|
||||
if (block.getRelative(BlockFace.NORTH).isLiquid() &&
|
||||
block.getRelative(BlockFace.EAST).isLiquid() &&
|
||||
block.getRelative(BlockFace.SOUTH).isLiquid() &&
|
||||
block.getRelative(BlockFace.WEST).isLiquid())
|
||||
continue;
|
||||
|
||||
block.setType(Material.ICE);
|
||||
|
||||
complete--;
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildLava()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
@ -790,20 +729,64 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
if (_lillyPads != null && !_lillyPads.isEmpty())
|
||||
{
|
||||
// Random Block
|
||||
Location bestLoc = _lillyPads.get(UtilMath.r(_lillyPads.size()));
|
||||
Location loc = _lillyPads.get(UtilMath.r(_lillyPads.size()));
|
||||
|
||||
if (bestLoc.getBlock().getRelative(BlockFace.DOWN).isLiquid())
|
||||
if (!loc.getBlock().getRelative(BlockFace.DOWN).isLiquid())
|
||||
continue;
|
||||
|
||||
_lillyPads.remove(bestLoc);
|
||||
_lillyPads.remove(loc);
|
||||
|
||||
MapUtil.QuickChangeBlockAt(bestLoc, Material.WATER_LILY);
|
||||
MapUtil.QuickChangeBlockAt(loc, Material.WATER_LILY);
|
||||
|
||||
// Sound
|
||||
bestLoc.getWorld().playEffect(bestLoc, Effect.STEP_SOUND, 111);
|
||||
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 111);
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildIce()
|
||||
{
|
||||
if (UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 120000))
|
||||
{
|
||||
WorldData.World.setStorm(false);
|
||||
return;
|
||||
}
|
||||
|
||||
WorldData.World.setStorm(true);
|
||||
|
||||
int attempts = 0;
|
||||
int done = 0;
|
||||
while (done < 2 && attempts < 500 && _iceBridge != null && !_iceBridge.isEmpty())
|
||||
{
|
||||
attempts++;
|
||||
|
||||
// Random Block
|
||||
Location loc = _iceBridge.get(UtilMath.r(_iceBridge.size()));
|
||||
|
||||
Block block = loc.getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
if (!block.isLiquid())
|
||||
continue;
|
||||
|
||||
if (block.getRelative(BlockFace.NORTH).isLiquid() &&
|
||||
block.getRelative(BlockFace.EAST).isLiquid() &&
|
||||
block.getRelative(BlockFace.SOUTH).isLiquid() &&
|
||||
block.getRelative(BlockFace.WEST).isLiquid())
|
||||
continue;
|
||||
|
||||
_iceBridge.remove(loc);
|
||||
|
||||
if (Math.random() > 0.25)
|
||||
MapUtil.QuickChangeBlockAt(loc, Material.PACKED_ICE);
|
||||
else
|
||||
MapUtil.QuickChangeBlockAt(loc, Material.ICE);
|
||||
|
||||
// Sound
|
||||
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, Material.ICE);
|
||||
|
||||
done++;
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildWood()
|
||||
{
|
||||
if (_woodBridgeBlocks != null && !_woodBridgeBlocks.isEmpty())
|
||||
@ -1604,14 +1587,14 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
|
||||
//Damagee is closer to Damagers Island
|
||||
if (UtilMath.offset(damagee.getLocation(), UtilWorld.averageLocation(damageeTeam.GetSpawns())) >
|
||||
UtilMath.offset(damagee.getLocation(), UtilWorld.averageLocation(damagerTeam.GetSpawns())))
|
||||
UtilMath.offset(damagee.getLocation(), UtilWorld.averageLocation(damagerTeam.GetSpawns())))
|
||||
{
|
||||
cheaterKill(damagee);
|
||||
}
|
||||
|
||||
//Damagee is closer to Damagees Island
|
||||
if (UtilMath.offset(damager.getLocation(), UtilWorld.averageLocation(damagerTeam.GetSpawns())) >
|
||||
UtilMath.offset(damager.getLocation(), UtilWorld.averageLocation(damageeTeam.GetSpawns())))
|
||||
UtilMath.offset(damager.getLocation(), UtilWorld.averageLocation(damageeTeam.GetSpawns())))
|
||||
{
|
||||
cheaterKill(damager);
|
||||
}
|
||||
@ -1636,23 +1619,23 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// public void liquidBlockDeny(BlockBreakEvent event)
|
||||
// {
|
||||
// if (_bridgesDown)
|
||||
// return;
|
||||
//
|
||||
// if (!IsAlive(event.getPlayer()))
|
||||
// return;
|
||||
//
|
||||
// if (event.getBlock().getRelative(BlockFace.UP).isLiquid() || event.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP).isLiquid())
|
||||
// {
|
||||
// UtilPlayer.message(event.getPlayer(), F.main("Game",
|
||||
// "Cannot tunnel under liquids."));
|
||||
//
|
||||
// event.setCancelled(true);
|
||||
// }
|
||||
// }
|
||||
// @EventHandler
|
||||
// public void liquidBlockDeny(BlockBreakEvent event)
|
||||
// {
|
||||
// if (_bridgesDown)
|
||||
// return;
|
||||
//
|
||||
// if (!IsAlive(event.getPlayer()))
|
||||
// return;
|
||||
//
|
||||
// if (event.getBlock().getRelative(BlockFace.UP).isLiquid() || event.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP).isLiquid())
|
||||
// {
|
||||
// UtilPlayer.message(event.getPlayer(), F.main("Game",
|
||||
// "Cannot tunnel under liquids."));
|
||||
//
|
||||
// event.setCancelled(true);
|
||||
// }
|
||||
// }
|
||||
|
||||
@EventHandler
|
||||
public void vehicleDeny(PlayerInteractEvent event)
|
||||
@ -1663,7 +1646,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.BOAT))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game",
|
||||
"You cannot place boats."));
|
||||
"You cannot place boats."));
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -993,17 +993,26 @@ public class GameFlagManager implements Listener
|
||||
@EventHandler
|
||||
public void WorldWaterDamage(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
Game game = Manager.GetGame();
|
||||
if (game == null) return;
|
||||
|
||||
if (game.WorldWaterDamage <= 0)
|
||||
return;
|
||||
|
||||
if (!game.IsLive())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
if (game.WorldWaterDamage <= 0)
|
||||
{
|
||||
if (!game.WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty())
|
||||
{
|
||||
game.WorldWaterDamage = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (GameTeam team : game.GetTeamList())
|
||||
for (Player player : team.GetPlayers(true))
|
||||
@ -1012,7 +1021,7 @@ public class GameFlagManager implements Listener
|
||||
{
|
||||
//Damage Event
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null,
|
||||
DamageCause.DROWNING, 4, true, false, false,
|
||||
DamageCause.DROWNING, game.WorldWaterDamage, true, false, false,
|
||||
"Water", "Water Damage");
|
||||
|
||||
player.getWorld().playSound(player.getLocation(),
|
||||
|
Loading…
Reference in New Issue
Block a user