- Added craftIRC channel tag support. A new entry per channel will
allow you to set the endpoint tags for all channels to craftIRC
(craftIRCTag: 'admin').
This commit is contained in:
ElgarL committed 2012-02-03 01:34:26 +00:00
1 parent 5558470cdc
commit 20c74891a4
8 files changed
+140 -47

No files matched your search

+6
View File
@@ -38,6 +38,7 @@ Channels:
channeltag: '&f[g]' channeltag: '&f[g]'
messagecolour: '&f' messagecolour: '&f'
permission: 'towny.chat.general' permission: 'towny.chat.general'
craftIRCTag: 'admin'
range: '-1' range: '-1'
town: town:
@@ -46,6 +47,7 @@ Channels:
channeltag: '&f[&3TC&f]' channeltag: '&f[&3TC&f]'
messagecolour: '&b' messagecolour: '&b'
permission: 'towny.chat.town' permission: 'towny.chat.town'
craftIRCTag: 'admin'
range: '-1' range: '-1'
nation: nation:
@@ -54,6 +56,7 @@ Channels:
channeltag: '&f[&6NC&f]' channeltag: '&f[&6NC&f]'
messagecolour: '&e' messagecolour: '&e'
permission: 'towny.chat.nation' permission: 'towny.chat.nation'
craftIRCTag: 'admin'
range: '-1' range: '-1'
admin: admin:
@@ -62,6 +65,7 @@ Channels:
channeltag: '&f[&4ADMIN&f]' channeltag: '&f[&4ADMIN&f]'
messagecolour: '&c' messagecolour: '&c'
permission: 'towny.chat.admin' permission: 'towny.chat.admin'
craftIRCTag: 'admin'
range: '-1' range: '-1'
mod: mod:
@@ -70,6 +74,7 @@ Channels:
channeltag: '&f[&9MOD&f]' channeltag: '&f[&9MOD&f]'
messagecolour: '&5' messagecolour: '&5'
permission: 'towny.chat.mod' permission: 'towny.chat.mod'
craftIRCTag: 'admin'
range: '-1' range: '-1'
local: local:
@@ -78,4 +83,5 @@ Channels:
channeltag: '&f[local]' channeltag: '&f[local]'
messagecolour: '&f' messagecolour: '&f'
permission: 'towny.chat.local' permission: 'towny.chat.local'
craftIRCTag: 'admin'
range: '100' range: '100'
+7
View File
@@ -45,6 +45,13 @@
# Spam_time set the minimum time between messages to be flagged as spam # Spam_time set the minimum time between messages to be flagged as spam
spam_time: [spam_time] spam_time: [spam_time]
# If using our updated HeroicDeath.jar and craftIRC 3.1 (dev), you can
#configure what IRC channels you want death messages relayed to.
HeroicDeathToIRC:
enabled: [hd_enable]
# comma delimited list of craftIRC channel tags 'admin,blah,blah'.
craftIRCTags: '[hd_tags]'
channel_formats: channel_formats:
# This is the format which will be used for GLOBAL chat/channels. # This is the format which will be used for GLOBAL chat/channels.
# This is also the format used when you have modify_chat.enable: true, but use other plugins to handle chat. # This is also the format used when you have modify_chat.enable: true, but use other plugins to handle chat.
+2
View File
@@ -90,3 +90,5 @@ v0.17:
- Fix Spam timer to work in milliseconds so values of 0.5 actually work. - Fix Spam timer to work in milliseconds so values of 0.5 actually work.
- Fix craftIRC hook to not spam console with an invalid number format error if the wrong version is detected. - Fix craftIRC hook to not spam console with an invalid number format error if the wrong version is detected.
- Add support for our updated HeroicDeath jar (hopefully someone will take over support for heroic Death now it's updated). - Add support for our updated HeroicDeath jar (hopefully someone will take over support for heroic Death now it's updated).
v0.18:
- Added craftIRC channel tag support. A new entry per channel will allow you to set the endpoint tags for all channels to craftIRC (craftIRCTag: 'admin').
@@ -55,14 +55,18 @@ public class CraftIRCHandler extends BasePoint implements CommandEndPoint {
/** /**
* @param message * @param message
*/ */
public void IRCSender(String message) { public void IRCSender(String message, String tags) {
/** /**
* admin is the channel tag to send ALL messages to. * Relay this to every channel tag listed
*/ */
RelayedMessage msg = irc.newMsgToTag(this, "admin", "chat"); String[] tagArray = tags.split(",");
//msg.setField("command", "");
msg.setField("message", message); for (String destinationTag : tagArray) {
msg.post(false); RelayedMessage msg = irc.newMsgToTag(this, destinationTag.trim(), "chat");
//msg.setField("command", "");
msg.setField("message", message);
msg.post(false);
}
} }
} }
@@ -7,7 +7,7 @@ public class Channel {
private String name; private String name;
private List<String> commands; private List<String> commands;
private channelTypes type; private channelTypes type;
private String channelTag, messageColour, permission; private String channelTag, messageColour, permission, craftIRCTag;
private double range; private double range;
/** /**
@@ -85,6 +85,21 @@ public class Channel {
public void setPermission(String permission) { public void setPermission(String permission) {
this.permission = permission; this.permission = permission;
} }
/**
* @return the permission
*/
public String getCraftIRCTag() {
if (craftIRCTag.isEmpty())
return "admin";
return craftIRCTag;
}
/**
* @param permission the permission to set
*/
public void setCraftIRCTag(String craftIRCTag) {
this.craftIRCTag = craftIRCTag;
}
/** /**
* @return the range * @return the range
*/ */
@@ -15,6 +15,8 @@ public class ChatSettings extends tag_formats {
private static Double spam_time; private static Double spam_time;
private static boolean modify_chat; private static boolean modify_chat;
private static boolean per_world; private static boolean per_world;
private static boolean heroicDeathToIRC;
private static String heroicDeathTags;
private static Map<String, channelFormats> formatGroups = new HashMap<String, channelFormats>(); private static Map<String, channelFormats> formatGroups = new HashMap<String, channelFormats>();
@@ -113,6 +115,39 @@ public class ChatSettings extends tag_formats {
ChatSettings.per_world = per_world; ChatSettings.per_world = per_world;
} }
/**
* @return the HeroicDeathToIRC
*/
public static boolean isHeroicDeathToIRC() {
return heroicDeathToIRC;
}
/**
* @param HeroicDeathToIRC
* the HeroicDeathToIRC to set
*/
public static void setHeroicDeathToIRC(boolean HeroicDeathToIRC) {
ChatSettings.heroicDeathToIRC = HeroicDeathToIRC;
}
/**
* @return the heroicDeathTags
*/
public static String getHeroicDeathTags() {
return heroicDeathTags;
}
/**
* @param heroicDeathTags
* the heroicDeathTags to set
*/
public static void setheroicDeathTags(String heroicDeathTags) {
ChatSettings.heroicDeathTags = heroicDeathTags;
}
/** /**
* Adds customizable channel formats for each world. * Adds customizable channel formats for each world.
* *
@@ -48,54 +48,63 @@ public class ConfigurationHandler {
Map<String, Object> file = FileMgmt.getFile(filename, defaultRes, null); Map<String, Object> file = FileMgmt.getFile(filename, defaultRes, null);
if (file != null) { if (file != null) {
// Parse the channels for (String rootNode : file.keySet()) {
Map<String, Object> allChannelNodes = (Map<String, Object>) file.get("Channels");
// Load channels if the file is NOT empty if (rootNode.equalsIgnoreCase("Channels")) {
if (allChannelNodes != null) { // Parse the channels
for (String channelKey : allChannelNodes.keySet()) { Map<String, Object> allChannelNodes = (Map<String, Object>) file.get("rootNode");
if (channelKey.equalsIgnoreCase("spam_time"))
ChatSettings.setSpam_time((Double)allChannelNodes.get(channelKey)); // Load channels if the file is NOT empty
if (allChannelNodes != null) {
for (String channelKey : allChannelNodes.keySet()) {
if (channelKey.equalsIgnoreCase("spam_time"))
ChatSettings.setSpam_time((Double)allChannelNodes.get(channelKey));
Map<String, Object> thisChannelNode = (Map<String, Object>) allChannelNodes.get(channelKey); Map<String, Object> thisChannelNode = (Map<String, Object>) allChannelNodes.get(channelKey);
Channel channel = new Channel(channelKey.toLowerCase()); Channel channel = new Channel(channelKey.toLowerCase());
for (String key : thisChannelNode.keySet()) { for (String key : thisChannelNode.keySet()) {
Object element = thisChannelNode.get(key); Object element = thisChannelNode.get(key);
if (key.equalsIgnoreCase("commands")) if (key.equalsIgnoreCase("commands"))
if (element instanceof ArrayList) if (element instanceof ArrayList)
channel.setCommands((List<String>) element); channel.setCommands((List<String>) element);
else if (element instanceof String) else if (element instanceof String)
channel.setCommands(Arrays.asList(element.toString())); channel.setCommands(Arrays.asList(element.toString()));
if (key.equalsIgnoreCase("type")) if (key.equalsIgnoreCase("type"))
if (element instanceof String) if (element instanceof String)
channel.setType(channelTypes.valueOf(element.toString())); channel.setType(channelTypes.valueOf(element.toString()));
if (key.equalsIgnoreCase("channeltag")) if (key.equalsIgnoreCase("channeltag"))
if (element instanceof String) if (element instanceof String)
channel.setChannelTag(element.toString()); channel.setChannelTag(element.toString());
if (key.equalsIgnoreCase("messagecolour")) if (key.equalsIgnoreCase("messagecolour"))
if (element instanceof String) if (element instanceof String)
channel.setMessageColour(element.toString()); channel.setMessageColour(element.toString());
if (key.equalsIgnoreCase("permission")) if (key.equalsIgnoreCase("permission"))
if (element instanceof String) if (element instanceof String)
channel.setPermission(element.toString()); channel.setPermission(element.toString());
if (key.equalsIgnoreCase("craftIRCTag"))
if (element instanceof String)
channel.setPermission(element.toString());
if (key.equalsIgnoreCase("range"))
channel.setRange(Double.valueOf(element.toString()));
}
plugin.getChannelsHandler().addChannel(channel);
//System.out.print("Channel: " + channel.getName() + " : Type : " + channel.getType().name());
}
return true;
if (key.equalsIgnoreCase("range"))
channel.setRange(Double.valueOf(element.toString()));
} }
plugin.getChannelsHandler().addChannel(channel);
//System.out.print("Channel: " + channel.getName() + " : Type : " + channel.getType().name());
} }
return true;
} }
} }
return false; return false;
@@ -125,6 +134,18 @@ public class ConfigurationHandler {
if (Key.equalsIgnoreCase("spam_time")) if (Key.equalsIgnoreCase("spam_time"))
ChatSettings.setSpam_time( Double.parseDouble((file.get(Key)).toString()) ); ChatSettings.setSpam_time( Double.parseDouble((file.get(Key)).toString()) );
if (Key.equalsIgnoreCase("HeroicDeathToIRC")) {
Map<String, Object> subNodes = (Map<String, Object>) file.get(Key);
for (String element : subNodes.keySet()) {
if (element.equalsIgnoreCase("enabled"))
ChatSettings.setHeroicDeathToIRC(Boolean.valueOf(subNodes.get(element).toString()));
if (element.equalsIgnoreCase("craftIRCTags"))
ChatSettings.setheroicDeathTags(subNodes.get(element).toString());
}
}
if (Key.equalsIgnoreCase("modify_chat")) { if (Key.equalsIgnoreCase("modify_chat")) {
Map<String, Object> subNodes = (Map<String, Object>) file.get(Key); Map<String, Object> subNodes = (Map<String, Object>) file.get(Key);
@@ -287,6 +308,9 @@ public class ConfigurationHandler {
newConfig = newConfig.replace("[spam_time]", (defaults)? "0.5" : Double.toString(ChatSettings.getSpam_time())); newConfig = newConfig.replace("[spam_time]", (defaults)? "0.5" : Double.toString(ChatSettings.getSpam_time()));
newConfig = newConfig.replace("[hd_enable]", (defaults)? "true" : Boolean.toString(ChatSettings.isHeroicDeathToIRC()));
newConfig = newConfig.replace("[hd_tags]", (defaults)? "admin" : ChatSettings.getHeroicDeathTags());
newConfig = newConfig.replace("[globalformat]", (defaults)? global : ChatSettings.getFormatGroup("channel_formats").getGLOBAL()); newConfig = newConfig.replace("[globalformat]", (defaults)? global : ChatSettings.getFormatGroup("channel_formats").getGLOBAL());
newConfig = newConfig.replace("[townformat]", (defaults)? town : ChatSettings.getFormatGroup("channel_formats").getTOWN()); newConfig = newConfig.replace("[townformat]", (defaults)? town : ChatSettings.getFormatGroup("channel_formats").getTOWN());
newConfig = newConfig.replace("[nationformat]", (defaults)? nation : ChatSettings.getFormatGroup("channel_formats").getNATION()); newConfig = newConfig.replace("[nationformat]", (defaults)? nation : ChatSettings.getFormatGroup("channel_formats").getNATION());
@@ -199,7 +199,7 @@ public class TownyPlayerHighestListener implements Listener {
// Relay to IRC // Relay to IRC
if (ircHander != null) if (ircHander != null)
ircHander.IRCSender(msg); ircHander.IRCSender(msg, chan.getCraftIRCTag());
sendSpy(player, "[Town Msg] " + town.getName() + ": " + msg); sendSpy(player, "[Town Msg] " + town.getName() + ": " + msg);
@@ -235,7 +235,7 @@ public class TownyPlayerHighestListener implements Listener {
// Relay to IRC // Relay to IRC
if (ircHander != null) if (ircHander != null)
ircHander.IRCSender(msg); ircHander.IRCSender(msg, chan.getCraftIRCTag());
sendSpy(player, "[Nation Msg] " + nation.getName() + ": " + msg); sendSpy(player, "[Nation Msg] " + nation.getName() + ": " + msg);
@@ -270,7 +270,7 @@ public class TownyPlayerHighestListener implements Listener {
// Relay to IRC // Relay to IRC
if (ircHander != null) if (ircHander != null)
ircHander.IRCSender(msg); ircHander.IRCSender(msg, chan.getCraftIRCTag());
sendSpy(player, msg); sendSpy(player, msg);
@@ -318,7 +318,7 @@ public class TownyPlayerHighestListener implements Listener {
// Relay to IRC // Relay to IRC
if (ircHander != null) if (ircHander != null)
ircHander.IRCSender(msg); ircHander.IRCSender(msg, chan.getCraftIRCTag());
sendSpy(player, msg); sendSpy(player, msg);