Update for latest Text version
This commit is contained in:
parent
069c76c53a
commit
39aaa8a292
@ -25,9 +25,10 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.bukkit.compat;
|
package me.lucko.luckperms.bukkit.compat;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.LegacyComponent;
|
import net.kyori.text.serializer.ComponentSerializers;
|
||||||
import net.kyori.text.serializer.ComponentSerializer;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -47,7 +48,7 @@ public class MessageHandler {
|
|||||||
public void sendJsonMessage(CommandSender sender, Component message) {
|
public void sendJsonMessage(CommandSender sender, Component message) {
|
||||||
if (ReflectionUtil.isChatCompatible() && sender instanceof Player) {
|
if (ReflectionUtil.isChatCompatible() && sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String json = ComponentSerializer.serialize(message);
|
String json = ComponentSerializers.JSON.serialize(message);
|
||||||
|
|
||||||
// Try Bukkit.
|
// Try Bukkit.
|
||||||
if (bukkitHandler.sendJsonMessage(player, json)) {
|
if (bukkitHandler.sendJsonMessage(player, json)) {
|
||||||
@ -61,8 +62,7 @@ public class MessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to Bukkit
|
// Fallback to Bukkit
|
||||||
//noinspection deprecation
|
sender.sendMessage(TextUtils.toLegacy(message));
|
||||||
sender.sendMessage(LegacyComponent.to(message));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSpigot() {
|
private static boolean isSpigot() {
|
||||||
|
@ -30,10 +30,10 @@ import me.lucko.luckperms.bungee.event.TristateCheckEvent;
|
|||||||
import me.lucko.luckperms.common.commands.sender.SenderFactory;
|
import me.lucko.luckperms.common.commands.sender.SenderFactory;
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.LegacyComponent;
|
import net.kyori.text.serializer.ComponentSerializers;
|
||||||
import net.kyori.text.serializer.ComponentSerializer;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -69,10 +69,10 @@ public class BungeeSenderFactory extends SenderFactory<CommandSender> {
|
|||||||
@Override
|
@Override
|
||||||
protected void sendMessage(CommandSender sender, Component message) {
|
protected void sendMessage(CommandSender sender, Component message) {
|
||||||
try {
|
try {
|
||||||
sender.sendMessage(net.md_5.bungee.chat.ComponentSerializer.parse(ComponentSerializer.serialize(message)));
|
sender.sendMessage(net.md_5.bungee.chat.ComponentSerializer.parse(ComponentSerializers.JSON.serialize(message)));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
sendMessage(sender, LegacyComponent.to(message));
|
sendMessage(sender, TextUtils.toLegacy(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>text</artifactId>
|
<artifactId>text</artifactId>
|
||||||
<version>1.11-SNAPSHOT</version>
|
<version>1.11-1.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -32,9 +32,9 @@ import me.lucko.luckperms.common.commands.sender.Sender;
|
|||||||
import me.lucko.luckperms.common.constants.CommandPermission;
|
import me.lucko.luckperms.common.constants.CommandPermission;
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -67,7 +67,7 @@ public class ImporterSender implements Sender {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(Component message) {
|
public void sendMessage(Component message) {
|
||||||
messageConsumer.accept(LegacyComponent.to(message));
|
messageConsumer.accept(TextUtils.toLegacy(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,7 +63,6 @@ import me.lucko.luckperms.common.locale.Message;
|
|||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.utils.TextUtils;
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.ClickEvent;
|
import net.kyori.text.event.ClickEvent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
@ -255,9 +254,9 @@ public class CommandManager {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
String permission = (String) c.getPermission().map(p -> ((CommandPermission) p).getPermission()).orElse("None");
|
String permission = (String) c.getPermission().map(p -> ((CommandPermission) p).getPermission()).orElse("None");
|
||||||
|
|
||||||
TextComponent component = LegacyComponent.from("&3> &a" + String.format(c.getUsage(), label), Constants.FORMAT_CHAR)
|
TextComponent component = TextUtils.fromLegacy("&3> &a" + String.format(c.getUsage(), label), Constants.FORMAT_CHAR)
|
||||||
.toBuilder().applyDeep(comp -> {
|
.toBuilder().applyDeep(comp -> {
|
||||||
comp.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline(
|
comp.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
|
||||||
"&bCommand: &2" + c.getName(),
|
"&bCommand: &2" + c.getName(),
|
||||||
"&bDescription: &2" + c.getDescription(),
|
"&bDescription: &2" + c.getDescription(),
|
||||||
"&bUsage: &2" + String.format(c.getUsage(), label),
|
"&bUsage: &2" + String.format(c.getUsage(), label),
|
||||||
|
@ -45,8 +45,8 @@ import me.lucko.luckperms.common.model.PermissionHolder;
|
|||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
|
|
||||||
@ -85,8 +85,8 @@ public class MetaAddChatMeta extends SharedSubCommand {
|
|||||||
|
|
||||||
DataMutateResult result = holder.setPermission(NodeFactory.makeChatMetaNode(type, priority, meta).withExtraContext(context).build());
|
DataMutateResult result = holder.setPermission(NodeFactory.makeChatMetaNode(type, priority, meta).withExtraContext(context).build());
|
||||||
if (result.asBoolean()) {
|
if (result.asBoolean()) {
|
||||||
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();
|
TextComponent.Builder builder = TextUtils.fromLegacy(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(
|
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||||
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
|
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
|
||||||
'¥'
|
'¥'
|
||||||
));
|
));
|
||||||
|
@ -49,8 +49,8 @@ import me.lucko.luckperms.common.node.NodeFactory;
|
|||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.utils.DateUtil;
|
import me.lucko.luckperms.common.utils.DateUtil;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
|
|
||||||
@ -95,8 +95,8 @@ public class MetaAddTempChatMeta extends SharedSubCommand {
|
|||||||
if (ret.getKey().asBoolean()) {
|
if (ret.getKey().asBoolean()) {
|
||||||
duration = ret.getValue().getExpiryUnixTime();
|
duration = ret.getValue().getExpiryUnixTime();
|
||||||
|
|
||||||
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();
|
TextComponent.Builder builder = TextUtils.fromLegacy(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(
|
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||||
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
|
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
|
||||||
'¥'
|
'¥'
|
||||||
));
|
));
|
||||||
|
@ -50,7 +50,6 @@ import me.lucko.luckperms.common.utils.Predicates;
|
|||||||
import me.lucko.luckperms.common.utils.TextUtils;
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.BuildableComponent;
|
import net.kyori.text.BuildableComponent;
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.ClickEvent;
|
import net.kyori.text.event.ClickEvent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
@ -127,11 +126,11 @@ public class MetaInfo extends SharedSubCommand {
|
|||||||
String location = processLocation(m, holder);
|
String location = processLocation(m, holder);
|
||||||
if (m.hasSpecificContext()) {
|
if (m.hasSpecificContext()) {
|
||||||
String context = Util.getAppendableNodeContextString(m);
|
String context = Util.getAppendableNodeContextString(m);
|
||||||
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();
|
TextComponent.Builder builder = TextUtils.fromLegacy(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));
|
builder.applyDeep(makeFancy(holder, label, m));
|
||||||
sender.sendMessage(builder.build());
|
sender.sendMessage(builder.build());
|
||||||
} else {
|
} else {
|
||||||
TextComponent.Builder builder = LegacyComponent.from(Message.META_ENTRY.asString(sender.getPlatform().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location), Constants.COLOR_CHAR).toBuilder();
|
TextComponent.Builder builder = TextUtils.fromLegacy(Message.META_ENTRY.asString(sender.getPlatform().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location), Constants.COLOR_CHAR).toBuilder();
|
||||||
builder.applyDeep(makeFancy(holder, label, m));
|
builder.applyDeep(makeFancy(holder, label, m));
|
||||||
sender.sendMessage(builder.build());
|
sender.sendMessage(builder.build());
|
||||||
}
|
}
|
||||||
@ -143,11 +142,11 @@ public class MetaInfo extends SharedSubCommand {
|
|||||||
String location = processLocation(e.getValue(), holder);
|
String location = processLocation(e.getValue(), holder);
|
||||||
if (e.getValue().hasSpecificContext()) {
|
if (e.getValue().hasSpecificContext()) {
|
||||||
String context = Util.getAppendableNodeContextString(e.getValue());
|
String context = Util.getAppendableNodeContextString(e.getValue());
|
||||||
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();
|
TextComponent.Builder builder = TextUtils.fromLegacy(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()));
|
builder.applyDeep(makeFancy(type, holder, label, e.getValue()));
|
||||||
sender.sendMessage(builder.build());
|
sender.sendMessage(builder.build());
|
||||||
} else {
|
} else {
|
||||||
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();
|
TextComponent.Builder builder = TextUtils.fromLegacy(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()));
|
builder.applyDeep(makeFancy(type, holder, label, e.getValue()));
|
||||||
sender.sendMessage(builder.build());
|
sender.sendMessage(builder.build());
|
||||||
}
|
}
|
||||||
@ -163,7 +162,7 @@ public class MetaInfo extends SharedSubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline(
|
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
|
||||||
"¥3> ¥a" + type.getEntry(node).getKey() + " ¥7- ¥r" + type.getEntry(node).getValue(),
|
"¥3> ¥a" + type.getEntry(node).getKey() + " ¥7- ¥r" + type.getEntry(node).getValue(),
|
||||||
" ",
|
" ",
|
||||||
"¥7Click to remove this " + type.name().toLowerCase() + " from " + holder.getFriendlyName()
|
"¥7Click to remove this " + type.name().toLowerCase() + " from " + holder.getFriendlyName()
|
||||||
@ -188,7 +187,7 @@ public class MetaInfo extends SharedSubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline(
|
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
|
||||||
"¥3> ¥r" + node.getMeta().getKey() + " ¥7- ¥r" + node.getMeta().getValue(),
|
"¥3> ¥r" + node.getMeta().getKey() + " ¥7- ¥r" + node.getMeta().getValue(),
|
||||||
" ",
|
" ",
|
||||||
"¥7Click to remove this meta pair from " + holder.getFriendlyName()
|
"¥7Click to remove this meta pair from " + holder.getFriendlyName()
|
||||||
|
@ -45,8 +45,8 @@ import me.lucko.luckperms.common.model.PermissionHolder;
|
|||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
|
|
||||||
@ -99,8 +99,8 @@ public class MetaRemoveChatMeta extends SharedSubCommand {
|
|||||||
DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(type, priority, meta).withExtraContext(context).build());
|
DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(type, priority, meta).withExtraContext(context).build());
|
||||||
|
|
||||||
if (result.asBoolean()) {
|
if (result.asBoolean()) {
|
||||||
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();
|
TextComponent.Builder builder = TextUtils.fromLegacy(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(
|
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||||
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
|
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
|
||||||
'¥'
|
'¥'
|
||||||
));
|
));
|
||||||
|
@ -45,8 +45,8 @@ import me.lucko.luckperms.common.model.PermissionHolder;
|
|||||||
import me.lucko.luckperms.common.node.NodeFactory;
|
import me.lucko.luckperms.common.node.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
|
|
||||||
@ -99,8 +99,8 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand {
|
|||||||
DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(type, priority, meta).setExpiry(10L).withExtraContext(context).build());
|
DataMutateResult result = holder.unsetPermission(NodeFactory.makeChatMetaNode(type, priority, meta).setExpiry(10L).withExtraContext(context).build());
|
||||||
|
|
||||||
if (result.asBoolean()) {
|
if (result.asBoolean()) {
|
||||||
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();
|
TextComponent.Builder builder = TextUtils.fromLegacy(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(
|
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||||
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
|
"¥3Raw " + type.name().toLowerCase() + ": ¥r" + meta,
|
||||||
'¥'
|
'¥'
|
||||||
));
|
));
|
||||||
|
@ -45,7 +45,6 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
|||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.common.utils.TextUtils;
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
|
|
||||||
@ -88,8 +87,8 @@ public class MetaSet extends SharedSubCommand {
|
|||||||
holder.clearMetaKeys(key, context, false);
|
holder.clearMetaKeys(key, context, false);
|
||||||
holder.setPermission(n);
|
holder.setPermission(n);
|
||||||
|
|
||||||
TextComponent.Builder builder = LegacyComponent.from(Message.SET_META_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), Util.contextSetToString(context))).toBuilder();
|
TextComponent.Builder builder = TextUtils.fromLegacy(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(
|
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||||
TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value),
|
TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value),
|
||||||
'¥'
|
'¥'
|
||||||
));
|
));
|
||||||
|
@ -49,7 +49,6 @@ import me.lucko.luckperms.common.utils.DateUtil;
|
|||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.common.utils.TextUtils;
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
|
|
||||||
@ -94,8 +93,8 @@ public class MetaSetTemp extends SharedSubCommand {
|
|||||||
holder.clearMetaKeys(key, context, true);
|
holder.clearMetaKeys(key, context, true);
|
||||||
duration = holder.setPermission(n, modifier).getValue().getExpiryUnixTime();
|
duration = holder.setPermission(n, modifier).getValue().getExpiryUnixTime();
|
||||||
|
|
||||||
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();
|
TextComponent.Builder builder = TextUtils.fromLegacy(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(
|
HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(
|
||||||
TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value),
|
TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value),
|
||||||
'¥'
|
'¥'
|
||||||
));
|
));
|
||||||
|
@ -48,7 +48,6 @@ import me.lucko.luckperms.common.utils.TextUtils;
|
|||||||
|
|
||||||
import net.kyori.text.BuildableComponent;
|
import net.kyori.text.BuildableComponent;
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.ClickEvent;
|
import net.kyori.text.event.ClickEvent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
@ -97,7 +96,7 @@ public class ParentInfo extends SharedSubCommand {
|
|||||||
TextComponent.Builder message = TextComponent.builder("");
|
TextComponent.Builder message = TextComponent.builder("");
|
||||||
for (Node node : page) {
|
for (Node node : page) {
|
||||||
String s = "&3> &a" + node.getGroupName() + Util.getAppendableNodeContextString(node) + "\n";
|
String s = "&3> &a" + node.getGroupName() + Util.getAppendableNodeContextString(node) + "\n";
|
||||||
message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build());
|
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build());
|
||||||
}
|
}
|
||||||
return message.build();
|
return message.build();
|
||||||
}
|
}
|
||||||
@ -117,13 +116,13 @@ public class ParentInfo extends SharedSubCommand {
|
|||||||
TextComponent.Builder message = TextComponent.builder("");
|
TextComponent.Builder message = TextComponent.builder("");
|
||||||
for (Node node : page) {
|
for (Node node : page) {
|
||||||
String s = "&3> &a" + node.getPermission() + Util.getAppendableNodeContextString(node) + "\n&2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "\n";
|
String s = "&3> &a" + node.getPermission() + Util.getAppendableNodeContextString(node) + "\n&2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "\n";
|
||||||
message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build());
|
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build());
|
||||||
}
|
}
|
||||||
return message.build();
|
return message.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Consumer<BuildableComponent.Builder<? ,?>> makeFancy(PermissionHolder holder, String label, Node node) {
|
private static Consumer<BuildableComponent.Builder<? ,?>> makeFancy(PermissionHolder holder, String label, Node node) {
|
||||||
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline(
|
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
|
||||||
"&3> &f" + node.getGroupName(),
|
"&3> &f" + node.getGroupName(),
|
||||||
" ",
|
" ",
|
||||||
"&7Click to remove this parent from " + holder.getFriendlyName()
|
"&7Click to remove this parent from " + holder.getFriendlyName()
|
||||||
|
@ -51,7 +51,6 @@ import me.lucko.luckperms.common.utils.TextUtils;
|
|||||||
|
|
||||||
import net.kyori.text.BuildableComponent;
|
import net.kyori.text.BuildableComponent;
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.ClickEvent;
|
import net.kyori.text.event.ClickEvent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
@ -179,14 +178,14 @@ public class PermissionInfo extends SharedSubCommand {
|
|||||||
s += "&2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "\n";
|
s += "&2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()) + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build());
|
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(holder, label, node)).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Maps.immutableEntry(message.build(), title);
|
return Maps.immutableEntry(message.build(), title);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(PermissionHolder holder, String label, Node node) {
|
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(PermissionHolder holder, String label, Node node) {
|
||||||
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponent.from(TextUtils.joinNewline(
|
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
|
||||||
"¥3> " + (node.getValue() ? "¥a" : "¥c") + node.getPermission(),
|
"¥3> " + (node.getValue() ? "¥a" : "¥c") + node.getPermission(),
|
||||||
" ",
|
" ",
|
||||||
"¥7Click to remove this node from " + holder.getFriendlyName()
|
"¥7Click to remove this node from " + holder.getFriendlyName()
|
||||||
|
@ -50,7 +50,6 @@ import me.lucko.luckperms.common.utils.TextUtils;
|
|||||||
|
|
||||||
import net.kyori.text.BuildableComponent;
|
import net.kyori.text.BuildableComponent;
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.ClickEvent;
|
import net.kyori.text.event.ClickEvent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
@ -148,7 +147,7 @@ public class GroupListMembers extends SubCommand<Group> {
|
|||||||
|
|
||||||
for (Map.Entry<String, HeldPermission<UUID>> ent : uuidMappedPage) {
|
for (Map.Entry<String, HeldPermission<UUID>> ent : uuidMappedPage) {
|
||||||
String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().asNode()) + Util.getAppendableNodeContextString(ent.getValue().asNode()) + "\n";
|
String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().asNode()) + Util.getAppendableNodeContextString(ent.getValue().asNode()) + "\n";
|
||||||
message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), false, label, ent.getValue())).build());
|
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), false, label, ent.getValue())).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Maps.immutableEntry(message.build(), title);
|
return Maps.immutableEntry(message.build(), title);
|
||||||
@ -177,7 +176,7 @@ public class GroupListMembers extends SubCommand<Group> {
|
|||||||
|
|
||||||
for (HeldPermission<String> ent : page) {
|
for (HeldPermission<String> ent : page) {
|
||||||
String s = "&3> &b" + ent.getHolder() + " " + getNodeExpiryString(ent.asNode()) + Util.getAppendableNodeContextString(ent.asNode()) + "\n";
|
String s = "&3> &b" + ent.getHolder() + " " + getNodeExpiryString(ent.asNode()) + Util.getAppendableNodeContextString(ent.asNode()) + "\n";
|
||||||
message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getHolder(), true, label, ent)).build());
|
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getHolder(), true, label, ent)).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Maps.immutableEntry(message.build(), title);
|
return Maps.immutableEntry(message.build(), title);
|
||||||
@ -192,7 +191,7 @@ public class GroupListMembers extends SubCommand<Group> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Consumer<BuildableComponent.Builder<? ,?>> makeFancy(String holderName, boolean group, String label, HeldPermission<?> perm) {
|
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(
|
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
|
||||||
"&3> " + (perm.asNode().getValue() ? "&a" : "&c") + perm.asNode().getGroupName(),
|
"&3> " + (perm.asNode().getValue() ? "&a" : "&c") + perm.asNode().getGroupName(),
|
||||||
" ",
|
" ",
|
||||||
"&7Click to remove this parent from " + holderName
|
"&7Click to remove this parent from " + holderName
|
||||||
|
@ -37,8 +37,8 @@ import me.lucko.luckperms.common.locale.Message;
|
|||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.ClickEvent;
|
import net.kyori.text.event.ClickEvent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
@ -70,12 +70,12 @@ public class ListGroups extends SingleCommand {
|
|||||||
TextComponent component;
|
TextComponent component;
|
||||||
|
|
||||||
if (tracks.isEmpty()) {
|
if (tracks.isEmpty()) {
|
||||||
component = LegacyComponent.from(Message.GROUPS_LIST_ENTRY.asString(plugin.getLocaleManager(),
|
component = TextUtils.fromLegacy(Message.GROUPS_LIST_ENTRY.asString(plugin.getLocaleManager(),
|
||||||
group.getDisplayName(),
|
group.getDisplayName(),
|
||||||
group.getWeight().orElse(0)
|
group.getWeight().orElse(0)
|
||||||
), Constants.COLOR_CHAR);
|
), Constants.COLOR_CHAR);
|
||||||
} else {
|
} else {
|
||||||
component = LegacyComponent.from(Message.GROUPS_LIST_ENTRY_WITH_TRACKS.asString(plugin.getLocaleManager(),
|
component = TextUtils.fromLegacy(Message.GROUPS_LIST_ENTRY_WITH_TRACKS.asString(plugin.getLocaleManager(),
|
||||||
group.getDisplayName(),
|
group.getDisplayName(),
|
||||||
group.getWeight().orElse(0),
|
group.getWeight().orElse(0),
|
||||||
Util.toCommaSep(tracks)
|
Util.toCommaSep(tracks)
|
||||||
|
@ -49,7 +49,6 @@ import me.lucko.luckperms.common.utils.TextUtils;
|
|||||||
|
|
||||||
import net.kyori.text.BuildableComponent;
|
import net.kyori.text.BuildableComponent;
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.event.ClickEvent;
|
import net.kyori.text.event.ClickEvent;
|
||||||
import net.kyori.text.event.HoverEvent;
|
import net.kyori.text.event.HoverEvent;
|
||||||
@ -147,7 +146,7 @@ public class SearchCommand extends SingleCommand {
|
|||||||
|
|
||||||
for (Map.Entry<String, HeldPermission<UUID>> ent : uuidMappedPage) {
|
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";
|
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(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), false, label, ent.getValue())).build());
|
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), false, label, ent.getValue())).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Maps.immutableEntry(message.build(), title);
|
return Maps.immutableEntry(message.build(), title);
|
||||||
@ -176,7 +175,7 @@ public class SearchCommand extends SingleCommand {
|
|||||||
|
|
||||||
for (HeldPermission<String> ent : page) {
|
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";
|
String s = "&3> &b" + ent.getHolder() + " &7- " + (ent.getValue() ? "&a" : "&c") + ent.getValue() + getNodeExpiryString(ent.asNode()) + Util.getAppendableNodeContextString(ent.asNode()) + "\n";
|
||||||
message.append(LegacyComponent.from(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getHolder(), true, label, ent)).build());
|
message.append(TextUtils.fromLegacy(s, Constants.FORMAT_CHAR).toBuilder().applyDeep(makeFancy(ent.getHolder(), true, label, ent)).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Maps.immutableEntry(message.build(), title);
|
return Maps.immutableEntry(message.build(), title);
|
||||||
@ -191,7 +190,7 @@ public class SearchCommand extends SingleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Consumer<BuildableComponent.Builder<?, ?>> makeFancy(String holderName, boolean group, String label, HeldPermission<?> perm) {
|
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(
|
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy(TextUtils.joinNewline(
|
||||||
"&3> " + (perm.asNode().getValue() ? "&a" : "&c") + perm.asNode().getPermission(),
|
"&3> " + (perm.asNode().getValue() ? "&a" : "&c") + perm.asNode().getPermission(),
|
||||||
" ",
|
" ",
|
||||||
"&7Click to remove this node from " + holderName
|
"&7Click to remove this node from " + holderName
|
||||||
|
@ -34,9 +34,9 @@ import me.lucko.luckperms.api.Tristate;
|
|||||||
import me.lucko.luckperms.common.constants.CommandPermission;
|
import me.lucko.luckperms.common.constants.CommandPermission;
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.LegacyComponent;
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -86,7 +86,7 @@ public final class AbstractSender<T> implements Sender {
|
|||||||
@Override
|
@Override
|
||||||
public void sendMessage(Component message) {
|
public void sendMessage(Component message) {
|
||||||
if (isConsole()) {
|
if (isConsole()) {
|
||||||
sendMessage(LegacyComponent.to(message));
|
sendMessage(TextUtils.toLegacy(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +27,14 @@ package me.lucko.luckperms.common.utils;
|
|||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
|
import net.kyori.text.Component;
|
||||||
|
import net.kyori.text.TextComponent;
|
||||||
|
import net.kyori.text.serializer.ComponentSerializers;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class TextUtils {
|
public class TextUtils {
|
||||||
|
|
||||||
@ -37,4 +42,20 @@ public class TextUtils {
|
|||||||
return Arrays.stream(strings).collect(Collectors.joining("\n"));
|
return Arrays.stream(strings).collect(Collectors.joining("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TextComponent fromLegacy(String input, char character) {
|
||||||
|
return ComponentSerializers.LEGACY.deserialize(input, character);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextComponent fromLegacy(String input) {
|
||||||
|
return ComponentSerializers.LEGACY.deserialize(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toLegacy(Component component, char character) {
|
||||||
|
return ComponentSerializers.LEGACY.serialize(component, character);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toLegacy(Component component) {
|
||||||
|
return ComponentSerializers.LEGACY.serialize(component);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
4
pom.xml
4
pom.xml
@ -106,10 +106,6 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
|
||||||
<id>sonatype-snapshots</id>
|
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>luck-repo</id>
|
<id>luck-repo</id>
|
||||||
<url>https://repo.lucko.me/</url>
|
<url>https://repo.lucko.me/</url>
|
||||||
|
@ -29,11 +29,11 @@ import me.lucko.luckperms.api.Tristate;
|
|||||||
import me.lucko.luckperms.common.commands.sender.SenderFactory;
|
import me.lucko.luckperms.common.commands.sender.SenderFactory;
|
||||||
import me.lucko.luckperms.common.constants.Constants;
|
import me.lucko.luckperms.common.constants.Constants;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
import me.lucko.luckperms.sponge.service.model.CompatibilityUtil;
|
import me.lucko.luckperms.sponge.service.model.CompatibilityUtil;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.LegacyComponent;
|
import net.kyori.text.serializer.ComponentSerializers;
|
||||||
import net.kyori.text.serializer.ComponentSerializer;
|
|
||||||
|
|
||||||
import org.spongepowered.api.command.CommandSource;
|
import org.spongepowered.api.command.CommandSource;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
@ -71,10 +71,10 @@ public class SpongeSenderFactory extends SenderFactory<CommandSource> {
|
|||||||
@Override
|
@Override
|
||||||
protected void sendMessage(CommandSource source, Component message) {
|
protected void sendMessage(CommandSource source, Component message) {
|
||||||
try {
|
try {
|
||||||
source.sendMessage(TextSerializers.JSON.deserialize(ComponentSerializer.serialize(message)));
|
source.sendMessage(TextSerializers.JSON.deserialize(ComponentSerializers.JSON.serialize(message)));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
sendMessage(source, LegacyComponent.to(message));
|
sendMessage(source, TextUtils.toLegacy(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user