mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-12 06:26:57 +00:00
add hidden debug mode
This commit is contained in:
+9
-2
@@ -17,8 +17,15 @@ public class TabCompleteBlockerListener implements Listener {
|
|||||||
Player player = (Player) event.getSender();
|
Player player = (Player) event.getSender();
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
String buffer = event.getBuffer();
|
String buffer = event.getBuffer();
|
||||||
if (!buffer.endsWith(" ") && buffer.split(" ").length == 1) event.setCancelled(true);
|
if (!buffer.endsWith(" ") && buffer.split(" ").length == 1) {
|
||||||
if (event.getCompletions().isEmpty()) return;
|
CommandWhitelistBukkit.getConfigCache().debug("Actively prevented "+event.getSender().getName()+"'s tab completion (/[tab] packet)");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.getCompletions().isEmpty()) {
|
||||||
|
CommandWhitelistBukkit.getConfigCache().debug("Tab completion not provided");
|
||||||
|
return;
|
||||||
|
}
|
||||||
event.setCompletions(
|
event.setCompletions(
|
||||||
CommandUtil.filterSuggestions(
|
CommandUtil.filterSuggestions(
|
||||||
buffer,
|
buffer,
|
||||||
|
|||||||
+18
@@ -17,6 +17,7 @@ public class ConfigCache {
|
|||||||
public String prefix, command_denied, no_permission, no_such_subcommand, config_reloaded, added_to_whitelist,
|
public String prefix, command_denied, no_permission, no_such_subcommand, config_reloaded, added_to_whitelist,
|
||||||
removed_from_whitelist, group_doesnt_exist, subcommand_denied;
|
removed_from_whitelist, group_doesnt_exist, subcommand_denied;
|
||||||
public boolean useProtocolLib = false;
|
public boolean useProtocolLib = false;
|
||||||
|
public boolean debug = false;
|
||||||
|
|
||||||
public ConfigCache(File configFile, boolean canDoProtocolLib, Object logger) {
|
public ConfigCache(File configFile, boolean canDoProtocolLib, Object logger) {
|
||||||
this.configFile = configFile;
|
this.configFile = configFile;
|
||||||
@@ -91,6 +92,7 @@ public class ConfigCache {
|
|||||||
removed_from_whitelist = config.getString("messages.removed_from_whitelist");
|
removed_from_whitelist = config.getString("messages.removed_from_whitelist");
|
||||||
group_doesnt_exist = config.getString("messages.group_doesnt_exist");
|
group_doesnt_exist = config.getString("messages.group_doesnt_exist");
|
||||||
useProtocolLib = config.getBoolean("use_protocollib");
|
useProtocolLib = config.getBoolean("use_protocollib");
|
||||||
|
debug = config.getBoolean("debug", false);
|
||||||
|
|
||||||
ConfigSection groupSection = config.getConfigSection("groups");
|
ConfigSection groupSection = config.getConfigSection("groups");
|
||||||
for (String key : groupSection.getKeys(false)) {
|
for (String key : groupSection.getKeys(false)) {
|
||||||
@@ -164,4 +166,20 @@ public class ConfigCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void debug(String log) {
|
||||||
|
if (!debug) return;
|
||||||
|
if (logger == null) {
|
||||||
|
System.out.println("DEBUG: "+log);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (logger instanceof org.slf4j.Logger) {
|
||||||
|
((org.slf4j.Logger) logger).info(log);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (logger instanceof java.util.logging.Logger) {
|
||||||
|
((java.util.logging.Logger) logger).info(log);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user