From 4e9999019b50110f39fe8676065c4c3258167b4e Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Tue, 5 Nov 2019 13:37:05 -0600 Subject: [PATCH] v0.62: - New Channel: AllianceChat - Requires Towny 0.95.0.5 or newer. - Will send messages to every online ally of your nation. - Has its own channel_format in the chatconfig.yml. - Your channels.yml will need to have an Alliance channel added. - Default channels.yml is: alliance: commands: [ac] type: ALLIANCE channeltag: '&f[&2AC&f]' messagecolour: '&a' permission: 'towny.chat.alliance' range: '-1' --- pom.xml | 2 +- resources/Channels.yml | 10 +++++++++- resources/changelog.txt | 19 ++++++++++++++++++- .../TownyChat/channels/StandardChannel.java | 13 +++++++++++++ .../TownyChat/channels/channelFormats.java | 18 +++++++++++++++++- .../TownyChat/channels/channelTypes.java | 1 + .../TownyChat/config/ChatConfigNodes.java | 4 ++++ .../bukkit/TownyChat/config/ChatSettings.java | 2 ++ .../config/ConfigurationHandler.java | 6 ++++++ 9 files changed, 71 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 0f88967..099b710 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.palmergames.bukkit TownyChat jar - 0.61 + 0.62 diff --git a/resources/Channels.yml b/resources/Channels.yml index e06c3de..ccb83ea 100644 --- a/resources/Channels.yml +++ b/resources/Channels.yml @@ -56,7 +56,15 @@ Channels: messagecolour: '&e' permission: 'towny.chat.nation' range: '-1' - + + alliance: + commands: [ac] + type: ALLIANCE + channeltag: '&f[&2AC&f]' + messagecolour: '&a' + permission: 'towny.chat.alliance' + range: '-1' + admin: commands: [a,admin] type: DEFAULT diff --git a/resources/changelog.txt b/resources/changelog.txt index cc3c1ea..f6a1592 100644 --- a/resources/changelog.txt +++ b/resources/changelog.txt @@ -256,4 +256,21 @@ v0.60: v0.61: - New Config Option: display_modes_set_on_join - Default: true - - If true players will see [Towny] Modes set: general when they log in. \ No newline at end of file + - If true players will see [Towny] Modes set: general when they log in. +v0.62: + - New Channel: AllianceChat + - Requires Towny 0.95.0.5 or newer. + - Will send messages to every online ally of your nation. + - Has its own channel_format in the chatconfig.yml. + - Your channels.yml will need to have an Alliance channel added. + - Default channels.yml is: + alliance: + commands: [ac] + type: ALLIANCE + channeltag: '&f[&2AC&f]' + messagecolour: '&a' + permission: 'towny.chat.alliance' + range: '-1' + + + \ No newline at end of file diff --git a/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java b/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java index dec8152..71d9360 100644 --- a/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java +++ b/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java @@ -91,6 +91,16 @@ public class StandardChannel extends Channel { recipients = checkSpying(recipients); break; + case ALLIANCE: + if (nation == null) { + event.setCancelled(true); + return; + } + Format = ChatSettings.getRelevantFormatGroup(player).getALLIANCE(); + recipients = new HashSet<>(findRecipients(player, TownyAPI.getInstance().getOnlinePlayersAlliance(nation))); + recipients = checkSpying(recipients); + break; + case DEFAULT: Format = ChatSettings.getRelevantFormatGroup(player).getDEFAULT(); recipients = new HashSet<>(findRecipients(player, new ArrayList<>(event.getRecipients()))); @@ -155,6 +165,9 @@ public class StandardChannel extends Channel { case NATION: break; + + case ALLIANCE: + break; case DEFAULT: break; diff --git a/src/com/palmergames/bukkit/TownyChat/channels/channelFormats.java b/src/com/palmergames/bukkit/TownyChat/channels/channelFormats.java index b6d9df1..e9732d8 100644 --- a/src/com/palmergames/bukkit/TownyChat/channels/channelFormats.java +++ b/src/com/palmergames/bukkit/TownyChat/channels/channelFormats.java @@ -14,7 +14,7 @@ public class channelFormats { this.name = name.toLowerCase(); } - private String name, GLOBAL, TOWN, NATION, DEFAULT; + private String name, GLOBAL, TOWN, NATION, ALLIANCE, DEFAULT; /** * @return a clone of this channelFormats @@ -26,6 +26,7 @@ public class channelFormats { clone.setGLOBAL(this.getGLOBAL()); clone.setTOWN(this.getTOWN()); clone.setNATION(this.getNATION()); + clone.setALLIANCE(this.getALLIANCE()); clone.setDEFAULT(this.getDEFAULT()); return clone; @@ -91,6 +92,21 @@ public class channelFormats { this.NATION = NATION; } + /** + * @return the ALLIANCE + */ + public String getALLIANCE() { + return this.ALLIANCE; + } + + /** + * @param ALLIANCE + * the ALLIANCE to set + */ + public void setALLIANCE(String ALLIANCE) { + this.ALLIANCE = ALLIANCE; + } + /** * @return the DEFAULT */ diff --git a/src/com/palmergames/bukkit/TownyChat/channels/channelTypes.java b/src/com/palmergames/bukkit/TownyChat/channels/channelTypes.java index e80db01..116e3a8 100644 --- a/src/com/palmergames/bukkit/TownyChat/channels/channelTypes.java +++ b/src/com/palmergames/bukkit/TownyChat/channels/channelTypes.java @@ -4,6 +4,7 @@ package com.palmergames.bukkit.TownyChat.channels; public enum channelTypes { TOWN, NATION, + ALLIANCE, DEFAULT, GLOBAL, PRIVATE diff --git a/src/com/palmergames/bukkit/TownyChat/config/ChatConfigNodes.java b/src/com/palmergames/bukkit/TownyChat/config/ChatConfigNodes.java index 96e4f11..14d66e0 100644 --- a/src/com/palmergames/bukkit/TownyChat/config/ChatConfigNodes.java +++ b/src/com/palmergames/bukkit/TownyChat/config/ChatConfigNodes.java @@ -93,6 +93,10 @@ public enum ChatConfigNodes { "channel_formats.nation", "{channelTag} {towntagoverride}{townycolor}{permprefix}{townyprefix}{playername}{townypostfix}{permsuffix}&f:{msgcolour} {msg}", "# NATION channel types."), + CHANNEL_FORMATS_ALLIANCE( + "channel_formats.alliance", + "{channelTag} {towntagoverride}{townycolor}{permprefix}{townyprefix}{playername}{townypostfix}{permsuffix}&f:{msgcolour} {msg}", + "# ALLIANCE channel types."), CHANNEL_FORMATS_DEFAULT( "channel_formats.default", "{channelTag} {permprefix}{playername}{permsuffix}&f:{msgcolour} {msg}", diff --git a/src/com/palmergames/bukkit/TownyChat/config/ChatSettings.java b/src/com/palmergames/bukkit/TownyChat/config/ChatSettings.java index 0e483d9..8e8fc15 100644 --- a/src/com/palmergames/bukkit/TownyChat/config/ChatSettings.java +++ b/src/com/palmergames/bukkit/TownyChat/config/ChatSettings.java @@ -91,12 +91,14 @@ public class ChatSettings extends tag_formats { || !chatConfig.contains("worlds." + world + ".global") || !chatConfig.contains("worlds." + world + ".town") || !chatConfig.contains("worlds." + world + ".nation") + || !chatConfig.contains("worlds." + world + ".alliance") || !chatConfig.contains("worlds." + world + ".default")) { newChatConfig.createSection("worlds." + world); ConfigurationSection worldsection = newChatConfig.getConfigurationSection("worlds." + world); worldsection.set("global", (chatConfig.get("worlds." + world + ".global")!= null) ? chatConfig.get("worlds." + world + ".global") : ChatConfigNodes.CHANNEL_FORMATS_GLOBAL.getDefault()); worldsection.set("town", (chatConfig.get("worlds." + world + ".town")!= null) ? chatConfig.get("worlds." + world + ".town") : ChatConfigNodes.CHANNEL_FORMATS_TOWN.getDefault()); worldsection.set("nation", (chatConfig.get("worlds." + world + ".nation")!= null) ? chatConfig.get("worlds." + world + ".nation") : ChatConfigNodes.CHANNEL_FORMATS_NATION.getDefault()); + worldsection.set("alliance", (chatConfig.get("worlds." + world + ".alliance")!= null) ? chatConfig.get("worlds." + world + ".alliance") : ChatConfigNodes.CHANNEL_FORMATS_ALLIANCE.getDefault()); worldsection.set("default", (chatConfig.get("worlds." + world + ".default")!= null) ? chatConfig.get("worlds." + world + ".default") : ChatConfigNodes.CHANNEL_FORMATS_DEFAULT.getDefault()); } } diff --git a/src/com/palmergames/bukkit/TownyChat/config/ConfigurationHandler.java b/src/com/palmergames/bukkit/TownyChat/config/ConfigurationHandler.java index 28a2859..11d8262 100644 --- a/src/com/palmergames/bukkit/TownyChat/config/ConfigurationHandler.java +++ b/src/com/palmergames/bukkit/TownyChat/config/ConfigurationHandler.java @@ -257,6 +257,9 @@ public class ConfigurationHandler { if (element.equalsIgnoreCase("nation")) group.setNATION(subNodes.get(element).toString()); + + if (element.equalsIgnoreCase("alliance")) + group.setALLIANCE(subNodes.get(element).toString()); if (element.equalsIgnoreCase("default")) group.setDEFAULT(subNodes.get(element).toString()); @@ -283,6 +286,9 @@ public class ConfigurationHandler { if (element.equalsIgnoreCase("nation")) group.setNATION(world.get(element).toString()); + + if (element.equalsIgnoreCase("alliance")) + group.setALLIANCE(world.get(element).toString()); if (element.equalsIgnoreCase("default")) group.setDEFAULT(world.get(element).toString());