From c7f2a8072e8693206b4fa79e0dead603cb5aa517 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sun, 23 Nov 2014 19:51:23 -0600 Subject: [PATCH] Antistack replacement --- .../mineplex/core/antistack/AntiStack.java | 138 ------------------ .../Mineplex.Hub/src/mineplex/hub/Hub.java | 2 - .../src/mineplex/hub/HubManager.java | 2 + .../src/nautilus/game/arcade/Arcade.java | 4 +- .../nautilus/game/arcade/ArcadeManager.java | 11 +- .../src/nautilus/game/arcade/game/Game.java | 34 +++++ .../game/games/minestrike/MineStrike.java | 3 - .../survivalgames/SurvivalGamesTeams.java | 3 +- .../game/arcade/game/games/uhc/UHC.java | 3 +- .../arcade/managers/GameCreationManager.java | 2 +- .../nautilus/game/arcade/world/WorldData.java | 5 +- 11 files changed, 46 insertions(+), 161 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antistack/AntiStack.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antistack/AntiStack.java b/Plugins/Mineplex.Core/src/mineplex/core/antistack/AntiStack.java deleted file mode 100644 index adfd31e2b..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/antistack/AntiStack.java +++ /dev/null @@ -1,138 +0,0 @@ -package mineplex.core.antistack; - -import java.util.HashSet; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.UtilMath; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; -import org.bukkit.entity.Item; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.inventory.InventoryPickupItemEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.plugin.java.JavaPlugin; - -public class AntiStack extends MiniPlugin -{ - private boolean _enabled = true; - - private HashSet _ignoreAround = new HashSet(); - - public AntiStack(JavaPlugin plugin) - { - super("AntiStack", plugin); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void BlockBreak(BlockBreakEvent event) - { - if (!_enabled) - return; - - if (event.isCancelled()) - return; - - _ignoreAround.add(event.getBlock().getLocation().add(0.5, 0.5, 0.5)); - } - - @EventHandler - public void ClearIgnoreAround(UpdateEvent event) - { - if (!_enabled) - return; - - if (event.getType() != UpdateType.TICK) - return; - - _ignoreAround.clear(); - } - - @EventHandler (priority=EventPriority.HIGHEST) - public void ItemSpawn(ItemSpawnEvent event) - { - if (!_enabled) - return; - - if (event.isCancelled()) - return; - - Item item = event.getEntity(); - - for (Location loc : _ignoreAround) - if (UtilMath.offset(loc, event.getLocation()) < 2) - return; - - //ItemName() - if (item.getLocation().getY() < -10) - return; - - //Get Name - String name = ((CraftItemStack)item.getItemStack()).getHandle().getName(); - - //Append UID - name += ":" + item.getUniqueId(); - - //Set Name - ((CraftItemStack)item.getItemStack()).getHandle().c(name); - } - - @EventHandler (priority=EventPriority.HIGHEST) - public void PlayerPickup(PlayerPickupItemEvent event) - { - if (!_enabled) - return; - - if (event.isCancelled()) - return; - - Item item = event.getItem(); - - removeUID(item); - } - - @EventHandler - public void HopperPickup(InventoryPickupItemEvent event) - { - if (!_enabled) - return; - - if (event.isCancelled()) - return; - - Item item = event.getItem(); - - //Get Name - String name = ((CraftItemStack)item.getItemStack()).getHandle().getName(); - - //Remove UID - if (name.contains(":")) - name = name.substring(0, name.indexOf(":" + item.getUniqueId())); - - //Set Name - ((CraftItemStack)item.getItemStack()).getHandle().c(name); - } - - public void SetEnabled(boolean var) - { - _enabled = var; - } - - public static void removeUID(Item item) - { - //Get Name - String name = ((CraftItemStack)item.getItemStack()).getHandle().getName(); - - //Remove UID - if (name.contains(":")) - name = name.substring(0, name.indexOf(":" + item.getUniqueId())); - - //Set Name - ((CraftItemStack)item.getItemStack()).getHandle().c(name); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index b3d9a4ea0..0e2367bc5 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -6,7 +6,6 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.CustomTagFix; import mineplex.core.account.CoreClientManager; import mineplex.core.antihack.AntiHack; -import mineplex.core.antistack.AntiStack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; @@ -89,7 +88,6 @@ public class Hub extends JavaPlugin implements IRelation Creature creature = new Creature(this); NpcManager npcManager = new NpcManager(this, creature); PetManager petManager = new PetManager(this, clientManager, donationManager, creature, webServerAddress); - new AntiStack(this); PollManager pollManager = new PollManager(this, donationManager); //Main Modules diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 1968f68c8..88a4170f5 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -158,6 +158,8 @@ public class HubManager extends MiniClientPlugin _portal = portal; _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); + // Disable item merging + ((CraftWorld) _spawn.getWorld()).getHandle().spigotConfig.itemMerge = 0; _textCreator = new TextManager(this); _parkour = new ParkourManager(this, donationManager, taskManager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 1694f058a..d09a3d25e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -9,7 +9,6 @@ import net.minecraft.server.v1_7_R4.MinecraftServer; import mineplex.core.CustomTagFix; import mineplex.core.account.CoreClientManager; import mineplex.core.antihack.AntiHack; -import mineplex.core.antistack.AntiStack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.command.CommandCenter; @@ -89,7 +88,6 @@ public class Arcade extends JavaPlugin PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager); new MessageManager(this, _clientManager, preferenceManager); - AntiStack antistack = new AntiStack(this); Creature creature = new Creature(this); Spawn spawn = new Spawn(this); Teleport teleport = new Teleport(this, _clientManager, spawn); @@ -119,7 +117,7 @@ public class Arcade extends JavaPlugin cosmeticManager.setInterfaceSlot(7); //Arcade Manager - _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, webServerAddress); + _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, webServerAddress); new MemoryFix(this); new CustomTagFix(this, packetHandler); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 23404cac7..0717c1c3d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -36,7 +36,6 @@ import org.bukkit.event.server.ServerListPingEvent; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; -import mineplex.core.antistack.AntiStack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.chat.Chat; @@ -115,7 +114,6 @@ import nautilus.game.arcade.shop.ArcadeShop; public class ArcadeManager extends MiniPlugin implements IRelation { // Modules - private AntiStack _antistack; private BlockRestore _blockRestore; private Blood _blood; private Chat _chat; @@ -172,7 +170,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, - DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack, + DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler, CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, String webAddress) { @@ -181,8 +179,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation _serverConfig = serverConfig; // Modules - _antistack = antistack; - _blockRestore = new BlockRestore(plugin); _blood = blood; @@ -298,11 +294,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _achievementManager; } - public AntiStack GetAntiStack() - { - return _antistack; - } - public Blood GetBlood() { return _blood; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 6a6496739..5808a7c44 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -13,6 +13,7 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Hanging; @@ -24,6 +25,7 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.scoreboard.Objective; import org.bukkit.util.Vector; @@ -191,6 +193,8 @@ public abstract class Game implements Listener public boolean RepairWeapons = true; + private double _itemMergeRadius = 0; + public boolean AnnounceStay = true; public boolean AnnounceJoinQuit = true; @@ -1274,4 +1278,34 @@ public abstract class Game implements Listener loc.getY() >= WorldData.MaxY || loc.getY() <= WorldData.MinY); } + + public void setItemMerge(boolean itemMerge) + { + setItemMergeRadius(itemMerge ? 3.5 : 0); + } + + public void setItemMergeRadius(double mergeRadius) + { + _itemMergeRadius = mergeRadius; + + if (WorldData.World != null) + { + ((CraftWorld) WorldData.World).getHandle().spigotConfig.itemMerge = _itemMergeRadius; + } + } + + public double getItemMergeRadius() + { + return _itemMergeRadius; + } + + @EventHandler + public void applyItemMerge(WorldLoadEvent event) + { + if (event.getWorld().getName().equals(WorldData.GetFolder())) + { + System.out.println("Setting item merge radius for game to " + _itemMergeRadius); + ((CraftWorld) event.getWorld()).getHandle().spigotConfig.itemMerge = _itemMergeRadius; + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java index d80ae53d5..e1fefd4fd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java @@ -57,7 +57,6 @@ import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.TeamNameTagVisibility; import org.bukkit.util.Vector; -import mineplex.core.antistack.AntiStack; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -898,8 +897,6 @@ public class MineStrike extends TeamGame if (UtilInv.contains(event.getPlayer(), Material.SHEARS, (byte)0, 1)) return; - AntiStack.removeUID(event.getItem()); - event.getPlayer().getInventory().setItem(8, event.getItem().getItemStack()); UtilPlayer.message(event.getPlayer(), F.main("Game", "You equipped Defusal Kit.")); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java index 0f90adf98..9f1719883 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java @@ -149,7 +149,8 @@ public class SurvivalGamesTeams extends TeamGame C.cAqua + "Compass finds Players during day time.", }; - Manager.GetAntiStack().SetEnabled(false); + setItemMerge(true); +// Manager.GetAntiStack().SetEnabled(false); this.GameTimeout = 9600000; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index b7e4f87d1..ab74aa916 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -174,7 +174,8 @@ public class UHC extends TeamGame Manager.GetCreature().SetDisableCustomDrops(true); //Disable Anti-Stack - Manager.GetAntiStack().SetEnabled(false); + setItemMerge(true); +// Manager.GetAntiStack().SetEnabled(false); //Damage Settings Manager.GetDamage().SetEnabled(false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java index a7a6ce2cc..5ab646033 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java @@ -159,7 +159,7 @@ public class GameCreationManager implements Listener Manager.GetDamage().SetEnabled(true); Manager.GetExplosion().SetRegenerate(false); Manager.GetExplosion().SetTNTSpread(true); - Manager.GetAntiStack().SetEnabled(true); +// Manager.GetAntiStack().SetEnabled(true); Manager.getCosmeticManager().setHideParticles(false); HashMap pastTeams = null; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java index b1e5c7536..1f64962ad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java @@ -23,6 +23,7 @@ import org.bukkit.Difficulty; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.WorldCreator; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.event.world.ChunkUnloadEvent; public class WorldData @@ -84,7 +85,7 @@ public class WorldData TimingManager.stop("WorldData loading world."); World.setDifficulty(Difficulty.HARD); - + TimingManager.start("WorldData loading WorldConfig."); //Load World Data worldData.LoadWorldConfig(); @@ -116,7 +117,7 @@ public class WorldData return File; } - protected String GetFolder() + public String GetFolder() { if (Folder == null) Folder = "Game" + Id + "_" + Host.GetName() + "_" + GetFile();