MAC Update

This commit is contained in:
Chiss 2014-10-12 14:19:35 +11:00
parent 42d22ac38f
commit 9cc28d1ad8
27 changed files with 241 additions and 137 deletions

View File

@ -7,14 +7,15 @@ import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin;
@ -44,6 +45,8 @@ public class AntiHack extends MiniPlugin
public static AntiHack Instance;
private boolean _enabled = true;
private boolean _strict = true;
private boolean _kick = true;
public Punish Punish;
public Portal Portal;
@ -51,9 +54,6 @@ public class AntiHack extends MiniPlugin
private CoreClientManager _clientManager;
//Record Offenses
private HashMap<Player, HashMap<String, ArrayList<Long>>> _suspicion = new HashMap<Player, HashMap<String, ArrayList<Long>>>();
//Some suspicions will not become offenses, for example, using double jump will remove suspicion 2 seconds prior
private HashMap<Player, HashMap<String, ArrayList<Long>>> _offense = new HashMap<Player, HashMap<String, ArrayList<Long>>>();
//Ignore Player
@ -64,12 +64,14 @@ public class AntiHack extends MiniPlugin
private HashMap<Player, Long> _lastMoveEvent = new HashMap<Player, Long>();
//Hack Requirements
public int FloatHackTicks = 6;
public int HoverHackTicks = 3;
public int FloatHackTicks = 10;
public int HoverHackTicks = 4;
public int RiseHackTicks = 6;
public int SpeedHackTicks = 6;
public int IdleTime = 20000;
public int KeepOffensesFor = 30000;
//Other Times
public int FlightTriggerCancel = 2000;
@ -121,7 +123,7 @@ public class AntiHack extends MiniPlugin
synchronized (_antiHackLock)
{
_ignore.put(event.getPlayer(), System.currentTimeMillis() + 2000);
setIgnore(event.getPlayer(), 2000);
}
}
@ -137,35 +139,6 @@ 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<Long> offenseList : _suspicion.get(player).values())
{
Iterator<Long> offenseIterator = offenseList.iterator();
while (offenseIterator.hasNext())
{
long time = offenseIterator.next();
if (!UtilTime.elapsed(time, FlightTriggerCancel))
offenseIterator.remove();
}
}
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
@ -197,7 +170,7 @@ public class AntiHack extends MiniPlugin
if (timeBetweenPackets > 500)
{
setIgnore(player, 5000);
setIgnore(player, Math.min(4000, timeBetweenPackets));
}
}
}
@ -235,7 +208,12 @@ public class AntiHack extends MiniPlugin
}
}
return (_ignore.containsKey(player) && System.currentTimeMillis() < _ignore.get(player));
if ((_ignore.containsKey(player) && System.currentTimeMillis() < _ignore.get(player)))
{
return true;
}
return false;
}
public void addSuspicion(Player player, String type)
@ -243,62 +221,45 @@ public class AntiHack extends MiniPlugin
if (!_enabled)
return;
System.out.println(C.cRed + C.Bold + player.getName() + " suspected for " + type + ".");
synchronized (_antiHackLock)
{
//Add Offense
if (!_suspicion.containsKey(player))
_suspicion.put(player, new HashMap<String, ArrayList<Long>>());
if (!_suspicion.get(player).containsKey(type))
_suspicion.get(player).put(type, new ArrayList<Long>());
_suspicion.get(player).get(type).add(System.currentTimeMillis());
}
for (Player admin : UtilServer.getPlayers())
if (_clientManager.Get(admin).GetRank().Has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports)
UtilPlayer.message(admin, C.cRed + C.Bold + player.getName() + " suspected for " + type + ".");
// Print (Debug)
System.out.println("[Offense] " + player.getName() + " received suspicion for " + type + ".");
}
@EventHandler
public void processOffenses(UpdateEvent event)
{
if (!_enabled)
return;
if (event.getType() != UpdateType.SEC)
return;
synchronized (_antiHackLock)
{
for (Player player : _suspicion.keySet())
{
if (!_offense.containsKey(player))
_offense.put(player, new HashMap<String, ArrayList<Long>>());
for (String type : _suspicion.get(player).keySet())
{
if (!_offense.get(player).containsKey(type))
_offense.get(player).put(type, new ArrayList<Long>());
Iterator<Long> offenseIterator = _suspicion.get(player).get(type).iterator();
_offense.get(player).get(type).add(System.currentTimeMillis());
//Cull & Count
int total = 0;
for (String curType : _offense.get(player).keySet())
{
//Remove Old Offenses
Iterator<Long> offenseIterator = _offense.get(player).get(curType).iterator();
while (offenseIterator.hasNext())
{
long time = offenseIterator.next();
//Suspicion turns into Offense
if (UtilTime.elapsed(time, FlightTriggerCancel))
{
if (UtilTime.elapsed(offenseIterator.next(), KeepOffensesFor))
offenseIterator.remove();
_offense.get(player).get(type).add(time);
}
}
//Count
total += _offense.get(player).get(curType).size();
}
//Inform
for (Player admin : UtilServer.getPlayers())
if (_clientManager.Get(admin).GetRank().Has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports)
{
UtilPlayer.message(admin, "#" + total + ": " + C.cRed + C.Bold + player.getName() + " suspected for " + type + ".");
}
// Print (Debug)
System.out.println("[Offense] #" + total + ": "+ player.getName() + " received suspicion for " + type + ".");
}
}
@ -308,7 +269,7 @@ public class AntiHack extends MiniPlugin
if (!_enabled)
return;
if (event.getType() != UpdateType.SLOW)
if (event.getType() != UpdateType.SEC)
return;
synchronized (_antiHackLock)
@ -321,12 +282,12 @@ public class AntiHack extends MiniPlugin
for (String type : _offense.get(player).keySet())
{
//Remove Old Offenses
Iterator<Long> offenseIterator = _suspicion.get(player).get(type).iterator();
Iterator<Long> offenseIterator = _offense.get(player).get(type).iterator();
while (offenseIterator.hasNext())
{
long time = offenseIterator.next();
if (UtilTime.elapsed(time, 300000))
if (UtilTime.elapsed(time, KeepOffensesFor))
offenseIterator.remove();
}
@ -340,10 +301,10 @@ public class AntiHack extends MiniPlugin
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";
String severity;
if (total > (_strict ? 6 : 15)) severity = "Extreme";
else if (total > (_strict ? 4 : 10)) severity = "High";
else if (total > (_strict ? 2 : 5)) severity = "Medium";
else severity = "Low";
//Send Report
@ -355,6 +316,28 @@ public class AntiHack extends MiniPlugin
public void sendReport(Player player, String report, String severity)
{
if (severity.equals("Extreme"))
{
ResetAll(player);
//Staff
boolean handled = false;
for (Player staff : UtilServer.getPlayers())
{
if (_clientManager.Get(staff).GetRank().Has(Rank.MODERATOR))
{
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cYellow + report);
UtilPlayer.message(staff, C.cAqua + C.Scramble + "A" + ChatColor.RESET + C.cRed + C.Bold + " MAC > " + ChatColor.RESET + C.cGold + player.getName() + C.cYellow + " has extreme violation. Please investigate.");
handled = true;
}
}
//Auto-Kick
if (!handled)
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 2f, 0.5f);
if (_kick)
{
player.kickPlayer(
C.cGold + "Mineplex Anti-Cheat" + "\n" +
@ -362,9 +345,25 @@ public class AntiHack extends MiniPlugin
C.cWhite + "Cheating may result in a " + C.cRed + "Permanent Ban" + C.cWhite + "." + "\n" +
C.cWhite + "If you were not cheating, you will not be banned."
);
}
else
{
UtilPlayer.message(player, C.cGold + C.Bold + "----------------------------------------------------");
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cGold + "Mineplex Anti-Cheat");
UtilPlayer.message(player, "");
UtilPlayer.message(player, "You were kicked from the game for suspicious movement.");
UtilPlayer.message(player, "Cheating may result in a " + C.cRed + "Permanent Ban" + C.cWhite + ".");
UtilPlayer.message(player, "If you were not cheating, you will not be banned.");
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cGold + C.Bold + "----------------------------------------------------");
Portal.SendPlayerToServer(player, "Lobby");
}
UtilServer.broadcast(F.main("MAC", player.getName() + " was kicked for suspicious movement."));
}
//Record
ServerListPingEvent event = new ServerListPingEvent(null, Bukkit.getServer().getMotd(), Bukkit.getServer().getOnlinePlayers().size(), Bukkit.getServer().getMaxPlayers());
GetPluginManager().callEvent(event);
@ -387,6 +386,12 @@ public class AntiHack extends MiniPlugin
}
}
private void Reset()
{
for (Player player : UtilServer.getPlayers())
ResetAll(player);
}
private void ResetAll(Player player)
{
synchronized (_antiHackLock)
@ -397,7 +402,6 @@ public class AntiHack extends MiniPlugin
_offense.remove(player);
_suspicion.remove(player);
for (Detector detector : _detectors)
detector.Reset(player);
@ -413,6 +417,8 @@ public class AntiHack extends MiniPlugin
if (event.getType() != UpdateType.SLOW)
return;
synchronized (_antiHackLock)
{
for (Iterator<Entry<Player, Long>> playerIterator = _ignore.entrySet().iterator(); playerIterator.hasNext();)
{
Player player = playerIterator.next().getKey();
@ -425,17 +431,12 @@ public class AntiHack extends MiniPlugin
_lastMoveEvent.remove(player);
_offense.remove(player);
_suspicion.remove(player);
for (Detector detector : _detectors)
detector.Reset(player);
}
}
}
public HashMap<Player, HashMap<String, ArrayList<Long>>> getOffenses()
{
return _offense;
}
public void SetEnabled(boolean b)
@ -448,4 +449,20 @@ public class AntiHack extends MiniPlugin
{
return _enabled;
}
public void setStrict(boolean strict)
{
_strict = strict;
Reset();
System.out.println("MAC Strict: " + strict);
}
public void setKick(boolean kick)
{
_kick = kick;
System.out.println("MAC Kick: " + kick);
}
}

View File

@ -44,7 +44,7 @@ public class Fly extends MiniPlugin implements Detector
//100% Valid
if (Host.isValid(player, true))
return;
Reset(player);
//Hasn't moved, just looking around
if (UtilMath.offset(event.getFrom(), event.getTo()) <= 0)
@ -52,6 +52,10 @@ public class Fly extends MiniPlugin implements Detector
updateFloat(player);
return;
}
else
{
_floatTicks.remove(player);
}
updateHover(player);
updateRise(player);
@ -76,7 +80,7 @@ public class Fly extends MiniPlugin implements Detector
if (count > Host.FloatHackTicks)
{
Host.addSuspicion(player, "Fly (Float)");
count = 0;
count -= 2;
}
_floatTicks.put(player, new AbstractMap.SimpleEntry<Integer, Double>(count, player.getLocation().getY()));
@ -96,12 +100,14 @@ public class Fly extends MiniPlugin implements Detector
{
count = 0;
}
//player.sendMessage(count + " - " + player.getLocation().getY() + " vs " + _hoverTicks.get(player).getValue());
}
if (count > Host.HoverHackTicks)
{
Host.addSuspicion(player, "Fly (Hover)");
count = 0;
count -= 2;
}
_hoverTicks.put(player, new AbstractMap.SimpleEntry<Integer, Double>(count, player.getLocation().getY()));
@ -113,7 +119,7 @@ public class Fly extends MiniPlugin implements Detector
if (_riseTicks.containsKey(player))
{
if (player.getLocation().getY() > _riseTicks.get(player).getValue())
if (player.getLocation().getY() >= _riseTicks.get(player).getValue())
{
boolean nearBlocks = false;
for (Block block : UtilBlock.getSurrounding(player.getLocation().getBlock(), true))
@ -143,8 +149,11 @@ public class Fly extends MiniPlugin implements Detector
if (count > Host.RiseHackTicks)
{
//Only give Offense if actually rising - initial ticks can be trigged via Hover.
if (player.getLocation().getY() > _riseTicks.get(player).getValue())
Host.addSuspicion(player, "Fly (Rise)");
count = 0;
count -= 2;
}
_riseTicks.put(player, new AbstractMap.SimpleEntry<Integer, Double>(count, player.getLocation().getY()));

View File

@ -91,7 +91,7 @@ public class Speed extends MiniPlugin implements Detector
if (count > Host.SpeedHackTicks)
{
Host.addSuspicion(player, "Speed (Fly/Move)");
count = 0;
count -= 2;
}
_speedTicks.put(player, new AbstractMap.SimpleEntry<Integer, Long>(count, System.currentTimeMillis()));

View File

@ -216,7 +216,7 @@ public class DamageManager extends MiniPlugin
@EventHandler(priority = EventPriority.MONITOR)
public void EndDamageEvent(CustomDamageEvent event)
{
if (!event.IsCancelled())
if (!event.IsCancelled() && event.GetDamage() > 0)
{
Damage(event);

View File

@ -106,6 +106,7 @@ public class Arcade extends JavaPlugin
Punish punish = new Punish(this, webServerAddress, _clientManager);
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
AntiHack.Instance.setKick(false);
BlockRestore blockRestore = new BlockRestore(this);

View File

@ -200,6 +200,8 @@ public abstract class Game implements Listener
public boolean JoinInProgress = false;
public boolean StrictAntiHack = false;
//Addons
public boolean CompassEnabled = false;
public boolean CompassGiveItem = true;

View File

@ -148,6 +148,8 @@ public class Bridge extends TeamGame implements OreObsfucation
// Flags
GameTimeout = Manager.IsTournamentServer() ? 5400000 : 3600000;
this.StrictAntiHack = true;
DamageSelf = true;
ItemDrop = true;
@ -984,6 +986,9 @@ public class Bridge extends TeamGame implements OreObsfucation
{
UtilPlayer.message(event.getPlayer(), F.main("Game",
"Cannot place blocks in liquids until Bridge is down."));
event.getPlayer().setVelocity(new Vector(0,-0.5,0));
event.setCancelled(true);
return;
}
@ -1093,7 +1098,6 @@ public class Bridge extends TeamGame implements OreObsfucation
}
@EventHandler(priority = EventPriority.LOW)
public void BucketEmpty(PlayerBucketEmptyEvent event)
{

View File

@ -185,6 +185,8 @@ public class CastleSiege extends TeamGame
};
this.StrictAntiHack = true;
this.HungerSet = 20;
this.DeathOut = false;
this.WorldTimeSet = 14000; //14000

View File

@ -53,6 +53,8 @@ public class ChampionsDominate extends Domination
Manager.GetDamage().UseSimpleWeaponDamage = false;
this.StrictAntiHack = true;
InventoryOpenChest = true;
EloRanking = false;

View File

@ -54,6 +54,8 @@ public class ChampionsTDM extends TeamDeathmatch
this.Manager.GetDamage().UseSimpleWeaponDamage = false;
this.StrictAntiHack = true;
InventoryOpenChest = true;
registerStatTrackers(

View File

@ -65,6 +65,8 @@ public class DeathTag extends SoloGame
"The last Runner alive wins!"
});
this.StrictAntiHack = true;
this.DeathOut = false;
this.HungerSet = 20;

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.dragonescape;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilWorld;
import org.bukkit.Location;
@ -24,6 +25,7 @@ public class DragonEscapeData
Host = host;
Dragon = dragon;
UtilEnt.ghost(Dragon, true, false);
Location temp = dragon.getLocation();
temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(dragon.getLocation(), target)));

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.dragonescape;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import org.bukkit.Location;
import org.bukkit.entity.EnderDragon;
@ -23,6 +24,7 @@ public class DragonEscapeTeamsData
Host = host;
Dragon = dragon;
UtilEnt.ghost(Dragon, true, false);
Location temp = dragon.getLocation();
temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(dragon.getLocation(), target)));

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.dragons;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;

View File

@ -18,8 +18,11 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -221,4 +224,31 @@ public class Dragons extends SoloGame
if (event.GetCause() == DamageCause.FALL)
event.AddMod("Fall Reduction", "Fall Reduction", -1, false);
}
/*
@EventHandler
public void DragonKnockback(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (DragonData data : _dragons.values())
{
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, data.Dragon.getLocation(), 0f, 0f, 0f, 0, 1);
for (Player player : GetPlayers(true))
{
if (!Recharge.Instance.use(player, "Dragon Hit", 500, false, false))
continue;
if (UtilMath.offset(player, data.Dragon) < 6)
{
UtilAction.velocity(player, UtilAlg.getTrajectory(data.Dragon, player), 1, false, 0, 0.6, 2, true);
player.damage(1);
}
}
}
}
*/
}

View File

@ -94,6 +94,7 @@ public class Draw extends SoloGame
"Hints are given at top of screen",
});
this.StrictAntiHack = true;
this.Damage = false;
this.HungerSet = 20;
this.WorldTimeSet = 8000;

View File

@ -46,6 +46,8 @@ public class Micro extends TeamGame
"Small game, big strategy!",
});
this.StrictAntiHack = true;
this.TeamArmor = true;
this.TeamArmorHotbar = true;

View File

@ -184,6 +184,8 @@ public class MineStrike extends TeamGame
_shopManager = new ShopManager(this);
this.StrictAntiHack = true;
this.HungerSet = 20;
this.ItemDrop = true;

View File

@ -63,6 +63,7 @@ public class Quiver extends SoloGame
"First player to 20 kills wins."
});
this.StrictAntiHack = true;
this.HungerSet = 20;
this.DeathOut = false;
this.DamageSelf = false;

View File

@ -20,16 +20,16 @@ public class KitLeaper extends Kit
{
public KitLeaper(ArcadeManager manager)
{
super(manager, "Jumper", KitAvailability.Free,
super(manager, "Leaper", KitAvailability.Free,
new String[]
{
"Evade and kill using your double jump!"
"Evade and kill using your leap!"
},
new Perk[]
{
new PerkDoubleJump("Double Jump", 0.9, 0.9, true)
new PerkLeap("Leap", 1.2, 1, 3000)
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_AXE));

View File

@ -139,6 +139,8 @@ public class SheepGame extends TeamGame
"Most sheep at 5 minutes wins!"
});
this.StrictAntiHack = true;
this.DeathOut = false;
this.DeathSpectateSecs = 8;

View File

@ -63,6 +63,8 @@ public class SneakyAssassins extends SoloGame
this._npcManager = new NpcManager(this, UtilMath.random);
this.StrictAntiHack = true;
this.DamageTeamSelf = true;
this.PrepareFreeze = false;

View File

@ -158,6 +158,8 @@ public class SurvivalGames extends SoloGame
Manager.GetAntiStack().SetEnabled(false);
this.StrictAntiHack = true;
this.GameTimeout = 9600000;
this.WorldTimeSet = 0;

View File

@ -126,6 +126,7 @@ public class TurfForts extends TeamGame
});
this.StrictAntiHack = true;
this.HungerSet = 20;
this.DeathOut = false;
this.BlockPlaceAllow.add(35);

View File

@ -119,6 +119,8 @@ public class UHC extends TeamGame
"Last player/team alive wins!"
});
this.StrictAntiHack = true;
this.GameTimeout = 10800000;
this.DamagePvP = false;
@ -546,7 +548,7 @@ public class UHC extends TeamGame
//Get Radius Location
else
{
block = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 8 + UtilMath.r(16), around.getBlockZ() - 8 + UtilMath.r(16), ignore);
block = UtilBlock.getHighest(WorldData.World, around.getBlockX() - 4 + UtilMath.r(8), around.getBlockZ() - 4 + UtilMath.r(8), ignore);
}
//Check Validity
@ -1319,9 +1321,9 @@ public class UHC extends TeamGame
return 0;
if (assist)
return 50;
return 40;
return 400;
return 200;
}
@EventHandler

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.managers;
import mineplex.core.antihack.AntiHack;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -16,6 +17,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerDeathOutEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
@ -982,4 +984,16 @@ public class GameFlagManager implements Listener
UtilPlayer.message(player, C.cWhite + C.Bold + "The next game will be starting soon...");
}
}
@EventHandler
public void AntiHackStrict(GameStateChangeEvent event)
{
if (event.GetState() == GameState.Prepare || event.GetState() == GameState.Live)
AntiHack.Instance.setStrict(event.GetGame().StrictAntiHack);
else
AntiHack.Instance.setStrict(true);
}
}

View File

@ -398,5 +398,4 @@ public class GamePlayerManager implements Listener
event.setCancelled(true);
}
}
}