Adds the setting to not log commands that are unknown

This commit is contained in:
Fuzzlemann 2017-07-24 20:22:54 +02:00
parent bf47ca79a7
commit 0e8b1b2f1c
4 changed files with 20 additions and 2 deletions

View File

@ -23,6 +23,7 @@ public enum Settings {
GATHERKILLS("Settings.Data.GatherKillData"),
GATHERGMTIMES("Settings.Data.GamemodeChangeListener"),
GATHERCOMMANDS("Settings.Data.GatherCommandUsage"),
DO_NOT_LOG_UNKNOWN_COMMANDS("Customization.Data.DoNotLogUnknownCommands"),
SECURITY_IP_UUID("Settings.WebServer.Security.DisplayIPsAndUUIDs"),
GRAPH_PLAYERS_USEMAXPLAYERS_SCALE("Customization.Graphs.PlayersOnlineGraph.UseMaxPlayersAsScale"),
PLAYERLIST_SHOW_IMAGES("Customization.SmallHeadImagesOnAnalysisPlayerlist"),

View File

@ -78,7 +78,9 @@ public class TPS {
return false;
}
final TPS other = (TPS) obj;
return this.date == other.date && Double.doubleToLongBits(this.tps) == Double.doubleToLongBits(other.tps) && this.players == other.players;
return this.date == other.date
&& Double.doubleToLongBits(this.tps) == Double.doubleToLongBits(other.tps)
&& this.players == other.players;
}
@Override

View File

@ -3,12 +3,14 @@ package main.java.com.djrapitops.plan.data.listeners;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.help.HelpMap;
/**
* Event Listener for PlayerCommandPreprocessEvents.
@ -40,12 +42,23 @@ public class PlanCommandPreprocessListener implements Listener {
if (event.isCancelled()) {
return;
}
String cmd = event.getMessage().split(" ")[0].toLowerCase();
if (Settings.DO_NOT_LOG_UNKNOWN_COMMANDS.isTrue()) {
HelpMap helpMap = plugin.getServer().getHelpMap();
if (helpMap.getHelpTopic(cmd) == null) {
Log.debug("Ignored command, command is unknown");
return;
}
}
Player player = event.getPlayer();
if (player.hasPermission(Permissions.IGNORE_COMMANDUSE.getPermission())) {
Log.debug("Ignored command, player had ignore permission.");
return;
}
handler.handleCommand(event.getMessage().split(" ")[0].toLowerCase());
handler.handleCommand(cmd);
}
}

View File

@ -41,6 +41,8 @@ Settings:
Customization:
ServerName: 'Plan'
SmallHeadImagesOnAnalysisPlayerlist: true
Data:
DoNotLogUnknownCommands: false
Graphs:
PlayersOnlineGraph:
UseMaxPlayersAsScale: true