Skip to content

Commit 80436df

Browse files
authored
Merge pull request #124 from MultiChat/hex
RGB Colour Code Support for MultiChat v1.9.3
2 parents 064b1bd + f37a3ff commit 80436df

56 files changed

Lines changed: 599 additions & 115 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

multichat/dependency-reduced-pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>xyz.olivermartin.multichat</groupId>
55
<artifactId>multichat</artifactId>
6-
<version>1.9.2</version>
6+
<version>1.9.3</version>
77
<build>
88
<plugins>
99
<plugin>
@@ -148,7 +148,7 @@
148148
<dependency>
149149
<groupId>net.md-5</groupId>
150150
<artifactId>bungeecord-api</artifactId>
151-
<version>1.15-SNAPSHOT</version>
151+
<version>1.16-R0.2-SNAPSHOT</version>
152152
<scope>provided</scope>
153153
<exclusions>
154154
<exclusion>
@@ -184,7 +184,7 @@
184184
<dependency>
185185
<groupId>net.md-5</groupId>
186186
<artifactId>bungeecord-api</artifactId>
187-
<version>1.15-SNAPSHOT</version>
187+
<version>1.16-R0.2-SNAPSHOT</version>
188188
<type>javadoc</type>
189189
<scope>provided</scope>
190190
<exclusions>
@@ -221,7 +221,7 @@
221221
<dependency>
222222
<groupId>org.spigotmc</groupId>
223223
<artifactId>spigot-api</artifactId>
224-
<version>1.15.1-R0.1-SNAPSHOT</version>
224+
<version>1.16.1-R0.1-SNAPSHOT</version>
225225
<scope>provided</scope>
226226
<exclusions>
227227
<exclusion>

multichat/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>xyz.olivermartin.multichat</groupId>
77
<artifactId>multichat</artifactId>
8-
<version>1.9.2</version>
8+
<version>1.9.3</version>
99

1010
<repositories>
1111

@@ -117,23 +117,23 @@
117117
<dependency>
118118
<groupId>net.md-5</groupId>
119119
<artifactId>bungeecord-api</artifactId>
120-
<version>1.15-SNAPSHOT</version>
120+
<version>1.16-R0.2-SNAPSHOT</version>
121121
<type>jar</type>
122122
<scope>provided</scope>
123123
</dependency>
124124

125125
<dependency>
126126
<groupId>net.md-5</groupId>
127127
<artifactId>bungeecord-api</artifactId>
128-
<version>1.15-SNAPSHOT</version>
128+
<version>1.16-R0.2-SNAPSHOT</version>
129129
<type>javadoc</type>
130130
<scope>provided</scope>
131131
</dependency>
132132

133133
<dependency>
134134
<groupId>org.spigotmc</groupId>
135135
<artifactId>spigot-api</artifactId>
136-
<version>1.15.1-R0.1-SNAPSHOT</version>
136+
<version>1.16.1-R0.1-SNAPSHOT</version>
137137
<scope>provided</scope>
138138
</dependency>
139139

557 KB
Binary file not shown.
561 KB
Binary file not shown.
563 KB
Binary file not shown.

multichat/src/main/java/xyz/olivermartin/multichat/bungee/Announcements.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ public void run() {
3838
message = ChatControl.applyChatRules(message, "announcements", "").get();
3939

4040
for (ProxiedPlayer onlineplayer : ProxyServer.getInstance().getPlayers()) {
41-
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
41+
if (MultiChat.legacyServers.contains(onlineplayer.getServer().getInfo().getName())) {
42+
onlineplayer.sendMessage(TextComponent.fromLegacyText(MultiChatUtil.approximateHexCodes(ChatColor.translateAlternateColorCodes('&',message))));
43+
} else {
44+
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
45+
}
4246
}
43-
47+
4448
// Trigger PostBroadcastEvent
4549
ProxyServer.getInstance().getPluginManager().callEvent(new PostBroadcastEvent("announcement", message));
4650
}
@@ -88,7 +92,7 @@ public static boolean addAnnouncement(String name, String message) {
8892

8993
if (!announcements.containsKey(name.toLowerCase())) {
9094

91-
announcements.put(name.toLowerCase(), message);
95+
announcements.put(name.toLowerCase(), MultiChatUtil.reformatRGB(message));
9296
return true;
9397

9498
} else {
@@ -132,9 +136,13 @@ public static void playAnnouncement(String name) {
132136
message = ChatControl.applyChatRules(message, "announcements", "").get();
133137

134138
for (ProxiedPlayer onlineplayer : ProxyServer.getInstance().getPlayers()) {
135-
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
139+
if (MultiChat.legacyServers.contains(onlineplayer.getServer().getInfo().getName())) {
140+
onlineplayer.sendMessage(TextComponent.fromLegacyText(MultiChatUtil.approximateHexCodes(ChatColor.translateAlternateColorCodes('&',message))));
141+
} else {
142+
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
143+
}
136144
}
137-
145+
138146
// Trigger PostBroadcastEvent
139147
ProxyServer.getInstance().getPluginManager().callEvent(new PostBroadcastEvent("announcement", message));
140148

multichat/src/main/java/xyz/olivermartin/multichat/bungee/Bulletins.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static void stopBulletins() {
7272

7373
public static void addBulletin(String message) {
7474
synchronized (bulletin) {
75-
bulletin.add(message);
75+
bulletin.add(MultiChatUtil.reformatRGB(message));
7676
}
7777
}
7878

@@ -111,7 +111,11 @@ public void run() {
111111
message = ChatControl.applyChatRules(message, "bulletins", "").get();
112112

113113
for (ProxiedPlayer onlineplayer : ProxyServer.getInstance().getPlayers()) {
114-
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
114+
if (MultiChat.legacyServers.contains(onlineplayer.getServer().getInfo().getName())) {
115+
onlineplayer.sendMessage(TextComponent.fromLegacyText(MultiChatUtil.approximateHexCodes(ChatColor.translateAlternateColorCodes('&',message))));
116+
} else {
117+
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
118+
}
115119
}
116120

117121
// Trigger PostBroadcastEvent

multichat/src/main/java/xyz/olivermartin/multichat/bungee/BungeeComm.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public static void sendIgnoreMap(ServerInfo server) {
150150

151151
}
152152

153-
public static void sendPlayerChannelMessage(String playerName, String channel, Channel channelObject, ServerInfo server, boolean colour) {
153+
public static void sendPlayerChannelMessage(String playerName, String channel, Channel channelObject, ServerInfo server, boolean colour, boolean rgb) {
154154

155155
sendIgnoreMap(server);
156156

@@ -164,6 +164,7 @@ public static void sendPlayerChannelMessage(String playerName, String channel, C
164164
// Channel part
165165
oout.writeUTF(channel);
166166
oout.writeBoolean(colour);
167+
oout.writeBoolean(rgb);
167168
oout.writeBoolean(channelObject.isWhitelistMembers());
168169
oout.writeObject(channelObject.getMembers());
169170

multichat/src/main/java/xyz/olivermartin/multichat/bungee/CastControl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static void sendCast(String castName, String castMessage, Channel chatStr
2222
}
2323

2424
public static void addCast(String castName, String castFormat) {
25-
castList.put(castName.toLowerCase(), castFormat);
25+
castList.put(castName.toLowerCase(), MultiChatUtil.reformatRGB(castFormat));
2626
}
2727

2828
public static void removeCast(String castName) {

multichat/src/main/java/xyz/olivermartin/multichat/bungee/Channel.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ public void sendMessage(String message, CommandSender sender) {
187187
if ( (whitelistServers && servers.contains(receiver.getServer().getInfo().getName())) || (!whitelistServers && !servers.contains(receiver.getServer().getInfo().getName()))) {
188188
//TODO hiding & showing streams
189189

190-
receiver.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', message)));
190+
if (MultiChat.legacyServers.contains(receiver.getServer().getInfo().getName())) {
191+
receiver.sendMessage(TextComponent.fromLegacyText(MultiChatUtil.approximateHexCodes(ChatColor.translateAlternateColorCodes('&', message))));
192+
} else {
193+
receiver.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', message)));
194+
}
191195

192196
}
193197
}
@@ -202,7 +206,7 @@ public void sendMessage(String message, CommandSender sender) {
202206

203207
}
204208

205-
public String buildSpigotFormat(ProxiedPlayer sender, String format, String message) {
209+
/*public String buildSpigotFormat(ProxiedPlayer sender, String format, String message) {
206210
207211
String newFormat = format;
208212
@@ -228,13 +232,13 @@ public String buildSpigotFormat(ProxiedPlayer sender, String format, String mess
228232
if (ChatModeManager.getInstance().isGlobal(sender.getUniqueId())) {
229233
newFormat = newFormat.replace("%MODE%", "Global");
230234
newFormat = newFormat.replace("%M%", "G");
231-
}*/
235+
}
232236
233237
newFormat = newFormat + "%MESSAGE%";
234238
235239
return newFormat;
236240
237-
}
241+
}*/
238242

239243
public BaseComponent[] buildFormat(ProxiedPlayer sender, ProxiedPlayer receiver, String format, String message) {
240244

@@ -283,11 +287,17 @@ public BaseComponent[] buildFormat(ProxiedPlayer sender, ProxiedPlayer receiver,
283287
if (sender.hasPermission("multichat.chat.colour") || sender.hasPermission("multichat.chat.color")) {
284288

285289
newFormat = newFormat.replace("%MESSAGE%", message);
290+
if (MultiChat.legacyServers.contains(receiver.getServer().getInfo().getName())) {
291+
newFormat = MultiChatUtil.approximateHexCodes(newFormat);
292+
}
286293
toSend = TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', newFormat));
287294

288295
} else {
289296

290297
newFormat = newFormat.replace("%MESSAGE%", "");
298+
if (MultiChat.legacyServers.contains(receiver.getServer().getInfo().getName())) {
299+
newFormat = MultiChatUtil.approximateHexCodes(newFormat);
300+
}
291301
toSend = TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', newFormat) + message);
292302
}
293303

@@ -326,6 +336,9 @@ public BaseComponent[] buildFormat(String name, String displayName, String serve
326336
BaseComponent[] toSend;
327337

328338
newFormat = newFormat.replace("%MESSAGE%", message);
339+
if (MultiChat.legacyServers.contains(receiver.getServer().getInfo().getName())) {
340+
newFormat = MultiChatUtil.approximateHexCodes(newFormat);
341+
}
329342
toSend = TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', newFormat));
330343

331344
return toSend;

0 commit comments

Comments
 (0)