From 1211402c58e86652d2d67871283cbe050afff661 Mon Sep 17 00:00:00 2001 From: Aust1n46 Date: Mon, 5 Feb 2024 11:14:52 -0600 Subject: [PATCH] Support viewing removed message content --- .../Aust1n46/chat/utilities/Format.java | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java b/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java index 7d19096..71caa68 100644 --- a/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java +++ b/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java @@ -524,9 +524,9 @@ public class Format { if (VersionHandler.is1_7()) { return "\"extra\":[{\"text\":\"Hover to see original message is not currently supported in 1.7\",\"color\":\"red\"}]"; } - if (VersionHandler.isAbove_1_19()) { - return "\"extra\":[{\"text\":\"Hover to see original message is not currently supported in 1.19+\",\"color\":\"red\"}]"; - } +// if (VersionHandler.isAbove_1_19()) { +// return "\"extra\":[{\"text\":\"Hover to see original message is not currently supported in 1.19+\",\"color\":\"red\"}]"; +// } List finalList = new ArrayList<>(); StringBuilder stringbuilder = new StringBuilder(); stringbuilder.append("\"extra\":["); @@ -556,7 +556,7 @@ public class Format { jsonObject.put("underlined", underlined); jsonObject.put("obfuscated", obfuscated); stringbuilder.append(jsonObject.toJSONString() + ","); - } else { + } else if (VersionHandler.is1_18() || VersionHandler.is1_19()) { String text = (String) component.getClass().getMethod("getString").invoke(component); Object chatModifier = component.getClass().getMethod("c").invoke(component); Object color = chatModifier.getClass().getMethod("a").invoke(chatModifier); @@ -578,9 +578,33 @@ public class Format { jsonObject.put("underlined", underlined); jsonObject.put("obfuscated", obfuscated); stringbuilder.append(jsonObject.toJSONString() + ","); + } + else { + String text = (String) component.getClass().getMethod("getString").invoke(component); + Object chatModifier = component.getClass().getMethod("a").invoke(component); + Object color = chatModifier.getClass().getMethod("a").invoke(chatModifier); + String colorString = "white"; + if (color != null ) { + colorString = color.getClass().getMethod("b").invoke(color).toString(); + } + boolean bold = (boolean) chatModifier.getClass().getMethod("b").invoke(chatModifier); + boolean italic = (boolean) chatModifier.getClass().getMethod("c").invoke(chatModifier); + boolean strikethrough = (boolean) chatModifier.getClass().getMethod("d").invoke(chatModifier); + boolean underlined = (boolean) chatModifier.getClass().getMethod("e").invoke(chatModifier); + boolean obfuscated = (boolean) chatModifier.getClass().getMethod("f").invoke(chatModifier); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("text", text); + jsonObject.put("color", colorString); + jsonObject.put("bold", bold); + jsonObject.put("strikethrough", strikethrough); + jsonObject.put("italic", italic); + jsonObject.put("underlined", underlined); + jsonObject.put("obfuscated", obfuscated); + stringbuilder.append(jsonObject.toJSONString() + ","); } } catch(Exception e) { + e.printStackTrace(); return "\"extra\":[{\"text\":\"Something went wrong. Could not access color.\",\"color\":\"red\"}]"; } } @@ -639,7 +663,7 @@ public class Format { finalList.add(component); } } - } else if (VersionHandler.is1_18() || VersionHandler.is1_19()){ + } else if (VersionHandler.is1_18() || VersionHandler.is1_19()) { ArrayList list = (ArrayList) c.getMethod("b").invoke(o, new Object[0]); for (Object component : list) { ArrayList innerList = (ArrayList) c.getMethod("b").invoke(component, new Object[0]);