diff options
author | syeyoung <cyong06@naver.com> | 2021-07-12 00:04:29 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-07-12 00:04:29 +0900 |
commit | 0508914bfe927cdeb8efd148e99e5290eb01fe51 (patch) | |
tree | fc6ec6c5c2cd3774cb3f990a027921a3ec188b44 | |
parent | f8ad8cce99560e8991ceca7a0937e4a144ed0937 (diff) | |
download | Skyblock-Dungeons-Guide-0508914bfe927cdeb8efd148e99e5290eb01fe51.tar.gz Skyblock-Dungeons-Guide-0508914bfe927cdeb8efd148e99e5290eb01fe51.tar.bz2 Skyblock-Dungeons-Guide-0508914bfe927cdeb8efd148e99e5290eb01fe51.zip |
better cosmetics
11 files changed, 657 insertions, 114 deletions
diff --git a/build.gradle b/build.gradle index 76198293..3012eaa2 100755 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ buildscript { maven { url "https://jitpack.io" } } dependencies { - classpath "com.github.Skytils:ForgeGradle:FG_2.1-SNAPSHOT" + classpath "com.github.Skytils:ForgeGradle:6f5327" classpath "com.github.jengelman.gradle.plugins:shadow:6.1.0" } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Main.java b/src/main/java/kr/syeyoung/dungeonsguide/Main.java index 6e2e887e..bd6a34bb 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/Main.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/Main.java @@ -35,11 +35,14 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import scala.tools.nsc.Global; import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import java.io.*; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.net.URL; import java.security.*; import java.security.cert.CertificateException; @@ -80,6 +83,11 @@ public class Main e.printStackTrace(); } } + + + + + } @SubscribeEvent(priority = EventPriority.HIGHEST) diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java index 47a2f4e1..b24b5194 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java @@ -22,6 +22,7 @@ import com.google.gson.JsonObject; import kr.syeyoung.dungeonsguide.DungeonsGuide; import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.cosmetics.chatreplacers.*; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; @@ -48,6 +49,7 @@ import net.minecraft.util.ChatStyle; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.json.JSONObject; import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; @@ -194,42 +196,42 @@ public class CommandDungeonsGuide extends CommandBase { DungeonRoomInfo dri = (DungeonRoomInfo) ois.readObject(); ois.close(); fis.close(); - System.out.println("Starting at "+dri.getName() +" - "+dri.getUuid()); + System.out.println("Starting at " + dri.getName() + " - " + dri.getUuid()); for (Map.Entry<String, DungeonMechanic> value2 : dri.getMechanics().entrySet()) { DungeonMechanic value = value2.getValue(); if (value instanceof DungeonSecret && (((DungeonSecret) value).getSecretType() == DungeonSecret.SecretType.BAT - || ((DungeonSecret) value).getSecretType() == DungeonSecret.SecretType.CHEST) - && ((DungeonSecret) value).getSecretPoint().getY() == 0) { + || ((DungeonSecret) value).getSecretType() == DungeonSecret.SecretType.CHEST) + && ((DungeonSecret) value).getSecretPoint().getY() == 0) { OffsetPoint offsetPoint = ((DungeonSecret) value).getSecretPoint(); dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; - System.out.println("Fixing "+value2.getKey()+" - as secret "+((DungeonSecret) value).getSecretType() + " - at "+((DungeonSecret) value).getSecretPoint()); + System.out.println("Fixing " + value2.getKey() + " - as secret " + ((DungeonSecret) value).getSecretType() + " - at " + ((DungeonSecret) value).getSecretPoint()); } else if (value instanceof DungeonOnewayDoor) { for (OffsetPoint offsetPoint : ((DungeonOnewayDoor) value).getSecretPoint().getOffsetPointList()) { if (offsetPoint.getY() == 0) { dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; - System.out.println("Fixing "+value2.getKey()+" - o-door - at "+offsetPoint); + System.out.println("Fixing " + value2.getKey() + " - o-door - at " + offsetPoint); } } } else if (value instanceof DungeonDoor) { for (OffsetPoint offsetPoint : ((DungeonDoor) value).getSecretPoint().getOffsetPointList()) { if (offsetPoint.getY() == 0) { dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; - System.out.println("Fixing "+value2.getKey()+" - door - at "+offsetPoint); + System.out.println("Fixing " + value2.getKey() + " - door - at " + offsetPoint); } } } else if (value instanceof DungeonBreakableWall) { for (OffsetPoint offsetPoint : ((DungeonBreakableWall) value).getSecretPoint().getOffsetPointList()) { if (offsetPoint.getY() == 0) { dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; - System.out.println("Fixing "+value2.getKey()+" - wall - at "+offsetPoint); + System.out.println("Fixing " + value2.getKey() + " - wall - at " + offsetPoint); } } } else if (value instanceof DungeonTomb) { for (OffsetPoint offsetPoint : ((DungeonTomb) value).getSecretPoint().getOffsetPointList()) { if (offsetPoint.getY() == 0) { dri.getBlocks()[offsetPoint.getZ()][offsetPoint.getX()] = -1; - System.out.println("Fixing "+value2.getKey()+" - crypt - at "+offsetPoint); + System.out.println("Fixing " + value2.getKey() + " - crypt - at " + offsetPoint); } } } @@ -243,7 +245,7 @@ public class CommandDungeonsGuide extends CommandBase { e.printStackTrace(); } } - } else if (args[0].equals("reloaddungeon") && Minecraft.getMinecraft().getSession().getPlayerID().replace("-", "").equals("e686fe0aab804a71ac7011dc8c2b534c")){ + } else if (args[0].equals("reloaddungeon") && Minecraft.getMinecraft().getSession().getPlayerID().replace("-", "").equals("e686fe0aab804a71ac7011dc8c2b534c")) { try { MinecraftForge.EVENT_BUS.post(new DungeonLeftEvent()); DungeonsGuide.getDungeonsGuide().getSkyblockStatus().setContext(null); @@ -292,15 +294,15 @@ public class CommandDungeonsGuide extends CommandBase { sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cYou don't have perms in the party to invite people!")); } else { PartyManager.INSTANCE.toggleAllowAskToJoin(); - sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fToggled Ask to join to "+(PartyManager.INSTANCE.isAllowAskToJoin() ? "§eon" : "§coff"))); + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fToggled Ask to join to " + (PartyManager.INSTANCE.isAllowAskToJoin() ? "§eon" : "§coff"))); } if (!FeatureRegistry.ADVANCED_RICHPRESENCE.isEnabled()) { sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cDiscord Rich Presence is disabled! Enable at /dg -> Advanced ")); } } else if (args[0].equalsIgnoreCase("partymax") || args[0].equalsIgnoreCase("pm")) { - if (args.length == 1){ - sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fCurrent party max is §e"+PartyManager.INSTANCE.getMaxParty())); + if (args.length == 1) { + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fCurrent party max is §e" + PartyManager.INSTANCE.getMaxParty())); } else if (args.length == 2) { try { int partyMax = Integer.parseInt(args[1]); @@ -310,23 +312,23 @@ public class CommandDungeonsGuide extends CommandBase { } PartyManager.INSTANCE.setMaxParty(partyMax); - sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fSuccessfully set partymax to §e"+PartyManager.INSTANCE.getMaxParty())); + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fSuccessfully set partymax to §e" + PartyManager.INSTANCE.getMaxParty())); } catch (Exception e) { - sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §c"+args[1]+" is not valid number.")); + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §c" + args[1] + " is not valid number.")); return; } } } else if (args[0].equals("partyid")) { - sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fInternal Party id: "+PartyManager.INSTANCE.getPartyID())); + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fInternal Party id: " + PartyManager.INSTANCE.getPartyID())); } else if (args[0].equalsIgnoreCase("loc")) { - sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fYou're in "+ DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName())); + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fYou're in " + DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName())); } else if (args[0].equalsIgnoreCase("saverun")) { try { File f = DungeonsGuide.getDungeonsGuide().getConfigDir(); File runDir = new File(f, "dungeonruns"); runDir.mkdirs(); - File runFile = new File(runDir, UUID.randomUUID() +".dgrun"); + File runFile = new File(runDir, UUID.randomUUID() + ".dgrun"); DungeonContext dungeonContext = DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getContext(); if (dungeonContext == null) { @@ -343,16 +345,16 @@ public class CommandDungeonsGuide extends CommandBase { oos.writeObject(dungeonEventHolder); oos.flush(); oos.close(); - sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fSuccessfully saved dungeon run to "+runFile.getAbsolutePath())); + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fSuccessfully saved dungeon run to " + runFile.getAbsolutePath())); } catch (Exception e) { - sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cAn error occured while writing rundata "+e.getMessage())); + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cAn error occured while writing rundata " + e.getMessage())); e.printStackTrace(); } } else if (args[0].equals("pv")) { try { ApiFetchur.fetchUUIDAsync(args[1]) .thenAccept(a -> { - sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e"+args[1]+"§f's Profile ").appendSibling(new ChatComponentText("§7view").setChatStyle(new ChatStyle().setChatHoverEvent(new FeatureViewPlayerOnJoin.HoverEventRenderPlayer(a.orElse(null)))))); + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e" + args[1] + "§f's Profile ").appendSibling(new ChatComponentText("§7view").setChatStyle(new ChatStyle().setChatHoverEvent(new FeatureViewPlayerOnJoin.HoverEventRenderPlayer(a.orElse(null)))))); }); } catch (Exception e) { e.printStackTrace(); @@ -369,8 +371,13 @@ public class CommandDungeonsGuide extends CommandBase { String[] payload = new String[args.length - 1]; System.arraycopy(args, 1, payload, 0, payload.length); String actualPayload = String.join(" ", payload).replace("$C$", "§"); - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().header("destination", "/queue/party.broadcast").payload(actualPayload)); - } catch (Exception e) {e.printStackTrace();} + DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload().header("destination", "/app/party.broadcast").payload( + new JSONObject().put("partyID", PartyManager.INSTANCE.getPartyID()) + .put("payload", actualPayload).toString() + )); + } catch (Exception e) { + e.printStackTrace(); + } } else { sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg §7-§fOpens configuration gui")); sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg gui §7-§fOpens configuration gui")); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java index faa41214..f208ac74 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java @@ -20,20 +20,22 @@ package kr.syeyoung.dungeonsguide.cosmetics; import com.google.gson.JsonPrimitive; import kr.syeyoung.dungeonsguide.DungeonsGuide; +import kr.syeyoung.dungeonsguide.cosmetics.chatreplacers.*; import kr.syeyoung.dungeonsguide.events.PlayerListItemPacketEvent; import kr.syeyoung.dungeonsguide.events.StompConnectedEvent; import kr.syeyoung.dungeonsguide.stomp.*; import kr.syeyoung.dungeonsguide.utils.TextUtils; import lombok.Getter; +import lombok.Setter; import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.play.server.S38PacketPlayerListItem; import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.*; import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.EventPriority; @@ -231,100 +233,26 @@ public class CosmeticsManager implements StompMessageHandler { requestActiveCosmetics(); requestPerms(); } - - // §9Party §8> §a[VIP§6+§a] syeyoung§f: ty - // §2Guild > §a[VIP§6+§a] syeyoung §3[Vet]§f - // §dTo §r§a[VIP§r§6+§r§a] SlashSlayer§r§7: §r§7what§r - // §dFrom §r§a[VIP§r§6+§r§a] SlashSlayer§r§7: §r§7?§r - // §7Rock_Bird§7§r§7: SELLING 30 DIAMOD BLOCK /p me§r - // §b[MVP§c+§b] Probutnoobgamer§f: quitting skyblock! highe - // §r§bCo-op > §a[VIP§6+§a] syeyoung§f: §rwhat§r - - public static String substitute(String str) { - str = str.replace("{HYPIXEL_RANKED_NAME}", "{ANY_COLOR}(?:\\[[a-zA-Z\\+§0-9]+\\] )?{MC_NAME}"); - str = str.replace("{HYPIXEL_RANKED_NAME_PAT}", "({ANY_COLOR}(?:\\[[a-zA-Z\\+§0-9]+\\] )?)({MC_NAME})"); - str = str.replace("{ISLAND_VISITOR}", "(?:§r§a\\[✌\\] )"); - str = str.replace("{RANK}", "(?:{ANY_COLOR}\\[[a-zA-Z0-9_ ]+\\] )"); - str = str.replace("{MC_NAME}", "[a-zA-Z0-9_]+"); - str = str.replace("{ANY_COLOR}", "(?:§[a-zA-Z0-9])*"); - return str; + @Getter @Setter + private static Set<IChatReplacer> iChatReplacers = new HashSet<>(); + static { + iChatReplacers.add(new ChatReplacerViewProfile()); + iChatReplacers.add(new ChatReplacerSocialOptions()); + iChatReplacers.add(new ChatReplacerCoop()); + iChatReplacers.add(new ChatReplacerMessage()); + iChatReplacers.add(new ChatReplacerChatByMe()); } - private static final Pattern PARTY_MSG = Pattern.compile(substitute("§r§9P(?:arty)? §8> {HYPIXEL_RANKED_NAME_PAT}({ANY_COLOR}): (.+)")); - private static final Pattern GUILD_MSG = Pattern.compile(substitute("§r§2G(?:uild)? > {HYPIXEL_RANKED_NAME_PAT}((?: {ANY_COLOR}\\[.+\\])?{ANY_COLOR}): (.+)")); - private static final Pattern CHAT_MSG = Pattern.compile(substitute("({ISLAND_VISITOR}?{RANK}?){HYPIXEL_RANKED_NAME_PAT}({ANY_COLOR}): (.+)")); - private static final Pattern COOP_MSG = Pattern.compile(substitute("§r§bCo-op > {HYPIXEL_RANKED_NAME_PAT}({ANY_COLOR}): (.+)")); - private static final Pattern DM_TO = Pattern.compile(substitute("§dTo §r{HYPIXEL_RANKED_NAME_PAT}§r§7: (.+)")); - private static final Pattern DM_FROM = Pattern.compile(substitute("§dFrom §r{HYPIXEL_RANKED_NAME_PAT}§r§7: (.+)")); - @SubscribeEvent(priority = EventPriority.LOWEST) public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - Matcher m; - String msg = clientChatReceivedEvent.message.getFormattedText(); - boolean match = false; - String preRank = ""; - String rank = ""; - String last = ""; - String nickname = ""; - if ((m = PARTY_MSG.matcher(msg)).matches()) { - match = true; - nickname = m.group(2); - preRank = "§r§9Party §8> "; - rank = m.group(1); - last = m.group(2)+m.group(3)+": "+m.group(4); - } else if ((m = GUILD_MSG.matcher(msg)).matches()) { - match = true; - nickname = m.group(2); - preRank = "§r§2Guild > "; - rank = m.group(1); - last = m.group(2)+m.group(3)+": "+m.group(4); - } else if ((m = CHAT_MSG.matcher(msg)).matches()) { - match = true; - nickname = m.group(3); - preRank = m.group(1); - rank = m.group(2); - last = m.group(3)+m.group(4)+": "+m.group(5); - } else if ((m = COOP_MSG.matcher(msg)).matches()) { - match = true; - nickname = m.group(2); - preRank = "§r§bCo-op > "; - rank = m.group(1); - last = m.group(2)+m.group(3)+": "+m.group(4); - } else if ((m = DM_TO.matcher(msg)).matches()) { - match = true; - nickname = m.group(2); - preRank = "§dTo §r"; - rank = m.group(1); - last = m.group(2)+"§r§7: "+m.group(3); - } else if ((m = DM_FROM.matcher(msg)).matches()) { - match = true; - nickname = m.group(2); - preRank = "§dFrom §r"; - rank = m.group(1); - last = m.group(2)+"§r§7: "+m.group(3); - } - - if (!match) return; - - List<ActiveCosmetic> activeCosmetics = activeCosmeticByPlayerNameLowerCase.get(nickname.toLowerCase()); - if (activeCosmetics != null) { - CosmeticData prefix = null, color =null; - for (ActiveCosmetic activeCosmetic : activeCosmetics) { - CosmeticData cosmeticData = cosmeticDataMap.get(activeCosmetic.getCosmeticData()); - if (cosmeticData == null) continue; - if (cosmeticData.getCosmeticType().equals("prefix")) prefix = cosmeticData; - if (cosmeticData.getCosmeticType().equals("color")) color = cosmeticData; - } - - if (prefix != null) { - preRank += prefix.getData().replace("&", "§")+" "; - } - if (color != null) { - last = color.getData().replace("&", "§") + last; + if (clientChatReceivedEvent.type == 2) return; + for (IChatReplacer iChatReplacer : iChatReplacers) { + if (iChatReplacer.isAcceptable(clientChatReceivedEvent)) { + System.out.println("Chosen "+iChatReplacer); + iChatReplacer.translate(clientChatReceivedEvent, this); + return; } } - - clientChatReceivedEvent.message = new ChatComponentText(preRank + rank + last); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java new file mode 100644 index 00000000..b2bcfc0e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java @@ -0,0 +1,26 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.cosmetics; + +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +public interface IChatReplacer { + boolean isAcceptable(ClientChatReceivedEvent event); + void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java new file mode 100644 index 00000000..28fb861e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java @@ -0,0 +1,105 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.cosmetics.chatreplacers; + +import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.cosmetics.IChatReplacer; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.Tuple; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.List; + +public class ChatReplacerChatByMe implements IChatReplacer { + @Override + public boolean isAcceptable(ClientChatReceivedEvent event) { + for (IChatComponent sibling : event.message.getSiblings()) { + if (sibling.getUnformattedTextForChat().startsWith(": ")) return true; + } + return false; + } + + @Override + public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { + List<Tuple<IChatComponent, IChatComponent>> replaceMents = new ArrayList<>(); + List<IChatComponent> iChatComponents = new ArrayList<>( event.message.getSiblings() ); + List<IChatComponent> hasMsg = new ArrayList<>(); + for (IChatComponent sibling : iChatComponents) { + if (sibling.getUnformattedTextForChat().startsWith(": ")) break; + hasMsg.add(sibling); + } + iChatComponents.removeAll(hasMsg); + + ChatComponentText chatComponents = new ChatComponentText(""); + chatComponents.getSiblings().addAll(hasMsg); + ChatStyle origStyle = hasMsg.get(0).getChatStyle(); + String name = chatComponents.getFormattedText(); + + + String[] splited = name.split(" "); + String actualName = splited[splited.length-1]; + + List<ActiveCosmetic> cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(TextUtils.stripColor(actualName).toLowerCase()); + if (cDatas == null || splited.length > 2) return; + CosmeticData color=null, prefix=null; + for (ActiveCosmetic activeCosmetic : cDatas) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + String building = ""; + if (prefix != null) building += prefix.getData().replace("&", "§") + " "; + if (splited.length == 2) building += splited[0] +" "; + + if (color != null) { + String nick = splited[1]; + building += color.getData().replace("&","§"); + boolean foundLegitChar = false; + boolean foundColor = false; + for (char c : nick.toCharArray()) { + if (foundColor) { + foundColor = false; continue; + } + if (c == '§' && !foundLegitChar) foundColor = true; + else { + foundLegitChar = true; + building += c; + } + } + } else { + building += splited[1] ; + } + + ChatComponentText chatComponents1 = new ChatComponentText(building); + chatComponents1.setChatStyle(origStyle); + event.message.getSiblings().clear(); + event.message.getSiblings().add(chatComponents1); + event.message.getSiblings().addAll(iChatComponents); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java new file mode 100644 index 00000000..91bb58b6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java @@ -0,0 +1,121 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.cosmetics.chatreplacers; + +import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.cosmetics.IChatReplacer; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.Tuple; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class ChatReplacerCoop implements IChatReplacer { + @Override + public boolean isAcceptable(ClientChatReceivedEvent event) { + for (IChatComponent sibling : event.message.getSiblings()) { + if (sibling.getUnformattedTextForChat().startsWith("§bCo-op > ")) return true; + } + return false; + } + + @Override + public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { + List<Tuple<IChatComponent, IChatComponent>> replaceMents = new ArrayList<>(); + List<IChatComponent> iChatComponents = new ArrayList<>( event.message.getSiblings() ); + IChatComponent sibling = iChatComponents.get(0); iChatComponents.remove(sibling); + + + String[] splitInto = sibling.getUnformattedTextForChat().split(" "); + int lastValidNickname = -1; + int lastprefix = -1; + for (int i = 0; i < splitInto.length; i++) { + String s = TextUtils.stripColor(splitInto[i]); + char c = s.charAt(0); + if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_' || c == '-') { + lastValidNickname = i; + } + } + if (lastValidNickname == -1) return; + + if (lastValidNickname -1 >= 0 && TextUtils.stripColor(splitInto[lastValidNickname - 1]).charAt(0) == '[') lastprefix = lastValidNickname -1; + else lastprefix = lastValidNickname; + + + List<ActiveCosmetic> cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(TextUtils.stripColor(splitInto[lastValidNickname].substring(0, splitInto[lastValidNickname].length()-1)).toLowerCase()); + + if (cDatas == null) return; + + CosmeticData color = null, prefix = null; + for (ActiveCosmetic activeCosmetic : cDatas) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData != null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + String building = ""; + for (int i = 0; i < lastprefix; i++) { + building += splitInto[i] +" "; + } + if (prefix != null) building += prefix.getData().replace("&", "§") + " "; + for (int i = lastprefix; i < lastValidNickname; i++) { + building += splitInto[i] +" "; + } + if (color != null) { + String nick = splitInto[lastValidNickname]; + building += color.getData().replace("&","§"); + boolean foundLegitChar = false; + boolean foundColor = false; + for (char c : nick.toCharArray()) { + if (foundColor) { + foundColor = false; continue; + } + if (c == '§' && !foundLegitChar) foundColor = true; + else { + foundLegitChar = true; + building += c; + } + } + building += " "; + } else { + building += splitInto[lastValidNickname] + " "; + } + for (int i = lastValidNickname+1; i<splitInto.length; i++) { + building += splitInto[i] + " "; + } + if (sibling.getUnformattedTextForChat().charAt(sibling.getUnformattedText().length()-1) != ' ') + building = building.substring(0, building.length() - 1); + + ChatComponentText chatComponents1 = new ChatComponentText(building); + chatComponents1.setChatStyle(sibling.getChatStyle()); + event.message.getSiblings().clear(); + event.message.getSiblings().add(chatComponents1); + event.message.getSiblings().addAll(iChatComponents); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerMessage.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerMessage.java new file mode 100644 index 00000000..14c2bd11 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerMessage.java @@ -0,0 +1,107 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.cosmetics.chatreplacers; + +import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.cosmetics.IChatReplacer; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.Tuple; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class ChatReplacerMessage implements IChatReplacer { + @Override + public boolean isAcceptable(ClientChatReceivedEvent event) { + for (IChatComponent sibling : event.message.getSiblings()) { + if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/msg")) return true; + } + return false; + } + + @Override + public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { + List<Tuple<IChatComponent, IChatComponent>> replaceMents = new ArrayList<>(); + List<IChatComponent> iChatComponents = new ArrayList<>( event.message.getSiblings() ); + List<IChatComponent> hasMsg = new ArrayList<>(); + for (IChatComponent sibling : iChatComponents) { + if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/msg")) { + hasMsg.add(sibling); + } + } + iChatComponents.removeAll(hasMsg); + + ChatComponentText chatComponents = new ChatComponentText(""); + chatComponents.getSiblings().addAll(hasMsg); + ChatStyle origStyle = hasMsg.get(0).getChatStyle(); + String name = chatComponents.getFormattedText(); + + + String[] splited = name.split(" "); + String actualName = splited[splited.length-1]; + + List<ActiveCosmetic> cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(TextUtils.stripColor(actualName).toLowerCase()); + if (cDatas == null || splited.length > 2) return; + CosmeticData color=null, prefix=null; + for (ActiveCosmetic activeCosmetic : cDatas) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + String building = ""; + if (prefix != null) building += prefix.getData().replace("&", "§") + " "; + if (splited.length == 2) building += splited[0] +" "; + + if (color != null) { + String nick = splited[1]; + building += color.getData().replace("&","§"); + boolean foundLegitChar = false; + boolean foundColor = false; + for (char c : nick.toCharArray()) { + if (foundColor) { + foundColor = false; continue; + } + if (c == '§' && !foundLegitChar) foundColor = true; + else { + foundLegitChar = true; + building += c; + } + } + } else { + building += splited[1] ; + } + + ChatComponentText chatComponents1 = new ChatComponentText(building); + chatComponents1.setChatStyle(origStyle); + event.message.getSiblings().clear(); + event.message.getSiblings().add(chatComponents1); + event.message.getSiblings().addAll(iChatComponents); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerSocialOptions.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerSocialOptions.java new file mode 100644 index 00000000..62e8e0af --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerSocialOptions.java @@ -0,0 +1,117 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.cosmetics.chatreplacers; + +import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.cosmetics.IChatReplacer; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.Tuple; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class ChatReplacerSocialOptions implements IChatReplacer { + @Override + public boolean isAcceptable(ClientChatReceivedEvent event) { + if (event.message.getChatStyle() != null && event.message.getChatStyle().getChatClickEvent() != null && event.message.getChatStyle().getChatClickEvent().getValue().startsWith("/socialoptions")) return true; + return false; + } + + @Override + public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { + if (event.message.getChatStyle() != null && event.message.getChatStyle().getChatClickEvent() != null && event.message.getChatStyle().getChatClickEvent().getValue().startsWith("/socialoptions")) { + String username = event.message.getChatStyle().getChatClickEvent().getValue().split(" ")[1]; + List<ActiveCosmetic> cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(username.toLowerCase()); + + if (cDatas != null) { + CosmeticData color=null, prefix=null; + for (ActiveCosmetic activeCosmetic : cDatas) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + String[] splitInto = event.message.getUnformattedTextForChat().split(" "); + int lastValidNickname = -1; + int lastprefix = -1; + for (int i = 0; i < splitInto.length; i++) { + String s = splitInto[i]; + if (s.startsWith("§7")) s = s.substring(2); + char c = s.charAt(0); + if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_' || c == '-') { + lastValidNickname = i; + } + } + if (lastValidNickname == -1) return; + + if (lastValidNickname -1 >= 0 && TextUtils.stripColor(splitInto[lastValidNickname - 1]).charAt(0) == '[') lastprefix = lastValidNickname -1; + else lastprefix = lastValidNickname; + + String building = ""; + for (int i = 0; i < lastprefix; i++) { + building += splitInto[i] +" "; + } + if (prefix != null) building += prefix.getData().replace("&", "§") + " "; + for (int i = lastprefix; i < lastValidNickname; i++) { + building += splitInto[i] +" "; + } + if (color != null) { + String nick = splitInto[lastValidNickname]; + building += color.getData().replace("&","§"); + boolean foundLegitChar = false; + boolean foundColor = false; + for (char c : nick.toCharArray()) { + if (foundColor) { + foundColor = false; continue; + } + if (c == '§' && !foundLegitChar) foundColor = true; + else { + foundLegitChar = true; + building += c; + } + } + building += " "; + } else { + building += splitInto[lastValidNickname] + " "; + } + for (int i = lastValidNickname+1; i<splitInto.length; i++) { + building += splitInto[i] + " "; + } + if (event.message.getUnformattedTextForChat().charAt(event.message.getUnformattedTextForChat().length()-1) != ' ') + building = building.substring(0, building.length() - 1); + + ChatComponentText newChatCompText = new ChatComponentText(building); + newChatCompText.setChatStyle(event.message.getChatStyle()); + newChatCompText.getSiblings().addAll(event.message.getSiblings()); + + event.message = newChatCompText; + } + } + + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerViewProfile.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerViewProfile.java new file mode 100644 index 00000000..abd399e3 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerViewProfile.java @@ -0,0 +1,124 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.cosmetics.chatreplacers; + +import kr.syeyoung.dungeonsguide.cosmetics.ActiveCosmetic; +import kr.syeyoung.dungeonsguide.cosmetics.CosmeticData; +import kr.syeyoung.dungeonsguide.cosmetics.CosmeticsManager; +import kr.syeyoung.dungeonsguide.cosmetics.IChatReplacer; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.Tuple; +import net.minecraftforge.client.event.ClientChatReceivedEvent; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class ChatReplacerViewProfile implements IChatReplacer { + @Override + public boolean isAcceptable(ClientChatReceivedEvent event) { + System.out.println(event.message); + for (IChatComponent sibling : event.message.getSiblings()) { + if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/viewprofile")) return true; + } + return false; + } + + @Override + public void translate(ClientChatReceivedEvent event, CosmeticsManager cosmeticsManager) { + List<Tuple<IChatComponent, IChatComponent>> replaceMents = new ArrayList<>(); + for (IChatComponent sibling : event.message.getSiblings()) { + if (sibling.getChatStyle() != null && sibling.getChatStyle().getChatClickEvent() != null && sibling.getChatStyle().getChatClickEvent().getValue().startsWith("/viewprofile")) { + String uid = sibling.getChatStyle().getChatClickEvent().getValue().split(" ")[1]; + List<ActiveCosmetic> cDatas = cosmeticsManager.getActiveCosmeticByPlayer().get(UUID.fromString(uid)); + + if (cDatas != null) { + CosmeticData color=null, prefix=null; + for (ActiveCosmetic activeCosmetic : cDatas) { + CosmeticData cosmeticData = cosmeticsManager.getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); + if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { + color = cosmeticData; + } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { + prefix = cosmeticData; + } + } + + String[] splitInto = sibling.getUnformattedTextForChat().split(" "); + int lastValidNickname = -1; + int lastprefix = -1; + for (int i = 0; i < splitInto.length; i++) { + String s = TextUtils.stripColor(splitInto[i]); + char c = s.charAt(0); + if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_' || c == '-') { + lastValidNickname = i; + } + } + if (lastValidNickname == -1) continue; + + if (lastValidNickname -1 >= 0 && TextUtils.stripColor(splitInto[lastValidNickname - 1]).charAt(0) == '[') lastprefix = lastValidNickname -1; + else lastprefix = lastValidNickname; + + String building = ""; + for (int i = 0; i < lastprefix; i++) { + building += splitInto[i] +" "; + } + if (prefix != null) building += prefix.getData().replace("&", "§") + " "; + for (int i = lastprefix; i < lastValidNickname; i++) { + building += splitInto[i] +" "; + } + if (color != null) { + String nick = splitInto[lastValidNickname]; + building += color.getData().replace("&","§"); + boolean foundLegitChar = false; + boolean foundColor = false; + for (char c : nick.toCharArray()) { + if (foundColor) { + foundColor = false; continue; + } + if (c == '§' && !foundLegitChar) foundColor = true; + else { + foundLegitChar = true; + building += c; + } + } + building += " "; + } else { + building += splitInto[lastValidNickname] + " "; + } + for (int i = lastValidNickname+1; i<splitInto.length; i++) { + building += splitInto[i] + " "; + } + if (sibling.getUnformattedTextForChat().charAt(sibling.getUnformattedText().length()-1) != ' ') + building = building.substring(0, building.length() - 1); + + ChatComponentText newChatCompText = new ChatComponentText(building); + newChatCompText.setChatStyle(sibling.getChatStyle()); + replaceMents.add(new Tuple<>(sibling, newChatCompText)); + } + } + } + + for (Tuple<IChatComponent, IChatComponent> replaceMent : replaceMents) { + int index = event.message.getSiblings().indexOf(replaceMent.getFirst()); + event.message.getSiblings().set(index, replaceMent.getSecond()); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/party/PartyManager.java b/src/main/java/kr/syeyoung/dungeonsguide/party/PartyManager.java index 0368ecfc..feb3757a 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/party/PartyManager.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/party/PartyManager.java @@ -395,7 +395,7 @@ public class PartyManager implements StompMessageHandler { } } else if ("/user/queue/party.broadcast".equals(stompPayload.headers().get("destination"))) { try { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: Message Broadcasted from player:: \n" + stompPayload.payload())); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: Message Broadcasted from player:: \n" + new JSONObject(stompPayload.payload()).getString("payload"))); } catch (Exception e) { e.printStackTrace(); } |