Merge branch 'master' of ZeroHD/QoL into master
commit
9ec2f05087
|
@ -18,6 +18,7 @@ import org.dynmap.DynmapAPI;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
public class CommandPreprocessListener implements Listener {
|
public class CommandPreprocessListener implements Listener {
|
||||||
|
|
||||||
|
@ -34,7 +35,6 @@ public class CommandPreprocessListener implements Listener {
|
||||||
|
|
||||||
String command = event.getMessage();
|
String command = event.getMessage();
|
||||||
String base = command.split(" ")[0].substring(1).toLowerCase(); // Strip the slash
|
String base = command.split(" ")[0].substring(1).toLowerCase(); // Strip the slash
|
||||||
String auditBypassPerm = "qol.audit.bypass." + base;
|
|
||||||
|
|
||||||
Player sender = event.getPlayer();
|
Player sender = event.getPlayer();
|
||||||
DynmapAPI dynmap = plugin.getDynmap();
|
DynmapAPI dynmap = plugin.getDynmap();
|
||||||
|
@ -79,7 +79,10 @@ public class CommandPreprocessListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command Auditing
|
// Command Auditing
|
||||||
if (sender.hasPermission("qol.audit") && !sender.hasPermission(auditBypassPerm) && plugin.getConfig().getBoolean("audit.enabled")) {
|
if (sender.hasPermission("qol.auditable") && plugin.getConfig().getBoolean("audit.enabled")) {
|
||||||
|
if (sender.hasPermission("qol.auditor") && targetIsAuditable(command)) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
boolean auditable = false;
|
boolean auditable = false;
|
||||||
|
|
||||||
for (String audit : QoL.getAudits()) {
|
for (String audit : QoL.getAudits()) {
|
||||||
|
@ -101,6 +104,7 @@ public class CommandPreprocessListener implements Listener {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Links
|
// Links
|
||||||
for (LinkCommand linkCommand : QoL.getLinks()) {
|
for (LinkCommand linkCommand : QoL.getLinks()) {
|
||||||
|
@ -115,6 +119,23 @@ public class CommandPreprocessListener implements Listener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean targetIsAuditable(String command) {
|
||||||
|
String[] commandSplit = command.split(" ");
|
||||||
|
Collection<? extends Player> players = plugin.getServer().getOnlinePlayers();
|
||||||
|
|
||||||
|
for (String param : commandSplit) {
|
||||||
|
String lowerCaseParam = param.toLowerCase();
|
||||||
|
for (Player p : players) {
|
||||||
|
|
||||||
|
if (p.getName().toLowerCase().equals(lowerCaseParam)) {
|
||||||
|
return p.hasPermission("qol.auditable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public String noSlash(String command) {
|
public String noSlash(String command) {
|
||||||
return command.startsWith("/") ? command.substring(1) : command;
|
return command.startsWith("/") ? command.substring(1) : command;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,10 @@ permissions:
|
||||||
qol.shadowmute:
|
qol.shadowmute:
|
||||||
description: Ability to use the Shadow Mute command
|
description: Ability to use the Shadow Mute command
|
||||||
default: op
|
default: op
|
||||||
qol.audit:
|
qol.auditable:
|
||||||
|
description: Audits command usage
|
||||||
|
default: op
|
||||||
|
qol.auditor:
|
||||||
description: Audits command usage
|
description: Audits command usage
|
||||||
default: op
|
default: op
|
||||||
qol.tpconfirm:
|
qol.tpconfirm:
|
||||||
|
|
Loading…
Reference in New Issue