From c7da1647ea106d9cb1abfe76ba419e46577fd57c Mon Sep 17 00:00:00 2001 From: Pepich Date: Tue, 7 Feb 2017 04:03:17 +0100 Subject: [PATCH] Disabled chatalias cmd interaction --- .../modules/chatalias/Chatalias.java | 81 +++++++++---------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/src/com/redstoner/modules/chatalias/Chatalias.java b/src/com/redstoner/modules/chatalias/Chatalias.java index ae851f5..e36754f 100644 --- a/src/com/redstoner/modules/chatalias/Chatalias.java +++ b/src/com/redstoner/modules/chatalias/Chatalias.java @@ -8,9 +8,7 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; 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.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -26,7 +24,7 @@ import com.redstoner.misc.Utils; import com.redstoner.modules.Module; @AutoRegisterListener -@Version(major = 1, minor = 0, revision = 1, compatible = 1) +@Version(major = 1, minor = 0, revision = 2, compatible = 1) public class Chatalias implements Module, Listener { // to export chatalias data to json: @@ -82,45 +80,44 @@ public class Chatalias implements Module, Listener aliases.remove(event.getPlayer().getUniqueId().toString()); } - @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerChat(AsyncPlayerChatEvent event) - { - Player player = event.getPlayer(); - UUID uuid = player.getUniqueId(); - JSONObject playerAliases = (JSONObject) aliases.get(uuid.toString()); - for (Object key : playerAliases.keySet()) - { - String keyword = (String) key; - String replacement = (String) playerAliases.get(key); - if (keyword.startsWith("R: ")) - { - keyword = keyword.replace("R: ", ""); - event.setMessage(event.getMessage().replaceAll(keyword, replacement)); - } - else - { - if (keyword.startsWith("N: ")) - keyword = keyword.replace("N: ", ""); - event.setMessage(event.getMessage().replace(keyword, replacement)); - } - int maxLength; - try - { - maxLength = Integer.valueOf(getPermissionContent(player, "utils.alias.length.")); - } - catch (NumberFormatException e) - { - maxLength = 255; - } - if (event.getMessage().length() > maxLength) - { - Utils.sendErrorMessage(player, null, "The generated message is too long!"); - event.setCancelled(true); - return; - } - } - } - + // @EventHandler(priority = EventPriority.LOWEST) + // public void onPlayerChat(AsyncPlayerChatEvent event) + // { + // Player player = event.getPlayer(); + // UUID uuid = player.getUniqueId(); + // JSONObject playerAliases = (JSONObject) aliases.get(uuid.toString()); + // for (Object key : playerAliases.keySet()) + // { + // String keyword = (String) key; + // String replacement = (String) playerAliases.get(key); + // if (keyword.startsWith("R: ")) + // { + // keyword = keyword.replace("R: ", ""); + // event.setMessage(event.getMessage().replaceAll(keyword, replacement)); + // } + // else + // { + // if (keyword.startsWith("N: ")) + // keyword = keyword.replace("N: ", ""); + // event.setMessage(event.getMessage().replace(keyword, replacement)); + // } + // int maxLength; + // try + // { + // maxLength = Integer.valueOf(getPermissionContent(player, "utils.alias.length.")); + // } + // catch (NumberFormatException e) + // { + // maxLength = 255; + // } + // if (event.getMessage().length() > maxLength) + // { + // Utils.sendErrorMessage(player, null, "The generated message is too long!"); + // event.setCancelled(true); + // return; + // } + // } + // } @EventHandler public void onPlayerCommand(PlayerCommandPreprocessEvent event) {