diff --git a/UltimateChat-Spigot/src/main/java/br/net/fabiozumbi12/UltimateChat/Bukkit/UCChannel.java b/UltimateChat-Spigot/src/main/java/br/net/fabiozumbi12/UltimateChat/Bukkit/UCChannel.java index 26b0b0a5..e0a54d18 100644 --- a/UltimateChat-Spigot/src/main/java/br/net/fabiozumbi12/UltimateChat/Bukkit/UCChannel.java +++ b/UltimateChat-Spigot/src/main/java/br/net/fabiozumbi12/UltimateChat/Bukkit/UCChannel.java @@ -52,7 +52,7 @@ public class UCChannel { private List members = new ArrayList<>(); @Deprecated() - public UCChannel(String name, String alias, boolean worlds, int dist, String color, String builder, boolean focus, boolean receiversMsg, double cost, boolean isbungee, boolean hand, boolean ownBuilder, boolean isAlias, String aliasSender, String aliasCmd, List availableWorlds, String ddchannel, String ddmode, String ddmcformat, String mcddformat, String ddhover, boolean ddallowcmds, boolean lock, boolean dynenable, String mcdynformat, String dynmcformat) { + public UCChannel(String name, String alias, boolean worlds, int dist, String color, String builder, boolean focus, boolean receiversMsg, double cost, boolean isbungee, boolean hand, boolean ownBuilder, boolean isAlias, String aliasSender, String aliasCmd, List availableWorlds, String ddchannel, String ddmode, String ddmcformat, String mcddformat, String ddhover, boolean ddallowcmds, boolean lock, boolean dynenable, String mcdynformat, String dynmcformat, boolean chatEvent) { addDefaults(); properties.put("name", name); properties.put("alias", alias); @@ -82,6 +82,8 @@ public UCChannel(String name, String alias, boolean worlds, int dist, String col properties.put("dynmap.enable", dynenable); properties.put("dynmap.ingame-to-web", mcdynformat); properties.put("dynmap.web-to-ingame", dynmcformat); + + properties.put("compat.cancel-chat-event", chatEvent); } public UCChannel(String name, String alias, String color) { @@ -133,6 +135,7 @@ private void addDefaults() { properties.put("discord.format-to-dd", ":regional_indicator_g: **{sender}**: {message}"); properties.put("dynmap.enable", false); + properties.put("compat.cancel-chat-event", false); } public Properties getProperties() { @@ -157,6 +160,10 @@ public void setProperty(String key, String value) { } } + public boolean compatCancelChatEvent(){ + return (boolean) properties.get("compat.cancel-chat-event"); + } + public boolean useDynmap() { return (boolean) properties.get("dynmap.enable"); } diff --git a/UltimateChat-Spigot/src/main/java/br/net/fabiozumbi12/UltimateChat/Bukkit/UCListener.java b/UltimateChat-Spigot/src/main/java/br/net/fabiozumbi12/UltimateChat/Bukkit/UCListener.java index 32df8ca4..5acb3091 100644 --- a/UltimateChat-Spigot/src/main/java/br/net/fabiozumbi12/UltimateChat/Bukkit/UCListener.java +++ b/UltimateChat-Spigot/src/main/java/br/net/fabiozumbi12/UltimateChat/Bukkit/UCListener.java @@ -865,15 +865,15 @@ public void onChat(AsyncPlayerChatEvent e) { if (ch.getCharAlias().length() == rawMsg.length() && rawMsg.equalsIgnoreCase(ch.getCharAlias())) { addPlayerToChannel(ch, p); e.setCancelled(true); - AsyncPlayerChatEvent newEvent = new AsyncPlayerChatEvent(true, e.getPlayer(), e.getMessage(), new HashSet<>()); - Bukkit.getPluginManager().callEvent(newEvent); } if (rawMsg.startsWith(ch.getCharAlias())) { String msg = rawMsg.substring(ch.getCharAlias().length()); sendMessageToPlayer(ch, p, e.getMessage().split(" "), msg); e.setCancelled(true); - AsyncPlayerChatEvent newEvent = new AsyncPlayerChatEvent(true, e.getPlayer(), e.getMessage(), new HashSet<>()); - Bukkit.getPluginManager().callEvent(newEvent); + if (!ch.compatCancelChatEvent()){ + AsyncPlayerChatEvent newEvent = new AsyncPlayerChatEvent(true, e.getPlayer(), e.getMessage(), new HashSet<>()); + Bukkit.getPluginManager().callEvent(newEvent); + } } } if (e.isCancelled()) return; @@ -882,8 +882,6 @@ public void onChat(AsyncPlayerChatEvent e) { Player tellReceiver = UChat.get().getServer().getPlayer(UChat.get().tellPlayers.get(p.getName())); sendTell(p, tellReceiver, e.getMessage()); e.setCancelled(true); - AsyncPlayerChatEvent newEvent = new AsyncPlayerChatEvent(true, e.getPlayer(), e.getMessage(), new HashSet<>()); - Bukkit.getPluginManager().callEvent(newEvent); } else if (UChat.get().command.contains(p.getName()) || UChat.get().command.contains("CONSOLE")) { if (UChat.get().tempTellPlayers.containsKey("CONSOLE")) { String recStr = UChat.get().tempTellPlayers.get("CONSOLE"); @@ -912,8 +910,6 @@ public void onChat(AsyncPlayerChatEvent e) { UChat.get().command.remove(p.getName()); } e.setCancelled(true); - AsyncPlayerChatEvent newEvent = new AsyncPlayerChatEvent(true, e.getPlayer(), e.getMessage(), new HashSet<>()); - Bukkit.getPluginManager().callEvent(newEvent); } else { UCChannel ch = UChat.get().getPlayerChannel(p); if (UChat.get().tempChannels.containsKey(p.getName()) && !UChat.get().tempChannels.get(p.getName()).equals(ch.getAlias())) { @@ -929,8 +925,6 @@ public void onChat(AsyncPlayerChatEvent e) { UChat.get().getLang().sendMessage(p, "channel.muted"); } e.setCancelled(true); - AsyncPlayerChatEvent newEvent = new AsyncPlayerChatEvent(true, e.getPlayer(), e.getMessage(), new HashSet<>()); - Bukkit.getPluginManager().callEvent(newEvent); } if (ch.isCmdAlias()) { @@ -947,8 +941,10 @@ public void onChat(AsyncPlayerChatEvent e) { UCMessages.sendFancyMessage(e.getFormat().split(","), e.getMessage(), ch, p, null); } e.setCancelled(true); - AsyncPlayerChatEvent newEvent = new AsyncPlayerChatEvent(true, e.getPlayer(), e.getMessage(), new HashSet<>()); - Bukkit.getPluginManager().callEvent(newEvent); + if (!ch.compatCancelChatEvent()){ + AsyncPlayerChatEvent newEvent = new AsyncPlayerChatEvent(true, e.getPlayer(), e.getMessage(), new HashSet<>()); + Bukkit.getPluginManager().callEvent(newEvent); + } } }