added WATER_DAMAGE support for maps
modified some bridges code
This commit is contained in:
parent
c6e4c5c5e4
commit
de36e3d8e4
|
@ -96,7 +96,10 @@ 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
|
||||
|
@ -108,14 +111,13 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
|
||||
//Chest Loot
|
||||
private ArrayList<ItemStack> _chestLoot = new ArrayList<ItemStack>();
|
||||
|
||||
|
||||
//Ore
|
||||
private OreHider _ore;
|
||||
private double _oreDensity = 2.2;
|
||||
|
||||
//Map Flags
|
||||
private int _buildHeight = -1;
|
||||
private int _iceForm = -1;
|
||||
|
||||
//Player Respawn
|
||||
private HashSet<String> _usedLife = new HashSet<String>();
|
||||
|
@ -150,16 +152,16 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
"Special loot is located in the center.",
|
||||
"The last team alive wins!"
|
||||
});
|
||||
|
||||
|
||||
_ore = new OreHider();
|
||||
|
||||
// Flags
|
||||
GameTimeout = Manager.IsTournamentServer() ? 5400000 : 3600000;
|
||||
|
||||
Manager.GetExplosion().SetLiquidDamage(false);
|
||||
|
||||
|
||||
this.StrictAntiHack = true;
|
||||
|
||||
|
||||
DamageSelf = true;
|
||||
|
||||
ItemDrop = true;
|
||||
|
@ -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();
|
||||
|
@ -379,7 +378,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void ParseOre(ArrayList<Location> teamOre)
|
||||
{
|
||||
|
@ -648,15 +647,12 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
|
||||
_lavaSource = WorldData.GetDataLocs("BLACK");
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
_lillyPads = WorldData.GetDataLocs("LIME");
|
||||
|
@ -673,15 +669,15 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
|
||||
if (!UtilTime.elapsed(this.GetStateTime(), _bridgeTime))
|
||||
return;
|
||||
|
||||
|
||||
if (!_bridgesDown)
|
||||
{
|
||||
Manager.GetExplosion().SetLiquidDamage(true);
|
||||
this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "THE BRIDGES ARE SPAWNING!");
|
||||
}
|
||||
|
||||
|
||||
_bridgesDown = true;
|
||||
|
||||
|
||||
for (Kit kit : this.GetKits())
|
||||
{
|
||||
if (kit instanceof KitDestructor)
|
||||
|
@ -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++)
|
||||
|
@ -783,27 +722,71 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
0.5f + (float) Math.random());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void BuildLillyPad()
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
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(loc, Material.WATER_LILY);
|
||||
|
||||
MapUtil.QuickChangeBlockAt(bestLoc, 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())
|
||||
|
@ -1051,7 +1034,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
|
||||
if (_bridgesDown)
|
||||
return;
|
||||
|
||||
|
||||
//In Liquid
|
||||
if (event.getBlock().getRelative(BlockFace.UP).isLiquid() ||
|
||||
event.getBlockReplacedState().getTypeId() == 8 ||
|
||||
|
@ -1061,9 +1044,9 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game",
|
||||
"Cannot place blocks in liquids until Bridge is down."));
|
||||
|
||||
|
||||
event.getPlayer().setVelocity(new Vector(0,-0.5,0));
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -1178,7 +1161,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
{
|
||||
if (event.getBucket() != Material.WATER_BUCKET)
|
||||
return;
|
||||
|
||||
|
||||
if (WorldWaterDamage > 0)
|
||||
{
|
||||
UtilPlayer.message(
|
||||
|
@ -1186,7 +1169,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
F.main("Game", "Cannot use " + F.elem("Water Bucket") + " on this map."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
else if (!_bridgesDown)
|
||||
{
|
||||
UtilPlayer.message(
|
||||
|
@ -1263,7 +1246,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
{
|
||||
if (!team.IsTeamAlive())
|
||||
continue;
|
||||
|
||||
|
||||
Scoreboard.WriteBlank();
|
||||
|
||||
for (Player player : team.GetPlayers(true))
|
||||
|
@ -1446,7 +1429,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
SetState(GameState.End);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ArrayList<GameTeam> bestTeams = new ArrayList<GameTeam>();
|
||||
int bestKills = 0;
|
||||
|
||||
|
@ -1508,7 +1491,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
{
|
||||
return _bridgesDown;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void CheatChestBreak(BlockBreakEvent event)
|
||||
{
|
||||
|
@ -1517,7 +1500,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
|
||||
if (event.getBlock().getType() != Material.CHEST)
|
||||
return;
|
||||
|
||||
|
||||
if (!IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
|
@ -1531,7 +1514,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void CheatChestBreak(BlockPlaceEvent event)
|
||||
{
|
||||
|
@ -1540,7 +1523,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
|
||||
if (event.getBlock().getType() != Material.CHEST)
|
||||
return;
|
||||
|
||||
|
||||
if (!IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
|
@ -1554,19 +1537,19 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void CheatChestInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (_bridgesDown)
|
||||
return;
|
||||
|
||||
|
||||
if (event.getClickedBlock() == null)
|
||||
return;
|
||||
|
||||
if (event.getClickedBlock().getType() != Material.CHEST)
|
||||
return;
|
||||
|
||||
|
||||
if (!IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
|
@ -1580,50 +1563,50 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void PreBridgeDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.IsCancelled())
|
||||
return;
|
||||
|
||||
|
||||
if (_bridgesDown || event.GetProjectile() != null)
|
||||
return;
|
||||
|
||||
|
||||
GameTeam damageeTeam = GetTeam(event.GetDamageePlayer());
|
||||
GameTeam damagerTeam = GetTeam(event.GetDamagerPlayer(false));
|
||||
|
||||
|
||||
if (damageeTeam == null || damagerTeam == null)
|
||||
return;
|
||||
|
||||
|
||||
if (damageeTeam.equals(damagerTeam))
|
||||
return;
|
||||
|
||||
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
Player damager = event.GetDamagerPlayer(false);
|
||||
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void cheaterKill(Player player)
|
||||
{
|
||||
Announce(C.Bold + player.getName() + " was killed for cheating!");
|
||||
_usedLife.add(player.getName());
|
||||
player.damage(9999);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void liquidFlow(BlockFromToEvent event)
|
||||
{
|
||||
|
@ -1635,40 +1618,40 @@ 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)
|
||||
{
|
||||
if (!UtilEvent.isAction(event, ActionType.R))
|
||||
return;
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double GetKillsGems(Player killer, Player killed, boolean assist)
|
||||
{
|
||||
|
@ -1677,7 +1660,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||
else
|
||||
return 12;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void toggleOre(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
|
|
|
@ -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