mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 14:38:45 +00:00
Redo some permissions code, support anticheat * permission nodes
This commit is contained in:
1 parent
22dafba2b0
commit
e481af55cc
3 files changed
+63
-56
No files matched your search
@@ -75,7 +75,11 @@ public class PastebinReport {
|
||||
|
||||
// alrighty then noobs.
|
||||
for (Permission node : Permission.values()) {
|
||||
report.append(player.getName() + ": " + node.toString() + " " + node.get(player) + '\n');
|
||||
report.append(player.getName() + ": " + node.toString() + " " + node.get(player));
|
||||
if(node.get(player) && !node.whichPermission(player).equals(node.toString())) {
|
||||
report.append(" (Applied by " + node.whichPermission(player) +")");
|
||||
}
|
||||
report.append('\n');
|
||||
}
|
||||
}
|
||||
/* Not working at the moment.
|
||||
@@ -112,6 +116,7 @@ public class PastebinReport {
|
||||
report.append("Max Memory: " + runtime.maxMemory() / 1024 / 1024 + "MB" + '\n');
|
||||
report.append("Total Memory: " + runtime.totalMemory() / 1024 / 1024 + "MB" + '\n');
|
||||
report.append("Server ID + Name: " + Bukkit.getServerId() + " - " + Bukkit.getName() + '\n');
|
||||
report.append("Online Mode: " + String.valueOf(Bukkit.getOnlineMode()).toUpperCase() + '\n');
|
||||
report.append("Players: " + Bukkit.getOnlinePlayers().length + "/" + Bukkit.getMaxPlayers() + '\n');
|
||||
}
|
||||
|
||||
|
||||
@@ -60,16 +60,26 @@ public enum Permission {
|
||||
SYSTEM_REPORT,
|
||||
SYSTEM_ALERT,
|
||||
SYSTEM_CALIBRATE,
|
||||
SYSTEM_DEBUG,
|
||||
SYSTEM_RELOAD;
|
||||
|
||||
private static final String PERMISSION_ALL = "anticheat.*";
|
||||
|
||||
public boolean get(CommandSender cs) {
|
||||
return cs.hasPermission(toString());
|
||||
return cs.hasPermission(toString()) || cs.hasPermission(getBase()) || cs.hasPermission(PERMISSION_ALL);
|
||||
}
|
||||
|
||||
// Now h31ix, I know this is redundant, but this may actually solve the issue.
|
||||
// So please, just give it a try :P
|
||||
public boolean get(Player p) {
|
||||
return p.hasPermission(toString());
|
||||
|
||||
public String getBase() {
|
||||
return "anticheat." + this.name().toLowerCase().split("_")[0] + ".*";
|
||||
}
|
||||
|
||||
public String whichPermission(CommandSender cs) {
|
||||
for(String s : new String[]{toString(), getBase(), PERMISSION_ALL}) {
|
||||
if(cs.hasPermission(s)) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user