From 74d65f309a6adcfc9b9916e1b8e3fe46669bd1cc Mon Sep 17 00:00:00 2001 From: Boos Date: Wed, 21 Mar 2012 00:30:28 +0100 Subject: [PATCH] added command logging --- .../boosCooldown/boosConfigManager.java | 6 +++++ src/cz/boosik/boosCooldown/boosCoolDown.java | 5 ++++ .../boosCooldown/boosCoolDownListener.java | 23 ++++++++++++------- src/plugin.yml | 2 +- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/cz/boosik/boosCooldown/boosConfigManager.java b/src/cz/boosik/boosCooldown/boosConfigManager.java index feb5de9..7f8b0f9 100644 --- a/src/cz/boosik/boosCooldown/boosConfigManager.java +++ b/src/cz/boosik/boosCooldown/boosConfigManager.java @@ -43,6 +43,7 @@ public class boosConfigManager { conf.addDefault("options.options.cancel_warmup_on_sprint", false); conf.addDefault("options.options.clear_on_restart", false); + conf.addDefault("options.options.command_logging", false); conf.addDefault("options.units.seconds", "seconds"); conf.addDefault("options.units.minutes", "minutes"); conf.addDefault("options.units.hours", "hours"); @@ -332,6 +333,11 @@ public class boosConfigManager { return conf.getBoolean( "options.options.cancel_warmup_on_sneak", false); } + + public static boolean getCommandLogging() { + return conf.getBoolean( + "options.options.command_logging", false); + } public static boolean getBlocked2(Player player, String pre) { boolean blocked = false; diff --git a/src/cz/boosik/boosCooldown/boosCoolDown.java b/src/cz/boosik/boosCooldown/boosCoolDown.java index 4c17dcb..c7e02a0 100644 --- a/src/cz/boosik/boosCooldown/boosCoolDown.java +++ b/src/cz/boosik/boosCooldown/boosCoolDown.java @@ -106,6 +106,11 @@ public class boosCoolDown extends JavaPlugin { return usingPermissions; } + public static void commandLogger(String player, String command) { + log.info("[" + "boosLogger" + "] " + player + " used command " + + command); + } + private boolean setupEconomy() { if (usingVault) { RegisteredServiceProvider economyProvider = getServer() diff --git a/src/cz/boosik/boosCooldown/boosCoolDownListener.java b/src/cz/boosik/boosCooldown/boosCoolDownListener.java index 7068e6d..33caefa 100644 --- a/src/cz/boosik/boosCooldown/boosCoolDownListener.java +++ b/src/cz/boosik/boosCooldown/boosCoolDownListener.java @@ -34,7 +34,6 @@ public class boosCoolDownListener implements Listener { String message = event.getMessage(); Player player = event.getPlayer(); boolean on = true; - on = isPluginOnForPlayer(player); if (on) { @@ -52,7 +51,7 @@ public class boosCoolDownListener implements Listener { if (!used && messageCommand.length() > 1) { int j = messageCommand.indexOf(' ', 1); if (j < 0) { - j = messageCommand.length(); + j = messageCommand.length(); } String preSub = messageCommand.substring(1, j); @@ -60,10 +59,12 @@ public class boosCoolDownListener implements Listener { messageCommand.length()); preSub = preCommand + ' ' + preSub; preSubCheck = preSubCheck(player, preSub); - if (preCDCheck(player, preSub) > 0){ - preSubCheck = 0;} - if (prePriceCheck(player, preSub) > 0){ - preSubCheck = 0;} + if (preCDCheck(player, preSub) > 0) { + preSubCheck = 0; + } + if (prePriceCheck(player, preSub) > 0) { + preSubCheck = 0; + } if (preSubCheck >= 0) { blocked = blocked(player, preSub); this.checkCooldown(event, player, preSub, messageSub); @@ -106,7 +107,7 @@ public class boosCoolDownListener implements Listener { } return preSubCheck; } - + private int preCDCheck(Player player, String preSub) { int preCDCheck; if (boosCoolDown.isUsingPermissions()) { @@ -130,7 +131,7 @@ public class boosCoolDownListener implements Listener { } return preCDCheck; } - + private int prePriceCheck(Player player, String preSub) { int prePriceCheck; if (boosCoolDown.isUsingPermissions()) { @@ -283,6 +284,9 @@ public class boosCoolDownListener implements Listener { .getPrice(player, pre)) { boosPriceManager .payForCommand(player, pre, message); + if (boosConfigManager.getCommandLogging()) { + boosCoolDown.commandLogger(player.getName(), message); + } } else { boosPriceManager .payForCommand(player, pre, message); @@ -300,6 +304,9 @@ public class boosCoolDownListener implements Listener { boosChat.sendMessageToPlayer(player, msg); return false; } + if(!event.isCancelled()){ + boosCoolDown.commandLogger(player.getName(), pre); + } return false; } diff --git a/src/plugin.yml b/src/plugin.yml index f7e6e98..8a0c206 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: boosCooldown main: cz.boosik.boosCooldown.boosCoolDown -version: 2.2.4 beta +version: 2.3.0 beta author: boosik softdepend: [Vault,PermissionsEX] description: >