mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Rewrote Permissions to make our lives that easier.
This commit is contained in:
1 parent
e96e99b87d
commit
618f63b0a0
5 files changed
+120
-38
No files matched your search
@@ -56,7 +56,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleLog(CommandSender cs, String [] args)
|
||||
{
|
||||
if(cs.hasPermission("system.log"))
|
||||
if(Permissions.SYSTEM_LOG.get(cs))
|
||||
{
|
||||
if(args[1].equalsIgnoreCase("enable"))
|
||||
{
|
||||
@@ -95,7 +95,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleXRay(CommandSender cs, String [] args)
|
||||
{
|
||||
if(cs.hasPermission("system.xray"))
|
||||
if(Permissions.SYSTEM_XRAY.get(cs))
|
||||
{
|
||||
if(config.logXRay())
|
||||
{
|
||||
@@ -140,7 +140,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleReset(CommandSender cs, String [] args)
|
||||
{
|
||||
if(cs.hasPermission("system.reset"))
|
||||
if(Permissions.SYSTEM_RESET.get(cs))
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
@@ -178,7 +178,7 @@ public class CommandHandler implements CommandExecutor
|
||||
if(cs instanceof Player)
|
||||
{
|
||||
Player sender = (Player)cs;
|
||||
if(cs.hasPermission("system.spy"))
|
||||
if(Permissions.SYSTEM_SPY.get(cs))
|
||||
{
|
||||
if(!args[1].equalsIgnoreCase("off"))
|
||||
{
|
||||
@@ -234,7 +234,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleHelp(CommandSender cs)
|
||||
{
|
||||
if(cs.hasPermission("system.help"))
|
||||
if(Permissions.SYSTEM_HELP.get(cs))
|
||||
{
|
||||
String base = "/AntiCheat ";
|
||||
cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------");
|
||||
@@ -257,7 +257,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleUpdate(CommandSender cs)
|
||||
{
|
||||
if(cs.hasPermission("system.update"))
|
||||
if(Permissions.SYSTEM_UPDATE.get(cs))
|
||||
{
|
||||
cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion());
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
@@ -287,7 +287,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleReport(CommandSender cs)
|
||||
{
|
||||
if(cs.hasPermission("system.report"))
|
||||
if(Permissions.SYSTEM_REPORT.get(cs))
|
||||
{
|
||||
getPlayers();
|
||||
if(!low.isEmpty())
|
||||
@@ -323,7 +323,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handlePlayerReport(CommandSender cs,String [] args)
|
||||
{
|
||||
if(cs.hasPermission("system.report"))
|
||||
if(Permissions.SYSTEM_REPORT.get(cs))
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
@@ -437,7 +437,7 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleReload(CommandSender cs)
|
||||
{
|
||||
if(cs.hasPermission("system.reload"))
|
||||
if(Permissions.SYSTEM_RELOAD.get(cs))
|
||||
{
|
||||
config.load();
|
||||
cs.sendMessage(GREEN+"AntiCheat configuration reloaded.");
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public enum Permissions {
|
||||
|
||||
/* Check Nodes */
|
||||
ZOMBE_FLY("zombe.fly", true),
|
||||
ZOMBE_NOCLIP("zombe.noclip", true),
|
||||
ZOMBE_CHEAT("zombe.chest", true),
|
||||
FLY("", true),
|
||||
WATER_WALK("", true),
|
||||
NO_SWING("", true),
|
||||
FAST_BREAK("", true),
|
||||
FAST_PLACE("", true),
|
||||
SPAM("", true),
|
||||
SPRINT("", true),
|
||||
SNEAK("", true),
|
||||
SPEED("", true),
|
||||
SPIDER("", true),
|
||||
NOFALL("", true),
|
||||
FAST_BOW("", true),
|
||||
FAST_EAT("", true),
|
||||
FAST_HEAL("", true),
|
||||
FORCEFIELD("", true),
|
||||
XRAY("", true),
|
||||
LONG_REACH("", true),
|
||||
FAST_PROJECTILE("", true),
|
||||
ITEM_SPAM("", true),
|
||||
|
||||
/* System Nodes */
|
||||
SYSTEM_LOG("system.log", false),
|
||||
SYSTEM_XRAY("system.xray", false),
|
||||
SYSTEM_RESET("system.reset", false),
|
||||
SYSTEM_SPY("system.spy", false),
|
||||
SYSTEM_HELP("system.help", false),
|
||||
SYSTEM_UPDATE("system.update", false),
|
||||
SYSTEM_REPORT("system.report", false),
|
||||
SYSTEM_RELOAD("system.reload", false);
|
||||
|
||||
|
||||
String permnode = "";
|
||||
boolean isCheckType;
|
||||
Permissions(String node, boolean isCheckTypeNode)
|
||||
{
|
||||
permnode = node;
|
||||
isCheckType = isCheckTypeNode;
|
||||
}
|
||||
|
||||
public boolean get(CommandSender player)
|
||||
{
|
||||
return getPermission(player);
|
||||
}
|
||||
|
||||
public boolean getPermission(CommandSender player)
|
||||
{
|
||||
return player.hasPermission(parsePermissionNode());
|
||||
}
|
||||
|
||||
private String parsePermissionNode()
|
||||
{
|
||||
if(!isCheckType)
|
||||
{
|
||||
return "anticheat." + permnode;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "anticheat.checks." + parseEnum();
|
||||
}
|
||||
}
|
||||
|
||||
private String parseEnum()
|
||||
{
|
||||
return this.name().toLowerCase().replace("_", "");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class AnticheatAPI
|
||||
*/
|
||||
public boolean willCheck(Player player, CheckType type)
|
||||
{
|
||||
return chk.willCheck(player, type);
|
||||
return chk.willCheck(player, type);
|
||||
}
|
||||
|
||||
//PlayerManager API
|
||||
|
||||
@@ -89,7 +89,7 @@ public class CheckManager
|
||||
return isActive(type)
|
||||
&& manager.getConfiguration().checkInWorld(player.getWorld())
|
||||
&& !isExempt(player, type)
|
||||
&& !player.hasPermission(type.getPermission());
|
||||
&& !type.checkPermission(player);
|
||||
}
|
||||
|
||||
public int getExempt()
|
||||
|
||||
@@ -20,6 +20,9 @@ package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.h31ix.anticheat.Permissions;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -31,40 +34,40 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public enum CheckType
|
||||
{
|
||||
ZOMBE_FLY("anticheat.zombe.fly"),
|
||||
ZOMBE_NOCLIP("anticheat.zombe.noclip"),
|
||||
ZOMBE_CHEAT("anticheat.zombe.cheat"),
|
||||
FLY("anticheat.fly"),
|
||||
WATER_WALK("anticheat.waterwalk"),
|
||||
NO_SWING("anticheat.noswing"),
|
||||
FAST_BREAK("anticheat.fastbreak"),
|
||||
FAST_PLACE("anticheat.fastplace"),
|
||||
SPAM("anticheat.spam"),
|
||||
SPRINT("anticheat.sprint"),
|
||||
SNEAK("anticheat.sneak"),
|
||||
SPEED("anticheat.speed"),
|
||||
SPIDER("anticheat.spider"),
|
||||
NOFALL("anticheat.nofall"),
|
||||
FAST_BOW("anticheat.fastbow"),
|
||||
FAST_EAT("anticheat.fasteat"),
|
||||
FAST_HEAL("anticheat.fastheal"),
|
||||
FORCEFIELD("anticheat.forcefield"),
|
||||
XRAY("anticheat.xray"),
|
||||
LONG_REACH("anticheat.longreach"),
|
||||
FAST_PROJECTILE("anticheat.projectile"),
|
||||
ITEM_SPAM("anticheat.itemspam");
|
||||
ZOMBE_FLY(Permissions.ZOMBE_FLY),
|
||||
ZOMBE_NOCLIP(Permissions.ZOMBE_NOCLIP),
|
||||
ZOMBE_CHEAT(Permissions.ZOMBE_CHEAT),
|
||||
FLY(Permissions.FLY),
|
||||
WATER_WALK(Permissions.WATER_WALK),
|
||||
NO_SWING(Permissions.NO_SWING),
|
||||
FAST_BREAK(Permissions.FAST_BREAK),
|
||||
FAST_PLACE(Permissions.FAST_PLACE),
|
||||
SPAM(Permissions.SPAM),
|
||||
SPRINT(Permissions.SPRINT),
|
||||
SNEAK(Permissions.SNEAK),
|
||||
SPEED(Permissions.SPEED),
|
||||
SPIDER(Permissions.SPIDER),
|
||||
NOFALL(Permissions.NOFALL),
|
||||
FAST_BOW(Permissions.FAST_BOW),
|
||||
FAST_EAT(Permissions.FAST_EAT),
|
||||
FAST_HEAL(Permissions.FAST_HEAL),
|
||||
FORCEFIELD(Permissions.FORCEFIELD),
|
||||
XRAY(Permissions.XRAY),
|
||||
LONG_REACH(Permissions.LONG_REACH),
|
||||
FAST_PROJECTILE(Permissions.FAST_PROJECTILE),
|
||||
ITEM_SPAM(Permissions.ITEM_SPAM);
|
||||
|
||||
private final String permission;
|
||||
private final Permissions permission;
|
||||
private final Map<String,Integer> level = new HashMap<String,Integer>();
|
||||
|
||||
private CheckType(String permission)
|
||||
private CheckType(Permissions perm)
|
||||
{
|
||||
this.permission = permission;
|
||||
this.permission = perm;
|
||||
}
|
||||
|
||||
public String getPermission()
|
||||
public boolean checkPermission(Player player)
|
||||
{
|
||||
return this.permission;
|
||||
return permission.get(player);
|
||||
}
|
||||
|
||||
public void logUse(Player player)
|
||||
|
||||
Reference in new issue
Block a user