mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-02 22:23:18 +00:00
Throw a "fake" PlayerChatEvent which will allow TownyChat to have much increased compatibility with other plugins.
This commit is contained in:
1 parent
e3ac53b3f6
commit
15451e6a19
2 files changed
+34
-6
No files matched your search
@@ -9,6 +9,7 @@ import com.palmergames.bukkit.TownyChat.Chat;
|
||||
import com.palmergames.bukkit.TownyChat.CraftIRCHandler;
|
||||
import com.palmergames.bukkit.TownyChat.TownyChatFormatter;
|
||||
import com.palmergames.bukkit.TownyChat.config.ChatSettings;
|
||||
import com.palmergames.bukkit.TownyChat.event.TownyChatEvent;
|
||||
import com.palmergames.bukkit.TownyChat.listener.LocalTownyChatEvent;
|
||||
import com.palmergames.bukkit.towny.TownyMessaging;
|
||||
import com.palmergames.bukkit.towny.TownySettings;
|
||||
@@ -71,6 +72,13 @@ public class StandardChannel extends Channel {
|
||||
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
||||
String msg = chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage());
|
||||
|
||||
// Throw a "fake" chat event for other plugins to handle the chat after TownyChat has formatted it.
|
||||
event = new TownyChatEvent(player, msg);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
msg = event.getMessage();
|
||||
|
||||
plugin.getLogger().info(ChatTools.stripColour("[Town Msg] " + town.getName() + ": " + msg));
|
||||
|
||||
CraftIRCHandler ircHander = plugin.getIRC();
|
||||
@@ -110,6 +118,13 @@ public class StandardChannel extends Channel {
|
||||
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
||||
String msg = chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage());
|
||||
|
||||
// Throw a "fake" chat event for other plugins to handle the chat after TownyChat has formatted it.
|
||||
event = new TownyChatEvent(player, msg);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
msg = event.getMessage();
|
||||
|
||||
plugin.getLogger().info(ChatTools.stripColour("[Nation Msg] " + nation.getName() + ": " + msg));
|
||||
|
||||
CraftIRCHandler ircHander = plugin.getIRC();
|
||||
@@ -148,6 +163,13 @@ public class StandardChannel extends Channel {
|
||||
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
||||
String msg = chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage());
|
||||
|
||||
// Throw a "fake" chat event for other plugins to handle the chat after TownyChat has formatted it.
|
||||
event = new TownyChatEvent(player, msg);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
msg = event.getMessage();
|
||||
|
||||
plugin.getLogger().info(ChatTools.stripColour(msg));
|
||||
|
||||
CraftIRCHandler ircHander = plugin.getIRC();
|
||||
@@ -199,6 +221,13 @@ public class StandardChannel extends Channel {
|
||||
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
||||
String msg = chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage());
|
||||
|
||||
// Throw a "fake" chat event for other plugins to handle the chat after TownyChat has formatted it.
|
||||
event = new TownyChatEvent(player, msg);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
msg = event.getMessage();
|
||||
|
||||
plugin.getLogger().info(ChatTools.stripColour(msg));
|
||||
|
||||
CraftIRCHandler ircHander = plugin.getIRC();
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.palmergames.bukkit.towny.TownyMessaging;
|
||||
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
||||
import com.palmergames.bukkit.TownyChat.channels.channelTypes;
|
||||
import com.palmergames.bukkit.TownyChat.config.ChatSettings;
|
||||
import com.palmergames.bukkit.TownyChat.event.TownyChatEvent;
|
||||
import com.palmergames.bukkit.TownyChat.listener.LocalTownyChatEvent;
|
||||
import com.palmergames.bukkit.TownyChat.Chat;
|
||||
import com.palmergames.bukkit.TownyChat.TownyChatFormatter;
|
||||
@@ -32,11 +33,8 @@ public class TownyChatPlayerListener implements Listener {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
@@ -86,10 +84,11 @@ public class TownyChatPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
|
||||
if (event.isCancelled())
|
||||
// We don't care about the events we already processed.
|
||||
if (event instanceof TownyChatEvent)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Reference in new issue
Block a user