mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-03 06:28:57 +00:00
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').
This commit is contained in:
1 parent
5558470cdc
commit
20c74891a4
8 files changed
+152
-59
No files matched your search
@@ -38,6 +38,7 @@ Channels:
|
||||
channeltag: '&f[g]'
|
||||
messagecolour: '&f'
|
||||
permission: 'towny.chat.general'
|
||||
craftIRCTag: 'admin'
|
||||
range: '-1'
|
||||
|
||||
town:
|
||||
@@ -46,6 +47,7 @@ Channels:
|
||||
channeltag: '&f[&3TC&f]'
|
||||
messagecolour: '&b'
|
||||
permission: 'towny.chat.town'
|
||||
craftIRCTag: 'admin'
|
||||
range: '-1'
|
||||
|
||||
nation:
|
||||
@@ -54,6 +56,7 @@ Channels:
|
||||
channeltag: '&f[&6NC&f]'
|
||||
messagecolour: '&e'
|
||||
permission: 'towny.chat.nation'
|
||||
craftIRCTag: 'admin'
|
||||
range: '-1'
|
||||
|
||||
admin:
|
||||
@@ -62,6 +65,7 @@ Channels:
|
||||
channeltag: '&f[&4ADMIN&f]'
|
||||
messagecolour: '&c'
|
||||
permission: 'towny.chat.admin'
|
||||
craftIRCTag: 'admin'
|
||||
range: '-1'
|
||||
|
||||
mod:
|
||||
@@ -70,6 +74,7 @@ Channels:
|
||||
channeltag: '&f[&9MOD&f]'
|
||||
messagecolour: '&5'
|
||||
permission: 'towny.chat.mod'
|
||||
craftIRCTag: 'admin'
|
||||
range: '-1'
|
||||
|
||||
local:
|
||||
@@ -78,4 +83,5 @@ Channels:
|
||||
channeltag: '&f[local]'
|
||||
messagecolour: '&f'
|
||||
permission: 'towny.chat.local'
|
||||
craftIRCTag: 'admin'
|
||||
range: '100'
|
||||
@@ -44,6 +44,13 @@
|
||||
|
||||
# Spam_time set the minimum time between messages to be flagged as spam
|
||||
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:
|
||||
# This is the format which will be used for GLOBAL chat/channels.
|
||||
|
||||
+3
-1
@@ -89,4 +89,6 @@ v0.17:
|
||||
- If a player has no permissions for any channel but we are still set to modify chat, remove the channelTag and msgcolour entries.
|
||||
- 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.
|
||||
- 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
|
||||
*/
|
||||
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");
|
||||
//msg.setField("command", "");
|
||||
msg.setField("message", message);
|
||||
msg.post(false);
|
||||
String[] tagArray = tags.split(",");
|
||||
|
||||
for (String destinationTag : tagArray) {
|
||||
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 List<String> commands;
|
||||
private channelTypes type;
|
||||
private String channelTag, messageColour, permission;
|
||||
private String channelTag, messageColour, permission, craftIRCTag;
|
||||
private double range;
|
||||
|
||||
/**
|
||||
@@ -85,6 +85,21 @@ public class Channel {
|
||||
public void setPermission(String 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
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,8 @@ public class ChatSettings extends tag_formats {
|
||||
private static Double spam_time;
|
||||
private static boolean modify_chat;
|
||||
private static boolean per_world;
|
||||
private static boolean heroicDeathToIRC;
|
||||
private static String heroicDeathTags;
|
||||
|
||||
private static Map<String, channelFormats> formatGroups = new HashMap<String, channelFormats>();
|
||||
|
||||
@@ -112,6 +114,39 @@ public class ChatSettings extends tag_formats {
|
||||
public static void setPer_world(boolean 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.
|
||||
|
||||
@@ -48,54 +48,63 @@ public class ConfigurationHandler {
|
||||
Map<String, Object> file = FileMgmt.getFile(filename, defaultRes, null);
|
||||
if (file != null) {
|
||||
|
||||
// Parse the channels
|
||||
Map<String, Object> allChannelNodes = (Map<String, Object>) file.get("Channels");
|
||||
|
||||
// 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);
|
||||
Channel channel = new Channel(channelKey.toLowerCase());
|
||||
|
||||
for (String key : thisChannelNode.keySet()) {
|
||||
Object element = thisChannelNode.get(key);
|
||||
|
||||
if (key.equalsIgnoreCase("commands"))
|
||||
if (element instanceof ArrayList)
|
||||
channel.setCommands((List<String>) element);
|
||||
else if (element instanceof String)
|
||||
channel.setCommands(Arrays.asList(element.toString()));
|
||||
|
||||
if (key.equalsIgnoreCase("type"))
|
||||
if (element instanceof String)
|
||||
channel.setType(channelTypes.valueOf(element.toString()));
|
||||
|
||||
if (key.equalsIgnoreCase("channeltag"))
|
||||
if (element instanceof String)
|
||||
channel.setChannelTag(element.toString());
|
||||
|
||||
if (key.equalsIgnoreCase("messagecolour"))
|
||||
if (element instanceof String)
|
||||
channel.setMessageColour(element.toString());
|
||||
|
||||
if (key.equalsIgnoreCase("permission"))
|
||||
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;
|
||||
for (String rootNode : file.keySet()) {
|
||||
|
||||
if (rootNode.equalsIgnoreCase("Channels")) {
|
||||
// Parse the channels
|
||||
Map<String, Object> allChannelNodes = (Map<String, Object>) file.get("rootNode");
|
||||
|
||||
// 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);
|
||||
Channel channel = new Channel(channelKey.toLowerCase());
|
||||
|
||||
for (String key : thisChannelNode.keySet()) {
|
||||
Object element = thisChannelNode.get(key);
|
||||
|
||||
if (key.equalsIgnoreCase("commands"))
|
||||
if (element instanceof ArrayList)
|
||||
channel.setCommands((List<String>) element);
|
||||
else if (element instanceof String)
|
||||
channel.setCommands(Arrays.asList(element.toString()));
|
||||
|
||||
if (key.equalsIgnoreCase("type"))
|
||||
if (element instanceof String)
|
||||
channel.setType(channelTypes.valueOf(element.toString()));
|
||||
|
||||
if (key.equalsIgnoreCase("channeltag"))
|
||||
if (element instanceof String)
|
||||
channel.setChannelTag(element.toString());
|
||||
|
||||
if (key.equalsIgnoreCase("messagecolour"))
|
||||
if (element instanceof String)
|
||||
channel.setMessageColour(element.toString());
|
||||
|
||||
if (key.equalsIgnoreCase("permission"))
|
||||
if (element instanceof String)
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -124,6 +133,18 @@ public class ConfigurationHandler {
|
||||
|
||||
if (Key.equalsIgnoreCase("spam_time"))
|
||||
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")) {
|
||||
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("[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("[townformat]", (defaults)? town : ChatSettings.getFormatGroup("channel_formats").getTOWN());
|
||||
newConfig = newConfig.replace("[nationformat]", (defaults)? nation : ChatSettings.getFormatGroup("channel_formats").getNATION());
|
||||
|
||||
@@ -199,7 +199,7 @@ public class TownyPlayerHighestListener implements Listener {
|
||||
|
||||
// Relay to IRC
|
||||
if (ircHander != null)
|
||||
ircHander.IRCSender(msg);
|
||||
ircHander.IRCSender(msg, chan.getCraftIRCTag());
|
||||
|
||||
sendSpy(player, "[Town Msg] " + town.getName() + ": " + msg);
|
||||
|
||||
@@ -235,7 +235,7 @@ public class TownyPlayerHighestListener implements Listener {
|
||||
|
||||
// Relay to IRC
|
||||
if (ircHander != null)
|
||||
ircHander.IRCSender(msg);
|
||||
ircHander.IRCSender(msg, chan.getCraftIRCTag());
|
||||
|
||||
sendSpy(player, "[Nation Msg] " + nation.getName() + ": " + msg);
|
||||
|
||||
@@ -270,7 +270,7 @@ public class TownyPlayerHighestListener implements Listener {
|
||||
|
||||
// Relay to IRC
|
||||
if (ircHander != null)
|
||||
ircHander.IRCSender(msg);
|
||||
ircHander.IRCSender(msg, chan.getCraftIRCTag());
|
||||
|
||||
sendSpy(player, msg);
|
||||
|
||||
@@ -318,7 +318,7 @@ public class TownyPlayerHighestListener implements Listener {
|
||||
|
||||
// Relay to IRC
|
||||
if (ircHander != null)
|
||||
ircHander.IRCSender(msg);
|
||||
ircHander.IRCSender(msg, chan.getCraftIRCTag());
|
||||
|
||||
sendSpy(player, msg);
|
||||
|
||||
|
||||
Reference in new issue
Block a user