From 395a5d2c08a18014e845a84deb5d76c79a40a7e7 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 3 May 2014 11:47:15 +1000 Subject: [PATCH] MAC disabled with Tournament Mode Bridges TM game desc fix --- .../src/mineplex/core/antihack/AntiHack.java | 115 ++++++++++++------ .../nautilus/game/arcade/ArcadeManager.java | 8 +- .../src/nautilus/game/arcade/game/Game.java | 2 +- .../game/arcade/game/games/bridge/Bridge.java | 11 ++ 4 files changed, 94 insertions(+), 42 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 0a0bff79d..b4f990d10 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -36,9 +36,11 @@ import org.bukkit.plugin.java.JavaPlugin; public class AntiHack extends MiniPlugin { private static Object _antiHackLock = new Object(); - + public static AntiHack Instance; + private boolean _enabled = true; + public Punish Punish; public Portal Portal; @@ -66,7 +68,7 @@ public class AntiHack extends MiniPlugin public int FlightTriggerCancel = 2000; public ArrayList _detectors; - + private AntiHackRepository _repository; protected AntiHack(JavaPlugin plugin, Punish punish, Portal portal) @@ -94,6 +96,9 @@ public class AntiHack extends MiniPlugin @EventHandler public void playerMove(PlayerMoveEvent event) { + if (!_enabled) + return; + synchronized (_antiHackLock) { _lastMoveEvent.put(event.getPlayer(), System.currentTimeMillis()); @@ -103,6 +108,9 @@ public class AntiHack extends MiniPlugin @EventHandler public void playerTeleport(PlayerTeleportEvent event) { + if (!_enabled) + return; + synchronized (_antiHackLock) { _ignore.put(event.getPlayer(), System.currentTimeMillis() + 2000); @@ -112,6 +120,9 @@ public class AntiHack extends MiniPlugin @EventHandler public void playerVelocity(PlayerVelocityEvent event) { + if (!_enabled) + return; + synchronized (_antiHackLock) { _velocityEvent.add(event.getPlayer()); @@ -121,22 +132,25 @@ public class AntiHack extends MiniPlugin @EventHandler public void playerToggleFly(PlayerToggleFlightEvent event) { + if (!_enabled) + return; + Player player = event.getPlayer(); synchronized (_antiHackLock) { if (!_suspicion.containsKey(player)) return; - + //Remove all infractions within last 2 seconds. for (ArrayList offenseList : _suspicion.get(player).values()) { Iterator offenseIterator = offenseList.iterator(); - + while (offenseIterator.hasNext()) { long time = offenseIterator.next(); - + if (!UtilTime.elapsed(time, FlightTriggerCancel)) offenseIterator.remove(); } @@ -147,12 +161,18 @@ public class AntiHack extends MiniPlugin @EventHandler public void playerQuit(PlayerQuitEvent event) { + if (!_enabled) + return; + ResetAll(event.getPlayer()); } @EventHandler public void startIgnore(PlayerMoveEvent event) { + if (!_enabled) + return; + Player player = event.getPlayer(); synchronized (_antiHackLock) @@ -161,12 +181,12 @@ public class AntiHack extends MiniPlugin { setIgnore(player, 2000); } - + //Initial Move (or Lag) Ignore if (_lastMoveEvent.containsKey(player)) { long timeBetweenPackets = System.currentTimeMillis() - _lastMoveEvent.get(player); - + if (timeBetweenPackets > 500) { setIgnore(player, 5000); @@ -186,7 +206,7 @@ public class AntiHack extends MiniPlugin //Already ignoring for a longer period if (_ignore.containsKey(player) && _ignore.get(player) > System.currentTimeMillis() + time) return; - + //Add Ignore _ignore.put(player, System.currentTimeMillis() + time); } @@ -217,13 +237,13 @@ public class AntiHack extends MiniPlugin //Add Offense if (!_suspicion.containsKey(player)) _suspicion.put(player, new HashMap>()); - + if (!_suspicion.get(player).containsKey(type)) _suspicion.get(player).put(type, new ArrayList()); - + _suspicion.get(player).get(type).add(System.currentTimeMillis()); } - + for (Player admin : UtilServer.getPlayers()) if (admin.isOp() && UtilGear.isMat(admin.getItemInHand(), Material.PAPER)) UtilPlayer.message(admin, C.cRed + C.Bold + player.getName() + " suspected for " + type + "."); @@ -235,6 +255,9 @@ public class AntiHack extends MiniPlugin @EventHandler public void processOffenses(UpdateEvent event) { + if (!_enabled) + return; + if (event.getType() != UpdateType.SEC) return; @@ -244,18 +267,18 @@ public class AntiHack extends MiniPlugin { if (!_offense.containsKey(player)) _offense.put(player, new HashMap>()); - + for (String type : _suspicion.get(player).keySet()) { if (!_offense.get(player).containsKey(type)) _offense.get(player).put(type, new ArrayList()); - + Iterator offenseIterator = _suspicion.get(player).get(type).iterator(); - + while (offenseIterator.hasNext()) { long time = offenseIterator.next(); - + //Suspicion turns into Offense if (UtilTime.elapsed(time, FlightTriggerCancel)) { @@ -271,6 +294,9 @@ public class AntiHack extends MiniPlugin @EventHandler public void generateReports(UpdateEvent event) { + if (!_enabled) + return; + if (event.getType() != UpdateType.SLOW) return; @@ -280,7 +306,7 @@ public class AntiHack extends MiniPlugin { String out = ""; int total = 0; - + for (String type : _offense.get(player).keySet()) { //Remove Old Offenses @@ -288,27 +314,27 @@ public class AntiHack extends MiniPlugin while (offenseIterator.hasNext()) { long time = offenseIterator.next(); - + if (UtilTime.elapsed(time, 300000)) offenseIterator.remove(); } - + //Count int count = _offense.get(player).get(type).size(); total += count; - + out += count + " " + type + ", "; } - + if (out.length() > 0) out = out.substring(0, out.length() - 2); - + String severity = ""; if (total > 24) severity = "Extreme"; else if (total > 16) severity = "High"; else if (total > 8) severity = "Medium"; else severity = "Low"; - + //Send Report sendReport(player, out, severity); } @@ -321,31 +347,31 @@ public class AntiHack extends MiniPlugin { player.kickPlayer( C.cGold + "Mineplex Anti-Cheat" + "\n" + - C.cWhite + "You were kicked for suspicious movement." + "\n" + - C.cWhite + "Cheating will result in a " + C.cRed + "Permanent Ban" + C.cWhite + "." + "\n" + - C.cWhite + "If you were not cheating, you will not be banned." + C.cWhite + "You were kicked for suspicious movement." + "\n" + + C.cWhite + "Cheating will result in a " + C.cRed + "Permanent Ban" + C.cWhite + "." + "\n" + + C.cWhite + "If you were not cheating, you will not be banned." ); - + UtilServer.broadcast(F.main("MAC", player.getName() + " was kicked for suspicious movement.")); - + ServerListPingEvent event = new ServerListPingEvent(null, Bukkit.getServer().getMotd(), Bukkit.getServer().getOnlinePlayers().length, Bukkit.getServer().getMaxPlayers()); GetPluginManager().callEvent(event); - + String motd = event.getMotd(); String game = "N/A"; String map = "N/A"; - + String[] args = motd.split("\\|"); - + if (args.length > 0) motd = args[0]; - + if (args.length > 2) game = args[2]; - + if (args.length > 3) map = args[3]; - + _repository.saveOffense(player, motd, game, map, report); } } @@ -357,30 +383,33 @@ public class AntiHack extends MiniPlugin _ignore.remove(player); _velocityEvent.remove(player); _lastMoveEvent.remove(player); - - + + _offense.remove(player); _suspicion.remove(player); - + for (Detector detector : _detectors) detector.Reset(player); } } - + @EventHandler public void cleanupPlayers(UpdateEvent event) { + if (!_enabled) + return; + if (event.getType() != UpdateType.SLOW) return; - + for (Iterator> playerIterator = _ignore.entrySet().iterator(); playerIterator.hasNext();) { Player player = playerIterator.next().getKey(); - + if (!player.isOnline() || player.isDead() || !player.isValid()) { playerIterator.remove(); - + _velocityEvent.remove(player); _lastMoveEvent.remove(player); @@ -397,4 +426,10 @@ public class AntiHack extends MiniPlugin { return _offense; } + + public void SetEnabled(boolean b) + { + _enabled = b; + System.out.println("MAC Disabled"); + } } 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 4ce9b85b0..4028a9b92 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -50,6 +50,7 @@ import mineplex.minecraft.game.core.fire.Fire; import mineplex.core.MiniPlugin; import mineplex.core.itemstack.ItemStackFactory; 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; @@ -121,7 +122,12 @@ public class ArcadeManager extends MiniPlugin implements IRelation super("Game Manager", plugin); _serverConfig = serverConfig; - + + if (serverConfig.Tournament) + { + AntiHack.Instance.SetEnabled(false); + } + //Modules _antistack = antistack; 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 f25aecb30..dbd06a9d9 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 @@ -64,7 +64,7 @@ public abstract class Game implements Listener //Game private GameType _gameType; - private String[] _gameDesc; + protected String[] _gameDesc; //Map private ArrayList _files; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index 0a2978dee..e91c7a493 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -156,7 +156,18 @@ public class Bridge extends TeamGame implements OreObsfucation //Tournament if (Manager.IsTournamentServer()) + { QuitOut = false; + + _gameDesc = new String[] + { + "Gather resources and prepare for combat.", + "After 10 minutes, The Bridges will emerge.", + "Special loot is located in the center.", + "Team with the most kills wins!" + }; + } + _tournament = Manager.IsTournamentServer(); }