diff --git a/pom.xml b/pom.xml index 0e84e552..bbefe0d7 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 cc.co.evenprime.bukkit NoCheat - 2.19 + 2.19a jar NoCheat diff --git a/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java b/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java index 5e1d36a5..cf388cef 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java +++ b/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java @@ -2,6 +2,8 @@ package cc.co.evenprime.bukkit.nocheat; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.TreeMap; import org.bukkit.Bukkit; import org.bukkit.World; @@ -60,7 +62,7 @@ public class NoCheat extends JavaPlugin { private MCVersion mcVersion = MCVersion.Unknown; public enum MCVersion { - MC100, MC181, Unknown + MC100, MC181, Unknown, MC101 } public NoCheat() { @@ -100,6 +102,8 @@ public class NoCheat extends JavaPlugin { // find out Minecraft version if(Bukkit.getVersion().contains("MC: 1.0.0")) { this.mcVersion = MCVersion.MC100; + } else if(Bukkit.getVersion().contains("MC: 1.0.1")) { + this.mcVersion = MCVersion.MC101; } else if(Bukkit.getVersion().contains("MC: 1.8.1")) { this.mcVersion = MCVersion.MC181; } else { @@ -134,7 +138,7 @@ public class NoCheat extends JavaPlugin { // Then print a list of active checks per world ActiveCheckPrinter.printActiveChecks(this, eventManagers); - if(mcVersion == MCVersion.MC100 && this.conf.getConfigurationCacheForWorld(null).emergencyfix) { + if((mcVersion == MCVersion.MC100 || mcVersion == MCVersion.MC101) && this.conf.getConfigurationCacheForWorld(null).emergencyfix) { // Tell the server admin that we are activating a workaround log.logToConsole(LogLevel.LOW, "[NoCheat] Activating emergency bugfix for broken player death handling of minecraft."); @@ -231,7 +235,27 @@ public class NoCheat extends JavaPlugin { */ public void cleanDataMap() { players.cleanDataMap(); + } + /** + * An interface method usable by other plugins to collect information about + * a player. It will include the plugin version, two timestamps (beginning + * and end of data collection for that player), and various data from + * checks) + * + * @param playerName + * a player name + * @return A newly created map of identifiers and corresponding values + */ + public Map getPlayerData(String playerName) { + + Map map = new TreeMap(); + + players.getPlayerData(playerName, map); + + map.put("nocheat.version", this.getDescription().getVersion()); + + return map; } public NoCheatPlayer getPlayer(Player player) { diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/DirectionCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/DirectionCheck.java index 7423206d..29a3a70c 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/DirectionCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/DirectionCheck.java @@ -23,10 +23,10 @@ public class DirectionCheck extends BlockBreakCheck { super(plugin, "blockbreak.direction", Permissions.BLOCKBREAK_DIRECTION); } - public boolean check(final NoCheatPlayer player, final BlockBreakData blockbreak, final CCBlockBreak ccblockbreak) { + public boolean check(final NoCheatPlayer player, final BlockBreakData data, final CCBlockBreak ccblockbreak) { - final SimpleLocation brokenBlock = blockbreak.brokenBlockLocation; - final boolean isInstaBreak = blockbreak.instaBrokenBlockLocation.equals(brokenBlock); + final SimpleLocation brokenBlock = data.brokenBlockLocation; + final boolean isInstaBreak = data.instaBrokenBlockLocation.equals(brokenBlock); // If the block is instabreak and we don't check instabreak, return if(isInstaBreak && !ccblockbreak.checkinstabreakblocks) { @@ -42,7 +42,7 @@ public class DirectionCheck extends BlockBreakCheck { if(off < 0.1D) { // Player did nothing wrong // reduce violation counter - blockbreak.directionVL *= 0.9D; + data.directionVL *= 0.9D; } else { // Player failed the check // Increment violation counter @@ -51,21 +51,23 @@ public class DirectionCheck extends BlockBreakCheck { // hard on people failing them off /= 10; } - blockbreak.directionVL += off; + data.directionVL += off; + data.directionTotalVL += off; + data.directionFailed++; - cancel = executeActions(player, ccblockbreak.directionActions.getActions(blockbreak.directionVL)); + cancel = executeActions(player, ccblockbreak.directionActions.getActions(data.directionVL)); if(cancel) { // Needed to calculate penalty times - blockbreak.directionLastViolationTime = time; + data.directionLastViolationTime = time; } } // If the player is still in penalty time, cancel the event anyway - if(blockbreak.directionLastViolationTime + ccblockbreak.directionPenaltyTime > time) { - if(blockbreak.directionLastViolationTime > time) { - System.out.println("Nocheat noted that your time ran backwards for " + (blockbreak.directionLastViolationTime - time) + " ms"); - blockbreak.directionLastViolationTime = 0; + if(data.directionLastViolationTime + ccblockbreak.directionPenaltyTime > time) { + if(data.directionLastViolationTime > time) { + System.out.println("Nocheat noted that your time ran backwards for " + (data.directionLastViolationTime - time) + " ms"); + data.directionLastViolationTime = 0; } return true; } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/NoswingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/NoswingCheck.java index 63e43210..7fce4d7a 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/NoswingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/NoswingCheck.java @@ -26,6 +26,8 @@ public class NoswingCheck extends BlockBreakCheck { data.noswingVL *= 0.90D; } else { data.noswingVL += 1; + data.noswingTotalVL += 1; + data.noswingFailed++; cancel = executeActions(player, cc.noswingActions.getActions(data.noswingVL)); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java index 22e725a2..2713343f 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java @@ -36,6 +36,8 @@ public class ReachCheck extends BlockBreakCheck { // Increment violation counter data.reachVL += distance; + data.reachTotalVL += distance; + data.reachFailed++; data.reachDistance = distance; cancel = executeActions(player, cc.reachActions.getActions(data.reachVL)); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/DirectionCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/DirectionCheck.java index e98eed8f..3abc8704 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/DirectionCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/DirectionCheck.java @@ -62,6 +62,8 @@ public class DirectionCheck extends BlockPlaceCheck { // Player failed the check // Increment violation counter data.directionVL += off; + data.directionTotalVL += off; + data.directionFailed++; // Prepare some event-specific values for logging and custom actions diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/ReachCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/ReachCheck.java index 514db6cb..11ba1d5c 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/ReachCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/ReachCheck.java @@ -36,6 +36,8 @@ public class ReachCheck extends BlockPlaceCheck { // Increment violation counter data.reachVL += distance; + data.reachTotalVL += distance; + data.reachFailed++; data.reachdistance = distance; cancel = executeActions(player, cc.reachActions.getActions(data.reachVL)); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/chat/EmptyCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/chat/EmptyCheck.java index 3de61ccf..637fa46b 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/chat/EmptyCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/chat/EmptyCheck.java @@ -19,10 +19,13 @@ public class EmptyCheck extends ChatCheck { public boolean check(NoCheatPlayer player, ChatData data, CCChat cc) { boolean cancel = false; - + if(data.message.trim().length() == 0) { data.emptyVL += 1; + data.emptyTotalVL += 1; + data.emptyFailed++; + cancel = executeActions(player, cc.emptyActions.getActions(data.emptyVL)); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/chat/SpamCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/chat/SpamCheck.java index 9d60aa0a..e69800f4 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/chat/SpamCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/chat/SpamCheck.java @@ -39,6 +39,9 @@ public class SpamCheck extends ChatCheck { if(data.messageCount > cc.spamLimit) { data.spamVL = data.messageCount - cc.spamLimit; + data.spamTotalVL++; + data.spamFailed++; + cancel = executeActions(player, cc.spamActions.getActions(data.spamVL)); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java index 7e300c77..7652963a 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java @@ -43,7 +43,10 @@ public class DirectionCheck extends FightCheck { // Player failed the check // Increment violation counter if(!plugin.skipCheck()) { - data.directionVL += Math.sqrt(off); + double sqrt = Math.sqrt(off); + data.directionVL += sqrt; + data.directionTotalVL += sqrt; + data.directionFailed++; } cancel = executeActions(player, cc.directionActions.getActions(data.directionVL)); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/NoswingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/NoswingCheck.java index f3d27f91..89eb328f 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/NoswingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/NoswingCheck.java @@ -26,6 +26,8 @@ public class NoswingCheck extends FightCheck { data.noswingVL *= 0.90D; } else { data.noswingVL += 1; + data.noswingTotalVL += 1; + data.noswingFailed++; cancel = executeActions(player, cc.noswingActions.getActions(data.noswingVL)); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/SelfhitCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/SelfhitCheck.java index f2b1bc7e..416dba46 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/SelfhitCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/SelfhitCheck.java @@ -24,6 +24,9 @@ public class SelfhitCheck extends FightCheck { // Player failed the check obviously data.selfhitVL += 1; + data.selfhitTotalVL += 1; + data.selfhitFailed++; + cancel = executeActions(player, cc.selfhitActions.getActions(data.selfhitVL)); } else { data.selfhitVL *= 0.99D; diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java index a268ee48..085215d6 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java @@ -24,11 +24,11 @@ public class FlyingCheck extends MovingCheck { private static final double creativeSpeed = 0.60D; - public PreciseLocation check(NoCheatPlayer player, MovingData moving, CCMoving ccmoving) { + public PreciseLocation check(NoCheatPlayer player, MovingData data, CCMoving ccmoving) { - final PreciseLocation setBack = moving.runflySetBackPoint; - final PreciseLocation from = moving.from; - final PreciseLocation to = moving.to; + final PreciseLocation setBack = data.runflySetBackPoint; + final PreciseLocation from = data.from; + final PreciseLocation to = data.to; if(!setBack.isSet()) { setBack.set(from); @@ -50,32 +50,34 @@ public class FlyingCheck extends MovingCheck { speedLimitHorizontal *= player.getSpeedAmplifier(); - result += Math.max(0.0D, horizontalDistance - moving.horizFreedom - speedLimitHorizontal); + result += Math.max(0.0D, horizontalDistance - data.horizFreedom - speedLimitHorizontal); boolean sprinting = player.isSprinting(); - moving.bunnyhopdelay--; + data.bunnyhopdelay--; // Did he go too far? if(result > 0 && sprinting) { // Try to treat it as a the "bunnyhop" problem - if(moving.bunnyhopdelay <= 0 && result < 0.4D) { - moving.bunnyhopdelay = 3; + if(data.bunnyhopdelay <= 0 && result < 0.4D) { + data.bunnyhopdelay = 3; result = 0; } } // super simple, just check distance compared to max distance - result += Math.max(0.0D, yDistance - moving.vertFreedom - ccmoving.flyingSpeedLimitVertical); + result += Math.max(0.0D, yDistance - data.vertFreedom - ccmoving.flyingSpeedLimitVertical); result = result * 100; if(result > 0) { // Increment violation counter - moving.runflyVL += result; + data.runflyVL += result; + data.runflyTotalVL += result; + data.runflyFailed++; - boolean cancel = executeActions(player, ccmoving.flyingActions.getActions(moving.runflyVL)); + boolean cancel = executeActions(player, ccmoving.flyingActions.getActions(data.runflyVL)); // Was one of the actions a cancel? Then really do it if(cancel) { @@ -84,7 +86,7 @@ public class FlyingCheck extends MovingCheck { } // Slowly reduce the level with each event - moving.runflyVL *= 0.97; + data.runflyVL *= 0.97; // Some other cleanup 'n' stuff if(newToLocation == null) { diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/MorePacketsCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/MorePacketsCheck.java index e7f34e82..5f14c17f 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/MorePacketsCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/MorePacketsCheck.java @@ -74,6 +74,8 @@ public class MorePacketsCheck extends MovingCheck { // went over the limit if(!plugin.skipCheck() && packetsAboveLimit > 0) { data.morePacketsVL += packetsAboveLimit; + data.morePacketsTotalVL += packetsAboveLimit; + data.morePacketsFailed++; data.packets = packetsAboveLimit; diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/NoFallCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/NoFallCheck.java index 8e23a67b..473c5f73 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/NoFallCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/NoFallCheck.java @@ -48,6 +48,8 @@ public class NoFallCheck extends MovingCheck { if(difference > 1.0F && data.toOnOrInGround && data.fallDistance > 2.0F) { data.nofallVL += difference; + data.nofallTotalVL += difference; + data.nofallFailed++; final boolean cancel = executeActions(player, cc.nofallActions.getActions(data.nofallVL)); diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunningCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunningCheck.java index 5e1760b9..1f87f41c 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunningCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunningCheck.java @@ -77,6 +77,8 @@ public class RunningCheck extends MovingCheck { // Increment violation counter data.runflyVL += result; + data.runflyTotalVL += result; + data.runflyFailed++; boolean cancel = executeActions(player, cc.actions.getActions(data.runflyVL)); diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/BaseData.java b/src/cc/co/evenprime/bukkit/nocheat/data/BaseData.java index e6d45f7b..c0e82a25 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/BaseData.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/BaseData.java @@ -1,5 +1,7 @@ package cc.co.evenprime.bukkit.nocheat.data; +import java.util.Map; + public class BaseData extends Data { public final BlockBreakData blockbreak; @@ -7,20 +9,22 @@ public class BaseData extends Data { public final ChatData chat; public final MovingData moving; public final FightData fight; - public final TimedData timed; private final Data[] data; // for convenience + private final long timestamp; + public BaseData() { this.blockbreak = new BlockBreakData(); this.blockplace = new BlockPlaceData(); this.chat = new ChatData(); this.moving = new MovingData(); this.fight = new FightData(); - this.timed = new TimedData(); data = new Data[] {this.blockbreak, this.blockplace, this.chat, - this.moving, this.fight, this.timed}; + this.moving, this.fight}; + + this.timestamp = System.currentTimeMillis(); } @@ -30,4 +34,12 @@ public class BaseData extends Data { } } + public void collectData(Map map) { + for(Data d : data) { + d.collectData(map); + } + + map.put("nocheat.starttime", timestamp); + map.put("nocheat.endtime", System.currentTimeMillis()); + } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/BlockBreakData.java b/src/cc/co/evenprime/bukkit/nocheat/data/BlockBreakData.java index 4b379eae..4de9420e 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/BlockBreakData.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/BlockBreakData.java @@ -1,5 +1,7 @@ package cc.co.evenprime.bukkit.nocheat.data; +import java.util.Map; + /** * Playerspecific data for the blockbreak check group * @@ -7,14 +9,21 @@ package cc.co.evenprime.bukkit.nocheat.data; public class BlockBreakData extends Data { public double reachVL = 0.0D; + public double reachTotalVL = 0.0D; + public int reachFailed = 0; public double directionVL = 0.0D; + public double directionTotalVL = 0.0D; + public int directionFailed = 0; + public double noswingVL = 0.0D; + public double noswingTotalVL = 0.0D; + public int noswingFailed = 0; public long directionLastViolationTime = 0; public final SimpleLocation instaBrokenBlockLocation = new SimpleLocation(); public final SimpleLocation brokenBlockLocation = new SimpleLocation(); public final ExecutionHistory history = new ExecutionHistory(); - public double noswingVL = 0.0D; + public double reachDistance; public boolean armswung = true; @@ -25,4 +34,14 @@ public class BlockBreakData extends Data { directionLastViolationTime = 0; armswung = true; } + + @Override + public void collectData(Map map) { + map.put("blockbreak.reach.vl", (int)reachTotalVL); + map.put("blockbreak.direction.vl", (int)directionTotalVL); + map.put("blockbreak.noswing.vl", (int)noswingTotalVL); + map.put("blockbreak.reach.failed", reachFailed); + map.put("blockbreak.direction.failed", directionFailed); + map.put("blockbreak.noswing.failed", noswingFailed); + } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/BlockPlaceData.java b/src/cc/co/evenprime/bukkit/nocheat/data/BlockPlaceData.java index 23dac699..d3b350e7 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/BlockPlaceData.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/BlockPlaceData.java @@ -1,13 +1,20 @@ package cc.co.evenprime.bukkit.nocheat.data; +import java.util.Map; + /** * */ public class BlockPlaceData extends Data { public double reachVL = 0.0D; - public final ExecutionHistory history = new ExecutionHistory(); + public double reachTotalVL = 0.0D; + public int reachFailed = 0; public double directionVL = 0.0D; + public double directionTotalVL = 0.0D; + public int directionFailed = 0; + + public final ExecutionHistory history = new ExecutionHistory(); public long directionLastViolationTime = 0; public final SimpleLocation blockPlacedAgainst = new SimpleLocation(); @@ -19,4 +26,12 @@ public class BlockPlaceData extends Data { blockPlaced.reset(); directionLastViolationTime = 0; } + + @Override + public void collectData(Map map) { + map.put("blockplace.reach.vl", (int) reachTotalVL); + map.put("blockplace.direction.vl", (int) directionTotalVL); + map.put("blockplace.reach.failed", reachFailed); + map.put("blockplace.direction.failed", directionFailed); + } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/ChatData.java b/src/cc/co/evenprime/bukkit/nocheat/data/ChatData.java index 77540db9..1db8044d 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/ChatData.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/ChatData.java @@ -1,14 +1,29 @@ package cc.co.evenprime.bukkit.nocheat.data; +import java.util.Map; + /** * */ public class ChatData extends Data { + public int spamVL; + public int spamTotalVL; + public int spamFailed; + public int emptyVL; + public int emptyTotalVL; + public int emptyFailed; + public int messageCount = 0; public int spamLasttime = 0; public final ExecutionHistory history = new ExecutionHistory(); public String message = ""; - public int spamVL; - public int emptyVL; + + @Override + public void collectData(Map map) { + map.put("chat.spam.vl", (int) spamTotalVL); + map.put("chat.empty.vl", (int) emptyTotalVL); + map.put("chat.spam.failed", spamFailed); + map.put("chat.empty.failed", emptyFailed); + } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/Data.java b/src/cc/co/evenprime/bukkit/nocheat/data/Data.java index 8ebfb93f..4cd486da 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/Data.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/Data.java @@ -1,5 +1,7 @@ package cc.co.evenprime.bukkit.nocheat.data; +import java.util.Map; + /** * * Every class that is extending this has to implement an empty Constructor() @@ -10,4 +12,6 @@ public abstract class Data { public void clearCriticalData() { } + + public abstract void collectData(Map map); } diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/FightData.java b/src/cc/co/evenprime/bukkit/nocheat/data/FightData.java index 1c946b8e..f9dffeb9 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/FightData.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/FightData.java @@ -1,15 +1,34 @@ package cc.co.evenprime.bukkit.nocheat.data; +import java.util.Map; + import net.minecraft.server.Entity; public class FightData extends Data { - public double directionVL = 0; + public double directionVL = 0.0D; + public double directionTotalVL = 0.0D; + public int directionFailed = 0; + public double selfhitVL = 0.0D; + public double selfhitTotalVL = 0.0D; + public int selfhitFailed = 0; + public double noswingVL = 0.0D; + public double noswingTotalVL = 0.0D; + public int noswingFailed = 0; + public long directionLastViolationTime = 0; public final ExecutionHistory history = new ExecutionHistory(); - public double selfhitVL = 0; - public double noswingVL = 0.0D; + public Entity damagee; public boolean armswung = true; + @Override + public void collectData(Map map) { + map.put("fight.direction.vl", (int)directionTotalVL); + map.put("fight.selfhit.vl", (int)selfhitTotalVL); + map.put("fight.noswing.vl", (int)noswingTotalVL); + map.put("fight.direction.failed", directionFailed); + map.put("fight.selfhit.failed", selfhitFailed); + map.put("fight.noswing.failed", noswingFailed); + } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java b/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java index 58a19a6f..a582b508 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java @@ -1,23 +1,34 @@ package cc.co.evenprime.bukkit.nocheat.data; +import java.util.Map; + /** * Player specific data for the moving check group */ public class MovingData extends Data { + public double runflyVL; + public double runflyTotalVL; + public int runflyFailed; + + public double nofallVL; + public double nofallTotalVL; + public int nofallFailed; + + public double morePacketsVL; + public double morePacketsTotalVL; + public int morePacketsFailed; + public int jumpPhase; public final PreciseLocation runflySetBackPoint = new PreciseLocation(); - public double runflyVL; - public double vertFreedom; public double vertVelocity; public int vertVelocityCounter; public double horizFreedom; public int horizVelocityCounter; - public double nofallVL; public float fallDistance; public float lastAddedFallDistance; @@ -29,7 +40,6 @@ public class MovingData extends Data { public int packets; public final PreciseLocation morePacketsSetbackPoint = new PreciseLocation(); - public double morePacketsVL; public final PreciseLocation teleportTo = new PreciseLocation(); @@ -58,4 +68,14 @@ public class MovingData extends Data { lastElapsedIngameSeconds = 0; morePacketsCounter = 0; } + + @Override + public void collectData(Map map) { + map.put("moving.runfly.vl", (int) runflyTotalVL); + map.put("moving.nofall.vl", (int) nofallTotalVL); + map.put("moving.morepackets.vl", (int) morePacketsTotalVL); + map.put("moving.runfly.failed", runflyFailed); + map.put("moving.nofall.failed", nofallFailed); + map.put("moving.morepackets.failed", morePacketsFailed); + } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/PlayerManager.java b/src/cc/co/evenprime/bukkit/nocheat/data/PlayerManager.java index 2d252825..e32cd183 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/PlayerManager.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/PlayerManager.java @@ -78,4 +78,15 @@ public class PlayerManager { } } + public void getPlayerData(String playerName, Map map) { + + NoCheatPlayer player = this.players.get(playerName); + + if(player != null) { + BaseData data = player.getData(); + + data.collectData(map); + } + } + } diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/TimedData.java b/src/cc/co/evenprime/bukkit/nocheat/data/TimedData.java deleted file mode 100644 index d732aeb9..00000000 --- a/src/cc/co/evenprime/bukkit/nocheat/data/TimedData.java +++ /dev/null @@ -1,17 +0,0 @@ -package cc.co.evenprime.bukkit.nocheat.data; - -public class TimedData extends Data { - - public int ticksLived; - public int ticksBehind; - public double godmodeVL; - public final ExecutionHistory history = new ExecutionHistory(); ; - - public TimedData() {} - - @Override - public void clearCriticalData() { - ticksBehind = 0; - ticksLived = 0; - } -}