From c3783b9bf070abf2b112057d92437e9e29cc070e Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 15 May 2021 14:10:01 +1200 Subject: [PATCH] Fix a component builder error in 1.12 --- .../disguise/commands/libsdisguises/LDJson.java | 7 ++++--- .../disguise/commands/libsdisguises/LDMetaInfo.java | 10 +++++----- .../disguise/commands/utils/CopyDisguiseCommand.java | 7 ++++--- .../disguise/commands/utils/GrabSkinCommand.java | 7 ++++--- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java index 310fc644..fa768423 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java @@ -9,6 +9,7 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; import org.apache.commons.lang.StringUtils; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -95,7 +96,7 @@ public class LDJson implements LDCommand { int start = 0; int msg = 1; - ComponentBuilder builder = new ComponentBuilder("").appendLegacy(prefix.get()); + ComponentBuilder builder = new ComponentBuilder("").append(TextComponent.fromLegacyText(prefix.get())); while (start < string.length()) { int end = Math.min(256, string.length() - start); @@ -105,10 +106,10 @@ public class LDJson implements LDCommand { builder.append(" "); if (string.length() <= 256) { - builder.appendLegacy(LibsMsg.CLICK_TO_COPY_DATA.get()); + builder.append(TextComponent.fromLegacyText(LibsMsg.CLICK_TO_COPY_DATA.get())); } else { builder.reset(); - builder.appendLegacy(LibsMsg.CLICK_COPY.get(msg)); + builder.append(TextComponent.fromLegacyText(LibsMsg.CLICK_COPY.get(msg))); } start += end; diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java index 9265f0bb..8dc175be 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java @@ -5,6 +5,7 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.command.CommandSender; import java.util.ArrayList; @@ -47,20 +48,19 @@ public class LDMetaInfo implements LDCommand { names.sort(String::compareToIgnoreCase); // if (NmsVersion.v1_13.isSupported()) { - ComponentBuilder builder = new ComponentBuilder("").appendLegacy(LibsMsg.META_VALUES.get()); + ComponentBuilder builder = new ComponentBuilder("").append(TextComponent.fromLegacyText(LibsMsg.META_VALUES.get())); Iterator itel = names.iterator(); while (itel.hasNext()) { String name = itel.next(); - builder.appendLegacy(name); + builder.append(TextComponent.fromLegacyText(name)); builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/libsdisguises metainfo " + name)); - builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - new ComponentBuilder("").appendLegacy(LibsMsg.META_CLICK_SHOW.get(name)).create())); + builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(LibsMsg.META_CLICK_SHOW.get(name)))); if (itel.hasNext()) { - builder.appendLegacy(LibsMsg.META_VALUE_SEPERATOR.get()); + builder.append(TextComponent.fromLegacyText(LibsMsg.META_VALUE_SEPERATOR.get())); } } diff --git a/src/main/java/me/libraryaddict/disguise/commands/utils/CopyDisguiseCommand.java b/src/main/java/me/libraryaddict/disguise/commands/utils/CopyDisguiseCommand.java index 18088716..4bd80f43 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/utils/CopyDisguiseCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/utils/CopyDisguiseCommand.java @@ -13,6 +13,7 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -93,7 +94,7 @@ public class CopyDisguiseCommand implements CommandExecutor { return; }*/ - ComponentBuilder builder = new ComponentBuilder("").appendLegacy(msg.get()).append(" "); + ComponentBuilder builder = new ComponentBuilder("").append(TextComponent.fromLegacyText(msg.get())).append(" "); if (string.length() > 256 || forceAbbrev) { String[] split = DisguiseUtilities.split(string); @@ -135,7 +136,7 @@ public class CopyDisguiseCommand implements CommandExecutor { sections++; - builder.appendLegacy(LibsMsg.CLICK_COPY.get(sections)); + builder.append(TextComponent.fromLegacyText(LibsMsg.CLICK_COPY.get(sections))); builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, current.toString())); builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(LibsMsg.CLICK_TO_COPY_HOVER.get() + " " + sections).create())); @@ -143,7 +144,7 @@ public class CopyDisguiseCommand implements CommandExecutor { current = new StringBuilder(); } } else { - builder.appendLegacy(LibsMsg.CLICK_COPY.get(string)); + builder.append(TextComponent.fromLegacyText(LibsMsg.CLICK_COPY.get(string))); builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, string)); builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(LibsMsg.CLICK_TO_COPY_HOVER.get()).create())); diff --git a/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java b/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java index 53a53c92..547b75c7 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java @@ -11,6 +11,7 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -114,7 +115,7 @@ public class GrabSkinCommand implements CommandExecutor { int msg = 1; //if (NmsVersion.v1_13.isSupported()) { - ComponentBuilder builder = new ComponentBuilder("").appendLegacy(LibsMsg.CLICK_TO_COPY.get()); + ComponentBuilder builder = new ComponentBuilder("").append(TextComponent.fromLegacyText(LibsMsg.CLICK_TO_COPY.get())); while (start < string.length()) { int end = Math.min(256, string.length() - start); @@ -124,10 +125,10 @@ public class GrabSkinCommand implements CommandExecutor { builder.append(" "); if (string.length() <= 256) { - builder.appendLegacy(LibsMsg.CLICK_TO_COPY_DATA.get()); + builder.append(TextComponent.fromLegacyText(LibsMsg.CLICK_TO_COPY_DATA.get())); } else { builder.reset(); - builder.appendLegacy(LibsMsg.CLICK_COPY.get(msg)); + builder.append(TextComponent.fromLegacyText(LibsMsg.CLICK_COPY.get(msg))); } start += end;