diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index 7402faf4b..4393f8129 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -43,6 +43,8 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilGear; @@ -95,8 +97,12 @@ public class Bridge extends TeamGame implements OreObsfucation private ArrayList _lavaSource = new ArrayList(); //Lilly Pad Bridge - private ArrayList _lillyPads = new ArrayList(); - + private NautHashMap _lillyPads = new NautHashMap(); + + //Mushrooms + private NautHashMap _mushroomStem = new NautHashMap(); + private NautHashMap _mushroomTop = new NautHashMap(); + //Ice private ArrayList _iceBridge = new ArrayList(); @@ -234,11 +240,16 @@ public class Bridge extends TeamGame implements OreObsfucation } } - @EventHandler(priority = EventPriority.HIGH) + @EventHandler(priority = EventPriority.MONITOR) public void GameStateChange(GameStateChangeEvent event) { if (event.GetState() != GameState.Live) return; + + if (!WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty()) + { + WorldWaterDamage = 4; + } if (WorldWaterDamage > 0) { @@ -259,7 +270,8 @@ public class Bridge extends TeamGame implements OreObsfucation ParseWoodBridge(); ParseIceBridge(); ParseLillyPad(); - + ParseMushrooms(); + ParseChests(); ParseOre(WorldData.GetCustomLocs("73")); // Red @@ -650,12 +662,29 @@ public class Bridge extends TeamGame implements OreObsfucation private void ParseIceBridge() { - _iceBridge = WorldData.GetCustomLocs("LIGHT_BLUE"); + _iceBridge = WorldData.GetDataLocs("LIGHT_BLUE"); } + private void ParseMushrooms() + { + for (Location loc : WorldData.GetCustomLocs("21")) + { + _mushroomStem.put(loc, 0L); + loc.getBlock().setType(Material.AIR); + } + + for (Location loc : WorldData.GetDataLocs("PURPLE")) + { + _mushroomTop.put(loc, 0L); + } + } + private void ParseLillyPad() { - _lillyPads = WorldData.GetDataLocs("LIME"); + for (Location loc : WorldData.GetDataLocs("LIME")) + { + _lillyPads.put(loc, 0L); + } } @EventHandler @@ -690,6 +719,7 @@ public class Bridge extends TeamGame implements OreObsfucation BuildLava(); BuildIce(); BuildLillyPad(); + buildMushroom(); } private void BuildLava() @@ -729,7 +759,10 @@ public class Bridge extends TeamGame implements OreObsfucation if (_lillyPads != null && !_lillyPads.isEmpty()) { // Random Block - Location loc = _lillyPads.get(UtilMath.r(_lillyPads.size())); + Location loc = UtilAlg.Random(_lillyPads.keySet()); + + if (!UtilTime.elapsed(_lillyPads.get(loc), 8000)) + continue; if (!loc.getBlock().getRelative(BlockFace.DOWN).isLiquid()) continue; @@ -743,19 +776,109 @@ public class Bridge extends TeamGame implements OreObsfucation } } + @EventHandler + public void breakLillyPad(BlockBreakEvent event) + { + if (event.getBlock().getType() != Material.WATER_LILY) + return; + + _lillyPads.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000)); + } + + private void buildMushroom() + { + if (_mushroomStem != null && !_mushroomStem.isEmpty()) + { + for (int i=0 ; i<4 && !_mushroomStem.isEmpty() ; i++) + { + double lowestY = 0; + Location lowestLoc = null; + + for (Location loc : _mushroomStem.keySet()) + { + if (!UtilTime.elapsed(_mushroomStem.get(loc), 6000)) + continue; + + if (lowestLoc == null || loc.getY() < lowestY) + { + lowestY = loc.getY(); + lowestLoc = loc; + } + } + + if (lowestLoc == null) + continue; + + _mushroomStem.remove(lowestLoc); + + MapUtil.QuickChangeBlockAt(lowestLoc, 100, (byte)15); + } + } + + else if (_mushroomTop != null && !_mushroomTop.isEmpty()) + { + int attempts = 0; + int done = 0; + while (done < 4 && attempts < 400) + { + attempts++; + + // Random Block + Location loc = UtilAlg.Random(_mushroomTop.keySet()); + + if (!UtilTime.elapsed(_mushroomTop.get(loc), 6000)) + continue; + + Block block = loc.getBlock(); + + if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR && + block.getRelative(BlockFace.NORTH).getType() == Material.AIR && + block.getRelative(BlockFace.EAST).getType() == Material.AIR && + block.getRelative(BlockFace.SOUTH).getType() == Material.AIR && + block.getRelative(BlockFace.WEST).getType() == Material.AIR) + continue; + + _mushroomTop.remove(loc); + + MapUtil.QuickChangeBlockAt(block.getLocation(), 99, (byte)14); + + // Sound + loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 99); + + done++; + } + } + } + + @EventHandler + public void breakMushroom(BlockBreakEvent event) + { + if (event.getBlock().getTypeId() == 100 && + WorldData.GetCustomLocs("21").contains(event.getBlock().getLocation().add(0.5, 0, 0.5))) + { + _mushroomStem.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000)); + } + + if (event.getBlock().getTypeId() == 99 && + WorldData.GetDataLocs("PURPLE").contains(event.getBlock().getLocation().add(0.5, 0, 0.5))) + { + _mushroomTop.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000)); + } + } + private void BuildIce() { - if (UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 120000)) + if (_iceBridge == null || _iceBridge.isEmpty() || 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()) + while (done < 4 && attempts < 500) { attempts++; @@ -776,9 +899,9 @@ public class Bridge extends TeamGame implements OreObsfucation _iceBridge.remove(loc); if (Math.random() > 0.25) - MapUtil.QuickChangeBlockAt(loc, Material.PACKED_ICE); + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.PACKED_ICE); else - MapUtil.QuickChangeBlockAt(loc, Material.ICE); + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.ICE); // Sound loc.getWorld().playEffect(loc, Effect.STEP_SOUND, Material.ICE); @@ -1242,7 +1365,7 @@ public class Bridge extends TeamGame implements OreObsfucation for (GameTeam team : this.GetTeamList()) { //Display Individual Players - if (this.GetPlayers(true).size() < 10) + if (this.GetPlayers(true).size() < 8) { if (!team.IsTeamAlive()) continue; @@ -1662,9 +1785,12 @@ public class Bridge extends TeamGame implements OreObsfucation } @EventHandler - public void toggleOre(PlayerCommandPreprocessEvent event) + public void debug(PlayerCommandPreprocessEvent event) { if (event.getPlayer().isOp() && event.getMessage().contains("/oretoggle")) _ore.ToggleVisibility(); + + if (event.getPlayer().isOp() && event.getMessage().contains("/bridge")) + _bridgeTime = 30000; } }