From f315689dda1445c50dacf28cc8d26a74f053da78 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 10 Apr 2017 23:46:09 +0100 Subject: [PATCH 01/10] Staff Oscars --- .../arcade/game/games/event/EventGame.java | 12 +- .../games/event/staffoscars/ChairData.java | 41 +++ .../games/event/staffoscars/RainbowSheep.java | 105 ++++++++ .../event/staffoscars/StaffOscarsModule.java | 252 ++++++++++++++++++ 4 files changed, 409 insertions(+), 1 deletion(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/ChairData.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/StaffOscarsModule.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java index 68767903c..efdbebb6c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventGame.java @@ -19,6 +19,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.event.kits.KitPlayer; +import nautilus.game.arcade.game.games.event.staffoscars.StaffOscarsModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.GameHostManager; @@ -125,7 +126,16 @@ public class EventGame extends Game .setGiveCompassToAlive(false) .register(this); } - + + @Override + public void ParseData() + { + if (WorldData.MapName.equals("Staff Oscars")) + { + new StaffOscarsModule().register(this); + } + } + @EventHandler public void registerSigns(GameStateChangeEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/ChairData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/ChairData.java new file mode 100644 index 000000000..4f15c0bdc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/ChairData.java @@ -0,0 +1,41 @@ +package nautilus.game.arcade.game.games.event.staffoscars; + +import org.bukkit.block.Block; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; + +public class ChairData +{ + + private Player _player; + private Block _block; + private ArmorStand _stand; + + public ChairData(Player player, Block block) + { + _player = player; + _block = block; + _stand = block.getWorld().spawn(block.getLocation().add(0.5, -0.4, 0.5), ArmorStand.class); + + _stand.setGravity(false); + _stand.setSmall(true); + _stand.setVisible(false); + _stand.setPassenger(player); + } + + public Player getPlayer() + { + return _player; + } + + public Block getBlock() + { + return _block; + } + + public ArmorStand getStand() + { + return _stand; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java new file mode 100644 index 000000000..bcdddfc13 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java @@ -0,0 +1,105 @@ +package nautilus.game.arcade.game.games.event.staffoscars; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Color; +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.Set; + +public class RainbowSheep implements Listener +{ + + private static final Color[] COLOURS = { + Color.RED, Color.ORANGE, Color.YELLOW, Color.LIME, Color.AQUA, Color.BLUE, Color.PURPLE + }; + + private final Set _sheep; + private Player _player; + private boolean _active; + private long _start; + + public RainbowSheep() + { + _sheep = new HashSet<>(); + } + + @EventHandler + public void updateSpawn(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER || !_active) + { + return; + } + + if (UtilTime.elapsed(_start, 50000)) + { + for (Sheep sheep : _sheep) + { + sheep.remove(); + } + + _sheep.clear(); + _active = false; + return; + } + + Vector direction = _player.getLocation().getDirection(); + Vector left = UtilAlg.getLeft(direction).add(direction.clone().multiply(1.5)); + Vector right = UtilAlg.getRight(direction).add(direction.clone().multiply(1.5)); + + spawnSheep(_player, direction); + spawnSheep(_player, left); + spawnSheep(_player, right); + } + + @EventHandler + public void updateParticles(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Sheep sheep : _sheep) + { + UtilParticle.playColoredParticleToAll(COLOURS[UtilMath.r(COLOURS.length)], UtilParticle.ParticleType.RED_DUST, sheep.getLocation().add(0, 0.75, 0), 2, UtilParticle.ViewDist.LONGER); + } + } + + @EventHandler + public void entityDamage(EntityDamageEvent event) + { + if (_sheep.contains(event.getEntity())) + { + event.setCancelled(true); + } + } + + private void spawnSheep(Player player, Vector vector) + { + Sheep sheep = player.getWorld().spawn(player.getEyeLocation(), Sheep.class); + + sheep.setCustomName("jeb_"); + sheep.setVelocity(vector); + + _sheep.add(sheep); + } + + public void setActive(Player player) + { + _player = player; + _active = true; + _start = System.currentTimeMillis(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/StaffOscarsModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/StaffOscarsModule.java new file mode 100644 index 000000000..2e45e694a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/StaffOscarsModule.java @@ -0,0 +1,252 @@ +package nautilus.game.arcade.game.games.event.staffoscars; + +import mineplex.core.common.util.*; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.modules.Module; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerArmorStandManipulateEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +public class StaffOscarsModule extends Module +{ + + private static final int MAX_X = 18; + + private List _blocks; + private boolean _open; + private boolean _animate; + private int _x; + private Location _center; + + private Set _chairs; + + private List _fireworks; + + private RainbowSheep _sheep; + + @Override + protected void setup() + { + _chairs = new HashSet<>(); + _blocks = getGame().WorldData.GetCustomLocs(String.valueOf(Material.EMERALD_BLOCK.getId())); + _center = UtilAlg.getAverageLocation(_blocks); + _fireworks = getGame().WorldData.GetDataLocs("YELLOW"); + _sheep = new RainbowSheep(); + UtilServer.RegisterEvents(_sheep); + } + + @Override + public void cleanup() + { + UtilServer.Unregister(_sheep); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != Game.GameState.Prepare) + { + return; + } + + for (Location location : _blocks) + { + MapUtil.QuickChangeBlockAt(location, Material.WOOL, (byte) 14); + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !_animate) + { + return; + } + + for (Location location : _blocks) + { + boolean in = UtilMath.offset2d(location, _center) < _x; + + if (in && _open) + { + MapUtil.QuickChangeBlockAt(location, Material.AIR); + } + else if (!in && !_open) + { + MapUtil.QuickChangeBlockAt(location, Material.WOOL, (byte) 14); + } + } + + if (_open) + { + _x++; + } + else + { + _x--; + } + + if (_open && _x == MAX_X || !_open && _x == -1) + { + _animate = false; + } + } + + @EventHandler + public void curtainCommand(PlayerCommandPreprocessEvent event) + { + String message = event.getMessage(); + + if (message.startsWith("/curtain") && getGame().getArcadeManager().GetGameHostManager().isAdmin(event.getPlayer(), false)) + { + _open = !_open; + _animate = true; + + event.setCancelled(true); + event.getPlayer().sendMessage(F.main("Event", "Curtain open state = " + _open + ".")); + } + } + + @EventHandler + public void chairInteract(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + Block block = event.getClickedBlock(); + + if (block == null) + { + return; + } + + if (UtilBlock.usable(block)) + { + event.setCancelled(true); + } + + if (block.getType() != Material.WOOD_STAIRS) + { + return; + } + + for (ChairData data : _chairs) + { + if (data.getBlock().equals(block)) + { + return; + } + + if (data.getPlayer().equals(player)) + { + handleDismount(player); + break; + } + } + + _chairs.add(new ChairData(player, block)); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + handleDismount(event.getPlayer()); + } + + @EventHandler + public void updateDismount(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + Iterator iterator = _chairs.iterator(); + + while (iterator.hasNext()) + { + ChairData data = iterator.next(); + + if (data.getPlayer().isInsideVehicle()) + { + continue; + } + + data.getStand().remove(); + iterator.remove(); + } + } + + private void handleDismount(Player player) + { + Iterator iterator = _chairs.iterator(); + + while (iterator.hasNext()) + { + ChairData data = iterator.next(); + + if (!data.getPlayer().equals(player)) + { + continue; + } + + data.getStand().remove(); + iterator.remove(); + } + } + + @EventHandler + public void armourStandEdit(PlayerArmorStandManipulateEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void fireworksCommand(PlayerCommandPreprocessEvent event) + { + String message = event.getMessage(); + + if (message.startsWith("/firework") && getGame().getArcadeManager().GetGameHostManager().isAdmin(event.getPlayer(), false)) + { + event.setCancelled(true); + + FireworkEffect fireworkEffect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.YELLOW).build(); + + for (Location location : _fireworks) + { + for (int i = 0; i < 4; i++) + { + UtilFirework.launchFirework(location, fireworkEffect, null, UtilMath.r(3) + 1); + } + } + } + } + + @EventHandler + public void rainbowSheepCommand(PlayerCommandPreprocessEvent event) + { + String message = event.getMessage(); + + if (!message.startsWith("/deantm") || !getGame().getArcadeManager().GetGameHostManager().isAdmin(event.getPlayer(), false)) + { + return; + } + + event.setCancelled(true); + _sheep.setActive(event.getPlayer()); + } +} From ee7a29d387c92bf66af42523a147d607115a6893 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 11 Apr 2017 01:55:49 +0100 Subject: [PATCH 02/10] Stop command spam --- .../arcade/game/games/event/staffoscars/RainbowSheep.java | 5 +++++ .../game/games/event/staffoscars/StaffOscarsModule.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java index bcdddfc13..6460c645a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java @@ -102,4 +102,9 @@ public class RainbowSheep implements Listener _active = true; _start = System.currentTimeMillis(); } + + public boolean isActive() + { + return _active; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/StaffOscarsModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/StaffOscarsModule.java index 2e45e694a..c560563d6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/StaffOscarsModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/StaffOscarsModule.java @@ -246,6 +246,11 @@ public class StaffOscarsModule extends Module return; } + if (_sheep.isActive()) + { + return; + } + event.setCancelled(true); _sheep.setActive(event.getPlayer()); } From fd317063337e7b2406f897c7aa767b3bf1aae14a Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 24 Apr 2017 23:21:10 +0100 Subject: [PATCH 03/10] 5 seconds rather than 50 --- .../game/arcade/game/games/event/staffoscars/RainbowSheep.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java index 6460c645a..ce068bac8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/staffoscars/RainbowSheep.java @@ -42,7 +42,7 @@ public class RainbowSheep implements Listener return; } - if (UtilTime.elapsed(_start, 50000)) + if (UtilTime.elapsed(_start, 5000)) { for (Sheep sheep : _sheep) { From 0bbd0659a031cd9aed98d1866d6f82c148d472f3 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 24 Apr 2017 21:26:00 +0100 Subject: [PATCH 04/10] Fix the water not being replaced bug --- .../game/arcade/game/games/bridge/Bridge.java | 675 +++++++++++++----- .../custom/CustomBridgeAnimation.java | 27 +- 2 files changed, 522 insertions(+), 180 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 6a6d7b56c..dfc12db46 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,6 +1,5 @@ package nautilus.game.arcade.game.games.bridge; -import mineplex.core.common.Rank; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.explosion.ExplosionEvent; @@ -22,12 +21,9 @@ import nautilus.game.arcade.game.games.bridge.animation.custom.CustomBridgeAnima 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.*; -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.PerkBomber; -import nautilus.game.arcade.kit.perks.PerkDestructor; import nautilus.game.arcade.ore.OreHider; import nautilus.game.arcade.ore.OreObsfucation; import nautilus.game.arcade.stats.*; @@ -65,21 +61,21 @@ public class Bridge extends TeamGame implements OreObsfucation /** * When a block is broken of one of these materials, the item drop will be locked to the player that broke the block for 8 seconds. After that, anyone can pick up the item. */ - 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 }; + 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}; /** * 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); - + 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 @@ -108,7 +104,7 @@ public class Bridge extends TeamGame implements OreObsfucation private long _tournamentKillMessageTimer = 0; private final Map _averageSpawns = new HashMap<>(); - + @SuppressWarnings("unchecked") public Bridge(ArcadeManager manager) { @@ -120,7 +116,7 @@ public class Bridge extends TeamGame implements OreObsfucation new TntMinerStatTracker(this), new KillFastStatTracker(this, 4, 10, "Rampage"), new DeathBomberStatTracker(this, 5) - ); + ); registerChatStats( Kills, @@ -132,31 +128,31 @@ public class Bridge extends TeamGame implements OreObsfucation DamageDealt ); } - + public Bridge(ArcadeManager manager, GameType type) { - this(manager, new Kit[] - { - new KitApple(manager), - new KitBerserker(manager), - new KitBrawler(manager), - new KitArcher(manager), - new KitMiner(manager), - new KitBomber(manager), - new KitDestructor(manager), + this(manager, new Kit[] + { + new KitApple(manager), + new KitBerserker(manager), + new KitBrawler(manager), + new KitArcher(manager), + new KitMiner(manager), + new KitBomber(manager), + new KitDestructor(manager), }, type); } - + public Bridge(ArcadeManager manager, Kit[] kitarray, GameType type) { super(manager, type, kitarray, - new String[] { - "Gather resources and prepare for combat.", - "After 10 minutes, The Bridges will emerge.", - "Special loot is located in the center.", - "The last team alive wins!" - }); + new String[]{ + "Gather resources and prepare for combat.", + "After 10 minutes, The Bridges will emerge.", + "Special loot is located in the center.", + "The last team alive wins!" + }); _ore = new OreHider(); @@ -173,7 +169,7 @@ public class Bridge extends TeamGame implements OreObsfucation ItemPickup = true; InventoryClick = true; - + AnnounceStay = false; PrivateBlocks = true; @@ -190,7 +186,7 @@ public class Bridge extends TeamGame implements OreObsfucation DeathDropItems = true; - GemMultiplier = 2.5; + GemMultiplier = 2.5; PrepareFreeze = false; @@ -199,26 +195,26 @@ public class Bridge extends TeamGame implements OreObsfucation { QuitOut = false; - _gameDesc = new String[] - { - "Gather resources and prepare for combat.", - "After 10 minutes, The Bridges will emerge.", - "Special loot is located in the center.", - "Killing yourself counts as -1 team kill.", - "Team with the most kills wins!" + _gameDesc = new String[] + { + "Gather resources and prepare for combat.", + "After 10 minutes, The Bridges will emerge.", + "Special loot is located in the center.", + "Killing yourself counts as -1 team kill.", + "Team with the most kills wins!" }; - + _tournament = true; } - _customAnimations = new CustomBridgeAnimation[] { + _customAnimations = new CustomBridgeAnimation[]{ new RandomCustomBridgeAnimation(this), new RadiusCustomBridgeAnimation(this) }; - + new CompassModule() - .setGiveCompassToAlive(true) - .register(this); + .setGiveCompassToAlive(true) + .register(this); // So that we can be 110% sure for (Kit kit : GetKits()) @@ -229,10 +225,10 @@ public class Bridge extends TeamGame implements OreObsfucation break; } } - + registerDebugCommand(new DebugCommand("bridge", getArcadeManager().getGameCommandRank()) { - + @Override public void Execute(Player caller, String[] args) { @@ -240,10 +236,10 @@ public class Bridge extends TeamGame implements OreObsfucation _bridgeTime = 3000; } }); - + registerDebugCommand(new DebugCommand("bridgeinfo", getArcadeManager().getGameCommandRank()) { - + @Override public void Execute(Player caller, String[] args) { @@ -252,7 +248,7 @@ public class Bridge extends TeamGame implements OreObsfucation 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()); } @@ -269,7 +265,7 @@ public class Bridge extends TeamGame implements OreObsfucation Manager.runSyncLater(() -> _animation.onParse(), 10); } - + @EventHandler(priority = EventPriority.MONITOR) public void live(GameStateChangeEvent event) { @@ -277,7 +273,7 @@ public class Bridge extends TeamGame implements OreObsfucation { return; } - + if (!WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty()) { WorldWaterDamage = 4; @@ -299,10 +295,11 @@ public class Bridge extends TeamGame implements OreObsfucation } @Override - public void ParseData() + public void ParseData() { // Now we need to decide on what bridge animation. - typeLoop : for (BridgeAnimationType type : BridgeAnimationType.values()) + typeLoop: + for (BridgeAnimationType type : BridgeAnimationType.values()) { for (String colours : type.getColoursUsed()) { @@ -311,30 +308,31 @@ public class Bridge extends TeamGame implements OreObsfucation continue typeLoop; } } - + _animation = type.createInstance(this); break; } - + // If none of the premade ones are usable then we need a custom one! if (_animation == null) { - locationLoop : for (String key : WorldData.GetAllCustomLocs().keySet()) + 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)) @@ -354,30 +352,56 @@ public class Bridge extends TeamGame implements OreObsfucation 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("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")); + 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")); + } } protected void ParseChests() { - for (Location loc : WorldData.GetCustomLocs("54")) + for (Location loc : WorldData.GetCustomLocs("54")) { if (loc.getBlock().getType() != Material.CHEST) + { loc.getBlock().setType(Material.CHEST); + } Chest chest = (Chest) loc.getBlock().getState(); chest.getBlockInventory().clear(); int count = 2 + UtilMath.r(5); - for (int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { chest.getBlockInventory().addItem(GetChestItem()); } @@ -386,7 +410,7 @@ public class Bridge extends TeamGame implements OreObsfucation protected ItemStack GetChestItem() { - if (_chestLoot.isEmpty()) + if (_chestLoot.isEmpty()) { for (int i = 0; i < 1; i++) _chestLoot.add(new ItemStack(Material.DIAMOND_HELMET)); @@ -434,7 +458,9 @@ public class Bridge extends TeamGame implements OreObsfucation int amount = 1; if (stack.getType().getMaxStackSize() > 1) + { amount = stack.getAmount() + UtilMath.r(stack.getAmount()); + } return ItemStackFactory.Instance.CreateStack(stack.getTypeId(), amount); } @@ -443,18 +469,26 @@ public class Bridge extends TeamGame implements OreObsfucation public void ChestDeny(PlayerInteractEvent event) { if (_bridgesDown) + { return; + } if (event.getClickedBlock() == null) + { return; + } if (event.getClickedBlock().getType() != Material.CHEST) + { return; + } if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + { return; + } - for (Location loc : WorldData.GetCustomLocs("54")) + for (Location loc : WorldData.GetCustomLocs("54")) { if (loc.getBlock().equals(event.getClickedBlock())) { @@ -479,10 +513,14 @@ public class Bridge extends TeamGame implements OreObsfucation for (Location loc : teamOre) { if (loc.getBlockY() < lowY) + { lowY = loc.getBlockY(); + } if (loc.getBlockY() > highY) + { highY = loc.getBlockY(); + } loc.getBlock().setTypeId(1); } @@ -490,63 +528,79 @@ public class Bridge extends TeamGame implements OreObsfucation int varY = highY - lowY; //Gravel - for (int i = 0; i < gravel && !teamOre.isEmpty(); i++) + for (int i = 0; i < gravel && !teamOre.isEmpty(); i++) { int attempts = 20; int id = 0; - while (attempts > 0) + while (attempts > 0) { id = UtilMath.r(teamOre.size()); double height = (double) (teamOre.get(id).getBlockY() - lowY) / (double) varY; if (height > 0.8) + { break; + } else if (height > 0.6 && Math.random() > 0.4) + { break; + } else if (height > 0.4 && Math.random() > 0.6) + { break; + } else if (height > 0.2 && Math.random() > 0.8) + { break; + } } CreateOre(teamOre.remove(id), Material.GRAVEL, 6); } //Coal - for (int i = 0; i < coal && !teamOre.isEmpty(); i++) + for (int i = 0; i < coal && !teamOre.isEmpty(); i++) { int attempts = 20; int id = 0; - while (attempts > 0) + while (attempts > 0) { id = UtilMath.r(teamOre.size()); double height = (double) (teamOre.get(id).getBlockY() - lowY) / (double) varY; if (height > 0.8) + { break; + } else if (height > 0.6 && Math.random() > 0.4) + { break; + } else if (height > 0.4 && Math.random() > 0.6) + { break; + } else if (height > 0.2 && Math.random() > 0.8) + { break; + } } CreateOre(teamOre.remove(id), Material.COAL_ORE, 6); } //Iron - for (int i = 0; i < iron && !teamOre.isEmpty(); i++) + for (int i = 0; i < iron && !teamOre.isEmpty(); i++) { int id = UtilMath.r(teamOre.size()); @@ -554,12 +608,12 @@ public class Bridge extends TeamGame implements OreObsfucation } //Gold - for (int i = 0; i < gold && !teamOre.isEmpty(); i++) + for (int i = 0; i < gold && !teamOre.isEmpty(); i++) { int attempts = 20; int id = 0; - while (attempts > 0) + while (attempts > 0) { id = UtilMath.r(teamOre.size()); @@ -567,19 +621,29 @@ public class Bridge extends TeamGame implements OreObsfucation / (double) varY; if (height > 0.8 && Math.random() > 0.8) + { break; + } else if (height > 0.6 && Math.random() > 0.7) + { break; + } else if (height > 0.4 && Math.random() > 0.6) + { break; + } else if (height > 0.2 && Math.random() > 0.4) + { break; + } else if (Math.random() > 0.2) + { break; + } } CreateOre(teamOre.remove(id), Material.GOLD_ORE, 3); @@ -599,33 +663,43 @@ public class Bridge extends TeamGame implements OreObsfucation / (double) varY; if (height > 0.8) + { continue; + } else if (height > 0.6 && Math.random() > 0.9) + { break; + } else if (height > 0.4 && Math.random() > 0.7) + { break; + } else if (height > 0.2 && Math.random() > 0.5) + { break; + } else + { break; + } } CreateOre(teamOre.remove(id), Material.DIAMOND_ORE, 2); } } - public void CreateOre(Location loc, Material type, int amount) + public void CreateOre(Location loc, Material type, int amount) { double bonus = Math.random() + 1; amount = (int) (amount * bonus); int attempts = 100; - while (amount > 0 && attempts > 0) + while (amount > 0 && attempts > 0) { attempts--; @@ -636,45 +710,98 @@ public class Bridge extends TeamGame implements OreObsfucation { int rFace = UtilMath.r(6); - if (rFace == 0) faceY = BlockFace.UP; - else if (rFace == 1) faceY = BlockFace.DOWN; - else if (rFace == 2) faceXZ = BlockFace.NORTH; - else if (rFace == 3) faceXZ = BlockFace.SOUTH; - else if (rFace == 4) faceXZ = BlockFace.EAST; - else faceXZ = BlockFace.WEST; + if (rFace == 0) + { + faceY = BlockFace.UP; + } + else if (rFace == 1) + { + faceY = BlockFace.DOWN; + } + else if (rFace == 2) + { + faceXZ = BlockFace.NORTH; + } + else if (rFace == 3) + { + faceXZ = BlockFace.SOUTH; + } + else if (rFace == 4) + { + faceXZ = BlockFace.EAST; + } + else + { + faceXZ = BlockFace.WEST; + } } else { //Height int rFace = UtilMath.r(3); - if (rFace == 0) faceY = BlockFace.SELF; - else if (rFace == 1) faceY = BlockFace.UP; - else faceY = BlockFace.DOWN; + if (rFace == 0) + { + faceY = BlockFace.SELF; + } + else if (rFace == 1) + { + faceY = BlockFace.UP; + } + else + { + faceY = BlockFace.DOWN; + } //Flat if (faceY == BlockFace.SELF) { rFace = UtilMath.r(4); - if (rFace == 0) faceXZ = BlockFace.NORTH_EAST; - else if (rFace == 1) faceXZ = BlockFace.NORTH_WEST; - else if (rFace == 2) faceXZ = BlockFace.SOUTH_EAST; - else faceXZ = BlockFace.SOUTH_WEST; + if (rFace == 0) + { + faceXZ = BlockFace.NORTH_EAST; + } + else if (rFace == 1) + { + faceXZ = BlockFace.NORTH_WEST; + } + else if (rFace == 2) + { + faceXZ = BlockFace.SOUTH_EAST; + } + else + { + faceXZ = BlockFace.SOUTH_WEST; + } } else { rFace = UtilMath.r(4); - if (rFace == 0) faceXZ = BlockFace.NORTH; - else if (rFace == 1) faceXZ = BlockFace.SOUTH; - else if (rFace == 2) faceXZ = BlockFace.EAST; - else faceXZ = BlockFace.WEST; + if (rFace == 0) + { + faceXZ = BlockFace.NORTH; + } + else if (rFace == 1) + { + faceXZ = BlockFace.SOUTH; + } + else if (rFace == 2) + { + faceXZ = BlockFace.EAST; + } + else + { + faceXZ = BlockFace.WEST; + } } } if (loc.getBlock().getRelative(faceY).getRelative(faceXZ).getType() != Material.STONE) + { continue; + } loc = loc.getBlock().getRelative(faceY).getRelative(faceXZ).getLocation(); @@ -731,19 +858,25 @@ public class Bridge extends TeamGame implements OreObsfucation public void BridgeUpdate(UpdateEvent event) { if (!IsLive()) + { return; + } if (event.getType() != UpdateType.TICK) + { return; + } Iterator partIterator = _bridgeParts.iterator(); - while (partIterator.hasNext()) + while (partIterator.hasNext()) { BridgePart part = partIterator.next(); if (part.Update()) + { partIterator.remove(); + } } } @@ -751,20 +884,24 @@ public class Bridge extends TeamGame implements OreObsfucation public void BridgeForm(EntityChangeBlockEvent event) { for (BridgePart part : _bridgeParts) - if (part.Entity.equals(event.getEntity())) + if (part.Entity.equals(event.getEntity())) + { event.setCancelled(true); + } } @EventHandler - public void BridgeItem(ItemSpawnEvent event) + public void BridgeItem(ItemSpawnEvent event) { for (BridgePart part : _bridgeParts) if (part.ItemSpawn(event.getEntity())) + { event.setCancelled(true); + } } @EventHandler - public void IceForm(BlockFormEvent event) + public void IceForm(BlockFormEvent event) { event.setCancelled(true); } @@ -773,20 +910,28 @@ public class Bridge extends TeamGame implements OreObsfucation public void AnimalSpawn(UpdateEvent event) { if (!IsLive()) + { return; + } if (event.getType() != UpdateType.SEC) + { return; + } if (!UtilTime.elapsed(_lastAnimal, 30000)) + { return; + } _lastAnimal = System.currentTimeMillis(); - for (GameTeam team : GetTeamList()) + for (GameTeam team : GetTeamList()) { if (_animalSet.get(team) == null) + { _animalSet.put(team, new HashSet()); + } // Clean Iterator entIterator = _animalSet.get(team).iterator(); @@ -796,12 +941,16 @@ public class Bridge extends TeamGame implements OreObsfucation Entity ent = entIterator.next(); if (ent.isDead() || !ent.isValid()) + { entIterator.remove(); + } } // Too Many if (_animalSet.get(team).size() > 4) + { continue; + } // Spawn double rand = Math.random(); @@ -810,11 +959,17 @@ public class Bridge extends TeamGame implements OreObsfucation CreatureAllowOverride = true; if (rand > 0.66) + { ent = team.GetSpawn().getWorld().spawn(team.GetSpawn(), Cow.class); + } else if (rand > 0.33) + { ent = team.GetSpawn().getWorld().spawn(team.GetSpawn(), Pig.class); + } else + { ent = team.GetSpawn().getWorld().spawn(team.GetSpawn(), Chicken.class); + } CreatureAllowOverride = false; _animalSet.get(team).add(ent); @@ -825,45 +980,59 @@ public class Bridge extends TeamGame implements OreObsfucation public void MushroomSpawn(UpdateEvent event) { if (!IsLive()) + { return; + } if (event.getType() != UpdateType.SEC) + { return; + } if (!UtilTime.elapsed(_lastMushroom, 20000)) + { return; + } _lastMushroom = System.currentTimeMillis(); - for (GameTeam team : GetTeamList()) + for (GameTeam team : GetTeamList()) { Block block = team.GetSpawn().getBlock(); while (!UtilBlock.airFoliage(block)) { block = block.getRelative(BlockFace.UP); - + if (block.getY() >= 256) + { break; + } } while (UtilBlock.airFoliage(block)) { block = block.getRelative(BlockFace.DOWN); - + if (block.getY() <= 0) + { break; + } } - if (block.getType() != Material.SNOW) + if (block.getType() != Material.SNOW) { block = block.getRelative(BlockFace.UP); } - + if (Math.random() > 0.5) + { block.setTypeId(39); + } else + { block.setTypeId(40); + } } } @@ -872,7 +1041,7 @@ public class Bridge extends TeamGame implements OreObsfucation { // Reveal ore that are inside the explosion _ore.Explosion(event); - + NautHashMap> lootDrops = new NautHashMap>(); // Handle block ownership for explosion @@ -889,14 +1058,14 @@ public class Bridge extends TeamGame implements OreObsfucation { event.GetBlocks().remove(cur); lootDrops.put(cur, new HashSet()); - + lootDrops.get(cur).addAll(cur.getDrops()); } } } Manager.runSyncLater(new Runnable() // Run after the explosion has already happened - { + { @Override public void run() { @@ -912,17 +1081,21 @@ public class Bridge extends TeamGame implements OreObsfucation } } } - }, 1); + }, 1); } @EventHandler(priority = EventPriority.LOW) - public void BlockPlace(BlockPlaceEvent event) + public void BlockPlace(BlockPlaceEvent event) { if (event.isCancelled()) + { return; + } if (!IsAlive(event.getPlayer())) + { return; + } //No water basing if (event.getBlock().getRelative(BlockFace.UP).isLiquid() || @@ -944,7 +1117,7 @@ public class Bridge extends TeamGame implements OreObsfucation event.getItemInHand().getTypeId() == 429 || //1.8 doors event.getItemInHand().getTypeId() == 430 || //1.8 doors event.getItemInHand().getTypeId() == 431 || //1.8 doors - event.getItemInHand().getType() == Material.TRAP_DOOR || + event.getItemInHand().getType() == Material.TRAP_DOOR || event.getItemInHand().getTypeId() == 167 || //Iron trap door event.getItemInHand().getType() == Material.LADDER || event.getItemInHand().getType() == Material.STONE_PLATE || @@ -976,7 +1149,7 @@ public class Bridge extends TeamGame implements OreObsfucation return; } } - + //Too High if (event.getBlock().getLocation().getBlockY() > GetHeightLimit()) { @@ -984,10 +1157,12 @@ public class Bridge extends TeamGame implements OreObsfucation "Cannot place blocks this high up.")); event.setCancelled(true); return; - } + } if (_bridgesDown) + { return; + } //In Liquid if (event.getBlock().getRelative(BlockFace.UP).isLiquid() || @@ -1006,34 +1181,36 @@ public class Bridge extends TeamGame implements OreObsfucation } //Above Water/Void - for (int i = 1; i <= event.getBlock().getLocation().getY(); i++) + for (int i = 1; i <= event.getBlock().getLocation().getY(); i++) { Block below = event.getBlock().getRelative(BlockFace.DOWN, i); if (below.isLiquid()) { UtilPlayer - .message( - event.getPlayer(), - F.main("Game", - "Cannot place blocks above water until Bridge is down.")); + .message( + event.getPlayer(), + F.main("Game", + "Cannot place blocks above water until Bridge is down.")); event.setCancelled(true); return; } - if (event.getBlock().getLocation().getY() - i <= 0) + if (event.getBlock().getLocation().getY() - i <= 0) { UtilPlayer - .message( - event.getPlayer(), - F.main("Game", - "Cannot place blocks above void until Bridge is down.")); + .message( + event.getPlayer(), + F.main("Game", + "Cannot place blocks above void until Bridge is down.")); event.setCancelled(true); return; } if (below.getTypeId() != 0) + { break; + } } } @@ -1043,13 +1220,19 @@ public class Bridge extends TeamGame implements OreObsfucation _ore.BlockBreak(event); if (!IsLive()) + { return; + } if (!IsAlive(event.getPlayer())) + { return; + } if (event.getPlayer().getGameMode() == GameMode.CREATIVE) + { return; + } List drops = new ArrayList(); @@ -1063,8 +1246,10 @@ public class Bridge extends TeamGame implements OreObsfucation } if (drops.isEmpty()) + { return; - + } + event.setCancelled(true); event.getBlock().setType(Material.AIR); @@ -1106,11 +1291,11 @@ public class Bridge extends TeamGame implements OreObsfucation } @EventHandler(priority = EventPriority.LOW) - public void ChestProtect(EntityExplodeEvent event) + public void ChestProtect(EntityExplodeEvent event) { Iterator blockIterator = event.blockList().iterator(); - while (blockIterator.hasNext()) + while (blockIterator.hasNext()) { Block block = blockIterator.next(); @@ -1118,16 +1303,20 @@ public class Bridge extends TeamGame implements OreObsfucation || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE || block.getType() == Material.WORKBENCH) + { blockIterator.remove(); + } } } @EventHandler(priority = EventPriority.LOW) - public void BucketEmpty(PlayerBucketEmptyEvent event) + public void BucketEmpty(PlayerBucketEmptyEvent event) { if (event.getBucket() != Material.WATER_BUCKET) + { return; + } if (WorldWaterDamage > 0) { @@ -1168,7 +1357,7 @@ public class Bridge extends TeamGame implements OreObsfucation } @Override - public OreHider GetOreHider() + public OreHider GetOreHider() { return _ore; } @@ -1177,19 +1366,25 @@ public class Bridge extends TeamGame implements OreObsfucation public void CraftingDeny(PrepareItemCraftEvent event) { if (event.getRecipe().getResult() == null) + { return; + } Material type = event.getRecipe().getResult().getType(); if (type != Material.GOLDEN_APPLE && - type != Material.GOLDEN_CARROT && + type != Material.GOLDEN_CARROT && type != Material.FLINT_AND_STEEL && type != Material.HOPPER) + { return; + } if (!(event.getInventory() instanceof CraftingInventory)) + { return; + } - CraftingInventory inv = (CraftingInventory)event.getInventory(); + CraftingInventory inv = (CraftingInventory) event.getInventory(); inv.setResult(null); } @@ -1198,7 +1393,9 @@ public class Bridge extends TeamGame implements OreObsfucation public void ScoreboardUpdate(UpdateEvent event) { if (event.getType() != UpdateType.FAST) + { return; + } //Wipe Last Scoreboard.reset(); @@ -1207,12 +1404,14 @@ public class Bridge extends TeamGame implements OreObsfucation if (!_tournament) { for (GameTeam team : this.GetTeamList()) - { + { //Display Individual Players if (this.GetPlayers(true).size() < 8) { if (!team.IsTeamAlive()) + { continue; + } Scoreboard.writeNewLine(); @@ -1223,7 +1422,7 @@ public class Bridge extends TeamGame implements OreObsfucation } //Display Players Alive - else + else { Scoreboard.writeNewLine(); Scoreboard.write(team.GetColor() + team.GetName() + " Team"); @@ -1235,10 +1434,12 @@ public class Bridge extends TeamGame implements OreObsfucation else { for (GameTeam team : this.GetTeamList()) - { + { int kills = 0; if (_tournamentKills.containsKey(team)) + { kills = _tournamentKills.get(team); + } Scoreboard.writeNewLine(); @@ -1262,7 +1463,7 @@ public class Bridge extends TeamGame implements OreObsfucation { Scoreboard.write(C.cYellow + C.Bold + "Time Left"); Scoreboard.write(UtilTime.MakeStr(GameTimeout - (System.currentTimeMillis() - GetStateTime()), 0)); - } + } Scoreboard.draw(); } @@ -1271,16 +1472,23 @@ public class Bridge extends TeamGame implements OreObsfucation public void RecordKill(CombatDeathEvent event) { Game game = Manager.GetGame(); - if (game == null) return; + if (game == null) + { + return; + } if (!(event.GetEvent().getEntity() instanceof Player)) + { return; + } - Player killed = (Player)event.GetEvent().getEntity(); + Player killed = (Player) event.GetEvent().getEntity(); GameTeam killedTeam = GetTeam(killed); - if (killedTeam == null) + if (killedTeam == null) + { return; + } if (event.GetLog().GetKiller() != null) { @@ -1289,33 +1497,49 @@ public class Bridge extends TeamGame implements OreObsfucation if (killer != null && !killer.equals(killed)) { GameTeam killerTeam = GetTeam(killer); - if (killerTeam == null) + if (killerTeam == null) + { return; + } if (killerTeam.equals(killedTeam)) + { return; + } if (!_tournamentKills.containsKey(killerTeam)) + { _tournamentKills.put(killerTeam, 1); + } else + { _tournamentKills.put(killerTeam, _tournamentKills.get(killerTeam) + 1); + } } //self kill else if (_bridgesDown) { if (!_tournamentKills.containsKey(killedTeam)) + { _tournamentKills.put(killedTeam, -1); + } else + { _tournamentKills.put(killedTeam, _tournamentKills.get(killedTeam) - 1); + } } } //self kill else if (_bridgesDown) { if (!_tournamentKills.containsKey(killedTeam)) + { _tournamentKills.put(killedTeam, -1); + } else + { _tournamentKills.put(killedTeam, _tournamentKills.get(killedTeam) - 1); + } } } @@ -1323,13 +1547,17 @@ public class Bridge extends TeamGame implements OreObsfucation public void EndCheck() { if (!IsLive()) + { return; + } ArrayList teamsAlive = new ArrayList(); for (GameTeam team : this.GetTeamList()) if (team.GetPlayers(true).size() > 0) + { teamsAlive.add(team); + } // if (!QuitOut) // { @@ -1344,7 +1572,9 @@ public class Bridge extends TeamGame implements OreObsfucation if (!_tournament) { if (teamsAlive.size() > 0) + { AnnounceEnd(teamsAlive.get(0)); + } } else { @@ -1366,7 +1596,9 @@ public class Bridge extends TeamGame implements OreObsfucation } if (bestTeam != null) + { AnnounceEnd(bestTeam); + } } @@ -1380,11 +1612,13 @@ public class Bridge extends TeamGame implements OreObsfucation for (Player player : team.GetPlayers(false)) if (player.isOnline()) + { AddGems(player, 10, "Participation", false, false); + } } //End - SetState(GameState.End); + SetState(GameState.End); } } @@ -1433,7 +1667,7 @@ public class Bridge extends TeamGame implements OreObsfucation //Team Won else - { + { AnnounceEnd(bestTeams.get(0)); for (GameTeam team : GetTeamList()) @@ -1446,12 +1680,14 @@ public class Bridge extends TeamGame implements OreObsfucation for (Player player : team.GetPlayers(false)) if (player.isOnline()) + { AddGems(player, 10, "Participation", false, false); + } } //End - SetState(GameState.End); - } + SetState(GameState.End); + } } public boolean isBridgesDown() @@ -1463,15 +1699,21 @@ public class Bridge extends TeamGame implements OreObsfucation public void CheatChestBreak(BlockBreakEvent event) { if (_bridgesDown) + { return; + } if (event.getBlock().getType() != Material.CHEST) + { return; + } if (!IsAlive(event.getPlayer())) + { return; + } - for (Location loc : WorldData.GetCustomLocs("54")) + for (Location loc : WorldData.GetCustomLocs("54")) { if (loc.getBlock().equals(event.getBlock())) { @@ -1486,15 +1728,21 @@ public class Bridge extends TeamGame implements OreObsfucation public void CheatChestBreak(BlockPlaceEvent event) { if (_bridgesDown) + { return; + } if (event.getBlock().getType() != Material.CHEST) + { return; + } if (!IsAlive(event.getPlayer())) + { return; + } - for (Location loc : WorldData.GetCustomLocs("54")) + for (Location loc : WorldData.GetCustomLocs("54")) { if (UtilMath.offset(loc, event.getBlock().getLocation()) < 2) { @@ -1509,18 +1757,26 @@ public class Bridge extends TeamGame implements OreObsfucation public void CheatChestInteract(PlayerInteractEvent event) { if (_bridgesDown) + { return; + } if (event.getClickedBlock() == null) - return; + { + return; + } if (event.getClickedBlock().getType() != Material.CHEST) + { return; + } if (!IsAlive(event.getPlayer())) + { return; + } - for (Location loc : WorldData.GetCustomLocs("54")) + for (Location loc : WorldData.GetCustomLocs("54")) { if (loc.getBlock().equals(event.getClickedBlock())) { @@ -1532,56 +1788,72 @@ public class Bridge extends TeamGame implements OreObsfucation } @EventHandler(priority = EventPriority.MONITOR) - public void PreBridgeDamage(CustomDamageEvent event) + public void PreBridgeDamage(CustomDamageEvent event) { if (event.IsCancelled()) + { return; + } if (_bridgesDown || event.GetProjectile() != null) + { return; + } GameTeam damageeTeam = GetTeam(event.GetDamageePlayer()); GameTeam damagerTeam = GetTeam(event.GetDamagerPlayer(false)); if (damageeTeam == null || damagerTeam == null) + { return; + } if (damageeTeam.equals(damagerTeam)) + { return; + } Player damagee = event.GetDamageePlayer(); Player damager = event.GetDamagerPlayer(false); //Damagee is closer to Damagers Island - if (UtilMath.offset(damagee.getLocation(), UtilWorld.averageLocation(damageeTeam.GetSpawns())) > - UtilMath.offset(damagee.getLocation(), UtilWorld.averageLocation(damagerTeam.GetSpawns()))) + if (UtilMath.offset(damagee.getLocation(), UtilWorld.averageLocation(damageeTeam.GetSpawns())) > + UtilMath.offset(damagee.getLocation(), UtilWorld.averageLocation(damagerTeam.GetSpawns()))) { cheaterKill(damagee); } //Damagee is closer to Damagees Island - if (UtilMath.offset(damager.getLocation(), UtilWorld.averageLocation(damagerTeam.GetSpawns())) > - UtilMath.offset(damager.getLocation(), UtilWorld.averageLocation(damageeTeam.GetSpawns()))) + if (UtilMath.offset(damager.getLocation(), UtilWorld.averageLocation(damagerTeam.GetSpawns())) > + UtilMath.offset(damager.getLocation(), UtilWorld.averageLocation(damageeTeam.GetSpawns()))) { cheaterKill(damager); } } - + @EventHandler public void preventMinecarts(PlayerInteractEvent event) { if (!IsLive()) + { return; + } if (!IsAlive(event.getPlayer())) + { return; + } if (!UtilEvent.isAction(event, ActionType.R)) + { return; - + } + if (event.getItem() == null) + { return; - + } + if (event.getItem().getType().toString().toLowerCase().contains("minecart")) { event.setCancelled(true); @@ -1593,7 +1865,9 @@ public class Bridge extends TeamGame implements OreObsfucation public void preventMinecarts(EntitySpawnEvent event) { if (!IsLive()) + { return; + } if (event.getEntityType().toString().toLowerCase().contains("minecart")) { @@ -1610,7 +1884,7 @@ public class Bridge extends TeamGame implements OreObsfucation @EventHandler public void liquidFlow(BlockFromToEvent event) - { + { if (!_bridgesDown) { if (!event.getToBlock().getRelative(BlockFace.UP).equals(event.getBlock())) @@ -1620,7 +1894,7 @@ public class Bridge extends TeamGame implements OreObsfucation } } - @EventHandler(priority=EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.HIGHEST) public void revivePlayer(CustomDamageEvent event) { if (!IsLive() || event.isCancelled() || _bridgesDown || !(event.GetDamageeEntity() instanceof Player)) @@ -1634,7 +1908,7 @@ public class Bridge extends TeamGame implements OreObsfucation { return; } - + if (!_usedLife.contains(player.getName())) { _usedLife.add(player.getName()); @@ -1653,7 +1927,9 @@ public class Bridge extends TeamGame implements OreObsfucation public void vehicleDeny(PlayerInteractEvent event) { if (!UtilEvent.isAction(event, ActionType.R)) + { return; + } if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.BOAT)) { @@ -1668,53 +1944,59 @@ public class Bridge extends TeamGame implements OreObsfucation public double GetKillsGems(Player killer, Player killed, boolean assist) { if (assist) + { return 3; + } else + { return 12; + } } - + @EventHandler public void disableIceForm(BlockFormEvent event) { event.setCancelled(true); } - + @EventHandler public void disableWaterPickup(PlayerBucketFillEvent event) - { - if(_bridgesDown) - return; - 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; } - + 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) + 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(); @@ -1765,31 +2047,66 @@ public class Bridge extends TeamGame implements OreObsfucation } } + @EventHandler + public void blockOutsideBorder(BlockBreakEvent event) + { + Player player = event.getPlayer(); + + if (_bridgesDown || player.getGameMode() != GameMode.SURVIVAL) + { + return; + } + + GameTeam team = GetTeam(player); + Block block = event.getBlock(); + + if (team == null) + { + return; + } + + List border = WorldData.GetCustomLocs("BORDER " + team.getDisplayName()); + + if (border.size() < 2) + { + return; + } + + Location one = border.get(0); + Location two = border.get(1); + + if (!UtilAlg.inBoundingBox(block.getLocation(), one, two)) + { + event.setCancelled(true); + player.sendMessage(F.main("Game", "You cannot break blocks outside the border.")); + } + } + public void setBridgeTime(int time) { _bridgeTime = time; } - + public boolean hasUsedRevive(Player player) { return _usedLife.contains(player.getName()); - } + } public double getOreDensity() { return _oreDensity; } - + public ArrayList getChestLoot() { 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/custom/CustomBridgeAnimation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/animation/custom/CustomBridgeAnimation.java index b2d9e5752..e1fe59874 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 @@ -21,6 +21,8 @@ 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; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; public abstract class CustomBridgeAnimation extends BridgeAnimation { @@ -198,7 +200,18 @@ public abstract class CustomBridgeAnimation extends BridgeAnimation _maxDistance = dist; } - _restore.add(block, Material.AIR.getId(), (byte) 0, Integer.MAX_VALUE); + int toSet = Material.AIR.getId(); + + for (Block surround : getNextBlocks(block)) + { + if (surround.getType() == Material.WATER || surround.getType() == Material.STATIONARY_WATER) + { + toSet = Material.STATIONARY_WATER.getId(); + break; + } + } + + _restore.add(block, toSet, (byte) 0, Integer.MAX_VALUE); _bridgeBlocks.put(block.getLocation(), dist); } } @@ -248,4 +261,16 @@ public abstract class CustomBridgeAnimation extends BridgeAnimation return builder.toString(); } + private List getNextBlocks(Block block) + { + List blocks = new ArrayList<>(4); + + blocks.add(block.getRelative(BlockFace.NORTH)); + blocks.add(block.getRelative(BlockFace.EAST)); + blocks.add(block.getRelative(BlockFace.SOUTH)); + blocks.add(block.getRelative(BlockFace.WEST)); + + return blocks; + } + } From fdee6b11639606130783a718ffb89084a79697a3 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 15 Mar 2017 14:33:56 +0100 Subject: [PATCH 05/10] Add some more event commands, fix some existing event commands and change permissions for event related commands to be executeable by EVENT_MODERATOR --- .../src/mineplex/core/common/Rank.java | 3 +- .../HostEventServerCommand.java | 7 +- .../HostPersonalEventServer.java | 34 ++ .../personalServer/PersonalServerManager.java | 17 +- .../preferences/ui/menus/PreferenceMenu.java | 4 +- .../nautilus/game/arcade/ArcadeManager.java | 2 +- .../arcade/game/games/event/EventModule.java | 403 +++++++++++++----- .../arcade/game/games/smash/SuperSmash.java | 5 + .../games/survivalgames/SurvivalGames.java | 5 + .../button/PlayerHeadButton.java | 3 + 10 files changed, 366 insertions(+), 117 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 6871107bb..a8796a426 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -17,6 +17,7 @@ public enum Rank JNR_DEV("Jr.Dev", "jrdev", ChatColor.GOLD, "Junior Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", -1), SUPPORT("Support", "spp", ChatColor.BLUE, "Support agents handle tickets and \nprovide customer service.", 47), CMOD("C.Mod", "cmod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32), + EVENT_MODERATOR("Sr.Mod", "eventmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 44), SNR_MODERATOR("Sr.Mod", "srmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 44), MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32), HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 24), @@ -151,4 +152,4 @@ public enum Rank { return _forumId; } -} \ No newline at end of file +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java index 06667e96d..8b4ad8625 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java @@ -12,7 +12,10 @@ public class HostEventServerCommand extends CommandBase { public HostEventServerCommand(PersonalServerManager plugin) { - super(plugin, Rank.ADMIN, "hostevent"); + super(plugin, Rank.ADMIN, new Rank[] + { + Rank.EVENT_MODERATOR + }, "hostevent"); } @Override @@ -26,6 +29,6 @@ public class HostEventServerCommand extends CommandBase UtilPlayer.message(caller, F.main("Disguise", "You can't create a event server while you are disguised!")); return; } - Plugin.hostServer(caller, caller.getName(), true); + Plugin.hostServer(caller, caller.getName(), true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java new file mode 100644 index 000000000..92515d731 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java @@ -0,0 +1,34 @@ +package mineplex.core.personalServer; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; + +public class HostPersonalEventServer extends CommandBase +{ + public HostPersonalEventServer(PersonalServerManager plugin) + { + super(plugin, Rank.ADMIN, new Rank[] + { + Rank.EVENT_MODERATOR + }, "hostmes"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (!Recharge.Instance.use(caller, "Host Event", 30000, false, false)) + return; + + if(Plugin.getClients().Get(caller).isDisguised()) + { + UtilPlayer.message(caller, F.main("Disguise", "You can't create a event server while you are disguised!")); + return; + } + Plugin.hostServer(caller, caller.getName(), false, true); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java index 976814e4d..556d3758a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java @@ -106,6 +106,7 @@ public class PersonalServerManager extends MiniPlugin { addCommand(new HostServerCommand(this)); addCommand(new HostEventServerCommand(this)); + addCommand(new HostPersonalEventServer(this)); } private void setupConfigValues() @@ -124,6 +125,11 @@ public class PersonalServerManager extends MiniPlugin } public void hostServer(Player player, String serverName, boolean eventServer) + { + hostServer(player, serverName, eventServer, false); + } + + public void hostServer(Player player, String serverName, boolean eventServer, boolean eventgame) { int ram = 1024; int cpu = 1; @@ -143,7 +149,16 @@ public class PersonalServerManager extends MiniPlugin createGroup(player, "EVENT", ram, cpu, 40, 80, "Event", eventServer); } else - createGroup(player, serverName, ram, cpu, 40, 80, "Smash", eventServer); + { + if (eventgame) + { + createGroup(player, serverName, ram, cpu, 40, 80, "Event", eventServer); + } + else + { + createGroup(player, serverName, ram, cpu, 40, 80, "Smash", eventServer); + } + } } public void hostCommunityServer(Player host, Community community) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java index 08aef8b47..c077facb8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/menus/PreferenceMenu.java @@ -47,7 +47,9 @@ public class PreferenceMenu extends Menu if (rank.has(Rank.HELPER) && !rank.has(Rank.ADMIN)) { preferences.remove(Preference.INVISIBILITY); - preferences.remove(Preference.FORCE_FIELD); + + if (rank != Rank.EVENT_MODERATOR) + preferences.remove(Preference.FORCE_FIELD); } else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index af4d8cea5..20c226a03 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -1632,7 +1632,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation { // Disables gadgets if player count is greater than 40 int playerCount = UtilServer.getPlayers().length; - getCosmeticManager().getGadgetManager().setGadgetEnabled(playerCount <= 40); + getCosmeticManager().getGadgetManager().setGadgetEnabled(playerCount <= (GetGameHostManager().isEventServer() ? 120 : 40)); } /*public void saveBasicStats(final Game game) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java index bb7c61020..fe0c42add 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/event/EventModule.java @@ -6,31 +6,6 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.List; -import mineplex.core.MiniPlugin; -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.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilInv; -import mineplex.core.creature.event.CreatureKillEntitiesEvent; -import mineplex.core.event.StackerEvent; -import mineplex.core.gadget.gadgets.morph.MorphBlock; -import mineplex.core.gadget.types.Gadget; -import mineplex.core.gadget.types.GadgetType; -import mineplex.core.give.Give; -import mineplex.core.mount.Mount; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.bridge.Bridge; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Effect; @@ -54,6 +29,7 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -62,6 +38,36 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import mineplex.core.MiniPlugin; +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.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.creature.event.CreatureKillEntitiesEvent; +import mineplex.core.event.StackerEvent; +import mineplex.core.gadget.gadgets.morph.MorphBlock; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.give.Give; +import mineplex.core.mount.Mount; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.games.bridge.Bridge; +import nautilus.game.arcade.game.games.smash.SuperSmash; +import nautilus.game.arcade.game.games.survivalgames.SurvivalGames; +import nautilus.game.arcade.kit.Kit; + public class EventModule extends MiniPlugin { @@ -78,6 +84,8 @@ public class EventModule extends MiniPlugin private ArrayList _damage; private boolean _allowStacker; + private boolean _keepInventory; + public EventModule(ArcadeManager manager, JavaPlugin plugin) { super("EventModule", plugin); @@ -159,7 +167,6 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.value("/e doublejump", "Toggles Double Jump")); UtilPlayer.message(player, F.value("/e bc", "Broadcast a message with colorcodes")); UtilPlayer.message(player, F.value("/e tempgadget", "Activates gadget for all player")); - UtilPlayer.message(player, F.value("/e playerdamage", "Toggles damage fpr player")); UtilPlayer.message(player, F.value("/e stacker [Player]", "toggles stacker global or for Players")); UtilPlayer.message(player, F.value("/e kick", "Remove a player from the event")); UtilPlayer.message(player, F.value("/e area PVP|ALL|PVE|EVP|Gadget|Effect / add", "Create and edit areas")); @@ -175,6 +182,18 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.value("/e effect ", "")); UtilPlayer.message(player, F.value("/e effect clear", "")); + + UtilPlayer.message(player, F.value("/e announce ", "Broadcasts a 1.8 announcement")); + UtilPlayer.message(player, F.value("/e clear ", "Clears player’s inventory")); + UtilPlayer.message(player, F.value("/e clear all", "Clears all inventories")); + UtilPlayer.message(player, F.value("/e bridge", "Forces Bridges countdown to 10 seconds")); + UtilPlayer.message(player, F.value("/e revive", "Revive a Player")); + UtilPlayer.message(player, F.value("/e keepinventory", "")); + UtilPlayer.message(player, F.value("/e gamekit", "Change kit of a Player")); + UtilPlayer.message(player, F.value("/e smash", "spawn smash Crystal in Smash")); + UtilPlayer.message(player, F.value("/e dm", "start dm in SG")); + UtilPlayer.message(player, F.value("/e supplydrop", "spawn supply Drop in SG")); + UtilPlayer.message(player, F.value("/ea", "Talk in event chat")); } public void commandHelpSettings(Player player) @@ -199,9 +218,6 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.value("/e blockbreak whitelist ", "")); UtilPlayer.message(player, F.value("/e blockbreak blacklist ", "")); UtilPlayer.message(player, F.value("/e time <-1 to 24000>", "Sets World Time")); - //UtilPlayer.message(player, F.value("/e joiningame", "toggles Join In Process for games")); - //UtilPlayer.message(player, F.value("/e deathout", "toggles Deathout in games")); - //UtilPlayer.message(player, F.value("/e quitout", "toggles Quitout in games")); UtilPlayer.message(player, F.value("/e mobgriefing", "toggles mobgriefing in games")); } @@ -209,24 +225,30 @@ public class EventModule extends MiniPlugin @EventHandler(priority = EventPriority.LOWEST) public void commandHandler(PlayerCommandPreprocessEvent event) { - if (Manager.GetGame() == null || !Manager.GetGame().InProgress()) - return; - - if (!event.getMessage().toLowerCase().startsWith("/e ")) + if (Manager.GetGame() == null) return; boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1"); if(!Manager.GetGameHostManager().isEventServer() && !eventTestServer) return; + + //Trim off /e and split to args + String[] args = event.getMessage().substring(3, event.getMessage().length()).split(" "); + + if (event.getMessage().toLowerCase().startsWith("/ea")) + { + commandEventChat(event.getPlayer(), args); + event.setCancelled(true); + } - event.setCancelled(true); + if (!event.getMessage().toLowerCase().startsWith("/e ")) + return; if (!Manager.GetGameHostManager().isAdmin(event.getPlayer(), false)) return; - //Trim off /e and split to args - String[] args = event.getMessage().substring(3, event.getMessage().length()).split(" "); + event.setCancelled(true); if (args.length == 0 || args[0].equalsIgnoreCase("help")) { @@ -240,7 +262,6 @@ public class EventModule extends MiniPlugin commandHelpSettings(event.getPlayer()); } - //XXX Commands else if (args[0].equalsIgnoreCase("tp")) { commandTeleport(event.getPlayer(), args); @@ -257,9 +278,90 @@ public class EventModule extends MiniPlugin { commandAdmin(event.getPlayer(), args); } + else if (args[0].equalsIgnoreCase("whitelist")) + { + commandWhitelist(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("give")) + { + commandGive(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("effect")) + { + commandEffect(event.getPlayer(), args, null); + } + else if (args[0].equalsIgnoreCase("mob")) + { + if (args.length >= 2 && args[1].equalsIgnoreCase("kill")) + commandMobKill(event.getPlayer(), args); + else + commandMob(event.getPlayer(), args); + } + else if(args[0].equalsIgnoreCase("bc")) + { + commandBC(event.getPlayer(), args); + } + else if(args[0].equalsIgnoreCase("kick")) + { + if(Bukkit.getPlayer(args[1]) == null) + { + UtilPlayer.message(event.getPlayer(), "No matches for: " + C.cYellow + args[1]); + return; + } + if (Manager.GetGameHostManager().getBlacklist().contains(Bukkit.getPlayer(args[1]).getName())) + { + Manager.GetGameHostManager().getBlacklist().remove(Bukkit.getPlayer(args[1]).getName()); + } + else + { + Manager.GetGameHostManager().getBlacklist().add(Bukkit.getPlayer(args[1]).getName()); + UtilPlayer.message(event.getPlayer(), F.main("Event", "You removed " + C.cYellow + Bukkit.getPlayer(args[1]).getName())); + } + } + else if(args[0].equalsIgnoreCase("tempgadget")) + { + String gadget = args[1]; + for(int e = 2; e < args.length; e++) + gadget+= " " + args[e]; + + try + { + for(Player target : UtilServer.getPlayers()) + Manager.GetDonation().Get(target).addOwnedUnknownSalesPackage(gadget); + } + catch (Exception e) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "Gadget is not vallid")); + } + UtilPlayer.message(event.getPlayer(), F.main("Event", "You gave the gadget " + F.item(gadget) + " to all Players!")); + } + else if (args[0].equalsIgnoreCase("announce")) + { + String text = args[1]; + + for (int i = 2; i < args.length; i++) + { + text += " " + args[i]; + } + + UtilTextMiddle.display(C.cDGreenB + "Announcement", text); + UtilServer.broadcast(F.main("Event Announcement", text)); + } + + if (!Manager.GetGame().InProgress()) + return; + + //XXX Commands else if (args[0].equalsIgnoreCase("gm")) { commandGamemode(event.getPlayer(), args); + }else if (args[0].equalsIgnoreCase("gamekit")) + { + commandGameKit(event.getPlayer(), args); + } + else if (args[0].equalsIgnoreCase("keepinventory")) + { + commandKeepInventory(event.getPlayer()); } else if (args[0].equalsIgnoreCase("radius")) { @@ -273,28 +375,13 @@ public class EventModule extends MiniPlugin { commandScoreboard(event.getPlayer(), args); } - else if (args[0].equalsIgnoreCase("whitelist")) - { - commandWhitelist(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("give")) - { - commandGive(event.getPlayer(), args); - } - else if (args[0].equalsIgnoreCase("effect")) - { - commandEffect(event.getPlayer(), args, null); - } else if (args[0].equalsIgnoreCase("kit")) { commandKit(event.getPlayer(), args); } - else if (args[0].equalsIgnoreCase("mob")) + else if (args[0].equalsIgnoreCase("revive")) { - if (args.length >= 2 && args[1].equalsIgnoreCase("kill")) - commandMobKill(event.getPlayer(), args); - else - commandMob(event.getPlayer(), args); + commandRevive(event.getPlayer(), args); } @@ -366,22 +453,14 @@ public class EventModule extends MiniPlugin { commandTime(event.getPlayer(), args); } - /*else if(args[0].equalsIgnoreCase("joiningame")) - { - commandSpectators(event.getPlayer(), args); - } - else if(args[0].equalsIgnoreCase("deathout")) - { - commandDeathout(event.getPlayer(), args); - } - else if(args[0].equalsIgnoreCase("quitout")) - { - commandQuitOut(event.getPlayer(), args); - }*/ else if(args[0].equalsIgnoreCase("blockplacecreative")) { commandBlockPlaceInCreative(event.getPlayer(), args); } + else if(args[0].equalsIgnoreCase("blockbreakcreative")) + { + commandBlockBreakInCreative(event.getPlayer(), args); + } else if(args[0].equalsIgnoreCase("stacker")) { commandStacker(event.getPlayer(), args); @@ -405,10 +484,6 @@ public class EventModule extends MiniPlugin else _damage.add(Bukkit.getPlayer(args[1])); } - else if(args[0].equalsIgnoreCase("bc")) - { - commandBC(event.getPlayer(), args); - } else if(args[0].equalsIgnoreCase("area")) { if(!(Manager.GetGame() instanceof EventGame)) { @@ -422,46 +497,6 @@ public class EventModule extends MiniPlugin { commandMobGriefing(event.getPlayer(), args); } - else if(args[0].equalsIgnoreCase("kick")) - { - if(Bukkit.getPlayer(args[1]) == null) - { - UtilPlayer.message(event.getPlayer(), "No matches for: " + C.cYellow + args[1]); - return; - } - //Bukkit.getPlayer(args[1]).kickPlayer("You where kicked from the event, probably you didn't stick to the Event Rules."); - Manager.GetGameHostManager().getBlacklist().add(Bukkit.getPlayer(args[1]).getName()); - UtilPlayer.message(event.getPlayer(), F.main("Event", "You removed " + C.cYellow + Bukkit.getPlayer(args[1]).getName())); - } - else if(args[0].equalsIgnoreCase("tempgadget")) - { - String gadget = args[1]; - for(int e = 2; e < args.length; e++) - gadget+= " " + args[e]; - - try - { - for(Player target : UtilServer.getPlayers()) - Manager.GetDonation().Get(target).addOwnedUnknownSalesPackage(gadget); - } - catch (Exception e) - { - UtilPlayer.message(event.getPlayer(), F.main("Event", "Gadget is not vallid")); - } - UtilPlayer.message(event.getPlayer(), F.main("Event", "You gave the gadget " + F.item(gadget) + " to all Players!")); - } - else if (args[0].equalsIgnoreCase("announce")) - { - String text = args[1]; - - for (int i = 2; i < args.length; i++) - { - text += " " + args[i]; - } - - UtilTextMiddle.display(C.cDGreenB + "Announcement", text); - UtilServer.broadcast(F.main("Event Announcement", text)); - } else if (args[0].equalsIgnoreCase("clear")) { String playerName = args[1]; @@ -528,6 +563,50 @@ public class EventModule extends MiniPlugin ((Bridge) Manager.GetGame()).setBridgeTime((int) ((System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + seconds * 1000)); UtilPlayer.message(event.getPlayer(), F.main("Event", "Bridges will drop in " + F.elem(seconds + " Seconds") + "!")); } + else if (args[0].equalsIgnoreCase("dm")) + { + if (!(Manager.GetGame() instanceof SurvivalGames)) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You can only start the deathmatch in SG!")); + return; + } + + if (((SurvivalGames) Manager.GetGame()).isDeathMatchTeleported()) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "The Deathmatch has already began!")); + return; + } + + Manager.GetGame().Announce(C.cGreen + C.Bold + event.getPlayer().getName() + + " has initiated Deathmatch!"); + Manager.GetGame().Announce(C.cGreen + C.Bold + "Deathmatch starting in 60 seconds..."); + + ((SurvivalGames) Manager.GetGame()).setDeathMatchTime(60); + + for (Player player : UtilServer.getPlayers()) + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, + 1f); + } + else if (args[0].equalsIgnoreCase("supplydrop")) + { + if (!(Manager.GetGame() instanceof SurvivalGames)) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You can only start the Supply Srop in SG!")); + return; + } + + Manager.GetGame().WorldData.World.setTime(18000); + } + else if (args[0].equalsIgnoreCase("smash")) + { + if (!(Manager.GetGame() instanceof SuperSmash)) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You can only add a Smash Crystal in Smash!")); + return; + } + + ((SuperSmash) Manager.GetGame()).setNextPowerupTime(100); + } } public void listSettings(Player player) @@ -560,6 +639,80 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(Manager.GetGame().BlockBreakCreative))); } + public void commandKeepInventory(Player player) + { + _keepInventory = !_keepInventory; + + UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(_keepInventory))); + } + + public void commandGameKit(Player player, String[] args) + { + Player target = player; + String kitString = ""; + + if (args.length >= 3) + { + Player newTarget = UtilPlayer.searchOnline(player, args[1], true); + if (newTarget != null) + { + target = newTarget; + kitString = args[2]; + } + else + return; + } + else + return; + + Kit[] kits = Manager.GetGame().GetKits(); + Kit kit = null; + for (Kit otherKit : kits) + if (otherKit.GetName().replace(" ", "").equalsIgnoreCase(kitString)) + kit = otherKit; + + if (kit == null) + { + UtilPlayer.message(player, F.main("Event", "No Kit found")); + return; + } + + Manager.GetGame().SetKit(target, kit, true, true); + UtilPlayer.message(player, F.main("Event", "Kit [" + kit.GetName() + "] applied")); + } + + public void commandEventChat(Player player, String[] args) + { + String message = ChatColor.BLUE + "[Event Chat] " + ChatColor.GREEN + player.getName() + ": " + F.combine(args, 1, null, false); + UtilPlayer.message(player, message); + for (Player other : UtilServer.getPlayers()) + { + if (player == other) + continue; + + if (Manager.GetGameHostManager().isAdmin(other, true)) + UtilPlayer.message(other, message); + } + } + + public void commandRevive(Player player, String[] args) + { + Player target = player; + + if (args.length >= 2) + { + Player newTarget = UtilPlayer.searchOnline(player, args[1], true); + if (newTarget != null) + target = newTarget; + else + return; + } + + Manager.GetGame().SetPlayerState(target, PlayerState.IN); + Manager.GetGame().RespawnPlayer(target); + UtilPlayer.message(target, F.main("Game", "You have been Respawned!")); + } + public void commandStacker(Player player, String[] args) { if(args.length == 1) @@ -861,7 +1014,8 @@ public class EventModule extends MiniPlugin //Gadget Commands (Global & Individual) public void commandGadget(Player player, String[] args) { - if(!(Manager.GetGame() instanceof EventGame)) { + if(!(Manager.GetGame() instanceof EventGame)) + { UtilPlayer.message(player, F.main("Inventory", "You can only enable/disable gadgets in the Event game!")); return; } @@ -2003,6 +2157,33 @@ public class EventModule extends MiniPlugin } } + @EventHandler(priority=EventPriority.HIGHEST) + public void death(PlayerDeathEvent event) + { + if (Manager.GetGame() == null) + return; + + if (!Manager.GetGame().InProgress()) + return; + + if (!_keepInventory) + return; + + ArrayList stacks = new ArrayList<>(); + stacks.addAll(event.getDrops()); + event.getDrops().clear(); + + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + for (ItemStack item : stacks) + event.getEntity().getInventory().addItem(item); + } + }, 40); + } + public ArrayList getDamagePlayers() { return _damage; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java index ba21dfd17..6dd3ab954 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java @@ -773,4 +773,9 @@ public abstract class SuperSmash extends Game _lives.put(player, MAX_LIVES); } } + + public void setNextPowerupTime(long time) + { + _nextPowerup = time; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index 4dc2f850f..7596dc85c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -2184,5 +2184,10 @@ public abstract class SurvivalGames extends Game { return _spawn; } + + public void setDeathMatchTime(int time) + { + _deathMatchTime = time; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/PlayerHeadButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/PlayerHeadButton.java index 033be0d5a..47f9bbb19 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/PlayerHeadButton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/PlayerHeadButton.java @@ -26,6 +26,9 @@ public class PlayerHeadButton implements IButton int maxCap = _arcadeManager.GetGameHostManager().getMaxPlayerCap(); + if (_arcadeManager.GetGameHostManager().isEventServer()) + maxCap = 120; + if (clickType.isLeftClick()) newMax = ++maxPlayers > maxCap ? maxCap : maxPlayers; else From 8a33eabe3db5311f409928fc4abdb35b112c6f8f Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 19 Apr 2017 01:40:23 +0200 Subject: [PATCH 06/10] Add a way to log commands --- .../src/mineplex/core/command/CommandCenter.java | 9 ++++++++- .../core/personalServer/HostEventServerCommand.java | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java index 5ab90fc5a..988c6316f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandCenter.java @@ -89,12 +89,13 @@ public class CommandCenter implements Listener, IPacketHandler public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { String commandName = event.getMessage().substring(1); + String argString = event.getMessage().substring(event.getMessage().indexOf(' ') + 1); String[] args = new String[]{}; if (commandName.contains(" ")) { commandName = commandName.split(" ")[0]; - args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" "); + args = argString.split(" "); } ICommand command = Commands.get(commandName.toLowerCase()); @@ -113,6 +114,12 @@ public class CommandCenter implements Listener, IPacketHandler } command.SetAliasUsed(commandName.toLowerCase()); + + if (command instanceof LoggedCommand) + { + ((LoggedCommand) command).execute(System.currentTimeMillis(), event.getPlayer().getName(), commandName, argString); + } + command.Execute(event.getPlayer(), args); } return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java index 8b4ad8625..7d9f2590b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java @@ -3,6 +3,7 @@ package mineplex.core.personalServer; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; +import mineplex.core.command.LoggedCommand; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; From a0c00e86c40c41772ddef4363bcf4d582ebd6038 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 19 Apr 2017 01:45:39 +0200 Subject: [PATCH 07/10] Implement LoggedCommand into Event Commands --- .../mineplex/core/personalServer/HostEventServerCommand.java | 2 +- .../mineplex/core/personalServer/HostPersonalEventServer.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java index 7d9f2590b..acad080eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostEventServerCommand.java @@ -9,7 +9,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; -public class HostEventServerCommand extends CommandBase +public class HostEventServerCommand extends CommandBase implements LoggedCommand { public HostEventServerCommand(PersonalServerManager plugin) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java index 92515d731..8284c78e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/HostPersonalEventServer.java @@ -3,12 +3,13 @@ package mineplex.core.personalServer; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; +import mineplex.core.command.LoggedCommand; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; -public class HostPersonalEventServer extends CommandBase +public class HostPersonalEventServer extends CommandBase implements LoggedCommand { public HostPersonalEventServer(PersonalServerManager plugin) { From dda09d51e5b8dd25c18dcc8b438044a208458559 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 19 Apr 2017 01:55:19 +0200 Subject: [PATCH 08/10] Fix Commit --- .../mineplex/core/command/LoggedCommand.java | 17 +++++++++++++ .../core/command/LoggingServerCommand.java | 24 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/command/LoggedCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/command/LoggingServerCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/LoggedCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/command/LoggedCommand.java new file mode 100644 index 000000000..fa6f21d74 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/LoggedCommand.java @@ -0,0 +1,17 @@ +package mineplex.core.command; + +/** + * LoggedCommand + * + * @author xXVevzZXx + */ +public interface LoggedCommand +{ + + default void execute(long time, String username, String command, String args) + { + LoggingServerCommand cmd = new LoggingServerCommand(time, username, command, args); + cmd.publish(); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/LoggingServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/command/LoggingServerCommand.java new file mode 100644 index 000000000..34e02073d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/LoggingServerCommand.java @@ -0,0 +1,24 @@ +package mineplex.core.command; + +import mineplex.serverdata.commands.ServerCommand; + +/** + * LoggingServerCommand + * + * @author xXVevzZXx + */ +public class LoggingServerCommand extends ServerCommand +{ + private final long _time; + private final String _username; + private final String _command; + private final String _args; + + public LoggingServerCommand(long time, String username, String command, String args) + { + _time = time; + _username = username; + _command = command; + _args = args; + } +} From d99f51f3a973209f1eda0a0539226e8645db68e0 Mon Sep 17 00:00:00 2001 From: cnr Date: Sun, 30 Apr 2017 01:54:36 -0700 Subject: [PATCH 09/10] Revert "Clans doesn't have access to this through core for some reason" This reverts commit 20264ff1af98a85a2ab0454fc4c0a3618755a2de. --- .../mineplex/game/clans/BookRateLimiter.java | 55 ------------------- .../src/mineplex/game/clans/Clans.java | 2 +- .../src/mineplex/clanshub/ClansHub.java | 7 +-- 3 files changed, 4 insertions(+), 60 deletions(-) delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/BookRateLimiter.java diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/BookRateLimiter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/BookRateLimiter.java deleted file mode 100644 index 49cdd7509..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/BookRateLimiter.java +++ /dev/null @@ -1,55 +0,0 @@ -package mineplex.game.clans; - -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -import net.minecraft.server.v1_8_R3.PacketPlayInCustomPayload; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; - -import mineplex.core.MiniPlugin; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketHandler.ListenerPriority; - -/** - * A temporary fix for book-related crashes. Adds a rate limit to book/sign edits. - *

- * See: - * https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/1c3428e534283395dd1b85641a96a6f16842fc1e - * https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/4acd0f49e07e0912096e79494472535baf0db2ab - */ -public class BookRateLimiter extends MiniPlugin -{ - - private final PacketHandler _packetHandler = require(PacketHandler.class); - private final Cache _cache = CacheBuilder.newBuilder() - .expireAfterWrite(1, TimeUnit.SECONDS) - .build(); - - public BookRateLimiter() - { - super("PacketRateLimiter"); - - _packetHandler.addPacketHandler(info -> - { - PacketPlayInCustomPayload packet = (PacketPlayInCustomPayload) info.getPacket(); - String s = packet.a(); - if (!s.equals("MC|BEdit") && !s.equals("MC|BSign")) - { - return; - } - - if (_cache.asMap().containsKey(info.getPlayer().getUniqueId())) - { - info.setCancelled(true); - - return; - } - - _cache.put(info.getPlayer().getUniqueId(), 0); - - }, ListenerPriority.LOW, true, PacketPlayInCustomPayload.class); - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 4cb014d4a..8599201ea 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -282,7 +282,7 @@ public class Clans extends JavaPlugin SpigotConfig.debug = false; // TODO temporary fix for book related crashes. - new BookRateLimiter(); + new PacketRateLimiter(); } public static String prettifyName(Material material) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index d7a93e3f8..51de3e615 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -1,12 +1,9 @@ package mineplex.clanshub; -import static mineplex.core.Managers.require; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.BookRateLimiter; import mineplex.core.CustomTagFix; import mineplex.core.PacketsInteractionFix; import mineplex.core.account.CoreClientManager; @@ -68,6 +65,8 @@ import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; +import static mineplex.core.Managers.require; + /** * Main class for clans hub */ @@ -186,7 +185,7 @@ public class ClansHub extends JavaPlugin new WebsiteLinkManager(this, clientManager); // TODO temporary fix for book related crashes. - new BookRateLimiter(); + new PacketRateLimiter(); } @Override From 6ae6f7b6270dbcac94a87222d31f3a352be906ec Mon Sep 17 00:00:00 2001 From: cnr Date: Sun, 30 Apr 2017 01:54:43 -0700 Subject: [PATCH 10/10] Revert "Rate limit book/sign edits as a temporary measure against a crash exploit" This reverts commit f5cba1eb1eb5a031ce145ae8539970649a26c83a. --- .../src/mineplex/core/BookRateLimiter.java | 54 ------------------- .../src/mineplex/game/clans/Clans.java | 3 -- .../src/mineplex/clanshub/ClansHub.java | 3 -- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 6 +-- .../src/nautilus/game/arcade/Arcade.java | 9 +--- 5 files changed, 3 insertions(+), 72 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/BookRateLimiter.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/BookRateLimiter.java b/Plugins/Mineplex.Core/src/mineplex/core/BookRateLimiter.java deleted file mode 100644 index e1a5c8e97..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/BookRateLimiter.java +++ /dev/null @@ -1,54 +0,0 @@ -package mineplex.core; - -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -import net.minecraft.server.v1_8_R3.PacketPlayInCustomPayload; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; - -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketHandler.ListenerPriority; - -/** - * A temporary fix for book-related crashes. Adds a rate limit to book/sign edits. - *

- * See: - * https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/1c3428e534283395dd1b85641a96a6f16842fc1e - * https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/4acd0f49e07e0912096e79494472535baf0db2ab - */ -public class BookRateLimiter extends MiniPlugin -{ - - private final PacketHandler _packetHandler = require(PacketHandler.class); - private final Cache _cache = CacheBuilder.newBuilder() - .expireAfterWrite(1, TimeUnit.SECONDS) - .build(); - - public BookRateLimiter() - { - super("PacketRateLimiter"); - - _packetHandler.addPacketHandler(info -> - { - PacketPlayInCustomPayload packet = (PacketPlayInCustomPayload) info.getPacket(); - String s = packet.a(); - if (!s.equals("MC|BEdit") && !s.equals("MC|BSign")) - { - return; - } - - if (_cache.asMap().containsKey(info.getPlayer().getUniqueId())) - { - info.setCancelled(true); - - return; - } - - _cache.put(info.getPlayer().getUniqueId(), 0); - - }, ListenerPriority.LOW, true, PacketPlayInCustomPayload.class); - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 8599201ea..8bddf656b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -280,9 +280,6 @@ public class Clans extends JavaPlugin MinecraftServer.getServer().getPropertyManager().setProperty("debug", false); SpigotConfig.debug = false; - - // TODO temporary fix for book related crashes. - new PacketRateLimiter(); } public static String prettifyName(Material material) diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index 51de3e615..e0997337b 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -183,9 +183,6 @@ public class ClansHub extends JavaPlugin require(Titles.class); require(TwoFactorAuth.class); new WebsiteLinkManager(this, clientManager); - - // TODO temporary fix for book related crashes. - new PacketRateLimiter(); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index c1b7a822b..05b80b2e6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -2,13 +2,13 @@ package mineplex.hub; import static mineplex.core.Managers.require; +import mineplex.hub.modules.AprilFoolsTreasureHunt; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.CustomTagFix; -import mineplex.core.BookRateLimiter; import mineplex.core.PacketsInteractionFix; import mineplex.core.TwitchIntegrationFix; import mineplex.core.account.CoreClientManager; @@ -79,7 +79,6 @@ import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; import mineplex.core.website.WebsiteLinkManager; -import mineplex.hub.modules.AprilFoolsTreasureHunt; import mineplex.hub.modules.BillboardManager; import mineplex.hub.queue.QueueManager; import mineplex.hub.server.ServerManager; @@ -245,9 +244,6 @@ public class Hub extends JavaPlugin implements IRelation require(AprilFoolsTreasureHunt.class); } require(TwitchIntegrationFix.class); - - // TODO temporary fix for book related crashes. - new BookRateLimiter(); } @Override 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 0a699a9f6..26a762345 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -1,10 +1,9 @@ package nautilus.game.arcade; -import static mineplex.core.Managers.require; - import java.io.File; import java.util.HashMap; +import mineplex.core.aprilfools.AprilFoolsManager; import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Bukkit; @@ -17,7 +16,6 @@ import org.spigotmc.SpigotConfig; import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; -import mineplex.core.BookRateLimiter; import mineplex.core.PacketsInteractionFix; import mineplex.core.TimingsFix; import mineplex.core.TwitchIntegrationFix; @@ -26,7 +24,6 @@ import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; import mineplex.core.antihack.RelationProvider; import mineplex.core.antihack.logging.AntihackLogger; -import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.boosters.BoosterManager; @@ -89,6 +86,7 @@ import mineplex.minecraft.game.core.damage.DamageManager; import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameServerConfig; +import static mineplex.core.Managers.require; public class Arcade extends JavaPlugin { @@ -239,9 +237,6 @@ public class Arcade extends JavaPlugin MinecraftServer.getServer().getPropertyManager().setProperty("debug", false); SpigotConfig.debug = false; - - // TODO temporary fix for book related crashes. - new BookRateLimiter(); } @Override