diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/compat/MessageHandler.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/compat/MessageHandler.java index 1b6217239..80603dfa3 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/compat/MessageHandler.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/compat/MessageHandler.java @@ -25,9 +25,8 @@ package me.lucko.luckperms.bukkit.compat; -import me.lucko.luckperms.common.constants.Constants; - import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; import net.kyori.text.serializer.ComponentSerializer; import org.bukkit.command.CommandSender; @@ -62,7 +61,8 @@ public class MessageHandler { } // Fallback to Bukkit - sender.sendMessage(ComponentSerializer.toLegacy(message, Constants.COLOR_CHAR)); + //noinspection deprecation + sender.sendMessage(LegacyComponent.to(message)); } private static boolean isSpigot() { diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java index f3864dca3..67905990b 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java @@ -32,6 +32,7 @@ import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; import net.kyori.text.serializer.ComponentSerializer; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.TextComponent; @@ -70,7 +71,8 @@ public class BungeeSenderFactory extends SenderFactory { try { sender.sendMessage(net.md_5.bungee.chat.ComponentSerializer.parse(ComponentSerializer.serialize(message))); } catch (Exception e) { - sendMessage(sender, ComponentSerializer.toLegacy(message, Constants.COLOR_CHAR)); + //noinspection deprecation + sendMessage(sender, LegacyComponent.to(message)); } } diff --git a/common/pom.xml b/common/pom.xml index b45e4918c..4b8f24e85 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -39,7 +39,7 @@ net.kyori text - 1.12-SNAPSHOT + 1.11-SNAPSHOT compile diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java b/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java index e185058bd..b8372f379 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java @@ -63,10 +63,10 @@ import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.TextUtils; -import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; +import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; import java.util.ArrayList; import java.util.Collections; @@ -255,18 +255,18 @@ public class CommandManager { @SuppressWarnings("unchecked") String permission = (String) c.getPermission().map(p -> ((CommandPermission) p).getPermission()).orElse("None"); - Component component = ComponentSerializer.parseFromLegacy("&3> &a" + String.format(c.getUsage(), label), Constants.FORMAT_CHAR) - .applyRecursively(comp -> { - comp.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy(TextUtils.joinNewline( + TextComponent component = LegacyComponent.from("&3> &a" + String.format(c.getUsage(), label), Constants.FORMAT_CHAR) + .toBuilder().applyDeep(comp -> { + comp.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline( "&bCommand: &2" + c.getName(), "&bDescription: &2" + c.getDescription(), "&bUsage: &2" + String.format(c.getUsage(), label), "&bPermission: &2" + permission, " ", "&7Click to auto-complete." - ), Constants.FORMAT_CHAR))); + ), Constants.FORMAT_CHAR))); comp.clickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.format(c.getUsage(), label))); - }); + }).build(); sender.sendMessage(component); }); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddChatMeta.java index 691bdcbfa..28d607e4e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddChatMeta.java @@ -46,9 +46,9 @@ import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; -import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; +import net.kyori.text.TextComponent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; import java.util.List; import java.util.stream.Collectors; @@ -85,13 +85,13 @@ public class MetaAddChatMeta extends SharedSubCommand { DataMutateResult result = holder.setPermission(NodeFactory.makeChatMetaNode(type, priority, meta).withExtraContext(context).build()); if (result.asBoolean()) { - Component component = ComponentSerializer.parseFromLegacy(Message.ADD_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context)), Constants.COLOR_CHAR); - HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy( + TextComponent.Builder builder = LegacyComponent.from(Message.ADD_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder(); + HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from( "¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta, '¥' )); - component.applyRecursively(c -> c.hoverEvent(event)); - sender.sendMessage(component); + builder.applyDeep(c -> c.hoverEvent(event)); + sender.sendMessage(builder.build()); LogEntry.build().actor(sender).acted(holder) .action("meta add" + type.name().toLowerCase() + " " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" "))) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddTempChatMeta.java index 1e60aae57..16b5a207c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddTempChatMeta.java @@ -50,9 +50,9 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; -import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; +import net.kyori.text.TextComponent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; import java.util.List; import java.util.Map; @@ -95,13 +95,13 @@ public class MetaAddTempChatMeta extends SharedSubCommand { if (ret.getKey().asBoolean()) { duration = ret.getValue().getExpiryUnixTime(); - Component component = ComponentSerializer.parseFromLegacy(Message.ADD_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, DateUtil.formatDateDiff(duration), Util.contextSetToString(context)), Constants.COLOR_CHAR); - HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy( + TextComponent.Builder builder = LegacyComponent.from(Message.ADD_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, DateUtil.formatDateDiff(duration), Util.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder(); + HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from( "¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta, '¥' )); - component.applyRecursively(c -> c.hoverEvent(event)); - sender.sendMessage(component); + builder.applyDeep(c -> c.hoverEvent(event)); + sender.sendMessage(builder.build()); LogEntry.build().actor(sender).acted(holder) .action("meta addtemp" + type.name().toLowerCase() + " " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" "))) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java index 38c9d70ec..8946fdbdb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java @@ -49,10 +49,11 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; -import net.kyori.text.Component; +import net.kyori.text.BuildableComponent; +import net.kyori.text.LegacyComponent; +import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; import java.util.HashSet; import java.util.List; @@ -126,13 +127,13 @@ public class MetaInfo extends SharedSubCommand { String location = processLocation(m, holder); if (m.hasSpecificContext()) { String context = Util.getAppendableNodeContextString(m); - Component component = ComponentSerializer.parseFromLegacy(Message.META_ENTRY_WITH_CONTEXT.asString(sender.getPlatform().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location, context), Constants.COLOR_CHAR); - component.applyRecursively(makeFancy(holder, label, m)); - sender.sendMessage(component); + TextComponent.Builder builder = LegacyComponent.from(Message.META_ENTRY_WITH_CONTEXT.asString(sender.getPlatform().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location, context), Constants.COLOR_CHAR).toBuilder(); + builder.applyDeep(makeFancy(holder, label, m)); + sender.sendMessage(builder.build()); } else { - Component component = ComponentSerializer.parseFromLegacy(Message.META_ENTRY.asString(sender.getPlatform().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location), Constants.COLOR_CHAR); - component.applyRecursively(makeFancy(holder, label, m)); - sender.sendMessage(component); + TextComponent.Builder builder = LegacyComponent.from(Message.META_ENTRY.asString(sender.getPlatform().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location), Constants.COLOR_CHAR).toBuilder(); + builder.applyDeep(makeFancy(holder, label, m)); + sender.sendMessage(builder.build()); } } } @@ -142,18 +143,18 @@ public class MetaInfo extends SharedSubCommand { String location = processLocation(e.getValue(), holder); if (e.getValue().hasSpecificContext()) { String context = Util.getAppendableNodeContextString(e.getValue()); - Component component = ComponentSerializer.parseFromLegacy(Message.CHAT_META_ENTRY_WITH_CONTEXT.asString(sender.getPlatform().getLocaleManager(), e.getKey(), type.getEntry(e.getValue()).getValue(), location, context), Constants.COLOR_CHAR); - component.applyRecursively(makeFancy(type, holder, label, e.getValue())); - sender.sendMessage(component); + TextComponent.Builder builder = LegacyComponent.from(Message.CHAT_META_ENTRY_WITH_CONTEXT.asString(sender.getPlatform().getLocaleManager(), e.getKey(), type.getEntry(e.getValue()).getValue(), location, context), Constants.COLOR_CHAR).toBuilder(); + builder.applyDeep(makeFancy(type, holder, label, e.getValue())); + sender.sendMessage(builder.build()); } else { - Component component = ComponentSerializer.parseFromLegacy(Message.CHAT_META_ENTRY.asString(sender.getPlatform().getLocaleManager(), e.getKey(), type.getEntry(e.getValue()).getValue(), location), Constants.COLOR_CHAR); - component.applyRecursively(makeFancy(type, holder, label, e.getValue())); - sender.sendMessage(component); + TextComponent.Builder builder = LegacyComponent.from(Message.CHAT_META_ENTRY.asString(sender.getPlatform().getLocaleManager(), e.getKey(), type.getEntry(e.getValue()).getValue(), location), Constants.COLOR_CHAR).toBuilder(); + builder.applyDeep(makeFancy(type, holder, label, e.getValue())); + sender.sendMessage(builder.build()); } } } - private static Consumer makeFancy(ChatMetaType type, PermissionHolder holder, String label, LocalizedNode node) { + private static Consumer> makeFancy(ChatMetaType type, PermissionHolder holder, String label, LocalizedNode node) { if (!node.getLocation().equals(holder.getObjectName())) { // inherited. Group group = holder.getPlugin().getGroupManager().getIfLoaded(node.getLocation()); @@ -162,7 +163,7 @@ public class MetaInfo extends SharedSubCommand { } } - HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy(TextUtils.joinNewline( + HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline( "¥3> ¥a" + type.getEntry(node).getKey() + " ¥7- ¥r" + type.getEntry(node).getValue(), " ", "¥7Click to remove this " + type.name().toLowerCase() + " from " + holder.getFriendlyName() @@ -178,7 +179,7 @@ public class MetaInfo extends SharedSubCommand { }; } - private static Consumer makeFancy(PermissionHolder holder, String label, LocalizedNode node) { + private static Consumer> makeFancy(PermissionHolder holder, String label, LocalizedNode node) { if (!node.getLocation().equals(holder.getObjectName())) { // inherited. Group group = holder.getPlugin().getGroupManager().getIfLoaded(node.getLocation()); @@ -187,7 +188,7 @@ public class MetaInfo extends SharedSubCommand { } } - HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy(TextUtils.joinNewline( + HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline( "¥3> ¥r" + node.getMeta().getKey() + " ¥7- ¥r" + node.getMeta().getValue(), " ", "¥7Click to remove this meta pair from " + holder.getFriendlyName() diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveChatMeta.java index 5bc7bdf50..a7ae81b34 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveChatMeta.java @@ -46,9 +46,9 @@ import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; -import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; +import net.kyori.text.TextComponent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; import java.util.List; import java.util.stream.Collectors; @@ -99,13 +99,13 @@ public class MetaRemoveChatMeta extends SharedSubCommand { DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(type, priority, meta).withExtraContext(context).build()); if (result.asBoolean()) { - Component component = ComponentSerializer.parseFromLegacy(Message.REMOVE_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context)), Constants.COLOR_CHAR); - HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy( + TextComponent.Builder builder = LegacyComponent.from(Message.REMOVE_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder(); + HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from( "¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta, '¥' )); - component.applyRecursively(c -> c.hoverEvent(event)); - sender.sendMessage(component); + builder.applyDeep(c -> c.hoverEvent(event)); + sender.sendMessage(builder.build()); LogEntry.build().actor(sender).acted(holder) .action("meta remove" + type.name().toLowerCase() + " " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" "))) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveTempChatMeta.java index 38dbad59f..deb81bd73 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveTempChatMeta.java @@ -46,9 +46,9 @@ import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; -import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; +import net.kyori.text.TextComponent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; import java.util.List; import java.util.stream.Collectors; @@ -99,13 +99,13 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand { DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(type, priority, meta).setExpiry(10L).withExtraContext(context).build()); if (result.asBoolean()) { - Component component = ComponentSerializer.parseFromLegacy(Message.REMOVE_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context)), Constants.COLOR_CHAR); - HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy( + TextComponent.Builder builder = LegacyComponent.from(Message.REMOVE_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), type.name().toLowerCase(), meta, priority, Util.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder(); + HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from( "¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta, '¥' )); - component.applyRecursively(c -> c.hoverEvent(event)); - sender.sendMessage(component); + builder.applyDeep(c -> c.hoverEvent(event)); + sender.sendMessage(builder.build()); LogEntry.build().actor(sender).acted(holder) .action("meta removetemp" + type.name().toLowerCase() + " " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" "))) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSet.java index 9b4aadaf9..79103b425 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSet.java @@ -35,7 +35,6 @@ import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; import me.lucko.luckperms.common.constants.CommandPermission; -import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.locale.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; @@ -46,9 +45,9 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; -import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; +import net.kyori.text.TextComponent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; import java.util.List; import java.util.stream.Collectors; @@ -89,13 +88,13 @@ public class MetaSet extends SharedSubCommand { holder.clearMetaKeys(key, context, false); holder.setPermission(n); - Component component = ComponentSerializer.parseFromLegacy(Message.SET_META_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), Util.contextSetToString(context)), Constants.COLOR_CHAR); - HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy( + TextComponent.Builder builder = LegacyComponent.from(Message.SET_META_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), Util.contextSetToString(context))).toBuilder(); + HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from( TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value), '¥' )); - component.applyRecursively(c -> c.hoverEvent(event)); - sender.sendMessage(component); + builder.applyDeep(c -> c.hoverEvent(event)); + sender.sendMessage(builder.build()); LogEntry.build().actor(sender).acted(holder) .action("meta set " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" "))) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSetTemp.java index 90ba797db..14116287f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSetTemp.java @@ -49,9 +49,9 @@ import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; -import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; +import net.kyori.text.TextComponent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; import java.util.List; import java.util.stream.Collectors; @@ -94,13 +94,13 @@ public class MetaSetTemp extends SharedSubCommand { holder.clearMetaKeys(key, context, true); duration = holder.setPermission(n, modifier).getValue().getExpiryUnixTime(); - Component component = ComponentSerializer.parseFromLegacy(Message.SET_META_TEMP_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), Util.contextSetToString(context)), Constants.COLOR_CHAR); - HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy( + TextComponent.Builder builder = LegacyComponent.from(Message.SET_META_TEMP_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), Util.contextSetToString(context)), Constants.COLOR_CHAR).toBuilder(); + HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from( TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value), '¥' )); - component.applyRecursively(c -> c.hoverEvent(event)); - sender.sendMessage(component); + builder.applyDeep(c -> c.hoverEvent(event)); + sender.sendMessage(builder.build()); LogEntry.build().actor(sender).acted(holder) .action("meta settemp " + args.stream().map(ArgumentUtils.WRAPPER).collect(Collectors.joining(" "))) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderEditor.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderEditor.java index 384ba1a5f..016a2226f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderEditor.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderEditor.java @@ -53,6 +53,7 @@ import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; +import net.kyori.text.format.TextColor; import java.io.InputStream; import java.io.InputStreamReader; @@ -99,9 +100,10 @@ public class HolderEditor extends SubCommand { Message.EDITOR_URL.send(sender); - Component message = new TextComponent(url).color('b') + Component message = TextComponent.builder(url).color(TextColor.AQUA) .clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)) - .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("Click to open the editor.").color('7'))); + .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the editor.").color(TextColor.GRAY))) + .build(); sender.sendMessage(message); return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java index 8a0720dde..67c4f0d3a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java @@ -46,11 +46,13 @@ import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; +import net.kyori.text.BuildableComponent; import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; +import net.kyori.text.format.TextColor; import java.util.ArrayList; import java.util.List; @@ -89,15 +91,15 @@ public class ParentInfo extends SharedSubCommand { } if (page.isEmpty()) { - return new TextComponent("None").color('3'); + return TextComponent.builder("None").color(TextColor.DARK_AQUA).build(); } - TextComponent message = new TextComponent(""); + TextComponent.Builder message = TextComponent.builder(""); for (Node node : page) { String s = "&3> &a" + node.getGroupName() + Util.getAppendableNodeContextString(node) + "\n"; - message.append(ComponentSerializer.parseFromLegacy(s, Constants.FORMAT_CHAR).applyRecursively(makeFancy(holder, label, node))); + message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build()); } - return message; + return message.build(); } private static Component tempGroupsToMessage(SortedSet nodes, PermissionHolder holder, String label) { @@ -109,19 +111,19 @@ public class ParentInfo extends SharedSubCommand { } if (page.isEmpty()) { - return new TextComponent("None").color('3'); + return TextComponent.builder("None").color(TextColor.DARK_AQUA).build(); } - TextComponent message = new TextComponent(""); + TextComponent.Builder message = TextComponent.builder(""); for (Node node : page) { String s = "&3> &a" + node.getPermission() + Util.getAppendableNodeContextString(node) + "\n&2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "\n"; - message.append(ComponentSerializer.parseFromLegacy(s, Constants.FORMAT_CHAR).applyRecursively(makeFancy(holder, label, node))); + message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build()); } - return message; + return message.build(); } - private static Consumer makeFancy(PermissionHolder holder, String label, Node node) { - HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy(TextUtils.joinNewline( + private static Consumer> makeFancy(PermissionHolder holder, String label, Node node) { + HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline( "&3> &f" + node.getGroupName(), " ", "&7Click to remove this parent from " + holder.getFriendlyName() diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java index e6aa36226..cf2868e46 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java @@ -49,11 +49,13 @@ import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; +import net.kyori.text.BuildableComponent; import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; +import net.kyori.text.format.TextColor; import java.util.ArrayList; import java.util.List; @@ -118,7 +120,7 @@ public class PermissionInfo extends SharedSubCommand { } if (l.isEmpty()) { - return Maps.immutableEntry(new TextComponent("None").color('3'), null); + return Maps.immutableEntry(TextComponent.builder("None").color(TextColor.DARK_AQUA).build(), null); } int index = pageNumber - 1; @@ -131,7 +133,7 @@ public class PermissionInfo extends SharedSubCommand { List page = pages.get(index); - TextComponent message = new TextComponent(""); + TextComponent.Builder message = TextComponent.builder(""); String title = "&7(showing page &f" + pageNumber + "&7 of &f" + pages.size() + "&7 - &f" + l.size() + "&7 entries"; if (filter != null) { title += " - filtered by &f\"" + filter + "\"&7)"; @@ -145,14 +147,14 @@ public class PermissionInfo extends SharedSubCommand { s += "&2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "\n"; } - message.append(ComponentSerializer.parseFromLegacy(s, Constants.FORMAT_CHAR).applyRecursively(makeFancy(holder, label, node))); + message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build()); } - return Maps.immutableEntry(message, title); + return Maps.immutableEntry(message.build(), title); } - private static Consumer makeFancy(PermissionHolder holder, String label, Node node) { - HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy(TextUtils.joinNewline( + private static Consumer> makeFancy(PermissionHolder holder, String label, Node node) { + HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline( "¥3> " + (node.getValue() ? "¥a" : "¥c") + node.getPermission(), " ", "¥7Click to remove this node from " + holder.getFriendlyName() diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java index 6e145ed77..d17a81a0c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java @@ -48,11 +48,13 @@ import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; +import net.kyori.text.BuildableComponent; import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; +import net.kyori.text.format.TextColor; import java.util.ArrayList; import java.util.Comparator; @@ -122,7 +124,7 @@ public class GroupListMembers extends SubCommand { private static Map.Entry searchUserResultToMessage(List> results, Function uuidLookup, String label, int pageNumber) { if (results.isEmpty()) { - return Maps.immutableEntry(new TextComponent("None").color('3'), null); + return Maps.immutableEntry(TextComponent.builder("None").color(TextColor.DARK_AQUA).build(), null); } List> sorted = new ArrayList<>(results); @@ -141,20 +143,20 @@ public class GroupListMembers extends SubCommand { .map(hp -> Maps.immutableEntry(uuidLookup.apply(hp.getHolder()), hp)) .collect(Collectors.toList()); - TextComponent message = new TextComponent(""); + TextComponent.Builder message = TextComponent.builder(""); String title = "&7(page &f" + pageNumber + "&7 of &f" + pages.size() + "&7 - &f" + sorted.size() + "&7 entries)"; for (Map.Entry> ent : uuidMappedPage) { String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().asNode()) + Util.getAppendableNodeContextString(ent.getValue().asNode()) + "\n"; - message.append(ComponentSerializer.parseFromLegacy(s, Constants.FORMAT_CHAR).applyRecursively(makeFancy(ent.getKey(), false, label, ent.getValue()))); + message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), false, label, ent.getValue())).build()); } - return Maps.immutableEntry(message, title); + return Maps.immutableEntry(message.build(), title); } private static Map.Entry searchGroupResultToMessage(List> results, String label, int pageNumber) { if (results.isEmpty()) { - return Maps.immutableEntry(new TextComponent("None").color('3'), null); + return Maps.immutableEntry(TextComponent.builder("None").color(TextColor.DARK_AQUA).build(), null); } List> sorted = new ArrayList<>(results); @@ -170,15 +172,15 @@ public class GroupListMembers extends SubCommand { List> page = pages.get(index); - TextComponent message = new TextComponent(""); + TextComponent.Builder message = TextComponent.builder(""); String title = "&7(page &f" + pageNumber + "&7 of &f" + pages.size() + "&7 - &f" + sorted.size() + "&7 entries)"; for (HeldPermission ent : page) { String s = "&3> &b" + ent.getHolder() + " " + getNodeExpiryString(ent.asNode()) + Util.getAppendableNodeContextString(ent.asNode()) + "\n"; - message.append(ComponentSerializer.parseFromLegacy(s, Constants.FORMAT_CHAR).applyRecursively(makeFancy(ent.getHolder(), true, label, ent))); + message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getHolder(), true, label, ent)).build()); } - return Maps.immutableEntry(message, title); + return Maps.immutableEntry(message.build(), title); } private static String getNodeExpiryString(Node node) { @@ -189,8 +191,8 @@ public class GroupListMembers extends SubCommand { return " &8(&7expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "&8)"; } - private static Consumer makeFancy(String holderName, boolean group, String label, HeldPermission perm) { - HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy(TextUtils.joinNewline( + private static Consumer> makeFancy(String holderName, boolean group, String label, HeldPermission perm) { + HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline( "&3> " + (perm.asNode().getValue() ? "&a" : "&c") + perm.asNode().getGroupName(), " ", "&7Click to remove this parent from " + holderName diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/ListGroups.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/ListGroups.java index 7adaa91db..78c1b7fe4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/ListGroups.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/ListGroups.java @@ -38,11 +38,11 @@ import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.Predicates; -import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; +import net.kyori.text.format.TextColor; import java.util.List; import java.util.stream.Collectors; @@ -67,25 +67,25 @@ public class ListGroups extends SingleCommand { }) .forEach(group -> { List tracks = plugin.getTrackManager().getAll().values().stream().filter(t -> t.containsGroup(group)).map(Track::getName).collect(Collectors.toList()); - Component component; + TextComponent component; if (tracks.isEmpty()) { - component = ComponentSerializer.parseFromLegacy(Message.GROUPS_LIST_ENTRY.asString(plugin.getLocaleManager(), + component = LegacyComponent.from(Message.GROUPS_LIST_ENTRY.asString(plugin.getLocaleManager(), group.getDisplayName(), group.getWeight().orElse(0) ), Constants.COLOR_CHAR); } else { - component = ComponentSerializer.parseFromLegacy(Message.GROUPS_LIST_ENTRY_WITH_TRACKS.asString(plugin.getLocaleManager(), + component = LegacyComponent.from(Message.GROUPS_LIST_ENTRY_WITH_TRACKS.asString(plugin.getLocaleManager(), group.getDisplayName(), group.getWeight().orElse(0), Util.toCommaSep(tracks) ), Constants.COLOR_CHAR); } - component.applyRecursively(c -> { + component = component.toBuilder().applyDeep(c -> { c.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + label + " group " + group.getName() + " info")); - c.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("Click to view more info about " + group.getName() + ".").color('7'))); - }); + c.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to view more info about " + group.getName() + ".").color(TextColor.GRAY))); + }).build(); sender.sendMessage(component); }); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java index c58466e72..49ffcefde 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java @@ -47,11 +47,13 @@ import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; +import net.kyori.text.BuildableComponent; import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; -import net.kyori.text.serializer.ComponentSerializer; +import net.kyori.text.format.TextColor; import java.util.ArrayList; import java.util.Comparator; @@ -121,7 +123,7 @@ public class SearchCommand extends SingleCommand { private static Map.Entry searchUserResultToMessage(List> results, Function uuidLookup, String label, int pageNumber) { if (results.isEmpty()) { - return Maps.immutableEntry(new TextComponent("None").color('3'), null); + return Maps.immutableEntry(TextComponent.builder("None").color(TextColor.DARK_AQUA).build(), null); } List> sorted = new ArrayList<>(results); @@ -140,20 +142,20 @@ public class SearchCommand extends SingleCommand { .map(hp -> Maps.immutableEntry(uuidLookup.apply(hp.getHolder()), hp)) .collect(Collectors.toList()); - TextComponent message = new TextComponent(""); + TextComponent.Builder message = TextComponent.builder(""); String title = "&7(page &f" + pageNumber + "&7 of &f" + pages.size() + "&7 - &f" + sorted.size() + "&7 entries)"; for (Map.Entry> ent : uuidMappedPage) { String s = "&3> &b" + ent.getKey() + " &7- " + (ent.getValue().getValue() ? "&a" : "&c") + ent.getValue().getValue() + getNodeExpiryString(ent.getValue().asNode()) + Util.getAppendableNodeContextString(ent.getValue().asNode()) + "\n"; - message.append(ComponentSerializer.parseFromLegacy(s, Constants.FORMAT_CHAR).applyRecursively(makeFancy(ent.getKey(), false, label, ent.getValue()))); + message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), false, label, ent.getValue())).build()); } - return Maps.immutableEntry(message, title); + return Maps.immutableEntry(message.build(), title); } private static Map.Entry searchGroupResultToMessage(List> results, String label, int pageNumber) { if (results.isEmpty()) { - return Maps.immutableEntry(new TextComponent("None").color('3'), null); + return Maps.immutableEntry(TextComponent.builder("None").color(TextColor.DARK_AQUA).build(), null); } List> sorted = new ArrayList<>(results); @@ -169,15 +171,15 @@ public class SearchCommand extends SingleCommand { List> page = pages.get(index); - TextComponent message = new TextComponent(""); + TextComponent.Builder message = TextComponent.builder(""); String title = "&7(page &f" + pageNumber + "&7 of &f" + pages.size() + "&7 - &f" + sorted.size() + "&7 entries)"; for (HeldPermission ent : page) { String s = "&3> &b" + ent.getHolder() + " &7- " + (ent.getValue() ? "&a" : "&c") + ent.getValue() + getNodeExpiryString(ent.asNode()) + Util.getAppendableNodeContextString(ent.asNode()) + "\n"; - message.append(ComponentSerializer.parseFromLegacy(s, Constants.FORMAT_CHAR).applyRecursively(makeFancy(ent.getHolder(), true, label, ent))); + message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getHolder(), true, label, ent)).build()); } - return Maps.immutableEntry(message, title); + return Maps.immutableEntry(message.build(), title); } private static String getNodeExpiryString(Node node) { @@ -188,8 +190,8 @@ public class SearchCommand extends SingleCommand { return " &8(&7expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "&8)"; } - private static Consumer makeFancy(String holderName, boolean group, String label, HeldPermission perm) { - HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy(TextUtils.joinNewline( + private static Consumer> makeFancy(String holderName, boolean group, String label, HeldPermission perm) { + HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline( "&3> " + (perm.asNode().getValue() ? "&a" : "&c") + perm.asNode().getPermission(), " ", "&7Click to remove this node from " + holderName diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/TreeCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/TreeCommand.java index 9f6d44875..8957ed0ab 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/TreeCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/TreeCommand.java @@ -46,6 +46,7 @@ import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; +import net.kyori.text.format.TextColor; import java.util.List; import java.util.UUID; @@ -102,9 +103,10 @@ public class TreeCommand extends SingleCommand { Message.TREE_URL.send(sender); - Component message = new TextComponent(url).color('b') + Component message = TextComponent.builder(url).color(TextColor.AQUA) .clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)) - .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("Click to open the tree view.").color('7'))); + .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the tree view.").color(TextColor.GRAY))) + .build(); sender.sendMessage(message); return CommandResult.SUCCESS; @@ -126,9 +128,10 @@ public class TreeCommand extends SingleCommand { Message.TREE_URL.send(sender); - Component message = new TextComponent(url).color('b') + Component message = TextComponent.builder(url).color(TextColor.AQUA) .clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)) - .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("Click to open the tree view.").color('7'))); + .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the tree view.").color(TextColor.GRAY))) + .build(); sender.sendMessage(message); return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/VerboseCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/VerboseCommand.java index 22b16b835..6a455c065 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/VerboseCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/VerboseCommand.java @@ -43,6 +43,7 @@ import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; +import net.kyori.text.format.TextColor; import java.util.ArrayList; import java.util.Collections; @@ -114,9 +115,10 @@ public class VerboseCommand extends SingleCommand { Message.VERBOSE_RECORDING_URL.send(sender); - Component message = new TextComponent(url).color('b') + Component message = TextComponent.builder(url).color(TextColor.AQUA) .clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)) - .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent("Click to open the results page.").color('7'))); + .hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to open the results page.").color(TextColor.GRAY))) + .build(); sender.sendMessage(message); return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java b/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java index 46dd578d4..f64476b5f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java @@ -36,7 +36,7 @@ import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import net.kyori.text.Component; -import net.kyori.text.serializer.ComponentSerializer; +import net.kyori.text.LegacyComponent; import java.lang.ref.WeakReference; import java.util.UUID; @@ -82,10 +82,11 @@ public final class AbstractSender implements Sender { } } + @SuppressWarnings("deprecation") @Override public void sendMessage(Component message) { if (isConsole()) { - sendMessage(ComponentSerializer.toLegacy(message, Constants.COLOR_CHAR)); + sendMessage(LegacyComponent.to(message)); return; } diff --git a/common/src/main/java/me/lucko/luckperms/common/data/ImporterSender.java b/common/src/main/java/me/lucko/luckperms/common/data/ImporterSender.java index 4390cb0a1..162cf1362 100644 --- a/common/src/main/java/me/lucko/luckperms/common/data/ImporterSender.java +++ b/common/src/main/java/me/lucko/luckperms/common/data/ImporterSender.java @@ -34,7 +34,7 @@ import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import net.kyori.text.Component; -import net.kyori.text.serializer.ComponentSerializer; +import net.kyori.text.LegacyComponent; import java.util.UUID; import java.util.function.Consumer; @@ -64,9 +64,10 @@ public class ImporterSender implements Sender { messageConsumer.accept(s); } + @SuppressWarnings("deprecation") @Override public void sendMessage(Component message) { - messageConsumer.accept(ComponentSerializer.toLegacy(message, Constants.COLOR_CHAR)); + messageConsumer.accept(LegacyComponent.to(message)); } @Override diff --git a/pom.xml b/pom.xml index a2cea2a78..59ac6698a 100644 --- a/pom.xml +++ b/pom.xml @@ -106,6 +106,10 @@ + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + luck-repo https://repo.lucko.me/ diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java index 118be6f29..57e0a8f22 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java @@ -32,6 +32,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.sponge.service.model.CompatibilityUtil; import net.kyori.text.Component; +import net.kyori.text.LegacyComponent; import net.kyori.text.serializer.ComponentSerializer; import org.spongepowered.api.command.CommandSource; @@ -72,7 +73,8 @@ public class SpongeSenderFactory extends SenderFactory { try { source.sendMessage(TextSerializers.JSON.deserialize(ComponentSerializer.serialize(message))); } catch (Exception e) { - sendMessage(source, ComponentSerializer.toLegacy(message, Constants.COLOR_CHAR)); + //noinspection deprecation + sendMessage(source, LegacyComponent.to(message)); } }