diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/BlockPlaceCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/BlockPlaceCheck.java index e2ba2681..0394f441 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/BlockPlaceCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/BlockPlaceCheck.java @@ -30,9 +30,7 @@ public abstract class BlockPlaceCheck extends Check { @Override public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case PLACE_LOCATION: { + if(wildcard == ParameterName.PLACE_LOCATION) { SimpleLocation l = player.getData().blockplace.blockPlaced; if(l.isSet()) { return String.format(Locale.US, "%d %d %d", l.x, l.y, l.z); @@ -41,7 +39,7 @@ public abstract class BlockPlaceCheck extends Check { } } - case PLACE_AGAINST: { + else if(wildcard == ParameterName.PLACE_AGAINST) { SimpleLocation l = player.getData().blockplace.blockPlacedAgainst; if(l.isSet()) { return String.format(Locale.US, "%d %d %d", l.x, l.y, l.z); @@ -50,8 +48,7 @@ public abstract class BlockPlaceCheck extends Check { } } - default: + else return super.getParameter(wildcard, player); - } } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/ChatCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/ChatCheck.java index b6f40cc8..a6c44f74 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/ChatCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/ChatCheck.java @@ -24,14 +24,10 @@ public abstract class ChatCheck extends Check { @Override public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - case TEXT: { + if(wildcard == ParameterName.TEXT) return player.getData().chat.message; - } - - default: + else return super.getParameter(wildcard, player); - } } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/Check.java b/src/cc/co/evenprime/bukkit/nocheat/checks/Check.java index 77d4bed9..343d715e 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/Check.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/Check.java @@ -10,8 +10,8 @@ import cc.co.evenprime.bukkit.nocheat.actions.types.Action; import cc.co.evenprime.bukkit.nocheat.actions.types.ConsolecommandAction; import cc.co.evenprime.bukkit.nocheat.actions.types.DummyAction; import cc.co.evenprime.bukkit.nocheat.actions.types.LogAction; -import cc.co.evenprime.bukkit.nocheat.actions.types.SpecialAction; import cc.co.evenprime.bukkit.nocheat.actions.types.ParameterName; +import cc.co.evenprime.bukkit.nocheat.actions.types.SpecialAction; import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache; import cc.co.evenprime.bukkit.nocheat.data.ExecutionHistory; @@ -79,24 +79,17 @@ public abstract class Check { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - case PLAYER: + if(wildcard == ParameterName.PLAYER) return player.getName(); - - case CHECK: + else if(wildcard == ParameterName.CHECK) return getName(); - - case LOCATION: { + else if(wildcard == ParameterName.LOCATION) { Location l = player.getPlayer().getLocation(); return String.format(Locale.US, "%.2f,%.2f,%.2f", l.getX(), l.getY(), l.getZ()); - } - - case WORLD: { + } else if(wildcard == ParameterName.WORLD) return player.getPlayer().getWorld().getName(); - } - - default: + else return "Evenprime was lazy and forgot to define " + wildcard + "."; - } + } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java index 1b06020a..a230a885 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java @@ -34,25 +34,18 @@ public abstract class MovingCheck extends Check { @Override public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case LOCATION: { + if(wildcard == ParameterName.LOCATION) { PreciseLocation from = player.getData().moving.from; return String.format(Locale.US, "%.2f,%.2f,%.2f", from.x, from.y, from.z); - } - - case MOVEDISTANCE: { + } else if(wildcard == ParameterName.MOVEDISTANCE) { PreciseLocation from = player.getData().moving.from; PreciseLocation to = player.getData().moving.to; return String.format(Locale.US, "%.2f,%.2f,%.2f", to.x - from.x, to.y - from.y, to.z - from.z); - } - - case LOCATION_TO: + } else if(wildcard == ParameterName.LOCATION_TO) { PreciseLocation to = player.getData().moving.to; return String.format(Locale.US, "%.2f,%.2f,%.2f", to.x, to.y, to.z); - - default: + } else return super.getParameter(wildcard, 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 530c0085..e317b8b6 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/DirectionCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/DirectionCheck.java @@ -81,14 +81,9 @@ public class DirectionCheck extends BlockBreakCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().blockbreak.directionVL); - - default: + else return super.getParameter(wildcard, player); - - } } } 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 91c8798b..5606a4a4 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/NoswingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/NoswingCheck.java @@ -41,15 +41,10 @@ public class NoswingCheck extends BlockBreakCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().blockbreak.noswingVL); - - default: + else return super.getParameter(wildcard, player); - - } } } 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 72877a16..012db25d 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockbreak/ReachCheck.java @@ -54,16 +54,11 @@ public class ReachCheck extends BlockBreakCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().blockbreak.reachVL); - - case REACHDISTANCE: + else if(wildcard == ParameterName.REACHDISTANCE) return String.format(Locale.US, "%.2f", player.getData().blockbreak.reachDistance); - - default: + else return super.getParameter(wildcard, player); - } } } 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 769dd073..6785c2b6 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/DirectionCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/DirectionCheck.java @@ -95,13 +95,9 @@ public class DirectionCheck extends BlockPlaceCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().blockplace.directionVL); - - default: + else return super.getParameter(wildcard, player); - } } } 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 1c80651e..33e935f1 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/ReachCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/blockplace/ReachCheck.java @@ -55,16 +55,11 @@ public class ReachCheck extends BlockPlaceCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().blockplace.reachVL); - - case REACHDISTANCE: + else if(wildcard == ParameterName.REACHDISTANCE) return String.format(Locale.US, "%.2f", player.getData().blockplace.reachdistance); - - default: + else return super.getParameter(wildcard, player); - } } } 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 5007e580..314145c2 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/chat/EmptyCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/chat/EmptyCheck.java @@ -39,12 +39,9 @@ public class EmptyCheck extends ChatCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", player.getData().chat.emptyVL); - default: + else return super.getParameter(wildcard, player); - } } } 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 e0f2b34f..69ab15c6 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/chat/SpamCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/chat/SpamCheck.java @@ -55,12 +55,9 @@ public class SpamCheck extends ChatCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", player.getData().chat.spamVL); - default: + else return super.getParameter(wildcard, player); - } } } 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 0a172ba0..dc3c2e10 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/DirectionCheck.java @@ -77,12 +77,9 @@ public class DirectionCheck extends FightCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().fight.directionVL); - default: + else return super.getParameter(wildcard, player); - } } } 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 f119dcd8..8f2a48cc 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/NoswingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/NoswingCheck.java @@ -42,12 +42,9 @@ public class NoswingCheck extends FightCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().fight.noswingVL); - default: + else return super.getParameter(wildcard, player); - } } } 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 bf1dcf64..ebab3909 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/fight/SelfhitCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/fight/SelfhitCheck.java @@ -42,12 +42,9 @@ public class SelfhitCheck extends FightCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().fight.selfhitVL); - default: + else return super.getParameter(wildcard, player); - } } } 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 57afd7cd..2f068e8c 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/FlyingCheck.java @@ -69,10 +69,10 @@ public class FlyingCheck extends MovingCheck { } resultHoriz *= 100; - + // super simple, just check distance compared to max distance resultVert = Math.max(0.0D, yDistance - data.vertFreedom - ccmoving.flyingSpeedLimitVertical) * 100; - + result = resultHoriz + resultVert; if(result > 0) { @@ -83,7 +83,7 @@ public class FlyingCheck extends MovingCheck { data.runflyRunningTotalVL += resultHoriz; data.runflyRunningFailed++; } - + if(resultVert > 0) { data.runflyFlyingTotalVL += resultVert; data.runflyFlyingFailed++; @@ -115,12 +115,9 @@ public class FlyingCheck extends MovingCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().moving.runflyVL); - default: + else return super.getParameter(wildcard, player); - } } } 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 a21b591c..101dff11 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/MorePacketsCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/MorePacketsCheck.java @@ -109,13 +109,11 @@ public class MorePacketsCheck extends MovingCheck { @Override public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().moving.morePacketsVL); - case PACKETS: + else if(wildcard == ParameterName.PACKETS) return String.valueOf(player.getData().moving.packets); - default: + else return super.getParameter(wildcard, player); - } } } 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 d7d20afc..29b8f3b4 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/NoFallCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/NoFallCheck.java @@ -106,13 +106,11 @@ public class NoFallCheck extends MovingCheck { @Override public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - case VIOLATIONS: + if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().moving.nofallVL); - case FALLDISTANCE: + else if(wildcard == ParameterName.FALLDISTANCE) return String.format(Locale.US, "%.2f", player.getData().moving.fallDistance); - default: + else return super.getParameter(wildcard, player); - } } } 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 6dea2c54..85778315 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunningCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/moving/RunningCheck.java @@ -228,15 +228,12 @@ public class RunningCheck extends MovingCheck { public String getParameter(ParameterName wildcard, NoCheatPlayer player) { - switch (wildcard) { - - case CHECK: + if(wildcard == ParameterName.CHECK) // Workaround for something until I find a better way to do it return getName() + "." + player.getData().moving.checknamesuffix; - case VIOLATIONS: + else if(wildcard == ParameterName.VIOLATIONS) return String.format(Locale.US, "%d", (int) player.getData().moving.runflyVL); - default: + else return super.getParameter(wildcard, player); - } } }