From 633cbdabe279a9ec1a57d96d6585f58a6d3754df Mon Sep 17 00:00:00 2001 From: xGamingDudex Date: Thu, 20 Aug 2015 15:42:39 +0200 Subject: [PATCH 001/106] player.isOnGround() is controlled by packets from the player, meaning players can easily fake being on the ground resulting in infinite double jumps. player.getFallDisance() is also reset when isOnGround() returns true, meaning we'll need to manually check if the player is on the ground. Outlines two opposite corners of the entities bounding box, scann all blocks inside, check if any of them are solid and return respectively. --- .../mineplex/core/common/util/UtilEnt.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 8b489c952..1cc2d5416 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import net.minecraft.server.v1_7_R4.AxisAlignedBB; import net.minecraft.server.v1_7_R4.EntityBat; import net.minecraft.server.v1_7_R4.EntityCreature; import net.minecraft.server.v1_7_R4.EntityEnderDragon; @@ -26,7 +27,9 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.World; -import org.bukkit.block.BlockFace; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; import org.bukkit.entity.Creature; @@ -36,8 +39,6 @@ import org.bukkit.entity.Giant; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature; -import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; public class UtilEnt { @@ -495,10 +496,14 @@ public class UtilEnt public static boolean isGrounded(Entity ent) { - if (ent instanceof CraftEntity) - return ((CraftEntity)ent).getHandle().onGround; - - return UtilBlock.solid(ent.getLocation().getBlock().getRelative(BlockFace.DOWN)); + AxisAlignedBB box = ((CraftEntity)ent).getHandle().boundingBox; + Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.1, box.c); + Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.1, box.f); + + for(Block b : UtilBlock.getInBoundingBox(bottom_corner_1, bottom_corner_2)){ + if(UtilBlock.solid(b)) return true; + } + return false; } public static void PlayDamageSound(LivingEntity damagee) From 33d78a5efd7d8a1a0a4f998f4a9545322e3a5a3a Mon Sep 17 00:00:00 2001 From: Mysticate Date: Sun, 30 Aug 2015 18:39:07 -0400 Subject: [PATCH 002/106] Fixed eating spider eye. Yay! --- .../src/nautilus/game/arcade/managers/GameFlagManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index 97ebf6af2..b535e12a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -849,11 +849,17 @@ public class GameFlagManager implements Listener if (game.HungerSet != -1) for (Player player : game.GetPlayers(true)) + { player.setFoodLevel(game.HungerSet); + player.setSaturation(1F); + } if (game.HealthSet != -1) for (Player player : game.GetPlayers(true)) + { player.setHealth(game.HealthSet); + player.setSaturation(1F); + } } @EventHandler(priority = EventPriority.LOWEST) From becfbe1f1333ddf10a5e82fe3c25cdbadbd17f0a Mon Sep 17 00:00:00 2001 From: Mysticate Date: Sun, 30 Aug 2015 20:09:47 -0400 Subject: [PATCH 003/106] Fixed possible game breaking bug :S --- .../src/nautilus/game/arcade/managers/GameFlagManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index b535e12a6..da2381dd8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -858,7 +858,6 @@ public class GameFlagManager implements Listener for (Player player : game.GetPlayers(true)) { player.setHealth(game.HealthSet); - player.setSaturation(1F); } } From 58ae09ebd4c9af901974d286468a38f792bb75ee Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 31 Aug 2015 11:32:18 +0200 Subject: [PATCH 004/106] saving Project for pulling. --- .../arcade/game/games/event/EventGame.java | 131 +++++++++++++++++- .../arcade/game/games/event/EventModule.java | 60 ++++---- 2 files changed, 159 insertions(+), 32 deletions(-) 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 05d1c8508..681dd16c4 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 @@ -1,9 +1,12 @@ package nautilus.game.arcade.game.games.event; +import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -11,7 +14,9 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseBat; import mineplex.core.disguise.disguises.DisguiseChicken; @@ -26,21 +31,28 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.core.visibility.VisibilityManager; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.event.kits.KitPlayer; +import nautilus.game.arcade.game.games.skywars.TeamSkywars.TeamColors; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.GameHostManager; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.BlockFace; +import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockRedstoneEvent; +import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDeathEvent; @@ -65,6 +77,8 @@ public class EventGame extends Game private boolean _allowAllGadgets = false; private HashSet _gadgetWhitelist = new HashSet(); + + private HashMap _functionSigns; public EventGame(ArcadeManager manager) { @@ -110,9 +124,45 @@ public class EventGame extends Game this.GameTimeout = -1; _mps = manager.GetGameHostManager(); + _functionSigns = new HashMap<>(); this.CreatureAllow = true; } + + @EventHandler + public void registerSigns(GameStateChangeEvent event) + { + if(event.GetState() != GameState.Live) + return; + + for(Location loc : WorldData.GetDataLocs("RED")) + { + for(int i = -5; i < 5; i++) + { + Location temp = loc.clone().add(0, i, 0); + if(temp.getBlock().getType() == Material.SIGN_POST || temp.getBlock().getType() == Material.WALL_SIGN) + { + if(!_functionSigns.containsKey((Sign) temp.getBlock().getState())) + { + _functionSigns.put((Sign) temp.getBlock().getState(), System.currentTimeMillis()); + } + } + } + } + } + + @EventHandler + public void signPlace(SignChangeEvent event) + { + if(!IsLive()) + return; + + if(!Manager.GetGameHostManager().isAdmin(event.getPlayer(), true)) + return; + + if(event.getLine(0).startsWith("[") && event.getLine(0).endsWith("]")) + _functionSigns.put((Sign) event.getBlock().getState(), System.currentTimeMillis()); + } //Before GamePlayerManager puts onto Spec! @EventHandler(priority = EventPriority.LOW) @@ -464,4 +514,81 @@ public class EventGame extends Game return losers; } + @EventHandler + public void signCheck(BlockRedstoneEvent event) + { + if(event.getBlock().getType() != Material.SIGN_POST && event.getBlock().getType() != Material.WALL_SIGN) + return; + + useSign(((Sign) event.getBlock().getState()).getLines()); + } + + @EventHandler + public void signClock(UpdateEvent event) + { + if(event.getType() != UpdateType.SEC) + return; + + for(Sign sign : _functionSigns.keySet()) + { + if(sign.getBlock().getRelative(BlockFace.DOWN).getType() != Material.IRON_BLOCK) + continue; + + Sign cooldown = null; + + for(BlockFace face : BlockFace.values()) + { + if(face == BlockFace.UP) + continue; + + if(sign.getBlock().getRelative(BlockFace.DOWN).getRelative(face).getType() == Material.WALL_SIGN) + { + cooldown = (Sign) sign.getBlock().getRelative(BlockFace.DOWN).getRelative(face).getState(); + break; + } + } + + if(cooldown == null) + continue; + + if(!UtilTime.elapsed(_functionSigns.get(sign), Long.parseLong(cooldown.getLine(0)) * 1000)) + continue; + + _functionSigns.put(sign, System.currentTimeMillis()); + useSign(sign.getLines()); + } + } + + public void useSign(String[] args) + { + String command = args[0]; + String playerName = args[1]; + + command.replace("[", "").replaceAll("]", ""); + if(command.contentEquals("BC")) + { + String message = args[1]; + for(int i = 2; i <= 3; i++) + message += " " + args[i]; + + String colored = ChatColor.translateAlternateColorCodes('&', message); + this.Announce(F.main("Event", colored), true); + } + + + Player player = Bukkit.getPlayer(playerName); + if(player == null) + return; + + String[] vars = new String[args.length - 1]; + vars[0] = args[0]; + vars[1] = args[2]; + vars[2] = args[3]; + + if(command.contentEquals("MOB")) + { + Manager.GetEventModule().commandMob(player, vars); + } + } + } 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 537e6589c..90d0c4f29 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 @@ -54,7 +54,7 @@ import org.bukkit.potion.PotionEffectType; public class EventModule extends MiniPlugin { - public ArcadeManager Manager; + private ArcadeManager Manager; private NautHashMap _potionEffectsDuration = new NautHashMap<>(); private NautHashMap _potionEffectsMult = new NautHashMap<>(); @@ -110,7 +110,7 @@ public class EventModule extends MiniPlugin event.setCancelled(true); } - private void commandHelp(Player player) + public void commandHelp(Player player) { UtilPlayer.message(player, F.main("Event", "Displaying Commands;")); @@ -151,7 +151,7 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.value("/e effect clear", "")); } - private void commandHelpSettings(Player player) + public void commandHelpSettings(Player player) { UtilPlayer.message(player, F.main("Event", "Displaying Settings Commands;")); UtilPlayer.message(player, F.value("/e damage all", "Toggles All Damage")); @@ -181,7 +181,7 @@ public class EventModule extends MiniPlugin //Command Handler @EventHandler(priority = EventPriority.LOWEST) - private void commandHandler(PlayerCommandPreprocessEvent event) + public void commandHandler(PlayerCommandPreprocessEvent event) { if (!Manager.GetGame().InProgress()) return; @@ -366,7 +366,7 @@ public class EventModule extends MiniPlugin } } - private void listSettings(Player player) + public void listSettings(Player player) { UtilPlayer.message(player, F.value("Damage All", F.tf(Manager.GetGame().Damage))); UtilPlayer.message(player, F.value("Damage PvP", F.tf(Manager.GetGame().DamagePvP))); @@ -389,28 +389,28 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.value("Mob griefing", F.tf(_mobGriefing))); } - private void commandBlockBreakInCreative(Player player, String[] args) + public void commandBlockBreakInCreative(Player player, String[] args) { Manager.GetGame().BlockBreakCreative = !Manager.GetGame().BlockBreakCreative; UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(Manager.GetGame().BlockBreakCreative))); } - private void commandBlockPlaceInCreative(Player player, String[] args) + public void commandBlockPlaceInCreative(Player player, String[] args) { Manager.GetGame().BlockPlaceCreative = !Manager.GetGame().BlockPlaceCreative; UtilPlayer.message(player, F.main("Settings", "BlockPlaceCreative: " + F.tf(Manager.GetGame().BlockPlaceCreative))); } - private void commandMobGriefing(Player player, String[] args) + public void commandMobGriefing(Player player, String[] args) { _mobGriefing = !_mobGriefing; UtilPlayer.message(player, F.main("Settings", "Mob Griefing: " + F.tf(_mobGriefing))); } - private void commandBlockPlace(Player player, String[] args, boolean whitelist, String command) + public void commandBlockPlace(Player player, String[] args, boolean whitelist, String command) { try { @@ -471,7 +471,7 @@ public class EventModule extends MiniPlugin commandHelpSettings(player); } - private void commandBlockBreak(Player player, String[] args, boolean whitelist, String command) + public void commandBlockBreak(Player player, String[] args, boolean whitelist, String command) { try { @@ -532,7 +532,7 @@ public class EventModule extends MiniPlugin commandHelpSettings(player); } - private void commandHealth(Player player, String[] args) + public void commandHealth(Player player, String[] args) { try { @@ -563,7 +563,7 @@ public class EventModule extends MiniPlugin commandHelpSettings(player); } - private void commandHunger(Player player, String[] args) + public void commandHunger(Player player, String[] args) { try { @@ -594,7 +594,7 @@ public class EventModule extends MiniPlugin commandHelpSettings(player); } - private void commandTime(Player player, String[] args) + public void commandTime(Player player, String[] args) { try { @@ -626,7 +626,7 @@ public class EventModule extends MiniPlugin } //Teleport Command (To, Here, All) - private void commandTeleport(Player player, String[] args) + public void commandTeleport(Player player, String[] args) { if (args.length >= 3 && args[1].equalsIgnoreCase("here")) { @@ -668,7 +668,7 @@ public class EventModule extends MiniPlugin } //Gadget Commands (Global & Individual) - private void commandGadget(Player player, String[] args) + public void commandGadget(Player player, String[] args) { if(!(Manager.GetGame() instanceof EventGame)) { UtilPlayer.message(player, F.main("Inventory", "You can only enable/disable gadgets in the Event game!")); @@ -780,7 +780,7 @@ public class EventModule extends MiniPlugin } //Silence - private void commandSilence(Player player, String[] args) + public void commandSilence(Player player, String[] args) { try { @@ -813,7 +813,7 @@ public class EventModule extends MiniPlugin } //Gamemode (Self and Others) - private void commandAdmin(Player player, String[] args) + public void commandAdmin(Player player, String[] args) { Player target = player; @@ -835,7 +835,7 @@ public class EventModule extends MiniPlugin } //Gamemode (Self and Others) - private void commandGamemode(Player player, String[] args) + public void commandGamemode(Player player, String[] args) { Player target = player; @@ -857,7 +857,7 @@ public class EventModule extends MiniPlugin } //Forcefield - private void commandForcefieldRadius(Player player, String[] args) + public void commandForcefieldRadius(Player player, String[] args) { if(!(Manager.GetGame() instanceof EventGame)) { @@ -889,7 +889,7 @@ public class EventModule extends MiniPlugin } //Give - private void commandGive(Player player, String[] args) + public void commandGive(Player player, String[] args) { String[] newArgs = new String[args.length-1]; @@ -900,7 +900,7 @@ public class EventModule extends MiniPlugin } //Spec - private void commandSpectators(Player player, String[] args) + public void commandSpectators(Player player, String[] args) { Manager.GetGame().JoinInProgress = !Manager.GetGame().JoinInProgress; @@ -908,7 +908,7 @@ public class EventModule extends MiniPlugin } //Deathout - private void commandDeathout(Player player, String[] args) + public void commandDeathout(Player player, String[] args) { Manager.GetGame().DeathOut = !Manager.GetGame().DeathOut; @@ -916,7 +916,7 @@ public class EventModule extends MiniPlugin } //QuitOut - private void commandQuitOut(Player player, String[] args) + public void commandQuitOut(Player player, String[] args) { Manager.GetGame().QuitOut = !Manager.GetGame().QuitOut; @@ -924,7 +924,7 @@ public class EventModule extends MiniPlugin } //Double Jump - private void commandDoubleJump(Player player, String[] args) + public void commandDoubleJump(Player player, String[] args) { if(!(Manager.GetGame() instanceof EventGame)) { @@ -942,7 +942,7 @@ public class EventModule extends MiniPlugin } //Scoreboard - private void commandScoreboard(Player player, String[] args) + public void commandScoreboard(Player player, String[] args) { if(!(Manager.GetGame() instanceof EventGame)) { @@ -1016,7 +1016,7 @@ public class EventModule extends MiniPlugin } //Whitelist - private void commandWhitelist(Player player, String[] args) + public void commandWhitelist(Player player, String[] args) { //On and Off if (args.length >= 2) @@ -1056,7 +1056,7 @@ public class EventModule extends MiniPlugin } //Mob - private void commandMob(Player caller, String[] args) + public void commandMob(Player caller, String[] args) { if (args.length == 1) { @@ -1444,7 +1444,7 @@ public class EventModule extends MiniPlugin } } - private void commandMobKill(Player caller, String[] args) + public void commandMobKill(Player caller, String[] args) { if (args.length < 3) { @@ -1490,7 +1490,7 @@ public class EventModule extends MiniPlugin UtilPlayer.message(caller, F.main("Creature", "Killed " + target + ". " + count + " Removed.")); } - private void commandKit(Player caller, String[] args) + public void commandKit(Player caller, String[] args) { if(!(Manager.GetGame() instanceof EventGame)) { @@ -1533,7 +1533,7 @@ public class EventModule extends MiniPlugin commandHelp(caller); } - private void commandEffect(Player caller, String[] args) + public void commandEffect(Player caller, String[] args) { //Clear if (args.length >= 3 && args[2].equalsIgnoreCase("clear")) From b63843930f4d5394ff5312c22931114c6c450faf Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 31 Aug 2015 15:08:42 -0400 Subject: [PATCH 005/106] Fixed bug https://trello.com/c/ZYS3Ddxw/134-hub-emerald-twirl-particles-are-called-green-ring-in-the-gui --- .../src/mineplex/core/gadget/gadgets/ParticleGreen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java index 9a370fad1..0489005a2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java @@ -21,7 +21,7 @@ public class ParticleGreen extends ParticleGadget public ParticleGreen(GadgetManager manager) { - super(manager, "Green Ring", new String[] + super(manager, "Emerald Twirl", new String[] { C.cWhite + "With these sparkles, you", C.cWhite + "can now sparkle while you", From 32a257fa55ce97d9b9f98fceb70fc78a0dafb05f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 31 Aug 2015 15:11:57 -0400 Subject: [PATCH 006/106] Fix bug https://trello.com/c/Jf7bht6V/138-general-tp-before-game-starts --- .../src/nautilus/game/arcade/managers/GameFlagManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index 97ebf6af2..34c55e670 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -947,7 +947,7 @@ public class GameFlagManager implements Listener Game game = Manager.GetGame(); if (game == null) return; - if (!game.IsLive()) + if (!(game.IsLive() || game.GetState() == GameState.Prepare)) return; if (!game.TeleportsDisqualify) From 24fed013ae9920a84e6a899ea144ec9998169d9b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 31 Aug 2015 15:39:04 -0400 Subject: [PATCH 007/106] Fixed previous ownership not being transferred --- .../src/mineplex/core/gadget/gadgets/ParticleGreen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java index 0489005a2..9a370fad1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java @@ -21,7 +21,7 @@ public class ParticleGreen extends ParticleGadget public ParticleGreen(GadgetManager manager) { - super(manager, "Emerald Twirl", new String[] + super(manager, "Green Ring", new String[] { C.cWhite + "With these sparkles, you", C.cWhite + "can now sparkle while you", From 5322e9d018189c9ea1ac7315c27f1379086b39b2 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 31 Aug 2015 15:48:25 -0400 Subject: [PATCH 008/106] Marked the Bunny Morph to reflect its no longer available status --- .../src/mineplex/core/gadget/gadgets/MorphBunny.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBunny.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBunny.java index 7d84e2457..78e502bc5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBunny.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBunny.java @@ -59,8 +59,7 @@ public class MorphBunny extends MorphGadget " ", C.cRed +C.Bold + "WARNING: " + ChatColor.RESET + "Hide Easter Egg uses 500 Coins" , " ", - C.cPurple + "Special Limited Time Morph", - C.cPurple + "Purchase at www.mineplex.com/shop", + C.cPurple + "No longer available", }, -1, Material.MONSTER_EGG, (byte)98); From cbb0d4521cb4d12dafca9a4cae901bb3838e5182 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 31 Aug 2015 15:49:31 -0400 Subject: [PATCH 009/106] Made Legend cosmetics follow the same rules as all other premium rank cosmetics, as many staff were previously legend and lacked access to features they had paid for. --- .../src/mineplex/core/gadget/gadgets/MorphWither.java | 5 +---- Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java index da9d82ebd..7bd891dcb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java @@ -177,10 +177,7 @@ public class MorphWither extends MorphGadget @EventHandler public void legendOwner(PlayerJoinEvent event) { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.LEGEND || - Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.ADMIN || - Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.DEVELOPER || - Manager.getClientManager().Get(event.getPlayer()).GetRank() == Rank.OWNER) + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) { Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index a95bcb150..0e70a0a22 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -146,7 +146,7 @@ public class PetManager extends MiniClientPlugin { Player p = event.getPlayer(); Rank rank = _clientManager.Get(p).GetRank(); - if (rank == Rank.LEGEND || rank == Rank.ADMIN || rank == Rank.DEVELOPER || rank == Rank.OWNER) + if (rank.has(Rank.LEGEND)) { _donationManager.Get(p.getName()).AddUnknownSalesPackagesOwned("Widder"); } From fe4586852c7537adb4fb5cf1ca7da3c460c4f2e9 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 31 Aug 2015 15:59:53 -0400 Subject: [PATCH 010/106] Made rank unlock lore colored based on rank required for item (QA Requested) --- .../src/mineplex/core/cosmetic/ui/page/PetPage.java | 2 +- .../src/mineplex/core/gadget/gadgets/MorphPig.java | 2 +- .../src/mineplex/core/gadget/gadgets/MorphWither.java | 2 +- .../src/mineplex/core/gadget/gadgets/ParticleLegend.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index 47d45cfa3..c9a544b93 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -75,7 +75,7 @@ public class PetPage extends ShopPageBase if (pet.GetPetType() == EntityType.WITHER) { itemLore.add(C.cBlack); - itemLore.add(ChatColor.RESET + C.cYellow + "Unlocked with Legend Rank"); + itemLore.add(ChatColor.RESET + C.cGreen + "Unlocked with Legend Rank"); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java index f132e9e7a..44662f5a1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPig.java @@ -38,7 +38,7 @@ public class MorphPig extends MorphGadget C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Oink", C.cYellow + "Collide" + C.cGray + " to use " + C.cGreen + "Pig Bounce", " ", - C.cPurple + "Unlocked with Ultra Rank", + C.cAqua + "Unlocked with Ultra Rank", }, -1, Material.PORK, (byte)0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java index 7bd891dcb..d7e4ba8dc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java @@ -47,7 +47,7 @@ public class MorphWither extends MorphGadget " ", C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Wither Skull", " ", - C.cPurple + "Unlocked with Legend Rank", + C.cGreen + "Unlocked with Legend Rank", }, -1, Material.SKULL_ITEM, (byte)1); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java index 094c1ff39..7be1a9609 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java @@ -22,7 +22,7 @@ public class ParticleLegend extends ParticleGadget C.cWhite + "These mystic particle attach to", C.cWhite + "only the most legendary of players!", " ", - C.cPurple + "Unlocked with Legend Rank", + C.cGreen + "Unlocked with Legend Rank", }, -2, Material.ENDER_PORTAL, (byte)0); From 8a94602aefc1e4ea3490da434f14205f99ba1d8e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 31 Aug 2015 16:03:27 -0400 Subject: [PATCH 011/106] Fixed bug https://trello.com/c/KBhgw0zK/115-hg-mismatching-achievement-text --- .../src/mineplex/core/achievement/Achievement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index ab821003d..01925be94 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -56,7 +56,7 @@ public enum Achievement //Survival Games SURVIVAL_GAMES_WINS("Katniss Everdeen", 600, new String[]{"Survival Games.Wins"}, - new String[]{"Win 20 games of Survival Games"}, + new String[]{"Win 30 games of Survival Games"}, new int[]{30}, AchievementCategory.SURVIVAL_GAMES), From b4ce33a916246263f3c53e820c5fa4a0f1c1f4f6 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Tue, 1 Sep 2015 01:59:36 -0400 Subject: [PATCH 012/106] Fixed things. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Added a cancelled check to No Ability • Removed tokens on quit. • Checked if players are alive before giving them places. --- .../game/games/evolution/Evolution.java | 35 +++++++++++-------- .../evolution/trackers/NoAbilityTracker.java | 3 ++ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index 62978c22b..1d4506b45 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -73,6 +73,7 @@ import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.util.Vector; public class Evolution extends SoloGame @@ -141,7 +142,7 @@ public class Evolution extends SoloGame GemAssistDeathRespawn = .5; CompassEnabled = true; - CompassGiveItem = false; + CompassGiveItem = false; AutomaticRespawn = false; DeathSpectateSecs = 4.0; @@ -149,8 +150,7 @@ public class Evolution extends SoloGame VersionRequire1_8 = true; CreatureAllow = false; - - InventoryClick = false; + InventoryClick = false; InventoryOpenBlock = false; @@ -223,6 +223,12 @@ public class Evolution extends SoloGame upgradeKit(event.GetPlayer(), false); } + @EventHandler + public void removeToken(PlayerQuitEvent event) + { + _tokens.remove(event.getPlayer().getName()); + } + // //Double Kit // @EventHandler(priority = EventPriority.MONITOR) // public void storeTokens(GameStateChangeEvent event) @@ -414,7 +420,7 @@ public class Evolution extends SoloGame } } - @EventHandler + @EventHandler(priority = EventPriority.MONITOR) public void onKill(CombatDeathEvent event) { event.SetBroadcastType(DeathMessageType.Simple); @@ -747,7 +753,11 @@ public class Evolution extends SoloGame for (int i = 0 ; i < tokens.size() ; i++) { - players.add(tokens.get(i).Player); + Player cur = tokens.get(i).Player; + if (!cur.isOnline()) + continue; + + players.add(cur); } //Award Gems @@ -804,19 +814,14 @@ public class Evolution extends SoloGame Scoreboard.WriteBlank(); - int index = 0; + Scoreboard.Write(C.cYellow + C.Bold + "First to " + _mobKits.size()); + + Scoreboard.WriteBlank(); + for (Player player : GetPlayers(true)) { - if (index > 11) - break; - - Scoreboard.WriteOrdered("Score", C.cGreen + player.getName(), getScore(player), true); - index++; + Scoreboard.WriteOrdered("Score", C.cGreen + player.getName(), getScore(player), true); } - - Scoreboard.WriteBlank(); - - Scoreboard.Write(C.cGold + C.Bold + "First to " + _mobKits.size()); Scoreboard.Draw(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoAbilityTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoAbilityTracker.java index 655eb6f79..68b0cee22 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoAbilityTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/trackers/NoAbilityTracker.java @@ -29,6 +29,9 @@ public class NoAbilityTracker extends StatTracker @EventHandler(priority = EventPriority.MONITOR) public void onEvolutionAbility(EvolutionAbilityUseEvent event) { + if (event.isCancelled()) + return; + if (!getGame().IsLive()) return; From 0c58de3c190040a4f22f57226b60b010fbc0d89a Mon Sep 17 00:00:00 2001 From: Mysticate Date: Tue, 1 Sep 2015 02:35:06 -0400 Subject: [PATCH 013/106] Glitches. Fixed the things. --- .../game/arcade/game/games/evolution/kits/KitHealth.java | 4 ++-- .../game/arcade/game/games/evolution/mobs/KitChicken.java | 4 ++++ .../game/games/evolution/mobs/perks/PerkBounceEVO.java | 3 +++ .../games/evolution/mobs/perks/PerkFlamingSwordEVO.java | 4 ++++ .../games/evolution/mobs/perks/PerkSiesmicSlamEVO.java | 3 +++ .../games/evolution/mobs/perks/PerkSulphurBombEVO.java | 4 ++++ .../game/games/evolution/mobs/perks/PerkWebEVO.java | 8 ++++++++ 7 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitHealth.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitHealth.java index b9d93c102..71ae6fc03 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitHealth.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/kits/KitHealth.java @@ -61,7 +61,7 @@ public class KitHealth extends Kit if (!Manager.GetGame().IsLive()) return; - Player killer = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); + Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); if (killer == null || !killer.isOnline()) return; @@ -74,6 +74,6 @@ public class KitHealth extends Kit if (!HasKit(killer)) return; - killer.setHealth(killer.getMaxHealth()); + UtilPlayer.health(killer, 9999); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitChicken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitChicken.java index 0f9b32d9a..0910b74a3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitChicken.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitChicken.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.evolution.mobs; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; @@ -66,6 +67,9 @@ public class KitChicken extends EvoKit if (!UtilEvent.isAction(event, ActionType.R)) return; + if (UtilBlock.usable(event.getClickedBlock())) + return; + if (!Manager.GetGame().IsLive()) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBounceEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBounceEVO.java index 063a22493..d200e76e9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBounceEVO.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkBounceEVO.java @@ -55,6 +55,9 @@ public class PerkBounceEVO extends Perk if (!UtilEvent.isAction(event, ActionType.R)) return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; if (UtilBlock.usable(event.getClickedBlock())) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkFlamingSwordEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkFlamingSwordEVO.java index 6e226b34e..8f38ff279 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkFlamingSwordEVO.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkFlamingSwordEVO.java @@ -5,6 +5,7 @@ import java.util.Map.Entry; import mineplex.core.common.util.C; import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; @@ -49,6 +50,9 @@ public class PerkFlamingSwordEVO extends Perk if (!UtilEvent.isAction(event, ActionType.R)) return; + if (UtilBlock.usable(event.getClickedBlock())) + return; + if (!Manager.GetGame().IsLive()) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSiesmicSlamEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSiesmicSlamEVO.java index ad9232582..9339eef8c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSiesmicSlamEVO.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSiesmicSlamEVO.java @@ -71,6 +71,9 @@ public class PerkSiesmicSlamEVO extends Perk if (!UtilEvent.isAction(event, ActionType.R)) return; + if (UtilBlock.usable(event.getClickedBlock())) + return; + if (!UtilInv.IsItem(event.getItem(), Material.IRON_INGOT, (byte) 0)) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSulphurBombEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSulphurBombEVO.java index a11c63035..b38629a80 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSulphurBombEVO.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkSulphurBombEVO.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.evolution.mobs.perks; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; @@ -55,6 +56,9 @@ public class PerkSulphurBombEVO extends Perk implements IThrown if (!UtilEvent.isAction(event, ActionType.R)) return; + if (UtilBlock.usable(event.getClickedBlock())) + return; + if (!UtilInv.IsItem(event.getItem(), Material.SULPHUR, (byte) 0)) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkWebEVO.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkWebEVO.java index 7abe68567..03aeaa0d8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkWebEVO.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/perks/PerkWebEVO.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.evolution.mobs.perks; import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; @@ -39,6 +40,9 @@ public class PerkWebEVO extends Perk implements IThrown if (!UtilEvent.isAction(event, ActionType.R)) return; + if (UtilBlock.usable(event.getClickedBlock())) + return; + if (!Manager.GetGame().IsLive()) return; @@ -109,7 +113,11 @@ public class PerkWebEVO extends Perk implements IThrown public void Web(ProjectileUser data) { Location loc = data.GetThrown().getLocation(); + data.GetThrown().remove(); + + if (loc.getBlock().getType() != Material.AIR) + return; Manager.GetBlockRestore().Add(loc.getBlock(), 30, (byte)0, 4000); } From 271b86dabdb3c069f62066606f549b2545fba492 Mon Sep 17 00:00:00 2001 From: Mysticate Date: Fri, 4 Sep 2015 11:45:42 -0400 Subject: [PATCH 014/106] Fixed spectators slowing evolution times. --- .../nautilus/game/arcade/game/games/evolution/Evolution.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index 1d4506b45..39ceda806 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -375,9 +375,12 @@ public class Evolution extends SoloGame } } - @EventHandler + @EventHandler(priority = EventPriority.MONITOR) public void onDamage(CustomDamageEvent event) { + if (event.IsCancelled()) + return; + if (!IsLive()) return; From 5712af8ddcaeac6c5c5090b7ce7c445418c754ac Mon Sep 17 00:00:00 2001 From: Sarah Date: Sat, 5 Sep 2015 20:38:51 +0200 Subject: [PATCH 015/106] Adding Redstone function signs for events. --- .../arcade/game/games/event/EventGame.java | 316 ++++++++++++++++-- .../arcade/game/games/event/EventModule.java | 40 ++- 2 files changed, 327 insertions(+), 29 deletions(-) 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 681dd16c4..6f74a2da3 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 @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import mineplex.core.common.util.F; @@ -23,6 +24,7 @@ import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.disguise.disguises.DisguiseEnderman; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.gadget.event.GadgetActivateEvent; +import mineplex.core.give.Give; import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.SalesPackageBase; @@ -34,7 +36,6 @@ 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.skywars.TeamSkywars.TeamColors; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.GameHostManager; @@ -51,6 +52,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.entity.CreatureSpawnEvent; @@ -79,6 +81,7 @@ public class EventGame extends Game private HashSet _gadgetWhitelist = new HashSet(); private HashMap _functionSigns; + private ArrayList _powerdedSigns; public EventGame(ArcadeManager manager) { @@ -125,6 +128,7 @@ public class EventGame extends Game _mps = manager.GetGameHostManager(); _functionSigns = new HashMap<>(); + _powerdedSigns = new ArrayList<>(); this.CreatureAllow = true; } @@ -514,25 +518,23 @@ public class EventGame extends Game return losers; } - @EventHandler + /*@EventHandler public void signCheck(BlockRedstoneEvent event) { if(event.getBlock().getType() != Material.SIGN_POST && event.getBlock().getType() != Material.WALL_SIGN) - return; + return; useSign(((Sign) event.getBlock().getState()).getLines()); - } + }*/ @EventHandler public void signClock(UpdateEvent event) { - if(event.getType() != UpdateType.SEC) + if(event.getType() != UpdateType.TICK) return; for(Sign sign : _functionSigns.keySet()) { - if(sign.getBlock().getRelative(BlockFace.DOWN).getType() != Material.IRON_BLOCK) - continue; Sign cooldown = null; @@ -542,42 +544,243 @@ public class EventGame extends Game continue; if(sign.getBlock().getRelative(BlockFace.DOWN).getRelative(face).getType() == Material.WALL_SIGN) - { + { cooldown = (Sign) sign.getBlock().getRelative(BlockFace.DOWN).getRelative(face).getState(); break; } } if(cooldown == null) + { + if(!sign.getBlock().isBlockPowered()) + { + _powerdedSigns.remove(sign); + continue; + } + + if(_powerdedSigns.contains(sign)) + continue; + + useSign(sign, ((Sign) sign.getBlock().getState()).getLines()); + + if(sign.getBlock().isBlockPowered()) + { + if(!_powerdedSigns.contains(sign)) + { + _powerdedSigns.add(sign); + } + } + continue; + } + + if(!sign.getBlock().isBlockPowered() && !UtilTime.elapsed(_functionSigns.get(sign), Long.parseLong(cooldown.getLine(0)) * 1000)) continue; - if(!UtilTime.elapsed(_functionSigns.get(sign), Long.parseLong(cooldown.getLine(0)) * 1000)) + if(!sign.getBlock().isBlockPowered()) + { + _powerdedSigns.remove(sign); + } + + if(_powerdedSigns.contains(sign)) continue; _functionSigns.put(sign, System.currentTimeMillis()); - useSign(sign.getLines()); + useSign(sign, ((Sign) sign.getBlock().getState()).getLines()); + + if(sign.getBlock().isBlockPowered()) + { + if(!_powerdedSigns.contains(sign)) + { + _powerdedSigns.add(sign); + } + } } } - public void useSign(String[] args) + public void useSign(final Sign sign, String[] args) { String command = args[0]; String playerName = args[1]; - command.replace("[", "").replaceAll("]", ""); - if(command.contentEquals("BC")) + HashMap> varMap = new HashMap<>(); + + int i = 0; + for(String varArgs : args) + { + ArrayList players = new ArrayList<>(); + if(Bukkit.getPlayer(playerName) != null) + players.add(Bukkit.getPlayer(playerName)); + + if(playerName.contentEquals("@p")) + { + for(Player player : GetPlayers(true)) + { + boolean found = true; + for(Player otherPlayer : GetPlayers(true)) + { + if(UtilMath.offset(sign.getLocation(), player.getLocation()) >= UtilMath.offset(sign.getLocation(), otherPlayer.getLocation())) + { + found = false; + break; + } + } + if(found = true) + { + players.add(player); + break; + } + } + } + if(playerName.contains("@a")) + { + int radius = 0; + if(playerName.contains("r=")) + { + try + { + radius = Integer.parseInt(playerName.split("=")[1]); + } + catch (Exception e) {} + } + for(Player player : GetPlayers(true)) + { + if(UtilMath.offset(sign.getLocation(), player.getLocation()) <= radius || radius <= 0) + players.add(player); + } + } + + varMap.put(i, players); + i++; + } + + if(command.contentEquals("[BC]")) { String message = args[1]; - for(int i = 2; i <= 3; i++) - message += " " + args[i]; + for(int e = 2; e <= 3; e++) + message += " " + args[e]; String colored = ChatColor.translateAlternateColorCodes('&', message); this.Announce(F.main("Event", colored), true); } + if(command.contentEquals("[TELEPORT]")) + { + for(Player player : varMap.get(1)) + { + if(Bukkit.getPlayer(args[2]) != null) + { + player.teleport(Bukkit.getPlayer(args[2])); + } + else + { + String[] coords = args[2].split(" "); + int x = Integer.parseInt(coords[0]); + int y = Integer.parseInt(coords[1]); + int z = Integer.parseInt(coords[2]); + player.teleport(new Location(sign.getWorld(), x, y, z)); + } + } + } + + if(command.contentEquals("[MESSAGE]")) + { + String message = args[2]; + message += " " + args[3]; + + String colored = ChatColor.translateAlternateColorCodes('&', message); + + for(Player player : varMap.get(1)) + { + UtilPlayer.message(player, F.main("Event", colored)); + } + } + + if(command.contentEquals("[SETBLOCK]")) + { + Material mat = Material.getMaterial(args[1]); + String[] coords = args[2].split(" "); + int x = Integer.parseInt(coords[0]); + int y = Integer.parseInt(coords[1]); + int z = Integer.parseInt(coords[2]); + sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).setType(mat); + } + + if(command.contentEquals("[TESTFOR]")) + { + boolean redstone = false; + Material mat = Material.getMaterial(args[1]); + if(args[2].contains("r=")) + { + int radius = 0; + try + { + radius = Integer.parseInt(args[2].split("=")[1]); + if(radius >= 30) + radius = 30; + + for(int x = -radius + sign.getLocation().getBlockX(); x < radius + sign.getLocation().getBlockX(); x++) + { + for(int y = -radius + sign.getLocation().getBlockY(); y < radius + sign.getLocation().getBlockY(); y++) + { + for(int z = -radius + sign.getLocation().getBlockZ(); z < radius + sign.getLocation().getBlockZ(); z++) + { + if(sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).getType() == mat) + { + redstone = true; + } + } + } + } + } + catch (Exception e) {} + } + else + { + String[] coords = args[2].split(" "); + int x = Integer.parseInt(coords[0]); + int y = Integer.parseInt(coords[1]); + int z = Integer.parseInt(coords[2]); + if(sign.getWorld().getBlockAt(new Location(sign.getWorld(), x, y, z)).getType() == mat) + { + redstone = true; + } + } + if(redstone) + { + for(final BlockFace face : BlockFace.values()) + { + if(face != BlockFace.UP + && face != BlockFace.NORTH_WEST + && face != BlockFace.NORTH_EAST + && face != BlockFace.SOUTH_EAST + && face != BlockFace.SOUTH_WEST) + { + continue; + } + + if(sign.getBlock().getRelative(face).getType() != Material.AIR) + continue; + + if(sign.getBlock().getRelative(face).isBlockPowered()) + continue; + + sign.getBlock().getRelative(face).setType(Material.REDSTONE_BLOCK); + + Manager.runSyncLater(new Runnable() + { - Player player = Bukkit.getPlayer(playerName); - if(player == null) + @Override + public void run() + { + sign.getBlock().getRelative(face).setType(Material.AIR); + } + + }, 3L); + } + } + } + + if(varMap.get(1).isEmpty()) return; String[] vars = new String[args.length - 1]; @@ -585,9 +788,84 @@ public class EventGame extends Game vars[1] = args[2]; vars[2] = args[3]; - if(command.contentEquals("MOB")) + String tempArgs = ""; + for(String str : vars) { - Manager.GetEventModule().commandMob(player, vars); + for(String string : str.split(" ")) + { + tempArgs += string + " "; + } + } + String[] commandArgs = tempArgs.split(" "); + + if(command.contentEquals("[MOB]")) + { + for(Player player : varMap.get(1)) + Manager.GetEventModule().commandMob(player, commandArgs); + } + if(command.contentEquals("[SCORE]")) + { + for(Player player : varMap.get(1)) + Manager.GetEventModule().commandScoreboard(player, vars); + } + if(command.contentEquals("[GIVE]")) + { + try + { + for(Player player : varMap.get(1)) + { + String[] newArgs = new String[commandArgs.length-1]; + + for (int e=0 ; e signIter = _functionSigns.keySet().iterator(); + while(signIter.hasNext()) + { + Sign sign = signIter.next(); + if(sign.getLocation().getBlockX() == event.getBlock().getLocation().getBlockX() + && sign.getLocation().getBlockY() == event.getBlock().getLocation().getBlockY() + && sign.getLocation().getBlockZ() == event.getBlock().getLocation().getBlockZ()) + { + signIter.remove(); + } + } } } 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 90d0c4f29..8880db1e7 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 @@ -257,7 +257,7 @@ public class EventModule extends MiniPlugin } else if (args[0].equalsIgnoreCase("effect")) { - commandEffect(event.getPlayer(), args); + commandEffect(event.getPlayer(), args, null); } else if (args[0].equalsIgnoreCase("kit")) { @@ -987,7 +987,7 @@ public class EventModule extends MiniPlugin lineText += " "; } - ((EventGame) Manager.GetGame()).getSideText()[line] = lineText; + ((EventGame) Manager.GetGame()).getSideText()[line] = ChatColor.translateAlternateColorCodes('&', lineText); UtilPlayer.message(player, F.main("Scoreboard", "Set Line " + F.elem(line+"") + " to " + F.elem(lineText) + ".")); @@ -1533,7 +1533,7 @@ public class EventModule extends MiniPlugin commandHelp(caller); } - public void commandEffect(Player caller, String[] args) + public void commandEffect(Player caller, String[] args, ArrayList players) { //Clear if (args.length >= 3 && args[2].equalsIgnoreCase("clear")) @@ -1551,9 +1551,19 @@ public class EventModule extends MiniPlugin } else { - targets = UtilPlayer.matchOnline(caller, args[1], true); - if (targets.isEmpty()) - return; + if(players == null) + { + targets = UtilPlayer.matchOnline(caller, args[1], true); + if (targets.isEmpty()) + return; + } + else + { + targets = new LinkedList<>(); + for(Player player : players) + targets.add(player); + + } } for (Player player : targets) @@ -1647,10 +1657,20 @@ public class EventModule extends MiniPlugin _potionEffectsMult.put(type, mult); } else - { - targets = UtilPlayer.matchOnline(caller, args[1], true); - if (targets.isEmpty()) - return; + { + if(players == null) + { + targets = UtilPlayer.matchOnline(caller, args[1], true); + if (targets.isEmpty()) + return; + } + else + { + targets = new LinkedList<>(); + for(Player player : players) + targets.add(player); + + } } //Apply From 4240026024b8dbe1e4e0ca15df1f6b74403aa398 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 6 Sep 2015 18:55:00 +0200 Subject: [PATCH 016/106] Adding Areas and a few more commands like /e kick and /e tempgadget to the event game. --- .../arcade/game/games/event/EventGame.java | 178 ++++++++++++++++++ .../arcade/game/games/event/EventModule.java | 120 +++++++++++- 2 files changed, 293 insertions(+), 5 deletions(-) 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 6f74a2da3..2a979c53a 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 @@ -31,11 +31,13 @@ import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.visibility.VisibilityManager; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.event.kits.KitPlayer; +import nautilus.game.arcade.game.games.sheep.kits.KitBrute; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.GameHostManager; @@ -57,8 +59,10 @@ import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.inventory.ItemStack; @@ -82,6 +86,8 @@ public class EventGame extends Game private HashMap _functionSigns; private ArrayList _powerdedSigns; + + private HashMap _customAreas; public EventGame(ArcadeManager manager) { @@ -131,6 +137,8 @@ public class EventGame extends Game _powerdedSigns = new ArrayList<>(); this.CreatureAllow = true; + + _customAreas = new HashMap<>(); } @EventHandler @@ -155,6 +163,35 @@ public class EventGame extends Game } } + @EventHandler + public void registerAreas(GameStateChangeEvent event) + { + if(event.GetState() != GameState.Live) + return; + + for(String name : WorldData.GetAllCustomLocs().keySet()) + { + try + { + EventArea area = new EventArea(Integer.parseInt(name.split(" ")[0])); + Location tempA = WorldData.GetAllCustomLocs().get(name).get(0); + Location tempB = WorldData.GetAllCustomLocs().get(name).get(1); + area.CornerA = new Location(tempA.getWorld(), Math.min(tempA.getX(), tempB.getX()), Math.min(tempA.getY(), tempB.getY()), Math.min(tempA.getZ(), tempB.getZ())); + area.CornerB = new Location(tempA.getWorld(), Math.max(tempA.getX(), tempB.getX()), Math.max(tempA.getY(), tempB.getY()), Math.max(tempA.getZ(), tempB.getZ())); + area.DamageAll = name.contains("ALL"); + area.DamagePvP = name.contains("PVP"); + area.DamagePvE = name.contains("PVE"); + area.DamageEvP = name.contains("EVP"); + area.Usable = true; + _customAreas.put(Integer.parseInt(name.split(" ")[0]), area); + } + catch (Exception e) + { + System.out.println("Error while parsing area locs"); + } + } + } + @EventHandler public void signPlace(SignChangeEvent event) { @@ -869,4 +906,145 @@ public class EventGame extends Game } } + @EventHandler(ignoreCancelled=true) + public void areaDamage(CustomDamageEvent event) + { + for(EventArea area : _customAreas.values()) + { + if(area.CornerA == null || area.CornerB == null) + continue; + + if(area.Usable == false) + continue; + + if(event.GetDamageeEntity().getLocation().getX() < area.CornerA.getX() || event.GetDamageeEntity().getLocation().getX() > area.CornerB.getX()) + continue; + + if(event.GetDamageeEntity().getLocation().getY() < area.CornerA.getY() || event.GetDamageeEntity().getLocation().getY() > area.CornerB.getY()) + continue; + + if(event.GetDamageeEntity().getLocation().getZ() < area.CornerA.getZ() || event.GetDamageeEntity().getLocation().getZ() > area.CornerB.getZ()) + continue; + + if(!area.DamageAll) + { + event.SetCancelled("Event Area"); + } + if(event.GetCause() == DamageCause.ENTITY_ATTACK && event.GetDamagerPlayer(true) == null) + { + if(!area.DamageEvP) + { + event.SetCancelled("Event Area"); + } + } + if(!(event.GetDamageeEntity() instanceof Player)) + { + if(!area.DamagePvE) + { + event.SetCancelled("Event Area"); + } + } + if((event.GetDamageeEntity() instanceof Player) && (event.GetDamagerEntity(true) instanceof Player)) + { + if(!area.DamagePvP) + { + event.SetCancelled("Event Area"); + } + } + } + } + + public void editArea(Player player, String[] args) + { + try + { + if(_customAreas.containsKey(Integer.parseInt(args[1]))) + { + if(args[2].equalsIgnoreCase("Del")) + { + _customAreas.remove(Integer.parseInt(args[1])); + UtilPlayer.message(player, F.main("Event", "Region deleted")); + } + if(args[2].equalsIgnoreCase("ALL")) + { + _customAreas.get(Integer.parseInt(args[1])).DamageAll = !_customAreas.get(Integer.parseInt(args[1])).DamageAll; + UtilPlayer.message(player, F.main("Event", "Damage all for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamageAll))); + } + if(args[2].equalsIgnoreCase("PVP")) + { + _customAreas.get(Integer.parseInt(args[1])).DamagePvP = !_customAreas.get(Integer.parseInt(args[1])).DamagePvP; + UtilPlayer.message(player, F.main("Event", "Damage PvP for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamagePvP))); + } + if(args[2].equalsIgnoreCase("PVE")) + { + _customAreas.get(Integer.parseInt(args[1])).DamagePvE = !_customAreas.get(Integer.parseInt(args[1])).DamagePvE; + UtilPlayer.message(player, F.main("Event", "Damage PvE for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamagePvE))); + } + if(args[2].equalsIgnoreCase("EVP")) + { + _customAreas.get(Integer.parseInt(args[1])).DamageEvP = !_customAreas.get(Integer.parseInt(args[1])).DamageEvP; + UtilPlayer.message(player, F.main("Event", "Damage EvP for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamageEvP))); + } + } + else + { + UtilPlayer.message(player, F.main("Event", "No Area Found")); + } + if(args[2].equalsIgnoreCase("Add")) + { + if(!_customAreas.containsKey(Integer.parseInt(args[1]))) + _customAreas.put(Integer.parseInt(args[1]), new EventArea(Integer.parseInt(args[1]))); + + EventArea area = _customAreas.get(Integer.parseInt(args[1])); + + if(args[3].equalsIgnoreCase("A")) + { + area.CornerA = player.getLocation(); + UtilPlayer.message(player, F.main("Event", "Corner A set!")); + } + if(args[3].equalsIgnoreCase("B")) + { + area.CornerB = player.getLocation(); + UtilPlayer.message(player, F.main("Event", "Corner B set!")); + } + if(area.CornerA != null && area.CornerB != null) + { + Location tempA = area.CornerA.clone(); + Location tempB = area.CornerB.clone(); + area.CornerA = new Location(tempA.getWorld(), Math.min(tempA.getX(), tempB.getX()), Math.min(tempA.getY(), tempB.getY()), Math.min(tempA.getZ(), tempB.getZ())); + area.CornerB = new Location(tempA.getWorld(), Math.max(tempA.getX(), tempB.getX()), Math.max(tempA.getY(), tempB.getY()), Math.max(tempA.getZ(), tempB.getZ())); + area.Usable = true; + UtilPlayer.message(player, F.main("Event", "Region is Usable")); + } + } + } + catch (Exception e) + { + UtilPlayer.message(player, F.main("Event", "Error while executing command")); + } + } + + public class EventArea + { + + public int ID; + + public Location CornerA; + public Location CornerB; + + public boolean DamageAll; + public boolean DamagePvP; + public boolean DamagePvE; + public boolean DamageEvP; + + public boolean Usable; + + public EventArea(Integer id) + { + ID = id; + Usable = false; + } + + } + } 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 8880db1e7..e7bb773de 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 @@ -26,9 +26,12 @@ import nautilus.game.arcade.ArcadeManager; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Effect; import org.bukkit.GameMode; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.OfflinePlayer; +import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; import org.bukkit.entity.Ageable; @@ -36,16 +39,17 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.entity.Slime; import org.bukkit.entity.Villager; +import org.bukkit.entity.Villager.Profession; import org.bukkit.entity.Wolf; import org.bukkit.entity.Zombie; -import org.bukkit.entity.Skeleton.SkeletonType; -import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; @@ -59,12 +63,17 @@ public class EventModule extends MiniPlugin private NautHashMap _potionEffectsDuration = new NautHashMap<>(); private NautHashMap _potionEffectsMult = new NautHashMap<>(); - private boolean _mobGriefing = true; + private boolean _mobGriefing; + + private ArrayList _stacker; + private boolean _allowStacker; public EventModule(ArcadeManager manager, JavaPlugin plugin) { super("EventModule", plugin); Manager = manager; + _mobGriefing = true; + _stacker = new ArrayList<>(); } @EventHandler @@ -356,14 +365,50 @@ public class EventModule extends MiniPlugin { commandBlockPlaceInCreative(event.getPlayer(), args); } - else if(args[0].equalsIgnoreCase("blockbreakcreative")) + else if(args[0].equalsIgnoreCase("stacker")) { - commandBlockBreakInCreative(event.getPlayer(), args); + commandStacker(event.getPlayer(), args); + } + else if(args[0].equalsIgnoreCase("area")) + { + if(!(Manager.GetGame() instanceof EventGame)) { + UtilPlayer.message(event.getPlayer(), F.main("Settings", "You can only edit areas in the Event game!")); + return; + } + + ((EventGame) Manager.GetGame()).editArea(event.getPlayer(), args); } else if(args[0].equalsIgnoreCase("mobgriefing")) { 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."); + UtilPlayer.message(event.getPlayer(), F.main("Event", "You kicked " + 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).AddUnknownSalesPackagesOwned(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!")); + } } public void listSettings(Player player) @@ -396,6 +441,33 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(Manager.GetGame().BlockBreakCreative))); } + public void commandStacker(Player player, String[] args) + { + if(args.length == 1) + { + _allowStacker = !_allowStacker; + UtilPlayer.message(player, F.main("Settings", "Stacker all: " + F.tf(_allowStacker))); + } + else + { + for(Player target : UtilPlayer.matchOnline(player, args[1], true)) + { + if(_stacker.contains(target)) + { + _stacker.remove(target); + UtilPlayer.message(target, F.main("Settings", "Stacker: " + F.tf(false))); + UtilPlayer.message(player, F.main("Settings", "Stacker " + target.getName() + ": " + F.tf(false))); + } + else + { + _stacker.add(target); + UtilPlayer.message(target, F.main("Settings", "Stacker: " + F.tf(true))); + UtilPlayer.message(player, F.main("Settings", "Stacker " + target.getName() + ": " + F.tf(true))); + } + } + } + } + public void commandBlockPlaceInCreative(Player player, String[] args) { Manager.GetGame().BlockPlaceCreative = !Manager.GetGame().BlockPlaceCreative; @@ -1706,4 +1778,42 @@ public class EventModule extends MiniPlugin } } + @EventHandler + public void StackPlayer(PlayerInteractEntityEvent event) + { + if (!Manager.GetGame().IsLive()) + return; + + if (!(event.getRightClicked() instanceof Player)) + return; + + if (event.getRightClicked().getVehicle() != null) + return; + + Player player = event.getPlayer(); + Player other = (Player)event.getRightClicked(); + + if(!_allowStacker && !_stacker.contains(player)) + return; + + if (Manager.isSpectator(event.getPlayer())) + return; + + if (!Manager.GetGame().IsAlive(event.getPlayer())) + return; + + //Effect + event.getRightClicked().getWorld().playEffect(event.getRightClicked().getLocation(), Effect.STEP_SOUND, 35); + + //Stack + player.setPassenger(other); + + //Audio + player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f); + + //Inform + UtilPlayer.message(other, F.main("Event", F.elem(Manager.GetGame().GetTeam(player).GetColor() + player.getName()) + " picked you up.")); + UtilPlayer.message(player, F.main("Event", "You picked up " + F.elem(Manager.GetGame().GetTeam(other).GetColor() + other.getName()) + ".")); + } + } From b56813deefbfef323b39328c8dd53c259409fdaa Mon Sep 17 00:00:00 2001 From: Sarah Date: Sat, 12 Sep 2015 04:33:10 +0200 Subject: [PATCH 017/106] Improving /e commands (/e kick, /e area, etc) --- .../arcade/game/games/event/EventGame.java | 50 +++++-- .../arcade/game/games/event/EventModule.java | 132 ++++++++++++++++-- 2 files changed, 165 insertions(+), 17 deletions(-) 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 2a979c53a..a96234726 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 @@ -13,6 +13,7 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -62,6 +63,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; @@ -851,13 +853,7 @@ public class EventGame extends Game { for(Player player : varMap.get(1)) { - String[] newArgs = new String[commandArgs.length-1]; - - for (int e=0 ; e area.CornerB.getX()) continue; @@ -929,12 +936,14 @@ public class EventGame extends Game if(!area.DamageAll) { event.SetCancelled("Event Area"); + continue; } if(event.GetCause() == DamageCause.ENTITY_ATTACK && event.GetDamagerPlayer(true) == null) { if(!area.DamageEvP) { event.SetCancelled("Event Area"); + continue; } } if(!(event.GetDamageeEntity() instanceof Player)) @@ -942,6 +951,7 @@ public class EventGame extends Game if(!area.DamagePvE) { event.SetCancelled("Event Area"); + continue; } } if((event.GetDamageeEntity() instanceof Player) && (event.GetDamagerEntity(true) instanceof Player)) @@ -949,8 +959,17 @@ public class EventGame extends Game if(!area.DamagePvP) { event.SetCancelled("Event Area"); + continue; } } + if(!Manager.GetGame().DamagePvP) + { + Manager.GetGame().Damage = true; + Manager.GetGame().DamagePvP = true; + Bukkit.getPluginManager().callEvent(event); + Manager.GetGame().DamagePvP = false; + Manager.GetGame().Damage = false; + } } } @@ -1024,6 +1043,21 @@ public class EventGame extends Game } } + @EventHandler + public void preventChestDrop(PlayerDropItemEvent event) + { + if(event.getItemDrop() == null) + return; + + if(event.getItemDrop().getItemStack().getType() != Material.CHEST) + return; + + if(!event.getItemDrop().getItemStack().hasItemMeta()) + return; + + event.setCancelled(true); + } + public class EventArea { 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 e7bb773de..82315cc58 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 @@ -12,16 +12,22 @@ 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.UtilSystem; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.creature.event.CreatureKillEntitiesEvent; +import mineplex.core.event.StackerEvent; +import mineplex.core.gadget.gadgets.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 mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import org.bukkit.Bukkit; @@ -50,6 +56,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; @@ -65,7 +72,10 @@ public class EventModule extends MiniPlugin private boolean _mobGriefing; + private HashSet _tempStackShift = new HashSet(); + private ArrayList _stacker; + private ArrayList _damage; private boolean _allowStacker; public EventModule(ArcadeManager manager, JavaPlugin plugin) @@ -74,6 +84,7 @@ public class EventModule extends MiniPlugin Manager = manager; _mobGriefing = true; _stacker = new ArrayList<>(); + _damage = new ArrayList<>(); } @EventHandler @@ -369,6 +380,29 @@ public class EventModule extends MiniPlugin { commandStacker(event.getPlayer(), args); } + else if(args[0].equalsIgnoreCase("playerdamage")) + { + if(args[1] == null) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "Insufficient arguments!")); + return; + } + + if(Bukkit.getPlayer(args[1]) == null) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "This Player is not online!")); + return; + } + + if(_damage.contains(Bukkit.getPlayer(args[1]))) + _damage.remove(Bukkit.getPlayer(args[1])); + 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)) { @@ -389,8 +423,9 @@ public class EventModule extends MiniPlugin 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."); - UtilPlayer.message(event.getPlayer(), F.main("Event", "You kicked " + C.cYellow + Bukkit.getPlayer(args[1]).getName())); + //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")) { @@ -1562,6 +1597,16 @@ public class EventModule extends MiniPlugin UtilPlayer.message(caller, F.main("Creature", "Killed " + target + ". " + count + " Removed.")); } + public void commandBC(Player caller, String[] args) + { + String message = args[1]; + for(int e = 2; e <= 3; e++) + message += " " + args[e]; + + String colored = ChatColor.translateAlternateColorCodes('&', message); + Manager.GetGame().Announce(F.main("Event", colored), true); + } + public void commandKit(Player caller, String[] args) { @@ -1773,25 +1818,25 @@ public class EventModule extends MiniPlugin { for(PotionEffectType effect : _potionEffectsDuration.keySet()) { + if(_potionEffectsDuration.get(effect) < 0) + continue; + player.addPotionEffect(new PotionEffect(effect, (int) (((_potionEffectsDuration.get(effect) - System.currentTimeMillis()) / 1000) * 20), _potionEffectsMult.get(effect))); } } } @EventHandler - public void StackPlayer(PlayerInteractEntityEvent event) + public void StackEntity(PlayerInteractEntityEvent event) { if (!Manager.GetGame().IsLive()) return; - if (!(event.getRightClicked() instanceof Player)) - return; - if (event.getRightClicked().getVehicle() != null) return; Player player = event.getPlayer(); - Player other = (Player)event.getRightClicked(); + Entity other = event.getRightClicked(); if(!_allowStacker && !_stacker.contains(player)) return; @@ -1802,6 +1847,17 @@ public class EventModule extends MiniPlugin if (!Manager.GetGame().IsAlive(event.getPlayer())) return; + if (Manager.getCosmeticManager().getGadgetManager().getActive(player, GadgetType.Morph) instanceof MorphBlock) + { + UtilPlayer.message(player, F.main("Stacker", "You cannot stack while using the Block Morph.")); + return; + } + + StackerEvent stackerEvent = new StackerEvent(player); + Bukkit.getServer().getPluginManager().callEvent(stackerEvent); + if (stackerEvent.isCancelled()) + return; + //Effect event.getRightClicked().getWorld().playEffect(event.getRightClicked().getLocation(), Effect.STEP_SOUND, 35); @@ -1812,8 +1868,66 @@ public class EventModule extends MiniPlugin player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f); //Inform - UtilPlayer.message(other, F.main("Event", F.elem(Manager.GetGame().GetTeam(player).GetColor() + player.getName()) + " picked you up.")); - UtilPlayer.message(player, F.main("Event", "You picked up " + F.elem(Manager.GetGame().GetTeam(other).GetColor() + other.getName()) + ".")); + if ((event.getRightClicked() instanceof Player)) + { + UtilPlayer.message(other, F.main("Event", F.elem(Manager.GetGame().GetTeam(player).GetColor() + player.getName()) + " picked you up.")); + UtilPlayer.message(player, F.main("Event", "You picked up " + F.elem(Manager.GetGame().GetTeam(((Player) other)).GetColor() + ((Player) other).getName()) + ".")); + } } + + @EventHandler + public void ThrowEntity(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.L)) + return; + Player thrower = event.getPlayer(); + + if (thrower.getVehicle() != null) + return; + + Entity throwee = thrower.getPassenger(); + if (throwee == null) + return; + + StackerEvent stackerEvent = new StackerEvent(thrower); + Bukkit.getServer().getPluginManager().callEvent(stackerEvent); + if (stackerEvent.isCancelled()) + return; + + thrower.eject(); + + Entity throweeStack = throwee.getPassenger(); + if (throweeStack != null) + { + throwee.eject(); + throweeStack.leaveVehicle(); + + final Entity fThrower = thrower; + final Entity fThroweeStack = throweeStack; + + _tempStackShift.add(throweeStack); + + getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() + { + public void run() + { + fThrower.setPassenger(fThroweeStack); + _tempStackShift.remove(fThroweeStack); + } + }, 2); + } + } + + @EventHandler(ignoreCancelled=true) + public void playerDamage(CustomDamageEvent event) + { + + } + + public ArrayList getDamagePlayers() + { + return _damage; + } + } From fcec6253cdf635c48cbb81edf5b7c2b6efc7fcb2 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sat, 12 Sep 2015 23:56:38 +0200 Subject: [PATCH 018/106] fixing @p on signs, adding potioneffects and gadgets to areas. --- .../arcade/game/games/event/EventGame.java | 164 ++++++++++++++++-- .../arcade/game/games/event/EventModule.java | 10 +- 2 files changed, 152 insertions(+), 22 deletions(-) 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 a96234726..18c492865 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 @@ -25,7 +25,10 @@ import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.disguise.disguises.DisguiseEnderman; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.gadget.event.GadgetActivateEvent; +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.mount.event.MountActivateEvent; import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.SalesPackageBase; @@ -68,6 +71,8 @@ import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; public class EventGame extends Game { @@ -130,6 +135,7 @@ public class EventGame extends Game this.InventoryClick = true; this.InventoryOpenBlock = true; this.InventoryOpenChest = true; + //Dont timeout this.GameTimeout = -1; @@ -647,23 +653,27 @@ public class EventGame extends Game for(String varArgs : args) { ArrayList players = new ArrayList<>(); - if(Bukkit.getPlayer(playerName) != null) - players.add(Bukkit.getPlayer(playerName)); + if(Bukkit.getPlayer(varArgs) != null) + players.add(Bukkit.getPlayer(varArgs)); - if(playerName.contentEquals("@p")) + if(varArgs.contentEquals("@p")) { for(Player player : GetPlayers(true)) { - boolean found = true; + boolean found; + found = true; for(Player otherPlayer : GetPlayers(true)) { + if(player == otherPlayer) + continue; + if(UtilMath.offset(sign.getLocation(), player.getLocation()) >= UtilMath.offset(sign.getLocation(), otherPlayer.getLocation())) { found = false; break; } } - if(found = true) + if(found) { players.add(player); break; @@ -736,7 +746,7 @@ public class EventGame extends Game if(command.contentEquals("[SETBLOCK]")) { - Material mat = Material.getMaterial(args[1]); + Material mat = Material.getMaterial(Integer.parseInt(args[1])); String[] coords = args[2].split(" "); int x = Integer.parseInt(coords[0]); int y = Integer.parseInt(coords[1]); @@ -747,7 +757,7 @@ public class EventGame extends Game if(command.contentEquals("[TESTFOR]")) { boolean redstone = false; - Material mat = Material.getMaterial(args[1]); + Material mat = Material.getMaterial(Integer.parseInt(args[1])); if(args[2].contains("r=")) { int radius = 0; @@ -853,7 +863,7 @@ public class EventGame extends Game { for(Player player : varMap.get(1)) { - player.getInventory().addItem(new ItemStack(Material.getMaterial(args[2]), Integer.parseInt(args[3]))); + player.getInventory().addItem(new ItemStack(Material.getMaterial(Integer.parseInt(args[2])), Integer.parseInt(args[3]))); } } catch (Exception e) @@ -902,6 +912,68 @@ public class EventGame extends Game } } + public boolean isInArea(EventArea area, Entity entity) + { + if(entity.getLocation().getX() < area.CornerA.getX() || entity.getLocation().getX() > area.CornerB.getX()) + return false; + + if(entity.getLocation().getY() < area.CornerA.getY() || entity.getLocation().getY() > area.CornerB.getY()) + return false; + + if(entity.getLocation().getZ() < area.CornerA.getZ() || entity.getLocation().getZ() > area.CornerB.getZ()) + return false; + + return true; + } + + @EventHandler + public void activateGadget(GadgetActivateEvent event) + { + for(EventArea area : _customAreas.values()) + { + if(area.CornerA == null || area.CornerB == null) + continue; + + if(area.Usable == false) + continue; + + if(!isInArea(area, event.getPlayer())) + continue; + + if(!area.GadgetsEnabled.contains(event.getGadget())) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void areaPotionEffect(UpdateEvent event) + { + if(event.getType() != UpdateType.SEC) + return; + + for(EventArea area : _customAreas.values()) + { + for(Player player : GetPlayers(true)) + { + if(area.CornerA == null || area.CornerB == null) + continue; + + if(area.Usable == false) + continue; + + if(!isInArea(area, player)) + continue; + + for(PotionEffectType type : area.PotionEffects.keySet()) + { + player.addPotionEffect(new PotionEffect(type, 30, area.PotionEffects.get(type)), true); + } + } + } + } + @EventHandler(ignoreCancelled=true) public void areaDamage(CustomDamageEvent event) { @@ -917,20 +989,16 @@ public class EventGame extends Game { if(!Manager.GetGame().DamagePvP) { + Manager.GetGame().Damage = true; Manager.GetGame().DamagePvP = true; Bukkit.getPluginManager().callEvent(event); Manager.GetGame().DamagePvP = false; + Manager.GetGame().Damage = false; } return; } - if(event.GetDamageeEntity().getLocation().getX() < area.CornerA.getX() || event.GetDamageeEntity().getLocation().getX() > area.CornerB.getX()) - continue; - - if(event.GetDamageeEntity().getLocation().getY() < area.CornerA.getY() || event.GetDamageeEntity().getLocation().getY() > area.CornerB.getY()) - continue; - - if(event.GetDamageeEntity().getLocation().getZ() < area.CornerA.getZ() || event.GetDamageeEntity().getLocation().getZ() > area.CornerB.getZ()) + if(!isInArea(area, event.GetDamageeEntity())) continue; if(!area.DamageAll) @@ -1004,6 +1072,67 @@ public class EventGame extends Game _customAreas.get(Integer.parseInt(args[1])).DamageEvP = !_customAreas.get(Integer.parseInt(args[1])).DamageEvP; UtilPlayer.message(player, F.main("Event", "Damage EvP for Region " + args[1] + ": " + F.tf(_customAreas.get(Integer.parseInt(args[1])).DamageEvP))); } + if(args[2].equalsIgnoreCase("Effect")) + { + PotionEffectType type = PotionEffectType.getByName(args[3]); + if (type == null) + { + UtilPlayer.message(player, F.main("Effect", "Invalid Effect Type: " + args[2])); + UtilPlayer.message(player, F.value("Valid Types", "http://minecraft.gamepedia.com/Status_effect")); + return; + } + int strenght = 0; + try + { + strenght = Integer.parseInt(args[4]); + } + catch (Exception e) {} + _customAreas.get(Integer.parseInt(args[1])).PotionEffects.put(type, strenght); + UtilPlayer.message(player, F.main("Event", "Potion Effect added for Region " + args[1])); + } + if(args[2].equalsIgnoreCase("Gadget")) + { + //Gadgets + for (GadgetType type : GadgetType.values()) + { + for (Gadget gadget : Manager.getCosmeticManager().getGadgetManager().getGadgets(type)) + { + if (gadget.GetName().replaceAll(" ", "").equalsIgnoreCase(args[3])) + { + if (_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.remove(gadget)) + { + Manager.GetGame().Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget for area " + args[1], F.ed(false)))); + } + else + { + Manager.GetGame().Announce(F.main("Inventory", F.value(gadget.GetName() + " Gadget for area " + args[1], F.ed(true)))); + _customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.add(gadget); + } + + return; + } + } + } + + //Mounts + for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts()) + { + if (mount.GetName().replaceAll(" ", "").equalsIgnoreCase(args[3])) + { + if (_customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.remove(mount)) + { + Manager.GetGame().Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget for area " + args[1], F.ed(false)))); + } + else + { + Manager.GetGame().Announce(F.main("Inventory", F.value(mount.GetName() + " Gadget for area " + args[1], F.ed(true)))); + _customAreas.get(Integer.parseInt(args[1])).GadgetsEnabled.add(mount); + } + + return; + } + } + } } else { @@ -1073,10 +1202,15 @@ public class EventGame extends Game public boolean Usable; + public HashMap PotionEffects; + public HashSet GadgetsEnabled; + public EventArea(Integer id) { ID = id; Usable = false; + PotionEffects = new HashMap<>(); + GadgetsEnabled = new HashSet(); } } 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 82315cc58..9e980a32f 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 @@ -29,6 +29,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.events.PlayerDeathOutEvent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -57,6 +58,7 @@ import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; @@ -1600,7 +1602,7 @@ public class EventModule extends MiniPlugin public void commandBC(Player caller, String[] args) { String message = args[1]; - for(int e = 2; e <= 3; e++) + for(int e = 2; e < args.length; e++) message += " " + args[e]; String colored = ChatColor.translateAlternateColorCodes('&', message); @@ -1919,12 +1921,6 @@ public class EventModule extends MiniPlugin } } - @EventHandler(ignoreCancelled=true) - public void playerDamage(CustomDamageEvent event) - { - - } - public ArrayList getDamagePlayers() { return _damage; From 112f94a8421c61b2c73375975dab8ea971bed0ef Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 13 Sep 2015 00:00:47 +0200 Subject: [PATCH 019/106] forgot to add command to remove potion effects. --- .../src/nautilus/game/arcade/game/games/event/EventGame.java | 5 +++++ 1 file changed, 5 insertions(+) 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 18c492865..555511b96 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 @@ -1075,6 +1075,11 @@ public class EventGame extends Game if(args[2].equalsIgnoreCase("Effect")) { PotionEffectType type = PotionEffectType.getByName(args[3]); + if(_customAreas.get(Integer.parseInt(args[1])).PotionEffects.containsKey(type)) + { + _customAreas.get(Integer.parseInt(args[1])).PotionEffects.remove(type); + UtilPlayer.message(player, F.main("Event", "Removed potion effect from area")); + } if (type == null) { UtilPlayer.message(player, F.main("Effect", "Invalid Effect Type: " + args[2])); From 53d5c2fd0e9e5ae172d10e182cf33442a64cbb7e Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 13 Sep 2015 00:30:55 +0200 Subject: [PATCH 020/106] adding area info command. --- .../arcade/game/games/event/EventGame.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) 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 555511b96..d48f616d4 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 @@ -74,6 +74,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import com.sun.xml.internal.ws.resources.UtilMessages; + public class EventGame extends Game { private GameHostManager _mps; @@ -1041,8 +1043,34 @@ public class EventGame extends Game } } + public void listAreaSettings(Player player) + { + for(EventArea area : _customAreas.values()) + { + UtilPlayer.message(player, F.main("Event", "============================")); + UtilPlayer.message(player, F.main("Event", "Settings for area " + area.ID)); + UtilPlayer.message(player, F.oo("Damage All", area.DamageAll) + ", " + + F.oo("Damage PvP", area.DamagePvP) + ", " + + F.oo("Damage PvE", area.DamagePvE) + + ", " + F.oo("Damage EvP", area.DamageEvP)); + + UtilPlayer.message(player, F.main("Event", "Potion Effects for area " + area.ID)); + for(PotionEffectType type : area.PotionEffects.keySet()) + UtilPlayer.message(player, F.oo(type.getName(), true) + " level: " + area.PotionEffects.get(type)); + + for(SalesPackageBase gadget : area.GadgetsEnabled) + UtilPlayer.message(player, F.oo(gadget.GetName(), true)); + } + } + public void editArea(Player player, String[] args) { + + if(args[1].equalsIgnoreCase("Info")) + { + listAreaSettings(player); + return; + } try { if(_customAreas.containsKey(Integer.parseInt(args[1]))) From a46cb2c2749d634026e9134a7476466d4186f897 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 13 Sep 2015 00:35:22 +0200 Subject: [PATCH 021/106] last fix in the listAreaInfo method. --- .../src/nautilus/game/arcade/game/games/event/EventGame.java | 1 + 1 file changed, 1 insertion(+) 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 d48f616d4..0957549dd 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 @@ -1058,6 +1058,7 @@ public class EventGame extends Game for(PotionEffectType type : area.PotionEffects.keySet()) UtilPlayer.message(player, F.oo(type.getName(), true) + " level: " + area.PotionEffects.get(type)); + UtilPlayer.message(player, F.main("Event", "Gadgets for area " + area.ID)); for(SalesPackageBase gadget : area.GadgetsEnabled) UtilPlayer.message(player, F.oo(gadget.GetName(), true)); } From 7ca6f581082eea9e1c50bb2bd6ef609cf49246b0 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 13 Sep 2015 10:25:44 +0200 Subject: [PATCH 022/106] Adding Gem signs. --- .../arcade/game/games/event/EventGame.java | 48 +++++++++++++++++++ .../arcade/game/games/event/EventModule.java | 6 +++ 2 files changed, 54 insertions(+) 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 0957549dd..20caa6877 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 @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; @@ -58,6 +59,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.SignChangeEvent; @@ -68,6 +70,7 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.inventory.ItemStack; @@ -1221,6 +1224,51 @@ public class EventGame extends Game event.setCancelled(true); } + @EventHandler + public void gemSign(final PlayerInteractEvent event) + { + if(event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if(!(event.getClickedBlock() instanceof Sign)) + return; + + Sign sign = (Sign) event.getClickedBlock().getState(); + if(!sign.getLine(0).contentEquals("[GEM]")) + return; + + final Material mat = Material.getMaterial(Integer.parseInt(sign.getLine(1))); + Integer price = Integer.parseInt(sign.getLine(2)); + if(price > 500) + price = 500; + + if(price <= 0) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You got an item for free.")); + event.getPlayer().getInventory().addItem(new ItemStack(mat)); + return; + } + + if(Manager.GetDonation().Get(event.getPlayer()).GetGems() < price) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You dont have enough Gems.")); + return; + } + + final int gems = price; + Manager.GetDonation().RewardGems(new Callback() + { + public void run(Boolean completed) + { + if (completed) + { + UtilPlayer.message(event.getPlayer(), F.main("Event", "You bought an item for " + gems + " Gems.")); + event.getPlayer().getInventory().addItem(new ItemStack(mat)); + } + } + }, "Gem Sign", event.getPlayer().getName(), event.getPlayer().getUniqueId(), -price); + } + public class EventArea { 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 9e980a32f..9dc6de524 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 @@ -159,6 +159,12 @@ public class EventModule extends MiniPlugin UtilPlayer.message(player, F.value("/e give [e:#,e:#...]", "Give Item")); 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")); UtilPlayer.message(player, F.value("/e scoreboard [Text]", "Sets Scoreboard Text")); From 362d99a819f053f9907320b910133b14dd42ea20 Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 15 Sep 2015 07:10:39 +0200 Subject: [PATCH 023/106] Fixing up Gem signs, Effects etc. --- .../game/arcade/game/games/event/EventGame.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 20caa6877..31e1a164a 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 @@ -883,13 +883,12 @@ public class EventGame extends Game } if(command.contentEquals("[EFFECT]")) { - try + //Manager.GetEventModule().commandEffect(Manager.GetGameHostManager().getHost(), commandArgs, varMap.get(1)); + for(Player player : varMap.get(1)) { - Manager.GetEventModule().commandEffect(Manager.GetGameHostManager().getHost(), commandArgs, varMap.get(1)); - } catch (Exception e) - { - + player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(args[2]), Integer.parseInt(args[3].split(" ")[0]), Integer.parseInt(args[3].split(" ")[1]))); } + } if(command.contentEquals("[KIT]")) { @@ -973,7 +972,7 @@ public class EventGame extends Game for(PotionEffectType type : area.PotionEffects.keySet()) { - player.addPotionEffect(new PotionEffect(type, 30, area.PotionEffects.get(type)), true); + player.addPotionEffect(new PotionEffect(type, 60, area.PotionEffects.get(type)), true); } } } @@ -1111,6 +1110,7 @@ public class EventGame extends Game { _customAreas.get(Integer.parseInt(args[1])).PotionEffects.remove(type); UtilPlayer.message(player, F.main("Event", "Removed potion effect from area")); + return; } if (type == null) { @@ -1230,11 +1230,11 @@ public class EventGame extends Game if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return; - if(!(event.getClickedBlock() instanceof Sign)) + if(event.getClickedBlock().getType() != Material.SIGN && event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST) return; Sign sign = (Sign) event.getClickedBlock().getState(); - if(!sign.getLine(0).contentEquals("[GEM]")) + if(!sign.getLine(0).contentEquals("(GEM)")) return; final Material mat = Material.getMaterial(Integer.parseInt(sign.getLine(1))); From 5e8fc771649fd3e9513f3aa10b15022860b3b679 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 17 Sep 2015 04:34:45 +1200 Subject: [PATCH 024/106] Add pages to spectator and in-progress server menu --- .../mineplex/core/shop/page/ShopPageBase.java | 2 +- .../core/shop/page/ShopPageInventory.java | 123 ++++++++++++++++ .../mineplex/hub/server/ui/ServerNpcPage.java | 114 +++++++++++---- .../arcade/addons/compass/CompassAddon.java | 2 +- .../nautilus/game/arcade/game/GameTeam.java | 11 ++ .../gui/spectatorMenu/page/SpectatorPage.java | 137 +++++++++++++----- 6 files changed, 325 insertions(+), 64 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageInventory.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java index 4f46b6f0f..67f346fd0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java @@ -138,7 +138,7 @@ public abstract class ShopPageBase= 0) { if (event.getInventory().getTitle() == inventory.getInventoryName() && (inventory.getSize() <= event.getSlot() || inventory.getItem(event.getSlot()) != null)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageInventory.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageInventory.java new file mode 100644 index 000000000..0546c0de6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageInventory.java @@ -0,0 +1,123 @@ +package mineplex.core.shop.page; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.item.IButton; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +public abstract class ShopPageInventory> extends + ShopPageBase +{ + private int _page; + + public ShopPageInventory(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, + String name, Player player) + { + super(plugin, shop, clientManager, donationManager, name, player, 54); + } + + public PluginType getPlugin() + { + return (PluginType) super.getPlugin(); + } + + public ShopPageInventory(PluginType plugin, ShopType shop, CoreClientManager clientManager, DonationManager donationManager, + String name, Player player, int slots) + { + super(plugin, shop, clientManager, donationManager, name, player, slots); + } + + protected abstract IButton[] getButtons(); + + protected abstract ItemStack[] getItems(); + + protected abstract void buildItems(); + + @Override + protected final void buildPage() + { + clearPage(); + buildItems(); + + IButton[] buttons = getButtons(); + ItemStack[] items = getItems(); + + int maxLen = Math.max(items.length, buttons.length); + boolean pages = maxLen > getSize(); + + _page = Math.max(0, Math.min(_page, pages ? (int) Math.ceil(maxLen / (double) (getSize() - 9)) - 1 : 0)); + + int start = pages ? _page * (getSize() - 9) : 0; + + for (int slot = 0; slot < (pages ? getSize() - 9 : getSize()); slot++) + { + IButton button = null; + ItemStack item = null; + + if (slot + start < buttons.length) + { + button = buttons[slot + start]; + } + + if (slot + start < items.length) + { + item = items[slot + start]; + } + + if (button != null) + { + super.addButton(slot, item, button); + } + else + { + setItem(slot, item); + } + } + + if (pages) + { + for (int slot = 0; slot < 9; slot++) + { + int realSlot = getSize() - (9 - slot); + + if ((slot == 0 && _page > 0) || (slot == 8 && maxLen > (_page + 1) * (getSize() - 9))) + { + final int nextPage = slot == 0 ? _page - 1 : _page + 1; + + ItemBuilder builder = new ItemBuilder(Material.SIGN); + builder.setTitle(slot == 0 ? "Previous Page" : "Next Page"); + builder.setAmount(nextPage + 1); + + super.addButton(realSlot, builder.build(), new IButton() + { + + @Override + public void onClick(Player player, ClickType clickType) + { + setPage(nextPage); + } + }); + } + else if (slot == 4) + { + ItemStack item = new ItemBuilder(Material.PAPER).setTitle("Page " + (_page + 1)).setAmount(_page + 1).build(); + + setItem(realSlot, item); + } + } + } + } + + public void setPage(int newPage) + { + _page = newPage; + buildPage(); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java index c2c1bf9e4..34b527fa9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -1,6 +1,7 @@ package mineplex.hub.server.ui; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -8,25 +9,26 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; import mineplex.core.account.CoreClientManager; -import mineplex.core.achievement.AchievementCategory; import mineplex.core.common.Rank; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.game.GameDisplay; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.shop.page.ShopPageInventory; import mineplex.hub.server.ServerInfo; import mineplex.hub.server.ServerManager; import mineplex.hub.server.ServerSorter; import mineplex.hub.server.ui.button.JoinServerButton; -public class ServerNpcPage extends ShopPageBase implements IServerPage +public class ServerNpcPage extends ShopPageInventory implements IServerPage { // Shop Item Messages private static final String MESSAGE_BETA_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join Tournament servers!"; @@ -40,6 +42,9 @@ public class ServerNpcPage extends ShopPageBase im private String _serverGroupName; private boolean _onMainPage = true; + private IButton[] _buttons; + private ItemStack[] _items; + public ServerNpcPage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverGroupName) { super(plugin, shop, clientManager, donationManager, name, player, 54); @@ -50,12 +55,14 @@ public class ServerNpcPage extends ShopPageBase im } @Override - protected void buildPage() + protected void buildItems() { + _items = new ItemStack[0]; + _buttons = new IButton[0]; + List serverList = new ArrayList(getPlugin().getServerList(_serverGroupName)); - + int slotsNeeded = 1; - if (serverList.size() > 0) { @@ -81,6 +88,7 @@ public class ServerNpcPage extends ShopPageBase im getPlugin().selectServer(player, _serverGroupName); } }); + buildAvailableServerPage(serverList, slotsNeeded); } else @@ -109,7 +117,7 @@ public class ServerNpcPage extends ShopPageBase im ChatColor.RESET + C.cGreen + "www.mineplex.com/shop" }, seconds, false, false); - addItem(22, item); + addItemStack(22, item); } private ShopItem buildShopItem(ServerInfo serverInfo, int slotsNeeded) @@ -220,7 +228,7 @@ public class ServerNpcPage extends ShopPageBase im ChatColor.RESET + "Visit " + C.cGreen + "www.mineplex.com/shop" + C.cWhite + "!" }, 1, false, false); - addItem(22, item); + addItemStack(22, item); return; } @@ -243,9 +251,6 @@ public class ServerNpcPage extends ShopPageBase im } else { - if (slot >= 54) - continue; - addButton(slot, getPrivateItem(serverInfo), new JoinServerButton(this, serverInfo)); slot++; } @@ -273,7 +278,7 @@ public class ServerNpcPage extends ShopPageBase im greenCount++; if (serverInfo.MOTD.contains("Open in")) - setItem(slot, shopItem); + addItemStack(slot, shopItem); else { addButton(slot, shopItem, new JoinServerButton(this, serverInfo)); @@ -303,11 +308,39 @@ public class ServerNpcPage extends ShopPageBase im { for (int i = greenCount + greenStartSlot; i < greenStartSlot + serversToShow; i++) { - setItem(i, null); + addItemStack(i, null); } } } + public void addItemStack(int slot, ItemStack item) + { + if (_items.length <= slot) + { + if (item == null || item.getType() == Material.AIR) + { + return; + } + + _items = Arrays.copyOf(_items, slot + 1); + _buttons = Arrays.copyOf(_buttons, slot + 1); + } + + _items[slot] = item; + } + + protected void addButton(int slot, ItemStack item, IButton button) + { + if (_items.length <= slot) + { + _items = Arrays.copyOf(_items, slot + 1); + _buttons = Arrays.copyOf(_buttons, slot + 1); + } + + _items[slot] = item; + _buttons[slot] = button; + } + private ShopItem getPrivateItem(ServerInfo serverInfo) { String hostName = serverInfo.Name.substring(0, serverInfo.Name.indexOf('-')); @@ -371,36 +404,47 @@ public class ServerNpcPage extends ShopPageBase im private void buildInProgressServerPage(List serverList, int slotsNeeded) { int slot = 9; + + ArrayList inProgress = new ArrayList(); for (ServerInfo serverInfo : serverList) { - if (isInProgress(serverInfo) && slot < getSize()) + if (isInProgress(serverInfo)) { - ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded); - - addButton(slot, shopItem, new JoinServerButton(this, serverInfo)); - - slot++; + inProgress.add(serverInfo); } } - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + for (ServerInfo serverInfo : inProgress) + { + if (inProgress.size() > 45 && slot > 9 && slot % 45 == 0) + { + addBackBed(slot + 4); + slot += 9; + } + + ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded); + + addButton(slot, shopItem, new JoinServerButton(this, serverInfo)); + + slot++; + } + + addBackBed(4); + } + + private void addBackBed(int slot) + { + addButton(slot, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] + {}, 1, false), new IButton() { @Override public void onClick(Player player, ClickType clickType) { - clear(); _onMainPage = true; + buildPage(); } }); - - while (slot < getSize()) - { - if (getItem(slot) != null) - setItem(slot, null); - - slot++; - } } public void Update() @@ -422,4 +466,16 @@ public class ServerNpcPage extends ShopPageBase im getPlugin().selectServer(player, serverInfo); } + + @Override + protected IButton[] getButtons() + { + return _buttons; + } + + @Override + protected ItemStack[] getItems() + { + return _items; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/compass/CompassAddon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/compass/CompassAddon.java index 5383b0be6..488295caf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/compass/CompassAddon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/addons/compass/CompassAddon.java @@ -206,7 +206,7 @@ public class CompassAddon extends MiniPlugin { // Teleport to nearest player when you left click compass - if (!Recharge.Instance.use(player, "Spectate", 5000, true, false)) + if (!Recharge.Instance.use(player, "Spectate", 3000, true, false)) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index a4adccbd5..cc3956390 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -73,6 +73,7 @@ public class GameTeam //Records order players go out in protected ArrayList _places = new ArrayList(); + private long _teamCreatedTime = System.currentTimeMillis(); // Used just for SpectatorPage so that teams remain ordered public GameTeam(Game host, String name, ChatColor color, ArrayList spawns, boolean tags) { @@ -90,6 +91,11 @@ public class GameTeam this(host, name, color, spawns, false); } + public long getCreatedTime() + { + return _teamCreatedTime; + } + public String GetName() { return _name; @@ -300,6 +306,11 @@ public class GameTeam _displayName = name; } + public String getDisplayName() + { + return _displayName; + } + public byte GetColorData() { if (GetColor() == ChatColor.WHITE) return (byte)0; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java index ebe10c41a..7f75b4533 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/spectatorMenu/page/SpectatorPage.java @@ -4,8 +4,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -18,8 +20,9 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilColor; import mineplex.core.common.util.UtilMath; import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; +import mineplex.core.shop.page.ShopPageInventory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.addons.compass.CompassAddon; import nautilus.game.arcade.game.GameTeam; @@ -30,35 +33,46 @@ import nautilus.game.arcade.gui.spectatorMenu.button.SpectatorButton; * Created by shaun on 14-09-24. */ -public class SpectatorPage extends ShopPageBase +public class SpectatorPage extends + ShopPageInventory { private ArcadeManager _arcadeManager; + private IButton[] _buttons; + private ItemStack[] _items; - public SpectatorPage(CompassAddon plugin, ArcadeManager arcadeManager, SpectatorShop shop, CoreClientManager clientManager, + public SpectatorPage(CompassAddon plugin, ArcadeManager arcadeManager, + SpectatorShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { - super(plugin, shop, clientManager, donationManager, "Spectator Menu", player); + super(plugin, shop, clientManager, donationManager, "Spectator Menu", + player); + _arcadeManager = arcadeManager; buildPage(); } @Override - protected void buildPage() + protected void buildItems() { - int playerCount = _arcadeManager.GetGame().GetPlayers(true).size(); + _buttons = new IButton[54]; + _items = new ItemStack[54]; + List teamList = _arcadeManager.GetGame().GetTeamList(); - if (teamList.size() == 1 && playerCount < 28) - buildSingleTeam(teamList.get(0), playerCount); - else - buildMultipleTeams(teamList, playerCount); + int playerCount = _arcadeManager.GetGame().GetPlayers(true).size(); + if (teamList.size() == 1 && playerCount < 28) + { + buildSingleTeam(teamList.get(0), playerCount); + } + else + { + buildMultipleTeams(teamList, playerCount); + } } private void buildSingleTeam(GameTeam team, int playerCount) { - setItem(13, getTeamItem(team, playerCount)); - ArrayList players = team.GetPlayers(true); Collections.sort(players, new Comparator() @@ -72,6 +86,11 @@ public class SpectatorPage extends ShopPageBase }); + _buttons = new IButton[19 + players.size()]; + _items = new ItemStack[_buttons.length]; + + _items[13] = getTeamItem(team, playerCount); + int slot = 19; for (Player other : players) @@ -79,41 +98,70 @@ public class SpectatorPage extends ShopPageBase addPlayerItem(slot, team, other); if ((slot + 2) % 9 == 0) + { + _buttons = Arrays.copyOf(_buttons, _buttons.length + 3); + _items = Arrays.copyOf(_items, _items.length + 3); + slot += 3; + } else + { slot++; + } } } private void buildMultipleTeams(List teamList, int playerCount) { + _buttons = new IButton[0]; + _items = new ItemStack[0]; + int currentRow = 0; + Collections.sort(teamList, new Comparator() + { + + @Override + public int compare(GameTeam o1, GameTeam o2) + { + int returns = o1.getDisplayName().compareToIgnoreCase( + o2.getDisplayName()); + + if (returns == 0) + { + return Long.compare(o1.getCreatedTime(), + o2.getCreatedTime()); + } + + return returns; + } + + }); + for (GameTeam team : teamList) { ArrayList teamPlayers = team.GetPlayers(true); - int rowsNeeded = (int) Math.ceil(teamPlayers.size() / 8.0); Collections.sort(teamPlayers, new Comparator() { - @Override public int compare(Player o1, Player o2) { return o1.getName().compareToIgnoreCase(o2.getName()); } - }); + int rowsNeeded = (int) Math.ceil(teamPlayers.size() / 8.0); + + _buttons = Arrays.copyOf(_buttons, _buttons.length + + (rowsNeeded * 9)); + _items = Arrays.copyOf(_items, _items.length + (rowsNeeded * 9)); + for (int row = 0; row < rowsNeeded; row++) { int woolSlot = (row * 9) + (currentRow * 9); - // TODO Need to handle too many players in a better way - if (woolSlot >= getSize()) - continue; - - setItem(woolSlot, getTeamItem(team, teamPlayers.size())); + _items[woolSlot] = getTeamItem(team, teamPlayers.size()); int playerIndex = row * 8; for (int i = 0; i < 8 && playerIndex < teamPlayers.size(); i++, playerIndex++) @@ -121,36 +169,43 @@ public class SpectatorPage extends ShopPageBase Player other = teamPlayers.get(playerIndex); int slot = woolSlot + 1 + i; - // TODO Need to handle too many players in a better way - if (slot >= getSize()) - continue; - addPlayerItem(slot, team, other); } } - // Add a line in between teams if the player count is low enough and there are less than 4 teams + // Add a line in between teams if the player count is low enough and + // there are less than 4 teams if (rowsNeeded == 1 && teamList.size() < 4 && playerCount <= 26) + { currentRow += 2; + } else + { currentRow += rowsNeeded; + } } } private void addPlayerItem(int slot, GameTeam team, Player other) { ItemStack playerItem = getPlayerItem(team, other); - ShopItem shopItem = new ShopItem(playerItem, other.getName(), other.getName(), 1, false, false); - addButton(slot, shopItem, new SpectatorButton(_arcadeManager, getPlayer(), other)); + + ShopItem shopItem = new ShopItem(playerItem, other.getName(), + other.getName(), 1, false, false); + + _items[slot] = shopItem; + _buttons[slot] = new SpectatorButton(_arcadeManager, getPlayer(), other); } private ItemStack getTeamItem(GameTeam team, int playerCount) { - ItemStack item = new ItemStack(Material.WOOL, 1, (short) 0, UtilColor.chatColorToWoolData(team.GetColor())); + ItemStack item = new ItemStack(Material.WOOL, 1, (short) 0, + UtilColor.chatColorToWoolData(team.GetColor())); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(team.GetFormattedName()); - meta.setLore(Arrays.asList(" ", ChatColor.RESET + C.cYellow + "Players Alive: " + C.cWhite + playerCount)); + meta.setLore(Arrays.asList(" ", ChatColor.RESET + C.cYellow + + "Players Alive: " + C.cWhite + playerCount)); item.setItemMeta(meta); return item; @@ -161,13 +216,17 @@ public class SpectatorPage extends ShopPageBase ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3); double distance = UtilMath.offset(getPlayer(), other); - double heightDifference = other.getLocation().getY() - getPlayer().getLocation().getY(); + double heightDifference = other.getLocation().getY() + - getPlayer().getLocation().getY(); ArrayList lore = new ArrayList(); lore.add(" "); - lore.add(ChatColor.RESET + C.cYellow + "Kit: " + C.cWhite + _arcadeManager.GetGame().GetKit(other).GetName()); - lore.add(ChatColor.RESET + C.cYellow + "Distance: " + C.cWhite + UtilMath.trim(1, distance)); - lore.add(ChatColor.RESET + C.cYellow + "Height Difference: " + C.cWhite + UtilMath.trim(1, heightDifference)); + lore.add(ChatColor.RESET + C.cYellow + "Kit: " + C.cWhite + + _arcadeManager.GetGame().GetKit(other).GetName()); + lore.add(ChatColor.RESET + C.cYellow + "Distance: " + C.cWhite + + UtilMath.trim(1, distance)); + lore.add(ChatColor.RESET + C.cYellow + "Height Difference: " + C.cWhite + + UtilMath.trim(1, heightDifference)); lore.add(" "); lore.add(ChatColor.RESET + C.Line + "Click to Spectate"); SkullMeta skullMeta = ((SkullMeta) item.getItemMeta()); @@ -179,4 +238,16 @@ public class SpectatorPage extends ShopPageBase return item; } + @Override + protected IButton[] getButtons() + { + return _buttons; + } + + @Override + protected ItemStack[] getItems() + { + return _items; + } + } \ No newline at end of file From 901dad2f8a46126ee6691cf6d45cb5d793c8c311 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 17 Sep 2015 22:31:18 -0400 Subject: [PATCH 025/106] Add vote3 to bonusmanager --- .../Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 85f878294..1276e2f00 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -156,6 +156,7 @@ public class BonusManager extends MiniClientPlugin implements I _voteList = new ArrayList(); _voteList.add("http://vote1.mineplex.com"); _voteList.add("http://vote2.mineplex.com"); + _voteList.add("http://vote3.mineplex.com"); _coinQueue = new LinkedList(); _gemQueue = new LinkedList(); @@ -185,6 +186,7 @@ public class BonusManager extends MiniClientPlugin implements I _voteList = new ArrayList(); _voteList.add("http://vote1.mineplex.com"); _voteList.add("http://vote2.mineplex.com"); + _voteList.add("http://vote3.mineplex.com"); _canVote = true; _coinQueue = new LinkedList(); From cf618abd4ec47fd984b4212a93b025d68de35696 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Tue, 22 Sep 2015 01:38:45 -0400 Subject: [PATCH 026/106] BotSpam Module --- Plugins/.idea/artifacts/Mineplex_Hub_jar.xml | 1 + Plugins/.idea/compiler.xml | 1 + Plugins/Mineplex.Core/Mineplex.Core.iml | 1 + .../src/mineplex/core/TablistFix.java | 3 +- .../mineplex/core/botspam/BotSpamManager.java | 162 ++++++++++++++++++ .../src/mineplex/core/botspam/SpamText.java | 47 +++++ .../botspam/command/BotSpamAddCommand.java | 64 +++++++ .../core/botspam/command/BotSpamCommand.java | 31 ++++ .../command/BotSpamDisableCommand.java | 71 ++++++++ .../botspam/command/BotSpamEnableCommand.java | 71 ++++++++ .../botspam/command/BotSpamListCommand.java | 40 +++++ .../botspam/repository/BotSpamRepository.java | 85 +++++++++ .../src/mineplex/core/punish/Punish.java | 34 ++-- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 2 +- .../src/mineplex/hub/HubManager.java | 5 +- 15 files changed, 602 insertions(+), 16 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/botspam/BotSpamManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/botspam/SpamText.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamAddCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamDisableCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamEnableCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/botspam/command/BotSpamListCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/botspam/repository/BotSpamRepository.java diff --git a/Plugins/.idea/artifacts/Mineplex_Hub_jar.xml b/Plugins/.idea/artifacts/Mineplex_Hub_jar.xml index 150c21bc3..370ba8bd7 100644 --- a/Plugins/.idea/artifacts/Mineplex_Hub_jar.xml +++ b/Plugins/.idea/artifacts/Mineplex_Hub_jar.xml @@ -20,6 +20,7 @@ + \ No newline at end of file diff --git a/Plugins/.idea/compiler.xml b/Plugins/.idea/compiler.xml index bd35e0f52..37717d4dc 100644 --- a/Plugins/.idea/compiler.xml +++ b/Plugins/.idea/compiler.xml @@ -4,6 +4,7 @@