aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics
diff options
context:
space:
mode:
Diffstat (limited to 'mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics')
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java293
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java103
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java38
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java26
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java106
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java119
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerMessage.java106
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerPV.java119
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerSocialOptions.java117
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerViewProfile.java128
10 files changed, 0 insertions, 1155 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java
deleted file mode 100644
index 790a3bee..00000000
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java
+++ /dev/null
@@ -1,293 +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 <https://www.gnu.org/licenses/>.
- */
-
-package kr.syeyoung.dungeonsguide.cosmetics;
-
-import kr.syeyoung.dungeonsguide.cosmetics.chatreplacers.*;
-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 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.minecraftforge.client.event.ClientChatReceivedEvent;
-import net.minecraftforge.event.entity.player.PlayerEvent;
-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;
-
-public class CosmeticsManager implements StompMessageHandler {
- @Getter
- private Map<UUID, CosmeticData> cosmeticDataMap = new ConcurrentHashMap<>();
- @Getter
- private Map<UUID, ActiveCosmetic> activeCosmeticMap = new ConcurrentHashMap<>();
- @Getter
- private Map<String, List<ActiveCosmetic>> activeCosmeticByType = new ConcurrentHashMap<>();
- @Getter
- private Map<UUID, List<ActiveCosmetic>> activeCosmeticByPlayer = new ConcurrentHashMap<>();
- @Getter
- private Map<String, List<ActiveCosmetic>> activeCosmeticByPlayerNameLowerCase = new ConcurrentHashMap<>();
- @Getter
- private Set<String> 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<ActiveCosmetic> 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<ActiveCosmetic> 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<ActiveCosmetic> cosmeticsByTypeList = activeCosmeticByType.computeIfAbsent(cosmeticData.getCosmeticType(), a-> new CopyOnWriteArrayList<>());
- cosmeticsByTypeList.add(activeCosmetic);
- cosmeticsByTypeList.remove(previousThing);
- }
- List<ActiveCosmetic> 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<String> cache = new HashSet<>();
- for (Object o : object) {
- cache.add((String) o);
- }
- this.perms = cache;
- } else if (destination.equals("/user/queue/reply/cosmetic.activelist")) {
- Map<UUID, ActiveCosmetic> 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<UUID, CosmeticData> 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<String, List<ActiveCosmetic>> activeCosmeticByType = new HashMap<>();
- Map<UUID, List<ActiveCosmetic>> activeCosmeticByPlayer = new HashMap<>();
- Map<String, List<ActiveCosmetic>> activeCosmeticByPlayerName = new HashMap<>();
- for (ActiveCosmetic value : activeCosmeticMap.values()) {
- CosmeticData cosmeticData = cosmeticDataMap.get(value.getCosmeticData());
- if (cosmeticData != null) {
- List<ActiveCosmetic> cosmeticsByTypeList = activeCosmeticByType.computeIfAbsent(cosmeticData.getCosmeticType(), a-> new CopyOnWriteArrayList<>());
- cosmeticsByTypeList.add(value);
- }
- List<ActiveCosmetic> 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<IChatReplacer> 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<UUID, NetworkPlayerInfo> 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<ActiveCosmetic> 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/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomNetworkPlayerInfo.java
deleted file mode 100644
index cfbf1fc0..00000000
--- a/mod/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 <https://www.gnu.org/licenses/>.
- */
-
-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<ActiveCosmetic> 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/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java
deleted file mode 100644
index 1aa71d58..00000000
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CustomPacketPlayerListItem.java
+++ /dev/null
@@ -1,38 +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 <https://www.gnu.org/licenses/>.
- */
-
-package kr.syeyoung.dungeonsguide.cosmetics;
-
-import kr.syeyoung.dungeonsguide.events.PlayerListItemPacketEvent;
-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/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/IChatReplacer.java
deleted file mode 100644
index b2bcfc0e..00000000
--- a/mod/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 <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/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerChatByMe.java
deleted file mode 100644
index 8c99847a..00000000
--- a/mod/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 <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) 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/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.java
deleted file mode 100644
index a1491dd5..00000000
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerCoop.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 <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;
-
-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/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerMessage.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerMessage.java
deleted file mode 100644
index b7c772f1..00000000
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerMessage.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 <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 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/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerPV.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerPV.java
deleted file mode 100644
index e5e4053f..00000000
--- a/mod/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 <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.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<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 (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<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/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerSocialOptions.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerSocialOptions.java
deleted file mode 100644
index adf70075..00000000
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerSocialOptions.java
+++ /dev/null
@@ -1,117 +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 <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.minecraftforge.client.event.ClientChatReceivedEvent;
-
-import java.util.List;
-
-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 (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<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/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerViewProfile.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerViewProfile.java
deleted file mode 100644
index dd5bbd70..00000000
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/chatreplacers/ChatReplacerViewProfile.java
+++ /dev/null
@@ -1,128 +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 <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) {
- 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 (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<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));
- break;
- }
- }
- }
-
- for (Tuple<IChatComponent, IChatComponent> replaceMent : replaceMents) {
- int index = event.message.getSiblings().indexOf(replaceMent.getFirst());
- event.message.getSiblings().set(index, replaceMent.getSecond());
- }
- }
-}