Update KyoriPowered/text dependency

This commit is contained in:
Luck 2017-08-16 10:56:35 +02:00
parent 046202719a
commit 909844aef5
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
23 changed files with 153 additions and 128 deletions

View File

@ -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() {

View File

@ -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<CommandSender> {
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));
}
}

View File

@ -39,7 +39,7 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>text</artifactId>
<version>1.12-SNAPSHOT</version>
<version>1.11-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- HikariCP -->

View File

@ -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);
});
}

View File

@ -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(" ")))

View File

@ -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(" ")))

View File

@ -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<Component> makeFancy(ChatMetaType type, PermissionHolder holder, String label, LocalizedNode node) {
private static Consumer<BuildableComponent.Builder<?, ?>> 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<Component> makeFancy(PermissionHolder holder, String label, LocalizedNode node) {
private static Consumer<BuildableComponent.Builder<?, ?>> 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()

View File

@ -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(" ")))

View File

@ -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(" ")))

View File

@ -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(" ")))

View File

@ -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(" ")))

View File

@ -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<T extends PermissionHolder> extends SubCommand<T> {
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;

View File

@ -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<LocalizedNode> 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<Component> makeFancy(PermissionHolder holder, String label, Node node) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy(TextUtils.joinNewline(
private static Consumer<BuildableComponent.Builder<? ,?>> 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()

View File

@ -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<Node> 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<Component> makeFancy(PermissionHolder holder, String label, Node node) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy(TextUtils.joinNewline(
private static Consumer<BuildableComponent.Builder<?, ?>> 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()

View File

@ -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<Group> {
private static Map.Entry<Component, String> searchUserResultToMessage(List<HeldPermission<UUID>> results, Function<UUID, String> 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<HeldPermission<UUID>> sorted = new ArrayList<>(results);
@ -141,20 +143,20 @@ public class GroupListMembers extends SubCommand<Group> {
.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<String, HeldPermission<UUID>> 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<Component, String> searchGroupResultToMessage(List<HeldPermission<String>> 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<HeldPermission<String>> sorted = new ArrayList<>(results);
@ -170,15 +172,15 @@ public class GroupListMembers extends SubCommand<Group> {
List<HeldPermission<String>> 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<String> 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<Group> {
return " &8(&7expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "&8)";
}
private static Consumer<Component> makeFancy(String holderName, boolean group, String label, HeldPermission<?> perm) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy(TextUtils.joinNewline(
private static Consumer<BuildableComponent.Builder<? ,?>> 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

View File

@ -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<String> 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);
});

View File

@ -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<Component, String> searchUserResultToMessage(List<HeldPermission<UUID>> results, Function<UUID, String> 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<HeldPermission<UUID>> 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<String, HeldPermission<UUID>> 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<Component, String> searchGroupResultToMessage(List<HeldPermission<String>> 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<HeldPermission<String>> sorted = new ArrayList<>(results);
@ -169,15 +171,15 @@ public class SearchCommand extends SingleCommand {
List<HeldPermission<String>> 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<String> 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<Component> makeFancy(String holderName, boolean group, String label, HeldPermission<?> perm) {
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentSerializer.parseFromLegacy(TextUtils.joinNewline(
private static Consumer<BuildableComponent.Builder<?, ?>> 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

View File

@ -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;

View File

@ -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;

View File

@ -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<T> implements Sender {
}
}
@SuppressWarnings("deprecation")
@Override
public void sendMessage(Component message) {
if (isConsole()) {
sendMessage(ComponentSerializer.toLegacy(message, Constants.COLOR_CHAR));
sendMessage(LegacyComponent.to(message));
return;
}

View File

@ -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

View File

@ -106,6 +106,10 @@
</build>
<repositories>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>luck-repo</id>
<url>https://repo.lucko.me/</url>

View File

@ -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<CommandSource> {
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));
}
}