mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-04 14:38:58 +00:00
v0.7:
- Added support for Essentials mute and ignore features. Players on ignore will still be seen in town and nation chat. - Added craftIRC 3.1 support Add a channel tag of 'admin' to the receiving channel in the craftIRC config. Disable Auto paths and add the following to the 'paths:' section - source: 'minecraft' target: 'admin' formatting: chat: '%message%' - source: 'admin' # These are endpoint tags target: 'minecraft' # formatting: chat: '%foreground%[%red%%ircPrefix%%sender%%foreground%] %message%'
This commit is contained in:
1 parent
9e4357e8e3
commit
f368d6d25b
5 files changed
+138
-8
No files matched your search
@@ -6,5 +6,6 @@
|
|||||||
<classpathentry kind="lib" path="../../lib/craftbukkit-0.0.1-SNAPSHOT.jar"/>
|
<classpathentry kind="lib" path="../../lib/craftbukkit-0.0.1-SNAPSHOT.jar"/>
|
||||||
<classpathentry kind="lib" path="../../lib/Towny.jar"/>
|
<classpathentry kind="lib" path="../../lib/Towny.jar"/>
|
||||||
<classpathentry kind="lib" path="E:/ElgarL/lib/Essentials.jar"/>
|
<classpathentry kind="lib" path="E:/ElgarL/lib/Essentials.jar"/>
|
||||||
|
<classpathentry kind="lib" path="E:/ElgarL/lib/CraftIRC-3.0.0-SNAPSHOT.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
@@ -22,3 +22,19 @@ v0.6:
|
|||||||
- Changed global chat to pass through bukkits chat process instead of our own (allows other plugins to see it again).
|
- Changed global chat to pass through bukkits chat process instead of our own (allows other plugins to see it again).
|
||||||
v0.7:
|
v0.7:
|
||||||
- Added support for Essentials mute and ignore features. Players on ignore will still be seen in town and nation chat.
|
- Added support for Essentials mute and ignore features. Players on ignore will still be seen in town and nation chat.
|
||||||
|
- Added craftIRC 3.1 support
|
||||||
|
|
||||||
|
Add a channel tag of 'admin' to the
|
||||||
|
receiving channel in the craftIRC config.
|
||||||
|
|
||||||
|
Disable Auto paths and add the following to the 'paths:' section
|
||||||
|
|
||||||
|
- source: 'minecraft'
|
||||||
|
target: 'admin'
|
||||||
|
formatting:
|
||||||
|
chat: '%message%'
|
||||||
|
|
||||||
|
- source: 'admin' # These are endpoint tags
|
||||||
|
target: 'minecraft' #
|
||||||
|
formatting:
|
||||||
|
chat: '%foreground%[%red%%ircPrefix%%sender%%foreground%] %message%'
|
||||||
@@ -8,6 +8,8 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.ensifera.animosity.craftirc.CraftIRC;
|
||||||
|
import com.palmergames.bukkit.TownyChat.CraftIRCHandler;
|
||||||
import com.palmergames.bukkit.TownyChat.event.TownyPlayerHighestListener;
|
import com.palmergames.bukkit.TownyChat.event.TownyPlayerHighestListener;
|
||||||
import com.palmergames.bukkit.TownyChat.tasks.onLoadedTask;
|
import com.palmergames.bukkit.TownyChat.tasks.onLoadedTask;
|
||||||
import com.palmergames.bukkit.towny.Towny;
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
@@ -27,6 +29,9 @@ public class Chat extends JavaPlugin {
|
|||||||
|
|
||||||
protected PluginManager pm;
|
protected PluginManager pm;
|
||||||
private Towny towny = null;
|
private Towny towny = null;
|
||||||
|
private CraftIRC craftIRC = null;
|
||||||
|
|
||||||
|
private CraftIRCHandler irc = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@@ -66,10 +71,19 @@ public class Chat extends JavaPlugin {
|
|||||||
if (test != null && test instanceof Towny)
|
if (test != null && test instanceof Towny)
|
||||||
towny = (Towny) test;
|
towny = (Towny) test;
|
||||||
|
|
||||||
|
test = pm.getPlugin("CraftIRC");
|
||||||
|
if (test != null) {
|
||||||
|
if (Double.valueOf(test.getDescription().getVersion()) >= 3.1) {
|
||||||
|
craftIRC = (CraftIRC) test;
|
||||||
|
irc = new CraftIRCHandler(towny, craftIRC, "towny");
|
||||||
|
} else
|
||||||
|
logger.warning("TownyChat requires CraftIRC version 3.1 or higher to relay chat.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerEvents() {
|
public void registerEvents() {
|
||||||
TownyPlayerListener = new TownyPlayerHighestListener(towny);
|
TownyPlayerListener = new TownyPlayerHighestListener(towny, irc);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_CHAT, TownyPlayerListener, Priority.Highest, this); //Run this lower so we go before herochat? ( it needs to see us cancel).
|
pm.registerEvent(Event.Type.PLAYER_CHAT, TownyPlayerListener, Priority.Highest, this); //Run this lower so we go before herochat? ( it needs to see us cancel).
|
||||||
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, TownyPlayerListener, Priority.Highest, this);
|
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, TownyPlayerListener, Priority.Highest, this);
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.palmergames.bukkit.TownyChat;
|
||||||
|
|
||||||
|
import com.ensifera.animosity.craftirc.BasePoint;
|
||||||
|
import com.ensifera.animosity.craftirc.CommandEndPoint;
|
||||||
|
import com.ensifera.animosity.craftirc.CraftIRC;
|
||||||
|
import com.ensifera.animosity.craftirc.RelayedCommand;
|
||||||
|
import com.ensifera.animosity.craftirc.RelayedMessage;
|
||||||
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ElgarL
|
||||||
|
*
|
||||||
|
* Add a channel tag of 'admin' to the
|
||||||
|
* receiving channel in the craftIRC config.
|
||||||
|
*
|
||||||
|
* Disable Auto paths and add the following to the 'paths:' section
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
- source: 'minecraft'
|
||||||
|
target: 'admin'
|
||||||
|
formatting:
|
||||||
|
chat: '%message%'
|
||||||
|
|
||||||
|
- source: 'admin' # These are endpoint tags
|
||||||
|
target: 'minecraft' #
|
||||||
|
formatting:
|
||||||
|
chat: '%foreground%[%red%%ircPrefix%%sender%%foreground%] %message%'
|
||||||
|
|
||||||
|
*/
|
||||||
|
public class CraftIRCHandler extends BasePoint implements CommandEndPoint {
|
||||||
|
|
||||||
|
Towny plugin;
|
||||||
|
CraftIRC irc;
|
||||||
|
|
||||||
|
public CraftIRCHandler(Towny plugin, CraftIRC irc, String tag) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.irc = irc;
|
||||||
|
// Register this as the tags endpoint
|
||||||
|
irc.registerEndPoint(tag, this);
|
||||||
|
// Second argument below is the command name
|
||||||
|
//irc.registerCommand(tag, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getType() {
|
||||||
|
return Type.MINECRAFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void commandIn(RelayedCommand cmd) {
|
||||||
|
// Do nothing here as we do not process commands from IRC.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
public void IRCSender(String message) {
|
||||||
|
/**
|
||||||
|
* admin is the channel tag to send ALL messages to.
|
||||||
|
*/
|
||||||
|
RelayedMessage msg = irc.newMsgToTag(this, "admin", "chat");
|
||||||
|
//msg.setField("command", "");
|
||||||
|
msg.setField("message", message);
|
||||||
|
msg.post(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import com.palmergames.bukkit.towny.TownyException;
|
|||||||
import com.palmergames.bukkit.towny.TownyMessaging;
|
import com.palmergames.bukkit.towny.TownyMessaging;
|
||||||
import com.palmergames.bukkit.towny.TownySettings;
|
import com.palmergames.bukkit.towny.TownySettings;
|
||||||
import com.palmergames.bukkit.TownyChat.event.TownyChatEvent;
|
import com.palmergames.bukkit.TownyChat.event.TownyChatEvent;
|
||||||
|
import com.palmergames.bukkit.TownyChat.CraftIRCHandler;
|
||||||
import com.palmergames.bukkit.TownyChat.TownyChatFormatter;
|
import com.palmergames.bukkit.TownyChat.TownyChatFormatter;
|
||||||
import com.palmergames.bukkit.towny.object.Nation;
|
import com.palmergames.bukkit.towny.object.Nation;
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
@@ -22,9 +23,11 @@ import com.palmergames.util.StringMgmt;
|
|||||||
|
|
||||||
public class TownyPlayerHighestListener extends PlayerListener {
|
public class TownyPlayerHighestListener extends PlayerListener {
|
||||||
private final Towny plugin;
|
private final Towny plugin;
|
||||||
|
private CraftIRCHandler ircHander;
|
||||||
|
|
||||||
public TownyPlayerHighestListener(Towny instance) {
|
public TownyPlayerHighestListener(Towny instance, CraftIRCHandler irc) {
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
|
this.ircHander = irc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -152,7 +155,12 @@ public class TownyPlayerHighestListener extends PlayerListener {
|
|||||||
|
|
||||||
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
||||||
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
||||||
|
|
||||||
|
if (ircHander != null) {
|
||||||
|
parseGlobalChannelChatCommand(event, "/g", player);
|
||||||
|
} else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
for (String channel : TownySettings.getChatChannels()) {
|
for (String channel : TownySettings.getChatChannels()) {
|
||||||
@@ -171,6 +179,10 @@ public class TownyPlayerHighestListener extends PlayerListener {
|
|||||||
|
|
||||||
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
||||||
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
||||||
|
|
||||||
|
if (ircHander != null) {
|
||||||
|
parseGlobalChannelChatCommand(event, "/g", player);
|
||||||
|
} else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@@ -186,8 +198,13 @@ public class TownyPlayerHighestListener extends PlayerListener {
|
|||||||
|
|
||||||
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
||||||
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
||||||
|
String msg = chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage());
|
||||||
|
|
||||||
TownyMessaging.sendTownMessage(town, chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage()));
|
// Relay to IRC
|
||||||
|
if (ircHander != null)
|
||||||
|
ircHander.IRCSender(msg);
|
||||||
|
|
||||||
|
TownyMessaging.sendTownMessage(town, msg);
|
||||||
} catch (NotRegisteredException x) {
|
} catch (NotRegisteredException x) {
|
||||||
TownyMessaging.sendErrorMsg(player, x.getError());
|
TownyMessaging.sendErrorMsg(player, x.getError());
|
||||||
}
|
}
|
||||||
@@ -202,8 +219,13 @@ public class TownyPlayerHighestListener extends PlayerListener {
|
|||||||
|
|
||||||
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
||||||
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
||||||
|
String msg = chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage());
|
||||||
|
|
||||||
TownyMessaging.sendNationMessage(nation, chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage()));
|
// Relay to IRC
|
||||||
|
if (ircHander != null)
|
||||||
|
ircHander.IRCSender(msg);
|
||||||
|
|
||||||
|
TownyMessaging.sendNationMessage(nation, msg);
|
||||||
} catch (NotRegisteredException x) {
|
} catch (NotRegisteredException x) {
|
||||||
TownyMessaging.sendErrorMsg(player, x.getError());
|
TownyMessaging.sendErrorMsg(player, x.getError());
|
||||||
}
|
}
|
||||||
@@ -218,8 +240,13 @@ public class TownyPlayerHighestListener extends PlayerListener {
|
|||||||
|
|
||||||
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
||||||
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
||||||
|
String msg = chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage());
|
||||||
|
|
||||||
|
TownyUniverse.plugin.log(msg);
|
||||||
|
// Relay to IRC
|
||||||
|
if (ircHander != null)
|
||||||
|
ircHander.IRCSender(msg);
|
||||||
|
|
||||||
TownyUniverse.plugin.log(chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage()));
|
|
||||||
for (Player test : plugin.getTownyUniverse().getOnlinePlayers()) {
|
for (Player test : plugin.getTownyUniverse().getOnlinePlayers()) {
|
||||||
if (!plugin.isPermissions() || (plugin.isPermissions() && TownyUniverse.getPermissionSource().hasPermission(test, TownySettings.getChatChannelPermission(command)))) {
|
if (!plugin.isPermissions() || (plugin.isPermissions() && TownyUniverse.getPermissionSource().hasPermission(test, TownySettings.getChatChannelPermission(command)))) {
|
||||||
|
|
||||||
@@ -233,7 +260,7 @@ public class TownyPlayerHighestListener extends PlayerListener {
|
|||||||
// Failed to fetch user so ignore.
|
// Failed to fetch user so ignore.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TownyMessaging.sendMessage(test, chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage()));
|
TownyMessaging.sendMessage(test, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,8 +280,13 @@ public class TownyPlayerHighestListener extends PlayerListener {
|
|||||||
|
|
||||||
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
||||||
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
||||||
|
String msg = chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage());
|
||||||
|
|
||||||
|
TownyUniverse.plugin.log(msg);
|
||||||
|
// Relay to IRC
|
||||||
|
if (ircHander != null)
|
||||||
|
ircHander.IRCSender(msg);
|
||||||
|
|
||||||
TownyUniverse.plugin.log(chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage()));
|
|
||||||
for (Player test : plugin.getTownyUniverse().getOnlinePlayers()) {
|
for (Player test : plugin.getTownyUniverse().getOnlinePlayers()) {
|
||||||
if (!plugin.isPermissions() || (plugin.isPermissions() && TownyUniverse.getPermissionSource().hasPermission(test, TownySettings.getChatChannelPermission(command)))) {
|
if (!plugin.isPermissions() || (plugin.isPermissions() && TownyUniverse.getPermissionSource().hasPermission(test, TownySettings.getChatChannelPermission(command)))) {
|
||||||
|
|
||||||
@@ -268,7 +300,7 @@ public class TownyPlayerHighestListener extends PlayerListener {
|
|||||||
// Failed to fetch user so ignore.
|
// Failed to fetch user so ignore.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TownyMessaging.sendMessage(test, chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage()));
|
TownyMessaging.sendMessage(test, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user