mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 14:38:46 +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)
|
public void handleLog(CommandSender cs, String [] args)
|
||||||
{
|
{
|
||||||
if(cs.hasPermission("system.log"))
|
if(Permissions.SYSTEM_LOG.get(cs))
|
||||||
{
|
{
|
||||||
if(args[1].equalsIgnoreCase("enable"))
|
if(args[1].equalsIgnoreCase("enable"))
|
||||||
{
|
{
|
||||||
@@ -95,7 +95,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
|
|
||||||
public void handleXRay(CommandSender cs, String [] args)
|
public void handleXRay(CommandSender cs, String [] args)
|
||||||
{
|
{
|
||||||
if(cs.hasPermission("system.xray"))
|
if(Permissions.SYSTEM_XRAY.get(cs))
|
||||||
{
|
{
|
||||||
if(config.logXRay())
|
if(config.logXRay())
|
||||||
{
|
{
|
||||||
@@ -140,7 +140,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
|
|
||||||
public void handleReset(CommandSender cs, String [] args)
|
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]);
|
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||||
if(list.size() == 1)
|
if(list.size() == 1)
|
||||||
@@ -178,7 +178,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
if(cs instanceof Player)
|
if(cs instanceof Player)
|
||||||
{
|
{
|
||||||
Player sender = (Player)cs;
|
Player sender = (Player)cs;
|
||||||
if(cs.hasPermission("system.spy"))
|
if(Permissions.SYSTEM_SPY.get(cs))
|
||||||
{
|
{
|
||||||
if(!args[1].equalsIgnoreCase("off"))
|
if(!args[1].equalsIgnoreCase("off"))
|
||||||
{
|
{
|
||||||
@@ -234,7 +234,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
|
|
||||||
public void handleHelp(CommandSender cs)
|
public void handleHelp(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(cs.hasPermission("system.help"))
|
if(Permissions.SYSTEM_HELP.get(cs))
|
||||||
{
|
{
|
||||||
String base = "/AntiCheat ";
|
String base = "/AntiCheat ";
|
||||||
cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------");
|
cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------");
|
||||||
@@ -257,7 +257,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
|
|
||||||
public void handleUpdate(CommandSender cs)
|
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("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion());
|
||||||
cs.sendMessage("-----------------------------------------------------");
|
cs.sendMessage("-----------------------------------------------------");
|
||||||
@@ -287,7 +287,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
|
|
||||||
public void handleReport(CommandSender cs)
|
public void handleReport(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(cs.hasPermission("system.report"))
|
if(Permissions.SYSTEM_REPORT.get(cs))
|
||||||
{
|
{
|
||||||
getPlayers();
|
getPlayers();
|
||||||
if(!low.isEmpty())
|
if(!low.isEmpty())
|
||||||
@@ -323,7 +323,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
|
|
||||||
public void handlePlayerReport(CommandSender cs,String [] args)
|
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]);
|
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||||
if(list.size() == 1)
|
if(list.size() == 1)
|
||||||
@@ -437,7 +437,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
|
|
||||||
public void handleReload(CommandSender cs)
|
public void handleReload(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(cs.hasPermission("system.reload"))
|
if(Permissions.SYSTEM_RELOAD.get(cs))
|
||||||
{
|
{
|
||||||
config.load();
|
config.load();
|
||||||
cs.sendMessage(GREEN+"AntiCheat configuration reloaded.");
|
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)
|
public boolean willCheck(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
return chk.willCheck(player, type);
|
return chk.willCheck(player, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
//PlayerManager API
|
//PlayerManager API
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class CheckManager
|
|||||||
return isActive(type)
|
return isActive(type)
|
||||||
&& manager.getConfiguration().checkInWorld(player.getWorld())
|
&& manager.getConfiguration().checkInWorld(player.getWorld())
|
||||||
&& !isExempt(player, type)
|
&& !isExempt(player, type)
|
||||||
&& !player.hasPermission(type.getPermission());
|
&& !type.checkPermission(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExempt()
|
public int getExempt()
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ package net.h31ix.anticheat.manage;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.h31ix.anticheat.Permissions;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
@@ -31,40 +34,40 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public enum CheckType
|
public enum CheckType
|
||||||
{
|
{
|
||||||
ZOMBE_FLY("anticheat.zombe.fly"),
|
ZOMBE_FLY(Permissions.ZOMBE_FLY),
|
||||||
ZOMBE_NOCLIP("anticheat.zombe.noclip"),
|
ZOMBE_NOCLIP(Permissions.ZOMBE_NOCLIP),
|
||||||
ZOMBE_CHEAT("anticheat.zombe.cheat"),
|
ZOMBE_CHEAT(Permissions.ZOMBE_CHEAT),
|
||||||
FLY("anticheat.fly"),
|
FLY(Permissions.FLY),
|
||||||
WATER_WALK("anticheat.waterwalk"),
|
WATER_WALK(Permissions.WATER_WALK),
|
||||||
NO_SWING("anticheat.noswing"),
|
NO_SWING(Permissions.NO_SWING),
|
||||||
FAST_BREAK("anticheat.fastbreak"),
|
FAST_BREAK(Permissions.FAST_BREAK),
|
||||||
FAST_PLACE("anticheat.fastplace"),
|
FAST_PLACE(Permissions.FAST_PLACE),
|
||||||
SPAM("anticheat.spam"),
|
SPAM(Permissions.SPAM),
|
||||||
SPRINT("anticheat.sprint"),
|
SPRINT(Permissions.SPRINT),
|
||||||
SNEAK("anticheat.sneak"),
|
SNEAK(Permissions.SNEAK),
|
||||||
SPEED("anticheat.speed"),
|
SPEED(Permissions.SPEED),
|
||||||
SPIDER("anticheat.spider"),
|
SPIDER(Permissions.SPIDER),
|
||||||
NOFALL("anticheat.nofall"),
|
NOFALL(Permissions.NOFALL),
|
||||||
FAST_BOW("anticheat.fastbow"),
|
FAST_BOW(Permissions.FAST_BOW),
|
||||||
FAST_EAT("anticheat.fasteat"),
|
FAST_EAT(Permissions.FAST_EAT),
|
||||||
FAST_HEAL("anticheat.fastheal"),
|
FAST_HEAL(Permissions.FAST_HEAL),
|
||||||
FORCEFIELD("anticheat.forcefield"),
|
FORCEFIELD(Permissions.FORCEFIELD),
|
||||||
XRAY("anticheat.xray"),
|
XRAY(Permissions.XRAY),
|
||||||
LONG_REACH("anticheat.longreach"),
|
LONG_REACH(Permissions.LONG_REACH),
|
||||||
FAST_PROJECTILE("anticheat.projectile"),
|
FAST_PROJECTILE(Permissions.FAST_PROJECTILE),
|
||||||
ITEM_SPAM("anticheat.itemspam");
|
ITEM_SPAM(Permissions.ITEM_SPAM);
|
||||||
|
|
||||||
private final String permission;
|
private final Permissions permission;
|
||||||
private final Map<String,Integer> level = new HashMap<String,Integer>();
|
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)
|
public void logUse(Player player)
|
||||||
|
|||||||
Reference in new issue
Block a user