diff --git a/src/main/java/net/h31ix/anticheat/CommandHandler.java b/src/main/java/net/h31ix/anticheat/CommandHandler.java index 7931a93..89b05d9 100644 --- a/src/main/java/net/h31ix/anticheat/CommandHandler.java +++ b/src/main/java/net/h31ix/anticheat/CommandHandler.java @@ -52,13 +52,11 @@ public class CommandHandler implements CommandExecutor private static final Server SERVER = Bukkit.getServer(); private static final int MED_THRESHOLD = 20; private static final int HIGH_THRESHOLD = 50; - private static final String ADMIN_PERM = "anticheat.admin"; - private static final String MOD_PERM = "anticheat.mod"; private static final String PERMISSIONS_ERROR = RED+"Insufficient Permissions."; public void handleLog(CommandSender cs, String [] args) { - if(hasPermission(cs,"system.log") || hasPermission(cs,ADMIN_PERM)) + if(cs.hasPermission("system.log")) { if(args[1].equalsIgnoreCase("enable")) { @@ -97,7 +95,7 @@ public class CommandHandler implements CommandExecutor public void handleXRay(CommandSender cs, String [] args) { - if(hasPermission(cs,"system.xray") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM)) + if(cs.hasPermission("system.xray")) { if(config.logXRay()) { @@ -142,7 +140,7 @@ public class CommandHandler implements CommandExecutor public void handleReset(CommandSender cs, String [] args) { - if(hasPermission(cs,"system.reset") || hasPermission(cs,ADMIN_PERM)) + if(cs.hasPermission("system.reset")) { List list = SERVER.matchPlayer(args[1]); if(list.size() == 1) @@ -180,7 +178,7 @@ public class CommandHandler implements CommandExecutor if(cs instanceof Player) { Player sender = (Player)cs; - if(hasPermission(cs,"system.spy") || hasPermission(cs,MOD_PERM)) + if(cs.hasPermission("system.spy")) { if(!args[1].equalsIgnoreCase("off")) { @@ -236,7 +234,7 @@ public class CommandHandler implements CommandExecutor public void handleHelp(CommandSender cs) { - if(hasPermission(cs,"system.help") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM)) + if(cs.hasPermission("system.help")) { String base = "/AntiCheat "; cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------"); @@ -259,7 +257,7 @@ public class CommandHandler implements CommandExecutor public void handleUpdate(CommandSender cs) { - if(hasPermission(cs,"system.update") || hasPermission(cs,ADMIN_PERM)) + if(cs.hasPermission("system.update")) { cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion()); cs.sendMessage("-----------------------------------------------------"); @@ -289,7 +287,7 @@ public class CommandHandler implements CommandExecutor public void handleReport(CommandSender cs) { - if(hasPermission(cs,"system.report") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM)) + if(cs.hasPermission("system.report")) { getPlayers(); if(!low.isEmpty()) @@ -325,7 +323,7 @@ public class CommandHandler implements CommandExecutor public void handlePlayerReport(CommandSender cs,String [] args) { - if(hasPermission(cs,"system.report") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM)) + if(cs.hasPermission("system.report")) { List list = SERVER.matchPlayer(args[1]); if(list.size() == 1) @@ -439,7 +437,7 @@ public class CommandHandler implements CommandExecutor public void handleReload(CommandSender cs) { - if(hasPermission(cs,"system.reload") || hasPermission(cs,ADMIN_PERM)) + if(cs.hasPermission("system.reload")) { config.load(); cs.sendMessage(GREEN+"AntiCheat configuration reloaded."); @@ -517,17 +515,6 @@ public class CommandHandler implements CommandExecutor return true; } - public boolean hasPermission(CommandSender cs, String permission) - { - if(cs instanceof Player) - { - return ((Player)cs).hasPermission("anticheat."+permission); - } - else - { - return true; - } - } public void getPlayers() { high.clear(); diff --git a/src/main/java/net/h31ix/anticheat/manage/CheckManager.java b/src/main/java/net/h31ix/anticheat/manage/CheckManager.java index 4c6d41b..0e3c816 100644 --- a/src/main/java/net/h31ix/anticheat/manage/CheckManager.java +++ b/src/main/java/net/h31ix/anticheat/manage/CheckManager.java @@ -84,17 +84,12 @@ public class CheckManager return exemptList.containsEntry(player.getName(), type); } - private boolean hasPermission(Player player, String permission) - { - return player.hasPermission(permission) || player.hasPermission("anticheat.exempt"); - } - public boolean willCheck(Player player, CheckType type) { return isActive(type) && manager.getConfiguration().checkInWorld(player.getWorld()) && !isExempt(player, type) - && !hasPermission(player, type.getPermission()); + && !player.hasPermission(type.getPermission()); } public int getExempt() diff --git a/src/main/java/net/h31ix/anticheat/util/Utilities.java b/src/main/java/net/h31ix/anticheat/util/Utilities.java index eedf74b..24f152d 100644 --- a/src/main/java/net/h31ix/anticheat/util/Utilities.java +++ b/src/main/java/net/h31ix/anticheat/util/Utilities.java @@ -40,16 +40,10 @@ public final class Utilities } public static void alert(String [] message) { - for(Player p : Bukkit.getServer().getOnlinePlayers()) + for(String msg : message) { - if(p.hasPermission("anticheat.alert") || p.hasPermission("anticheat.admin") || p.hasPermission("anticheat.mod") || p.isOp()) - { - for(String msg : message) - { - p.sendMessage(msg); - } - } - } + Bukkit.broadcast(msg, "anticheat.alert"); + } if(Anticheat.getManager().getConfiguration().logConsole()) { for(String msg : message) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9572995..4e42b58 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -11,4 +11,131 @@ commands: anticheat: description: Control and view info about AntiCheat usage: /anticheat help - aliases: anti \ No newline at end of file + aliases: anti +permissions: + anticheat.alert: + description: Get alerts + anticheat.system.help: + description: Help access + anticheat.system.report: + description: Reports access + anticheat.system.spy: + description: Spy system access + anticheat.system.xray: + description: XRay info access + anticheat.mod: + description: Mod helper perm + children: + anticheat.alert: true + anticheat.system.help: true + anticheat.system.report: true + anticheat.system.spy: true + anticheat.system.xray: true + anticheat.system.log: + description: Log access + anticheat.system.reload: + description: Reload access + anticheat.system.reset: + description: Reset access + anticheat.system.update: + description: Update access + anticheat.admin: + description: Admin helper perm + children: + anticheat.mod: true + anticheat.system.log: true + anticheat.system.reload: true + anticheat.system.reset: true + anticheat.system.update: true + anticheat.zombe.fly: + description: Allow players to use zombe flymod + default: false + anticheat.zombe.noclip: + description: Allow players to use zombe noclip hack + default: false + anticheat.zombe.cheat: + description: Allow players to use zombe cheat hack + default: false + anticheat.fly: + description: Allow players to fly + default: false + anticheat.waterwalk: + description: Allow players to walk on water + default: false + anticheat.noswing: + description: Allow players to not ever swing their arm + default: false + anticheat.fastbreak: + description: Allow players to quickly break blocks + default: false + anticheat.fastplace: + description: Allow players to use build hacks and fastplace + default: false + anticheat.spam: + description: Allow players to spam the server + default: false + anticheat.sprint: + description: Allow players to sprint when hungry + default: false + anticheat.sneak: + description: Allow players to use auto-sneak + default: false + anticheat.speed: + description: Use this with anticheat.flyhack to allow more speed + default: false + anticheat.spider: + description: Allow players to climb non-climbable surfaces + default: false + anticheat.nofall: + description: Allow players to avoid fall damage + default: false + anticheat.fastbow: + description: Allow players to quickly fire bows + default: false + anticheat.fasteat: + description: Allow players to eat food instantly + default: false + anticheat.fastheal: + description: Allow players to heal up instantly + default: false + anticheat.forcefield: + description: Allow players to use a forcefield + default: false + anticheat.xray: + description: Allow players to bypass xray stats + default: false + anticheat.longreach: + description: Allow players to use longreaching hacks + default: false + anticheat.projectile: + description: Allow players to quickly launch projectiles + default: false + anticheat.itemspam: + description: Allow players to use inventory drop spam hacks + default: false + anticheat.exempt: + description: Total exemption from checks + default: false + children: + anticheat.zombe.fly: true + anticheat.zombe.noclip: true + anticheat.zombe.cheat: true + anticheat.fly: true + anticheat.waterwalk: true + anticheat.noswing: true + anticheat.fastbreak: true + anticheat.fastplace: true + anticheat.spam: true + anticheat.sprint: true + anticheat.sneak: true + anticheat.speed: true + anticheat.spider: true + anticheat.nofall: true + anticheat.fastbow: true + anticheat.fasteat: true + anticheat.fastheal: true + anticheat.forcefield: true + anticheat.xray: true + anticheat.longreach: true + anticheat.projectile: true + anticheat.itemspam: true \ No newline at end of file