From 20dd3f99a7b139b5848128246c622fd9cfefa478 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sat, 21 May 2022 21:18:14 +0900 Subject: - Project separation --- .../dungeonsguide/cosmetics/ActiveCosmetic.java | 12 - .../dungeonsguide/cosmetics/CosmeticData.java | 14 - .../dungeonsguide/cosmetics/CosmeticsManager.java | 300 --------------------- .../cosmetics/CustomNetworkPlayerInfo.java | 103 ------- .../cosmetics/CustomPacketPlayerListItem.java | 39 --- .../dungeonsguide/cosmetics/IChatReplacer.java | 26 -- .../chatreplacers/ChatReplacerChatByMe.java | 106 -------- .../cosmetics/chatreplacers/ChatReplacerCoop.java | 121 --------- .../chatreplacers/ChatReplacerMessage.java | 107 -------- .../cosmetics/chatreplacers/ChatReplacerPV.java | 119 -------- .../chatreplacers/ChatReplacerSocialOptions.java | 121 --------- .../chatreplacers/ChatReplacerViewProfile.java | 128 --------- 12 files changed, 1196 deletions(-) delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/ActiveCosmetic.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticData.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerMessage.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerPV.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerSocialOptions.java delete mode 100644 src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerViewProfile.java (limited to 'src/main/java/kr/syeyoung/dungeonsguide/cosmetics') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/ActiveCosmetic.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/ActiveCosmetic.java deleted file mode 100644 index f00ecf06..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/ActiveCosmetic.java +++ /dev/null @@ -1,12 +0,0 @@ -package kr.syeyoung.dungeonsguide.cosmetics; - -import lombok.Data; -import java.util.UUID; - -@Data -public class ActiveCosmetic { - private UUID activityUID; - private UUID playerUID; - private UUID cosmeticData; - private String username; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticData.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticData.java deleted file mode 100644 index 24842a8e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticData.java +++ /dev/null @@ -1,14 +0,0 @@ -package kr.syeyoung.dungeonsguide.cosmetics; - - -import lombok.Data; - -import java.util.UUID; - -@Data -public class CosmeticData { - private UUID id; - private String cosmeticType; - private String reqPerm; - private String data; -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java deleted file mode 100644 index fa597962..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * 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 . - */ - -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.*; -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; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.relauncher.ReflectionHelper; -import org.json.JSONArray; -import org.json.JSONObject; - -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.CopyOnWriteArraySet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class CosmeticsManager implements StompMessageHandler { - @Getter - private Map cosmeticDataMap = new ConcurrentHashMap<>(); - @Getter - private Map activeCosmeticMap = new ConcurrentHashMap<>(); - @Getter - private Map> activeCosmeticByType = new ConcurrentHashMap<>(); - @Getter - private Map> activeCosmeticByPlayer = new ConcurrentHashMap<>(); - @Getter - private Map> activeCosmeticByPlayerNameLowerCase = new ConcurrentHashMap<>(); - @Getter - private Set perms = new CopyOnWriteArraySet<>(); - - public void requestActiveCosmetics() { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload() - .method(StompHeader.SEND) - .header("destination", "/app/cosmetic.activelist") - ); - } - public void requestCosmeticsList() { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload() - .method(StompHeader.SEND) - .header("destination", "/app/cosmetic.list") - ); - } - public void requestPerms() { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload() - .method(StompHeader.SEND) - .header("destination", "/app/user.perms") - ); - } - public void setCosmetic(CosmeticData cosmetic) { - if (!perms.contains(cosmetic.getReqPerm())) return; - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload() - .method(StompHeader.SEND) - .header("destination", "/app/cosmetic.set") - .payload(cosmetic.getId().toString()) - ); - } - public void removeCosmetic(ActiveCosmetic activeCosmetic) { - DungeonsGuide.getDungeonsGuide().getStompConnection().send(new StompPayload() - .method(StompHeader.SEND) - .header("destination", "/app/cosmetic.remove") - .payload(activeCosmetic.getActivityUID().toString()) - ); - } - - @Override - public void handle(StompInterface stompInterface, StompPayload stompPayload) { - String destination = stompPayload.headers().get("destination"); - if (destination.equals("/topic/cosmetic.set")) { - JSONObject jsonObject = new JSONObject(stompPayload.payload()); - ActiveCosmetic activeCosmetic = new ActiveCosmetic(); - activeCosmetic.setActivityUID(UUID.fromString(jsonObject.getString("activityUID"))); - activeCosmetic.setPlayerUID(UUID.fromString(jsonObject.getString("playerUID"))); - if (jsonObject.isNull("cosmeticUID")) { - ActiveCosmetic activeCosmetic1 = activeCosmeticMap.remove(activeCosmetic.getActivityUID()); - - List activeCosmetics = activeCosmeticByPlayer.computeIfAbsent(activeCosmetic.getPlayerUID(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.remove(activeCosmetic1); - - activeCosmetics = activeCosmeticByPlayerNameLowerCase.computeIfAbsent(activeCosmetic1.getUsername().toLowerCase(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.remove(activeCosmetic1); - - CosmeticData cosmeticData = cosmeticDataMap.get(activeCosmetic.getCosmeticData()); - if (cosmeticData != null) { - List cosmeticsByTypeList = activeCosmeticByType.computeIfAbsent(cosmeticData.getCosmeticType(), a-> new CopyOnWriteArrayList<>()); - cosmeticsByTypeList.remove(activeCosmetic1); - } - } else { - activeCosmetic.setCosmeticData(UUID.fromString(jsonObject.getString("cosmeticUID"))); - activeCosmetic.setUsername(jsonObject.getString("username")); - - ActiveCosmetic previousThing = activeCosmeticMap.get(activeCosmetic.getActivityUID()); - activeCosmeticMap.put(activeCosmetic.getActivityUID(), activeCosmetic); - - CosmeticData cosmeticData = cosmeticDataMap.get(activeCosmetic.getCosmeticData()); - if (cosmeticData != null) { - List cosmeticsByTypeList = activeCosmeticByType.computeIfAbsent(cosmeticData.getCosmeticType(), a-> new CopyOnWriteArrayList<>()); - cosmeticsByTypeList.add(activeCosmetic); - cosmeticsByTypeList.remove(previousThing); - } - List activeCosmetics = activeCosmeticByPlayer.computeIfAbsent(activeCosmetic.getPlayerUID(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.add(activeCosmetic); - activeCosmetics.remove(previousThing); - - activeCosmetics = activeCosmeticByPlayerNameLowerCase.computeIfAbsent(activeCosmetic.getUsername().toLowerCase(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.add(activeCosmetic); - activeCosmetics.remove(previousThing); - } - - try { - if (Minecraft.getMinecraft().theWorld != null) { - EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByUUID(activeCosmetic.getPlayerUID()); - if (entityPlayer != null) entityPlayer.refreshDisplayName(); - } - } catch (Exception e) {e.printStackTrace();} - - } else if (destination.equals("/user/queue/reply/user.perms")) { - JSONArray object = new JSONArray(stompPayload.payload()); - Set cache = new HashSet<>(); - for (Object o : object) { - cache.add((String) o); - } - this.perms = cache; - } else if (destination.equals("/user/queue/reply/cosmetic.activelist")) { - Map activeCosmeticMap = new HashMap<>(); - JSONArray object = new JSONArray(stompPayload.payload()); - for (Object o : object) { - JSONObject jsonObject = (JSONObject) o; - ActiveCosmetic cosmeticData = new ActiveCosmetic(); - cosmeticData.setActivityUID(UUID.fromString(jsonObject.getString("activityUID"))); - cosmeticData.setPlayerUID(UUID.fromString(jsonObject.getString("playerUID"))); - cosmeticData.setCosmeticData(UUID.fromString(jsonObject.getString("cosmeticUID"))); - cosmeticData.setUsername(jsonObject.getString("username")); - - activeCosmeticMap.put(cosmeticData.getActivityUID(), cosmeticData); - try { - if (Minecraft.getMinecraft().theWorld != null) { - EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByUUID(cosmeticData.getPlayerUID()); - if (entityPlayer != null) entityPlayer.refreshDisplayName(); - } - } catch (Exception e) {e.printStackTrace();} - } - this.activeCosmeticMap = activeCosmeticMap; - rebuildCaches(); - } else if (destination.equals("/user/queue/reply/cosmetic.list")) { - JSONArray object = new JSONArray(stompPayload.payload()); - Map newCosmeticList = new HashMap<>(); - for (Object o : object) { - JSONObject jsonObject = (JSONObject) o; - CosmeticData cosmeticData = new CosmeticData(); - cosmeticData.setCosmeticType(jsonObject.getString("cosmeticType")); - cosmeticData.setReqPerm(jsonObject.getString("reqPerm")); - cosmeticData.setData(jsonObject.getString("data")); - cosmeticData.setId(UUID.fromString(jsonObject.getString("id"))); - - newCosmeticList.put(cosmeticData.getId(), cosmeticData); - } - - cosmeticDataMap = newCosmeticList; - rebuildCaches(); - } - } - - private void rebuildCaches() { - Map> activeCosmeticByType = new HashMap<>(); - Map> activeCosmeticByPlayer = new HashMap<>(); - Map> activeCosmeticByPlayerName = new HashMap<>(); - for (ActiveCosmetic value : activeCosmeticMap.values()) { - CosmeticData cosmeticData = cosmeticDataMap.get(value.getCosmeticData()); - if (cosmeticData != null) { - List cosmeticsByTypeList = activeCosmeticByType.computeIfAbsent(cosmeticData.getCosmeticType(), a-> new CopyOnWriteArrayList<>()); - cosmeticsByTypeList.add(value); - } - List activeCosmetics = activeCosmeticByPlayer.computeIfAbsent(value.getPlayerUID(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.add(value); - activeCosmetics = activeCosmeticByPlayerName.computeIfAbsent(value.getUsername().toLowerCase(), a-> new CopyOnWriteArrayList<>()); - activeCosmetics.add(value); - } - - this.activeCosmeticByPlayerNameLowerCase = activeCosmeticByPlayerName; - this.activeCosmeticByPlayer = activeCosmeticByPlayer; - this.activeCosmeticByType = activeCosmeticByType; - } - - @SubscribeEvent - public void stompConnect(StompConnectedEvent stompConnectedEvent) { - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/topic/cosmetic.set").build()); - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/reply/user.perms").build()); - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/reply/cosmetic.activelist").build()); - stompConnectedEvent.getStompInterface().subscribe(StompSubscription.builder() - .stompMessageHandler(this).ackMode(StompSubscription.AckMode.AUTO).destination("/user/queue/reply/cosmetic.list").build()); - - requestCosmeticsList(); - requestActiveCosmetics(); - requestPerms(); - } - @Getter @Setter - private static List iChatReplacers = new ArrayList<>(); - static { - iChatReplacers.add(new ChatReplacerViewProfile()); - iChatReplacers.add(new ChatReplacerPV()); - iChatReplacers.add(new ChatReplacerSocialOptions()); - iChatReplacers.add(new ChatReplacerCoop()); - iChatReplacers.add(new ChatReplacerMessage()); - iChatReplacers.add(new ChatReplacerChatByMe()); - } - - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onChat(ClientChatReceivedEvent clientChatReceivedEvent) { - try { - if (clientChatReceivedEvent.type == 2) return; - for (IChatReplacer iChatReplacer : iChatReplacers) { - if (iChatReplacer.isAcceptable(clientChatReceivedEvent)) { - iChatReplacer.translate(clientChatReceivedEvent, this); - return; - } - } - } catch (Throwable t) { - System.out.println(clientChatReceivedEvent.message); - t.printStackTrace(); - } - } - - - @SubscribeEvent - public void onTabList(PlayerListItemPacketEvent packetPlayerListItem) { - S38PacketPlayerListItem asd = packetPlayerListItem.getPacketPlayerListItem(); - if (asd.getAction() == S38PacketPlayerListItem.Action.ADD_PLAYER) { - if (Minecraft.getMinecraft().getNetHandler() == null) return; - - Map playerInfoMap = ReflectionHelper.getPrivateValue(NetHandlerPlayClient.class, Minecraft.getMinecraft().getNetHandler(), "playerInfoMap", "field_147310_i","i"); - for (S38PacketPlayerListItem.AddPlayerData entry : asd.getEntries()) { - playerInfoMap.remove(entry.getProfile().getId()); - playerInfoMap.put(entry.getProfile().getId(), new CustomNetworkPlayerInfo(entry)); - } - } - } - - @SubscribeEvent(priority = EventPriority.LOWEST) - public void nameFormat(PlayerEvent.NameFormat nameFormat) { - List activeCosmetics = activeCosmeticByPlayer.get(nameFormat.entityPlayer.getGameProfile().getId()); - if (activeCosmetics == null) return; - CosmeticData color=null, prefix=null; - for (ActiveCosmetic activeCosmetic : activeCosmetics) { - CosmeticData cosmeticData = cosmeticDataMap.get(activeCosmetic.getCosmeticData()); - if (cosmeticData !=null && cosmeticData.getCosmeticType().equals("color")) { - color = cosmeticData; - } else if (cosmeticData != null && cosmeticData.getCosmeticType().equals("prefix")) { - prefix = cosmeticData; - } - } - - - if (color != null) - nameFormat.displayname = color.getData().replace("&","§")+nameFormat.username; - - if (prefix != null) - nameFormat.displayname = prefix.getData().replace("&","§")+" "+nameFormat.displayname; - - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java deleted file mode 100644 index cfbf1fc0..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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 . - */ - -package kr.syeyoung.dungeonsguide.cosmetics; - -import com.mojang.authlib.GameProfile; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.utils.TextUtils; -import net.minecraft.client.network.NetworkPlayerInfo; -import net.minecraft.network.play.server.S38PacketPlayerListItem; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; - -import java.util.List; - -public class CustomNetworkPlayerInfo extends NetworkPlayerInfo { - public CustomNetworkPlayerInfo(GameProfile p_i46294_1_) { - super(p_i46294_1_); - } - - public CustomNetworkPlayerInfo(S38PacketPlayerListItem.AddPlayerData p_i46295_1_) { - super(p_i46295_1_); - setDisplayName(super.getDisplayName()); - } - - - private IChatComponent displayName; - private String playernameLowercase; - private String unformatted; - private String actualName; - @Override - public void setDisplayName(IChatComponent displayNameIn) { - displayName = displayNameIn; - if (displayName == null) { - playernameLowercase = null; - unformatted = null; - return; - } - - unformatted = displayName.getUnformattedText(); - - - actualName = ""; - for (String s : unformatted.split(" ")) { - String strippped = TextUtils.stripColor(s); - if (strippped.startsWith("[")) continue; - actualName = strippped; - break; - } - playernameLowercase = actualName.toLowerCase(); - } - - public IChatComponent getDisplayName() - { - - String semi_name; - String actualName; - List activeCosmetics; - if (playernameLowercase != null) { - activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(playernameLowercase); - semi_name = unformatted; - actualName = this.actualName; - } else { - semi_name = ScorePlayerTeam.formatPlayerName(super.getPlayerTeam(), super.getGameProfile().getName()); - actualName = ""; - for (String s : semi_name.split(" ")) { - String strippped = TextUtils.stripColor(s); - if (strippped.startsWith("[")) continue; - actualName = strippped; - break; - } - activeCosmetics = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getActiveCosmeticByPlayerNameLowerCase().get(actualName.toLowerCase()); - } - - - if (activeCosmetics == null) return displayName; - CosmeticData color=null; - for (ActiveCosmetic activeCosmetic : activeCosmetics) { - CosmeticData cosmeticData = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getCosmeticDataMap().get(activeCosmetic.getCosmeticData()); - if (cosmeticData.getCosmeticType().equals("color")) color = cosmeticData; - } - - if (color != null) semi_name = semi_name.replace(actualName, color.getData()+actualName); - - return new ChatComponentText(semi_name); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java deleted file mode 100644 index 2f957c42..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 . - */ - -package kr.syeyoung.dungeonsguide.cosmetics; - -import kr.syeyoung.dungeonsguide.events.PlayerListItemPacketEvent; -import net.minecraft.network.Packet; -import net.minecraft.network.play.INetHandlerPlayClient; -import net.minecraft.network.play.server.S38PacketPlayerListItem; -import net.minecraftforge.common.MinecraftForge; - -public class CustomPacketPlayerListItem extends S38PacketPlayerListItem { - public CustomPacketPlayerListItem(S38PacketPlayerListItem packet) { - super(packet.getAction()); - getEntries().addAll(packet.getEntries()); - } - - @Override - public void processPacket(INetHandlerPlayClient handler) { - super.processPacket(handler); - - MinecraftForge.EVENT_BUS.post(new PlayerListItemPacketEvent(this)); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java deleted file mode 100644 index b2bcfc0e..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 . - */ - -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 deleted file mode 100644 index 8c99847a..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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 . - */ - -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> replaceMents = new ArrayList<>(); - List iChatComponents = new ArrayList<>( event.message.getSiblings() ); - List 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 cDatas = cosmeticsManager.getActiveCosmeticByPlayerNameLowerCase().get(TextUtils.stripColor(actualName).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 = ""; - if (prefix != null) building += prefix.getData().replace("&", "§") + " "; - for (int i = 0; i < splited.length-1; i++) { - building += splited[i] +" "; - } - - if (color != null) { - String nick = splited[splited.length-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[splited.length-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 deleted file mode 100644 index 91bb58b6..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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 . - */ - -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> replaceMents = new ArrayList<>(); - List 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 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. - */ - -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> replaceMents = new ArrayList<>(); - List iChatComponents = new ArrayList<>( event.message.getSiblings() ); - List 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 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/ChatReplacerPV.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerPV.java deleted file mode 100644 index e5e4053f..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerPV.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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 . - */ - -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.minecraftforge.client.event.ClientChatReceivedEvent; - -import java.util.List; - - -// Bug 289 - mod conflict with NEU (Replaces /socialoptions with /pv) -public class ChatReplacerPV implements IChatReplacer { - @Override - public boolean isAcceptable(ClientChatReceivedEvent event) { - if (event.message.getChatStyle() != null && event.message.getChatStyle().getChatClickEvent() != null && event.message.getChatStyle().getChatClickEvent().getValue().startsWith("/pv")) 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("/pv")) { - String username = event.message.getChatStyle().getChatClickEvent().getValue().split(" ")[1]; - List 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 (i >= 1) { - String str = TextUtils.stripColor(splitInto[i-1]); - if (str.startsWith("[") && str.endsWith("]"))break; - } - } - } - 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. - */ - -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 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 (i >= 1) { - String str = TextUtils.stripColor(splitInto[i-1]); - if (str.startsWith("[") && str.endsWith("]"))break; - } - } - } - 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. - */ - -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) { - 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> 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 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 (i >= 1) { - String str = TextUtils.stripColor(splitInto[i-1]); - if (str.startsWith("[") && str.endsWith("]"))break; - } - } - } - 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(sibling, newChatCompText)); - break; - } - } - } - - for (Tuple replaceMent : replaceMents) { - int index = event.message.getSiblings().indexOf(replaceMent.getFirst()); - event.message.getSiblings().set(index, replaceMent.getSecond()); - } - } -} -- cgit