diff --git a/common/build.gradle b/common/build.gradle index c6f318ff5..a8b533e02 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -45,6 +45,11 @@ dependencies { exclude(module: 'adventure-api') } + api("net.kyori:adventure-text-minimessage:4.11.0") { + exclude(module: 'adventure-bom') + exclude(module: 'adventure-api') + } + api('net.kyori:event-api:3.0.0') { exclude(module: 'checker-qual') exclude(module: 'guava') diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java index bc4a66c23..99407c306 100644 --- a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java +++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java @@ -59,33 +59,32 @@ public enum Dependency { "1.7", "b30RhOF6kHiHl+O5suNLh/+eAr1iOFEFLXhwkHHDu4I=" ), - ADVENTURE( "me{}lucko", "adventure-api", - "4.11.0", - "7xrFaBbsTiQPZKBDzvDnTd8XIgOsHTy9qQICm3342GU=", + "4.13.0", + "gcmYlY1KDrzbnE9nB8rA44oBZKPSMvv9kNRefoEuud0=", Relocation.of("adventure", "net{}kyori{}adventure") ), ADVENTURE_PLATFORM( "me{}lucko", "adventure-platform-api", - "4.11.2", - "zCnxNgosme++TsheFaL+YHdtRIrp+oJhUiI8awsKgfQ=", + "4.13.0", + "Kk8IkEMVa9ITBfC3yocpcXQiZ9CwN9VxeWjKUD8I0n0=", Relocation.of("adventure", "net{}kyori{}adventure") ), ADVENTURE_PLATFORM_BUKKIT( "me{}lucko", "adventure-platform-bukkit", - "4.11.2", - "mrtYZvt00GH4oejuBJ2QEbFkmz1F+PGmthPwroSxCgo=", + "4.13.0", + "Rif/+xdGfRrlhxXYb2+jMFBnwnLQ2pnjAJ/BxWApins=", Relocation.of("adventure", "net{}kyori{}adventure") ), ADVENTURE_PLATFORM_BUNGEECORD( "me{}lucko", "adventure-platform-bungeecord", - "4.11.2", - "+WUdRdZ6qkacw3ha/R3ayLx46soMywGe70Zmnw4yha8=", + "4.13.0", + "MLk/qAgWC9YT2ImLq/sVo114V5Rk1jQr4jc57WAoO74=", Relocation.of("adventure", "net{}kyori{}adventure") ), EVENT( diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java index d192d9cbf..3a6ea5f56 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java @@ -39,9 +39,11 @@ import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.DurationFormatter; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.ComponentLike; +import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; +import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.luckperms.api.context.Context; import net.luckperms.api.context.ContextSet; @@ -96,7 +98,7 @@ public interface Message { TextComponent OPEN_BRACKET = Component.text('('); TextComponent CLOSE_BRACKET = Component.text(')'); TextComponent FULL_STOP = Component.text('.'); - + Component PREFIX_COMPONENT = text() .color(GRAY) .append(text('[')) @@ -135,7 +137,7 @@ public interface Message { // " | |__) " // " |___ | " - return join(newline(), + return joinNewline( text() .append(text(" ", AQUA)) .append(text(" __ ", DARK_AQUA)) @@ -175,7 +177,7 @@ public interface Message { .color(GRAY) ); - Args2 FIRST_TIME_SETUP = (label, username) -> join(newline(), + Args2 FIRST_TIME_SETUP = (label, username) -> joinNewline( // "&3It seems that no permissions have been setup yet!" // "&3Before you can use any of the LuckPerms commands in-game, you need to use the console to give yourself access." // "&3Open your console and run:" @@ -278,7 +280,7 @@ public interface Message { .append(FULL_STOP) ); - Args1 LOG = action -> join(newline(), + Args1 LOG = action -> joinNewline( // "&3LOG &3&l> &8(&e{}&8) [&a{}&8] (&b{}&8)" // "&3LOG &3&l> &f{}" prefixed(text() @@ -489,7 +491,7 @@ public interface Message { .append(CLOSE_BRACKET) )); - Args2 COMMAND_USAGE_DETAILED_HEADER = (name, usage) -> join(newline(), + Args2 COMMAND_USAGE_DETAILED_HEADER = (name, usage) -> joinNewline( // "&3&lCommand Usage &3- &b{}" // "&b> &7{}" prefixed(text() @@ -666,7 +668,7 @@ public interface Message { .append(FULL_STOP) ); - Args0 VERBOSE_OFF_COMMAND_NO_CHECKS = () -> join(newline(), + Args0 VERBOSE_OFF_COMMAND_NO_CHECKS = () -> joinNewline( // &bThe command execution completed, but no permission checks were made. // &7This might be because the plugin runs commands in the background (async). You can still use verbose manually to detect checks made like this. prefixed(translatable() @@ -705,7 +707,7 @@ public interface Message { .args(translatable("luckperms.command.verbose.disabled-term", RED)) ); - Args1 VERBOSE_RESULTS_URL = url -> join(newline(), + Args1 VERBOSE_RESULTS_URL = url -> joinNewline( // "&aVerbose results URL:" // prefixed(translatable() @@ -731,7 +733,7 @@ public interface Message { .append(FULL_STOP) ); - Args1 TREE_URL = url -> join(newline(), + Args1 TREE_URL = url -> joinNewline( // "&aPermission tree URL:" // prefixed(translatable() @@ -886,7 +888,7 @@ public interface Message { .apply(builder -> { boolean explicitGlobalContext = !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - Component hover = join(newline(), + Component hover = joinNewline( text() .append(text('>', DARK_AQUA)) .append(space()) @@ -930,7 +932,7 @@ public interface Message { .apply(builder -> { boolean explicitGlobalContext = !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - Component hover = join(newline(), + Component hover = joinNewline( text() .append(text('>', DARK_AQUA)) .append(space()) @@ -949,7 +951,7 @@ public interface Message { }) .build(); - Args2 APPLY_EDITS_SESSION_UNKNOWN = (code, label) -> join(newline(), + Args2 APPLY_EDITS_SESSION_UNKNOWN = (code, label) -> joinNewline( // "&4The changes received from the web editor were not made in a session started on this server!" // "&cAre you sure you're running the /lp applyedits command in the right place?" // "&cTo ignore this warning and apply the changes anyway, run: &4/lp applyedits --force" @@ -967,7 +969,7 @@ public interface Message { .append(text("/" + label + " applyedits " + code + " --force", DARK_RED))) ); - Args2 APPLY_EDITS_SESSION_APPLIED_ALREADY = (code, label) -> join(newline(), + Args2 APPLY_EDITS_SESSION_APPLIED_ALREADY = (code, label) -> joinNewline( // "&4The changes received from the web editor are based on an initial session which has already been applied!" // "&cTo avoid conflicts, you should never re-use the same editor session after the changes from it have been applied once already." // "&cTo ignore this warning and apply the changes anyway, run: /lp applyedits --force" @@ -1149,7 +1151,7 @@ public interface Message { .key("luckperms.command.editor.start") ); - Args1 EDITOR_URL = url -> join(newline(), + Args1 EDITOR_URL = url -> joinNewline( // "&aClick the link below to open the editor:" // prefixed(translatable() @@ -1183,7 +1185,7 @@ public interface Message { .append(FULL_STOP) ); - Args4 EDITOR_SOCKET_UNTRUSTED = (nonce, browser, cmdLabel, console) -> join(newline(), + Args4 EDITOR_SOCKET_UNTRUSTED = (nonce, browser, cmdLabel, console) -> joinNewline( // "&bAn editor window has connected, but it is not yet trusted." // "&8(&7session id = &faaaaa&7, browser = &fChrome on Windows 10&8)" // "&7If it was you, &aclick here&7 to trust the session!" @@ -1229,7 +1231,7 @@ public interface Message { })) ); - Args0 EDITOR_SOCKET_TRUST_SUCCESS = () -> join(newline(), + Args0 EDITOR_SOCKET_TRUST_SUCCESS = () -> joinNewline( // "&aThe editor session has been marked as trusted." // "&7In the future, connections from the same browser will be trusted automatically." // "&7The plugin will now attempt to establish a connection with the editor..." @@ -1533,7 +1535,7 @@ public interface Message { ) ); - Args2> INFO = (plugin, storageMeta) -> join(newline(), + Args2> INFO = (plugin, storageMeta) -> joinNewline( // "&2Running &bLuckPerms v{}&2 by &bLuck&2." // "&f- &3Platform: &f{}" // "&f- &3Server Brand: &f{}" @@ -1768,7 +1770,7 @@ public interface Message { String holderName = holder.getType() == HolderType.GROUP ? holder.getIdentifier().getName() : holder.getPlainDisplayName(); boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - Component hover = join(newline(), + Component hover = joinNewline( text() .append(text('>', DARK_AQUA)) .append(space()) @@ -1787,7 +1789,7 @@ public interface Message { }) .build(); - Args3 PERMISSION_INFO_TEMPORARY_NODE_ENTRY = (node, holder, label) -> join(newline(), + Args3 PERMISSION_INFO_TEMPORARY_NODE_ENTRY = (node, holder, label) -> joinNewline( text() .append(text('>', DARK_AQUA)) .append(space()) @@ -1798,7 +1800,7 @@ public interface Message { String holderName = holder.getType() == HolderType.GROUP ? holder.getIdentifier().getName() : holder.getPlainDisplayName(); boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - Component hover = join(newline(), + Component hover = joinNewline( text() .append(text('>', DARK_AQUA)) .append(space()) @@ -1868,7 +1870,7 @@ public interface Message { String holderName = holder.getType() == HolderType.GROUP ? holder.getIdentifier().getName() : holder.getPlainDisplayName(); boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - Component hover = join(newline(), + Component hover = joinNewline( text() .append(text('>', DARK_AQUA)) .append(space()) @@ -1890,7 +1892,7 @@ public interface Message { .append(formatContextSetBracketed(node.getContexts(), empty())) .build(); - Args3 PARENT_INFO_TEMPORARY_NODE_ENTRY = (node, holder, label) -> join(newline(), + Args3 PARENT_INFO_TEMPORARY_NODE_ENTRY = (node, holder, label) -> joinNewline( text() .append(text('>', DARK_AQUA)) .append(space()) @@ -1901,7 +1903,7 @@ public interface Message { String holderName = holder.getType() == HolderType.GROUP ? holder.getIdentifier().getName() : holder.getPlainDisplayName(); boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - Component hover = join(newline(), + Component hover = joinNewline( text() .append(text('>', DARK_AQUA)) .append(text(node.getGroupName(), WHITE)), @@ -1938,7 +1940,7 @@ public interface Message { .append(text(':')) ); - Args3 LIST_TRACKS_ENTRY = (name, contextSet, path) -> join(newline(), + Args3 LIST_TRACKS_ENTRY = (name, contextSet, path) -> joinNewline( // "&3> &a{}: {}" // "&7 ({}&7)" text() @@ -2040,7 +2042,7 @@ public interface Message { ) ); - Args5 PERMISSION_CHECK_RESULT = (permission, result, processor, causeNode, context) -> join(newline(), + Args5 PERMISSION_CHECK_RESULT = (permission, result, processor, causeNode, context) -> joinNewline( // &aPermission check for &b{}&a: // &3Result: {} // &3Processor: &f{} @@ -2516,7 +2518,7 @@ public interface Message { HolderType originType = HolderType.valueOf(origin.getOrigin().getType().toUpperCase(Locale.ROOT)); boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - Component hover = join(newline(), + Component hover = joinNewline( text() .append(text('>', DARK_AQUA)) .append(space()) @@ -2591,7 +2593,7 @@ public interface Message { HolderType originType = HolderType.valueOf(origin.getOrigin().getType().toUpperCase(Locale.ROOT)); boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - Component hover = join(newline(), + Component hover = joinNewline( text() .append(text('>', DARK_AQUA)) .append(space()) @@ -2987,7 +2989,7 @@ public interface Message { .append(FULL_STOP) ); - Args3 BULK_UPDATE_STATISTICS = (nodes, users, groups) -> join(newline(), + Args3 BULK_UPDATE_STATISTICS = (nodes, users, groups) -> joinNewline( // "&bTotal affected nodes: &a{}" // "&bTotal affected users: &a{}" // "&bTotal affected groups: &a{}" @@ -3069,7 +3071,7 @@ public interface Message { }) ); - Args1 TRANSLATIONS_DOWNLOAD_PROMPT = label -> join(newline(), + Args1 TRANSLATIONS_DOWNLOAD_PROMPT = label -> joinNewline( // "Use /lp translations install to download and install up-to-date versions of these translations provided by the community." // "Please note that this will override any changes you've made for these languages." prefixed(translatable() @@ -3113,7 +3115,7 @@ public interface Message { .append(FULL_STOP) ); - Args4 USER_INFO_GENERAL = (username, uuid, uuidType, online) -> join(newline(), + Args4 USER_INFO_GENERAL = (username, uuid, uuidType, online) -> joinNewline( // "&b&l> &bUser Info: &f{}" // "&f- &3UUID: &f{}" // "&f &7(type: {}&7)" @@ -3147,7 +3149,7 @@ public interface Message { .append(online ? translatable("luckperms.command.user.info.status.online", GREEN) : translatable("luckperms.command.user.info.status.offline", RED))) ); - Args6>> USER_INFO_CONTEXTUAL_DATA = (active, contexts, prefix, suffix, primaryGroup, meta) -> join(newline(), + Args6>> USER_INFO_CONTEXTUAL_DATA = (active, contexts, prefix, suffix, primaryGroup, meta) -> joinNewline( // "&f- &aContextual Data: &7(mode: {}&7)" // " &3Contexts: {}" // " &3Prefix: {}" @@ -3234,7 +3236,7 @@ public interface Message { .build() ) .collect(Collectors.toList()); - builder.append(join(space(), entries)); + builder.append(join(JoinConfiguration.separator(space()), entries)); } })) ); @@ -3261,7 +3263,7 @@ public interface Message { .append(formatContextSetBracketed(node.getContexts(), empty())) ); - Args1 INFO_PARENT_TEMPORARY_NODE_ENTRY = node -> join(newline(), + Args1 INFO_PARENT_TEMPORARY_NODE_ENTRY = node -> joinNewline( prefixed(text() .append(text(" > ", DARK_AQUA)) .append(text(node.getGroupName(), WHITE)) @@ -3390,7 +3392,7 @@ public interface Message { .append(FULL_STOP) ); - Args1 USER_PROMOTE_ERROR_MALFORMED = name -> join(newline(), + Args1 USER_PROMOTE_ERROR_MALFORMED = name -> joinNewline( // "&aThe next group on the track, &b{}&a, no longer exists. Unable to promote user." // "&aEither create the group, or remove it from the track and try again." prefixed(translatable() @@ -3444,7 +3446,7 @@ public interface Message { .append(FULL_STOP) ); - Args1 USER_DEMOTE_ERROR_MALFORMED = name -> join(newline(), + Args1 USER_DEMOTE_ERROR_MALFORMED = name -> joinNewline( // "&aThe previous group on the track, &b{}&a, no longer exists. Unable to demote user." // "&aEither create the group, or remove it from the track and try again." prefixed(translatable() @@ -3461,7 +3463,7 @@ public interface Message { .append(FULL_STOP)) ); - Args3 GROUP_INFO_GENERAL = (name, displayName, weight) -> join(newline(), + Args3 GROUP_INFO_GENERAL = (name, displayName, weight) -> joinNewline( // "&b&l> &bGroup Info: &f{}" // "&f- &3Display Name: &f{}" // "&f- &3Weight: &f{}" @@ -3486,7 +3488,7 @@ public interface Message { .append(weight.isPresent() ? text(weight.getAsInt(), WHITE) : translatable("luckperms.command.generic.contextual-data.null-result", WHITE))) ); - Args3>> GROUP_INFO_CONTEXTUAL_DATA = (prefix, suffix, meta) -> join(newline(), + Args3>> GROUP_INFO_CONTEXTUAL_DATA = (prefix, suffix, meta) -> joinNewline( // "&f- &aContextual Data: &7(mode: &8server&7)" // " &3Prefix: {}" // " &3Suffix: {}" @@ -3559,7 +3561,7 @@ public interface Message { .build() ) .collect(Collectors.toList()); - builder.append(join(space(), entries)); + builder.append(join(JoinConfiguration.separator(space()), entries)); } })) ); @@ -3615,7 +3617,7 @@ public interface Message { .append(FULL_STOP) ); - Args2 TRACK_INFO = (name, path) -> join(newline(), + Args2 TRACK_INFO = (name, path) -> joinNewline( // "&b&l> &bShowing Track: &f{}" + "\n" + // "&f- &7Path: &f{}", prefixed(text() @@ -3721,7 +3723,7 @@ public interface Message { .append(FULL_STOP) ); - Args2 LOG_ENTRY = (pos, action) -> join(newline(), + Args2 LOG_ENTRY = (pos, action) -> joinNewline( // "&b#{} &8(&7{} ago&8) &8(&e{}&8) [&a{}&8] (&b{}&8)" // "&7> &f{}" prefixed(text() @@ -3982,7 +3984,7 @@ public interface Message { .append(FULL_STOP) ); - Args2 EXPORT_WEB_SUCCESS = (pasteId, label) -> join(newline(), + Args2 EXPORT_WEB_SUCCESS = (pasteId, label) -> joinNewline( // "&aExport code: &7{}" // "&7Use the following command to import:" // "&a/{} import {} --upload" @@ -3995,7 +3997,8 @@ public interface Message { .key("luckperms.command.export.web.import-command-description") .color(GRAY) .append(text(":")), - text("/" + label + " import " + pasteId + " --upload", GREEN)); + text("/" + label + " import " + pasteId + " --upload", GREEN) + ); Args1 IMPORT_FILE_DOESNT_EXIST = file -> prefixed(text() // "&cError: File &4{}&c does not exist." @@ -4150,9 +4153,18 @@ public interface Message { ); static Component formatColoredValue(String value) { - return LegacyComponentSerializer.legacyAmpersand().deserialize(value).toBuilder() - .hoverEvent(HoverEvent.showText(text(value, WHITE))) - .build(); + boolean containsLegacyFormattingCharacter = value.indexOf(LegacyComponentSerializer.AMPERSAND_CHAR) != 1 + || value.indexOf(LegacyComponentSerializer.SECTION_CHAR) != 1; + + HoverEvent hover = HoverEvent.showText(text(value, WHITE)); + + if (containsLegacyFormattingCharacter) { + return LegacyComponentSerializer.legacyAmpersand().deserialize(value).toBuilder() + .hoverEvent(hover) + .build(); + } else { + return MiniMessage.miniMessage().deserialize(value).hoverEvent(hover); + } } static Component formatContextBracketed(String key, String value) { @@ -4320,6 +4332,10 @@ public interface Message { } } + static Component joinNewline(final ComponentLike... components) { + return join(JoinConfiguration.newlines(), components); + } + interface Args0 { Component build(); diff --git a/standalone/app/build.gradle b/standalone/app/build.gradle index aa2ab7bb8..ee7edfdb9 100644 --- a/standalone/app/build.gradle +++ b/standalone/app/build.gradle @@ -36,6 +36,10 @@ dependencies { exclude(module: 'adventure-bom') exclude(module: 'adventure-api') } + api('net.kyori:adventure-text-minimessage:4.14.0') { + exclude(module: 'adventure-bom') + exclude(module: 'adventure-api') + } api('net.kyori:ansi:1.0.1') }