Skip to content

Commit

Permalink
More multichat color code fix, Bungeecord fixes, getLastColor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LOOHP committed Feb 21, 2021
1 parent e3b5521 commit 1a989c6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.loohp</groupId>
<artifactId>InteractiveChat</artifactId>
<version>3.2.9.16</version>
<version>3.2.9.17</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public void write(ChannelHandlerContext channelHandlerContext, Object obj, Chann
Chat packet = (Chat) obj;
forwardedMessages.get(player.getUniqueId()).add(packet.getMessage());
}
super.write(channelHandlerContext, obj, channelPromise); // send it to client
super.write(channelHandlerContext, obj, channelPromise);
}
});
}
Expand Down Expand Up @@ -524,7 +524,7 @@ public void write(ChannelHandlerContext channelHandlerContext, Object obj, Chann
Chat packet = (Chat) obj;
if (packet.getMessage().contains("<QUxSRUFEWVBST0NFU1NFRA==>")) {
packet.setMessage(packet.getMessage().replace("<QUxSRUFEWVBST0NFU1NFRA==>", ""));
} else if (player.getServer() != null) {
} else if (hasInteractiveChat(player.getServer())) {
UUID messageId = UUID.randomUUID();
messageQueue.add(messageId);
//ProxyServer.getInstance().getConsole().sendMessage(new TextComponent(messageId.toString() + " -> " + packet.getMessage()));
Expand All @@ -541,7 +541,7 @@ public void run() {
return;
}
}
super.write(channelHandlerContext, obj, channelPromise); // send it to client
super.write(channelHandlerContext, obj, channelPromise);
}
});
}
Expand Down Expand Up @@ -595,4 +595,15 @@ public void run() {
}, 1000);
}

private boolean hasInteractiveChat(Server server) {
if (server == null || server.getInfo() == null) {
return false;
}
BackendInteractiveChatData data = serverInteractiveChatInfo.get(server.getInfo().getName());
if (data == null) {
return false;
}
return data.hasInteractiveChat();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public static BaseComponent processPlayer(String placeholder, ICPlayer player, S
}

String lastColor = "";

StringBuilder sb = new StringBuilder();

for (int i = 0; i < trim.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Optional;
import java.util.concurrent.TimeUnit;

import org.apache.commons.text.StringEscapeUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

Expand All @@ -18,13 +19,14 @@
import com.loohp.interactivechat.Utils.MCVersion;
import com.loohp.interactivechat.Utils.PlayerUtils;

import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.chat.ComponentSerializer;

public class ProcessBungeeRequestedMessage {

public static String processAndRespond(Player reciever, String component) throws Exception {
BaseComponent basecomponent = ChatComponentUtils.join(ComponentSerializer.parse(ChatColorUtils.filterIllegalColorCodes(component)));
BaseComponent basecomponent = ChatComponentUtils.join(ComponentSerializer.parse(ChatColorUtils.filterIllegalColorCodes(StringEscapeUtils.unescapeJava(component))));
BaseComponent originalComponent = ChatComponentUtils.clone(basecomponent);

try {
Expand Down Expand Up @@ -89,6 +91,8 @@ public static String processAndRespond(Player reciever, String component) throws
basecomponent = PlayernameDisplay.process(basecomponent, rawMessageKey, sender, unix);
}

System.out.println(ComponentSerializer.toString(basecomponent).replace(ChatColor.COLOR_CHAR, '&'));

if (InteractiveChat.AllowMention && sender.isPresent()) {
basecomponent = MentionDisplay.process(basecomponent, reciever, sender.get(), rawMessageKey, unix, !Bukkit.isPrimaryThread());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static boolean isLegal(String color) {
if (color.matches("§[0-9a-fk-or]")) {
return true;
}
if (color.matches("§x§[0-9A-F]§[0-9A-F]§[0-9A-F]§[0-9A-F]§[0-9A-F]§[0-9A-F]")) {
if (color.matches("§x(§[0-9a-fA-F]){6}")) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.md_5.bungee.api.chat.hover.content.Entity;
import net.md_5.bungee.api.chat.hover.content.Item;
import net.md_5.bungee.api.chat.hover.content.Text;
import net.md_5.bungee.chat.ComponentSerializer;

public class ChatComponentUtils {

Expand Down Expand Up @@ -306,7 +307,7 @@ public static BaseComponent cleanUpLegacyText(BaseComponent basecomponent, Playe
}

BaseComponent current = null;
for (BaseComponent base : CustomStringUtils.loadExtras(basecomponent)) {
for (BaseComponent base : list) {
List<BaseComponent> thislist = new LinkedList<BaseComponent>();
if (base instanceof TextComponent) {
List<TextComponent> texts = Stream.of(TextComponent.fromLegacyText(base.toLegacyText())).map(each -> (TextComponent) each).collect(Collectors.toList());
Expand Down

0 comments on commit 1a989c6

Please sign in to comment.