diff --git a/src/net/crystalyx/bukkit/simplyperms/SimplyAPI.java b/src/net/crystalyx/bukkit/simplyperms/SimplyAPI.java index a5f788f..bdfa796 100644 --- a/src/net/crystalyx/bukkit/simplyperms/SimplyAPI.java +++ b/src/net/crystalyx/bukkit/simplyperms/SimplyAPI.java @@ -168,6 +168,11 @@ public class SimplyAPI implements PermsConfig { return plugin.config.getMessages(); } + @Override + public String getMessage(String key) { + return plugin.config.getMessage(key); + } + @Override public void addMessage(String key, String message) { plugin.config.addMessage(key, message); diff --git a/src/net/crystalyx/bukkit/simplyperms/SimplyPrevents.java b/src/net/crystalyx/bukkit/simplyperms/SimplyPrevents.java index 5166f5c..c1a7fa5 100755 --- a/src/net/crystalyx/bukkit/simplyperms/SimplyPrevents.java +++ b/src/net/crystalyx/bukkit/simplyperms/SimplyPrevents.java @@ -63,25 +63,21 @@ public abstract class SimplyPrevents implements Listener { this.plugin = plugin; } - public void sendMessage(Player player, String message) { + public void sendMessage(Player player, String node) { Long next = throttleTimestamps.get(player); next = Long.valueOf(next == null ? 0 : next.longValue()); long current = System.currentTimeMillis(); if (next.longValue() < current) { - player.sendMessage(message); + player.sendMessage(plugin.config.getMessage(node)); + plugin.debug("Event '" + node + "' cancelled for " + player.getName()); throttleTimestamps.put(player, Long.valueOf(current + 3000)); } } private void deny(Cancellable event, Player player, String node) { event.setCancelled(true); - if (plugin.getConfig().getString("messages/" + node) != null) { - sendMessage(player, plugin.getConfig().getString("messages/" + node).replace('&', '\u00A7')); - } else if (plugin.getConfig().getString("messages/all") != null) { - sendMessage(player, plugin.getConfig().getString("messages/all").replace('&', '\u00A7')); - } - plugin.debug("Event '" + node + "' cancelled for " + player.getName()); + sendMessage(player, node); } protected boolean prevent(Cancellable event, Player player, String node) { diff --git a/src/net/crystalyx/bukkit/simplyperms/io/ConfigFile.java b/src/net/crystalyx/bukkit/simplyperms/io/ConfigFile.java index abc2acb..3568bb7 100755 --- a/src/net/crystalyx/bukkit/simplyperms/io/ConfigFile.java +++ b/src/net/crystalyx/bukkit/simplyperms/io/ConfigFile.java @@ -266,6 +266,11 @@ public class ConfigFile implements PermsConfig { } } + @Override + public String getMessage(String key) { + return plugin.getConfig().getString("messages/" + key, plugin.getConfig().getString("messages/all")).replace('&', '\u00A7'); + } + @Override public void addMessage(String key, String message) { Map messages = getMessages(); diff --git a/src/net/crystalyx/bukkit/simplyperms/io/ConfigSQL.java b/src/net/crystalyx/bukkit/simplyperms/io/ConfigSQL.java index 8ba365f..554ba2c 100755 --- a/src/net/crystalyx/bukkit/simplyperms/io/ConfigSQL.java +++ b/src/net/crystalyx/bukkit/simplyperms/io/ConfigSQL.java @@ -404,6 +404,11 @@ public class ConfigSQL implements PermsConfig { return config.getMessages(); } + @Override + public String getMessage(String key) { + return config.getMessage(key); + } + @Override public void addMessage(String key, String message) { config.addMessage(key, message); diff --git a/src/net/crystalyx/bukkit/simplyperms/io/PermsConfig.java b/src/net/crystalyx/bukkit/simplyperms/io/PermsConfig.java index 0f1e862..3817b63 100755 --- a/src/net/crystalyx/bukkit/simplyperms/io/PermsConfig.java +++ b/src/net/crystalyx/bukkit/simplyperms/io/PermsConfig.java @@ -67,6 +67,8 @@ public interface PermsConfig { public Map getMessages(); + public String getMessage(String key); + public void addMessage(String key, String message); public void removeMessage(String key);