From a62ecdb21225e143a75515423d815515c7e4ae18 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 25 Jan 2017 21:38:58 +0000 Subject: [PATCH 01/16] Custom Bridges and Per player world borders --- .../core/twofactor/TwoFactorAuth.java | 2 +- .../src/nautilus/game/arcade/Arcade.java | 8 +- .../game/games/bridge/BattleCryManager.java | 6 - .../game/arcade/game/games/bridge/Bridge.java | 336 +++++++++++++----- .../bridge/animation/BridgeAnimation.java | 45 +++ .../bridge/animation/BridgeAnimationType.java | 42 +++ .../animation/CustomBridgeAnimation.java | 153 ++++++++ .../bridge/animation/IceBridgeAnimation.java | 79 ++++ .../bridge/animation/LavaBridgeAnimation.java | 84 +++++ .../bridge/animation/WoodBridgeAnimation.java | 129 +++++++ .../game/arcade/game/modules/Module.java | 3 - .../game/modules/WorldBorderModule.java | 116 ++++++ 12 files changed, 898 insertions(+), 105 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BattleCryManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimationType.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/CustomBridgeAnimation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/IceBridgeAnimation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/LavaBridgeAnimation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/WoodBridgeAnimation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/WorldBorderModule.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java index bc46f5218..59cab85bf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java @@ -176,7 +176,7 @@ public class TwoFactorAuth extends MiniClientPlugin player.sendMessage(F.main("2FA", "Setting up two-factor authentication.")); } - @EventHandler + //@EventHandler public void onJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 152a6b8d1..82fedec62 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -157,10 +157,10 @@ public class Arcade extends JavaPlugin Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); - SnapshotManager snapshotManager = new SnapshotManager(this, new SnapshotRepository(serverStatusManager.getCurrentServerName(), getLogger())); - ReportManager reportManager = new ReportManager(this, snapshotManager, _clientManager, incognito, punish, serverStatusManager.getRegion(), serverStatusManager.getCurrentServerName(), 1); - new SnapshotPlugin(this, snapshotManager, _clientManager); - new ReportPlugin(this, reportManager); +// SnapshotManager snapshotManager = new SnapshotManager(this, new SnapshotRepository(serverStatusManager.getCurrentServerName(), getLogger())); +// ReportManager reportManager = new ReportManager(this, snapshotManager, _clientManager, incognito, punish, serverStatusManager.getRegion(), serverStatusManager.getCurrentServerName(), 1); +// new SnapshotPlugin(this, snapshotManager, _clientManager); +// new ReportPlugin(this, reportManager); BlockRestore blockRestore = new BlockRestore(this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BattleCryManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BattleCryManager.java deleted file mode 100644 index 7c7e71ba0..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/BattleCryManager.java +++ /dev/null @@ -1,6 +0,0 @@ -package nautilus.game.arcade.game.games.bridge; - -public class BattleCryManager -{ - -} 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 a6d5d92f3..ac985ad84 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 @@ -1,9 +1,67 @@ package nautilus.game.arcade.game.games.bridge; -import com.google.common.collect.Lists; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +import org.bukkit.ChatColor; +import org.bukkit.Effect; +import org.bukkit.GameMode; +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.block.Chest; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.Cow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Item; +import org.bukkit.entity.Pig; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.CraftingInventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.util.Vector; + import mineplex.core.common.Rank; -import mineplex.core.common.util.*; +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.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; import mineplex.core.explosion.ExplosionEvent; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; @@ -17,35 +75,27 @@ import nautilus.game.arcade.events.PlayerDeathOutEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.bridge.kits.*; +import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimation; +import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimationType; +import nautilus.game.arcade.game.games.bridge.animation.CustomBridgeAnimation; +import nautilus.game.arcade.game.games.bridge.kits.KitApple; +import nautilus.game.arcade.game.games.bridge.kits.KitArcher; +import nautilus.game.arcade.game.games.bridge.kits.KitBerserker; +import nautilus.game.arcade.game.games.bridge.kits.KitBomber; +import nautilus.game.arcade.game.games.bridge.kits.KitBrawler; +import nautilus.game.arcade.game.games.bridge.kits.KitDestructor; +import nautilus.game.arcade.game.games.bridge.kits.KitMammoth; +import nautilus.game.arcade.game.games.bridge.kits.KitMiner; +import nautilus.game.arcade.game.modules.WorldBorderModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.ore.OreHider; import nautilus.game.arcade.ore.OreObsfucation; -import nautilus.game.arcade.stats.*; -import org.bukkit.*; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; -import org.bukkit.entity.*; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockFormEvent; -import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.event.player.*; -import org.bukkit.inventory.CraftingInventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.util.Vector; - -import java.util.*; +import nautilus.game.arcade.stats.BridgesSniperStatTracker; +import nautilus.game.arcade.stats.DeathBomberStatTracker; +import nautilus.game.arcade.stats.FoodForTheMassesStatTracker; +import nautilus.game.arcade.stats.KillFastStatTracker; +import nautilus.game.arcade.stats.TntMinerStatTracker; public class Bridge extends TeamGame implements OreObsfucation { @@ -54,10 +104,21 @@ public class Bridge extends TeamGame implements OreObsfucation */ private static final Material[] PLAYER_DROP_DELAY_MATERIALS = new Material[] { Material.LOG, Material.LOG_2, Material.IRON_ORE, Material.DIAMOND_ORE, Material.COAL_ORE, Material.GOLD_ORE, Material.WORKBENCH, Material.FURNACE }; - //Bridge Timer - private int _bridgeTime = 600000; + /** + * The number of milliseconds from the game start time til the bridges should be built. + */ + private static final long BRIDGE_TIME = TimeUnit.MINUTES.toMillis(10); + + /** + * The number of ticks after the prepare state that we wait before setting the world border for the players. Just to make sure they are in the correct world. + */ + private static final int WORLD_BORDER_PREPARE_TICKS = 20; + + //Bridge + private long _bridgeTime = BRIDGE_TIME; private boolean _bridgesDown = false; - + private BridgeAnimation _animation; + //Wood Bridge private ArrayList _woodBridge = new ArrayList(); private HashMap _woodBridgeBlocks = null; @@ -103,8 +164,8 @@ public class Bridge extends TeamGame implements OreObsfucation private boolean _tournament; private HashMap _tournamentKills = new HashMap(); private long _tournamentKillMessageTimer = 0; - + @SuppressWarnings("unchecked") public Bridge(ArcadeManager manager) { this(manager, GameType.Bridge); @@ -154,28 +215,6 @@ public class Bridge extends TeamGame implements OreObsfucation "The last team alive wins!" }); - List kits = Lists.newArrayList(GetKits()); - List finalKits = Lists.newArrayList(kits); - - boolean foundBrawler = false; - for(int i = 0; i < kits.size(); i++) - { - Kit kit = kits.get(i); - if(kit.GetName().equalsIgnoreCase("Brawler")) - { - if(!foundBrawler) - { - foundBrawler = true; - } - else - { - finalKits.remove(i); - } - } - } - - setKits(finalKits.toArray(new Kit[finalKits.size()])); - _ore = new OreHider(); // Flags @@ -183,7 +222,7 @@ public class Bridge extends TeamGame implements OreObsfucation Manager.GetExplosion().SetLiquidDamage(false); - this.StrictAntiHack = true; + StrictAntiHack = true; DamageSelf = true; @@ -206,10 +245,6 @@ public class Bridge extends TeamGame implements OreObsfucation WorldWaterDamage = 0; WorldBoundaryKill = false; - new CompassModule() - .setGiveCompassToAlive(true) - .register(this); - DeathDropItems = true; GemMultiplier = 2.5; @@ -229,18 +264,26 @@ public class Bridge extends TeamGame implements OreObsfucation "Killing yourself counts as -1 team kill.", "Team with the most kills wins!" }; + + _tournament = true; } - - _tournament = Manager.IsTournamentServer(); + new CompassModule() + .setGiveCompassToAlive(true) + .register(this); + + new WorldBorderModule().register(this); } + //TODO move this lower and use EntityDamage @EventHandler public void PlayerOut(final PlayerDeathOutEvent event) { if (_bridgesDown) + { return; - + } + Player player = event.GetPlayer(); if (!_usedLife.contains(player.getName())) @@ -253,11 +296,78 @@ public class Bridge extends TeamGame implements OreObsfucation } } + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + //Delay this so that we are 100% sure people are in the world. + Manager.runSyncLater(() -> { + + WorldBorderModule borderModule = getModule(WorldBorderModule.class); + boolean oldWay = WorldData.GetCustomLocs("BORDER").isEmpty() || WorldData.GetCustomLocs("BORDER CENTER").isEmpty(); + +// if (!oldWay) +// { +// // Step 1 - Get the vector offset between the spectator location and the center of the border +// Location center = WorldData.GetCustomLocs("BORDER").get(0); +// +// Vector offset = center.subtract(SpectatorSpawn.toVector()).toVector(); +// } + + // Here we do some calculations for per player world borders + for (GameTeam team : GetTeamList()) + { + if (oldWay) + { + // If this is an old map or the builders haven't done it properly we can use this more of an estimate of the border size + // Step 1 - Get the average location of the spawns, we will assume this is the centre of the island + Location center = UtilAlg.getAverageLocation(team.GetSpawns()); + + // Step 2 - Calculate an estimate for the size of the border. We'll go with half but the setSize uses the radius so it works out the same to leave it like this + double distToCenter = UtilMath.offset2d(SpectatorSpawn, center); + + // Step 3 - Send the setCenter and setSize packets to the team members + for (Player player : team.GetPlayers(true)) + { + borderModule.setCenter(player, center); + borderModule.setSize(player, distToCenter); + } + } +// else +// { +// // Step 1 - Get the vector offset between the spectator location and the center of the border +// Location edge = WorldData.GetCustomLocs("BORDER").get(0); +// Location center = WorldData.GetCustomLocs("BORDER CENTER").get(0); +// +// Vector offset = center.subtract(SpectatorSpawn.toVector()).toVector(); +// +// // Step 2 - Calculate the distance between the the two border data points +// // Multiple by 2 because it is a radius +// double borderSize = UtilMath.offset2d(edge, center) * 2; +// +// // Step 3 - Send the setCenter and setSize packets to the team members +// for (Player player : team.GetPlayers(true)) +// { +// borderModule.setCenter(player, center); +// borderModule.setSize(player, borderSize); +// } +// } + } + + }, WORLD_BORDER_PREPARE_TICKS); + } + @EventHandler(priority = EventPriority.MONITOR) - public void GameStateChange(GameStateChangeEvent event) + public void live(GameStateChangeEvent event) { if (event.GetState() != GameState.Live) + { return; + } if (!WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty()) { @@ -266,19 +376,47 @@ public class Bridge extends TeamGame implements OreObsfucation if (WorldWaterDamage > 0) { - if (WorldData.MapName.equals("Volcanic Islands")) + String name = WorldData.MapName; + + if (name.equals("Volcanic Islands")) + { UtilTextMiddle.display(C.cRed + "Warning", "Water is Boiling Hot", 10, 60, 20); + } else if (WorldData.MapName.equals("Icelands")) + { UtilTextMiddle.display(C.cRed + "Warning", "Water is Freezing Cold", 10, 60, 20); + } else + { UtilTextMiddle.display(C.cRed + "Warning", "Water is Deadly", 10, 60, 20); + } } } - //parse @Override public void ParseData() { + // Now we need to decide on what bridge animation. + typeLoop : for (BridgeAnimationType type : BridgeAnimationType.values()) + { + for (String colours : type.getColoursUsed()) + { + if (WorldData.GetDataLocs(colours).isEmpty()) + { + continue typeLoop; + } + } + + _animation = type.createInstance(this); + _animation.onParse(); + } + + if (_animation == null) + { + _animation = new CustomBridgeAnimation(this); + _animation.onParse(); + } + ParseLavaBridge(); ParseWoodBridge(); ParseIceBridge(); @@ -403,8 +541,6 @@ public class Bridge extends TeamGame implements OreObsfucation } } - - public void ParseOre(ArrayList teamOre) { int coal = (int) ((teamOre.size() / 32d) * _oreDensity); @@ -703,36 +839,49 @@ public class Bridge extends TeamGame implements OreObsfucation @EventHandler public void BridgeBuild(UpdateEvent event) { - if (!IsLive()) + if (!IsLive() || !UtilTime.elapsed(GetStateTime(), _bridgeTime)) + { return; - - if (event.getType() != UpdateType.FASTEST) + } + + if (_animation != null) + { + _animation.onUpdate(event.getType()); + } + + if (event.getType() != UpdateType.FAST) + { return; - - 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) + _bridgesDown = true; + + WorldBorderModule borderModule = getModule(WorldBorderModule.class); + + for (Player player : GetPlayers(true)) { - ((KitDestructor)kit).SetEnabled(true); + borderModule.setSize(player, 1000); + } + + Manager.GetExplosion().SetLiquidDamage(true); + Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "THE BRIDGES ARE SPAWNING!"); + + for (Kit kit : GetKits()) + { + if (kit instanceof KitDestructor) + { + ((KitDestructor)kit).SetEnabled(true); + } } } - - BuildWood(); - BuildLava(); - BuildIce(); - BuildLillyPad(); - buildMushroom(); + +// BuildWood(); +// BuildLava(); +// BuildIce(); +// BuildLillyPad(); +// buildMushroom(); } protected void BuildLava() @@ -1515,7 +1664,7 @@ public class Bridge extends TeamGame implements OreObsfucation else { Scoreboard.write(C.cYellow + C.Bold + "Time Left"); - Scoreboard.write(UtilTime.MakeStr(5400000 - (System.currentTimeMillis() - this.GetStateTime()), 0)); + Scoreboard.write(UtilTime.MakeStr(GameTimeout - (System.currentTimeMillis() - GetStateTime()), 0)); } Scoreboard.draw(); @@ -1923,7 +2072,7 @@ public class Bridge extends TeamGame implements OreObsfucation _ore.ToggleVisibility(); if (Manager.GetClients().hasRank(event.getPlayer(), Rank.ADMIN) && event.getMessage().contains("/bridge")) - _bridgeTime = 30000; + _bridgeTime = 3000; } @EventHandler @@ -1961,6 +2110,11 @@ public class Bridge extends TeamGame implements OreObsfucation return _chestLoot; } + public HashSet getBridgeParts() + { + return _bridgeParts; + } + public boolean bridgesDown() { return _bridgesDown; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimation.java new file mode 100644 index 000000000..8c3496f10 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimation.java @@ -0,0 +1,45 @@ +package nautilus.game.arcade.game.games.bridge.animation; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; + +import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.game.games.bridge.Bridge; +import nautilus.game.arcade.game.games.bridge.BridgePart; +import nautilus.game.arcade.world.WorldData; + +public abstract class BridgeAnimation +{ + + public static final int AVERAGE_BRIDGE_BLOCKS = 3000; + + protected final Bridge _bridge; + protected final WorldData _worldData; + + public BridgeAnimation(Bridge bridge) + { + _bridge = bridge; + _worldData = bridge.WorldData; + } + + public abstract void onParse(); + + public abstract void onUpdate(UpdateType type); + + public void registerBridgePart(BridgePart part) + { + _bridge.getBridgeParts().add(part); + } + + public boolean isAir(Location location) + { + return isAir(location.getBlock()); + } + + public boolean isAir(Block block) + { + return block.getType() == Material.AIR; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimationType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimationType.java new file mode 100644 index 000000000..bf2207187 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimationType.java @@ -0,0 +1,42 @@ +package nautilus.game.arcade.game.games.bridge.animation; + +import nautilus.game.arcade.game.games.bridge.Bridge; + +public enum BridgeAnimationType +{ + + WOOD(WoodBridgeAnimation.class, "BROWN", "GRAY"), + ICE(IceBridgeAnimation.class, "LIGHT_BLUE"), + LAVA(LavaBridgeAnimation.class, "BLACK", "RED", "ORANGE") + + ; + + private final Class _clazz; + private final String[] _coloursUsed; + + private BridgeAnimationType(Class clazz, String... coloursUsed) + { + _clazz = clazz; + _coloursUsed = coloursUsed; + } + + public BridgeAnimation createInstance(Bridge bridge) + { + try + { + return _clazz.cast(_clazz.getConstructor(Bridge.class).newInstance(bridge)); + } + catch (Exception e) + { + e.printStackTrace(); + } + + return null; + } + + public String[] getColoursUsed() + { + return _coloursUsed; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/CustomBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/CustomBridgeAnimation.java new file mode 100644 index 000000000..921676590 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/CustomBridgeAnimation.java @@ -0,0 +1,153 @@ +package nautilus.game.arcade.game.games.bridge.animation; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.game.games.bridge.Bridge; + +public class CustomBridgeAnimation extends BridgeAnimation +{ + + private static final String REGION_KEY = "BRIDGE"; + private static final String BRIDGE_DATA_KEY = "CUSTOM_BRIDGE"; + private static final double RATE = 0.5; + + private final BlockRestore _restore; + private final Map _bridgeBlocks; + + private int[] _blockIds; + + private double _maxDistance; + private double _minDistance; + + public CustomBridgeAnimation(Bridge bridge) + { + super(bridge); + + _restore = bridge.getArcadeManager().GetBlockRestore(); + _bridgeBlocks = new HashMap<>(AVERAGE_BRIDGE_BLOCKS); + } + + @Override + public void onParse() + { + _maxDistance = 0; + + for (String key : _worldData.GetAllCustomLocs().keySet()) + { + if (!key.startsWith(BRIDGE_DATA_KEY)) + { + continue; + } + + String[] split = key.split(" "); + int[] blockIds = new int[split.length - 1]; + + for (int i = 1; i < split.length; i++) + { + try + { + blockIds[i - 1] = Integer.parseInt(split[i]); + } + catch (NumberFormatException e) + { + continue; + } + } + + _blockIds = blockIds; + } + + for (String key : _worldData.GetAllCustomLocs().keySet()) + { + if (!key.startsWith(REGION_KEY)) + { + continue; + } + + List locations = _worldData.GetCustomLocs(key); + + if (locations.size() < 2) + { + continue; + } + + for (Block block : UtilBlock.getInBoundingBox(locations.get(0), locations.get(1))) + { + boolean shouldAdd = false; + + for (int id : _blockIds) + { + if (block.getTypeId() == id) + { + shouldAdd = true; + break; + } + } + + if (!shouldAdd) + { + continue; + } + + double dist = UtilMath.offset2d(block.getLocation(), _bridge.GetSpectatorLocation()); + + if (dist > _maxDistance) + { + _maxDistance = dist; + } + + _restore.add(block, Material.AIR.getId(), (byte) 0, Integer.MAX_VALUE); + _bridgeBlocks.put(block.getLocation(), dist); + } + } + + _minDistance = _maxDistance; + } + + @Override + public void onUpdate(UpdateType type) + { + if (type != UpdateType.FAST) + { + return; + } + + _minDistance -= RATE; + + Iterator iterator = _bridgeBlocks.keySet().iterator(); + + while (iterator.hasNext()) + { + Location location = iterator.next(); + double dist = _bridgeBlocks.get(location); + + if (dist > _minDistance) + { + Block block = location.getBlock(); + + _restore.restore(block); + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, block.getLocation().add(0.5, 1.5, 0.5), 0.25F, 0.25F, 0.25F, 0.05F, 5, ViewDist.NORMAL); + + location.getWorld().playSound(location, Sound.ZOMBIE_UNFECT, 1.5F, 1); + + iterator.remove(); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/IceBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/IceBridgeAnimation.java new file mode 100644 index 000000000..6b555e861 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/IceBridgeAnimation.java @@ -0,0 +1,79 @@ +package nautilus.game.arcade.game.games.bridge.animation; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; + +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.game.games.bridge.Bridge; + +public class IceBridgeAnimation extends BridgeAnimation +{ + + private List _iceBridge; + + public IceBridgeAnimation(Bridge bridge) + { + super(bridge); + + _iceBridge = new ArrayList<>(AVERAGE_BRIDGE_BLOCKS); + } + + @Override + public void onParse() + { + _iceBridge = _worldData.GetDataLocs("LIGHT_BLUE"); + } + + @Override + public void onUpdate(UpdateType type) + { + if (type != UpdateType.FASTEST || _iceBridge.isEmpty()) + { + return; + } + + int attempts = 0; + int done = 0; + + while (done < 5 && attempts < 400) + { + attempts++; + + // Random Block + Location loc = UtilAlg.Random(_iceBridge); + + 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(block.getLocation(), Material.PACKED_ICE); + } + else + { + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.ICE); + } + + done++; + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/LavaBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/LavaBridgeAnimation.java new file mode 100644 index 000000000..2cf015470 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/LavaBridgeAnimation.java @@ -0,0 +1,84 @@ +package nautilus.game.arcade.game.games.bridge.animation; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.FallingBlock; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.game.games.bridge.Bridge; +import nautilus.game.arcade.game.games.bridge.BridgePart; + +public class LavaBridgeAnimation extends BridgeAnimation +{ + + private List _lavaSource; + private List _lavaBridge; + + public LavaBridgeAnimation(Bridge bridge) + { + super(bridge); + + _lavaSource = new ArrayList<>(); + _lavaBridge = new ArrayList<>(AVERAGE_BRIDGE_BLOCKS); + } + + @Override + public void onParse() + { + for (Location loc : _worldData.GetDataLocs("RED")) + { + _lavaBridge.add(loc.getBlock().getLocation()); + } + + for (Location loc : _worldData.GetDataLocs("ORANGE")) + { + _lavaBridge.add(loc.getBlock().getLocation()); + _lavaBridge.add(loc.getBlock().getRelative(BlockFace.UP).getLocation()); + } + + _lavaSource = _worldData.GetDataLocs("BLACK"); + } + + @Override + public void onUpdate(UpdateType type) + { + if (type != UpdateType.FASTEST) + { + return; + } + + for (int i = 0; i < 3; i++) + { + if (!_lavaBridge.isEmpty() && !_lavaSource.isEmpty()) + { + // Random Block + Location bestLoc = _lavaBridge.get(UtilMath.r(_lavaBridge.size())); + + if (bestLoc.getBlock().getRelative(BlockFace.DOWN).isLiquid()) + { + continue; + } + + _lavaBridge.remove(bestLoc); + + Location source = _lavaSource.get(UtilMath.r(_lavaSource.size())); + + // Create Part + FallingBlock block = bestLoc.getWorld().spawnFallingBlock(source, Material.NETHERRACK, (byte) 0); + BridgePart part = new BridgePart(block, bestLoc, true); + + registerBridgePart(part); + + // Sound + source.getWorld().playSound(source, Sound.EXPLODE, 5f * (float) Math.random(), 0.5f + (float) Math.random()); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/WoodBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/WoodBridgeAnimation.java new file mode 100644 index 000000000..ecafe937b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/WoodBridgeAnimation.java @@ -0,0 +1,129 @@ +package nautilus.game.arcade.game.games.bridge.animation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.FallingBlock; +import org.bukkit.util.Vector; + +import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.game.games.bridge.Bridge; +import nautilus.game.arcade.game.games.bridge.BridgePart; + +public class WoodBridgeAnimation extends BridgeAnimation +{ + + private static final BlockFace[] FACES = new BlockFace[] { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST }; + private static final int Y_MOD = 30; + + private final Map _woodBridge; + + public WoodBridgeAnimation(Bridge bridge) + { + super(bridge); + + _woodBridge = new HashMap<>(AVERAGE_BRIDGE_BLOCKS); + } + + @Override + public void onParse() + { + onParse(_worldData.GetDataLocs("BROWN"), false); + onParse(_worldData.GetDataLocs("GRAY"), true); + } + + public void onParse(List locations, boolean aboveBelow) + { + for (Location location : locations) + { + if (aboveBelow) + { + _woodBridge.put(location.getBlock().getRelative(BlockFace.UP).getLocation(), Material.FENCE); + _woodBridge.put(location, Material.LOG); + } + else + { + _woodBridge.put(location, Material.WOOD_STEP); + } + } + } + + @Override + public void onUpdate(UpdateType type) + { + if (type != UpdateType.FASTEST) + { + return; + } + + List toDo = new ArrayList<>(); + + for (Location location : _woodBridge.keySet()) + { + Material material = _woodBridge.get(location); + + if (material == Material.LOG) + { + int adjacent = 0; + + for (BlockFace face : FACES) + { + if (!isAir(location.getBlock().getRelative(face))) + { + adjacent++; + } + } + if (adjacent > 0) + { + toDo.add(location); + } + } + else if (material == Material.FENCE) + { + if (!isAir(location.getBlock().getRelative(BlockFace.DOWN))) + { + toDo.add(location); + } + } + else if (material == Material.WOOD_STEP) + { + int adjacent = 0; + + for (BlockFace face : FACES) + { + if (!isAir(location.getBlock().getRelative(face))) + { + adjacent++; + } + } + if (adjacent > 0) + { + toDo.add(location); + } + } + } + + if (toDo.size() == 0) + { + return; + } + + for (Location location : toDo) + { + Material material = _woodBridge.remove(location); + Location source = location.clone().add(0, Y_MOD, 0); + + // Create Part + FallingBlock block = location.getWorld().spawnFallingBlock(source, material, (byte) 0); + block.setVelocity(new Vector(0, -1, 0)); + BridgePart part = new BridgePart(block, location, false); + + registerBridgePart(part); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/Module.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/Module.java index 2aed67d39..638d2620b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/Module.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/Module.java @@ -1,10 +1,7 @@ package nautilus.game.arcade.game.modules; import com.google.gson.JsonElement; -import mineplex.core.Managers; -import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.TeamGame; import org.bukkit.event.Listener; /** diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/WorldBorderModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/WorldBorderModule.java new file mode 100644 index 000000000..6a1f13bae --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/WorldBorderModule.java @@ -0,0 +1,116 @@ +package nautilus.game.arcade.game.modules; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.common.Pair; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder; +import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder.EnumWorldBorderAction; +import net.minecraft.server.v1_8_R3.WorldBorder; + +public class WorldBorderModule extends Module implements IPacketHandler +{ + + private PacketHandler _packetHandler; + private Map _sizeToSet; + private Map> _centerToSet; + + @Override + protected void setup() + { + _packetHandler = getGame().getArcadeManager().getPacketHandler(); + _sizeToSet = new HashMap<>(); + _centerToSet = new HashMap<>(); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + _packetHandler.addPacketHandler(this, PacketPlayOutWorldBorder.class); + } + + @Override + public void handle(PacketInfo packetInfo) + { + UUID player = packetInfo.getPlayer().getUniqueId(); + PacketPlayOutWorldBorder packet = (PacketPlayOutWorldBorder) packetInfo.getPacket(); + + try + { + Field actionField = packet.getClass().getDeclaredField("a"); + actionField.setAccessible(true); + EnumWorldBorderAction action = (EnumWorldBorderAction) actionField.get(packet); + + if (action == EnumWorldBorderAction.SET_SIZE) + { + Field sizeField = packet.getClass().getDeclaredField("e"); + sizeField.setAccessible(true); + double newSize = _sizeToSet.get(player); + + sizeField.set(packet, newSize); + } + else if (action == EnumWorldBorderAction.SET_CENTER) + { + Field xField = packet.getClass().getDeclaredField("c"); + Field zField = packet.getClass().getDeclaredField("d"); + + xField.setAccessible(true); + zField.setAccessible(true); + + Pair pair = _centerToSet.get(player); + + xField.set(packet, pair.getLeft()); + zField.set(packet, pair.getRight()); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + @Override + public void cleanup() + { + _packetHandler.removePacketHandler(this); + } + + public void setSize(Player player, double size) + { + _sizeToSet.put(player.getUniqueId(), size); + + sendPacket(player, EnumWorldBorderAction.SET_SIZE); + } + + public void setCenter(Player player, Location location) + { + _centerToSet.put(player.getUniqueId(), Pair.create(location.getX(), location.getZ())); + + sendPacket(player, EnumWorldBorderAction.SET_CENTER); + } + + private void sendPacket(Player player, EnumWorldBorderAction action) + { + WorldBorder border = ((CraftWorld) player.getWorld()).getHandle().getWorldBorder(); + UtilPlayer.sendPacket(player, new PacketPlayOutWorldBorder(border, action)); + } +} From 13806a49d2a89b480acc172309e973133c655c22 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 3 Feb 2017 20:33:21 +0000 Subject: [PATCH 02/16] Bridges bug fixes --- .../game/arcade/game/games/bridge/Bridge.java | 581 ++++-------------- .../bridge/animation/BridgeAnimationType.java | 4 +- .../animation/LillyPadBridgeAnimation.java | 65 ++ .../animation/MushroomBridgeAnimation.java | 107 ++++ .../game/games/bridge/kits/KitDestructor.java | 2 +- .../games/bridge/modes/OverpoweredBridge.java | 36 +- .../game/arcade/kit/perks/PerkDestructor.java | 4 +- .../stats/FoodForTheMassesStatTracker.java | 6 + 8 files changed, 319 insertions(+), 486 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/LillyPadBridgeAnimation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/MushroomBridgeAnimation.java 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 ac985ad84..813f8349a 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 @@ -13,14 +13,12 @@ import org.bukkit.Effect; import org.bukkit.GameMode; 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.block.Chest; import org.bukkit.entity.Chicken; import org.bukkit.entity.Cow; import org.bukkit.entity.Entity; -import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Item; import org.bukkit.entity.Pig; import org.bukkit.entity.Player; @@ -31,9 +29,11 @@ import org.bukkit.event.block.BlockFormEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketFillEvent; @@ -48,7 +48,6 @@ import org.bukkit.util.Vector; import mineplex.core.common.Rank; 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.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -71,7 +70,6 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerDeathOutEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; @@ -89,6 +87,8 @@ import nautilus.game.arcade.game.games.bridge.kits.KitMiner; import nautilus.game.arcade.game.modules.WorldBorderModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDestructor; import nautilus.game.arcade.ore.OreHider; import nautilus.game.arcade.ore.OreObsfucation; import nautilus.game.arcade.stats.BridgesSniperStatTracker; @@ -118,25 +118,6 @@ public class Bridge extends TeamGame implements OreObsfucation private long _bridgeTime = BRIDGE_TIME; private boolean _bridgesDown = false; private BridgeAnimation _animation; - - //Wood Bridge - private ArrayList _woodBridge = new ArrayList(); - private HashMap _woodBridgeBlocks = null; - - //Lava Bridge - private ArrayList _lavaBridge = new ArrayList(); - private ArrayList _lavaSource = new ArrayList(); - - //Lilly Pad Bridge - private NautHashMap _lillyPads = new NautHashMap(); - - //Mushrooms - private NautHashMap _mushroomStem = new NautHashMap(); - private NautHashMap _mushroomTop = new NautHashMap(); - private boolean _stemsGrown = false; - - //Ice - private ArrayList _iceBridge = new ArrayList(); private HashSet _bridgeParts = new HashSet(); @@ -273,26 +254,20 @@ public class Bridge extends TeamGame implements OreObsfucation .register(this); new WorldBorderModule().register(this); - } - - //TODO move this lower and use EntityDamage - @EventHandler - public void PlayerOut(final PlayerDeathOutEvent event) - { - if (_bridgesDown) - { - return; - } - Player player = event.GetPlayer(); - - if (!_usedLife.contains(player.getName())) + // So that we can be 110% sure + for (Kit kit : GetKits()) { - _usedLife.add(player.getName()); - - UtilPlayer.message(player, F.main("Game", "You used your " + F.elem(C.cAqua + "Early Game Revive") + ".")); - - event.setCancelled(true); + if (kit instanceof KitDestructor) + { + for (Perk perk : kit.GetPerks()) + { + ((PerkDestructor) perk).setEnabled(false); + break; + } + + break; + } } } @@ -308,54 +283,25 @@ public class Bridge extends TeamGame implements OreObsfucation Manager.runSyncLater(() -> { WorldBorderModule borderModule = getModule(WorldBorderModule.class); - boolean oldWay = WorldData.GetCustomLocs("BORDER").isEmpty() || WorldData.GetCustomLocs("BORDER CENTER").isEmpty(); - -// if (!oldWay) -// { -// // Step 1 - Get the vector offset between the spectator location and the center of the border -// Location center = WorldData.GetCustomLocs("BORDER").get(0); -// -// Vector offset = center.subtract(SpectatorSpawn.toVector()).toVector(); -// } // Here we do some calculations for per player world borders for (GameTeam team : GetTeamList()) { - if (oldWay) + // If this is an old map or the builders haven't done it properly we can use this more of an estimate of the border size + // Step 1 - Get the average location of the spawns, we will assume this is the centre of the island + Location center = UtilAlg.getAverageLocation(team.GetSpawns()); + center.add(UtilAlg.getTrajectory(SpectatorSpawn, center).multiply(20)); + + // Step 2 - Calculate an estimate for the size of the border. We'll go with half but the setSize uses the radius so it works out the same to leave it like this + double distToCenter = UtilMath.offset2d(SpectatorSpawn, center); + + // Step 3 - Send the setCenter and setSize packets to the team members + for (Player player : team.GetPlayers(true)) { - // If this is an old map or the builders haven't done it properly we can use this more of an estimate of the border size - // Step 1 - Get the average location of the spawns, we will assume this is the centre of the island - Location center = UtilAlg.getAverageLocation(team.GetSpawns()); - - // Step 2 - Calculate an estimate for the size of the border. We'll go with half but the setSize uses the radius so it works out the same to leave it like this - double distToCenter = UtilMath.offset2d(SpectatorSpawn, center); - - // Step 3 - Send the setCenter and setSize packets to the team members - for (Player player : team.GetPlayers(true)) - { - borderModule.setCenter(player, center); - borderModule.setSize(player, distToCenter); - } + borderModule.setCenter(player, center); + borderModule.setSize(player, distToCenter * 0.6); } -// else -// { -// // Step 1 - Get the vector offset between the spectator location and the center of the border -// Location edge = WorldData.GetCustomLocs("BORDER").get(0); -// Location center = WorldData.GetCustomLocs("BORDER CENTER").get(0); -// -// Vector offset = center.subtract(SpectatorSpawn.toVector()).toVector(); -// -// // Step 2 - Calculate the distance between the the two border data points -// // Multiple by 2 because it is a radius -// double borderSize = UtilMath.offset2d(edge, center) * 2; -// -// // Step 3 - Send the setCenter and setSize packets to the team members -// for (Player player : team.GetPlayers(true)) -// { -// borderModule.setCenter(player, center); -// borderModule.setSize(player, borderSize); -// } -// } + } }, WORLD_BORDER_PREPARE_TICKS); @@ -417,12 +363,6 @@ public class Bridge extends TeamGame implements OreObsfucation _animation.onParse(); } - ParseLavaBridge(); - ParseWoodBridge(); - ParseIceBridge(); - ParseLillyPad(); - ParseMushrooms(); - ParseChests(); ParseOre(WorldData.GetCustomLocs("73")); // Red @@ -761,81 +701,6 @@ public class Bridge extends TeamGame implements OreObsfucation } } - protected void ParseWoodBridge() { - _woodBridge = new ArrayList(); - - // Load Wood In - for (Location loc : WorldData.GetDataLocs("BROWN")) { - _woodBridge.add(loc.getBlock().getLocation()); - } - - for (Location loc : WorldData.GetDataLocs("GRAY")) { - _woodBridge.add(loc.getBlock().getLocation()); - _woodBridge.add(loc.getBlock().getRelative(BlockFace.UP) - .getLocation()); - } - - // Determine Wood Block - _woodBridgeBlocks = new HashMap(); - - for (Location loc : _woodBridge) { - if (_woodBridge.contains(loc.getBlock().getRelative(BlockFace.DOWN) - .getLocation())) { - _woodBridgeBlocks.put(loc, 85); - } - - if (_woodBridge.contains(loc.getBlock().getRelative(BlockFace.UP) - .getLocation())) { - _woodBridgeBlocks.put(loc, 17); - } - - if (!_woodBridgeBlocks.containsKey(loc)) { - _woodBridgeBlocks.put(loc, 126); - } - } - } - - protected void ParseLavaBridge() { - for (Location loc : WorldData.GetDataLocs("RED")) { - _lavaBridge.add(loc.getBlock().getLocation()); - } - - for (Location loc : WorldData.GetDataLocs("ORANGE")) { - _lavaBridge.add(loc.getBlock().getLocation()); - _lavaBridge.add(loc.getBlock().getRelative(BlockFace.UP) - .getLocation()); - } - - _lavaSource = WorldData.GetDataLocs("BLACK"); - } - - protected void ParseIceBridge() - { - _iceBridge = WorldData.GetDataLocs("LIGHT_BLUE"); - } - - protected 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); - } - } - - protected void ParseLillyPad() - { - for (Location loc : WorldData.GetDataLocs("LIME")) - { - _lillyPads.put(loc, 0L); - } - } - @EventHandler public void BridgeBuild(UpdateEvent event) { @@ -866,7 +731,8 @@ public class Bridge extends TeamGame implements OreObsfucation } Manager.GetExplosion().SetLiquidDamage(true); - Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "THE BRIDGES ARE SPAWNING!"); + Announce(C.cRedB + "ALERT: " + C.Reset + C.Bold + "THE BRIDGES ARE SPAWNING!"); + UtilTextMiddle.display(C.cRedB + "ALERT", "The BRIDGES ARE SPAWNING!"); for (Kit kit : GetKits()) { @@ -876,269 +742,43 @@ public class Bridge extends TeamGame implements OreObsfucation } } } - -// BuildWood(); -// BuildLava(); -// BuildIce(); -// BuildLillyPad(); -// buildMushroom(); } - protected void BuildLava() - { - for (int i = 0; i < 3; i++) - if (_lavaBridge != null && _lavaSource != null - && !_lavaBridge.isEmpty() && !_lavaSource.isEmpty()) { - // Random Block - Location bestLoc = _lavaBridge.get(UtilMath.r(_lavaBridge - .size())); - if (bestLoc.getBlock().getRelative(BlockFace.DOWN) - .isLiquid()) - continue; - - _lavaBridge.remove(bestLoc); - - Location source = _lavaSource.get(UtilMath.r(_lavaSource - .size())); - - // Create Part - FallingBlock block = bestLoc.getWorld().spawnFallingBlock( - source, 87, (byte) 0); - BridgePart part = new BridgePart(block, bestLoc, true); - _bridgeParts.add(part); - - // Sound - source.getWorld().playSound(source, Sound.EXPLODE, - 5f * (float) Math.random(), - 0.5f + (float) Math.random()); - } - } - - protected void BuildLillyPad() - { - for (int i = 0; i < 3; i++) - if (_lillyPads != null && !_lillyPads.isEmpty()) - { - // Random Block - Location loc = UtilAlg.Random(_lillyPads.keySet()); - - if (!UtilTime.elapsed(_lillyPads.get(loc), 8000)) - continue; - - if (!loc.getBlock().getRelative(BlockFace.DOWN).isLiquid()) - continue; - - _lillyPads.remove(loc); - - MapUtil.QuickChangeBlockAt(loc, Material.WATER_LILY); - - // Sound - loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 111); - } - } - - @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)); - } +// @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)); +// } - protected 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 - { - _stemsGrown = true; - } - - if (_stemsGrown && _mushroomTop != null && !_mushroomTop.isEmpty()) - { - int attempts = 0; - int done = 0; - while (done < 6 && 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); - - done++; - } - } - } - - @EventHandler - public void breakMushroom(BlockBreakEvent event) - { - if (event.isCancelled()) - return; - - - if (event.getBlock().getTypeId() == 100 && - WorldData.GetCustomLocs("21").contains(event.getBlock().getLocation().add(0.5, 0, 0.5))) - { - event.setCancelled(true); - event.getBlock().setType(Material.AIR); - - _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))) - { - event.setCancelled(true); - event.getBlock().setType(Material.AIR); - - _mushroomTop.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000)); - } - } - - protected void BuildIce() - { - 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 < 5 && attempts < 400) - { - 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(block.getLocation(), Material.PACKED_ICE); - else - MapUtil.QuickChangeBlockAt(block.getLocation(), Material.ICE); - - done++; - } - } - - protected void BuildWood() - { - if (_woodBridgeBlocks != null && !_woodBridgeBlocks.isEmpty()) - { - ArrayList toDo = new ArrayList(); - - BlockFace[] faces = new BlockFace[] { BlockFace.NORTH, - BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST }; - - for (Location loc : _woodBridgeBlocks.keySet()) - { - if (_woodBridgeBlocks.get(loc) == 17) - { - int adjacent = 0; - - for (BlockFace face : faces) - if (loc.getBlock().getRelative(face).getTypeId() != 0) - adjacent++; - - if (adjacent > 0) - toDo.add(loc); - - } else if (_woodBridgeBlocks.get(loc) == 85) - { - if (loc.getBlock().getRelative(BlockFace.DOWN).getTypeId() == 0) - continue; - - toDo.add(loc); - } else if (_woodBridgeBlocks.get(loc) == 126) - { - int adjacent = 0; - - for (BlockFace face : faces) - if (loc.getBlock().getRelative(face).getTypeId() != 0) - adjacent++; - - if (adjacent > 0) - toDo.add(loc); - } - } - - if (toDo.size() == 0) - return; - - for (Location loc : toDo) - { - int id = _woodBridgeBlocks.remove(loc); - - Location source = loc.clone().add(0, 30, 0); - - // Create Part - FallingBlock block = loc.getWorld().spawnFallingBlock(source, - id, (byte) 0); - block.setVelocity(new Vector(0, -1, 0)); - BridgePart part = new BridgePart(block, loc, false); - _bridgeParts.add(part); - } - } - } +// @EventHandler +// public void breakMushroom(BlockBreakEvent event) +// { +// if (event.isCancelled()) +// return; +// +// +// if (event.getBlock().getTypeId() == 100 && +// WorldData.GetCustomLocs("21").contains(event.getBlock().getLocation().add(0.5, 0, 0.5))) +// { +// event.setCancelled(true); +// event.getBlock().setType(Material.AIR); +// +// _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))) +// { +// event.setCancelled(true); +// event.getBlock().setType(Material.AIR); +// +// _mushroomTop.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000)); +// } +// } @EventHandler public void BridgeUpdate(UpdateEvent event) @@ -1255,7 +895,7 @@ public class Bridge extends TeamGame implements OreObsfucation while (!UtilBlock.airFoliage(block)) { block = block.getRelative(BlockFace.UP); - + if (block.getY() >= 256) break; } @@ -1268,15 +908,15 @@ public class Bridge extends TeamGame implements OreObsfucation break; } - block = block.getRelative(BlockFace.UP); - - if (block.getTypeId() == 0) + if (block.getType() != Material.SNOW) { - if (Math.random() > 0.5) - block.setTypeId(39); - else - block.setTypeId(40); + block = block.getRelative(BlockFace.UP); } + + if (Math.random() > 0.5) + block.setTypeId(39); + else + block.setTypeId(40); } } @@ -2023,23 +1663,32 @@ 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(priority=EventPriority.LOWEST) + public void revivePlayer(EntityDamageEvent event) + { + if (_bridgesDown || !(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + if (player.getHealth() - event.getDamage() > 0) + { + return; + } + + if (!_usedLife.contains(player.getName())) + { + _usedLife.add(player.getName()); + + UtilPlayer.message(player, F.main("Game", "You used your " + F.elem(C.cAqua + "Early Game Revive") + ".")); + + GetTeam(player).SpawnTeleport(player); + player.setHealth(20); + event.setCancelled(true); + } + } @EventHandler public void vehicleDeny(PlayerInteractEvent event) @@ -2089,6 +1738,40 @@ public class Bridge extends TeamGame implements OreObsfucation UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot pickup liquids before the bridges have fallen.")); event.setCancelled(true); } + + @EventHandler + public void disableDoors(CraftItemEvent event) + { + if (_bridgesDown) + { + return; + } + + Material type = event.getRecipe().getResult().getType(); + + if (type == Material.WOOD_DOOR || type == Material.IRON_DOOR) + { + event.setResult(null); + event.setCancelled(true); + } + } + + @EventHandler + public void disableDoors(PlayerPickupItemEvent event) + { + if (_bridgesDown) + { + return; + } + + Material type = event.getItem().getItemStack().getType(); + + if (type == Material.WOOD_DOOR || type == Material.IRON_DOOR) + { + event.getItem().remove(); + event.setCancelled(true); + } + } public void setBridgeTime(int time) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimationType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimationType.java index bf2207187..a7a8aa739 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimationType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/BridgeAnimationType.java @@ -7,7 +7,9 @@ public enum BridgeAnimationType WOOD(WoodBridgeAnimation.class, "BROWN", "GRAY"), ICE(IceBridgeAnimation.class, "LIGHT_BLUE"), - LAVA(LavaBridgeAnimation.class, "BLACK", "RED", "ORANGE") + LAVA(LavaBridgeAnimation.class, "BLACK", "RED", "ORANGE"), + LILLY(LillyPadBridgeAnimation.class, "LIME"), + MUSHROOM(MushroomBridgeAnimation.class, "PURPLE") ; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/LillyPadBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/LillyPadBridgeAnimation.java new file mode 100644 index 000000000..839a9536e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/LillyPadBridgeAnimation.java @@ -0,0 +1,65 @@ +package nautilus.game.arcade.game.games.bridge.animation; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; + +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.game.games.bridge.Bridge; + +public class LillyPadBridgeAnimation extends BridgeAnimation +{ + + private Map _lillyPads = new HashMap<>(); + + public LillyPadBridgeAnimation(Bridge bridge) + { + super(bridge); + } + + @Override + public void onParse() + { + for (Location loc : _worldData.GetDataLocs("LIME")) + { + _lillyPads.put(loc, 0L); + } + } + + @Override + public void onUpdate(UpdateType type) + { + if (type != UpdateType.FASTEST) + return; + + for (int i = 0; i < 3; i++) + { + if (_lillyPads != null && !_lillyPads.isEmpty()) + { + // Random Block + Location loc = UtilAlg.Random(_lillyPads.keySet()); + + if (!UtilTime.elapsed(_lillyPads.get(loc), 8000)) + continue; + + if (!loc.getBlock().getRelative(BlockFace.DOWN).isLiquid()) + continue; + + _lillyPads.remove(loc); + + MapUtil.QuickChangeBlockAt(loc, Material.WATER_LILY); + + // Sound + loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 111); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/MushroomBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/MushroomBridgeAnimation.java new file mode 100644 index 000000000..dad3ecdb7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/MushroomBridgeAnimation.java @@ -0,0 +1,107 @@ +package nautilus.game.arcade.game.games.bridge.animation; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; + +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.game.games.bridge.Bridge; + +public class MushroomBridgeAnimation extends BridgeAnimation +{ + + private Map _mushroomStem = new HashMap<>(); + private Map _mushroomTop = new HashMap<>(); + private boolean _stemsGrown = false; + + public MushroomBridgeAnimation(Bridge bridge) + { + super(bridge); + } + + @Override + public void onParse() + { + 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); + } + } + + @Override + public void onUpdate(UpdateType type) + { + 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 + { + _stemsGrown = true; + } + + if (_stemsGrown && _mushroomTop != null && !_mushroomTop.isEmpty()) + { + int attempts = 0; + int done = 0; + while (done < 6 && 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); + + done++; + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitDestructor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitDestructor.java index b5710854f..178ae8ef1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitDestructor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitDestructor.java @@ -44,7 +44,7 @@ public class KitDestructor extends ProgressingKit { super(manager, "Destructor", "bridgedesctructor", KitAvailability.Achievement, 99999, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - this.setAchievementRequirements(ACHIEVEMENTS); + setAchievementRequirements(ACHIEVEMENTS); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java index 17b6b5ce5..5935aaee0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/modes/OverpoweredBridge.java @@ -14,7 +14,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.EnchantmentStorageMeta; @@ -29,7 +28,6 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.AbsorptionFix; import nautilus.game.arcade.game.games.bridge.Bridge; import net.md_5.bungee.api.ChatColor; @@ -72,38 +70,8 @@ public class OverpoweredBridge extends Bridge public void ParseData() { _starterChests = new HashMap<>(); - - ParseLavaBridge(); - ParseWoodBridge(); - ParseIceBridge(); - ParseLillyPad(); - ParseMushrooms(); - - ParseChests(); - - ParseOre(WorldData.GetCustomLocs("73")); // Red - ParseOre(WorldData.GetCustomLocs("14")); // Yellow - ParseOre(WorldData.GetCustomLocs("129")); // Green - ParseOre(WorldData.GetCustomLocs("56")); // Blue - - //Mass Teams - if (!WorldData.GetCustomLocs("152").isEmpty()) - ParseOre(WorldData.GetCustomLocs("152")); - if (!WorldData.GetCustomLocs("41").isEmpty()) - ParseOre(WorldData.GetCustomLocs("41")); - if (!WorldData.GetCustomLocs("133").isEmpty()) - ParseOre(WorldData.GetCustomLocs("133")); - if (!WorldData.GetCustomLocs("57").isEmpty()) - ParseOre(WorldData.GetCustomLocs("57")); - - if (!WorldData.GetCustomLocs("100").isEmpty()) - ParseOre(WorldData.GetCustomLocs("100")); - if (!WorldData.GetCustomLocs("86").isEmpty()) - ParseOre(WorldData.GetCustomLocs("86")); - if (!WorldData.GetCustomLocs("103").isEmpty()) - ParseOre(WorldData.GetCustomLocs("103")); - if (!WorldData.GetCustomLocs("22").isEmpty()) - ParseOre(WorldData.GetCustomLocs("22")); + + super.ParseData(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java index 5d63023a5..8c575627c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java @@ -294,7 +294,9 @@ public class PerkDestructor extends Perk if (lowest != null) { - if (lowest.getType() != Material.AIR && UtilBlock.airFoliage(lowest.getRelative(BlockFace.DOWN))) + Block down = lowest.getRelative(BlockFace.DOWN); + + if (lowest.getType() != Material.AIR && (UtilBlock.airFoliage(down) || down.isLiquid())) { lowest.getWorld().playEffect(lowest.getLocation(), Effect.STEP_SOUND, lowest.getType()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FoodForTheMassesStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FoodForTheMassesStatTracker.java index 5495e89a2..de127e6b2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FoodForTheMassesStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FoodForTheMassesStatTracker.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.stats; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -40,6 +41,11 @@ public class FoodForTheMassesStatTracker extends StatTracker Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); if (player == null) return; + + if (killer.getItemInHand().getType() != Material.APPLE) + { + return; + } if (event.GetLog().GetKiller().GetReason() != null && event.GetLog().GetKiller().GetReason().contains("Apple Thrower")) { From 36f318e4a0afaa8019835746c04454c35acbf984 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 6 Feb 2017 21:00:30 +0000 Subject: [PATCH 03/16] KP Upgrades (1) --- .../game/arcade/game/games/bridge/Bridge.java | 2 +- .../game/games/bridge/kits/KitApple.java | 74 ++++++++++++++- .../game/games/bridge/kits/KitBerserker.java | 93 +++++++++++++++---- .../game/games/skywars/kits/KitMetal.java | 4 + .../game/arcade/kit/ProgressingKit.java | 8 ++ 5 files changed, 158 insertions(+), 23 deletions(-) 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 813f8349a..eabc0b467 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 @@ -290,7 +290,7 @@ public class Bridge extends TeamGame implements OreObsfucation // If this is an old map or the builders haven't done it properly we can use this more of an estimate of the border size // Step 1 - Get the average location of the spawns, we will assume this is the centre of the island Location center = UtilAlg.getAverageLocation(team.GetSpawns()); - center.add(UtilAlg.getTrajectory(SpectatorSpawn, center).multiply(20)); + center.add(UtilAlg.getTrajectory(SpectatorSpawn, center).multiply(15)); // Step 2 - Calculate an estimate for the size of the border. We'll go with half but the setSize uses the radius so it works out the same to leave it like this double distToCenter = UtilMath.offset2d(SpectatorSpawn, center); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java index 78fc4acae..c3a40cdab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java @@ -13,6 +13,9 @@ import org.bukkit.inventory.ItemStack; public class KitApple extends ProgressingKit { + private static final String PERK = "Apples"; + private static final String STARTING = "Starting amount"; + private static final String[] DESCRIPTION = { "Possess the rare skill of finding apples frequently!", "", @@ -20,20 +23,81 @@ public class KitApple extends ProgressingKit click(true, "the apple to throw it") }; - private static final Perk[] PERKS = { - new PerkApple(10000) - }; + private static final Perk[][] PERKS = + { + { + new PerkApple(17000) + }, + { + new PerkApple(15000) + }, + { + new PerkApple(15000) + }, + { + new PerkApple(13000) + }, + { + new PerkApple(13000) + }, + { + new PerkApple(11000) + }, + }; + + private static final String[][] UPGRADE_DETAILS = + { + { + reduceCooldown(COOLDOWN, 2) + }, + { + increaseNumber(PERK, STARTING, 3, PERK) + }, + { + reduceCooldown(COOLDOWN, 2) + }, + { + increaseNumber(PERK, STARTING, 3, PERK) + }, + { + reduceCooldown(COOLDOWN, 2) + }, + }; private static final ItemStack IN_HAND = new ItemStack(Material.APPLE); public KitApple(ArcadeManager manager) { - super(manager, "Apple", "bridgeapple", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); + super(manager, "Apple", "bridgeapple", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); } @Override public void GiveItems(Player player) { - + int level = getUpgradeLevel(player.getUniqueId()); + int apples = 0; + + switch (level) + { + case 2: + case 3: + apples = 3; + break; + case 4: + case 5: + apples = 6; + default: + break; + } + + if (apples > 0) { + player.getInventory().addItem(new ItemStack(Material.APPLE, apples)); + } + } + + @Override + public boolean showUpgrades() + { + return true; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java index 497017ee6..5d76bf540 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java @@ -1,17 +1,17 @@ package nautilus.game.arcade.game.games.bridge.kits; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.perks.PerkAxeman; import nautilus.game.arcade.kit.perks.PerkLeap; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; public class KitBerserker extends ProgressingKit { @@ -23,27 +23,86 @@ public class KitBerserker extends ProgressingKit "Deal " + C.cGreen + "+1" + C.cWhite + " damage using axes", click(false, " with your axe to use " + C.cGreen + "Berserker Leap") }; - - private static final Perk[] PERKS = { - new PerkLeap("Beserker Leap", 1.2, 1.2, 8000), - new PerkAxeman(), - }; - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.STONE_AXE) - }; + + private static final Perk[][] PERKS = + { + { + new PerkLeap("Beserker Leap", 1.2, 1.2, 14000), + new PerkAxeman(), + }, + { + new PerkLeap("Beserker Leap", 1.2, 1.2, 13000), + new PerkAxeman(), + }, + { + new PerkLeap("Beserker Leap", 1.2, 1.2, 13000), + new PerkAxeman(), + }, + { + new PerkLeap("Beserker Leap", 1.2, 1.2, 12000), + new PerkAxeman(), + }, + { + new PerkLeap("Beserker Leap", 1.2, 1.2, 12000), + new PerkAxeman(), + }, + { + new PerkLeap("Beserker Leap", 1.2, 1.2, 11000), + new PerkAxeman(), + }, + }; + + private static final String[][] UPGRADE_DETAILS = + { + { + reduceCooldown(COOLDOWN, 1) + }, + { + receiveItem("Crafting Table", 1) + }, + { + reduceCooldown(COOLDOWN, 1) + }, + { + receiveItem("Iron Axe", 1) + }, + { + reduceCooldown(COOLDOWN, 1) + }, + }; private static final ItemStack IN_HAND = new ItemStack(Material.STONE_AXE); public KitBerserker(ArcadeManager manager) { - super(manager, "Berserker", "bridgeberserker", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - + super(manager, "Berserker", "bridgeberserker", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); } @Override public void GiveItems(Player player) { - player.getInventory().addItem(PLAYER_ITEMS); + int level = getUpgradeLevel(player.getUniqueId()); + + // Axe + if (level >= 4) + { + player.getInventory().addItem(new ItemStack(Material.IRON_AXE)); + } + else + { + player.getInventory().addItem(new ItemStack(Material.STONE_AXE)); + } + + //Crafting table + if (level >= 2) + { + player.getInventory().addItem(new ItemStack(Material.WORKBENCH)); + } + } + + @Override + public boolean showUpgrades() + { + return true; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java index a5e4be83e..5d6cf5ff5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java @@ -90,6 +90,10 @@ public class KitMetal extends ProgressingKit @Override public void GiveItems(Player player) { + int level = getUpgradeLevel(player.getUniqueId()); + + + player.getInventory().addItem(PLAYER_ITEMS); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java index a93f7415e..eabe114f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java @@ -30,6 +30,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; import mineplex.core.donation.Donor; import mineplex.core.menu.Menu; import mineplex.core.progression.ProgressiveKit; @@ -53,6 +54,8 @@ import net.minecraft.server.v1_8_R3.World; public abstract class ProgressingKit extends Kit implements ProgressiveKit { + public static final String COOLDOWN = "Cooldown"; + private static final FireworkEffect EFFECT = FireworkEffect.builder() .withColor(Color.AQUA) .with(Type.BALL) @@ -420,6 +423,11 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit return "Receive " + C.cGreen + amount + C.cWhite + " " + item + " every " + C.cGreen + time + C.cWhite + " second" + (time == 1 ? "" : "s") + (max > 0 ? ". Max " + C.cGreen + max : ""); } + + public static String receiveItem(String item, int amount) + { + return "Receive " + (amount == 1 ? (UtilText.startsWithVowel(item) ? "an" :" a") : C.cGreen + amount) + " " + item; + } public static String click(boolean left, String comp) { From 3018f264ccab79a3d7952eef46ea3de1f4c6a66d Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 6 Feb 2017 23:28:27 +0000 Subject: [PATCH 04/16] QA ready! --- .../src/nautilus/game/arcade/game/games/bridge/Bridge.java | 2 +- .../nautilus/game/arcade/game/games/bridge/kits/KitApple.java | 2 +- .../game/arcade/game/games/bridge/kits/KitBerserker.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 eabc0b467..c01dde25e 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 @@ -299,7 +299,7 @@ public class Bridge extends TeamGame implements OreObsfucation for (Player player : team.GetPlayers(true)) { borderModule.setCenter(player, center); - borderModule.setSize(player, distToCenter * 0.6); + borderModule.setSize(player, distToCenter * 0.8); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java index c3a40cdab..e915f72b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java @@ -98,6 +98,6 @@ public class KitApple extends ProgressingKit @Override public boolean showUpgrades() { - return true; + return false; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java index 5d76bf540..70f3591a4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java @@ -103,6 +103,6 @@ public class KitBerserker extends ProgressingKit @Override public boolean showUpgrades() { - return true; + return false; } } From 2f9f55226a161e687920effaa8438510422dc73f Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 7 Feb 2017 00:05:10 +0000 Subject: [PATCH 05/16] Adjust world border distance --- .../src/nautilus/game/arcade/game/games/bridge/Bridge.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c01dde25e..beaf472c5 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 @@ -299,7 +299,7 @@ public class Bridge extends TeamGame implements OreObsfucation for (Player player : team.GetPlayers(true)) { borderModule.setCenter(player, center); - borderModule.setSize(player, distToCenter * 0.8); + borderModule.setSize(player, distToCenter * 0.9); } } From a49b19ee0cc51fd6df697ffe3226168efed9d112 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 14 Mar 2017 16:08:16 +0000 Subject: [PATCH 06/16] Removal of kit progression from bridges --- .../game/games/bridge/kits/KitApple.java | 76 ++------------- .../game/games/bridge/kits/KitArcher.java | 2 +- .../game/games/bridge/kits/KitBerserker.java | 95 ++++--------------- 3 files changed, 25 insertions(+), 148 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java index e915f72b4..021c06e83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitApple.java @@ -13,9 +13,6 @@ import org.bukkit.inventory.ItemStack; public class KitApple extends ProgressingKit { - private static final String PERK = "Apples"; - private static final String STARTING = "Starting amount"; - private static final String[] DESCRIPTION = { "Possess the rare skill of finding apples frequently!", "", @@ -23,81 +20,20 @@ public class KitApple extends ProgressingKit click(true, "the apple to throw it") }; - private static final Perk[][] PERKS = - { - { - new PerkApple(17000) - }, - { - new PerkApple(15000) - }, - { - new PerkApple(15000) - }, - { - new PerkApple(13000) - }, - { - new PerkApple(13000) - }, - { - new PerkApple(11000) - }, - }; - - private static final String[][] UPGRADE_DETAILS = - { - { - reduceCooldown(COOLDOWN, 2) - }, - { - increaseNumber(PERK, STARTING, 3, PERK) - }, - { - reduceCooldown(COOLDOWN, 2) - }, - { - increaseNumber(PERK, STARTING, 3, PERK) - }, - { - reduceCooldown(COOLDOWN, 2) - }, - }; + private static final Perk[] PERKS = { + new PerkApple(10000) + }; private static final ItemStack IN_HAND = new ItemStack(Material.APPLE); public KitApple(ArcadeManager manager) { - super(manager, "Apple", "bridgeapple", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + super(manager, "Apple", "bridgeapple", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); } @Override public void GiveItems(Player player) { - int level = getUpgradeLevel(player.getUniqueId()); - int apples = 0; - - switch (level) - { - case 2: - case 3: - apples = 3; - break; - case 4: - case 5: - apples = 6; - default: - break; - } - - if (apples > 0) { - player.getInventory().addItem(new ItemStack(Material.APPLE, apples)); - } + } - - @Override - public boolean showUpgrades() - { - return false; - } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitArcher.java index a02a04427..87ee2d8dd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitArcher.java @@ -53,6 +53,6 @@ public class KitArcher extends ProgressingKit Bridge bridge = (Bridge) Manager.GetGame(); if(!bridge.hasUsedRevive(player)) - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); + player.getInventory().addItem(PLAYER_ITEMS); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java index 70f3591a4..9204c8d7a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/kits/KitBerserker.java @@ -1,17 +1,17 @@ package nautilus.game.arcade.game.games.bridge.kits; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.perks.PerkAxeman; import nautilus.game.arcade.kit.perks.PerkLeap; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; public class KitBerserker extends ProgressingKit { @@ -23,86 +23,27 @@ public class KitBerserker extends ProgressingKit "Deal " + C.cGreen + "+1" + C.cWhite + " damage using axes", click(false, " with your axe to use " + C.cGreen + "Berserker Leap") }; - - private static final Perk[][] PERKS = - { - { - new PerkLeap("Beserker Leap", 1.2, 1.2, 14000), - new PerkAxeman(), - }, - { - new PerkLeap("Beserker Leap", 1.2, 1.2, 13000), - new PerkAxeman(), - }, - { - new PerkLeap("Beserker Leap", 1.2, 1.2, 13000), - new PerkAxeman(), - }, - { - new PerkLeap("Beserker Leap", 1.2, 1.2, 12000), - new PerkAxeman(), - }, - { - new PerkLeap("Beserker Leap", 1.2, 1.2, 12000), - new PerkAxeman(), - }, - { - new PerkLeap("Beserker Leap", 1.2, 1.2, 11000), - new PerkAxeman(), - }, - }; - - private static final String[][] UPGRADE_DETAILS = - { - { - reduceCooldown(COOLDOWN, 1) - }, - { - receiveItem("Crafting Table", 1) - }, - { - reduceCooldown(COOLDOWN, 1) - }, - { - receiveItem("Iron Axe", 1) - }, - { - reduceCooldown(COOLDOWN, 1) - }, - }; + + private static final Perk[] PERKS = { + new PerkLeap("Beserker Leap", 1.2, 1.2, 8000), + new PerkAxeman(), + }; + + private static final ItemStack[] PLAYER_ITEMS = { + ItemStackFactory.Instance.CreateStack(Material.STONE_AXE) + }; private static final ItemStack IN_HAND = new ItemStack(Material.STONE_AXE); public KitBerserker(ArcadeManager manager) { - super(manager, "Berserker", "bridgeberserker", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + super(manager, "Berserker", "bridgeberserker", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); + } @Override public void GiveItems(Player player) { - int level = getUpgradeLevel(player.getUniqueId()); - - // Axe - if (level >= 4) - { - player.getInventory().addItem(new ItemStack(Material.IRON_AXE)); - } - else - { - player.getInventory().addItem(new ItemStack(Material.STONE_AXE)); - } - - //Crafting table - if (level >= 2) - { - player.getInventory().addItem(new ItemStack(Material.WORKBENCH)); - } + player.getInventory().addItem(PLAYER_ITEMS); } - - @Override - public boolean showUpgrades() - { - return false; - } -} +} \ No newline at end of file From c8a9cffcdf54ff67bd44c072db8937128227e2d3 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 14 Mar 2017 16:08:31 +0000 Subject: [PATCH 07/16] Edit the documentation for per player world borders --- .../nautilus/game/arcade/game/games/bridge/Bridge.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 beaf472c5..5995d93d3 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 @@ -287,19 +287,19 @@ public class Bridge extends TeamGame implements OreObsfucation // Here we do some calculations for per player world borders for (GameTeam team : GetTeamList()) { - // If this is an old map or the builders haven't done it properly we can use this more of an estimate of the border size - // Step 1 - Get the average location of the spawns, we will assume this is the centre of the island + // Step 1 - Get the average location of the spawns, we assume this is generally in an OK position. Location center = UtilAlg.getAverageLocation(team.GetSpawns()); + // Step 1.5 - Move the location back a bit from the centre, this is usually because spawns are on the inside edge of the islands. center.add(UtilAlg.getTrajectory(SpectatorSpawn, center).multiply(15)); // Step 2 - Calculate an estimate for the size of the border. We'll go with half but the setSize uses the radius so it works out the same to leave it like this - double distToCenter = UtilMath.offset2d(SpectatorSpawn, center); + double distToCenter = UtilMath.offset2d(SpectatorSpawn, center) * 0.9; // Step 3 - Send the setCenter and setSize packets to the team members for (Player player : team.GetPlayers(true)) { borderModule.setCenter(player, center); - borderModule.setSize(player, distToCenter * 0.9); + borderModule.setSize(player, distToCenter); } } From b35a9582df77c332f543375cec5a69b864af1a07 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 14 Mar 2017 17:07:36 +0000 Subject: [PATCH 08/16] Optimise PlayParticle --- .../src/mineplex/core/common/util/UtilParticle.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java index 0945ad7fd..7b85b4971 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -372,11 +372,12 @@ public class UtilParticle int count, ViewDist dist, Player... players) { PacketPlayOutWorldParticles packet = getPacket(particle, location, offsetX, offsetY, offsetZ, speed, count, true); - + int distValue = dist.getDist() * dist.getDist(); + for (Player player : players) { // Out of range for player - if (UtilMath.offset(player.getLocation(), location) > dist.getDist()) + if (UtilMath.offsetSquared(player.getLocation(), location) > distValue) continue; UtilPlayer.sendPacket(player, packet); From 15d691370de59b3083898dad461f19a20ff59a52 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 14 Mar 2017 21:05:52 +0000 Subject: [PATCH 09/16] Configuration for bridges --- .../game/arcade/game/games/bridge/Bridge.java | 88 +++++-- .../animation/CustomBridgeAnimation.java | 153 ----------- .../bridge/animation/WoodBridgeAnimation.java | 2 +- .../custom/CustomBridgeAnimation.java | 246 ++++++++++++++++++ .../custom/RadiusCustomBridgeAnimation.java | 58 +++++ .../custom/RandomCustomBridgeAnimation.java | 44 ++++ 6 files changed, 420 insertions(+), 171 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/CustomBridgeAnimation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/CustomBridgeAnimation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/RadiusCustomBridgeAnimation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/RandomCustomBridgeAnimation.java 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 5995d93d3..3a0e97fc6 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 @@ -37,7 +37,6 @@ import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketFillEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.CraftingInventory; @@ -70,12 +69,15 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimation; import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimationType; -import nautilus.game.arcade.game.games.bridge.animation.CustomBridgeAnimation; +import nautilus.game.arcade.game.games.bridge.animation.custom.CustomBridgeAnimation; +import nautilus.game.arcade.game.games.bridge.animation.custom.RadiusCustomBridgeAnimation; +import nautilus.game.arcade.game.games.bridge.animation.custom.RandomCustomBridgeAnimation; import nautilus.game.arcade.game.games.bridge.kits.KitApple; import nautilus.game.arcade.game.games.bridge.kits.KitArcher; import nautilus.game.arcade.game.games.bridge.kits.KitBerserker; @@ -114,11 +116,14 @@ public class Bridge extends TeamGame implements OreObsfucation */ private static final int WORLD_BORDER_PREPARE_TICKS = 20; + private static final String CUSTOM_BRIDGE_KEY = "TYPE"; + //Bridge private long _bridgeTime = BRIDGE_TIME; private boolean _bridgesDown = false; private BridgeAnimation _animation; - + private CustomBridgeAnimation[] _customAnimations; + private HashSet _bridgeParts = new HashSet(); //Animals @@ -249,6 +254,11 @@ public class Bridge extends TeamGame implements OreObsfucation _tournament = true; } + _customAnimations = new CustomBridgeAnimation[] { + new RandomCustomBridgeAnimation(this), + new RadiusCustomBridgeAnimation(this) + }; + new CompassModule() .setGiveCompassToAlive(true) .register(this); @@ -269,6 +279,34 @@ public class Bridge extends TeamGame implements OreObsfucation break; } } + + registerDebugCommand(new DebugCommand("bridge", Rank.ADMIN) + { + + @Override + public void Execute(Player caller, String[] args) + { + caller.sendMessage(F.main("Debug", "Spawning the bridges.")); + _bridgeTime = 3000; + } + }); + + registerDebugCommand(new DebugCommand("bridgeinfo", getArcadeManager().getGameCommandRank()) + { + + @Override + public void Execute(Player caller, String[] args) + { + if (_animation == null || !(_animation instanceof CustomBridgeAnimation)) + { + caller.sendMessage(F.main("Debug", "The bridge animation for this map isn't a custom one.")); + return; + } + + caller.sendMessage(F.main("Debug", "Bridge Info:")); + caller.sendMessage(_animation.toString()); + } + }); } @EventHandler @@ -354,15 +392,41 @@ public class Bridge extends TeamGame implements OreObsfucation } _animation = type.createInstance(this); - _animation.onParse(); + break; } + // If none of the premade ones are usable then we need a custom one! if (_animation == null) { - _animation = new CustomBridgeAnimation(this); - _animation.onParse(); + locationLoop : for (String key : WorldData.GetAllCustomLocs().keySet()) + { + if (!key.startsWith(CUSTOM_BRIDGE_KEY)) + { + continue; + } + + String[] split = key.split(" "); + + if (split.length < 2) + { + continue; + } + + String subKey = split[1]; + + for (CustomBridgeAnimation animation : _customAnimations) + { + if (animation.getTypeKey().equalsIgnoreCase(subKey)) + { + _animation = animation; + break locationLoop; + } + } + } } + _animation.onParse(); + ParseChests(); ParseOre(WorldData.GetCustomLocs("73")); // Red @@ -727,7 +791,7 @@ public class Bridge extends TeamGame implements OreObsfucation for (Player player : GetPlayers(true)) { - borderModule.setSize(player, 1000); + borderModule.setSize(player, 10000); } Manager.GetExplosion().SetLiquidDamage(true); @@ -1713,16 +1777,6 @@ public class Bridge extends TeamGame implements OreObsfucation else return 12; } - - @EventHandler - public void debug(PlayerCommandPreprocessEvent event) - { - if (Manager.GetClients().hasRank(event.getPlayer(), Rank.ADMIN) && event.getMessage().contains("/oretoggle")) - _ore.ToggleVisibility(); - - if (Manager.GetClients().hasRank(event.getPlayer(), Rank.ADMIN) && event.getMessage().contains("/bridge")) - _bridgeTime = 3000; - } @EventHandler public void disableIceForm(BlockFormEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/CustomBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/CustomBridgeAnimation.java deleted file mode 100644 index 921676590..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/CustomBridgeAnimation.java +++ /dev/null @@ -1,153 +0,0 @@ -package nautilus.game.arcade.game.games.bridge.animation; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; - -import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.updater.UpdateType; -import nautilus.game.arcade.game.games.bridge.Bridge; - -public class CustomBridgeAnimation extends BridgeAnimation -{ - - private static final String REGION_KEY = "BRIDGE"; - private static final String BRIDGE_DATA_KEY = "CUSTOM_BRIDGE"; - private static final double RATE = 0.5; - - private final BlockRestore _restore; - private final Map _bridgeBlocks; - - private int[] _blockIds; - - private double _maxDistance; - private double _minDistance; - - public CustomBridgeAnimation(Bridge bridge) - { - super(bridge); - - _restore = bridge.getArcadeManager().GetBlockRestore(); - _bridgeBlocks = new HashMap<>(AVERAGE_BRIDGE_BLOCKS); - } - - @Override - public void onParse() - { - _maxDistance = 0; - - for (String key : _worldData.GetAllCustomLocs().keySet()) - { - if (!key.startsWith(BRIDGE_DATA_KEY)) - { - continue; - } - - String[] split = key.split(" "); - int[] blockIds = new int[split.length - 1]; - - for (int i = 1; i < split.length; i++) - { - try - { - blockIds[i - 1] = Integer.parseInt(split[i]); - } - catch (NumberFormatException e) - { - continue; - } - } - - _blockIds = blockIds; - } - - for (String key : _worldData.GetAllCustomLocs().keySet()) - { - if (!key.startsWith(REGION_KEY)) - { - continue; - } - - List locations = _worldData.GetCustomLocs(key); - - if (locations.size() < 2) - { - continue; - } - - for (Block block : UtilBlock.getInBoundingBox(locations.get(0), locations.get(1))) - { - boolean shouldAdd = false; - - for (int id : _blockIds) - { - if (block.getTypeId() == id) - { - shouldAdd = true; - break; - } - } - - if (!shouldAdd) - { - continue; - } - - double dist = UtilMath.offset2d(block.getLocation(), _bridge.GetSpectatorLocation()); - - if (dist > _maxDistance) - { - _maxDistance = dist; - } - - _restore.add(block, Material.AIR.getId(), (byte) 0, Integer.MAX_VALUE); - _bridgeBlocks.put(block.getLocation(), dist); - } - } - - _minDistance = _maxDistance; - } - - @Override - public void onUpdate(UpdateType type) - { - if (type != UpdateType.FAST) - { - return; - } - - _minDistance -= RATE; - - Iterator iterator = _bridgeBlocks.keySet().iterator(); - - while (iterator.hasNext()) - { - Location location = iterator.next(); - double dist = _bridgeBlocks.get(location); - - if (dist > _minDistance) - { - Block block = location.getBlock(); - - _restore.restore(block); - UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, block.getLocation().add(0.5, 1.5, 0.5), 0.25F, 0.25F, 0.25F, 0.05F, 5, ViewDist.NORMAL); - - location.getWorld().playSound(location, Sound.ZOMBIE_UNFECT, 1.5F, 1); - - iterator.remove(); - } - } - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/WoodBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/WoodBridgeAnimation.java index ecafe937b..e149f2bc3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/WoodBridgeAnimation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/WoodBridgeAnimation.java @@ -108,7 +108,7 @@ public class WoodBridgeAnimation extends BridgeAnimation } } - if (toDo.size() == 0) + if (toDo.isEmpty()) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/CustomBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/CustomBridgeAnimation.java new file mode 100644 index 000000000..18f45bd3f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/CustomBridgeAnimation.java @@ -0,0 +1,246 @@ +package nautilus.game.arcade.game.games.bridge.animation.custom; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.block.Block; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import nautilus.game.arcade.game.games.bridge.Bridge; +import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimation; + +public abstract class CustomBridgeAnimation extends BridgeAnimation +{ + + private static final String BLOCK_IDS_KEY = "BLOCK_IDS"; + private static final String RATE_KEY = "RATE"; + private static final String PARTICLE_KEY = "PARTICLE"; + private static final String SOUND_KEY = "SOUND"; + private static final String REGION_KEY = "BRIDGE"; + + protected final BlockRestore _restore; + + private final String _typeKey; + protected final Map _bridgeBlocks; + + // Configuration + protected List _blockIds; + protected int _rate; + protected ParticleType _particle; + + // Sound + protected Sound _sound; + protected float _pitch; + + protected double _maxDistance; + + public CustomBridgeAnimation(Bridge bridge, String typeKey) + { + super(bridge); + + _restore = bridge.getArcadeManager().GetBlockRestore(); + + _typeKey = typeKey; + _bridgeBlocks = new HashMap<>(AVERAGE_BRIDGE_BLOCKS); + + // Defaults + // Wood, Logs, Fences + _blockIds = Arrays.asList(5, 17, 85); + _rate = 1; + _particle = ParticleType.BLOCK_DUST; + } + + @Override + public void onParse() + { + List blockIds = new ArrayList<>(); + + for (String key : _worldData.GetAllCustomLocs().keySet()) + { + String[] split = key.split(" "); + String subKey = split[0]; + + if (split.length < 2) + { + continue; + } + + switch (subKey) + { + + case BLOCK_IDS_KEY: + // Set the block ids that the animation will use + + for (int i = 1; i < split.length; i++) + { + try + { + blockIds.add(Integer.parseInt(split[i])); + } + catch (NumberFormatException e) + { + continue; + } + } + + break; + + case RATE_KEY: + // Set the rate at which the animation will run at + + try + { + _rate = Integer.parseInt(split[1]); + } + catch (NumberFormatException e) + { + continue; + } + + break; + + case PARTICLE_KEY: + // Set which type of particle will be displayed when a block + // spawns + + try + { + _particle = ParticleType.valueOf(split[1]); + } + catch (IllegalArgumentException e) + { + continue; + } + + break; + + case SOUND_KEY: + // Set the sound and pitch that will be played when a block + // spawns + + if (split.length < 3) + { + continue; + } + + try + { + _sound = Sound.valueOf(split[1]); + } + catch (IllegalArgumentException e) + { + continue; + } + + try + { + _pitch = Float.parseFloat(split[2]); + } + catch (NumberFormatException e) + { + continue; + } + + break; + + default: + break; + } + } + + // Set configuration values + _blockIds = blockIds; + + // Save all blocks in a big map. + for (String key : _worldData.GetAllCustomLocs().keySet()) + { + if (!key.startsWith(REGION_KEY)) + { + continue; + } + + List locations = _worldData.GetCustomLocs(key); + + if (locations.size() < 2) + { + continue; + } + + for (Block block : UtilBlock.getInBoundingBox(locations.get(0), locations.get(1))) + { + if (!_blockIds.contains(block.getTypeId())) + { + continue; + } + + double dist = UtilMath.offset2d(block.getLocation(), _bridge.GetSpectatorLocation()); + + if (dist > _maxDistance) + { + _maxDistance = dist; + } + + _restore.add(block, Material.AIR.getId(), (byte) 0, Integer.MAX_VALUE); + _bridgeBlocks.put(block.getLocation(), dist); + } + } + } + + public void onBlockSet(Block block) + { + World world = _worldData.World; + Location location = block.getLocation().add(0.5, 0.5, 0.5); + + if (_particle != null) + { + if (_particle == ParticleType.BLOCK_DUST) + { + world.playEffect(location, Effect.STEP_SOUND, block.getType(), block.getData()); + } + else + { + UtilParticle.PlayParticleToAll(_particle, block.getLocation(), 0.5F, 0.5F, 0.5F, 0.5F, 5, ViewDist.NORMAL); + } + } + + if (_sound != null) + { + world.playSound(location, _sound, 1, _pitch); + } + } + + public final String getTypeKey() + { + return _typeKey; + } + + @Override + public String toString() + { + StringBuilder builder = new StringBuilder(); + + builder.append("Type: " + _typeKey).append("\n"); + builder.append("Bridge Blocks: " + _bridgeBlocks.size()).append("\n"); + builder.append("Block Ids: " + _blockIds).append("\n"); + builder.append("Rate: " + _rate).append("\n"); + builder.append("Particle: " + (_particle == null ? "Null" : _particle.getFriendlyName())).append("\n"); + builder.append("Sound: " + (_sound == null ? "Null" : _sound.toString() + " Pitch: " + _pitch)).append("\n"); + builder.append("Max Distance: " + _maxDistance).append("\n"); + + return builder.toString(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/RadiusCustomBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/RadiusCustomBridgeAnimation.java new file mode 100644 index 000000000..fe0779c7c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/RadiusCustomBridgeAnimation.java @@ -0,0 +1,58 @@ +package nautilus.game.arcade.game.games.bridge.animation.custom; + +import java.util.Iterator; + +import org.bukkit.Location; +import org.bukkit.block.Block; + +import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.game.games.bridge.Bridge; + +public class RadiusCustomBridgeAnimation extends CustomBridgeAnimation +{ + + private double _minDistance; + + public RadiusCustomBridgeAnimation(Bridge bridge) + { + super(bridge, "RADIUS"); + } + + @Override + public void onParse() + { + super.onParse(); + + _minDistance = _maxDistance; + } + + @Override + public void onUpdate(UpdateType type) + { + if (type != UpdateType.FAST) + { + return; + } + + _minDistance -= _rate; + + Iterator iterator = _bridgeBlocks.keySet().iterator(); + + while (iterator.hasNext()) + { + Location location = iterator.next(); + double dist = _bridgeBlocks.get(location); + + if (dist > _minDistance) + { + Block block = location.getBlock(); + + _restore.restore(block); + onBlockSet(block); + + iterator.remove(); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/RandomCustomBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/RandomCustomBridgeAnimation.java new file mode 100644 index 000000000..badf135bb --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/RandomCustomBridgeAnimation.java @@ -0,0 +1,44 @@ +package nautilus.game.arcade.game.games.bridge.animation.custom; + +import java.util.Iterator; + +import org.bukkit.Location; +import org.bukkit.block.Block; + +import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.game.games.bridge.Bridge; + +public class RandomCustomBridgeAnimation extends CustomBridgeAnimation +{ + + public RandomCustomBridgeAnimation(Bridge bridge) + { + super(bridge, "RANDOM"); + } + + @Override + public void onUpdate(UpdateType type) + { + if (type != UpdateType.TICK) + { + return; + } + + Iterator iterator = _bridgeBlocks.keySet().iterator(); + int i = 0; + + while (iterator.hasNext() && i < _rate) + { + i++; + Location location = iterator.next(); + + Block block = location.getBlock(); + + _restore.restore(block); + onBlockSet(block); + + iterator.remove(); + } + } + +} From 8e5a5695d53add3216320974df973adee78443eb Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 17 Mar 2017 17:03:53 +0000 Subject: [PATCH 10/16] Fix early game revive --- .../game/arcade/game/games/bridge/Bridge.java | 177 +++++------------- 1 file changed, 52 insertions(+), 125 deletions(-) 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 3a0e97fc6..bf646fa6e 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 @@ -1,65 +1,8 @@ package nautilus.game.arcade.game.games.bridge; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -import org.bukkit.ChatColor; -import org.bukkit.Effect; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; -import org.bukkit.entity.Chicken; -import org.bukkit.entity.Cow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.entity.Pig; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockFormEvent; -import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.inventory.CraftItemEvent; -import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import org.bukkit.event.player.PlayerBucketFillEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.CraftingInventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.util.Vector; - import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilWorld; import mineplex.core.explosion.ExplosionEvent; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; @@ -78,14 +21,7 @@ import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimationType; import nautilus.game.arcade.game.games.bridge.animation.custom.CustomBridgeAnimation; import nautilus.game.arcade.game.games.bridge.animation.custom.RadiusCustomBridgeAnimation; import nautilus.game.arcade.game.games.bridge.animation.custom.RandomCustomBridgeAnimation; -import nautilus.game.arcade.game.games.bridge.kits.KitApple; -import nautilus.game.arcade.game.games.bridge.kits.KitArcher; -import nautilus.game.arcade.game.games.bridge.kits.KitBerserker; -import nautilus.game.arcade.game.games.bridge.kits.KitBomber; -import nautilus.game.arcade.game.games.bridge.kits.KitBrawler; -import nautilus.game.arcade.game.games.bridge.kits.KitDestructor; -import nautilus.game.arcade.game.games.bridge.kits.KitMammoth; -import nautilus.game.arcade.game.games.bridge.kits.KitMiner; +import nautilus.game.arcade.game.games.bridge.kits.*; import nautilus.game.arcade.game.modules.WorldBorderModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; @@ -93,11 +29,38 @@ import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkDestructor; import nautilus.game.arcade.ore.OreHider; import nautilus.game.arcade.ore.OreObsfucation; -import nautilus.game.arcade.stats.BridgesSniperStatTracker; -import nautilus.game.arcade.stats.DeathBomberStatTracker; -import nautilus.game.arcade.stats.FoodForTheMassesStatTracker; -import nautilus.game.arcade.stats.KillFastStatTracker; -import nautilus.game.arcade.stats.TntMinerStatTracker; +import nautilus.game.arcade.stats.*; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Chest; +import org.bukkit.entity.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.CraftingInventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.util.Vector; + +import java.util.*; +import java.util.concurrent.TimeUnit; public class Bridge extends TeamGame implements OreObsfucation { @@ -144,7 +107,7 @@ public class Bridge extends TeamGame implements OreObsfucation private int _buildHeight = -1; //Player Respawn - private HashSet _usedLife = new HashSet(); + private Set _usedLife = new HashSet<>(); //Tourney Mode private boolean _tournament; @@ -204,7 +167,7 @@ public class Bridge extends TeamGame implements OreObsfucation _ore = new OreHider(); // Flags - GameTimeout = Manager.IsTournamentServer() ? 5400000 : 3600000; + GameTimeout = Manager.IsTournamentServer() ? TimeUnit.MINUTES.toMillis(90) : TimeUnit.MINUTES.toMillis(60); Manager.GetExplosion().SetLiquidDamage(false); @@ -766,84 +729,48 @@ public class Bridge extends TeamGame implements OreObsfucation } @EventHandler - public void BridgeBuild(UpdateEvent event) + public void BridgeBuild(UpdateEvent event) { if (!IsLive() || !UtilTime.elapsed(GetStateTime(), _bridgeTime)) { return; } - + if (_animation != null) { _animation.onUpdate(event.getType()); } - + if (event.getType() != UpdateType.FAST) { return; } - + if (!_bridgesDown) { _bridgesDown = true; - + WorldBorderModule borderModule = getModule(WorldBorderModule.class); - + for (Player player : GetPlayers(true)) { borderModule.setSize(player, 10000); } - + Manager.GetExplosion().SetLiquidDamage(true); Announce(C.cRedB + "ALERT: " + C.Reset + C.Bold + "THE BRIDGES ARE SPAWNING!"); UtilTextMiddle.display(C.cRedB + "ALERT", "The BRIDGES ARE SPAWNING!"); - + for (Kit kit : GetKits()) { if (kit instanceof KitDestructor) { - ((KitDestructor)kit).SetEnabled(true); + ((KitDestructor) kit).SetEnabled(true); } } } } - -// @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)); -// } - -// @EventHandler -// public void breakMushroom(BlockBreakEvent event) -// { -// if (event.isCancelled()) -// return; -// -// -// if (event.getBlock().getTypeId() == 100 && -// WorldData.GetCustomLocs("21").contains(event.getBlock().getLocation().add(0.5, 0, 0.5))) -// { -// event.setCancelled(true); -// event.getBlock().setType(Material.AIR); -// -// _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))) -// { -// event.setCancelled(true); -// event.getBlock().setType(Material.AIR); -// -// _mushroomTop.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000)); -// } -// } - @EventHandler public void BridgeUpdate(UpdateEvent event) { @@ -1534,7 +1461,7 @@ public class Bridge extends TeamGame implements OreObsfucation { _tournamentKillMessageTimer = System.currentTimeMillis(); - this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "FIRST TEAM TO HAVE MOST KILLS WINS!"); + Announce(C.cRed + C.Bold + "ALERT: " + C.Reset + C.Bold + "FIRST TEAM TO HAVE MOST KILLS WINS!"); } } @@ -1728,16 +1655,16 @@ public class Bridge extends TeamGame implements OreObsfucation } @EventHandler(priority=EventPriority.LOWEST) - public void revivePlayer(EntityDamageEvent event) + public void revivePlayer(CustomDamageEvent event) { - if (_bridgesDown || !(event.getEntity() instanceof Player)) + if (_bridgesDown || !(event.GetDamageeEntity() instanceof Player)) { return; } - - Player player = (Player) event.getEntity(); - if (player.getHealth() - event.getDamage() > 0) + Player player = event.GetDamageePlayer(); + + if (player.getHealth() - event.GetDamage() > 0) { return; } @@ -1750,7 +1677,7 @@ public class Bridge extends TeamGame implements OreObsfucation GetTeam(player).SpawnTeleport(player); player.setHealth(20); - event.setCancelled(true); + event.SetCancelled("Early Game Revive"); } } From df8ed9013874456311fc5e1bfe9bac246a45d9e4 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 18 Mar 2017 23:44:42 +0000 Subject: [PATCH 11/16] Ops, forgot to enable reports. Eclipse is bad --- .../src/nautilus/game/arcade/Arcade.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 9c10cf9c2..6478db304 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -159,10 +159,10 @@ public class Arcade extends JavaPlugin Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); -// SnapshotManager snapshotManager = new SnapshotManager(this, new SnapshotRepository(serverStatusManager.getCurrentServerName(), getLogger())); -// ReportManager reportManager = new ReportManager(this, snapshotManager, _clientManager, incognito, punish, serverStatusManager.getRegion(), serverStatusManager.getCurrentServerName(), 1); -// new SnapshotPlugin(this, snapshotManager, _clientManager); -// new ReportPlugin(this, reportManager); + SnapshotManager snapshotManager = new SnapshotManager(this, new SnapshotRepository(serverStatusManager.getCurrentServerName(), getLogger())); + ReportManager reportManager = new ReportManager(this, snapshotManager, _clientManager, incognito, punish, serverStatusManager.getRegion(), serverStatusManager.getCurrentServerName(), 1); + new SnapshotPlugin(this, snapshotManager, _clientManager); + new ReportPlugin(this, reportManager); BlockRestore blockRestore = require(BlockRestore.class); From 18538d918ceacee21add7a7d483848bc211620b4 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 18 Mar 2017 23:51:13 +0000 Subject: [PATCH 12/16] And 2FA wow, this is why you skim read PRs --- .../src/mineplex/core/twofactor/TwoFactorAuth.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java index 02d2705e8..32107d3f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java @@ -185,7 +185,7 @@ public class TwoFactorAuth extends MiniClientPlugin player.sendMessage(F.main("2FA", "Setting up two-factor authentication.")); } - //@EventHandler + @EventHandler public void onJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); From 05bd93cbdf06e0a7eb632e57c880341c98aedec4 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 19 Mar 2017 00:01:11 +0000 Subject: [PATCH 13/16] Fixed Death Bomber achievement exploit --- .../arcade/stats/DeathBomberStatTracker.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java index 90316be6e..61d4b8923 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java @@ -1,17 +1,16 @@ package nautilus.game.arcade.stats; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityDamageEvent; - import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.Game; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; public class DeathBomberStatTracker extends StatTracker { @@ -52,6 +51,11 @@ public class DeathBomberStatTracker extends StatTracker if(killer.equals(killed)) return; + if (killer.getItemInHand().getType() != Material.TNT) + { + return; + } + if (event.GetLog().GetKiller() != null && event.GetLog().GetKiller().GetReason().contains("Throwing TNT")) { Integer count = _killCount.get(killer.getUniqueId()); From 95d919a654c72967b6105bb5c31569806ea43562 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 19 Mar 2017 00:07:23 +0000 Subject: [PATCH 14/16] Removed was werid disjointed code --- .../game/arcade/game/games/skywars/kits/KitMetal.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java index 5d6cf5ff5..a5e4be83e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java @@ -90,10 +90,6 @@ public class KitMetal extends ProgressingKit @Override public void GiveItems(Player player) { - int level = getUpgradeLevel(player.getUniqueId()); - - - player.getInventory().addItem(PLAYER_ITEMS); } From c4c7ebe1e6735a44f55e7f982f9ba69c66f95dcb Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 20 Mar 2017 22:10:20 +0000 Subject: [PATCH 15/16] Check for blocks already registering --- .../games/bridge/animation/custom/CustomBridgeAnimation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/CustomBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/CustomBridgeAnimation.java index 18f45bd3f..fe5e6ed04 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/CustomBridgeAnimation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/CustomBridgeAnimation.java @@ -181,7 +181,7 @@ public abstract class CustomBridgeAnimation extends BridgeAnimation for (Block block : UtilBlock.getInBoundingBox(locations.get(0), locations.get(1))) { - if (!_blockIds.contains(block.getTypeId())) + if (!_blockIds.contains(block.getTypeId()) || _bridgeBlocks.containsKey(block)) { continue; } From 401276d70587bff6f042e779298d0ba2c6f2aa87 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 22 Mar 2017 23:04:50 +0000 Subject: [PATCH 16/16] Missing isLive check --- .../src/nautilus/game/arcade/game/games/bridge/Bridge.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 bf646fa6e..91bf17b99 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 @@ -1657,7 +1657,7 @@ public class Bridge extends TeamGame implements OreObsfucation @EventHandler(priority=EventPriority.LOWEST) public void revivePlayer(CustomDamageEvent event) { - if (_bridgesDown || !(event.GetDamageeEntity() instanceof Player)) + if (!IsLive() || _bridgesDown || !(event.GetDamageeEntity() instanceof Player)) { return; }