From 4811129ab1ee3398081fb6ba0a902ae5cbb320c0 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 14 Oct 2020 12:26:09 +0100 Subject: [PATCH] Convert to text components and implement new translation system --- .../types/InheritanceOriginMetadata.java | 13 + bukkit/build.gradle | 4 +- .../luckperms/bukkit/BukkitSenderFactory.java | 49 +- .../luckperms/bukkit/LPBukkitPlugin.java | 3 +- .../listeners/BukkitConnectionListener.java | 21 +- .../listeners/BukkitPlatformListener.java | 4 +- .../migration/MigrationBPermissions.java | 9 +- .../migration/MigrationGroupManager.java | 9 +- .../migration/MigrationPermissionsBukkit.java | 9 +- .../migration/MigrationPermissionsEx.java | 9 +- .../migration/MigrationPowerfulPerms.java | 9 +- .../migration/MigrationZPermissions.java | 9 +- bungee/build.gradle | 4 +- .../luckperms/bungee/BungeeSenderFactory.java | 21 +- .../luckperms/bungee/LPBungeePlugin.java | 3 +- .../listeners/BungeeConnectionListener.java | 15 +- .../migration/MigrationBungeePerms.java | 9 +- common/build.gradle | 9 +- .../common/actionlog/LogDispatcher.java | 9 +- .../luckperms/common/backup/Exporter.java | 12 +- .../luckperms/common/backup/Importer.java | 4 +- .../common/command/CommandManager.java | 105 +- .../command/abstraction/ChildCommand.java | 36 +- .../common/command/abstraction/Command.java | 14 +- .../abstraction/GenericChildCommand.java | 41 +- .../abstraction/GenericParentCommand.java | 6 +- .../command/abstraction/ParentCommand.java | 6 +- .../command/abstraction/SingleCommand.java | 36 +- .../command => command/spec}/Argument.java | 31 +- .../common/command/spec/CommandSpec.java | 477 +++ .../command/utils/ArgumentException.java | 2 +- .../common/command/utils/MessageUtils.java | 162 - .../command/utils/StorageAssistant.java | 2 +- .../commands/generic/meta/CommandMeta.java | 43 +- .../generic/meta/MetaAddChatMeta.java | 30 +- .../generic/meta/MetaAddTempChatMeta.java | 31 +- .../commands/generic/meta/MetaClear.java | 16 +- .../commands/generic/meta/MetaInfo.java | 123 +- .../generic/meta/MetaRemoveChatMeta.java | 32 +- .../generic/meta/MetaRemoveTempChatMeta.java | 32 +- .../common/commands/generic/meta/MetaSet.java | 23 +- .../generic/meta/MetaSetChatMeta.java | 30 +- .../commands/generic/meta/MetaSetTemp.java | 24 +- .../generic/meta/MetaSetTempChatMeta.java | 31 +- .../commands/generic/meta/MetaUnset.java | 14 +- .../commands/generic/meta/MetaUnsetTemp.java | 14 +- .../commands/generic/other/HolderClear.java | 16 +- .../commands/generic/other/HolderEditor.java | 9 +- .../generic/other/HolderShowTracks.java | 29 +- .../generic/parent/CommandParent.java | 27 +- .../commands/generic/parent/ParentAdd.java | 14 +- .../generic/parent/ParentAddTemp.java | 17 +- .../commands/generic/parent/ParentClear.java | 16 +- .../generic/parent/ParentClearTrack.java | 17 +- .../commands/generic/parent/ParentInfo.java | 45 +- .../commands/generic/parent/ParentRemove.java | 14 +- .../generic/parent/ParentRemoveTemp.java | 23 +- .../commands/generic/parent/ParentSet.java | 12 +- .../generic/parent/ParentSetTrack.java | 14 +- .../parent/UserSwitchPrimaryGroup.java | 9 +- .../generic/permission/CommandPermission.java | 23 +- .../generic/permission/PermissionCheck.java | 14 +- .../permission/PermissionCheckInherits.java | 14 +- .../generic/permission/PermissionClear.java | 16 +- .../generic/permission/PermissionInfo.java | 45 +- .../generic/permission/PermissionSet.java | 14 +- .../generic/permission/PermissionSetTemp.java | 15 +- .../generic/permission/PermissionUnset.java | 14 +- .../permission/PermissionUnsetTemp.java | 24 +- .../common/commands/group/CreateGroup.java | 9 +- .../common/commands/group/DeleteGroup.java | 9 +- .../common/commands/group/GroupClone.java | 9 +- .../common/commands/group/GroupInfo.java | 48 +- .../commands/group/GroupListMembers.java | 50 +- .../commands/group/GroupParentCommand.java | 31 +- .../common/commands/group/GroupRename.java | 9 +- .../commands/group/GroupSetDisplayName.java | 14 +- .../common/commands/group/GroupSetWeight.java | 9 +- .../common/commands/group/ListGroups.java | 38 +- .../common/commands/log/LogGroupHistory.java | 19 +- .../common/commands/log/LogNotify.java | 9 +- .../common/commands/log/LogParentCommand.java | 21 +- .../common/commands/log/LogRecent.java | 19 +- .../common/commands/log/LogSearch.java | 19 +- .../common/commands/log/LogTrackHistory.java | 19 +- .../common/commands/log/LogUserHistory.java | 19 +- .../migration/MigrationParentCommand.java | 15 +- .../commands/misc/ApplyEditsCommand.java | 9 +- .../commands/misc/BulkUpdateCommand.java | 9 +- .../common/commands/misc/CheckCommand.java | 12 +- .../common/commands/misc/EditorCommand.java | 9 +- .../common/commands/misc/ExportCommand.java | 15 +- .../common/commands/misc/ImportCommand.java | 15 +- .../common/commands/misc/InfoCommand.java | 66 +- .../commands/misc/NetworkSyncCommand.java | 9 +- .../commands/misc/ReloadConfigCommand.java | 9 +- .../common/commands/misc/SearchCommand.java | 57 +- .../common/commands/misc/SyncCommand.java | 9 +- .../common/commands/misc/TreeCommand.java | 25 +- .../common/commands/misc/VerboseCommand.java | 25 +- .../common/commands/track/CreateTrack.java | 9 +- .../common/commands/track/DeleteTrack.java | 9 +- .../common/commands/track/ListTracks.java | 12 +- .../common/commands/track/TrackAppend.java | 12 +- .../common/commands/track/TrackClear.java | 9 +- .../common/commands/track/TrackClone.java | 9 +- .../common/commands/track/TrackInfo.java | 12 +- .../common/commands/track/TrackInsert.java | 12 +- .../commands/track/TrackParentCommand.java | 21 +- .../common/commands/track/TrackRemove.java | 12 +- .../common/commands/track/TrackRename.java | 9 +- .../common/commands/user/UserClone.java | 9 +- .../common/commands/user/UserDemote.java | 14 +- .../common/commands/user/UserInfo.java | 59 +- .../commands/user/UserParentCommand.java | 29 +- .../common/commands/user/UserPromote.java | 16 +- .../common/dependencies/Dependency.java | 67 +- .../common/locale/LocaleManager.java | 153 - .../luckperms/common/locale/Message.java | 3789 +++++++++++++++++ .../common/locale/TranslationManager.java | 121 + .../common/locale/command/CommandSpec.java | 668 --- .../locale/command/CommandSpecData.java | 82 - .../locale/command/LocalizedCommandSpec.java | 93 - .../common/locale/message/Message.java | 611 --- .../plugin/AbstractLuckPermsPlugin.java | 41 +- .../common/plugin/LuckPermsPlugin.java | 6 +- .../common/sender/AbstractSender.java | 70 +- .../luckperms/common/sender/DummySender.java | 14 - .../lucko/luckperms/common/sender/Sender.java | 12 +- .../common/sender/SenderFactory.java | 11 +- .../luckperms/common/util/ProgressLogger.java | 36 +- .../luckperms/common/util/TextUtils.java | 74 - .../common/verbose/VerboseListener.java | 80 +- .../common/webeditor/WebEditorRequest.java | 17 +- .../common/webeditor/WebEditorResponse.java | 29 +- .../main/resources/luckperms_en.properties | 589 +++ nukkit/build.gradle | 2 +- .../luckperms/nukkit/NukkitSenderFactory.java | 42 +- .../listeners/NukkitConnectionListener.java | 17 +- .../listeners/NukkitPlatformListener.java | 4 +- sponge/build.gradle | 4 +- .../luckperms/sponge/LPSpongePlugin.java | 9 +- .../luckperms/sponge/SpongeSenderFactory.java | 22 +- .../sponge/commands/OptionClear.java | 12 +- .../luckperms/sponge/commands/OptionInfo.java | 20 +- .../luckperms/sponge/commands/OptionSet.java | 12 +- .../sponge/commands/OptionUnset.java | 12 +- .../luckperms/sponge/commands/ParentAdd.java | 18 +- .../sponge/commands/ParentClear.java | 12 +- .../luckperms/sponge/commands/ParentInfo.java | 20 +- .../sponge/commands/ParentRemove.java | 18 +- .../sponge/commands/PermissionClear.java | 12 +- .../sponge/commands/PermissionInfo.java | 20 +- .../sponge/commands/PermissionSet.java | 12 +- .../sponge/commands/SpongeCommandUtils.java | 41 +- .../sponge/commands/SpongeParentCommand.java | 53 +- .../listeners/SpongeConnectionListener.java | 16 +- .../listeners/SpongePlatformListener.java | 2 +- velocity/build.gradle | 6 +- .../luckperms/velocity/LPVelocityPlugin.java | 4 +- .../velocity/VelocitySenderFactory.java | 20 +- .../listeners/VelocityConnectionListener.java | 13 +- 162 files changed, 6181 insertions(+), 3729 deletions(-) rename common/src/main/java/me/lucko/luckperms/common/{locale/command => command/spec}/Argument.java (67%) create mode 100644 common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/locale/LocaleManager.java create mode 100644 common/src/main/java/me/lucko/luckperms/common/locale/Message.java create mode 100644 common/src/main/java/me/lucko/luckperms/common/locale/TranslationManager.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpec.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpecData.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/locale/command/LocalizedCommandSpec.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/util/TextUtils.java create mode 100644 common/src/main/resources/luckperms_en.properties diff --git a/api/src/main/java/net/luckperms/api/node/metadata/types/InheritanceOriginMetadata.java b/api/src/main/java/net/luckperms/api/node/metadata/types/InheritanceOriginMetadata.java index 89983cbca..a25b223f6 100644 --- a/api/src/main/java/net/luckperms/api/node/metadata/types/InheritanceOriginMetadata.java +++ b/api/src/main/java/net/luckperms/api/node/metadata/types/InheritanceOriginMetadata.java @@ -54,4 +54,17 @@ public interface InheritanceOriginMetadata { */ PermissionHolder.@NonNull Identifier getOrigin(); + /** + * Gets whether the associated node was inherited from another holder. + * + *

In other terms, it returns whether the origin is not equal to the given holder.

+ * + * @param holder the holder defining the node + * @return if true the node was inherited, false if it was defined by the same holder + * @since 5.3 + */ + default boolean wasInherited(PermissionHolder.@NonNull Identifier holder) { + return !holder.equals(getOrigin()); + } + } diff --git a/bukkit/build.gradle b/bukkit/build.gradle index 4f7c630a9..617c47a76 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -11,7 +11,7 @@ dependencies { compile project(':common') compileOnly 'com.destroystokyo.paper:paper-api:1.15.2-R0.1-SNAPSHOT' - compileOnly 'net.kyori:text-adapter-bukkit:3.0.5' + compileOnly 'me.lucko:adventure-platform-bukkit:4.0.0' compileOnly 'me.lucko:commodore:1.7' compileOnly('net.milkbowl.vault:VaultAPI:1.6') { exclude(module: 'bukkit') @@ -50,7 +50,7 @@ shadowJar { include(dependency('me.lucko.luckperms:.*')) } - relocate 'net.kyori.text', 'me.lucko.luckperms.lib.text' + relocate 'net.kyori.adventure', 'me.lucko.luckperms.lib.adventure' relocate 'net.kyori.event', 'me.lucko.luckperms.lib.eventbus' relocate 'com.github.benmanes.caffeine', 'me.lucko.luckperms.lib.caffeine' relocate 'okio', 'me.lucko.luckperms.lib.okio' diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java index 65612dbbb..42fa90ee3 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java @@ -27,10 +27,9 @@ package me.lucko.luckperms.bukkit; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.sender.SenderFactory; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.Component; -import net.kyori.text.adapter.bukkit.TextAdapter; +import net.kyori.adventure.platform.bukkit.BukkitAudiences; +import net.kyori.adventure.text.Component; import net.luckperms.api.util.Tristate; import org.bukkit.command.CommandSender; @@ -41,8 +40,11 @@ import org.bukkit.entity.Player; import java.util.UUID; public class BukkitSenderFactory extends SenderFactory { + private final BukkitAudiences audiences; + public BukkitSenderFactory(LPBukkitPlugin plugin) { super(plugin); + this.audiences = BukkitAudiences.create(plugin.getBootstrap()); } @Override @@ -61,27 +63,14 @@ public class BukkitSenderFactory extends SenderFactory sendMessage(sender, message)); } - - // Fallback to legacy format - sendMessage(sender, TextUtils.toLegacy(message)); } @Override @@ -105,19 +94,9 @@ public class BukkitSenderFactory extends SenderFactory getGlobalDependencies() { Set dependencies = super.getGlobalDependencies(); - dependencies.add(Dependency.TEXT_ADAPTER_BUKKIT); + dependencies.add(Dependency.ADVENTURE_PLATFORM); + dependencies.add(Dependency.ADVENTURE_PLATFORM_BUKKIT); if (isBrigadierSupported()) { dependencies.add(Dependency.COMMODORE); } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java index 287d41f0f..4e67fa927 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java @@ -29,10 +29,15 @@ import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.bukkit.inject.permissible.LuckPermsPermissible; import me.lucko.luckperms.bukkit.inject.permissible.PermissibleInjector; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.TranslationManager; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import net.kyori.adventure.translation.GlobalTranslator; + import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -122,7 +127,9 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme // deny the connection this.deniedAsyncLogin.add(e.getUniqueId()); - e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager())); + + Component reason = GlobalTranslator.render(Message.LOADING_DATABASE_ERROR.build(), TranslationManager.DEFAULT_LOCALE); + e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, LegacyComponentSerializer.legacySection().serialize(reason)); this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(e.getUniqueId(), e.getName(), null); } } @@ -169,7 +176,9 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme if (this.detectedCraftBukkitOfflineMode) { printCraftBukkitOfflineModeError(); - e.disallow(PlayerLoginEvent.Result.KICK_OTHER, Message.LOADING_STATE_ERROR_CB_OFFLINE_MODE.asString(this.plugin.getLocaleManager())); + + Component reason = GlobalTranslator.render(Message.LOADING_STATE_ERROR_CB_OFFLINE_MODE.build(), TranslationManager.parseLocale(player.getLocale(), TranslationManager.DEFAULT_LOCALE)); + e.disallow(PlayerLoginEvent.Result.KICK_OTHER, LegacyComponentSerializer.legacySection().serialize(reason)); return; } @@ -179,7 +188,8 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme " - denying login."); } - e.disallow(PlayerLoginEvent.Result.KICK_OTHER, Message.LOADING_STATE_ERROR.asString(this.plugin.getLocaleManager())); + Component reason = GlobalTranslator.render(Message.LOADING_STATE_ERROR.build(), TranslationManager.parseLocale(player.getLocale(), TranslationManager.DEFAULT_LOCALE)); + e.disallow(PlayerLoginEvent.Result.KICK_OTHER, LegacyComponentSerializer.legacySection().serialize(reason)); return; } @@ -197,7 +207,8 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme player.getUniqueId() + " - " + player.getName() + " - denying login."); t.printStackTrace(); - e.disallow(PlayerLoginEvent.Result.KICK_OTHER, Message.LOADING_SETUP_ERROR.asString(this.plugin.getLocaleManager())); + Component reason = GlobalTranslator.render(Message.LOADING_SETUP_ERROR.build(), TranslationManager.parseLocale(player.getLocale(), TranslationManager.DEFAULT_LOCALE)); + e.disallow(PlayerLoginEvent.Result.KICK_OTHER, LegacyComponentSerializer.legacySection().serialize(reason)); return; } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitPlatformListener.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitPlatformListener.java index 932229b66..94a7501cf 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitPlatformListener.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitPlatformListener.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.bukkit.listeners; import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import org.bukkit.command.CommandSender; import org.bukkit.event.Cancellable; @@ -75,7 +75,7 @@ public class BukkitPlatformListener implements Listener { if (OP_COMMAND_PATTERN.matcher(cmdLine).matches()) { event.setCancelled(true); - sender.sendMessage(Message.OP_DISABLED.asString(this.plugin.getLocaleManager())); + Message.OP_DISABLED.send(this.plugin.getSenderFactory().wrap(sender)); } } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java index 936781948..1188e3179 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java @@ -34,11 +34,10 @@ import de.bananaco.bpermissions.api.WorldManager; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.commands.migration.MigrationUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; @@ -78,8 +77,8 @@ public class MigrationBPermissions extends ChildCommand { } } - public MigrationBPermissions(LocaleManager locale) { - super(CommandSpec.MIGRATION_COMMAND.localize(locale), "bpermissions", CommandPermission.MIGRATION, Predicates.alwaysFalse()); + public MigrationBPermissions() { + super(CommandSpec.MIGRATION_COMMAND, "bpermissions", CommandPermission.MIGRATION, Predicates.alwaysFalse()); } @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java index a832a01a0..8ceddfcc8 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java @@ -28,11 +28,10 @@ package me.lucko.luckperms.bukkit.migration; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.commands.migration.MigrationUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.model.UserIdentifier; @@ -70,8 +69,8 @@ import java.util.function.Function; import java.util.stream.Collectors; public class MigrationGroupManager extends ChildCommand { - public MigrationGroupManager(LocaleManager locale) { - super(CommandSpec.MIGRATION_GROUPMANAGER.localize(locale), "groupmanager", CommandPermission.MIGRATION, Predicates.is(0)); + public MigrationGroupManager() { + super(CommandSpec.MIGRATION_GROUPMANAGER, "groupmanager", CommandPermission.MIGRATION, Predicates.is(0)); } @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsBukkit.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsBukkit.java index 164448087..d2d0407a5 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsBukkit.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsBukkit.java @@ -30,11 +30,10 @@ import com.platymuus.bukkit.permissions.PermissionsPlugin; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.commands.migration.MigrationUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; @@ -58,8 +57,8 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; public class MigrationPermissionsBukkit extends ChildCommand { - public MigrationPermissionsBukkit(LocaleManager locale) { - super(CommandSpec.MIGRATION_COMMAND.localize(locale), "permissionsbukkit", CommandPermission.MIGRATION, Predicates.alwaysFalse()); + public MigrationPermissionsBukkit() { + super(CommandSpec.MIGRATION_COMMAND, "permissionsbukkit", CommandPermission.MIGRATION, Predicates.alwaysFalse()); } @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java index b480b362d..8bb92afa7 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java @@ -30,11 +30,10 @@ import com.google.common.base.Strings; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.commands.migration.MigrationUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; @@ -103,8 +102,8 @@ public class MigrationPermissionsEx extends ChildCommand { } } - public MigrationPermissionsEx(LocaleManager locale) { - super(CommandSpec.MIGRATION_COMMAND.localize(locale), "permissionsex", CommandPermission.MIGRATION, Predicates.alwaysFalse()); + public MigrationPermissionsEx() { + super(CommandSpec.MIGRATION_COMMAND, "permissionsex", CommandPermission.MIGRATION, Predicates.alwaysFalse()); } @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java index 28270a64f..c17bce1af 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java @@ -36,12 +36,11 @@ import com.zaxxer.hikari.HikariDataSource; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.commands.migration.MigrationUtils; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.model.manager.group.GroupManager; @@ -80,8 +79,8 @@ import java.util.concurrent.atomic.AtomicInteger; // Only supports the latest versions of the PP API. (it seems to change randomly almost every release) public class MigrationPowerfulPerms extends ChildCommand { - public MigrationPowerfulPerms(LocaleManager locale) { - super(CommandSpec.MIGRATION_POWERFULPERMS.localize(locale), "powerfulperms", CommandPermission.MIGRATION, Predicates.not(5)); + public MigrationPowerfulPerms() { + super(CommandSpec.MIGRATION_POWERFULPERMS, "powerfulperms", CommandPermission.MIGRATION, Predicates.not(5)); } @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java index 87ef7e119..b5a130cf8 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java @@ -28,11 +28,10 @@ package me.lucko.luckperms.bukkit.migration; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.commands.migration.MigrationUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; @@ -70,8 +69,8 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; public class MigrationZPermissions extends ChildCommand { - public MigrationZPermissions(LocaleManager locale) { - super(CommandSpec.MIGRATION_COMMAND.localize(locale), "zpermissions", CommandPermission.MIGRATION, Predicates.alwaysFalse()); + public MigrationZPermissions() { + super(CommandSpec.MIGRATION_COMMAND, "zpermissions", CommandPermission.MIGRATION, Predicates.alwaysFalse()); } @Override diff --git a/bungee/build.gradle b/bungee/build.gradle index 63818c5d7..c23251584 100644 --- a/bungee/build.gradle +++ b/bungee/build.gradle @@ -6,7 +6,7 @@ dependencies { compile project(':common') compileOnly 'net.md-5:bungeecord-api:1.15-SNAPSHOT' - compileOnly 'net.kyori:text-adapter-bungeecord:3.0.4' + compileOnly 'me.lucko:adventure-platform-bungeecord:4.0.0' compileOnly 'com.imaginarycode.minecraft:RedisBungee:0.4' // migration plugins @@ -36,7 +36,7 @@ shadowJar { include(dependency('me.lucko.luckperms:.*')) } - relocate 'net.kyori.text', 'me.lucko.luckperms.lib.text' + relocate 'net.kyori.adventure', 'me.lucko.luckperms.lib.adventure' relocate 'net.kyori.event', 'me.lucko.luckperms.lib.eventbus' relocate 'com.github.benmanes.caffeine', 'me.lucko.luckperms.lib.caffeine' relocate 'okio', 'me.lucko.luckperms.lib.okio' diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java index 877b7fdd2..e5090dc86 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java @@ -28,10 +28,9 @@ package me.lucko.luckperms.bungee; import me.lucko.luckperms.bungee.event.TristateCheckEvent; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.sender.SenderFactory; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.Component; -import net.kyori.text.adapter.bungeecord.TextAdapter; +import net.kyori.adventure.platform.bungeecord.BungeeAudiences; +import net.kyori.adventure.text.Component; import net.luckperms.api.util.Tristate; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -39,8 +38,11 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import java.util.UUID; public class BungeeSenderFactory extends SenderFactory { + private final BungeeAudiences audiences; + public BungeeSenderFactory(LPBungeePlugin plugin) { super(plugin); + this.audiences = BungeeAudiences.create(plugin.getBootstrap()); } @Override @@ -59,14 +61,9 @@ public class BungeeSenderFactory extends SenderFactory getGlobalDependencies() { Set dependencies = super.getGlobalDependencies(); - dependencies.add(Dependency.TEXT_ADAPTER_BUNGEECORD); + dependencies.add(Dependency.ADVENTURE_PLATFORM); + dependencies.add(Dependency.ADVENTURE_PLATFORM_BUNGEECORD); return dependencies; } diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java b/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java index 1282aa692..c476d653a 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java @@ -27,11 +27,14 @@ package me.lucko.luckperms.bungee.listeners; import me.lucko.luckperms.bungee.LPBungeePlugin; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.TranslationManager; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener; -import net.md_5.bungee.api.chat.TextComponent; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer; +import net.kyori.adventure.translation.GlobalTranslator; import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.LoginEvent; @@ -97,7 +100,8 @@ public class BungeeConnectionListener extends AbstractConnectionListener impleme // there was some error loading if (this.plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) { // cancel the login attempt - e.setCancelReason(TextComponent.fromLegacyText(Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager()))); + Component reason = GlobalTranslator.render(Message.LOADING_DATABASE_ERROR.build(), TranslationManager.DEFAULT_LOCALE); + e.setCancelReason(BungeeComponentSerializer.get().serialize(reason)); e.setCancelled(true); } this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(c.getUniqueId(), c.getName(), null); @@ -128,7 +132,8 @@ public class BungeeConnectionListener extends AbstractConnectionListener impleme if (this.plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) { // disconnect the user - e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.LOADING_STATE_ERROR.asString(this.plugin.getLocaleManager()))); + Component reason = GlobalTranslator.render(Message.LOADING_DATABASE_ERROR.build(), player.getLocale()); + e.getPlayer().disconnect(BungeeComponentSerializer.get().serialize(reason)); } else { // just send a message this.plugin.getBootstrap().getProxy().getScheduler().schedule(this.plugin.getBootstrap(), () -> { @@ -136,7 +141,7 @@ public class BungeeConnectionListener extends AbstractConnectionListener impleme return; } - player.sendMessage(TextComponent.fromLegacyText(Message.LOADING_STATE_ERROR.asString(this.plugin.getLocaleManager()))); + Message.LOADING_STATE_ERROR.send(this.plugin.getSenderFactory().wrap(player)); }, 1, TimeUnit.SECONDS); } } diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java b/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java index 41fc8fe38..11ddd4273 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java @@ -28,11 +28,10 @@ package me.lucko.luckperms.bungee.migration; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.commands.migration.MigrationUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.types.Inheritance; import me.lucko.luckperms.common.node.types.Prefix; @@ -57,8 +56,8 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; public class MigrationBungeePerms extends ChildCommand { - public MigrationBungeePerms(LocaleManager locale) { - super(CommandSpec.MIGRATION_COMMAND.localize(locale), "bungeeperms", CommandPermission.MIGRATION, Predicates.alwaysFalse()); + public MigrationBungeePerms() { + super(CommandSpec.MIGRATION_COMMAND, "bungeeperms", CommandPermission.MIGRATION, Predicates.alwaysFalse()); } @Override diff --git a/common/build.gradle b/common/build.gradle index 92680860f..33d2551bf 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -2,16 +2,9 @@ dependencies { compile project(':api') compile 'org.checkerframework:checker-qual:2.5.5' - compile('net.kyori:text-api:3.0.4') { + compile('me.lucko:adventure-api:4.0.0') { exclude(module: 'checker-qual') } - compile('net.kyori:text-serializer-legacy:3.0.4') { - exclude(module: 'text-api') - } - compile('net.kyori:text-serializer-gson:3.0.4') { - exclude(module: 'text-api') - exclude(module: 'gson') - } compile('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/actionlog/LogDispatcher.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/LogDispatcher.java index 07a368d02..2ef4d526f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/actionlog/LogDispatcher.java +++ b/common/src/main/java/me/lucko/luckperms/common/actionlog/LogDispatcher.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.actionlog; import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.commands.log.LogNotify; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -72,12 +72,7 @@ public class LogDispatcher { boolean shouldCancel = LogNotify.isIgnoring(this.plugin, s.getUniqueId()) || (sender != null && s.getUniqueId().equals(sender.getUniqueId())); return !this.plugin.getEventDispatcher().dispatchLogNotify(shouldCancel, entry, origin, s); }) - .forEach(s -> Message.LOG.send(s, - entry.getSourceFriendlyString(), - Character.toString(LoggedAction.getTypeCharacter(entry.getTarget().getType())), - entry.getTargetFriendlyString(), - entry.getDescription() - )); + .forEach(s -> Message.LOG.send(s, entry)); } public void dispatch(LoggedAction entry, Sender sender) { diff --git a/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java b/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java index b2376626e..e3cb5d7e0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java +++ b/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java @@ -29,7 +29,7 @@ import com.google.gson.JsonObject; import me.lucko.luckperms.common.http.AbstractHttpClient; import me.lucko.luckperms.common.http.UnsuccessfulRequestException; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; @@ -90,7 +90,7 @@ public abstract class Exporter implements Runnable { this.includeUsers = includeUsers; this.includeGroups = includeGroups; - this.log = new ProgressLogger(Message.EXPORT_LOG, Message.EXPORT_LOG_PROGRESS, null); + this.log = new ProgressLogger(Message.EXPORT_LOG, Message.EXPORT_LOG_PROGRESS); this.log.addListener(plugin.getConsoleSender()); this.log.addListener(executor); } @@ -238,7 +238,7 @@ public abstract class Exporter implements Runnable { e.printStackTrace(); } - this.log.getListeners().forEach(l -> Message.LOG_EXPORT_SUCCESS.send(l, this.filePath.toFile().getAbsolutePath())); + this.log.getListeners().forEach(l -> Message.EXPORT_FILE_SUCCESS.send(l, this.filePath.toFile().getAbsolutePath())); } } @@ -263,12 +263,12 @@ public abstract class Exporter implements Runnable { try { String pasteId = this.plugin.getBytebin().postContent(bytesOut.toByteArray(), AbstractHttpClient.JSON_TYPE, false).key(); - this.log.getListeners().forEach(l -> Message.EXPORT_CODE.send(l, pasteId, this.label, pasteId)); + this.log.getListeners().forEach(l -> Message.EXPORT_WEB_SUCCESS.send(l, pasteId, this.label)); } catch (UnsuccessfulRequestException e) { - this.log.getListeners().forEach(l -> Message.EXPORT_HTTP_REQUEST_FAILURE.send(l, e.getResponse().code(), e.getResponse().message())); + this.log.getListeners().forEach(l -> Message.HTTP_REQUEST_FAILURE.send(l, e.getResponse().code(), e.getResponse().message())); } catch (IOException e) { new RuntimeException("Error uploading data to bytebin", e).printStackTrace(); - this.log.getListeners().forEach(Message.EXPORT_HTTP_UNKNOWN_FAILURE::send); + this.log.getListeners().forEach(Message.HTTP_UNKNOWN_FAILURE::send); } } } diff --git a/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java b/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java index efafe9cb9..d80dee173 100644 --- a/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java +++ b/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java @@ -31,7 +31,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; @@ -242,7 +242,7 @@ public class Importer implements Runnable { private void sendProgress(int processedCount, int total) { int percent = (processedCount * 100) / total; - this.notify.forEach(s -> Message.IMPORT_PROGRESS.send(s, percent, processedCount, total, 0)); + this.notify.forEach(s -> Message.IMPORT_PROGRESS.send(s, percent, processedCount, total)); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java index 112d9beba..6a4ea1b6e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java @@ -29,7 +29,6 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.command.abstraction.Command; import me.lucko.luckperms.common.command.abstraction.CommandException; -import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.command.tabcomplete.CompletionSupplier; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; @@ -58,18 +57,16 @@ import me.lucko.luckperms.common.commands.track.DeleteTrack; import me.lucko.luckperms.common.commands.track.ListTracks; import me.lucko.luckperms.common.commands.track.TrackParentCommand; import me.lucko.luckperms.common.commands.user.UserParentCommand; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.ImmutableCollectors; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.TextComponent; -import net.kyori.text.event.ClickEvent; -import net.kyori.text.event.HoverEvent; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.event.ClickEvent; +import net.kyori.adventure.text.format.NamedTextColor; import java.util.Collection; import java.util.Collections; @@ -97,35 +94,33 @@ public class CommandManager { public CommandManager(LuckPermsPlugin plugin) { this.plugin = plugin; - LocaleManager locale = plugin.getLocaleManager(); - this.tabCompletions = new TabCompletions(plugin); this.mainCommands = ImmutableList.>builder() - .add(new UserParentCommand(locale)) - .add(new GroupParentCommand(locale)) - .add(new TrackParentCommand(locale)) + .add(new UserParentCommand()) + .add(new GroupParentCommand()) + .add(new TrackParentCommand()) .addAll(plugin.getExtraCommands()) - .add(new LogParentCommand(locale)) - .add(new SyncCommand(locale)) - .add(new InfoCommand(locale)) - .add(new EditorCommand(locale)) - .add(new VerboseCommand(locale)) - .add(new TreeCommand(locale)) - .add(new SearchCommand(locale)) - .add(new CheckCommand(locale)) - .add(new NetworkSyncCommand(locale)) - .add(new ImportCommand(locale)) - .add(new ExportCommand(locale)) - .add(new ReloadConfigCommand(locale)) - .add(new BulkUpdateCommand(locale)) - .add(new MigrationParentCommand(locale)) - .add(new ApplyEditsCommand(locale)) - .add(new CreateGroup(locale)) - .add(new DeleteGroup(locale)) - .add(new ListGroups(locale)) - .add(new CreateTrack(locale)) - .add(new DeleteTrack(locale)) - .add(new ListTracks(locale)) + .add(new LogParentCommand()) + .add(new SyncCommand()) + .add(new InfoCommand()) + .add(new EditorCommand()) + .add(new VerboseCommand()) + .add(new TreeCommand()) + .add(new SearchCommand()) + .add(new CheckCommand()) + .add(new NetworkSyncCommand()) + .add(new ImportCommand()) + .add(new ExportCommand()) + .add(new ReloadConfigCommand()) + .add(new BulkUpdateCommand()) + .add(new MigrationParentCommand()) + .add(new ApplyEditsCommand()) + .add(new CreateGroup()) + .add(new DeleteGroup()) + .add(new ListGroups()) + .add(new CreateTrack()) + .add(new DeleteTrack()) + .add(new ListTracks()) .build() .stream() .collect(ImmutableCollectors.toMap(c -> c.getName().toLowerCase(), Function.identity())); @@ -160,7 +155,15 @@ public class CommandManager { // Handle no arguments if (arguments.isEmpty() || (arguments.size() == 1 && arguments.get(0).trim().isEmpty())) { - Message.BLANK.send(sender, "&2Running &b" + AbstractLuckPermsPlugin.getPluginName() + " v" + this.plugin.getBootstrap().getVersion() + "&2."); + sender.sendMessage(Message.prefixed(Component.text() + .color(NamedTextColor.DARK_GREEN) + .append(Component.text("Running ")) + .append(Component.text(AbstractLuckPermsPlugin.getPluginName(), NamedTextColor.AQUA)) + .append(Component.space()) + .append(Component.text("v" + this.plugin.getBootstrap().getVersion(), NamedTextColor.AQUA)) + .append(Message.FULL_STOP) + )); + if (hasPermissionForAny(sender)) { Message.VIEW_AVAILABLE_COMMANDS_PROMPT.send(sender, label); return CommandResult.SUCCESS; @@ -232,27 +235,25 @@ public class CommandManager { } private void sendCommandUsage(Sender sender, String label) { - Message.BLANK.send(sender, "&2Running &b" + AbstractLuckPermsPlugin.getPluginName() + " v" + this.plugin.getBootstrap().getVersion() + "&2."); + sender.sendMessage(Message.prefixed(Component.text() + .color(NamedTextColor.DARK_GREEN) + .append(Component.text("Running ")) + .append(Component.text(AbstractLuckPermsPlugin.getPluginName(), NamedTextColor.AQUA)) + .append(Component.space()) + .append(Component.text("v" + this.plugin.getBootstrap().getVersion(), NamedTextColor.AQUA)) + .append(Message.FULL_STOP) + )); + this.mainCommands.values().stream() .filter(Command::shouldDisplay) .filter(c -> c.isAuthorized(sender)) - .forEach(c -> { - String permission = c.getPermission().map(CommandPermission::getPermission).orElse("None"); - - TextComponent component = TextUtils.fromLegacy("&3> &a" + String.format(c.getUsage(), label), TextUtils.AMPERSAND_CHAR) - .toBuilder().applyDeep(comp -> { - comp.hoverEvent(HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( - "&bCommand: &2" + c.getName(), - "&bDescription: &2" + c.getDescription(), - "&bUsage: &2" + String.format(c.getUsage(), label), - "&bPermission: &2" + permission, - " ", - "&7Click to auto-complete." - ), TextUtils.AMPERSAND_CHAR))); - comp.clickEvent(ClickEvent.suggestCommand(String.format(c.getUsage(), label))); - }).build(); - sender.sendMessage(component); - }); + .forEach(c -> sender.sendMessage(Component.text() + .append(Component.text('>', NamedTextColor.DARK_AQUA)) + .append(Component.space()) + .append(Component.text(String.format(c.getUsage(), label), NamedTextColor.GREEN)) + .clickEvent(ClickEvent.suggestCommand(String.format(c.getUsage(), label))) + .build() + )); } /** diff --git a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/ChildCommand.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/ChildCommand.java index 7aff2d6b6..a3f6cc67e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/ChildCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/ChildCommand.java @@ -26,19 +26,25 @@ package me.lucko.luckperms.common.command.abstraction; import me.lucko.luckperms.common.command.access.CommandPermission; -import me.lucko.luckperms.common.locale.command.Argument; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.command.spec.Argument; +import me.lucko.luckperms.common.command.spec.CommandSpec; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.sender.Sender; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.format.NamedTextColor; + +import java.util.List; import java.util.function.Predicate; +import java.util.stream.Collectors; /** * Abstract SubCommand class */ public abstract class ChildCommand extends Command { - public ChildCommand(LocalizedCommandSpec spec, String name, CommandPermission permission, Predicate argumentCheck) { + public ChildCommand(CommandSpec spec, String name, CommandPermission permission, Predicate argumentCheck) { super(spec, name, permission, argumentCheck); } @@ -49,25 +55,31 @@ public abstract class ChildCommand extends Command { */ @Override public void sendUsage(Sender sender, String label) { - StringBuilder sb = new StringBuilder(); + TextComponent.Builder builder = Component.text() + .append(Component.text('>', NamedTextColor.DARK_AQUA)) + .append(Component.space()) + .append(Component.text(getName().toLowerCase(), NamedTextColor.GREEN)); + if (getArgs().isPresent()) { - sb.append(Message.COMMAND_USAGE_ARGUMENT_JOIN.asString(sender.getPlugin().getLocaleManager())); - for (Argument arg : getArgs().get()) { - sb.append(arg.asPrettyString(sender.getPlugin().getLocaleManager())).append(" "); - } + List argUsages = getArgs().get().stream() + .map(Argument::asPrettyString) + .collect(Collectors.toList()); + + builder.append(Component.text(" - ", NamedTextColor.DARK_AQUA)) + .append(Component.join(Component.space(), argUsages)) + .build(); } - Message.COMMAND_USAGE_BRIEF.send(sender, getName().toLowerCase(), sb.toString()); + sender.sendMessage(builder.build()); } @Override public void sendDetailedUsage(Sender sender, String label) { Message.COMMAND_USAGE_DETAILED_HEADER.send(sender, getName(), getDescription()); - if (getArgs().isPresent()) { Message.COMMAND_USAGE_DETAILED_ARGS_HEADER.send(sender); for (Argument arg : getArgs().get()) { - Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(sender.getPlugin().getLocaleManager()), arg.getDescription()); + Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(), arg.getDescription()); } } } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/Command.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/Command.java index 86d0fca0b..82724c4da 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/Command.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/Command.java @@ -27,12 +27,14 @@ package me.lucko.luckperms.common.command.abstraction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.Argument; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.command.Argument; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; +import net.kyori.adventure.text.Component; + import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -53,7 +55,7 @@ public abstract class Command { * * Contains details about usage, description, etc */ - private final @NonNull LocalizedCommandSpec spec; + private final @NonNull CommandSpec spec; /** * The name of the command. Should be properly capitalised. @@ -70,7 +72,7 @@ public abstract class Command { */ private final @NonNull Predicate argumentCheck; - public Command(@NonNull LocalizedCommandSpec spec, @NonNull String name, @Nullable CommandPermission permission, @NonNull Predicate argumentCheck) { + public Command(@NonNull CommandSpec spec, @NonNull String name, @Nullable CommandPermission permission, @NonNull Predicate argumentCheck) { this.spec = spec; this.name = name; this.permission = permission; @@ -82,7 +84,7 @@ public abstract class Command { * * @return the command spec */ - public @NonNull LocalizedCommandSpec getSpec() { + public @NonNull CommandSpec getSpec() { return this.spec; } @@ -121,7 +123,7 @@ public abstract class Command { * * @return the description */ - public String getDescription() { + public Component getDescription() { return getSpec().description(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/GenericChildCommand.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/GenericChildCommand.java index 9cacac6ce..7ccfeaf69 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/GenericChildCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/GenericChildCommand.java @@ -27,18 +27,23 @@ package me.lucko.luckperms.common.command.abstraction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.Argument; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.command.Argument; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.format.NamedTextColor; + import java.util.Collections; import java.util.List; import java.util.function.Predicate; +import java.util.stream.Collectors; /** * A sub command which can be be applied to both groups and users. @@ -46,7 +51,7 @@ import java.util.function.Predicate; */ public abstract class GenericChildCommand { - private final LocalizedCommandSpec spec; + private final CommandSpec spec; /** * The name of the sub command @@ -64,7 +69,7 @@ public abstract class GenericChildCommand { */ private final Predicate argumentCheck; - public GenericChildCommand(LocalizedCommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission, Predicate argumentCheck) { + public GenericChildCommand(CommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission, Predicate argumentCheck) { this.spec = spec; this.name = name; this.userPermission = userPermission; @@ -78,7 +83,7 @@ public abstract class GenericChildCommand { return Collections.emptyList(); } - public LocalizedCommandSpec getSpec() { + public CommandSpec getSpec() { return this.spec; } @@ -99,24 +104,30 @@ public abstract class GenericChildCommand { } public void sendUsage(Sender sender) { - StringBuilder sb = new StringBuilder(); + TextComponent.Builder builder = Component.text() + .append(Component.text('>', NamedTextColor.DARK_AQUA)) + .append(Component.space()) + .append(Component.text(getName().toLowerCase(), NamedTextColor.GREEN)); + if (getArgs() != null) { - sb.append(Message.COMMAND_USAGE_ARGUMENT_JOIN.asString(sender.getPlugin().getLocaleManager())); - for (Argument arg : getArgs()) { - sb.append(arg.asPrettyString(sender.getPlugin().getLocaleManager())).append(" "); - } + List argUsages = getArgs().stream() + .map(Argument::asPrettyString) + .collect(Collectors.toList()); + + builder.append(Component.text(" - ", NamedTextColor.DARK_AQUA)) + .append(Component.join(Component.space(), argUsages)) + .build(); } - Message.COMMAND_USAGE_BRIEF.send(sender, getName(), sb.toString()); + sender.sendMessage(builder.build()); } public void sendDetailedUsage(Sender sender) { Message.COMMAND_USAGE_DETAILED_HEADER.send(sender, getName(), getDescription()); - if (getArgs() != null) { Message.COMMAND_USAGE_DETAILED_ARGS_HEADER.send(sender); for (Argument arg : getArgs()) { - Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(sender.getPlugin().getLocaleManager()), arg.getDescription()); + Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(), arg.getDescription()); } } } @@ -132,7 +143,7 @@ public abstract class GenericChildCommand { } } - public String getDescription() { + public Component getDescription() { return this.spec.description(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/GenericParentCommand.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/GenericParentCommand.java index 490097768..7bc8283ec 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/GenericParentCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/GenericParentCommand.java @@ -26,11 +26,11 @@ package me.lucko.luckperms.common.command.abstraction; import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.CompletionSupplier; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -52,7 +52,7 @@ public class GenericParentCommand extends ChildComma private final HolderType type; - public GenericParentCommand(LocalizedCommandSpec spec, String name, HolderType type, List children) { + public GenericParentCommand(CommandSpec spec, String name, HolderType type, List children) { super(spec, name, null, Predicates.alwaysFalse()); this.children = children; this.type = type; diff --git a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/ParentCommand.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/ParentCommand.java index f6ad6e2ad..9cf524224 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/ParentCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/ParentCommand.java @@ -26,11 +26,11 @@ package me.lucko.luckperms.common.command.abstraction; import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.CompletionSupplier; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -49,7 +49,7 @@ public abstract class ParentCommand extends Command { /** The type of parent command */ private final Type type; - public ParentCommand(LocalizedCommandSpec spec, String name, Type type, List> children) { + public ParentCommand(CommandSpec spec, String name, Type type, List> children) { super(spec, name, null, Predicates.alwaysFalse()); this.children = children; this.type = type; diff --git a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SingleCommand.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SingleCommand.java index e89203f81..6513d5001 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SingleCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SingleCommand.java @@ -27,21 +27,27 @@ package me.lucko.luckperms.common.command.abstraction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.Argument; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.command.Argument; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.format.NamedTextColor; + +import java.util.List; import java.util.function.Predicate; +import java.util.stream.Collectors; /** * Represents a single "main" command (one without any children) */ public abstract class SingleCommand extends Command { - public SingleCommand(LocalizedCommandSpec spec, String name, CommandPermission permission, Predicate argumentCheck) { + public SingleCommand(CommandSpec spec, String name, CommandPermission permission, Predicate argumentCheck) { super(spec, name, permission, argumentCheck); } @@ -54,25 +60,31 @@ public abstract class SingleCommand extends Command { @Override public void sendUsage(Sender sender, String label) { - StringBuilder sb = new StringBuilder(); + TextComponent.Builder builder = Component.text() + .append(Component.text('>', NamedTextColor.DARK_AQUA)) + .append(Component.space()) + .append(Component.text(getName().toLowerCase(), NamedTextColor.GREEN)); + if (getArgs().isPresent()) { - sb.append(Message.COMMAND_USAGE_ARGUMENT_JOIN.asString(sender.getPlugin().getLocaleManager())); - for (Argument arg : getArgs().get()) { - sb.append(arg.asPrettyString(sender.getPlugin().getLocaleManager())).append(" "); - } + List argUsages = getArgs().get().stream() + .map(Argument::asPrettyString) + .collect(Collectors.toList()); + + builder.append(Component.text(" - ", NamedTextColor.DARK_AQUA)) + .append(Component.join(Component.space(), argUsages)) + .build(); } - Message.COMMAND_USAGE_BRIEF.send(sender, getName().toLowerCase(), sb.toString()); + sender.sendMessage(builder.build()); } @Override public void sendDetailedUsage(Sender sender, String label) { Message.COMMAND_USAGE_DETAILED_HEADER.send(sender, getName(), getDescription()); - if (getArgs().isPresent()) { Message.COMMAND_USAGE_DETAILED_ARGS_HEADER.send(sender); for (Argument arg : getArgs().get()) { - Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(sender.getPlugin().getLocaleManager()), arg.getDescription()); + Message.COMMAND_USAGE_DETAILED_ARG.send(sender, arg.asPrettyString(), arg.getDescription()); } } } diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/command/Argument.java b/common/src/main/java/me/lucko/luckperms/common/command/spec/Argument.java similarity index 67% rename from common/src/main/java/me/lucko/luckperms/common/locale/command/Argument.java rename to common/src/main/java/me/lucko/luckperms/common/command/spec/Argument.java index 75765c056..f9788a3a6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/command/Argument.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/spec/Argument.java @@ -23,38 +23,23 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.locale.command; +package me.lucko.luckperms.common.command.spec; -import com.google.common.collect.ImmutableList; +import me.lucko.luckperms.common.locale.Message; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.message.Message; - -import org.checkerframework.checker.nullness.qual.Nullable; +import net.kyori.adventure.text.Component; public class Argument { - public static Argument create(String name, boolean required, String description) { - return new Argument(name, required, description); - } - - public static ImmutableList list(Argument... args) { - return ImmutableList.copyOf(args); - } - private final String name; private final boolean required; - private final String description; + private final Component description; - private Argument(String name, boolean required, String description) { + Argument(String name, boolean required, Component description) { this.name = name; this.required = required; this.description = description; } - public String asPrettyString(@Nullable LocaleManager localeManager) { - return (this.required ? Message.REQUIRED_ARGUMENT : Message.OPTIONAL_ARGUMENT).asString(localeManager, this.name); - } - public String getName() { return this.name; } @@ -63,7 +48,11 @@ public class Argument { return this.required; } - public String getDescription() { + public Component getDescription() { return this.description; } + + public Component asPrettyString() { + return (this.required ? Message.REQUIRED_ARGUMENT : Message.OPTIONAL_ARGUMENT).build(this.name); + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java b/common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java new file mode 100644 index 000000000..24b27f0c5 --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java @@ -0,0 +1,477 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.luckperms.common.command.spec; + +import me.lucko.luckperms.common.util.ImmutableCollectors; + +import net.kyori.adventure.text.Component; + +import java.util.Arrays; +import java.util.List; + +/** + * An enumeration of the command defintion/usage messages used in the plugin. + */ +@SuppressWarnings("SpellCheckingInspection") +public enum CommandSpec { + + USER("/%s user "), + GROUP("/%s group "), + TRACK("/%s track "), + LOG("/%s log"), + + SYNC("/%s sync"), + INFO("/%s info"), + EDITOR("/%s editor [type]", + arg("type", false), + arg("filter", false) + ), + DEBUG("/%s debug"), + VERBOSE("/%s verbose [filter]", + arg("action", "on|record|off|upload|command", true), + arg("filter", false), + arg("commandas", " ", false) + ), + TREE("/%s tree [scope] [player]", + arg("scope", false), + arg("player", false) + ), + SEARCH("/%s search ", + arg("permission", true), + arg("page", false) + ), + CHECK("/%s check ", + arg("user", true), + arg("permission", true) + ), + NETWORK_SYNC("/%s networksync"), + IMPORT("/%s import ", + arg("file", true), + arg("replace", "--replace", false) + ), + EXPORT("/%s export ", + arg("file", true), + arg("without-users", "--without-users", false) + ), + RELOAD_CONFIG("/%s reloadconfig"), + BULK_UPDATE("/%s bulkupdate", + arg("data type", true), + arg("action", true), + arg("action field", false), + arg("action value", false), + arg("constraint...", false) + ), + MIGRATION("/%s migration"), + APPLY_EDITS("/%s applyedits [target]", + arg("code", true), + arg("target", false) + ), + + CREATE_GROUP("/%s creategroup ", + arg("name", true) + ), + DELETE_GROUP("/%s deletegroup ", + arg("name", true) + ), + LIST_GROUPS("/%s listgroups"), + + CREATE_TRACK("/%s createtrack ", + arg("name", true) + ), + DELETE_TRACK("/%s deletetrack ", + arg("name", true) + ), + LIST_TRACKS("/%s listtracks"), + + USER_INFO, + USER_SWITCHPRIMARYGROUP( + (arg("group", true)) + ), + USER_PROMOTE( + arg("track", false), + arg("context...", false), + arg("dont-add-to-first", "--dont-add-to-first", false) + ), + USER_DEMOTE( + arg("track", false), + arg("context...", false), + arg("dont-remove-from-first", "--dont-remove-from-first", false) + ), + USER_CLONE( + arg("user", true) + ), + + GROUP_INFO, + GROUP_LISTMEMBERS( + arg("page", false) + ), + GROUP_SETWEIGHT( + arg("weight", true) + ), + GROUP_SET_DISPLAY_NAME( + arg("name", true), + arg("context...", false) + ), + GROUP_RENAME( + arg("name", true) + ), + GROUP_CLONE( + arg("name", true) + ), + + HOLDER_EDITOR, + HOLDER_SHOWTRACKS, + HOLDER_CLEAR( + arg("context...", false) + ), + + PERMISSION, + PARENT, + META, + + PERMISSION_INFO( + arg("page", false), + arg("sort mode", false) + ), + PERMISSION_SET( + arg("node", true), + arg("value", "true|false", false), + arg("context...", false) + ), + PERMISSION_UNSET( + arg("node", true), + arg("context...", false) + ), + PERMISSION_SETTEMP( + arg("node", true), + arg("value", "true|false", false), + arg("duration", true), + arg("temporary modifier", false), + arg("context...", false) + ), + PERMISSION_UNSETTEMP( + arg("node", true), + arg("duration", false), + arg("context...", false) + ), + PERMISSION_CHECK( + arg("node", true), + arg("context...", false) + ), + PERMISSION_CHECK_INHERITS( + arg("node", true), + arg("context...", false) + ), + PERMISSION_CLEAR( + arg("context...", false) + ), + + PARENT_INFO( + arg("page", false), + arg("sort mode", false) + ), + PARENT_SET( + arg("group", true), + arg("context...", false) + ), + PARENT_ADD( + arg("group", true), + arg("context...", false) + ), + PARENT_REMOVE( + arg("group", true), + arg("context...", false) + ), + PARENT_SET_TRACK( + arg("track", true), + arg("group", true), + arg("context...", false) + ), + PARENT_ADD_TEMP( + arg("group", true), + arg("duration", true), + arg("temporary modifier", false), + arg("context...", false) + ), + PARENT_REMOVE_TEMP( + arg("group", true), + arg("duration", false), + arg("context...", false) + ), + PARENT_CLEAR( + arg("context...", false) + ), + PARENT_CLEAR_TRACK( + arg("track", true), + arg("context...", false) + ), + + META_INFO, + META_SET( + arg("key", true), + arg("value", true), + arg("context...", false) + ), + META_UNSET( + arg("key", true), + arg("context...", false) + ), + META_SETTEMP( + arg("key", true), + arg("value", true), + arg("duration", true), + arg("context...", false) + ), + META_UNSETTEMP( + arg("key", true), + arg("context...", false) + ), + META_ADDPREFIX( + arg("priority", true), + arg("prefix", true), + arg("context...", false) + ), + META_ADDSUFFIX( + arg("priority", true), + arg("suffix", true), + arg("context...", false) + ), + META_SETPREFIX( + arg("priority", false), + arg("prefix", true), + arg("context...", false) + ), + META_SETSUFFIX( + arg("priority", false), + arg("suffix", true), + arg("context...", false) + ), + META_REMOVEPREFIX( + arg("priority", true), + arg("prefix", false), + arg("context...", false) + ), + META_REMOVESUFFIX( + arg("priority", true), + arg("suffix", false), + arg("context...", false) + ), + META_ADDTEMP_PREFIX( + arg("priority", true), + arg("prefix", true), + arg("duration", true), + arg("context...", false) + ), + META_ADDTEMP_SUFFIX( + arg("priority", true), + arg("suffix", true), + arg("duration", true), + arg("context...", false) + ), + META_SETTEMP_PREFIX( + arg("priority", true), + arg("prefix", true), + arg("duration", true), + arg("context...", false) + ), + META_SETTEMP_SUFFIX( + arg("priority", true), + arg("suffix", true), + arg("duration", true), + arg("context...", false) + ), + META_REMOVETEMP_PREFIX( + arg("priority", true), + arg("prefix", false), + arg("context...", false) + ), + META_REMOVETEMP_SUFFIX( + arg("priority", true), + arg("suffix", false), + arg("context...", false) + ), + META_CLEAR( + arg("type", false), + arg("context...", false) + ), + + TRACK_INFO, + TRACK_APPEND( + arg("group", true) + ), + TRACK_INSERT( + arg("group", true), + arg("position", true) + ), + TRACK_REMOVE( + arg("group", true) + ), + TRACK_CLEAR, + TRACK_RENAME( + arg("name", true) + ), + TRACK_CLONE( + arg("name", true) + ), + + LOG_RECENT( + arg("user", false), + arg("page", false) + ), + LOG_SEARCH( + arg("query", true), + arg("page", false) + ), + LOG_NOTIFY( + arg("toggle", "on|off", false) + ), + LOG_USER_HISTORY( + arg("user", true), + arg("page", false) + ), + LOG_GROUP_HISTORY( + arg("group", true), + arg("page", false) + ), + LOG_TRACK_HISTORY( + arg("track", true), + arg("page", false) + ), + + SPONGE("/%s sponge ", + arg("collection", true), + arg("subject", true) + ), + SPONGE_PERMISSION_INFO( + arg("contexts...", false) + ), + SPONGE_PERMISSION_SET( + arg("node", true), + arg("tristate", true), + arg("contexts...", false) + ), + SPONGE_PERMISSION_CLEAR( + arg("contexts...", false) + ), + SPONGE_PARENT_INFO( + arg("contexts...", false) + ), + SPONGE_PARENT_ADD( + arg("collection", true), + arg("subject", true), + arg("contexts...", false) + ), + SPONGE_PARENT_REMOVE( + arg("collection", true), + arg("subject", true), + arg("contexts...", false) + ), + SPONGE_PARENT_CLEAR( + arg("contexts...", false) + ), + SPONGE_OPTION_INFO( + arg("contexts...", false) + ), + SPONGE_OPTION_SET( + arg("key", true), + arg("value", true), + arg("contexts...", false) + ), + SPONGE_OPTION_UNSET( + arg("key", true), + arg("contexts...", false) + ), + SPONGE_OPTION_CLEAR( + arg("contexts...", false) + ), + + MIGRATION_COMMAND, + MIGRATION_GROUPMANAGER( + arg("migrate as global", true) + ), + MIGRATION_POWERFULPERMS( + arg("address", true), + arg("database", true), + arg("username", true), + arg("password", true), + arg("db table", true) + ); + + private final String usage; + private final List args; + + CommandSpec(String usage, PartialArgument... args) { + this.usage = usage; + this.args = args.length == 0 ? null : Arrays.stream(args) + .map(builder -> { + String key = builder.id.replace(".", "").replace(' ', '-'); + Component description = Component.translatable("luckperms.usage." + key() + ".argument." + key); + return new Argument(builder.name, builder.required, description); + }) + .collect(ImmutableCollectors.toList()); + } + + CommandSpec(PartialArgument... args) { + this(null, args); + } + + public Component description() { + return Component.translatable("luckperms.usage." + this.key() + ".description"); + } + + public String usage() { + return this.usage; + } + + public List args() { + return this.args; + } + + public String key() { + return name().toLowerCase().replace('_', '-'); + } + + private static PartialArgument arg(String id, String name, boolean required) { + return new PartialArgument(id, name, required); + } + + private static PartialArgument arg(String name, boolean required) { + return new PartialArgument(name, name, required); + } + + private static final class PartialArgument { + private final String id; + private final String name; + private final boolean required; + + private PartialArgument(String id, String name, boolean required) { + this.id = id; + this.name = name; + this.required = required; + } + } + +} diff --git a/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentException.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentException.java index 4592eb1eb..bb9287d1e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentException.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentException.java @@ -29,7 +29,7 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.Command; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.sender.Sender; public abstract class ArgumentException extends CommandException { diff --git a/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java deleted file mode 100644 index 32ea2e005..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.command.utils; - -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.message.Message; - -import net.luckperms.api.context.Context; -import net.luckperms.api.context.ContextSet; -import net.luckperms.api.node.Node; -import net.luckperms.api.util.Tristate; - -import java.util.Collection; -import java.util.List; - -public final class MessageUtils { - private MessageUtils() {} - - public static String toCommaSep(Collection strings) { - if (strings.isEmpty()) { - return "&bNone"; - } - - StringBuilder sb = new StringBuilder(); - strings.forEach(s -> sb.append("&3").append(s).append("&7, ")); - return sb.delete(sb.length() - 2, sb.length()).toString(); - } - - public static String listToArrowSep(Collection strings, String highlight) { - if (strings.isEmpty()) { - return "&bNone"; - } - - StringBuilder sb = new StringBuilder(); - strings.forEach(s -> sb.append(s.equalsIgnoreCase(highlight) ? "&b" : "&3").append(s).append("&7 ---> ")); - return sb.delete(sb.length() - 6, sb.length()).toString(); - } - - public static String listToArrowSep(Collection strings, String highlightFirst, String highlightSecond, boolean reversed) { - if (strings.isEmpty()) { - return "&6None"; - } - - StringBuilder sb = new StringBuilder(); - for (String s : strings) { - if (s.equalsIgnoreCase(highlightFirst)) { - sb.append("&b").append(s).append("&4"); - } else if (s.equalsIgnoreCase(highlightSecond)) { - sb.append("&b").append(s).append("&7"); - } else { - sb.append("&3").append(s).append("&7"); - } - - sb.append(reversed ? " <--- " : " ---> "); - } - return sb.delete(sb.length() - 6, sb.length()).toString(); - } - - public static String listToArrowSep(List strings) { - if (strings.isEmpty()) { - return "&6None"; - } - - StringBuilder sb = new StringBuilder(); - strings.forEach(s -> sb.append("&3").append(s).append("&b ---> ")); - return sb.delete(sb.length() - 6, sb.length()).toString(); - } - - /** - * Formats a boolean to a colored string - * - * @param b the boolean value - * @return a formatted boolean string - */ - public static String formatBoolean(boolean b) { - return b ? "&atrue" : "&cfalse"; - } - - /** - * Formats a tristate to a colored string - * - * @param t the tristate value - * @return a formatted tristate string - */ - public static String formatTristate(Tristate t) { - switch (t) { - case TRUE: - return "&atrue"; - case FALSE: - return "&cfalse"; - default: - return "&cundefined"; - } - } - - /** - * Produces a string representing a Nodes context, suitable for appending onto another message line. - * - * @param localeManager the locale manager - * @param node the node to query context from - * @return a string representing the nodes context, or an empty string if the node applies globally. - */ - public static String getAppendableNodeContextString(LocaleManager localeManager, Node node) { - StringBuilder sb = new StringBuilder(); - for (Context c : node.getContexts()) { - sb.append(" ").append(contextToString(localeManager, c.getKey(), c.getValue())); - } - return sb.toString(); - } - - /** - * Converts a context pair to a formatted string, surrounded by ( ) brackets. - * - * - * @param localeManager the locale manager - * @param key the context key - * @param value the context value - * @return a formatted string - */ - public static String contextToString(LocaleManager localeManager, String key, String value) { - return Message.CONTEXT_PAIR.asString(localeManager, key, value); - } - - public static String contextSetToString(LocaleManager localeManager, ContextSet set) { - if (set.isEmpty()) { - return Message.CONTEXT_PAIR_GLOBAL_INLINE.asString(localeManager); - } - - StringBuilder sb = new StringBuilder(); - - for (Context e : set) { - sb.append(Message.CONTEXT_PAIR_INLINE.asString(localeManager, e.getKey(), e.getValue())); - sb.append(Message.CONTEXT_PAIR_SEP.asString(localeManager)); - } - - return sb.delete(sb.length() - Message.CONTEXT_PAIR_SEP.asString(localeManager).length(), sb.length()).toString(); - } - -} diff --git a/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java index 66547dfa2..5badaa1e2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.common.command.utils; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.HolderType; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/CommandMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/CommandMeta.java index 55be88c53..400a7232c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/CommandMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/CommandMeta.java @@ -29,32 +29,31 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.abstraction.GenericParentCommand; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; public class CommandMeta extends GenericParentCommand { - public CommandMeta(LocaleManager locale, HolderType type) { - super(CommandSpec.META.localize(locale), "Meta", type, ImmutableList.builder() - .add(new MetaInfo(locale)) - .add(new MetaSet(locale)) - .add(new MetaUnset(locale)) - .add(new MetaSetTemp(locale)) - .add(new MetaUnsetTemp(locale)) - .add(MetaAddChatMeta.forPrefix(locale)) - .add(MetaAddChatMeta.forSuffix(locale)) - .add(MetaSetChatMeta.forPrefix(locale)) - .add(MetaSetChatMeta.forSuffix(locale)) - .add(MetaRemoveChatMeta.forPrefix(locale)) - .add(MetaRemoveChatMeta.forSuffix(locale)) - .add(MetaAddTempChatMeta.forPrefix(locale)) - .add(MetaAddTempChatMeta.forSuffix(locale)) - .add(MetaSetTempChatMeta.forPrefix(locale)) - .add(MetaSetTempChatMeta.forSuffix(locale)) - .add(MetaRemoveTempChatMeta.forPrefix(locale)) - .add(MetaRemoveTempChatMeta.forSuffix(locale)) - .add(new MetaClear(locale)) + public CommandMeta(HolderType type) { + super(CommandSpec.META, "Meta", type, ImmutableList.builder() + .add(new MetaInfo()) + .add(new MetaSet()) + .add(new MetaUnset()) + .add(new MetaSetTemp()) + .add(new MetaUnsetTemp()) + .add(MetaAddChatMeta.forPrefix()) + .add(MetaAddChatMeta.forSuffix()) + .add(MetaSetChatMeta.forPrefix()) + .add(MetaSetChatMeta.forSuffix()) + .add(MetaRemoveChatMeta.forPrefix()) + .add(MetaRemoveChatMeta.forSuffix()) + .add(MetaAddTempChatMeta.forPrefix()) + .add(MetaAddTempChatMeta.forSuffix()) + .add(MetaSetTempChatMeta.forPrefix()) + .add(MetaSetTempChatMeta.forSuffix()) + .add(MetaRemoveTempChatMeta.forPrefix()) + .add(MetaRemoveTempChatMeta.forSuffix()) + .add(new MetaClear()) .build()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddChatMeta.java index c8a53df00..974ffa237 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddChatMeta.java @@ -31,23 +31,17 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.TextComponent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.context.MutableContextSet; import net.luckperms.api.model.data.DataMutateResult; import net.luckperms.api.model.data.DataType; @@ -57,20 +51,20 @@ import java.util.List; public class MetaAddChatMeta extends GenericChildCommand { - public static MetaAddChatMeta forPrefix(LocaleManager locale) { + public static MetaAddChatMeta forPrefix() { return new MetaAddChatMeta( ChatMetaType.PREFIX, - CommandSpec.META_ADDPREFIX.localize(locale), + CommandSpec.META_ADDPREFIX, "addprefix", CommandPermission.USER_META_ADD_PREFIX, CommandPermission.GROUP_META_ADD_PREFIX ); } - public static MetaAddChatMeta forSuffix(LocaleManager locale) { + public static MetaAddChatMeta forSuffix() { return new MetaAddChatMeta( ChatMetaType.SUFFIX, - CommandSpec.META_ADDSUFFIX.localize(locale), + CommandSpec.META_ADDSUFFIX, "addsuffix", CommandPermission.USER_META_ADD_SUFFIX, CommandPermission.GROUP_META_ADD_SUFFIX @@ -79,7 +73,7 @@ public class MetaAddChatMeta extends GenericChildCommand { private final ChatMetaType type; - private MetaAddChatMeta(ChatMetaType type, LocalizedCommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { + private MetaAddChatMeta(ChatMetaType type, CommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { super(spec, name, userPermission, groupPermission, Predicates.inRange(0, 1)); this.type = type; } @@ -103,13 +97,7 @@ public class MetaAddChatMeta extends GenericChildCommand { DataMutateResult result = target.setNode(DataType.NORMAL, this.type.builder(meta, priority).withContext(context).build(), true); if (result.wasSuccessful()) { - TextComponent.Builder builder = Message.ADD_CHATMETA_SUCCESS.asComponent(plugin.getLocaleManager(), target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder(); - HoverEvent event = HoverEvent.showText(TextUtils.fromLegacy( - "§3Raw " + this.type.name().toLowerCase() + ": §r" + meta, - '§' - )); - builder.applyDeep(c -> c.hoverEvent(event)); - sender.sendMessage(builder.build()); + Message.ADD_CHATMETA_SUCCESS.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, context); LoggedAction.build().source(sender).target(target) .description("meta" , "add" + this.type.name().toLowerCase(), priority, meta, context) @@ -118,7 +106,7 @@ public class MetaAddChatMeta extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_HAS_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.ALREADY_HAS_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempChatMeta.java index e584b36cd..ae3eac83e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempChatMeta.java @@ -31,25 +31,18 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.TextComponent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.context.MutableContextSet; import net.luckperms.api.model.data.DataMutateResult; import net.luckperms.api.model.data.DataType; @@ -61,20 +54,20 @@ import java.util.List; public class MetaAddTempChatMeta extends GenericChildCommand { - public static MetaAddTempChatMeta forPrefix(LocaleManager locale) { + public static MetaAddTempChatMeta forPrefix() { return new MetaAddTempChatMeta( ChatMetaType.PREFIX, - CommandSpec.META_ADDTEMP_PREFIX.localize(locale), + CommandSpec.META_ADDTEMP_PREFIX, "addtempprefix", CommandPermission.USER_META_ADD_TEMP_PREFIX, CommandPermission.GROUP_META_ADD_TEMP_PREFIX ); } - public static MetaAddTempChatMeta forSuffix(LocaleManager locale) { + public static MetaAddTempChatMeta forSuffix() { return new MetaAddTempChatMeta( ChatMetaType.SUFFIX, - CommandSpec.META_ADDTEMP_SUFFIX.localize(locale), + CommandSpec.META_ADDTEMP_SUFFIX, "addtempsuffix", CommandPermission.USER_META_ADD_TEMP_SUFFIX, CommandPermission.GROUP_META_ADD_TEMP_SUFFIX @@ -83,7 +76,7 @@ public class MetaAddTempChatMeta extends GenericChildCommand { private final ChatMetaType type; - private MetaAddTempChatMeta(ChatMetaType type, LocalizedCommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { + private MetaAddTempChatMeta(ChatMetaType type, CommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { super(spec, name, userPermission, groupPermission, Predicates.inRange(0, 2)); this.type = type; } @@ -112,13 +105,7 @@ public class MetaAddTempChatMeta extends GenericChildCommand { if (result.getResult().wasSuccessful()) { duration = result.getMergedNode().getExpiryDuration(); - TextComponent.Builder builder = Message.ADD_TEMP_CHATMETA_SUCCESS.asComponent(plugin.getLocaleManager(), target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, DurationFormatter.LONG.format(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder(); - HoverEvent event = HoverEvent.showText(TextUtils.fromLegacy( - "§3Raw " + this.type.name().toLowerCase() + ": §r" + meta, - '§' - )); - builder.applyDeep(c -> c.hoverEvent(event)); - sender.sendMessage(builder.build()); + Message.ADD_TEMP_CHATMETA_SUCCESS.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, duration, context); LoggedAction.build().source(sender).target(target) .description("meta" , "addtemp" + this.type.name().toLowerCase(), priority, meta, duration, context) @@ -127,7 +114,7 @@ public class MetaAddTempChatMeta extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_HAS_TEMP_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.ALREADY_HAS_TEMP_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java index 154875974..c6ce659b4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -51,8 +49,8 @@ import net.luckperms.api.node.NodeType; import java.util.List; public class MetaClear extends GenericChildCommand { - public MetaClear(LocaleManager locale) { - super(CommandSpec.META_CLEAR.localize(locale), "clear", CommandPermission.USER_META_CLEAR, CommandPermission.GROUP_META_CLEAR, Predicates.alwaysFalse()); + public MetaClear() { + super(CommandSpec.META_CLEAR, "clear", CommandPermission.USER_META_CLEAR, CommandPermission.GROUP_META_CLEAR, Predicates.alwaysFalse()); } @Override @@ -107,11 +105,7 @@ public class MetaClear extends GenericChildCommand { } int changed = before - target.normalData().size(); - if (changed == 1) { - Message.META_CLEAR_SUCCESS_SINGULAR.send(sender, target.getFormattedDisplayName(), type.name().toLowerCase(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); - } else { - Message.META_CLEAR_SUCCESS.send(sender, target.getFormattedDisplayName(), type.name().toLowerCase(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); - } + Message.META_CLEAR_SUCCESS.send(sender, target.getFormattedDisplayName(), type.name().toLowerCase(), context, changed); LoggedAction.build().source(sender).target(target) .description("meta", "clear", context) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java index 3db0344ab..2843279ab 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java @@ -31,29 +31,18 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; -import me.lucko.luckperms.common.model.Group; -import me.lucko.luckperms.common.model.HolderType; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator; -import me.lucko.luckperms.common.node.factory.NodeCommandFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.query.QueryOptionsImpl; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.ComponentBuilder; -import net.kyori.text.TextComponent; -import net.kyori.text.event.ClickEvent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.node.Node; import net.luckperms.api.node.NodeType; -import net.luckperms.api.node.metadata.types.InheritanceOriginMetadata; import net.luckperms.api.node.types.ChatMetaNode; import net.luckperms.api.node.types.MetaNode; import net.luckperms.api.node.types.PrefixNode; @@ -65,11 +54,10 @@ import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import java.util.function.Consumer; public class MetaInfo extends GenericChildCommand { - public MetaInfo(LocaleManager locale) { - super(CommandSpec.META_INFO.localize(locale), "info", CommandPermission.USER_META_INFO, CommandPermission.GROUP_META_INFO, Predicates.alwaysFalse()); + public MetaInfo() { + super(CommandSpec.META_INFO, "info", CommandPermission.USER_META_INFO, CommandPermission.GROUP_META_INFO, Predicates.alwaysFalse()); } @Override @@ -104,117 +92,32 @@ public class MetaInfo extends GenericChildCommand { Message.CHAT_META_PREFIX_NONE.send(sender, target.getFormattedDisplayName()); } else { Message.CHAT_META_PREFIX_HEADER.send(sender, target.getFormattedDisplayName()); - sendChatMetaMessage(prefixes, sender, target, label); + for (Map.Entry e : prefixes) { + Message.CHAT_META_ENTRY.send(sender, e.getValue(), target, label); + } } if (suffixes.isEmpty()) { Message.CHAT_META_SUFFIX_NONE.send(sender, target.getFormattedDisplayName()); } else { Message.CHAT_META_SUFFIX_HEADER.send(sender, target.getFormattedDisplayName()); - sendChatMetaMessage(suffixes, sender, target, label); + for (Map.Entry e : suffixes) { + Message.CHAT_META_ENTRY.send(sender, e.getValue(), target, label); + } } if (meta.isEmpty()) { Message.META_NONE.send(sender, target.getFormattedDisplayName()); } else { Message.META_HEADER.send(sender, target.getFormattedDisplayName()); - sendMetaMessage(meta, sender, target, label); + for (MetaNode node : meta) { + Message.META_ENTRY.send(sender, node, target, label); + } } return CommandResult.SUCCESS; } - private static String processLocation(Node node, PermissionHolder holder) { - String location = node.metadata(InheritanceOriginMetadata.KEY).getOrigin().getName(); - return location.equalsIgnoreCase(holder.getObjectName()) ? "self" : location; - } - - private static void sendMetaMessage(Set meta, Sender sender, PermissionHolder holder, String label) { - for (MetaNode m : meta) { - String location = processLocation(m, holder); - if (!m.getContexts().isEmpty()) { - String context = MessageUtils.getAppendableNodeContextString(sender.getPlugin().getLocaleManager(), m); - TextComponent.Builder builder = Message.META_ENTRY_WITH_CONTEXT.asComponent(sender.getPlugin().getLocaleManager(), m.getMetaKey(), m.getMetaValue(), location, context).toBuilder(); - builder.applyDeep(makeFancy(holder, label, m)); - sender.sendMessage(builder.build()); - } else { - TextComponent.Builder builder = Message.META_ENTRY.asComponent(sender.getPlugin().getLocaleManager(), m.getMetaKey(), m.getMetaValue(), location).toBuilder(); - builder.applyDeep(makeFancy(holder, label, m)); - sender.sendMessage(builder.build()); - } - } - } - - private static void sendChatMetaMessage(SortedSet>> meta, Sender sender, PermissionHolder holder, String label) { - for (Map.Entry> e : meta) { - String location = processLocation(e.getValue(), holder); - if (!e.getValue().getContexts().isEmpty()) { - String context = MessageUtils.getAppendableNodeContextString(sender.getPlugin().getLocaleManager(), e.getValue()); - TextComponent.Builder builder = Message.CHAT_META_ENTRY_WITH_CONTEXT.asComponent(sender.getPlugin().getLocaleManager(), e.getKey(), e.getValue().getMetaValue(), location, context).toBuilder(); - builder.applyDeep(makeFancy(holder, label, e.getValue())); - sender.sendMessage(builder.build()); - } else { - TextComponent.Builder builder = Message.CHAT_META_ENTRY.asComponent(sender.getPlugin().getLocaleManager(), e.getKey(), e.getValue().getMetaValue(), location).toBuilder(); - builder.applyDeep(makeFancy(holder, label, e.getValue())); - sender.sendMessage(builder.build()); - } - } - } - - private static Consumer> makeFancy(PermissionHolder holder, String label, ChatMetaNode node) { - String location = node.metadata(InheritanceOriginMetadata.KEY).getOrigin().getName(); - if (!location.equals(holder.getObjectName())) { - // inherited. - Group group = holder.getPlugin().getGroupManager().getIfLoaded(location); - if (group != null) { - holder = group; - } - } - - HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( - "§3> §a" + node.getPriority() + " §7- §r" + node.getMetaValue(), - " ", - "§7Click to remove this " + node.getMetaType().name().toLowerCase() + " from " + holder.getPlainDisplayName() - ), '§')); - - String id = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getFormattedDisplayName(); - boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, id, holder.getType(), explicitGlobalContext); - ClickEvent clickEvent = ClickEvent.suggestCommand(command); - - return component -> { - component.hoverEvent(hoverEvent); - component.clickEvent(clickEvent); - }; - } - - private static Consumer> makeFancy(PermissionHolder holder, String label, MetaNode node) { - String location = node.metadata(InheritanceOriginMetadata.KEY).getOrigin().getName(); - if (!location.equals(holder.getObjectName())) { - // inherited. - Group group = holder.getPlugin().getGroupManager().getIfLoaded(location); - if (group != null) { - holder = group; - } - } - - HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( - "§3> §r" + node.getMetaKey() + " §7- §r" + node.getMetaValue(), - " ", - "§7Click to remove this meta pair from " + holder.getPlainDisplayName() - ), '§')); - - String id = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); - boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, id, holder.getType(), explicitGlobalContext); - ClickEvent clickEvent = ClickEvent.suggestCommand(command); - - return component -> { - component.hoverEvent(hoverEvent); - component.clickEvent(clickEvent); - }; - } - private static final class MetaComparator implements Comparator>> { public static final MetaComparator INSTANCE = new MetaComparator(); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java index 8534152e3..d2c5a9d7d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java @@ -31,23 +31,17 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.TextComponent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.model.data.DataMutateResult; import net.luckperms.api.model.data.DataType; @@ -57,20 +51,20 @@ import java.util.List; public class MetaRemoveChatMeta extends GenericChildCommand { - public static MetaRemoveChatMeta forPrefix(LocaleManager locale) { + public static MetaRemoveChatMeta forPrefix() { return new MetaRemoveChatMeta( ChatMetaType.PREFIX, - CommandSpec.META_REMOVEPREFIX.localize(locale), + CommandSpec.META_REMOVEPREFIX, "removeprefix", CommandPermission.USER_META_REMOVE_PREFIX, CommandPermission.GROUP_META_REMOVE_PREFIX ); } - public static MetaRemoveChatMeta forSuffix(LocaleManager locale) { + public static MetaRemoveChatMeta forSuffix() { return new MetaRemoveChatMeta( ChatMetaType.SUFFIX, - CommandSpec.META_REMOVESUFFIX.localize(locale), + CommandSpec.META_REMOVESUFFIX, "removesuffix", CommandPermission.USER_META_REMOVE_SUFFIX, CommandPermission.GROUP_META_REMOVE_SUFFIX @@ -79,7 +73,7 @@ public class MetaRemoveChatMeta extends GenericChildCommand { private final ChatMetaType type; - private MetaRemoveChatMeta(ChatMetaType type, LocalizedCommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { + private MetaRemoveChatMeta(ChatMetaType type, CommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { super(spec, name, userPermission, groupPermission, Predicates.is(0)); this.type = type; } @@ -104,7 +98,7 @@ public class MetaRemoveChatMeta extends GenericChildCommand { // Handle bulk removal if (meta.equalsIgnoreCase("null") || meta.equals("*")) { target.removeIf(DataType.NORMAL, context, this.type.nodeType().predicate(n -> n.getPriority() == priority && !n.hasExpiry()), false); - Message.BULK_REMOVE_CHATMETA_SUCCESS.send(sender, target.getFormattedDisplayName(), this.type.name().toLowerCase(), priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.BULK_REMOVE_CHATMETA_SUCCESS.send(sender, target.getFormattedDisplayName(), this.type, priority, context); LoggedAction.build().source(sender).target(target) .description("meta" , "remove" + this.type.name().toLowerCase(), priority, "*", context) @@ -117,13 +111,7 @@ public class MetaRemoveChatMeta extends GenericChildCommand { DataMutateResult result = target.unsetNode(DataType.NORMAL, this.type.builder(meta, priority).withContext(context).build()); if (result.wasSuccessful()) { - TextComponent.Builder builder = Message.REMOVE_CHATMETA_SUCCESS.asComponent(plugin.getLocaleManager(), target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder(); - HoverEvent event = HoverEvent.showText(TextUtils.fromLegacy( - "§3Raw " + this.type.name().toLowerCase() + ": §r" + meta, - '§' - )); - builder.applyDeep(c -> c.hoverEvent(event)); - sender.sendMessage(builder.build()); + Message.REMOVE_CHATMETA_SUCCESS.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, context); LoggedAction.build().source(sender).target(target) .description("meta" , "remove" + this.type.name().toLowerCase(), priority, meta, context) @@ -132,7 +120,7 @@ public class MetaRemoveChatMeta extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_HAVE_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.DOES_NOT_HAVE_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java index baebee6e4..8362fb24d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java @@ -31,23 +31,17 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.TextComponent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.model.data.DataMutateResult; import net.luckperms.api.model.data.DataType; @@ -57,20 +51,20 @@ import java.util.List; public class MetaRemoveTempChatMeta extends GenericChildCommand { - public static MetaRemoveTempChatMeta forPrefix(LocaleManager locale) { + public static MetaRemoveTempChatMeta forPrefix() { return new MetaRemoveTempChatMeta( ChatMetaType.PREFIX, - CommandSpec.META_REMOVETEMP_PREFIX.localize(locale), + CommandSpec.META_REMOVETEMP_PREFIX, "removetempprefix", CommandPermission.USER_META_REMOVE_TEMP_PREFIX, CommandPermission.GROUP_META_REMOVE_TEMP_PREFIX ); } - public static MetaRemoveTempChatMeta forSuffix(LocaleManager locale) { + public static MetaRemoveTempChatMeta forSuffix() { return new MetaRemoveTempChatMeta( ChatMetaType.SUFFIX, - CommandSpec.META_REMOVETEMP_SUFFIX.localize(locale), + CommandSpec.META_REMOVETEMP_SUFFIX, "removetempsuffix", CommandPermission.USER_META_REMOVE_TEMP_SUFFIX, CommandPermission.GROUP_META_REMOVE_TEMP_SUFFIX @@ -79,7 +73,7 @@ public class MetaRemoveTempChatMeta extends GenericChildCommand { private final ChatMetaType type; - private MetaRemoveTempChatMeta(ChatMetaType type, LocalizedCommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { + private MetaRemoveTempChatMeta(ChatMetaType type, CommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { super(spec, name, userPermission, groupPermission, Predicates.is(0)); this.type = type; } @@ -104,7 +98,7 @@ public class MetaRemoveTempChatMeta extends GenericChildCommand { // Handle bulk removal if (meta.equalsIgnoreCase("null") || meta.equals("*")) { target.removeIf(DataType.NORMAL, context, this.type.nodeType().predicate(n -> n.getPriority() == priority && n.hasExpiry()), false); - Message.BULK_REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, target.getFormattedDisplayName(), this.type.name().toLowerCase(), priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.BULK_REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, target.getFormattedDisplayName(), this.type, priority, context); LoggedAction.build().source(sender).target(target) .description("meta" , "removetemp" + this.type.name().toLowerCase(), priority, "*", context) @@ -117,13 +111,7 @@ public class MetaRemoveTempChatMeta extends GenericChildCommand { DataMutateResult result = target.unsetNode(DataType.NORMAL, this.type.builder(meta, priority).expiry(10L).withContext(context).build()); if (result.wasSuccessful()) { - TextComponent.Builder builder = Message.REMOVE_TEMP_CHATMETA_SUCCESS.asComponent(plugin.getLocaleManager(), target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder(); - HoverEvent event = HoverEvent.showText(TextUtils.fromLegacy( - "§3Raw " + this.type.name().toLowerCase() + ": §r" + meta, - '§' - )); - builder.applyDeep(c -> c.hoverEvent(event)); - sender.sendMessage(builder.build()); + Message.REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, context); LoggedAction.build().source(sender).target(target) .description("meta" , "removetemp" + this.type.name().toLowerCase(), priority, meta, context) @@ -132,7 +120,7 @@ public class MetaRemoveTempChatMeta extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_HAVE_TEMP_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.DOES_NOT_HAVE_TEMP_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java index c0b1b2aff..9ec0f7f2e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java @@ -31,23 +31,18 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.types.Meta; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.TextComponent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.context.MutableContextSet; import net.luckperms.api.model.data.DataType; import net.luckperms.api.node.Node; @@ -57,8 +52,8 @@ import net.luckperms.api.node.NodeType; import java.util.List; public class MetaSet extends GenericChildCommand { - public MetaSet(LocaleManager locale) { - super(CommandSpec.META_SET.localize(locale), "set", CommandPermission.USER_META_SET, CommandPermission.GROUP_META_SET, Predicates.inRange(0, 1)); + public MetaSet() { + super(CommandSpec.META_SET, "set", CommandPermission.USER_META_SET, CommandPermission.GROUP_META_SET, Predicates.inRange(0, 1)); } @Override @@ -82,20 +77,14 @@ public class MetaSet extends GenericChildCommand { Node node = Meta.builder(key, value).withContext(context).build(); if (target.hasNode(DataType.NORMAL, node, NodeEqualityPredicate.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean()) { - Message.ALREADY_HAS_META.send(sender, target.getFormattedDisplayName(), key, value, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.ALREADY_HAS_META.send(sender, target.getFormattedDisplayName(), key, value, context); return CommandResult.STATE_ERROR; } target.removeIf(DataType.NORMAL, context, NodeType.META.predicate(n -> !n.hasExpiry() && n.getMetaKey().equalsIgnoreCase(key)), false); target.setNode(DataType.NORMAL, node, true); - TextComponent.Builder builder = Message.SET_META_SUCCESS.asComponent(plugin.getLocaleManager(), key, value, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder(); - HoverEvent event = HoverEvent.showText(TextUtils.fromLegacy( - TextUtils.joinNewline("§3Raw key: §r" + key, "§3Raw value: §r" + value), - '§' - )); - builder.applyDeep(c -> c.hoverEvent(event)); - sender.sendMessage(builder.build()); + Message.SET_META_SUCCESS.send(sender, key, value, target.getFormattedDisplayName(), context); LoggedAction.build().source(sender).target(target) .description("meta", "set", key, value, context) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java index 29bdd97b7..604f50d51 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java @@ -32,25 +32,19 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.query.QueryOptionsImpl; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.TextComponent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.context.MutableContextSet; import net.luckperms.api.model.data.DataMutateResult; import net.luckperms.api.model.data.DataType; @@ -61,20 +55,20 @@ import java.util.OptionalInt; public class MetaSetChatMeta extends GenericChildCommand { - public static MetaSetChatMeta forPrefix(LocaleManager locale) { + public static MetaSetChatMeta forPrefix() { return new MetaSetChatMeta( ChatMetaType.PREFIX, - CommandSpec.META_SETPREFIX.localize(locale), + CommandSpec.META_SETPREFIX, "setprefix", CommandPermission.USER_META_SET_PREFIX, CommandPermission.GROUP_META_SET_PREFIX ); } - public static MetaSetChatMeta forSuffix(LocaleManager locale) { + public static MetaSetChatMeta forSuffix() { return new MetaSetChatMeta( ChatMetaType.SUFFIX, - CommandSpec.META_SETSUFFIX.localize(locale), + CommandSpec.META_SETSUFFIX, "setsuffix", CommandPermission.USER_META_SET_SUFFIX, CommandPermission.GROUP_META_SET_SUFFIX @@ -83,7 +77,7 @@ public class MetaSetChatMeta extends GenericChildCommand { private final ChatMetaType type; - private MetaSetChatMeta(ChatMetaType type, LocalizedCommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { + private MetaSetChatMeta(ChatMetaType type, CommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { super(spec, name, userPermission, groupPermission, Predicates.is(0)); this.type = type; } @@ -138,13 +132,7 @@ public class MetaSetChatMeta extends GenericChildCommand { DataMutateResult result = target.setNode(DataType.NORMAL, this.type.builder(meta, priority).withContext(context).build(), true); if (result.wasSuccessful()) { - TextComponent.Builder builder = Message.ADD_CHATMETA_SUCCESS.asComponent(plugin.getLocaleManager(), target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder(); - HoverEvent event = HoverEvent.showText(TextUtils.fromLegacy( - "§3Raw " + this.type.name().toLowerCase() + ": §r" + meta, - '§' - )); - builder.applyDeep(c -> c.hoverEvent(event)); - sender.sendMessage(builder.build()); + Message.ADD_CHATMETA_SUCCESS.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, context); LoggedAction.build().source(sender).target(target) .description("meta" , "set" + this.type.name().toLowerCase(), priority, meta, context) @@ -153,7 +141,7 @@ public class MetaSetChatMeta extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_HAS_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.ALREADY_HAS_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java index 2e4c2da5b..2578048bd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java @@ -31,25 +31,19 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.types.Meta; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.TextComponent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.context.MutableContextSet; import net.luckperms.api.model.data.DataType; import net.luckperms.api.model.data.TemporaryNodeMergeStrategy; @@ -61,8 +55,8 @@ import java.time.Duration; import java.util.List; public class MetaSetTemp extends GenericChildCommand { - public MetaSetTemp(LocaleManager locale) { - super(CommandSpec.META_SETTEMP.localize(locale), "settemp", CommandPermission.USER_META_SET_TEMP, CommandPermission.GROUP_META_SET_TEMP, Predicates.inRange(0, 2)); + public MetaSetTemp() { + super(CommandSpec.META_SETTEMP, "settemp", CommandPermission.USER_META_SET_TEMP, CommandPermission.GROUP_META_SET_TEMP, Predicates.inRange(0, 2)); } @Override @@ -88,20 +82,14 @@ public class MetaSetTemp extends GenericChildCommand { Node node = Meta.builder(key, value).withContext(context).expiry(duration).build(); if (target.hasNode(DataType.NORMAL, node, NodeEqualityPredicate.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean()) { - Message.ALREADY_HAS_TEMP_META.send(sender, target.getFormattedDisplayName(), key, value, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.ALREADY_HAS_TEMP_META.send(sender, target.getFormattedDisplayName(), key, value, context); return CommandResult.STATE_ERROR; } target.removeIf(DataType.NORMAL, context, NodeType.META.predicate(n -> n.hasExpiry() && n.getMetaKey().equalsIgnoreCase(key)), false); duration = target.setNode(DataType.NORMAL, node, modifier).getMergedNode().getExpiryDuration(); - TextComponent.Builder builder = Message.SET_META_TEMP_SUCCESS.asComponent(plugin.getLocaleManager(), key, value, target.getFormattedDisplayName(), DurationFormatter.LONG.format(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder(); - HoverEvent event = HoverEvent.showText(TextUtils.fromLegacy( - TextUtils.joinNewline("§3Raw key: §r" + key, "§3Raw value: §r" + value), - '§' - )); - builder.applyDeep(c -> c.hoverEvent(event)); - sender.sendMessage(builder.build()); + Message.SET_META_TEMP_SUCCESS.send(sender, key, value, target.getFormattedDisplayName(), duration, context); LoggedAction.build().source(sender).target(target) .description("meta", "settemp", key, value, duration, context) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java index 1180a6c8a..a83d4ae68 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java @@ -32,27 +32,20 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.query.QueryOptionsImpl; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.TextComponent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.context.MutableContextSet; import net.luckperms.api.model.data.DataMutateResult; import net.luckperms.api.model.data.DataType; @@ -65,20 +58,20 @@ import java.util.OptionalInt; public class MetaSetTempChatMeta extends GenericChildCommand { - public static MetaSetTempChatMeta forPrefix(LocaleManager locale) { + public static MetaSetTempChatMeta forPrefix() { return new MetaSetTempChatMeta( ChatMetaType.PREFIX, - CommandSpec.META_SETTEMP_PREFIX.localize(locale), + CommandSpec.META_SETTEMP_PREFIX, "settempprefix", CommandPermission.USER_META_SET_TEMP_PREFIX, CommandPermission.GROUP_META_SET_TEMP_PREFIX ); } - public static MetaSetTempChatMeta forSuffix(LocaleManager locale) { + public static MetaSetTempChatMeta forSuffix() { return new MetaSetTempChatMeta( ChatMetaType.SUFFIX, - CommandSpec.META_SETTEMP_SUFFIX.localize(locale), + CommandSpec.META_SETTEMP_SUFFIX, "settempsuffix", CommandPermission.USER_META_SET_TEMP_SUFFIX, CommandPermission.GROUP_META_SET_TEMP_SUFFIX @@ -87,7 +80,7 @@ public class MetaSetTempChatMeta extends GenericChildCommand { private final ChatMetaType type; - private MetaSetTempChatMeta(ChatMetaType type, LocalizedCommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { + private MetaSetTempChatMeta(ChatMetaType type, CommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission) { super(spec, name, userPermission, groupPermission, Predicates.inRange(0, 1)); this.type = type; } @@ -151,13 +144,7 @@ public class MetaSetTempChatMeta extends GenericChildCommand { if (result.getResult().wasSuccessful()) { duration = result.getMergedNode().getExpiryDuration(); - TextComponent.Builder builder = Message.ADD_TEMP_CHATMETA_SUCCESS.asComponent(plugin.getLocaleManager(), target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, DurationFormatter.LONG.format(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)).toBuilder(); - HoverEvent event = HoverEvent.showText(TextUtils.fromLegacy( - "§3Raw " + this.type.name().toLowerCase() + ": §r" + meta, - '§' - )); - builder.applyDeep(c -> c.hoverEvent(event)); - sender.sendMessage(builder.build()); + Message.ADD_TEMP_CHATMETA_SUCCESS.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, duration, context); LoggedAction.build().source(sender).target(target) .description("meta" , "settemp" + this.type.name().toLowerCase(), priority, meta, duration, context) @@ -166,7 +153,7 @@ public class MetaSetTempChatMeta extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_HAS_TEMP_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.ALREADY_HAS_TEMP_CHAT_META.send(sender, target.getFormattedDisplayName(), this.type, meta, priority, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java index 720446ec1..9492b164f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -51,8 +49,8 @@ import net.luckperms.api.node.NodeType; import java.util.List; public class MetaUnset extends GenericChildCommand { - public MetaUnset(LocaleManager locale) { - super(CommandSpec.META_UNSET.localize(locale), "unset", CommandPermission.USER_META_UNSET, CommandPermission.GROUP_META_UNSET, Predicates.is(0)); + public MetaUnset() { + super(CommandSpec.META_UNSET, "unset", CommandPermission.USER_META_UNSET, CommandPermission.GROUP_META_UNSET, Predicates.is(0)); } @Override @@ -73,7 +71,7 @@ public class MetaUnset extends GenericChildCommand { } if (target.removeIf(DataType.NORMAL, context, NodeType.META.predicate(n -> !n.hasExpiry() && n.getMetaKey().equalsIgnoreCase(key)), false)) { - Message.UNSET_META_SUCCESS.send(sender, key, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.UNSET_META_SUCCESS.send(sender, key, target.getFormattedDisplayName(), context); LoggedAction.build().source(sender).target(target) .description("meta", "unset", key, context) @@ -82,7 +80,7 @@ public class MetaUnset extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOESNT_HAVE_META.send(sender, target.getFormattedDisplayName(), key, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.DOESNT_HAVE_META.send(sender, target.getFormattedDisplayName(), key, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java index ed0785703..4fbc2ab31 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -51,8 +49,8 @@ import net.luckperms.api.node.NodeType; import java.util.List; public class MetaUnsetTemp extends GenericChildCommand { - public MetaUnsetTemp(LocaleManager locale) { - super(CommandSpec.META_UNSETTEMP.localize(locale), "unsettemp", CommandPermission.USER_META_UNSET_TEMP, CommandPermission.GROUP_META_UNSET_TEMP, Predicates.is(0)); + public MetaUnsetTemp() { + super(CommandSpec.META_UNSETTEMP, "unsettemp", CommandPermission.USER_META_UNSET_TEMP, CommandPermission.GROUP_META_UNSET_TEMP, Predicates.is(0)); } @Override @@ -73,7 +71,7 @@ public class MetaUnsetTemp extends GenericChildCommand { } if (target.removeIf(DataType.NORMAL, context, NodeType.META.predicate(n -> n.hasExpiry() && n.getMetaKey().equalsIgnoreCase(key)), false)) { - Message.UNSET_META_TEMP_SUCCESS.send(sender, key, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.UNSET_META_TEMP_SUCCESS.send(sender, key, target.getFormattedDisplayName(), context); LoggedAction.build().source(sender).target(target) .description("meta", "unsettemp", key, context) @@ -82,7 +80,7 @@ public class MetaUnsetTemp extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOESNT_HAVE_TEMP_META.send(sender, target.getFormattedDisplayName(), key, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.DOESNT_HAVE_TEMP_META.send(sender, target.getFormattedDisplayName(), key, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderClear.java index 830069825..be3d1164c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderClear.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -51,8 +49,8 @@ import net.luckperms.api.model.data.DataType; import java.util.List; public class HolderClear extends ChildCommand { - public HolderClear(LocaleManager locale, HolderType type) { - super(CommandSpec.HOLDER_CLEAR.localize(locale), "clear", type == HolderType.USER ? CommandPermission.USER_CLEAR : CommandPermission.GROUP_CLEAR, Predicates.alwaysFalse()); + public HolderClear(HolderType type) { + super(CommandSpec.HOLDER_CLEAR, "clear", type == HolderType.USER ? CommandPermission.USER_CLEAR : CommandPermission.GROUP_CLEAR, Predicates.alwaysFalse()); } @Override @@ -79,11 +77,7 @@ public class HolderClear extends ChildCommand { } int changed = before - target.normalData().size(); - if (changed == 1) { - Message.CLEAR_SUCCESS_SINGULAR.send(sender, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); - } else { - Message.CLEAR_SUCCESS.send(sender, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); - } + Message.CLEAR_SUCCESS.send(sender, target.getFormattedDisplayName(), context, changed); LoggedAction.build().source(sender).target(target) .description("clear", context) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderEditor.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderEditor.java index efe7c4e1f..628500b85 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderEditor.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderEditor.java @@ -29,12 +29,11 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.commands.misc.EditorCommand; import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; @@ -61,8 +60,8 @@ import java.util.Map; import java.util.UUID; public class HolderEditor extends ChildCommand { - public HolderEditor(LocaleManager locale, HolderType type) { - super(CommandSpec.HOLDER_EDITOR.localize(locale), "editor", type == HolderType.USER ? CommandPermission.USER_EDITOR : CommandPermission.GROUP_EDITOR, Predicates.alwaysFalse()); + public HolderEditor(HolderType type) { + super(CommandSpec.HOLDER_EDITOR, "editor", type == HolderType.USER ? CommandPermission.USER_EDITOR : CommandPermission.GROUP_EDITOR, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderShowTracks.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderShowTracks.java index 9cb749a8b..a0ab4ff51 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderShowTracks.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderShowTracks.java @@ -31,11 +31,9 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; @@ -44,6 +42,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; +import net.kyori.adventure.text.Component; import net.luckperms.api.node.Node; import net.luckperms.api.node.types.InheritanceNode; @@ -54,8 +53,8 @@ import java.util.Set; import java.util.stream.Collectors; public class HolderShowTracks extends ChildCommand { - public HolderShowTracks(LocaleManager locale, HolderType type) { - super(CommandSpec.HOLDER_SHOWTRACKS.localize(locale), "showtracks", type == HolderType.USER ? CommandPermission.USER_SHOW_TRACKS : CommandPermission.GROUP_SHOW_TRACKS, Predicates.alwaysFalse()); + public HolderShowTracks(HolderType type) { + super(CommandSpec.HOLDER_SHOWTRACKS, "showtracks", type == HolderType.USER ? CommandPermission.USER_SHOW_TRACKS : CommandPermission.GROUP_SHOW_TRACKS, Predicates.alwaysFalse()); } @Override @@ -73,7 +72,7 @@ public class HolderShowTracks extends ChildCommand> lines = new ArrayList<>(); + List> lines = new ArrayList<>(); if (target.getType() == HolderType.USER) { // if the holder is a user, we want to query parent groups for tracks @@ -88,8 +87,14 @@ public class HolderShowTracks extends ChildCommand t.containsGroup(groupName)) .collect(Collectors.toList()); - for (Track t : tracks) { - lines.add(Maps.immutableEntry(t, MessageUtils.getAppendableNodeContextString(plugin.getLocaleManager(), node) + "\n" + MessageUtils.listToArrowSep(t.getGroups(), groupName))); + for (Track track : tracks) { + Component line = Component.text() + .append(Message.formatContextSetBracketed(node.getContexts(), Component.empty())) + .append(Component.newline()) + .append(Message.formatTrackPath(track.getGroups(), groupName)) + .build(); + + lines.add(Maps.immutableEntry(track, line)); } } } else { @@ -99,8 +104,8 @@ public class HolderShowTracks extends ChildCommand t.containsGroup(groupName)) .collect(Collectors.toList()); - for (Track t : tracks) { - lines.add(Maps.immutableEntry(t, MessageUtils.listToArrowSep(t.getGroups(), groupName))); + for (Track track : tracks) { + lines.add(Maps.immutableEntry(track, Message.formatTrackPath(track.getGroups(), groupName))); } } @@ -110,7 +115,7 @@ public class HolderShowTracks extends ChildCommand line : lines) { + for (Map.Entry line : lines) { Message.LIST_TRACKS_ENTRY.send(sender, line.getKey().getName(), line.getValue()); } return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/CommandParent.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/CommandParent.java index e700952b9..0d4a78db5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/CommandParent.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/CommandParent.java @@ -29,26 +29,25 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.abstraction.GenericParentCommand; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import java.util.Collections; public class CommandParent extends GenericParentCommand { - public CommandParent(LocaleManager locale, HolderType type) { - super(CommandSpec.PARENT.localize(locale), "Parent", type, ImmutableList.builder() - .add(new ParentInfo(locale)) - .add(new ParentSet(locale)) - .add(new ParentAdd(locale)) - .add(new ParentRemove(locale)) - .add(new ParentSetTrack(locale)) - .add(new ParentAddTemp(locale)) - .add(new ParentRemoveTemp(locale)) - .add(new ParentClear(locale)) - .add(new ParentClearTrack(locale)) - .addAll(type == HolderType.USER ? Collections.singleton(new UserSwitchPrimaryGroup(locale)) : Collections.emptySet()) + public CommandParent(HolderType type) { + super(CommandSpec.PARENT, "Parent", type, ImmutableList.builder() + .add(new ParentInfo()) + .add(new ParentSet()) + .add(new ParentAdd()) + .add(new ParentRemove()) + .add(new ParentSetTrack()) + .add(new ParentAddTemp()) + .add(new ParentRemoveTemp()) + .add(new ParentClear()) + .add(new ParentClearTrack()) + .addAll(type == HolderType.USER ? Collections.singleton(new UserSwitchPrimaryGroup()) : Collections.emptySet()) .build()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java index e40b3d5fb..5bd4a75cb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.types.Inheritance; @@ -54,8 +52,8 @@ import net.luckperms.api.model.data.DataType; import java.util.List; public class ParentAdd extends GenericChildCommand { - public ParentAdd(LocaleManager locale) { - super(CommandSpec.PARENT_ADD.localize(locale), "add", CommandPermission.USER_PARENT_ADD, CommandPermission.GROUP_PARENT_ADD, Predicates.is(0)); + public ParentAdd() { + super(CommandSpec.PARENT_ADD, "add", CommandPermission.USER_PARENT_ADD, CommandPermission.GROUP_PARENT_ADD, Predicates.is(0)); } @Override @@ -84,7 +82,7 @@ public class ParentAdd extends GenericChildCommand { DataMutateResult result = target.setNode(DataType.NORMAL, Inheritance.builder(group.getName()).withContext(context).build(), true); if (result.wasSuccessful()) { - Message.SET_INHERIT_SUCCESS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.SET_INHERIT_SUCCESS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), context); LoggedAction.build().source(sender).target(target) .description("parent", "add", group.getName(), context) @@ -93,7 +91,7 @@ public class ParentAdd extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_INHERITS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.ALREADY_INHERITS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java index f20e6131b..beb51da15 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java @@ -31,22 +31,19 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.types.Inheritance; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.misc.DataConstraints; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Predicates; import net.luckperms.api.context.MutableContextSet; @@ -58,8 +55,8 @@ import java.time.Duration; import java.util.List; public class ParentAddTemp extends GenericChildCommand { - public ParentAddTemp(LocaleManager locale) { - super(CommandSpec.PARENT_ADD_TEMP.localize(locale), "addtemp", CommandPermission.USER_PARENT_ADD_TEMP, CommandPermission.GROUP_PARENT_ADD_TEMP, Predicates.inRange(0, 1)); + public ParentAddTemp() { + super(CommandSpec.PARENT_ADD_TEMP, "addtemp", CommandPermission.USER_PARENT_ADD_TEMP, CommandPermission.GROUP_PARENT_ADD_TEMP, Predicates.inRange(0, 1)); } @Override @@ -88,7 +85,7 @@ public class ParentAddTemp extends GenericChildCommand { } if (group.getName().equalsIgnoreCase(target.getObjectName())) { - Message.ALREADY_TEMP_INHERITS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.ALREADY_TEMP_INHERITS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), context); return CommandResult.STATE_ERROR; } @@ -96,7 +93,7 @@ public class ParentAddTemp extends GenericChildCommand { if (result.getResult().wasSuccessful()) { duration = result.getMergedNode().getExpiryDuration(); - Message.SET_TEMP_INHERIT_SUCCESS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), DurationFormatter.LONG.format(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.SET_TEMP_INHERIT_SUCCESS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), duration, context); LoggedAction.build().source(sender).target(target) .description("parent", "addtemp", group.getName(), duration, context) @@ -105,7 +102,7 @@ public class ParentAddTemp extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_TEMP_INHERITS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.ALREADY_TEMP_INHERITS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java index 5e8b36d3b..e5e7c76c1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -51,8 +49,8 @@ import net.luckperms.api.node.NodeType; import java.util.List; public class ParentClear extends GenericChildCommand { - public ParentClear(LocaleManager locale) { - super(CommandSpec.PARENT_CLEAR.localize(locale), "clear", CommandPermission.USER_PARENT_CLEAR, CommandPermission.GROUP_PARENT_CLEAR, Predicates.alwaysFalse()); + public ParentClear() { + super(CommandSpec.PARENT_CLEAR, "clear", CommandPermission.USER_PARENT_CLEAR, CommandPermission.GROUP_PARENT_CLEAR, Predicates.alwaysFalse()); } @Override @@ -78,11 +76,7 @@ public class ParentClear extends GenericChildCommand { } int changed = before - target.normalData().size(); - if (changed == 1) { - Message.PARENT_CLEAR_SUCCESS_SINGULAR.send(sender, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); - } else { - Message.PARENT_CLEAR_SUCCESS.send(sender, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); - } + Message.PARENT_CLEAR_SUCCESS.send(sender, target.getFormattedDisplayName(), context, changed); LoggedAction.build().source(sender).target(target) .description("parent", "clear", context) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java index eeb66cd4b..f9e9aa73d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; @@ -55,8 +53,8 @@ import net.luckperms.api.node.NodeType; import java.util.List; public class ParentClearTrack extends GenericChildCommand { - public ParentClearTrack(LocaleManager locale) { - super(CommandSpec.PARENT_CLEAR_TRACK.localize(locale), "cleartrack", CommandPermission.USER_PARENT_CLEAR_TRACK, CommandPermission.GROUP_PARENT_CLEAR_TRACK, Predicates.is(0)); + public ParentClearTrack() { + super(CommandSpec.PARENT_CLEAR_TRACK, "cleartrack", CommandPermission.USER_PARENT_CLEAR_TRACK, CommandPermission.GROUP_PARENT_CLEAR_TRACK, Predicates.is(0)); } @Override @@ -100,12 +98,7 @@ public class ParentClearTrack extends GenericChildCommand { } int changed = before - target.normalData().size(); - - if (changed == 1) { - Message.PARENT_CLEAR_TRACK_SUCCESS_SINGULAR.send(sender, target.getFormattedDisplayName(), track.getName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); - } else { - Message.PARENT_CLEAR_TRACK_SUCCESS.send(sender, target.getFormattedDisplayName(), track.getName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); - } + Message.PARENT_CLEAR_TRACK_SUCCESS.send(sender, target.getFormattedDisplayName(), track.getName(), context, changed); LoggedAction.build().source(sender).target(target) .description("parent", "cleartrack", track.getName(), context) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java index e06f71ab0..f7b08088e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java @@ -29,40 +29,29 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.SortMode; import me.lucko.luckperms.common.command.utils.SortType; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; -import me.lucko.luckperms.common.model.HolderType; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator; -import me.lucko.luckperms.common.node.factory.NodeCommandFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.query.QueryOptionsImpl; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Iterators; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.ComponentBuilder; -import net.kyori.text.TextComponent; -import net.kyori.text.event.ClickEvent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.node.types.InheritanceNode; import java.util.Collections; import java.util.Comparator; import java.util.LinkedList; import java.util.List; -import java.util.function.Consumer; public class ParentInfo extends GenericChildCommand { - public ParentInfo(LocaleManager locale) { - super(CommandSpec.PARENT_INFO.localize(locale), "info", CommandPermission.USER_PARENT_INFO, CommandPermission.GROUP_PARENT_INFO, Predicates.notInRange(0, 2)); + public ParentInfo() { + super(CommandSpec.PARENT_INFO, "info", CommandPermission.USER_PARENT_INFO, CommandPermission.GROUP_PARENT_INFO, Predicates.notInRange(0, 2)); } @Override @@ -113,13 +102,11 @@ public class ParentInfo extends GenericChildCommand { // send content for (InheritanceNode node : content) { - String s = "&3> &a" + node.getGroupName() + MessageUtils.getAppendableNodeContextString(plugin.getLocaleManager(), node); if (node.hasExpiry()) { - s += "\n&2 expires in " + DurationFormatter.LONG.format(node.getExpiryDuration()); + Message.PARENT_INFO_TEMPORARY_NODE_ENTRY.send(sender, node, target, label); + } else { + Message.PARENT_INFO_NODE_ENTRY.send(sender, node, target, label); } - - TextComponent message = TextUtils.fromLegacy(s, TextUtils.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(target, label, node)).build(); - sender.sendMessage(message); } return CommandResult.SUCCESS; @@ -134,22 +121,4 @@ public class ParentInfo extends GenericChildCommand { // fallback to priority return NodeWithContextComparator.reverse().compare(o1, o2); }; - - private static Consumer> makeFancy(PermissionHolder holder, String label, InheritanceNode node) { - HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( - "&3> &f" + node.getGroupName(), - " ", - "&7Click to remove this parent from " + holder.getPlainDisplayName() - ), TextUtils.AMPERSAND_CHAR)); - - String id = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); - boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, id, holder.getType(), explicitGlobalContext); - ClickEvent clickEvent = ClickEvent.suggestCommand(command); - - return component -> { - component.hoverEvent(hoverEvent); - component.clickEvent(clickEvent); - }; - } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java index e92c8ca27..f23fd1c78 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java @@ -31,15 +31,13 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; @@ -57,8 +55,8 @@ import net.luckperms.api.model.data.DataType; import java.util.List; public class ParentRemove extends GenericChildCommand { - public ParentRemove(LocaleManager locale) { - super(CommandSpec.PARENT_REMOVE.localize(locale), "remove", CommandPermission.USER_PARENT_REMOVE, CommandPermission.GROUP_PARENT_REMOVE, Predicates.is(0)); + public ParentRemove() { + super(CommandSpec.PARENT_REMOVE, "remove", CommandPermission.USER_PARENT_REMOVE, CommandPermission.GROUP_PARENT_REMOVE, Predicates.is(0)); } @Override @@ -95,7 +93,7 @@ public class ParentRemove extends GenericChildCommand { DataMutateResult result = target.unsetNode(DataType.NORMAL, Inheritance.builder(groupName).withContext(context).build()); if (result.wasSuccessful()) { - Message.UNSET_INHERIT_SUCCESS.send(sender, target.getFormattedDisplayName(), groupName, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.UNSET_INHERIT_SUCCESS.send(sender, target.getFormattedDisplayName(), groupName, context); LoggedAction.build().source(sender).target(target) .description("parent", "remove", groupName, context) @@ -108,7 +106,7 @@ public class ParentRemove extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_INHERIT.send(sender, target.getFormattedDisplayName(), groupName, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.DOES_NOT_INHERIT.send(sender, target.getFormattedDisplayName(), groupName, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java index 0e3a63e22..c249578a9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java @@ -31,20 +31,17 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.types.Inheritance; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.misc.DataConstraints; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Predicates; import net.luckperms.api.context.MutableContextSet; @@ -56,8 +53,8 @@ import java.time.Duration; import java.util.List; public class ParentRemoveTemp extends GenericChildCommand { - public ParentRemoveTemp(LocaleManager locale) { - super(CommandSpec.PARENT_REMOVE_TEMP.localize(locale), "removetemp", CommandPermission.USER_PARENT_REMOVE_TEMP, CommandPermission.GROUP_PARENT_REMOVE_TEMP, Predicates.is(0)); + public ParentRemoveTemp() { + super(CommandSpec.PARENT_REMOVE_TEMP, "removetemp", CommandPermission.USER_PARENT_REMOVE_TEMP, CommandPermission.GROUP_PARENT_REMOVE_TEMP, Predicates.is(0)); } @Override @@ -85,19 +82,13 @@ public class ParentRemoveTemp extends GenericChildCommand { Node mergedNode = result.getMergedNode(); //noinspection ConstantConditions if (mergedNode != null) { - Message.UNSET_TEMP_INHERIT_SUBTRACT_SUCCESS.send(sender, - target.getFormattedDisplayName(), - groupName, - DurationFormatter.LONG.format(mergedNode.getExpiryDuration()), - MessageUtils.contextSetToString(plugin.getLocaleManager(), context), - DurationFormatter.LONG.format(duration) - ); + Message.UNSET_TEMP_INHERIT_SUBTRACT_SUCCESS.send(sender, target.getFormattedDisplayName(), groupName, mergedNode.getExpiryDuration(), context, duration); LoggedAction.build().source(sender).target(target) .description("parent", "removetemp", groupName, duration, context) .build().submit(plugin, sender); } else { - Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, target.getFormattedDisplayName(), groupName, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, target.getFormattedDisplayName(), groupName, context); LoggedAction.build().source(sender).target(target) .description("parent", "removetemp", groupName, context) @@ -107,7 +98,7 @@ public class ParentRemoveTemp extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_TEMP_INHERIT.send(sender, target.getFormattedDisplayName(), groupName, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.DOES_NOT_TEMP_INHERIT.send(sender, target.getFormattedDisplayName(), groupName, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java index 3781f8b27..fb180e82d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; @@ -56,8 +54,8 @@ import net.luckperms.api.node.NodeType; import java.util.List; public class ParentSet extends GenericChildCommand { - public ParentSet(LocaleManager locale) { - super(CommandSpec.PARENT_SET.localize(locale), "set", CommandPermission.USER_PARENT_SET, CommandPermission.GROUP_PARENT_SET, Predicates.is(0)); + public ParentSet() { + super(CommandSpec.PARENT_SET, "set", CommandPermission.USER_PARENT_SET, CommandPermission.GROUP_PARENT_SET, Predicates.is(0)); } @Override @@ -89,7 +87,7 @@ public class ParentSet extends GenericChildCommand { ((User) target).getPrimaryGroup().setStoredValue(group.getName()); } - Message.SET_PARENT_SUCCESS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.SET_PARENT_SUCCESS.send(sender, target.getFormattedDisplayName(), group.getFormattedDisplayName(), context); LoggedAction.build().source(sender).target(target) .description("parent", "set", group.getName(), context) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java index 2be6cdf5c..54817e23f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; @@ -55,8 +53,8 @@ import net.luckperms.api.node.NodeType; import java.util.List; public class ParentSetTrack extends GenericChildCommand { - public ParentSetTrack(LocaleManager locale) { - super(CommandSpec.PARENT_SET_TRACK.localize(locale), "settrack", CommandPermission.USER_PARENT_SET_TRACK, CommandPermission.GROUP_PARENT_SET_TRACK, Predicates.inRange(0, 1)); + public ParentSetTrack() { + super(CommandSpec.PARENT_SET_TRACK, "settrack", CommandPermission.USER_PARENT_SET_TRACK, CommandPermission.GROUP_PARENT_SET_TRACK, Predicates.inRange(0, 1)); } @Override @@ -87,7 +85,7 @@ public class ParentSetTrack extends GenericChildCommand { if (index > 0) { List trackGroups = track.getGroups(); if ((index - 1) >= trackGroups.size()) { - Message.DOES_NOT_EXIST.send(sender, index); + Message.DOES_NOT_EXIST.send(sender, String.valueOf(index)); return CommandResult.INVALID_ARGS; } groupName = track.getGroups().get(index - 1); @@ -117,7 +115,7 @@ public class ParentSetTrack extends GenericChildCommand { target.removeIf(DataType.NORMAL, context, NodeType.INHERITANCE.predicate(n -> track.containsGroup(n.getGroupName())), false); target.setNode(DataType.NORMAL, Inheritance.builder(group.getName()).withContext(context).build(), true); - Message.SET_TRACK_PARENT_SUCCESS.send(sender, target.getFormattedDisplayName(), track.getName(), group.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.SET_TRACK_PARENT_SUCCESS.send(sender, target.getFormattedDisplayName(), track.getName(), group.getFormattedDisplayName(), context); LoggedAction.build().source(sender).target(target) .description("parent", "settrack", track.getName(), groupName, context) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java index 5bcc4b63b..88665dbe7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java @@ -30,15 +30,14 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; @@ -55,8 +54,8 @@ import net.luckperms.api.node.NodeEqualityPredicate; import java.util.List; public class UserSwitchPrimaryGroup extends GenericChildCommand { - public UserSwitchPrimaryGroup(LocaleManager locale) { - super(CommandSpec.USER_SWITCHPRIMARYGROUP.localize(locale), "switchprimarygroup", CommandPermission.USER_PARENT_SWITCHPRIMARYGROUP, null, Predicates.not(1)); + public UserSwitchPrimaryGroup() { + super(CommandSpec.USER_SWITCHPRIMARYGROUP, "switchprimarygroup", CommandPermission.USER_PARENT_SWITCHPRIMARYGROUP, null, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/CommandPermission.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/CommandPermission.java index e0539d725..09d9590ac 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/CommandPermission.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/CommandPermission.java @@ -29,22 +29,21 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.abstraction.GenericParentCommand; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; public class CommandPermission extends GenericParentCommand { - public CommandPermission(LocaleManager locale, HolderType type) { - super(CommandSpec.PERMISSION.localize(locale), "Permission", type, ImmutableList.builder() - .add(new PermissionInfo(locale)) - .add(new PermissionSet(locale)) - .add(new PermissionUnset(locale)) - .add(new PermissionSetTemp(locale)) - .add(new PermissionUnsetTemp(locale)) - .add(new PermissionCheck(locale)) - .add(new PermissionCheckInherits(locale)) - .add(new PermissionClear(locale)) + public CommandPermission(HolderType type) { + super(CommandSpec.PERMISSION, "Permission", type, ImmutableList.builder() + .add(new PermissionInfo()) + .add(new PermissionSet()) + .add(new PermissionUnset()) + .add(new PermissionSetTemp()) + .add(new PermissionUnsetTemp()) + .add(new PermissionCheck()) + .add(new PermissionCheckInherits()) + .add(new PermissionClear()) .build()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheck.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheck.java index ef468c9e3..aba036af6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheck.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheck.java @@ -30,13 +30,11 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.factory.NodeBuilders; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -51,8 +49,8 @@ import net.luckperms.api.util.Tristate; import java.util.List; public class PermissionCheck extends GenericChildCommand { - public PermissionCheck(LocaleManager locale) { - super(CommandSpec.PERMISSION_CHECK.localize(locale), "check", CommandPermission.USER_PERM_CHECK, CommandPermission.GROUP_PERM_CHECK, Predicates.is(0)); + public PermissionCheck() { + super(CommandSpec.PERMISSION_CHECK, "check", CommandPermission.USER_PERM_CHECK, CommandPermission.GROUP_PERM_CHECK, Predicates.is(0)); } @Override @@ -66,9 +64,7 @@ public class PermissionCheck extends GenericChildCommand { MutableContextSet context = args.getContextOrDefault(1, plugin); Tristate result = target.hasNode(DataType.NORMAL, NodeBuilders.determineMostApplicable(node).withContext(context).build(), NodeEqualityPredicate.IGNORE_VALUE_OR_IF_TEMPORARY); - String s = MessageUtils.formatTristate(result); - - Message.CHECK_PERMISSION.send(sender, target.getFormattedDisplayName(), node, s, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.CHECK_PERMISSION.send(sender, target.getFormattedDisplayName(), node, result, context); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheckInherits.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheckInherits.java index 050a0ae00..83f311fc3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheckInherits.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheckInherits.java @@ -30,13 +30,11 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.query.QueryOptionsImpl; @@ -52,8 +50,8 @@ import java.util.List; import java.util.Optional; public class PermissionCheckInherits extends GenericChildCommand { - public PermissionCheckInherits(LocaleManager locale) { - super(CommandSpec.PERMISSION_CHECK_INHERITS.localize(locale), "checkinherits", CommandPermission.USER_PERM_CHECK_INHERITS, CommandPermission.GROUP_PERM_CHECK_INHERITS, Predicates.is(0)); + public PermissionCheckInherits() { + super(CommandSpec.PERMISSION_CHECK_INHERITS, "checkinherits", CommandPermission.USER_PERM_CHECK_INHERITS, CommandPermission.GROUP_PERM_CHECK_INHERITS, Predicates.is(0)); } @Override @@ -76,8 +74,8 @@ public class PermissionCheckInherits extends GenericChildCommand { location = "self"; } - String s = MessageUtils.formatTristate(match.map(n -> Tristate.of(n.getValue())).orElse(Tristate.UNDEFINED)); - Message.CHECK_INHERITS_PERMISSION.send(sender, target.getFormattedDisplayName(), node, s, MessageUtils.contextSetToString(plugin.getLocaleManager(), context), location); + Tristate result = match.map(n -> Tristate.of(n.getValue())).orElse(Tristate.UNDEFINED); + Message.CHECK_INHERITS_PERMISSION.send(sender, target.getFormattedDisplayName(), node, result, context, location); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java index b4d604d89..4e052b6cd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -51,8 +49,8 @@ import net.luckperms.api.node.NodeType; import java.util.List; public class PermissionClear extends GenericChildCommand { - public PermissionClear(LocaleManager locale) { - super(CommandSpec.PERMISSION_CLEAR.localize(locale), "clear", CommandPermission.USER_PERM_CLEAR, CommandPermission.GROUP_PERM_CLEAR, Predicates.alwaysFalse()); + public PermissionClear() { + super(CommandSpec.PERMISSION_CLEAR, "clear", CommandPermission.USER_PERM_CLEAR, CommandPermission.GROUP_PERM_CLEAR, Predicates.alwaysFalse()); } @Override @@ -75,11 +73,7 @@ public class PermissionClear extends GenericChildCommand { target.removeIf(DataType.NORMAL, context.isEmpty() ? null : context, NodeType.PERMISSION::matches, false); int changed = before - target.normalData().size(); - if (changed == 1) { - Message.PERMISSION_CLEAR_SUCCESS_SINGULAR.send(sender, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); - } else { - Message.PERMISSION_CLEAR_SUCCESS.send(sender, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); - } + Message.PERMISSION_CLEAR_SUCCESS.send(sender, target.getFormattedDisplayName(), context, changed); LoggedAction.build().source(sender).target(target) .description("permission", "clear", context) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionInfo.java index f4bd99831..800a26cf4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionInfo.java @@ -29,28 +29,18 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.SortMode; import me.lucko.luckperms.common.command.utils.SortType; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; -import me.lucko.luckperms.common.model.HolderType; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator; -import me.lucko.luckperms.common.node.factory.NodeCommandFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Iterators; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.ComponentBuilder; -import net.kyori.text.TextComponent; -import net.kyori.text.event.ClickEvent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.node.Node; import net.luckperms.api.node.NodeType; @@ -58,11 +48,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; -import java.util.function.Consumer; public class PermissionInfo extends GenericChildCommand { - public PermissionInfo(LocaleManager locale) { - super(CommandSpec.PERMISSION_INFO.localize(locale), "info", CommandPermission.USER_PERM_INFO, CommandPermission.GROUP_PERM_INFO, Predicates.notInRange(0, 2)); + public PermissionInfo() { + super(CommandSpec.PERMISSION_INFO, "info", CommandPermission.USER_PERM_INFO, CommandPermission.GROUP_PERM_INFO, Predicates.notInRange(0, 2)); } @Override @@ -113,13 +102,11 @@ public class PermissionInfo extends GenericChildCommand { // send content for (Node node : content) { - String s = "&3> " + (node.getValue() ? "&a" : "&c") + node.getKey() + (sender.isConsole() ? " &7(" + node.getValue() + "&7)" : "") + MessageUtils.getAppendableNodeContextString(plugin.getLocaleManager(), node); if (node.hasExpiry()) { - s += "\n&2- expires in " + DurationFormatter.LONG.format(node.getExpiryDuration()); + Message.PERMISSION_INFO_TEMPORARY_NODE_ENTRY.send(sender, node, target, label); + } else { + Message.PERMISSION_INFO_NODE_ENTRY.send(sender, node, target, label); } - - TextComponent message = TextUtils.fromLegacy(s, TextUtils.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(target, label, node)).build(); - sender.sendMessage(message); } return CommandResult.SUCCESS; @@ -134,22 +121,4 @@ public class PermissionInfo extends GenericChildCommand { // fallback to priority return NodeWithContextComparator.reverse().compare(o1, o2); }; - - private static Consumer> makeFancy(PermissionHolder holder, String label, Node node) { - HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( - "§3> " + (node.getValue() ? "§a" : "§c") + node.getKey(), - " ", - "§7Click to remove this node from " + holder.getPlainDisplayName() - ), '§')); - - String id = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); - boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, id, holder.getType(), explicitGlobalContext); - ClickEvent clickEvent = ClickEvent.suggestCommand(command); - - return component -> { - component.hoverEvent(hoverEvent); - component.clickEvent(clickEvent); - }; - } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java index 10326fd8e..ca87d3ce9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.factory.NodeBuilders; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -54,8 +52,8 @@ import net.luckperms.api.node.types.InheritanceNode; import java.util.List; public class PermissionSet extends GenericChildCommand { - public PermissionSet(LocaleManager locale) { - super(CommandSpec.PERMISSION_SET.localize(locale), "set", CommandPermission.USER_PERM_SET, CommandPermission.GROUP_PERM_SET, Predicates.is(0)); + public PermissionSet() { + super(CommandSpec.PERMISSION_SET, "set", CommandPermission.USER_PERM_SET, CommandPermission.GROUP_PERM_SET, Predicates.is(0)); } @Override @@ -88,7 +86,7 @@ public class PermissionSet extends GenericChildCommand { DataMutateResult result = target.setNode(DataType.NORMAL, builtNode, true); if (result.wasSuccessful()) { - Message.SETPERMISSION_SUCCESS.send(sender, node, value, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.SETPERMISSION_SUCCESS.send(sender, node, value, target.getFormattedDisplayName(), context); LoggedAction.build().source(sender).target(target) .description("permission", "set", node, value, context) @@ -97,7 +95,7 @@ public class PermissionSet extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_HASPERMISSION.send(sender, target.getFormattedDisplayName(), node, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.ALREADY_HASPERMISSION.send(sender, target.getFormattedDisplayName(), node, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java index 49076468f..76311539b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java @@ -31,20 +31,17 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.factory.NodeBuilders; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Predicates; import net.luckperms.api.context.MutableContextSet; @@ -58,8 +55,8 @@ import java.time.Duration; import java.util.List; public class PermissionSetTemp extends GenericChildCommand { - public PermissionSetTemp(LocaleManager locale) { - super(CommandSpec.PERMISSION_SETTEMP.localize(locale), "settemp", CommandPermission.USER_PERM_SET_TEMP, CommandPermission.GROUP_PERM_SET_TEMP, Predicates.inRange(0, 2)); + public PermissionSetTemp() { + super(CommandSpec.PERMISSION_SETTEMP, "settemp", CommandPermission.USER_PERM_SET_TEMP, CommandPermission.GROUP_PERM_SET_TEMP, Predicates.inRange(0, 2)); } @Override @@ -95,7 +92,7 @@ public class PermissionSetTemp extends GenericChildCommand { if (result.getResult().wasSuccessful()) { duration = result.getMergedNode().getExpiryDuration(); - Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, value, target.getFormattedDisplayName(), DurationFormatter.LONG.format(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, value, target.getFormattedDisplayName(), duration, context); LoggedAction.build().source(sender).target(target) .description("permission", "settemp", node, value, duration, context) @@ -104,7 +101,7 @@ public class PermissionSetTemp extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_HAS_TEMP_PERMISSION.send(sender, target.getFormattedDisplayName(), node, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.ALREADY_HAS_TEMP_PERMISSION.send(sender, target.getFormattedDisplayName(), node, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java index 4f63f0d8e..5e7234246 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.factory.NodeBuilders; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -54,8 +52,8 @@ import net.luckperms.api.node.types.InheritanceNode; import java.util.List; public class PermissionUnset extends GenericChildCommand { - public PermissionUnset(LocaleManager locale) { - super(CommandSpec.PERMISSION_UNSET.localize(locale), "unset", CommandPermission.USER_PERM_UNSET, CommandPermission.GROUP_PERM_UNSET, Predicates.is(0)); + public PermissionUnset() { + super(CommandSpec.PERMISSION_UNSET, "unset", CommandPermission.USER_PERM_UNSET, CommandPermission.GROUP_PERM_UNSET, Predicates.is(0)); } @Override @@ -87,7 +85,7 @@ public class PermissionUnset extends GenericChildCommand { DataMutateResult result = target.unsetNode(DataType.NORMAL, builtNode); if (result.wasSuccessful()) { - Message.UNSETPERMISSION_SUCCESS.send(sender, node, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.UNSETPERMISSION_SUCCESS.send(sender, node, target.getFormattedDisplayName(), context); LoggedAction.build().source(sender).target(target) .description("permission", "unset", node, context) @@ -96,7 +94,7 @@ public class PermissionUnset extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_HAVE_PERMISSION.send(sender, target.getFormattedDisplayName(), node, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.DOES_NOT_HAVE_PERMISSION.send(sender, target.getFormattedDisplayName(), node, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java index 866f0c31e..9ed46173a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java @@ -31,19 +31,16 @@ import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.GenericChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.factory.NodeBuilders; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Predicates; import net.luckperms.api.context.MutableContextSet; @@ -56,8 +53,8 @@ import java.time.Duration; import java.util.List; public class PermissionUnsetTemp extends GenericChildCommand { - public PermissionUnsetTemp(LocaleManager locale) { - super(CommandSpec.PERMISSION_UNSETTEMP.localize(locale), "unsettemp", CommandPermission.USER_PERM_UNSET_TEMP, CommandPermission.GROUP_PERM_UNSET_TEMP, Predicates.is(0)); + public PermissionUnsetTemp() { + super(CommandSpec.PERMISSION_UNSETTEMP, "unsettemp", CommandPermission.USER_PERM_UNSET_TEMP, CommandPermission.GROUP_PERM_UNSET_TEMP, Predicates.is(0)); } @Override @@ -93,20 +90,13 @@ public class PermissionUnsetTemp extends GenericChildCommand { Node mergedNode = result.getMergedNode(); //noinspection ConstantConditions if (mergedNode != null) { - Message.UNSET_TEMP_PERMISSION_SUBTRACT_SUCCESS.send(sender, - mergedNode.getKey(), - mergedNode.getValue(), - target.getFormattedDisplayName(), - DurationFormatter.LONG.format(mergedNode.getExpiryDuration()), - MessageUtils.contextSetToString(plugin.getLocaleManager(), context), - DurationFormatter.LONG.format(duration) - ); + Message.UNSET_TEMP_PERMISSION_SUBTRACT_SUCCESS.send(sender, mergedNode.getKey(), mergedNode.getValue(), target.getFormattedDisplayName(), mergedNode.getExpiryDuration(), context, duration); LoggedAction.build().source(sender).target(target) .description("permission", "unsettemp", node, duration, context) .build().submit(plugin, sender); } else { - Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, target.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, target.getFormattedDisplayName(), context); LoggedAction.build().source(sender).target(target) .description("permission", "unsettemp", node, context) @@ -116,7 +106,7 @@ public class PermissionUnsetTemp extends GenericChildCommand { StorageAssistant.save(target, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_HAVE_TEMP_PERMISSION.send(sender, target.getFormattedDisplayName(), node, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.DOES_NOT_HAVE_TEMP_PERMISSION.send(sender, target.getFormattedDisplayName(), node, context); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/CreateGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/CreateGroup.java index fc395d878..3da86bc8d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/CreateGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/CreateGroup.java @@ -29,10 +29,9 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.misc.DataConstraints; @@ -42,8 +41,8 @@ import net.luckperms.api.actionlog.Action; import net.luckperms.api.event.cause.CreationCause; public class CreateGroup extends SingleCommand { - public CreateGroup(LocaleManager locale) { - super(CommandSpec.CREATE_GROUP.localize(locale), "CreateGroup", CommandPermission.CREATE_GROUP, Predicates.not(1)); + public CreateGroup() { + super(CommandSpec.CREATE_GROUP, "CreateGroup", CommandPermission.CREATE_GROUP, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/DeleteGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/DeleteGroup.java index 4581c0b85..aef3c0c24 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/DeleteGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/DeleteGroup.java @@ -29,12 +29,11 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.manager.group.GroupManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -47,8 +46,8 @@ import net.luckperms.api.event.cause.DeletionCause; import java.util.List; public class DeleteGroup extends SingleCommand { - public DeleteGroup(LocaleManager locale) { - super(CommandSpec.DELETE_GROUP.localize(locale), "DeleteGroup", CommandPermission.DELETE_GROUP, Predicates.not(1)); + public DeleteGroup() { + super(CommandSpec.DELETE_GROUP, "DeleteGroup", CommandPermission.DELETE_GROUP, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupClone.java index 8399077d2..ec4f8c361 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupClone.java @@ -30,11 +30,10 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -45,8 +44,8 @@ import net.luckperms.api.event.cause.CreationCause; import net.luckperms.api.model.data.DataType; public class GroupClone extends ChildCommand { - public GroupClone(LocaleManager locale) { - super(CommandSpec.GROUP_CLONE.localize(locale), "clone", CommandPermission.GROUP_CLONE, Predicates.not(1)); + public GroupClone() { + super(CommandSpec.GROUP_CLONE, "clone", CommandPermission.GROUP_CLONE, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupInfo.java index 04cd1b29d..9672acec6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupInfo.java @@ -25,22 +25,17 @@ package me.lucko.luckperms.common.commands.group; -import com.google.common.collect.Maps; - import me.lucko.luckperms.common.cacheddata.type.MetaCache; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Predicates; import me.lucko.luckperms.common.verbose.event.MetaCheckEvent; @@ -53,8 +48,8 @@ import java.util.Map; import java.util.stream.Collectors; public class GroupInfo extends ChildCommand { - public GroupInfo(LocaleManager locale) { - super(CommandSpec.GROUP_INFO.localize(locale), "info", CommandPermission.GROUP_INFO, Predicates.alwaysFalse()); + public GroupInfo() { + super(CommandSpec.GROUP_INFO, "info", CommandPermission.GROUP_INFO, Predicates.alwaysFalse()); } @Override @@ -64,11 +59,7 @@ public class GroupInfo extends ChildCommand { return CommandResult.NO_PERMISSION; } - Message.GROUP_INFO_GENERAL.send(sender, - target.getName(), - target.getPlainDisplayName(), - target.getWeight().isPresent() ? target.getWeight().getAsInt() : "None" - ); + Message.GROUP_INFO_GENERAL.send(sender, target.getName(), target.getPlainDisplayName(), target.getWeight()); List parents = target.normalData().inheritanceAsSortedSet().stream() .filter(Node::getValue) @@ -83,41 +74,22 @@ public class GroupInfo extends ChildCommand { if (!parents.isEmpty()) { Message.INFO_PARENT_HEADER.send(sender); for (InheritanceNode node : parents) { - Message.INFO_PARENT_ENTRY.send(sender, node.getGroupName(), MessageUtils.getAppendableNodeContextString(plugin.getLocaleManager(), node)); + Message.INFO_PARENT_NODE_ENTRY.send(sender, node); } } if (!tempParents.isEmpty()) { Message.INFO_TEMP_PARENT_HEADER.send(sender); for (InheritanceNode node : tempParents) { - Message.INFO_PARENT_ENTRY.send(sender, node.getGroupName(), MessageUtils.getAppendableNodeContextString(plugin.getLocaleManager(), node)); - Message.INFO_PARENT_ENTRY_EXPIRY.send(sender, DurationFormatter.LONG.format(node.getExpiryDuration())); + Message.INFO_PARENT_TEMPORARY_NODE_ENTRY.send(sender, node); } } QueryOptions queryOptions = plugin.getContextManager().getStaticQueryOptions(); - - String prefix = "&bNone"; - String suffix = "&bNone"; - String meta = "&bNone"; - MetaCache data = target.getCachedData().getMetaData(queryOptions); - String prefixValue = data.getPrefix(MetaCheckEvent.Origin.INTERNAL); - if (prefixValue != null) { - prefix = "&f\"" + prefixValue + "&f\""; - } - String sussexValue = data.getSuffix(MetaCheckEvent.Origin.INTERNAL); - if (sussexValue != null) { - suffix = "&f\"" + sussexValue + "&f\""; - } - - Map> metaMap = data.getMeta(MetaCheckEvent.Origin.INTERNAL); - if (!metaMap.isEmpty()) { - meta = metaMap.entrySet().stream() - .flatMap(entry -> entry.getValue().stream().map(value -> Maps.immutableEntry(entry.getKey(), value))) - .map(e -> MessageUtils.contextToString(plugin.getLocaleManager(), e.getKey(), e.getValue())) - .collect(Collectors.joining(" ")); - } + String prefix = data.getPrefix(MetaCheckEvent.Origin.INTERNAL); + String suffix = data.getSuffix(MetaCheckEvent.Origin.INTERNAL); + Map> meta = data.getMeta(MetaCheckEvent.Origin.INTERNAL); Message.GROUP_INFO_CONTEXTUAL_DATA.send(sender, prefix, suffix, meta); return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupListMembers.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupListMembers.java index 335fffdd6..7cd44a210 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupListMembers.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupListMembers.java @@ -32,47 +32,36 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.model.manager.group.GroupManager; import me.lucko.luckperms.common.node.comparator.NodeEntryComparator; -import me.lucko.luckperms.common.node.factory.NodeCommandFactory; import me.lucko.luckperms.common.node.matcher.ConstraintNodeMatcher; import me.lucko.luckperms.common.node.matcher.StandardNodeMatchers; import me.lucko.luckperms.common.node.types.Inheritance; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.misc.NodeEntry; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Iterators; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.ComponentBuilder; -import net.kyori.text.TextComponent; -import net.kyori.text.event.ClickEvent; -import net.kyori.text.event.HoverEvent; -import net.luckperms.api.node.Node; import net.luckperms.api.node.types.InheritanceNode; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; -import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; public class GroupListMembers extends ChildCommand { - public GroupListMembers(LocaleManager locale) { - super(CommandSpec.GROUP_LISTMEMBERS.localize(locale), "listmembers", CommandPermission.GROUP_LIST_MEMBERS, Predicates.notInRange(0, 1)); + public GroupListMembers() { + super(CommandSpec.GROUP_LISTMEMBERS, "listmembers", CommandPermission.GROUP_LIST_MEMBERS, Predicates.notInRange(0, 1)); } @Override @@ -140,7 +129,7 @@ public class GroupListMembers extends ChildCommand { return CommandResult.SUCCESS; } - private static > void sendResult(Sender sender, List> results, Function lookupFunction, Message headerMessage, HolderType holderType, String label, int page) { + private static > void sendResult(Sender sender, List> results, Function lookupFunction, Message.Args3 headerMessage, HolderType holderType, String label, int page) { results = new ArrayList<>(results); results.sort(NodeEntryComparator.normal()); @@ -162,34 +151,7 @@ public class GroupListMembers extends ChildCommand { headerMessage.send(sender, page, pages.size(), results.size()); for (Map.Entry> ent : mappedContent) { - String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().getNode()) + MessageUtils.getAppendableNodeContextString(sender.getPlugin().getLocaleManager(), ent.getValue().getNode()); - TextComponent message = TextUtils.fromLegacy(s, TextUtils.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue(), sender.getPlugin())).build(); - sender.sendMessage(message); + Message.SEARCH_INHERITS_NODE_ENTRY.send(sender, ent.getValue().getNode(), ent.getKey(), holderType, label, sender.getPlugin()); } } - - private static String getNodeExpiryString(Node node) { - if (!node.hasExpiry()) { - return ""; - } - - return " &8(&7expires in " + DurationFormatter.LONG.format(node.getExpiryDuration()) + "&8)"; - } - - private static Consumer> makeFancy(String holderName, HolderType holderType, String label, NodeEntry perm, LuckPermsPlugin plugin) { - HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( - "&3> &b" + ((InheritanceNode) perm.getNode()).getGroupName(), - " ", - "&7Click to remove this parent from " + holderName - ), TextUtils.AMPERSAND_CHAR)); - - boolean explicitGlobalContext = !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - String command = "/" + label + " " + NodeCommandFactory.undoCommand(perm.getNode(), holderName, holderType, explicitGlobalContext); - ClickEvent clickEvent = ClickEvent.suggestCommand(command); - - return component -> { - component.hoverEvent(hoverEvent); - component.clickEvent(clickEvent); - }; - } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupParentCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupParentCommand.java index 1abd8f69a..8262a55e0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupParentCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupParentCommand.java @@ -30,6 +30,7 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.command.abstraction.Command; import me.lucko.luckperms.common.command.abstraction.ParentCommand; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.commands.generic.meta.CommandMeta; import me.lucko.luckperms.common.commands.generic.other.HolderClear; @@ -37,8 +38,6 @@ import me.lucko.luckperms.common.commands.generic.other.HolderEditor; import me.lucko.luckperms.common.commands.generic.other.HolderShowTracks; import me.lucko.luckperms.common.commands.generic.parent.CommandParent; import me.lucko.luckperms.common.commands.generic.permission.CommandPermission; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -60,20 +59,20 @@ public class GroupParentCommand extends ParentCommand { .expireAfterAccess(1, TimeUnit.HOURS) .build(key -> new ReentrantLock()); - public GroupParentCommand(LocaleManager locale) { - super(CommandSpec.GROUP.localize(locale), "Group", Type.TAKES_ARGUMENT_FOR_TARGET, ImmutableList.>builder() - .add(new GroupInfo(locale)) - .add(new CommandPermission<>(locale, HolderType.GROUP)) - .add(new CommandParent<>(locale, HolderType.GROUP)) - .add(new CommandMeta<>(locale, HolderType.GROUP)) - .add(new HolderEditor<>(locale, HolderType.GROUP)) - .add(new GroupListMembers(locale)) - .add(new GroupSetWeight(locale)) - .add(new GroupSetDisplayName(locale)) - .add(new HolderShowTracks<>(locale, HolderType.GROUP)) - .add(new HolderClear<>(locale, HolderType.GROUP)) - .add(new GroupRename(locale)) - .add(new GroupClone(locale)) + public GroupParentCommand() { + super(CommandSpec.GROUP, "Group", Type.TAKES_ARGUMENT_FOR_TARGET, ImmutableList.>builder() + .add(new GroupInfo()) + .add(new CommandPermission<>(HolderType.GROUP)) + .add(new CommandParent<>(HolderType.GROUP)) + .add(new CommandMeta<>(HolderType.GROUP)) + .add(new HolderEditor<>(HolderType.GROUP)) + .add(new GroupListMembers()) + .add(new GroupSetWeight()) + .add(new GroupSetDisplayName()) + .add(new HolderShowTracks<>(HolderType.GROUP)) + .add(new HolderClear<>(HolderType.GROUP)) + .add(new GroupRename()) + .add(new GroupClone()) .build() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupRename.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupRename.java index f76a09343..5e7c7123a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupRename.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupRename.java @@ -29,11 +29,10 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -45,8 +44,8 @@ import net.luckperms.api.event.cause.DeletionCause; import net.luckperms.api.model.data.DataType; public class GroupRename extends ChildCommand { - public GroupRename(LocaleManager locale) { - super(CommandSpec.GROUP_RENAME.localize(locale), "rename", CommandPermission.GROUP_RENAME, Predicates.not(1)); + public GroupRename() { + super(CommandSpec.GROUP_RENAME, "rename", CommandPermission.GROUP_RENAME, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java index 7f9a35e89..88bfe52b2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.node.types.DisplayName; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -53,8 +51,8 @@ import net.luckperms.api.node.types.DisplayNameNode; import java.util.List; public class GroupSetDisplayName extends ChildCommand { - public GroupSetDisplayName(LocaleManager locale) { - super(CommandSpec.GROUP_SET_DISPLAY_NAME.localize(locale), "setdisplayname", CommandPermission.GROUP_SET_DISPLAY_NAME, Predicates.is(0)); + public GroupSetDisplayName() { + super(CommandSpec.GROUP_SET_DISPLAY_NAME, "setdisplayname", CommandPermission.GROUP_SET_DISPLAY_NAME, Predicates.is(0)); } @Override @@ -93,7 +91,7 @@ public class GroupSetDisplayName extends ChildCommand { target.removeIf(DataType.NORMAL, context, NodeType.DISPLAY_NAME::matches, false); if (name.equals(target.getName())) { - Message.GROUP_SET_DISPLAY_NAME_REMOVED.send(sender, target.getName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.GROUP_SET_DISPLAY_NAME_REMOVED.send(sender, target.getName(), context); LoggedAction.build().source(sender).target(target) .description("setdisplayname", name, context) @@ -105,7 +103,7 @@ public class GroupSetDisplayName extends ChildCommand { target.setNode(DataType.NORMAL, DisplayName.builder(name).withContext(context).build(), true); - Message.GROUP_SET_DISPLAY_NAME.send(sender, name, target.getName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.GROUP_SET_DISPLAY_NAME.send(sender, name, target.getName(), context); LoggedAction.build().source(sender).target(target) .description("setdisplayname", name, context) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java index 1c3b6be95..f8a695550 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java @@ -31,11 +31,10 @@ import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.node.types.Weight; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -46,8 +45,8 @@ import net.luckperms.api.model.data.DataType; import net.luckperms.api.node.NodeType; public class GroupSetWeight extends ChildCommand { - public GroupSetWeight(LocaleManager locale) { - super(CommandSpec.GROUP_SETWEIGHT.localize(locale), "setweight", CommandPermission.GROUP_SET_WEIGHT, Predicates.not(1)); + public GroupSetWeight() { + super(CommandSpec.GROUP_SETWEIGHT, "setweight", CommandPermission.GROUP_SET_WEIGHT, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/ListGroups.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/ListGroups.java index 9aced2747..b30ad4dba 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/ListGroups.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/ListGroups.java @@ -28,32 +28,24 @@ package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; -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.stream.Collectors; public class ListGroups extends SingleCommand { - public ListGroups(LocaleManager locale) { - super(CommandSpec.LIST_GROUPS.localize(locale), "ListGroups", CommandPermission.LIST_GROUPS, Predicates.alwaysFalse()); + public ListGroups() { + super(CommandSpec.LIST_GROUPS, "ListGroups", CommandPermission.LIST_GROUPS, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, ArgumentList args, String label) { - try { plugin.getStorage().loadAllGroups().get(); } catch (Exception e) { @@ -70,27 +62,7 @@ public class ListGroups extends SingleCommand { }) .forEach(group -> { List tracks = plugin.getTrackManager().getAll().values().stream().filter(t -> t.containsGroup(group)).map(Track::getName).collect(Collectors.toList()); - TextComponent component; - - if (tracks.isEmpty()) { - component = Message.GROUPS_LIST_ENTRY.asComponent(plugin.getLocaleManager(), - group.getFormattedDisplayName(), - group.getWeight().orElse(0) - ); - } else { - component = Message.GROUPS_LIST_ENTRY_WITH_TRACKS.asComponent(plugin.getLocaleManager(), - group.getFormattedDisplayName(), - group.getWeight().orElse(0), - MessageUtils.toCommaSep(tracks) - ); - } - - component = component.toBuilder().applyDeep(c -> { - c.clickEvent(ClickEvent.runCommand("/" + label + " group " + group.getName() + " info")); - c.hoverEvent(HoverEvent.showText(TextComponent.of("Click to view more info about " + group.getName() + ".").color(TextColor.GRAY))); - }).build(); - - sender.sendMessage(component); + Message.GROUPS_LIST_ENTRY.send(sender, group.getFormattedDisplayName(), group.getWeight().orElse(0), tracks); }); return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogGroupHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogGroupHistory.java index 0587a21b9..1112bcdb1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogGroupHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogGroupHistory.java @@ -30,16 +30,14 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.misc.DataConstraints; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Paginated; import me.lucko.luckperms.common.util.Predicates; @@ -48,8 +46,8 @@ import java.util.List; public class LogGroupHistory extends ChildCommand { private static final int ENTRIES_PER_PAGE = 10; - public LogGroupHistory(LocaleManager locale) { - super(CommandSpec.LOG_GROUP_HISTORY.localize(locale), "grouphistory", CommandPermission.LOG_GROUP_HISTORY, Predicates.notInRange(1, 2)); + public LogGroupHistory() { + super(CommandSpec.LOG_GROUP_HISTORY, "grouphistory", CommandPermission.LOG_GROUP_HISTORY, Predicates.notInRange(1, 2)); } @Override @@ -91,14 +89,7 @@ public class LogGroupHistory extends ChildCommand { Message.LOG_HISTORY_GROUP_HEADER.send(sender, name, page, maxPage); for (Paginated.Entry e : entries) { - Message.LOG_ENTRY.send(sender, - e.position(), - DurationFormatter.CONCISE_LOW_ACCURACY.format(e.value().getDurationSince()), - e.value().getSourceFriendlyString(), - Character.toString(LoggedAction.getTypeCharacter(e.value().getTarget().getType())), - e.value().getTargetFriendlyString(), - e.value().getDescription() - ); + Message.LOG_ENTRY.send(sender, e.position(), e.value()); } return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java index 617b0161d..1b720591b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java @@ -29,11 +29,10 @@ import me.lucko.luckperms.common.actionlog.Log; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.factory.NodeBuilders; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -49,8 +48,8 @@ import java.util.UUID; public class LogNotify extends ChildCommand { private static final String IGNORE_NODE = "luckperms.log.notify.ignoring"; - public LogNotify(LocaleManager locale) { - super(CommandSpec.LOG_NOTIFY.localize(locale), "notify", CommandPermission.LOG_NOTIFY, Predicates.notInRange(0, 1)); + public LogNotify() { + super(CommandSpec.LOG_NOTIFY, "notify", CommandPermission.LOG_NOTIFY, Predicates.notInRange(0, 1)); } public static boolean isIgnoring(LuckPermsPlugin plugin, UUID uuid) { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogParentCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogParentCommand.java index 24d768dbe..5f701f60b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogParentCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogParentCommand.java @@ -30,9 +30,8 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.actionlog.Log; import me.lucko.luckperms.common.command.abstraction.Command; import me.lucko.luckperms.common.command.abstraction.ParentCommand; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.command.spec.CommandSpec; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -42,14 +41,14 @@ import java.util.concurrent.locks.ReentrantLock; public class LogParentCommand extends ParentCommand { private final ReentrantLock lock = new ReentrantLock(); - public LogParentCommand(LocaleManager locale) { - super(CommandSpec.LOG.localize(locale), "Log", Type.NO_TARGET_ARGUMENT, ImmutableList.>builder() - .add(new LogRecent(locale)) - .add(new LogSearch(locale)) - .add(new LogNotify(locale)) - .add(new LogUserHistory(locale)) - .add(new LogGroupHistory(locale)) - .add(new LogTrackHistory(locale)) + public LogParentCommand() { + super(CommandSpec.LOG, "Log", Type.NO_TARGET_ARGUMENT, ImmutableList.>builder() + .add(new LogRecent()) + .add(new LogSearch()) + .add(new LogNotify()) + .add(new LogUserHistory()) + .add(new LogGroupHistory()) + .add(new LogTrackHistory()) .build() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogRecent.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogRecent.java index 36b04da0c..4bf748a04 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogRecent.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogRecent.java @@ -30,13 +30,11 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Paginated; import me.lucko.luckperms.common.util.Predicates; @@ -46,8 +44,8 @@ import java.util.UUID; public class LogRecent extends ChildCommand { private static final int ENTRIES_PER_PAGE = 10; - public LogRecent(LocaleManager locale) { - super(CommandSpec.LOG_RECENT.localize(locale), "recent", CommandPermission.LOG_RECENT, Predicates.notInRange(0, 2)); + public LogRecent() { + super(CommandSpec.LOG_RECENT, "recent", CommandPermission.LOG_RECENT, Predicates.notInRange(0, 2)); } @Override @@ -103,14 +101,7 @@ public class LogRecent extends ChildCommand { } for (Paginated.Entry e : entries) { - Message.LOG_ENTRY.send(sender, - e.position(), - DurationFormatter.CONCISE_LOW_ACCURACY.format(e.value().getDurationSince()), - e.value().getSourceFriendlyString(), - Character.toString(LoggedAction.getTypeCharacter(e.value().getTarget().getType())), - e.value().getTargetFriendlyString(), - e.value().getDescription() - ); + Message.LOG_ENTRY.send(sender, e.position(), e.value()); } return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogSearch.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogSearch.java index b02fd6fa0..e741ec93c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogSearch.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogSearch.java @@ -30,13 +30,11 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Paginated; import me.lucko.luckperms.common.util.Predicates; @@ -45,8 +43,8 @@ import java.util.List; public class LogSearch extends ChildCommand { private static final int ENTRIES_PER_PAGE = 10; - public LogSearch(LocaleManager locale) { - super(CommandSpec.LOG_SEARCH.localize(locale), "search", CommandPermission.LOG_SEARCH, Predicates.is(0)); + public LogSearch() { + super(CommandSpec.LOG_SEARCH, "search", CommandPermission.LOG_SEARCH, Predicates.is(0)); } @Override @@ -91,14 +89,7 @@ public class LogSearch extends ChildCommand { Message.LOG_SEARCH_HEADER.send(sender, query, page, maxPage); for (Paginated.Entry e : entries) { - Message.LOG_ENTRY.send(sender, - e.position(), - DurationFormatter.CONCISE_LOW_ACCURACY.format(e.value().getDurationSince()), - e.value().getSourceFriendlyString(), - Character.toString(LoggedAction.getTypeCharacter(e.value().getTarget().getType())), - e.value().getTargetFriendlyString(), - e.value().getDescription() - ); + Message.LOG_ENTRY.send(sender, e.position(), e.value()); } return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogTrackHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogTrackHistory.java index 7b323d690..00a03af4e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogTrackHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogTrackHistory.java @@ -30,16 +30,14 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.misc.DataConstraints; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Paginated; import me.lucko.luckperms.common.util.Predicates; @@ -48,8 +46,8 @@ import java.util.List; public class LogTrackHistory extends ChildCommand { private static final int ENTRIES_PER_PAGE = 10; - public LogTrackHistory(LocaleManager locale) { - super(CommandSpec.LOG_TRACK_HISTORY.localize(locale), "trackhistory", CommandPermission.LOG_TRACK_HISTORY, Predicates.notInRange(1, 2)); + public LogTrackHistory() { + super(CommandSpec.LOG_TRACK_HISTORY, "trackhistory", CommandPermission.LOG_TRACK_HISTORY, Predicates.notInRange(1, 2)); } @Override @@ -91,14 +89,7 @@ public class LogTrackHistory extends ChildCommand { Message.LOG_HISTORY_TRACK_HEADER.send(sender, name, page, maxPage); for (Paginated.Entry e : entries) { - Message.LOG_ENTRY.send(sender, - e.position(), - DurationFormatter.CONCISE_LOW_ACCURACY.format(e.value().getDurationSince()), - e.value().getSourceFriendlyString(), - Character.toString(LoggedAction.getTypeCharacter(e.value().getTarget().getType())), - e.value().getTargetFriendlyString(), - e.value().getDescription() - ); + Message.LOG_ENTRY.send(sender, e.position(), e.value()); } return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogUserHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogUserHistory.java index 4b8f60451..52a3ad52b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogUserHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogUserHistory.java @@ -30,13 +30,11 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Paginated; import me.lucko.luckperms.common.util.Predicates; @@ -46,8 +44,8 @@ import java.util.UUID; public class LogUserHistory extends ChildCommand { private static final int ENTRIES_PER_PAGE = 10; - public LogUserHistory(LocaleManager locale) { - super(CommandSpec.LOG_USER_HISTORY.localize(locale), "userhistory", CommandPermission.LOG_USER_HISTORY, Predicates.notInRange(1, 2)); + public LogUserHistory() { + super(CommandSpec.LOG_USER_HISTORY, "userhistory", CommandPermission.LOG_USER_HISTORY, Predicates.notInRange(1, 2)); } @Override @@ -84,14 +82,7 @@ public class LogUserHistory extends ChildCommand { Message.LOG_HISTORY_USER_HEADER.send(sender, name, page, maxPage); for (Paginated.Entry e : entries) { - Message.LOG_ENTRY.send(sender, - e.position(), - DurationFormatter.CONCISE_LOW_ACCURACY.format(e.value().getDurationSince()), - e.value().getSourceFriendlyString(), - Character.toString(LoggedAction.getTypeCharacter(e.value().getTarget().getType())), - e.value().getTargetFriendlyString(), - e.value().getDescription() - ); + Message.LOG_ENTRY.send(sender, e.position(), e.value()); } return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationParentCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationParentCommand.java index 032203787..d168274ee 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationParentCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationParentCommand.java @@ -32,9 +32,8 @@ import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.abstraction.Command; import me.lucko.luckperms.common.command.abstraction.ParentCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -63,19 +62,19 @@ public class MigrationParentCommand extends ParentCommand { private List> commands = null; private boolean display = true; - public MigrationParentCommand(LocaleManager locale) { - super(CommandSpec.MIGRATION.localize(locale), "Migration", Type.NO_TARGET_ARGUMENT, null); + public MigrationParentCommand() { + super(CommandSpec.MIGRATION, "Migration", Type.NO_TARGET_ARGUMENT, null); } @Override public synchronized @NonNull List> getChildren() { if (this.commands == null) { - this.commands = getAvailableCommands(getSpec().getLocaleManager()); + this.commands = getAvailableCommands(); // Add dummy command to show in the list. if (this.commands.isEmpty()) { this.display = false; - this.commands.add(new ChildCommand(CommandSpec.MIGRATION_COMMAND.localize(getSpec().getLocaleManager()), "No available plugins to migrate from", CommandPermission.MIGRATION, Predicates.alwaysFalse()) { + this.commands.add(new ChildCommand(CommandSpec.MIGRATION_COMMAND, "No available plugins to migrate from", CommandPermission.MIGRATION, Predicates.alwaysFalse()) { @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, ArgumentList args, String label) { return CommandResult.SUCCESS; @@ -98,13 +97,13 @@ public class MigrationParentCommand extends ParentCommand { } @SuppressWarnings("unchecked") - private static List> getAvailableCommands(LocaleManager locale) { + private static List> getAvailableCommands() { List> available = new ArrayList<>(); for (Map.Entry plugin : PLUGINS.entrySet()) { try { Class.forName(plugin.getKey()); - available.add((ChildCommand) Class.forName(plugin.getValue()).getConstructor(LocaleManager.class).newInstance(locale)); + available.add((ChildCommand) Class.forName(plugin.getValue()).getConstructor().newInstance()); } catch (Throwable ignored) {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ApplyEditsCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ApplyEditsCommand.java index 1c8031636..9ab94b6a2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ApplyEditsCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ApplyEditsCommand.java @@ -30,11 +30,10 @@ import com.google.gson.JsonObject; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.http.UnsuccessfulRequestException; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -43,8 +42,8 @@ import me.lucko.luckperms.common.webeditor.WebEditorResponse; import java.io.IOException; public class ApplyEditsCommand extends SingleCommand { - public ApplyEditsCommand(LocaleManager locale) { - super(CommandSpec.APPLY_EDITS.localize(locale), "ApplyEdits", CommandPermission.APPLY_EDITS, Predicates.notInRange(1, 2)); + public ApplyEditsCommand() { + super(CommandSpec.APPLY_EDITS, "ApplyEdits", CommandPermission.APPLY_EDITS, Predicates.notInRange(1, 2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/BulkUpdateCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/BulkUpdateCommand.java index aed588dfc..c6bee1406 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/BulkUpdateCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/BulkUpdateCommand.java @@ -41,11 +41,10 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentException; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.CaffeineFactory; @@ -57,8 +56,8 @@ import java.util.concurrent.TimeUnit; public class BulkUpdateCommand extends SingleCommand { private final Cache pendingOperations = CaffeineFactory.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(); - public BulkUpdateCommand(LocaleManager locale) { - super(CommandSpec.BULK_UPDATE.localize(locale), "BulkUpdate", CommandPermission.BULK_UPDATE, Predicates.alwaysFalse()); + public BulkUpdateCommand() { + super(CommandSpec.BULK_UPDATE, "BulkUpdate", CommandPermission.BULK_UPDATE, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/CheckCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/CheckCommand.java index 3ee61c9f1..771340ec5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/CheckCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/CheckCommand.java @@ -28,14 +28,12 @@ package me.lucko.luckperms.common.commands.misc; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.CompletionSupplier; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -49,8 +47,8 @@ import java.util.List; import java.util.UUID; public class CheckCommand extends SingleCommand { - public CheckCommand(LocaleManager locale) { - super(CommandSpec.CHECK.localize(locale), "Check", CommandPermission.CHECK, Predicates.not(2)); + public CheckCommand() { + super(CommandSpec.CHECK, "Check", CommandPermission.CHECK, Predicates.not(2)); } @Override @@ -72,7 +70,7 @@ public class CheckCommand extends SingleCommand { } Tristate tristate = user.getCachedData().getPermissionData(user.getQueryOptions()).checkPermission(permission, PermissionCheckEvent.Origin.INTERNAL).result(); - Message.CHECK_RESULT.send(sender, user.getFormattedDisplayName(), permission, MessageUtils.formatTristate(tristate)); + Message.CHECK_RESULT.send(sender, user.getFormattedDisplayName(), permission, tristate); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java index b717193ee..1e137c437 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java @@ -29,11 +29,10 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; @@ -60,8 +59,8 @@ import java.util.UUID; public class EditorCommand extends SingleCommand { public static final int MAX_USERS = 1000; - public EditorCommand(LocaleManager locale) { - super(CommandSpec.EDITOR.localize(locale), "Editor", CommandPermission.EDITOR, Predicates.notInRange(0, 2)); + public EditorCommand() { + super(CommandSpec.EDITOR, "Editor", CommandPermission.EDITOR, Predicates.notInRange(0, 2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ExportCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ExportCommand.java index 20528aa86..3fa042e2f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ExportCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ExportCommand.java @@ -29,10 +29,9 @@ import me.lucko.luckperms.common.backup.Exporter; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -45,8 +44,8 @@ import java.util.concurrent.atomic.AtomicBoolean; public class ExportCommand extends SingleCommand { private final AtomicBoolean running = new AtomicBoolean(false); - public ExportCommand(LocaleManager locale) { - super(CommandSpec.EXPORT.localize(locale), "Export", CommandPermission.EXPORT, Predicates.notInRange(1, 2)); + public ExportCommand() { + super(CommandSpec.EXPORT, "Export", CommandPermission.EXPORT, Predicates.notInRange(1, 2)); } @Override @@ -78,20 +77,20 @@ public class ExportCommand extends SingleCommand { } if (Files.exists(path)) { - Message.LOG_EXPORT_ALREADY_EXISTS.send(sender, path.toString()); + Message.EXPORT_FILE_ALREADY_EXISTS.send(sender, path.toString()); return CommandResult.INVALID_ARGS; } try { Files.createFile(path); } catch (IOException e) { - Message.LOG_EXPORT_FAILURE.send(sender); + Message.EXPORT_FILE_FAILURE.send(sender); e.printStackTrace(); return CommandResult.FAILURE; } if (!Files.isWritable(path)) { - Message.LOG_EXPORT_NOT_WRITABLE.send(sender, path.toString()); + Message.EXPORT_FILE_NOT_WRITABLE.send(sender, path.toString()); return CommandResult.FAILURE; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ImportCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ImportCommand.java index 907cadf1c..86d6a7db7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ImportCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ImportCommand.java @@ -31,11 +31,10 @@ import me.lucko.luckperms.common.backup.Importer; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.http.UnsuccessfulRequestException; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -53,8 +52,8 @@ import java.util.zip.GZIPInputStream; public class ImportCommand extends SingleCommand { private final AtomicBoolean running = new AtomicBoolean(false); - public ImportCommand(LocaleManager locale) { - super(CommandSpec.IMPORT.localize(locale), "Import", CommandPermission.IMPORT, Predicates.notInRange(1, 2)); + public ImportCommand() { + super(CommandSpec.IMPORT, "Import", CommandPermission.IMPORT, Predicates.notInRange(1, 2)); } @Override @@ -112,18 +111,18 @@ public class ImportCommand extends SingleCommand { String code = args.get(0); if (code.isEmpty()) { - Message.IMPORT_INVALID_CODE.send(sender, code); + Message.IMPORT_WEB_INVALID_CODE.send(sender, code); return CommandResult.INVALID_ARGS; } try { data = plugin.getBytebin().getJsonContent(code).getAsJsonObject(); } catch (UnsuccessfulRequestException e) { - Message.IMPORT_HTTP_REQUEST_FAILURE.send(sender, e.getResponse().code(), e.getResponse().message()); + Message.HTTP_REQUEST_FAILURE.send(sender, e.getResponse().code(), e.getResponse().message()); return CommandResult.STATE_ERROR; } catch (IOException e) { new RuntimeException("Error reading data to bytebin", e).printStackTrace(); - Message.IMPORT_HTTP_UNKNOWN_FAILURE.send(sender); + Message.HTTP_UNKNOWN_FAILURE.send(sender); return CommandResult.STATE_ERROR; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/InfoCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/InfoCommand.java index fcf17f1be..f682cbe30 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/InfoCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/InfoCommand.java @@ -28,81 +28,25 @@ package me.lucko.luckperms.common.commands.misc; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; -import me.lucko.luckperms.common.messaging.InternalMessagingService; -import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Predicates; -import net.luckperms.api.context.ImmutableContextSet; -import net.luckperms.api.extension.Extension; - -import java.time.Duration; -import java.time.Instant; -import java.util.Collection; import java.util.Map; public class InfoCommand extends SingleCommand { - public InfoCommand(LocaleManager locale) { - super(CommandSpec.INFO.localize(locale), "Info", CommandPermission.INFO, Predicates.alwaysFalse()); + public InfoCommand() { + super(CommandSpec.INFO, "Info", CommandPermission.INFO, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, ArgumentList args, String label) { Map storageMeta = plugin.getStorage().getMeta(); - - Message.INFO_HEADER.send(sender, - AbstractLuckPermsPlugin.getPluginName(), - plugin.getBootstrap().getVersion(), - plugin.getBootstrap().getType().getFriendlyName(), - plugin.getBootstrap().getServerBrand(), - plugin.getBootstrap().getServerVersion() - ); - - Message.INFO_STORAGE.send(sender, plugin.getStorage().getName()); - for (Map.Entry e : storageMeta.entrySet()) { - Message.INFO_STORAGE_META.send(sender, e.getKey(), formatValue(e.getValue())); - } - - Collection loadedExtensions = plugin.getExtensionManager().getLoadedExtensions(); - if (!loadedExtensions.isEmpty()) { - Message.INFO_EXTENSIONS.send(sender); - for (Extension extension : loadedExtensions) { - Message.INFO_EXTENSION_ENTRY.send(sender, extension.getClass().getName()); - } - } - - ImmutableContextSet staticContext = plugin.getContextManager().getStaticContext(); - Message.INFO_MIDDLE.send(sender, - plugin.getMessagingService().map(InternalMessagingService::getName).orElse("None"), - staticContext.isEmpty() ? "None" : MessageUtils.contextSetToString(plugin.getLocaleManager(), staticContext), - plugin.getBootstrap().getPlayerCount(), - plugin.getConnectionListener().getUniqueConnections().size(), - DurationFormatter.CONCISE_LOW_ACCURACY.format(Duration.between(plugin.getBootstrap().getStartupTime(), Instant.now())), - plugin.getUserManager().getAll().size(), - plugin.getGroupManager().getAll().size(), - plugin.getTrackManager().getAll().size() - ); - + Message.INFO.send(sender, plugin, storageMeta); return CommandResult.SUCCESS; } - private static String formatValue(String value) { - if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { - return MessageUtils.formatBoolean(Boolean.parseBoolean(value)); - } - - try { - int i = Integer.parseInt(value); - return "&a" + i; - } catch (NumberFormatException ignored) {} - - return "&f" + value; - } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/NetworkSyncCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/NetworkSyncCommand.java index c18689161..b5d949a20 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/NetworkSyncCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/NetworkSyncCommand.java @@ -28,10 +28,9 @@ package me.lucko.luckperms.common.commands.misc; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -40,8 +39,8 @@ import me.lucko.luckperms.common.util.Predicates; import java.util.Optional; public class NetworkSyncCommand extends SingleCommand { - public NetworkSyncCommand(LocaleManager locale) { - super(CommandSpec.NETWORK_SYNC.localize(locale), "NetworkSync", CommandPermission.SYNC, Predicates.alwaysFalse()); + public NetworkSyncCommand() { + super(CommandSpec.NETWORK_SYNC, "NetworkSync", CommandPermission.SYNC, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ReloadConfigCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ReloadConfigCommand.java index eff2492fe..3cce4e7d3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ReloadConfigCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ReloadConfigCommand.java @@ -28,17 +28,16 @@ package me.lucko.luckperms.common.commands.misc; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; public class ReloadConfigCommand extends SingleCommand { - public ReloadConfigCommand(LocaleManager locale) { - super(CommandSpec.RELOAD_CONFIG.localize(locale), "ReloadConfig", CommandPermission.RELOAD_CONFIG, Predicates.alwaysFalse()); + public ReloadConfigCommand() { + super(CommandSpec.RELOAD_CONFIG, "ReloadConfig", CommandPermission.RELOAD_CONFIG, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/SearchCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/SearchCommand.java index 68cd7a07f..0f9d17cb9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/SearchCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/SearchCommand.java @@ -34,44 +34,34 @@ import me.lucko.luckperms.common.cache.LoadingMap; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.node.comparator.NodeEntryComparator; -import me.lucko.luckperms.common.node.factory.NodeCommandFactory; import me.lucko.luckperms.common.node.matcher.ConstraintNodeMatcher; import me.lucko.luckperms.common.node.matcher.StandardNodeMatchers; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.misc.NodeEntry; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Iterators; import me.lucko.luckperms.common.util.Predicates; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.ComponentBuilder; -import net.kyori.text.TextComponent; -import net.kyori.text.event.ClickEvent; -import net.kyori.text.event.HoverEvent; import net.luckperms.api.node.Node; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; -import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; public class SearchCommand extends SingleCommand { - public SearchCommand(LocaleManager locale) { - super(CommandSpec.SEARCH.localize(locale), "Search", CommandPermission.SEARCH, Predicates.notInRange(1, 3)); + public SearchCommand() { + super(CommandSpec.SEARCH, "Search", CommandPermission.SEARCH, Predicates.notInRange(1, 3)); } @Override @@ -85,7 +75,7 @@ public class SearchCommand extends SingleCommand { ConstraintNodeMatcher matcher = StandardNodeMatchers.of(Constraint.of(comparison, args.get(1))); int page = args.getIntOrDefault(2, 1); - Message.SEARCH_SEARCHING.send(sender, matcher); + Message.SEARCH_SEARCHING.send(sender, matcher.toString()); List> matchedUsers = plugin.getStorage().searchUserNodes(matcher).join(); List> matchedGroups = plugin.getStorage().searchGroupNodes(matcher).join(); @@ -128,7 +118,7 @@ public class SearchCommand extends SingleCommand { .complete(args); } - private static > void sendResult(Sender sender, List> results, Function lookupFunction, Message headerMessage, HolderType holderType, String label, int page, Comparison comparison) { + private static > void sendResult(Sender sender, List> results, Function lookupFunction, Message.Args3 headerMessage, HolderType holderType, String label, int page, Comparison comparison) { results = new ArrayList<>(results); results.sort(NodeEntryComparator.normal()); @@ -150,40 +140,7 @@ public class SearchCommand extends SingleCommand { headerMessage.send(sender, page, pages.size(), results.size()); for (Map.Entry> ent : mappedContent) { - // only show the permission in the results if the comparison isn't equals - String permission = ""; - if (comparison != StandardComparison.EQUAL) { - permission = "&7 - (" + ent.getValue().getNode().getKey() + ")"; - } - - String s = "&3> &b" + ent.getKey() + permission + "&7 - " + (ent.getValue().getNode().getValue() ? "&a" : "&c") + ent.getValue().getNode().getValue() + getNodeExpiryString(ent.getValue().getNode()) + MessageUtils.getAppendableNodeContextString(sender.getPlugin().getLocaleManager(), ent.getValue().getNode()); - TextComponent message = TextUtils.fromLegacy(s, TextUtils.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue(), sender.getPlugin())).build(); - sender.sendMessage(message); + Message.SEARCH_NODE_ENTRY.send(sender, comparison != StandardComparison.EQUAL, ent.getValue().getNode(), ent.getKey(), holderType, label, sender.getPlugin()); } } - - private static String getNodeExpiryString(Node node) { - if (!node.hasExpiry()) { - return ""; - } - - return " &8(&7expires in " + DurationFormatter.LONG.format(node.getExpiryDuration()) + "&8)"; - } - - private static Consumer> makeFancy(String holderName, HolderType holderType, String label, NodeEntry perm, LuckPermsPlugin plugin) { - HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline( - "&3> " + (perm.getNode().getValue() ? "&a" : "&c") + perm.getNode().getKey(), - " ", - "&7Click to remove this node from " + holderName - ), TextUtils.AMPERSAND_CHAR)); - - boolean explicitGlobalContext = !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); - String command = "/" + label + " " + NodeCommandFactory.undoCommand(perm.getNode(), holderName, holderType, explicitGlobalContext); - ClickEvent clickEvent = ClickEvent.suggestCommand(command); - - return component -> { - component.hoverEvent(hoverEvent); - component.clickEvent(clickEvent); - }; - } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/SyncCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/SyncCommand.java index 6468e1271..92af14887 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/SyncCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/SyncCommand.java @@ -28,17 +28,16 @@ package me.lucko.luckperms.common.commands.misc; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; public class SyncCommand extends SingleCommand { - public SyncCommand(LocaleManager locale) { - super(CommandSpec.SYNC.localize(locale), "Sync", CommandPermission.SYNC, Predicates.alwaysFalse()); + public SyncCommand() { + super(CommandSpec.SYNC, "Sync", CommandPermission.SYNC, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/TreeCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/TreeCommand.java index 9d31a3a2c..a45bf334b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/TreeCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/TreeCommand.java @@ -29,12 +29,11 @@ import me.lucko.luckperms.common.cacheddata.type.PermissionCache; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.http.UnsuccessfulRequestException; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -42,18 +41,12 @@ import me.lucko.luckperms.common.treeview.TreeView; import me.lucko.luckperms.common.util.Predicates; import me.lucko.luckperms.common.util.Uuids; -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.IOException; import java.util.UUID; public class TreeCommand extends SingleCommand { - public TreeCommand(LocaleManager locale) { - super(CommandSpec.TREE.localize(locale), "Tree", CommandPermission.TREE, Predicates.alwaysFalse()); + public TreeCommand() { + super(CommandSpec.TREE, "Tree", CommandPermission.TREE, Predicates.alwaysFalse()); } @Override @@ -107,15 +100,7 @@ public class TreeCommand extends SingleCommand { } String url = plugin.getConfiguration().get(ConfigKeys.TREE_VIEWER_URL_PATTERN) + id; - - Message.TREE_URL.send(sender); - - Component message = TextComponent.builder(url).color(TextColor.AQUA) - .clickEvent(ClickEvent.openUrl(url)) - .hoverEvent(HoverEvent.showText(TextComponent.of("Click to open the tree view.").color(TextColor.GRAY))) - .build(); - - sender.sendMessage(message); + Message.TREE_URL.send(sender, url); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/VerboseCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/VerboseCommand.java index 018d8f21a..1d124255e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/VerboseCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/VerboseCommand.java @@ -28,14 +28,13 @@ package me.lucko.luckperms.common.commands.misc; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.CompletionSupplier; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.http.UnsuccessfulRequestException; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -44,19 +43,13 @@ import me.lucko.luckperms.common.verbose.VerboseFilter; import me.lucko.luckperms.common.verbose.VerboseHandler; import me.lucko.luckperms.common.verbose.VerboseListener; -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.IOException; import java.util.ArrayList; import java.util.List; public class VerboseCommand extends SingleCommand { - public VerboseCommand(LocaleManager locale) { - super(CommandSpec.VERBOSE.localize(locale), "Verbose", CommandPermission.VERBOSE, Predicates.is(0)); + public VerboseCommand() { + super(CommandSpec.VERBOSE, "Verbose", CommandPermission.VERBOSE, Predicates.is(0)); } @Override @@ -173,15 +166,7 @@ public class VerboseCommand extends SingleCommand { } String url = plugin.getConfiguration().get(ConfigKeys.VERBOSE_VIEWER_URL_PATTERN) + id; - - Message.VERBOSE_RESULTS_URL.send(sender); - - Component message = TextComponent.builder(url).color(TextColor.AQUA) - .clickEvent(ClickEvent.openUrl(url)) - .hoverEvent(HoverEvent.showText(TextComponent.of("Click to open the results page.").color(TextColor.GRAY))) - .build(); - - sender.sendMessage(message); + Message.VERBOSE_RESULTS_URL.send(sender, url); return CommandResult.SUCCESS; } } else { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/CreateTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/CreateTrack.java index 1cb9b55c1..28d100071 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/CreateTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/CreateTrack.java @@ -29,10 +29,9 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.misc.DataConstraints; @@ -42,8 +41,8 @@ import net.luckperms.api.actionlog.Action; import net.luckperms.api.event.cause.CreationCause; public class CreateTrack extends SingleCommand { - public CreateTrack(LocaleManager locale) { - super(CommandSpec.CREATE_TRACK.localize(locale), "CreateTrack", CommandPermission.CREATE_TRACK, Predicates.not(1)); + public CreateTrack() { + super(CommandSpec.CREATE_TRACK, "CreateTrack", CommandPermission.CREATE_TRACK, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/DeleteTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/DeleteTrack.java index 36362c038..ff43a4f69 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/DeleteTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/DeleteTrack.java @@ -29,12 +29,11 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -46,8 +45,8 @@ import net.luckperms.api.event.cause.DeletionCause; import java.util.List; public class DeleteTrack extends SingleCommand { - public DeleteTrack(LocaleManager locale) { - super(CommandSpec.DELETE_TRACK.localize(locale), "DeleteTrack", CommandPermission.DELETE_TRACK, Predicates.not(1)); + public DeleteTrack() { + super(CommandSpec.DELETE_TRACK, "DeleteTrack", CommandPermission.DELETE_TRACK, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/ListTracks.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/ListTracks.java index 0b3c07d13..7f3be513b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/ListTracks.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/ListTracks.java @@ -28,11 +28,9 @@ package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -40,8 +38,8 @@ import me.lucko.luckperms.common.util.Predicates; import java.util.stream.Collectors; public class ListTracks extends SingleCommand { - public ListTracks(LocaleManager locale) { - super(CommandSpec.LIST_TRACKS.localize(locale), "ListTracks", CommandPermission.LIST_TRACKS, Predicates.alwaysFalse()); + public ListTracks() { + super(CommandSpec.LIST_TRACKS, "ListTracks", CommandPermission.LIST_TRACKS, Predicates.alwaysFalse()); } @Override @@ -54,7 +52,7 @@ public class ListTracks extends SingleCommand { return CommandResult.LOADING_ERROR; } - Message.TRACKS_LIST.send(sender, MessageUtils.toCommaSep(plugin.getTrackManager().getAll().keySet().stream().sorted().collect(Collectors.toList()))); + Message.TRACKS_LIST.send(sender, plugin.getTrackManager().getAll().keySet().stream().sorted().collect(Collectors.toList())); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackAppend.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackAppend.java index ad6cc2342..8a06bb5a1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackAppend.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackAppend.java @@ -29,14 +29,12 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -49,8 +47,8 @@ import net.luckperms.api.model.data.DataMutateResult; import java.util.List; public class TrackAppend extends ChildCommand { - public TrackAppend(LocaleManager locale) { - super(CommandSpec.TRACK_APPEND.localize(locale), "append", CommandPermission.TRACK_APPEND, Predicates.not(1)); + public TrackAppend() { + super(CommandSpec.TRACK_APPEND, "append", CommandPermission.TRACK_APPEND, Predicates.not(1)); } @Override @@ -71,7 +69,7 @@ public class TrackAppend extends ChildCommand { if (result.wasSuccessful()) { Message.TRACK_APPEND_SUCCESS.send(sender, group.getName(), target.getName()); if (target.getGroups().size() > 1) { - Message.BLANK.send(sender, MessageUtils.listToArrowSep(target.getGroups(), group.getName())); + Message.TRACK_PATH_HIGHLIGHTED.send(sender, target.getGroups(), group.getName()); } LoggedAction.build().source(sender).target(target) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClear.java index 61f3c39c6..03a4b4a7d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClear.java @@ -29,19 +29,18 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; public class TrackClear extends ChildCommand { - public TrackClear(LocaleManager locale) { - super(CommandSpec.TRACK_CLEAR.localize(locale), "clear", CommandPermission.TRACK_CLEAR, Predicates.alwaysFalse()); + public TrackClear() { + super(CommandSpec.TRACK_CLEAR, "clear", CommandPermission.TRACK_CLEAR, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClone.java index 6ec3ab0d3..2aeabc0c3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClone.java @@ -29,11 +29,10 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -43,8 +42,8 @@ import me.lucko.luckperms.common.util.Predicates; import net.luckperms.api.event.cause.CreationCause; public class TrackClone extends ChildCommand { - public TrackClone(LocaleManager locale) { - super(CommandSpec.TRACK_CLONE.localize(locale), "clone", CommandPermission.TRACK_CLONE, Predicates.not(1)); + public TrackClone() { + super(CommandSpec.TRACK_CLONE, "clone", CommandPermission.TRACK_CLONE, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInfo.java index 54bcad134..530cf1486 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInfo.java @@ -28,24 +28,22 @@ package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; public class TrackInfo extends ChildCommand { - public TrackInfo(LocaleManager locale) { - super(CommandSpec.TRACK_INFO.localize(locale), "info", CommandPermission.TRACK_INFO, Predicates.alwaysFalse()); + public TrackInfo() { + super(CommandSpec.TRACK_INFO, "info", CommandPermission.TRACK_INFO, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track target, ArgumentList args, String label) { - Message.TRACK_INFO.send(sender, target.getName(), MessageUtils.listToArrowSep(target.getGroups())); + Message.TRACK_INFO.send(sender, target.getName(), Message.formatTrackPath(target.getGroups())); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInsert.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInsert.java index d66fde8b7..413ceca1f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInsert.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInsert.java @@ -29,14 +29,12 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -49,8 +47,8 @@ import net.luckperms.api.model.data.DataMutateResult; import java.util.List; public class TrackInsert extends ChildCommand { - public TrackInsert(LocaleManager locale) { - super(CommandSpec.TRACK_INSERT.localize(locale), "insert", CommandPermission.TRACK_INSERT, Predicates.not(2)); + public TrackInsert() { + super(CommandSpec.TRACK_INSERT, "insert", CommandPermission.TRACK_INSERT, Predicates.not(2)); } @Override @@ -80,7 +78,7 @@ public class TrackInsert extends ChildCommand { if (result.wasSuccessful()) { Message.TRACK_INSERT_SUCCESS.send(sender, group.getName(), target.getName(), pos); if (target.getGroups().size() > 1) { - Message.BLANK.send(sender, MessageUtils.listToArrowSep(target.getGroups(), group.getName())); + Message.TRACK_PATH_HIGHLIGHTED.send(sender, target.getGroups(), group.getName()); } LoggedAction.build().source(sender).target(target) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackParentCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackParentCommand.java index 3da3564dc..61497bc24 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackParentCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackParentCommand.java @@ -30,9 +30,8 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.command.abstraction.Command; import me.lucko.luckperms.common.command.abstraction.ParentCommand; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -53,15 +52,15 @@ public class TrackParentCommand extends ParentCommand { .expireAfterAccess(1, TimeUnit.HOURS) .build(key -> new ReentrantLock()); - public TrackParentCommand(LocaleManager locale) { - super(CommandSpec.TRACK.localize(locale), "Track", Type.TAKES_ARGUMENT_FOR_TARGET, ImmutableList.>builder() - .add(new TrackInfo(locale)) - .add(new TrackAppend(locale)) - .add(new TrackInsert(locale)) - .add(new TrackRemove(locale)) - .add(new TrackClear(locale)) - .add(new TrackRename(locale)) - .add(new TrackClone(locale)) + public TrackParentCommand() { + super(CommandSpec.TRACK, "Track", Type.TAKES_ARGUMENT_FOR_TARGET, ImmutableList.>builder() + .add(new TrackInfo()) + .add(new TrackAppend()) + .add(new TrackInsert()) + .add(new TrackRemove()) + .add(new TrackClear()) + .add(new TrackRename()) + .add(new TrackClone()) .build() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRemove.java index 4e98bc778..9ef661488 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRemove.java @@ -29,14 +29,12 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -48,8 +46,8 @@ import net.luckperms.api.model.data.DataMutateResult; import java.util.List; public class TrackRemove extends ChildCommand { - public TrackRemove(LocaleManager locale) { - super(CommandSpec.TRACK_REMOVE.localize(locale), "remove", CommandPermission.TRACK_REMOVE, Predicates.not(1)); + public TrackRemove() { + super(CommandSpec.TRACK_REMOVE, "remove", CommandPermission.TRACK_REMOVE, Predicates.not(1)); } @Override @@ -65,7 +63,7 @@ public class TrackRemove extends ChildCommand { if (result.wasSuccessful()) { Message.TRACK_REMOVE_SUCCESS.send(sender, groupName, target.getName()); if (target.getGroups().size() > 1) { - Message.BLANK.send(sender, MessageUtils.listToArrowSep(target.getGroups())); + Message.TRACK_PATH.send(sender, target.getGroups()); } LoggedAction.build().source(sender).target(target) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRename.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRename.java index 49b9bd43b..28f86eb7a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRename.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRename.java @@ -29,11 +29,10 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -44,8 +43,8 @@ import net.luckperms.api.event.cause.CreationCause; import net.luckperms.api.event.cause.DeletionCause; public class TrackRename extends ChildCommand { - public TrackRename(LocaleManager locale) { - super(CommandSpec.TRACK_RENAME.localize(locale), "rename", CommandPermission.TRACK_RENAME, Predicates.not(1)); + public TrackRename() { + super(CommandSpec.TRACK_RENAME, "rename", CommandPermission.TRACK_RENAME, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserClone.java index 4d36a8f90..384289a50 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserClone.java @@ -30,11 +30,10 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -45,8 +44,8 @@ import net.luckperms.api.model.data.DataType; import java.util.UUID; public class UserClone extends ChildCommand { - public UserClone(LocaleManager locale) { - super(CommandSpec.USER_CLONE.localize(locale), "clone", CommandPermission.USER_CLONE, Predicates.not(1)); + public UserClone() { + super(CommandSpec.USER_CLONE, "clone", CommandPermission.USER_CLONE, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserDemote.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserDemote.java index 9bd336294..405f5fd43 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserDemote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserDemote.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -54,8 +52,8 @@ import java.util.Set; import java.util.function.Predicate; public class UserDemote extends ChildCommand { - public UserDemote(LocaleManager locale) { - super(CommandSpec.USER_DEMOTE.localize(locale), "demote", CommandPermission.USER_DEMOTE, Predicates.alwaysFalse()); + public UserDemote() { + super(CommandSpec.USER_DEMOTE, "demote", CommandPermission.USER_DEMOTE, Predicates.alwaysFalse()); } @Override @@ -143,9 +141,9 @@ public class UserDemote extends ChildCommand { String groupFrom = result.getGroupFrom().get(); String groupTo = result.getGroupTo().get(); - Message.USER_DEMOTE_SUCCESS.send(sender, target.getFormattedDisplayName(), track.getName(), groupFrom, groupTo, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.USER_DEMOTE_SUCCESS.send(sender, target.getFormattedDisplayName(), track.getName(), groupFrom, groupTo, context); if (!dontShowTrackProgress) { - Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups(), groupTo, groupFrom, true)); + Message.TRACK_PATH_HIGHLIGHTED_PROGRESSION.send(sender, track.getGroups(), groupTo, groupFrom, true); } LoggedAction.build().source(sender).target(target) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserInfo.java index e69f43ab5..8f9803989 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserInfo.java @@ -25,22 +25,17 @@ package me.lucko.luckperms.common.commands.user; -import com.google.common.collect.Maps; - import me.lucko.luckperms.common.cacheddata.type.MetaCache; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Predicates; import me.lucko.luckperms.common.verbose.event.MetaCheckEvent; @@ -54,8 +49,8 @@ import java.util.Map; import java.util.stream.Collectors; public class UserInfo extends ChildCommand { - public UserInfo(LocaleManager locale) { - super(CommandSpec.USER_INFO.localize(locale), "info", CommandPermission.USER_INFO, Predicates.alwaysFalse()); + public UserInfo() { + super(CommandSpec.USER_INFO, "info", CommandPermission.USER_INFO, Predicates.alwaysFalse()); } @Override @@ -65,12 +60,11 @@ public class UserInfo extends ChildCommand { return CommandResult.NO_PERMISSION; } - Message status = plugin.getBootstrap().isPlayerOnline(target.getUniqueId()) ? Message.PLAYER_ONLINE : Message.PLAYER_OFFLINE; Message.USER_INFO_GENERAL.send(sender, target.getUsername().orElse("Unknown"), - target.getUniqueId(), - target.getUniqueId().version() == 4 ? "&2mojang" : "&8offline", - status.asString(plugin.getLocaleManager()) + target.getUniqueId().toString(), + target.getUniqueId().version() == 4, + plugin.getBootstrap().isPlayerOnline(target.getUniqueId()) ); List parents = target.normalData().inheritanceAsSortedSet().stream() @@ -86,15 +80,14 @@ public class UserInfo extends ChildCommand { if (!parents.isEmpty()) { Message.INFO_PARENT_HEADER.send(sender); for (InheritanceNode node : parents) { - Message.INFO_PARENT_ENTRY.send(sender, node.getGroupName(), MessageUtils.getAppendableNodeContextString(plugin.getLocaleManager(), node)); + Message.INFO_PARENT_NODE_ENTRY.send(sender, node); } } if (!tempParents.isEmpty()) { Message.INFO_TEMP_PARENT_HEADER.send(sender); for (InheritanceNode node : tempParents) { - Message.INFO_PARENT_ENTRY.send(sender, node.getGroupName(), MessageUtils.getAppendableNodeContextString(plugin.getLocaleManager(), node)); - Message.INFO_PARENT_ENTRY_EXPIRY.send(sender, DurationFormatter.LONG.format(node.getExpiryDuration())); + Message.INFO_PARENT_TEMPORARY_NODE_ENTRY.send(sender, node); } } @@ -106,38 +99,14 @@ public class UserInfo extends ChildCommand { queryOptions = plugin.getContextManager().getStaticQueryOptions(); } - String context = "&bNone"; - String prefix = "&bNone"; - String suffix = "&bNone"; - String meta = "&bNone"; - ContextSet contextSet = queryOptions.context(); - if (!contextSet.isEmpty()) { - context = contextSet.toSet().stream() - .map(e -> MessageUtils.contextToString(plugin.getLocaleManager(), e.getKey(), e.getValue())) - .collect(Collectors.joining(" ")); - } - MetaCache data = target.getCachedData().getMetaData(queryOptions); - String prefixValue = data.getPrefix(MetaCheckEvent.Origin.INTERNAL); - if (prefixValue != null) { - prefix = "&f\"" + prefixValue + "&f\""; - } - String sussexValue = data.getSuffix(MetaCheckEvent.Origin.INTERNAL); - if (sussexValue != null) { - suffix = "&f\"" + sussexValue + "&f\""; - } - String primaryGroup = target.getCachedData().getMetaData(queryOptions).getPrimaryGroup(MetaCheckEvent.Origin.INTERNAL); + String prefix = data.getPrefix(MetaCheckEvent.Origin.INTERNAL); + String suffix = data.getSuffix(MetaCheckEvent.Origin.INTERNAL); + String primaryGroup = data.getPrimaryGroup(MetaCheckEvent.Origin.INTERNAL); + Map> meta = data.getMeta(MetaCheckEvent.Origin.INTERNAL); - Map> metaMap = data.getMeta(MetaCheckEvent.Origin.INTERNAL); - if (!metaMap.isEmpty()) { - meta = metaMap.entrySet().stream() - .flatMap(entry -> entry.getValue().stream().map(value -> Maps.immutableEntry(entry.getKey(), value))) - .map(e -> MessageUtils.contextToString(plugin.getLocaleManager(), e.getKey(), e.getValue())) - .collect(Collectors.joining(" ")); - } - - Message.USER_INFO_CONTEXTUAL_DATA.send(sender, active ? "&2active player" : "&8server", context, prefix, suffix, primaryGroup, meta); + Message.USER_INFO_CONTEXTUAL_DATA.send(sender, active, contextSet, prefix, suffix, primaryGroup, meta); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserParentCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserParentCommand.java index 08a002f30..80c1969bf 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserParentCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserParentCommand.java @@ -30,6 +30,7 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.command.abstraction.Command; import me.lucko.luckperms.common.command.abstraction.ParentCommand; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.commands.generic.meta.CommandMeta; import me.lucko.luckperms.common.commands.generic.other.HolderClear; import me.lucko.luckperms.common.commands.generic.other.HolderEditor; @@ -37,9 +38,7 @@ import me.lucko.luckperms.common.commands.generic.other.HolderShowTracks; import me.lucko.luckperms.common.commands.generic.parent.CommandParent; import me.lucko.luckperms.common.commands.generic.permission.CommandPermission; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.model.UserIdentifier; @@ -65,18 +64,18 @@ public class UserParentCommand extends ParentCommand { .expireAfterAccess(1, TimeUnit.HOURS) .build(key -> new ReentrantLock()); - public UserParentCommand(LocaleManager locale) { - super(CommandSpec.USER.localize(locale), "User", Type.TAKES_ARGUMENT_FOR_TARGET, ImmutableList.>builder() - .add(new UserInfo(locale)) - .add(new CommandPermission<>(locale, HolderType.USER)) - .add(new CommandParent<>(locale, HolderType.USER)) - .add(new CommandMeta<>(locale, HolderType.USER)) - .add(new HolderEditor<>(locale, HolderType.USER)) - .add(new UserPromote(locale)) - .add(new UserDemote(locale)) - .add(new HolderShowTracks<>(locale, HolderType.USER)) - .add(new HolderClear<>(locale, HolderType.USER)) - .add(new UserClone(locale)) + public UserParentCommand() { + super(CommandSpec.USER, "User", Type.TAKES_ARGUMENT_FOR_TARGET, ImmutableList.>builder() + .add(new UserInfo()) + .add(new CommandPermission<>(HolderType.USER)) + .add(new CommandParent<>(HolderType.USER)) + .add(new CommandMeta<>(HolderType.USER)) + .add(new HolderEditor<>(HolderType.USER)) + .add(new UserPromote()) + .add(new UserDemote()) + .add(new HolderShowTracks<>(HolderType.USER)) + .add(new HolderClear<>(HolderType.USER)) + .add(new UserClone()) .build() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserPromote.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserPromote.java index f765aefd1..81a84531e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserPromote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserPromote.java @@ -31,14 +31,12 @@ import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -54,8 +52,8 @@ import java.util.Set; import java.util.function.Predicate; public class UserPromote extends ChildCommand { - public UserPromote(LocaleManager locale) { - super(CommandSpec.USER_PROMOTE.localize(locale), "promote", CommandPermission.USER_PROMOTE, Predicates.alwaysFalse()); + public UserPromote() { + super(CommandSpec.USER_PROMOTE, "promote", CommandPermission.USER_PROMOTE, Predicates.alwaysFalse()); } @Override @@ -129,7 +127,7 @@ public class UserPromote extends ChildCommand { return CommandResult.STATE_ERROR; } - Message.USER_TRACK_ADDED_TO_FIRST.send(sender, target.getFormattedDisplayName(), result.getGroupTo().get(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.USER_TRACK_ADDED_TO_FIRST.send(sender, target.getFormattedDisplayName(), track.getName(), result.getGroupTo().get(), context); LoggedAction.build().source(sender).target(target) .description("promote", track.getName(), context) @@ -143,9 +141,9 @@ public class UserPromote extends ChildCommand { String groupFrom = result.getGroupFrom().get(); String groupTo = result.getGroupTo().get(); - Message.USER_PROMOTE_SUCCESS.send(sender, target.getFormattedDisplayName(), track.getName(), groupFrom, groupTo, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); + Message.USER_PROMOTE_SUCCESS.send(sender, target.getFormattedDisplayName(), track.getName(), groupFrom, groupTo, context); if (!dontShowTrackProgress) { - Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups(), groupFrom, groupTo, false)); + Message.TRACK_PATH_HIGHLIGHTED_PROGRESSION.send(sender, track.getGroups(), groupFrom, groupTo, false); } LoggedAction.build().source(sender).target(target) 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 babd8485f..74fd2ee96 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 @@ -60,47 +60,40 @@ public enum Dependency { "1RsiF3BiVztjlfTA+svDCuoDSGFuSpTZYHvUK8yBx8I=" ), - TEXT( - "net{}kyori", - "text-api", - "3.0.4", - "qJCoD0fTnRhI0EpqdiLAT9QH5gIyY8aNw4Exe/gTWm0=", - Relocation.of("text", "net{}kyori{}text") + ADVENTURE( + "me{}lucko", + "adventure-api", + "4.0.1", + "6dKz0iM9MChLzU5MTLW5HSLFEmmNh/D9Bb6kzJvK/1E=", + Relocation.of("adventure", "net{}kyori{}adventure") ), - TEXT_SERIALIZER_GSON( - "net{}kyori", - "text-serializer-gson", - "3.0.4", - "pes03k1/XKS9OpiK+xqVmk+lXSJIsCEkkg3g36PV65A=", - Relocation.of("text", "net{}kyori{}text") + ADVENTURE_PLATFORM( + "me{}lucko", + "adventure-platform-api", + "4.0.0", + "SgUP+9qpF0QogfbR7NOmXJ9zoi3gyMAAh4igc4SivO4=", + Relocation.of("adventure", "net{}kyori{}adventure") ), - TEXT_SERIALIZER_LEGACY( - "net{}kyori", - "text-serializer-legacy", - "3.0.4", - "1ZYqzZ7zhnN2AyU/n/NeRQv0A9R01j/gX1Uq/nE02SI=", - Relocation.of("text", "net{}kyori{}text") + ADVENTURE_PLATFORM_BUKKIT( + "me{}lucko", + "adventure-platform-bukkit", + "4.0.0", + "St2dvhkBLX4Wr+yZeRbICh/hlw0uhA6cfN/0Ua6YGw4=", + Relocation.of("adventure", "net{}kyori{}adventure") ), - TEXT_ADAPTER_BUKKIT( - "net{}kyori", - "text-adapter-bukkit", - "3.0.5", - "cXA/7PDtnWpd8l7H4AEhP/3Z/WRNiFhDSqKbqO/1+ig=", - Relocation.of("text", "net{}kyori{}text") + ADVENTURE_PLATFORM_BUNGEECORD( + "me{}lucko", + "adventure-platform-bungeecord", + "4.0.0", + "CNvYc3//7OqEz2615Omuq0rRpORvDiy1kEJuzi0lc4Q=", + Relocation.of("adventure", "net{}kyori{}adventure") ), - TEXT_ADAPTER_BUNGEECORD( - "net{}kyori", - "text-adapter-bungeecord", - "3.0.5", - "+yU9AB1mG5wTAFeZc6zArs67loFz00w8VqE34QCjCdw=", - Relocation.of("text", "net{}kyori{}text") - ), - TEXT_ADAPTER_SPONGEAPI( - "net{}kyori", - "text-adapter-spongeapi", - "3.0.5", - "/plXxpvDwqYECq+0saN13Y/Qf6F7GthJPc/hjR7SL5s=", - Relocation.of("text", "net{}kyori{}text") + ADVENTURE_PLATFORM_SPONGEAPI( + "me{}lucko", + "adventure-platform-spongeapi", + "4.0.0", + "qVFz5oHdpiHI+KLMKSigpmu+T5nYZ25BmGYC6Imcx9A=", + Relocation.of("adventure", "net{}kyori{}adventure") ), EVENT( "net{}kyori", diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/LocaleManager.java b/common/src/main/java/me/lucko/luckperms/common/locale/LocaleManager.java deleted file mode 100644 index e23176d9b..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/locale/LocaleManager.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.locale; - -import com.google.common.collect.ImmutableMap; - -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.command.CommandSpecData; -import me.lucko.luckperms.common.locale.message.Message; -import me.lucko.luckperms.common.plugin.LuckPermsPlugin; - -import org.yaml.snakeyaml.Yaml; - -import java.io.BufferedReader; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.EnumMap; -import java.util.Map; - -public class LocaleManager { - - private Map messages = ImmutableMap.of(); - private Map commands = ImmutableMap.of(); - - /** - * Tries to load from a locale file, and logs via the plugin if successful. - * - * @param plugin the plugin to log to - * @param file the file to load from - */ - public void tryLoad(LuckPermsPlugin plugin, Path file) { - if (Files.exists(file)) { - plugin.getLogger().info("Found lang.yml - loading messages..."); - try { - loadFromFile(file); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - /** - * Loads a locale file - * - * @param file the file to load from - * @throws Exception if the process fails - */ - @SuppressWarnings("unchecked") - public void loadFromFile(Path file) throws Exception { - try (BufferedReader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) { - EnumMap messages = new EnumMap<>(Message.class); - EnumMap commands = new EnumMap<>(CommandSpec.class); - - Map data = new Yaml().load(reader); - for (Map.Entry entry : data.entrySet()) { - if (entry.getKey() == null || entry.getKey().isEmpty() || entry.getValue() == null) { - continue; - } - - // might be a message - if (entry.getValue() instanceof String) { - String key = entry.getKey().toUpperCase().replace('-', '_'); - String value = (String) entry.getValue(); - - try { - messages.put(Message.valueOf(key), value); - } catch (IllegalArgumentException e) { - // ignore - } - } - - // might be the entries for command specifications - take care for malformed entries of differing types. - if (entry.getKey().equals("command-specs") && entry.getValue() instanceof Map) { - Map commandKeys = (Map) entry.getValue(); - - // key is the command id, value is a map of the commands attributes - for (Map.Entry commandKey : commandKeys.entrySet()) { - - // just try catch, can't be bothered with safe casting every single value. - try { - String id = (String) commandKey.getKey(); - Map attributes = (Map) commandKey.getValue(); - CommandSpec spec = CommandSpec.valueOf(id.toUpperCase().replace('-', '_')); - - String description = (String) attributes.get("description"); - String usage = (String) attributes.get("usage"); - Map args = (Map) attributes.get("args"); - if (args != null && args.isEmpty()) { - args = null; - } - - CommandSpecData specData = new CommandSpecData(description, usage, args == null ? null : ImmutableMap.copyOf(args)); - commands.put(spec, specData); - - } catch (IllegalArgumentException e) { - // ignore - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - - this.messages = ImmutableMap.copyOf(messages); - this.commands = ImmutableMap.copyOf(commands); - } - } - - /** - * Gets a translation for a given message key - * - * @param key the key - * @return the translation, or null if there isn't any translation available. - */ - public String getTranslation(Message key) { - return this.messages.get(key); - } - - /** - * Gets a translation for a given command spec key - * - * @param key the key - * @return the translation data, or null if there isn't any translation available. - */ - public CommandSpecData getTranslation(CommandSpec key) { - return this.commands.get(key); - } - -} 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 new file mode 100644 index 000000000..1d0e61490 --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java @@ -0,0 +1,3789 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.luckperms.common.locale; + +import com.google.common.collect.Maps; + +import me.lucko.luckperms.common.actionlog.LoggedAction; +import me.lucko.luckperms.common.model.HolderType; +import me.lucko.luckperms.common.model.PermissionHolder; +import me.lucko.luckperms.common.node.factory.NodeCommandFactory; +import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin; +import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap; +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.TextComponent; +import net.kyori.adventure.text.event.ClickEvent; +import net.kyori.adventure.text.event.HoverEvent; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import net.luckperms.api.context.Context; +import net.luckperms.api.context.ContextSet; +import net.luckperms.api.node.ChatMetaType; +import net.luckperms.api.node.Node; +import net.luckperms.api.node.metadata.types.InheritanceOriginMetadata; +import net.luckperms.api.node.types.ChatMetaNode; +import net.luckperms.api.node.types.InheritanceNode; +import net.luckperms.api.node.types.MetaNode; +import net.luckperms.api.util.Tristate; + +import java.time.Duration; +import java.time.Instant; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.OptionalInt; +import java.util.stream.Collectors; + +import static net.kyori.adventure.text.Component.empty; +import static net.kyori.adventure.text.Component.join; +import static net.kyori.adventure.text.Component.newline; +import static net.kyori.adventure.text.Component.space; +import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.Component.translatable; +import static net.kyori.adventure.text.format.NamedTextColor.AQUA; +import static net.kyori.adventure.text.format.NamedTextColor.BLUE; +import static net.kyori.adventure.text.format.NamedTextColor.DARK_AQUA; +import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; +import static net.kyori.adventure.text.format.NamedTextColor.DARK_GREEN; +import static net.kyori.adventure.text.format.NamedTextColor.DARK_RED; +import static net.kyori.adventure.text.format.NamedTextColor.GOLD; +import static net.kyori.adventure.text.format.NamedTextColor.GRAY; +import static net.kyori.adventure.text.format.NamedTextColor.GREEN; +import static net.kyori.adventure.text.format.NamedTextColor.RED; +import static net.kyori.adventure.text.format.NamedTextColor.WHITE; +import static net.kyori.adventure.text.format.NamedTextColor.YELLOW; +import static net.kyori.adventure.text.format.Style.style; +import static net.kyori.adventure.text.format.TextDecoration.BOLD; + +/** + * A collection of formatted messages used by the plugin. + */ +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('[')) + .append(text() + .decoration(BOLD, true) + .append(text('L', AQUA)) + .append(text('P', DARK_GREEN)) + ) + .append(text(']')) + .build(); + + static TextComponent prefixed(ComponentLike component) { + return text() + .append(PREFIX_COMPONENT) + .append(space()) + .append(component) + .build(); + } + + Args1 STARTUP_BANNER = bootstrap -> { + Component infoLine1 = text() + .append(text(AbstractLuckPermsPlugin.getPluginName(), DARK_GREEN)) + .append(space()) + .append(text("v" + bootstrap.getVersion(), AQUA)) + .build(); + + Component infoLine2 = text() + .color(DARK_GRAY) + .append(text("Running on ")) + .append(text(bootstrap.getType().getFriendlyName())) + .append(text(" - ")) + .append(text(bootstrap.getServerBrand())) + .build(); + + // " __ " + // " | |__) " + // " |___ | " + + return join(newline(), + text() + .append(text(" ", AQUA)) + .append(text(" __ ", DARK_AQUA)) + .build(), + text() + .append(text(" | ", AQUA)) + .append(text("|__) ", DARK_AQUA)) + .append(infoLine1) + .build(), + text() + .append(text(" |___ ", AQUA)) + .append(text("| ", DARK_AQUA)) + .append(infoLine2) + .build(), + empty() + ); + }; + + Args1 VIEW_AVAILABLE_COMMANDS_PROMPT = label -> prefixed(translatable() + // "&3Use &a/{} help &3to view available commands." + .key("luckperms.commandsystem.available-commands") + .color(DARK_AQUA) + .args(text('/' + label + " help", GREEN)) + .append(FULL_STOP) + ); + + Args0 NO_PERMISSION_FOR_SUBCOMMANDS = () -> prefixed(translatable() + // "&3You do not have permission to use any sub commands." + .key("luckperms.commandsystem.no-permission-subcommands") + .color(DARK_AQUA) + .append(FULL_STOP) + ); + + Args2 FIRST_TIME_SETUP = (label, username) -> join(newline(), + // "&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:" + // " &3&l> &a{} user {} permission set luckperms.* true" + // "&3After you've done this, you can begin to define your permission assignments and groups." + // "&3Don't know where to start? Check here: &7https://github.com/lucko/LuckPerms/wiki/Usage" + prefixed(translatable() + .key("luckperms.first-time.no-permissions-setup") + .color(DARK_AQUA)), + prefixed(translatable() + .key("luckperms.first-time.use-console-to-give-access") + .color(DARK_AQUA) + .append(FULL_STOP)), + prefixed(translatable() + .key("luckperms.first-time.console-command-prompt") + .color(DARK_AQUA) + .append(text(':'))), + prefixed(text() + .color(DARK_AQUA) + .append(space()) + .append(text('>', style(BOLD))) + .append(space()) + .append(text(label + " user " + username + " permission set luckperms.* true", GREEN)) + .append(newline())), + prefixed(translatable() + .key("luckperms.first-time.next-step") + .color(DARK_AQUA) + .append(FULL_STOP)), + prefixed(translatable() + .key("luckperms.first-time.wiki-prompt") + .color(DARK_AQUA) + .args(text("https://github.com/lucko/LuckPerms/wiki/Usage", GRAY))) + ); + + Args0 LOADING_DATABASE_ERROR = () -> prefixed(translatable() + // "&cA database error occurred whilst loading permissions data. Please try again later. If you are a server admin, please check the console for any errors." + .key("luckperms.login.loading-database-error") + .color(RED) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.login.try-again")) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.login.server-admin-check-console-errors")) + .append(FULL_STOP) + ); + + Args0 LOADING_STATE_ERROR = () -> prefixed(translatable() + // "&cPermissions data for your user was not loaded during the pre-login stage - unable to continue. Please try again later. If you are a server admin, please check the console for any errors." + .key("luckperms.login.data-not-loaded-at-pre") + .color(RED) + .append(text(" - ")) + .append(translatable("luckperms.login.unable-to-continue")) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.login.try-again")) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.login.server-admin-check-console-errors")) + .append(FULL_STOP) + ); + + Args0 LOADING_STATE_ERROR_CB_OFFLINE_MODE = () -> prefixed(translatable() + // "&cPermissions data for your user was not loaded during the pre-login stage - this is likely due to a conflict between CraftBukkit and the online-mode setting. Please check the server console for more information." + .key("luckperms.login.data-not-loaded-at-pre") + .color(RED) + .append(text(" - ")) + .append(translatable("luckperms.login.craftbukkit-offline-mode-error")) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.login.server-admin-check-console-info")) + .append(FULL_STOP) + ); + + Args0 LOADING_SETUP_ERROR = () -> prefixed(translatable() + // "&cAn unexpected error occurred whilst setting up your permissions data. Please try again later." + .key("luckperms.login.unexpected-error") + .color(RED) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.login.try-again")) + .append(FULL_STOP) + ); + + Args0 OP_DISABLED = () -> prefixed(translatable() + // "&bThe vanilla OP system is disabled on this server." + .key("luckperms.opsystem.disabled") + .color(AQUA) + .append(FULL_STOP) + ); + + Args0 OP_DISABLED_SPONGE = () -> prefixed(translatable() + // "&2Please note that Server Operator status has no effect on Sponge permission checks when a permission plugin is installed, you must edit user data directly." + .key("luckperms.opsystem.sponge-warning") + .color(DARK_GREEN) + .append(FULL_STOP) + ); + + Args1 LOG = action -> join(newline(), + // "&3LOG &3&l> &8(&e{}&8) [&a{}&8] (&b{}&8)" + // "&3LOG &3&l> &f{}" + prefixed(text() + .append(translatable("luckperms.logs.actionlog-prefix", DARK_AQUA)) + .append(space()) + .append(text('>', DARK_AQUA, BOLD)) + .append(space()) + .append(text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(text(action.getSourceFriendlyString(), YELLOW)) + .append(CLOSE_BRACKET) + ) + .append(space()) + .append(text() + .color(DARK_GRAY) + .append(text('[')) + .append(text(LoggedAction.getTypeCharacter(action.getTarget().getType()), GREEN)) + .append(text(']')) + ) + .append(space()) + .append(text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(text(action.getTargetFriendlyString(), AQUA)) + .append(CLOSE_BRACKET) + )), + prefixed(text() + .append(translatable("luckperms.logs.actionlog-prefix", DARK_AQUA)) + .append(space()) + .append(text('>', DARK_AQUA, BOLD)) + .append(space()) + .append(text(action.getDescription(), WHITE))) + ); + + Args3 VERBOSE_LOG_PERMISSION = (target, permission, result) -> prefixed(text() + // "&3VB &3&l> &a{}&7 - &a{}&7 - {}" + .append(translatable("luckperms.logs.verbose-prefix", DARK_AQUA)) + .append(space()) + .append(text('>', DARK_AQUA, BOLD)) + .append(space()) + .append(text(target, GREEN)) + .append(text(" - ", GRAY)) + .append(text(permission, GREEN)) + .append(text(" - ", GRAY)) + .append(formatTristate(result)) + ); + + Args3 VERBOSE_LOG_META = (target, metaKey, result) -> prefixed(text() + // "&3VB &3&l> &a{}&7 - &bmeta: &a{}&7 - &7{}" + .append(translatable("luckperms.logs.verbose-prefix", DARK_AQUA)) + .append(space()) + .append(text('>', DARK_AQUA, BOLD)) + .append(space()) + .append(text(target, GREEN)) + .append(text(" - ", GRAY)) + .append(text("meta: ", BLUE)) + .append(text(metaKey, GREEN)) + .append(text(" - ", GRAY)) + .append(text(result, GRAY)) + ); + + Args1 EXPORT_LOG = msg -> prefixed(text() + // "&3EXPORT &3&l> &f{}" + .append(translatable("luckperms.logs.export-prefix", DARK_AQUA)) + .append(space()) + .append(text('>', DARK_AQUA, BOLD)) + .append(space()) + .append(text(msg, WHITE)) + ); + + Args1 EXPORT_LOG_PROGRESS = msg -> prefixed(text() + // "&3EXPORT &3&l> &7{}" + .append(translatable("luckperms.logs.export-prefix", DARK_AQUA)) + .append(space()) + .append(text('>', DARK_AQUA, BOLD)) + .append(space()) + .append(text(msg, GRAY)) + ); + + Args2 MIGRATION_LOG = (pluginName, msg) -> prefixed(text() + // "&3MIGRATION &7[&3{}&7] &3&l> &f{}" + .append(translatable("luckperms.logs.migration-prefix", DARK_AQUA)) + .append(space()) + .append(text() + .color(GRAY) + .append(text('[')) + .append(text(pluginName, DARK_AQUA)) + .append(text(']')) + ) + .append(space()) + .append(text('>', DARK_AQUA, BOLD)) + .append(space()) + .append(text(msg, WHITE)) + ); + + Args2 MIGRATION_LOG_PROGRESS = (pluginName, msg) -> prefixed(text() + // "&3MIGRATION &7[&3{}&7] &3&l> &7{}" + .append(translatable("luckperms.logs.migration-prefix", DARK_AQUA)) + .append(space()) + .append(text() + .color(GRAY) + .append(text('[')) + .append(text(pluginName, DARK_AQUA)) + .append(text(']')) + ) + .append(space()) + .append(text('>', DARK_AQUA, BOLD)) + .append(space()) + .append(text(msg, GRAY)) + ); + + Args0 COMMAND_NOT_RECOGNISED = () -> prefixed(translatable() + // "&cCommand not recognised." + .key("luckperms.commandsystem.command-not-recognised") + .color(RED) + .append(FULL_STOP) + ); + + Args0 COMMAND_NO_PERMISSION = () -> prefixed(translatable() + // "&cYou do not have permission to use this command!" + .key("luckperms.commandsystem.no-permission") + .color(RED) + ); + + Args2 MAIN_COMMAND_USAGE_HEADER = (name, usage) -> prefixed(text() + // "&b{} Sub Commands: &7({} ...)" + .color(AQUA) + .append(text(name)) + .append(space()) + .append(translatable("luckperms.commandsystem.usage.sub-commands-header")) + .append(text(": ")) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(text(usage)) + .append(text(" ...")) + .append(CLOSE_BRACKET) + )); + + Args2 COMMAND_USAGE_DETAILED_HEADER = (name, usage) -> join(newline(), + // "&3&lCommand Usage &3- &b{}" + // "&b> &7{}" + prefixed(text() + .append(translatable("luckperms.commandsystem.usage.usage-header", DARK_AQUA, BOLD)) + .append(text(" - ", DARK_AQUA)) + .append(text(name, AQUA))), + prefixed(text() + .append(text('>', AQUA)) + .append(space()) + .append(text().color(GRAY).append(usage))) + ); + + Args0 COMMAND_USAGE_DETAILED_ARGS_HEADER = () -> prefixed(translatable() + // "&3Arguments:" + .key("luckperms.commandsystem.usage.arguments-header") + .color(DARK_AQUA) + .append(text(':')) + ); + + Args2 COMMAND_USAGE_DETAILED_ARG = (arg, usage) -> prefixed(text() + // "&b- {}&3 -> &7{}" + .append(text('-', AQUA)) + .append(space()) + .append(arg) + .append(text(" -> ", DARK_AQUA)) + .append(text().color(GRAY).append(usage)) + ); + + Args1 REQUIRED_ARGUMENT = name -> text() + .color(DARK_GRAY) + .append(text('<')) + .append(text(name, GRAY)) + .append(text('>')) + .build(); + + Args1 OPTIONAL_ARGUMENT = name -> text() + .color(DARK_GRAY) + .append(text('[')) + .append(text(name, GRAY)) + .append(text(']')) + .build(); + + Args1 USER_NOT_ONLINE = id -> prefixed(translatable() + // "&aUser &b{}&a is not online." + .key("luckperms.command.misc.loading.error.user-not-online") + .color(GREEN) + .args(text(id, AQUA)) + .append(FULL_STOP) + ); + + Args1 USER_NOT_FOUND = id -> prefixed(translatable() + // "&cA user for &4{}&c could not be found." + .key("luckperms.command.misc.loading.error.user-not-found") + .color(RED) + .args(text(id, DARK_RED)) + .append(FULL_STOP) + ); + + Args1 GROUP_NOT_FOUND = id -> prefixed(translatable() + // "&cA group named &4{}&c could not be found." + .key("luckperms.command.misc.loading.error.group-not-found") + .color(RED) + .args(text(id, DARK_RED)) + .append(FULL_STOP) + ); + + Args1 TRACK_NOT_FOUND = id -> prefixed(translatable() + // "&cA track named &4{}&c could not be found." + .key("luckperms.command.misc.loading.error.track-not-found") + .color(RED) + .args(text(id, DARK_RED)) + .append(FULL_STOP) + ); + + Args1 USER_SAVE_ERROR = id -> prefixed(translatable() + // "&cThere was an error whilst saving user data for &4{}&c." + .key("luckperms.command.misc.loading.error.user-save-error") + .color(RED) + .args(text(id, DARK_RED)) + .append(FULL_STOP) + ); + + Args1 GROUP_SAVE_ERROR = id -> prefixed(translatable() + // "&cThere was an error whilst saving group data for &4{}&c." + .key("luckperms.command.misc.loading.error.group-save-error") + .color(RED) + .args(text(id, DARK_RED)) + .append(FULL_STOP) + ); + + Args1 TRACK_SAVE_ERROR = id -> prefixed(translatable() + // "&cThere was an error whilst saving track data for &4{}&c." + .key("luckperms.command.misc.loading.error.track-save-error") + .color(RED) + .args(text(id, DARK_RED)) + .append(FULL_STOP) + ); + + Args1 USER_INVALID_ENTRY = invalid -> prefixed(translatable() + // "&4{}&c is not a valid username/uuid." + .key("luckperms.command.misc.loading.error.user-invalid") + .color(RED) + .args(text(invalid, DARK_RED)) + .append(FULL_STOP) + ); + + Args1 GROUP_INVALID_ENTRY = invalid -> prefixed(translatable() + // "&4{}&c is not a valid group name." + .key("luckperms.command.misc.loading.error.group-invalid") + .color(RED) + .args(text(invalid, DARK_RED)) + .append(FULL_STOP) + ); + + Args1 TRACK_INVALID_ENTRY = invalid -> prefixed(translatable() + // "&4{}&c is not a valid track name." + .key("luckperms.command.misc.loading.error.track-invalid") + .color(RED) + .args(text(invalid, DARK_RED)) + .append(FULL_STOP) + ); + + Args2 VERBOSE_INVALID_FILTER = (invalid, error) -> prefixed(translatable() + // "&4{}&c is not a valid verbose filter. &7({})" + .key("luckperms.command.verbose.invalid-filter") + .color(RED) + .args(text(invalid, DARK_RED)) + .append(FULL_STOP) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(text(error)) + .append(CLOSE_BRACKET) + ) + ); + + Args0 VERBOSE_ON = () -> prefixed(translatable() + // "&bVerbose logging &aenabled &bfor checks matching &aANY&b." + .key("luckperms.command.verbose.enabled") + .color(AQUA) + .args(translatable("luckperms.command.verbose.enabled-term", GREEN), translatable("luckperms.command.verbose.query-any", GREEN)) + .append(FULL_STOP) + ); + + Args1 VERBOSE_ON_QUERY = query -> prefixed(translatable() + // "&bVerbose logging &aenabled &bfor checks matching &a{}&b." + .key("luckperms.command.verbose.enabled") + .color(AQUA) + .args(translatable("luckperms.command.verbose.enabled-term", GREEN), text(query, GREEN)) + .append(FULL_STOP) + ); + + Args2 VERBOSE_ON_COMMAND = (user, command) -> prefixed(translatable() + // "&bForcing &a{}&b to execute command &a/{}&b and reporting all checks made..." + .key("luckperms.command.verbose.command-exec") + .color(AQUA) + .args(text(user, GREEN), text(command, GREEN)) + .append(FULL_STOP) + ); + + Args0 VERBOSE_OFF = () -> prefixed(translatable() + // "&bVerbose logging &cdisabled&b." + .key("luckperms.command.verbose.off") + .color(AQUA) + .args(translatable("luckperms.command.verbose.disabled-term", RED)) + .append(FULL_STOP) + ); + + Args0 VERBOSE_OFF_COMMAND = () -> prefixed(translatable() + // "&bCommand execution complete." + .key("luckperms.command.verbose.command-exec-complete") + .color(AQUA) + .append(FULL_STOP) + ); + + Args0 VERBOSE_RECORDING_ON = () -> prefixed(translatable() + // "&bVerbose recording &aenabled &bfor checks matching &aANY&b." + .key("luckperms.command.verbose.enabled-recording") + .color(AQUA) + .args(translatable("luckperms.command.verbose.enabled-term", GREEN), translatable("luckperms.command.verbose.query-any", GREEN)) + .append(FULL_STOP) + ); + + Args1 VERBOSE_RECORDING_ON_QUERY = query -> prefixed(translatable() + // "&bVerbose recording &aenabled &bfor checks matching &a{}&b." + .key("luckperms.command.verbose.enabled-recording") + .color(AQUA) + .args(translatable("luckperms.command.verbose.enabled-term", GREEN), text(query, GREEN)) + .append(FULL_STOP) + ); + + Args0 VERBOSE_UPLOAD_START = () -> prefixed(translatable() + // "&bVerbose logging &cdisabled&b, uploading results..." + .key("luckperms.command.verbose.uploading") + .color(AQUA) + .args(translatable("luckperms.command.verbose.disabled-term", RED)) + ); + + Args1 VERBOSE_RESULTS_URL = url -> join(newline(), + // "&aVerbose results URL:" + // + prefixed(translatable() + .key("luckperms.command.verbose.url") + .color(GREEN) + .append(text(':'))), + text() + .content(url) + .color(AQUA) + .clickEvent(ClickEvent.openUrl(url)) + ); + + Args0 TREE_UPLOAD_START = () -> prefixed(translatable() + // "&bGenerating permission tree, please wait..." + .key("luckperms.command.tree.start") + .color(AQUA) + ); + + Args0 TREE_EMPTY = () -> prefixed(translatable() + // "&cUnable to generate tree, no results were found." + .key("luckperms.command.tree.empty") + .color(RED) + .append(FULL_STOP) + ); + + Args1 TREE_URL = url -> join(newline(), + // "&aPermission tree URL:" + // + prefixed(translatable() + .key("luckperms.command.tree.url") + .color(GREEN) + .append(text(':'))), + text() + .content(url) + .color(AQUA) + .clickEvent(ClickEvent.openUrl(url)) + ); + + Args2 GENERIC_HTTP_REQUEST_FAILURE = (code, message) -> prefixed(text() + // "&cUnable to communicate with the web app. (response code &4{}&c, message='{}')" + .color(RED) + .append(translatable("luckperms.command.misc.webapp-unable-to-communicate")) + .append(FULL_STOP) + .append(space()) + .append(text() + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.misc.response-code-key")) + .append(space()) + .append(text(code)) + .append(text(", ")) + .append(translatable("luckperms.command.misc.error-message-key")) + .append(text("='")) + .append(text(message)) + .append(text("'")) + .append(CLOSE_BRACKET) + ) + ); + + Args0 GENERIC_HTTP_UNKNOWN_FAILURE = () -> prefixed(text() + // "&cUnable to communicate with the web app. Check the console for errors." + .color(RED) + .append(translatable("luckperms.command.misc.webapp-unable-to-communicate")) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.misc.check-console-for-errors")) + .append(FULL_STOP) + ); + + Args1 SEARCH_SEARCHING = searchQuery -> prefixed(translatable() + // "&aSearching for users and groups with &bpermissions {}&a..." + .key("luckperms.command.search.searching.permission") + .color(GREEN) + .args(text("permissions " + searchQuery, AQUA)) + .append(text("...")) + ); + + Args1 SEARCH_SEARCHING_MEMBERS = group -> prefixed(translatable() + // "&aSearching for users and groups who inherit from &b{}&a..." + .key("luckperms.command.search.searching.inherit") + .color(GREEN) + .args(text(group, AQUA)) + .append(text("...")) + ); + + Args0 SEARCH_RESULT_GROUP_DEFAULT = () -> prefixed(translatable() + // "&7Note: when searching for members of the default group, offline players with no other permissions will not be shown!" + .key("luckperms.command.search.result.default-notice") + .color(GRAY) + ); + + Args3 SEARCH_RESULT = (entries, users, groups) -> prefixed(translatable() + // "&aFound &b{}&a entries from &b{}&a users and &b{}&a groups." + .key("luckperms.command.search.result") + .color(GREEN) + .args(text(entries, AQUA), text(users, AQUA), text(groups, AQUA)) + .append(FULL_STOP) + ); + + Args3 SEARCH_SHOWING_USERS = (page, totalPages, totalEntries) -> prefixed(text() + // "&bShowing user entries: &7(page &f{}&7 of &f{}&7 - &f{}&7 entries)" + .color(AQUA) + .append(translatable("luckperms.command.search.showing-users")) + .append(text(':')) + .append(text(" ")) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.misc.page") + .args(text(page, WHITE), text(totalPages, WHITE)) + ) + .append(text(" - ")) + .append(translatable() + .key("luckperms.command.misc.page-entries") + .args(text(totalEntries, WHITE)) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args3 SEARCH_SHOWING_GROUPS = (page, totalPages, totalEntries) -> prefixed(text() + // "&bShowing group entries: &7(page &f{}&7 of &f{}&7 - &f{}&7 entries)" + .color(AQUA) + .append(translatable("luckperms.command.search.showing-groups")) + .append(text(':')) + .append(text(" ")) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.misc.page") + .args(text(page, WHITE), text(totalPages, WHITE)) + ) + .append(text(" - ")) + .append(translatable() + .key("luckperms.command.misc.page-entries") + .args(text(totalEntries, WHITE)) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args6 SEARCH_NODE_ENTRY = (showNode, node, holder, holderType, label, plugin) -> text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text(holder, AQUA)) + .apply(builder -> { + if (showNode) { + builder.append(text(" - ", GRAY)); + builder.append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(text(node.getKey())) + .append(CLOSE_BRACKET) + ); + } + }) + .append(text(" - ", GRAY)) + .append(text(node.getValue(), node.getValue() ? GREEN : RED)) + .apply(builder -> { + if (node.hasExpiry()) { + builder.append(space()); + builder.append(text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.generic.info.expires-in") + .color(GRAY) + .append(space()) + .append(text(DurationFormatter.LONG.format(node.getExpiryDuration()))) + ) + .append(CLOSE_BRACKET) + ); + } + }) + .append(space()) + .append(formatContextSetBracketed(node.getContexts(), empty())) + .apply(builder -> { + boolean explicitGlobalContext = !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); + + Component hover = join(newline(), + text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text(node.getKey(), node.getValue() ? GREEN : RED)), + text(), + translatable() + .key("luckperms.command.generic.permission.info.click-to-remove") + .color(GRAY) + .args(text(holder)) + ); + + String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, holder, holderType, explicitGlobalContext); + + builder.hoverEvent(HoverEvent.showText(hover)); + builder.clickEvent(ClickEvent.suggestCommand(command)); + }) + .build(); + + Args5 SEARCH_INHERITS_NODE_ENTRY = (node, holder, holderType, label, plugin) -> text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text(holder, AQUA)) + .apply(builder -> { + if (node.hasExpiry()) { + builder.append(space()); + builder.append(text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.generic.info.expires-in") + .color(GRAY) + .append(space()) + .append(text(DurationFormatter.LONG.format(node.getExpiryDuration()))) + ) + .append(CLOSE_BRACKET) + ); + } + }) + .append(space()) + .append(formatContextSetBracketed(node.getContexts(), empty())) + .apply(builder -> { + boolean explicitGlobalContext = !plugin.getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); + + Component hover = join(newline(), + text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text(node.getKey(), node.getValue() ? GREEN : RED)), + text(), + translatable() + .key("luckperms.command.generic.parent.info.click-to-remove") + .color(GRAY) + .args(text(holder)) + ); + + String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, holder, holderType, explicitGlobalContext); + + builder.hoverEvent(HoverEvent.showText(hover)); + builder.clickEvent(ClickEvent.suggestCommand(command)); + }) + .build(); + + Args1 APPLY_EDITS_INVALID_CODE = code -> prefixed(text() + // "&cInvalid code. &7({})" + .color(RED) + .append(translatable("luckperms.command.misc.invalid-code")) + .append(FULL_STOP) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(text(code)) + .append(CLOSE_BRACKET) + ) + ); + + Args1 APPLY_EDITS_UNABLE_TO_READ = invalid -> prefixed(translatable() + // "&cUnable to read data using the given code. &7({})" + .key("luckperms.command.editor.apply-edits.unable-to-read") + .color(RED) + .append(FULL_STOP) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(text(invalid)) + .append(CLOSE_BRACKET) + ) + ); + + Args1 APPLY_EDITS_UNKNOWN_TYPE = invalid -> prefixed(translatable() + // "&cUnable to apply edit to the specified object type. &7({})" + .key("luckperms.command.editor.apply-edits.unknown-type") + .color(RED) + .append(FULL_STOP) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(text(invalid)) + .append(CLOSE_BRACKET) + ) + ); + + Args1 APPLY_EDITS_TARGET_USER_NOT_UUID = target -> prefixed(translatable() + // "&cTarget user &4{}&c is not a valid uuid." + .key("luckperms.command.misc.loading.error.user-not-uuid") + .color(RED) + .args(text(target, DARK_RED)) + .append(FULL_STOP) + ); + + Args1 APPLY_EDITS_TARGET_USER_UNABLE_TO_LOAD = target -> prefixed(translatable() + // "&cUnable to load target user &4{}&c." + .key("luckperms.command.misc.loading.error.user-specific") + .color(RED) + .args(text(target, DARK_RED)) + .append(FULL_STOP) + ); + + Args0 APPLY_EDITS_TARGET_NO_CHANGES_PRESENT = () -> prefixed(translatable() + // "&aNo changes were applied from the web editor. The returned data didn't contain any edits." + .key("luckperms.command.editor.apply-edits.no-changes") + .color(GREEN) + .append(FULL_STOP) + ); + + Args2 APPLY_EDITS_SUCCESS = (type, name) -> prefixed(translatable() + // "&aWeb editor data was applied to {} &b{}&a successfully." + .key("luckperms.command.editor.apply-edits.success") + .color(GREEN) + .args(text(type), text(name, AQUA)) + .append(FULL_STOP) + ); + + Args2 APPLY_EDITS_SUCCESS_SUMMARY = (additions, deletions) -> prefixed(text() + // "&7(&a{} &7{} and &c{} &7{})" + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.editor.apply-edits.success-summary") + .args( + text(additions, GREEN), + additions == 1 ? + translatable("luckperms.command.editor.apply-edits.success.additions-singular") : + translatable("luckperms.command.editor.apply-edits.success.additions"), + text(deletions, RED), + deletions == 1 ? + translatable("luckperms.command.editor.apply-edits.success.deletions-singular") : + translatable("luckperms.command.editor.apply-edits.success.deletions") + ) + ) + .append(CLOSE_BRACKET) + ); + + Args1 APPLY_EDIT_NODE = node -> text() + // "&f{} {} {} {}" + .color(WHITE) + .append(text(node.getKey())) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(text(node.getValue(), node.getValue() ? GREEN : RED)) + .append(CLOSE_BRACKET) + ) + .apply(builder -> { + if (!node.getContexts().isEmpty()) { + builder.append(space()); + builder.append(formatContextSetBracketed(node.getContexts(), empty())); + } + }) + .apply(builder -> { + if (node.hasExpiry()) { + builder.append(space()); + builder.append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(text(DurationFormatter.CONCISE.format(node.getExpiryDuration()))) + .append(CLOSE_BRACKET) + ); + } + }) + .build(); + + Args1 APPLY_EDITS_DIFF_ADDED = node -> text() + // "&a+ {}" + .append(text('+', GREEN)) + .append(text(" ")) + .append(APPLY_EDIT_NODE.build(node)) + .build(); + + Args1 APPLY_EDITS_DIFF_REMOVED = node -> text() + // "&c- {}" + .append(text('-', RED)) + .append(text(" ")) + .append(APPLY_EDIT_NODE.build(node)) + .build(); + + Args1> APPLY_EDITS_TRACK_AFTER = groups -> text() + // "&a+ {}" + .append(text('+', GREEN)) + .append(text(" ")) + .append(formatTrackPath(groups)) + .build(); + + Args1> APPLY_EDITS_TRACK_BEFORE = groups -> text() + // "&c- {}" + .append(text('-', RED)) + .append(text(" ")) + .append(formatTrackPath(groups)) + .build(); + + Args0 EDITOR_NO_MATCH = () -> prefixed(translatable() + // "&cUnable to open editor, no objects matched the desired type." + .color(RED) + .key("luckperms.command.editor.no-match") + .append(FULL_STOP) + ); + + Args0 EDITOR_START = () -> prefixed(translatable() + // "&7Preparing a new editor session, please wait..." + .color(GRAY) + .key("luckperms.command.editor.start") + ); + + Args1 EDITOR_URL = url -> join(newline(), + // "&aClick the link below to open the editor:" + // + prefixed(translatable() + .key("luckperms.command.editor.url") + .color(GREEN) + .append(text(':'))), + text() + .content(url) + .color(AQUA) + .clickEvent(ClickEvent.openUrl(url)) + ); + + Args2 EDITOR_HTTP_REQUEST_FAILURE = (code, message) -> prefixed(text() + // "&cUnable to communicate with the editor. (response code &4{}&c, message='{}')" + .color(RED) + .append(translatable("luckperms.command.editor.unable-to-communicate")) + .append(FULL_STOP) + .append(space()) + .append(text() + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.misc.response-code-key")) + .append(space()) + .append(text(code)) + .append(text(", ")) + .append(translatable("luckperms.command.misc.error-message-key")) + .append(text("='")) + .append(text(message)) + .append(text("'")) + .append(CLOSE_BRACKET) + ) + ); + + Args0 EDITOR_HTTP_UNKNOWN_FAILURE = () -> prefixed(text() + // "&cUnable to communicate with the editor. Check the console for errors." + .color(RED) + .append(translatable("luckperms.command.editor.unable-to-communicate")) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.misc.check-console-for-errors")) + .append(FULL_STOP) + ); + + Args3 CHECK_RESULT = (user, permission, result) -> prefixed(translatable() + // "&aPermission check result on user &b{}&a for permission &b{}&a: &f{}" + .color(GREEN) + .key("luckperms.command.check.result") + .args(text(user, AQUA), text(permission, AQUA)) + .append(text(": ")) + .append(formatTristate(result)) + ); + + Args1 CREATE_SUCCESS = name -> prefixed(translatable() + // "&b{}&a was successfully created." + .color(GREEN) + .key("luckperms.command.generic.create.success") + .args(text(name, AQUA)) + .append(FULL_STOP) + ); + + Args1 DELETE_SUCCESS = name -> prefixed(translatable() + // "&b{}&a was successfully deleted." + .color(GREEN) + .key("luckperms.command.generic.delete.success") + .args(text(name, AQUA)) + .append(FULL_STOP) + ); + + Args2 RENAME_SUCCESS = (from, to) -> prefixed(translatable() + // "&b{}&a was successfully renamed to &b{}&a." + .color(GREEN) + .key("luckperms.command.generic.rename.success") + .args(text(from, AQUA), text(to, AQUA)) + .append(FULL_STOP) + ); + + Args2 CLONE_SUCCESS = (from, to) -> prefixed(translatable() + // "&b{}&a was successfully cloned onto &b{}&a." + .color(GREEN) + .key("luckperms.command.generic.clone.success") + .args(text(from, AQUA), text(to, AQUA)) + .append(FULL_STOP) + ); + + Args3 ALREADY_INHERITS = (holder, group, context) -> prefixed(translatable() + // "&b{}&a already inherits from &b{}&a in context {}&a." + .color(GREEN) + .key("luckperms.command.generic.parent.already-inherits") + .args(text(holder, AQUA), text(group, AQUA), formatContextSet(context)) + .append(FULL_STOP) + ); + + Args3 DOES_NOT_INHERIT = (holder, group, context) -> prefixed(translatable() + // "&b{}&a does not inherit from &b{}&a in context {}&a." + .color(GREEN) + .key("luckperms.command.generic.parent.doesnt-inherit") + .args(text(holder, AQUA), text(group, AQUA), formatContextSet(context)) + .append(FULL_STOP) + ); + + Args3 ALREADY_TEMP_INHERITS = (holder, group, context) -> prefixed(translatable() + // "&b{}&a already temporarily inherits from &b{}&a in context {}&a." + .color(GREEN) + .key("luckperms.command.generic.parent.already-temp-inherits") + .args(text(holder, AQUA), text(group, AQUA), formatContextSet(context)) + .append(FULL_STOP) + ); + + Args3 DOES_NOT_TEMP_INHERIT = (holder, group, context) -> prefixed(translatable() + // "&b{}&a does not temporarily inherit from &b{}&a in context {}&a." + .color(GREEN) + .key("luckperms.command.generic.parent.doesnt-temp-inherit") + .args(text(holder, AQUA), text(group, AQUA), formatContextSet(context)) + .append(FULL_STOP) + ); + + Args2 TRACK_ALREADY_CONTAINS = (track, group) -> prefixed(translatable() + // "&b{}&a already contains &b{}&a." + .color(GREEN) + .key("luckperms.command.track.already-contains") + .args(text(track, AQUA), text(group, AQUA)) + .append(FULL_STOP) + ); + + Args2 TRACK_DOES_NOT_CONTAIN = (track, group) -> prefixed(translatable() + // "&b{}&a doesn't contain &b{}&a." + .color(GREEN) + .key("luckperms.command.track.doesnt-contain") + .args(text(track, AQUA), text(group, AQUA)) + .append(FULL_STOP) + ); + + Args1 TRACK_AMBIGUOUS_CALL = name -> prefixed(translatable() + // "&4{}&c is a member of multiple groups on this track. Unable to determine their location." + .color(RED) + .key("luckperms.command.track.error-multiple-groups") + .args(text(name, DARK_RED)) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.track.error-ambiguous")) + .append(FULL_STOP) + ); + + Args1 ALREADY_EXISTS = name -> prefixed(translatable() + // "&4{}&c already exists!" + .color(RED) + .key("luckperms.command.generic.create.error-already-exists") + .args(text(name, DARK_RED)) + .append(FULL_STOP) + ); + + Args1 DOES_NOT_EXIST = name -> prefixed(translatable() + // "&4{}&c does not exist!" + .color(RED) + .key("luckperms.command.generic.delete.error-doesnt-exist") + .args(text(name, DARK_RED)) + .append(FULL_STOP) + ); + + Args0 USER_LOAD_ERROR = () -> prefixed(translatable() + // "&cAn unexpected error occurred. User not loaded." + .color(RED) + .key("luckperms.command.misc.loading.error.unexpected") + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.misc.loading.error.user")) + .append(FULL_STOP) + ); + + Args0 GROUP_LOAD_ERROR = () -> prefixed(translatable() + // "&cAn unexpected error occurred. Group not loaded." + .color(RED) + .key("luckperms.command.misc.loading.error.unexpected") + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.misc.loading.error.group")) + .append(FULL_STOP) + ); + + Args0 GROUPS_LOAD_ERROR = () -> prefixed(translatable() + // "&cAn unexpected error occurred. Unable to load all groups." + .color(RED) + .key("luckperms.command.misc.loading.error.unexpected") + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.misc.loading.error.all-groups")) + .append(FULL_STOP) + ); + + Args0 TRACK_LOAD_ERROR = () -> prefixed(translatable() + // "&cAn unexpected error occurred. Track not loaded." + .color(RED) + .key("luckperms.command.misc.loading.error.unexpected") + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.misc.loading.error.track")) + .append(FULL_STOP) + ); + + Args0 TRACKS_LOAD_ERROR = () -> prefixed(translatable() + // "&cAn unexpected error occurred. Unable to load all tracks." + .color(RED) + .key("luckperms.command.misc.loading.error.unexpected") + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.misc.loading.error.all-tracks")) + .append(FULL_STOP) + ); + + Args1 TRACK_EMPTY = name -> prefixed(translatable() + // "&4{}&c cannot be used as it is empty or contains only one group." + .color(RED) + .key("luckperms.command.track.error-empty") + .args(text(name, DARK_RED)) + .append(FULL_STOP) + ); + + Args0 UPDATE_TASK_REQUEST = () -> prefixed(translatable() + // "&bAn update task has been requested. Please wait..." + .color(AQUA) + .key("luckperms.command.update-task.request") + .append(FULL_STOP) + ); + + Args0 UPDATE_TASK_COMPLETE = () -> prefixed(translatable() + // "&aUpdate task complete." + .color(GREEN) + .key("luckperms.command.update-task.complete") + .append(FULL_STOP) + ); + + Args0 UPDATE_TASK_COMPLETE_NETWORK = () -> prefixed(translatable() + // "&aUpdate task complete. Now attempting to push to other servers." + .color(GREEN) + .key("luckperms.command.update-task.complete") + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.update-task.push.attempting")) + .append(FULL_STOP) + ); + + Args1 UPDATE_TASK_PUSH_SUCCESS = serviceName -> prefixed(translatable() + // "&aOther servers were notified via &b{} Messaging &asuccessfully." + .color(GREEN) + .key("luckperms.command.update-task.push.complete") + .args(text(serviceName + " Messaging", AQUA)) + .append(FULL_STOP) + ); + + Args0 UPDATE_TASK_PUSH_FAILURE = () -> prefixed(translatable() + // "&cError whilst pushing changes to other servers." + .color(RED) + .key("luckperms.command.update-task.push.error") + .append(FULL_STOP) + ); + + Args0 UPDATE_TASK_PUSH_FAILURE_NOT_SETUP = () -> prefixed(translatable() + // "&cCannot push changes to other servers as a messaging service has not been configured." + .color(RED) + .key("luckperms.command.update-task.push.error-not-setup") + .append(FULL_STOP) + ); + + Args0 RELOAD_CONFIG_SUCCESS = () -> prefixed(translatable() + // "&aThe configuration file was reloaded. &7(some options will only apply after the server has restarted)" + .key("luckperms.command.reload-config.success") + .color(GREEN) + .append(FULL_STOP) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.reload-config.restart-note")) + .append(CLOSE_BRACKET) + ) + ); + + Args2> INFO = (plugin, storageMeta) -> join(newline(), + // "&2Running &bLuckPerms v{}&2 by &bLuck&2." + // "&f- &3Platform: &f{}" + // "&f- &3Server Brand: &f{}" + // "&f- &3Server Version:" + // " &f{}" + // "&f- &bStorage:" + // " &3Type: &f{}" + // " &3Some meta value: {}" + // "&f- &3Extensions:" + // " &f{}" + // "&f- &bMessaging: &f{}" + // "&f- &bInstance:" + // " &3Static contexts: &f{}" + // " &3Online Players: &a{} &7(&a{}&7 unique)" + // " &3Uptime: &7{}" + // " &3Local Data: &a{} &7users, &a{} &7groups, &a{} &7tracks", + prefixed(translatable() + .key("luckperms.command.info.running-plugin") + .color(DARK_GREEN) + .append(space()) + .append(text(AbstractLuckPermsPlugin.getPluginName(), AQUA)) + .append(space()) + .append(text("v" + plugin.getBootstrap().getVersion(), AQUA)) + .append(text(" by ")) + .append(text("Luck", AQUA)) + .append(FULL_STOP)), + prefixed(text() + .color(DARK_AQUA) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.info.platform-key")) + .append(text(": ")) + .append(text(plugin.getBootstrap().getType().getFriendlyName(), WHITE))), + prefixed(text() + .color(DARK_AQUA) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.info.server-brand-key")) + .append(text(": ")) + .append(text(plugin.getBootstrap().getServerBrand(), WHITE))), + prefixed(text() + .color(DARK_AQUA) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.info.server-version-key")) + .append(text(':'))), + prefixed(text() + .color(WHITE) + .append(text(" ")) + .append(text(plugin.getBootstrap().getServerVersion()))), + prefixed(text() + .color(AQUA) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.info.storage-key")) + .append(text(':'))), + prefixed(text() + .apply(builder -> { + builder.append(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.info.storage-type-key")) + .append(text(": ")) + .append(text(plugin.getStorage().getName(), WHITE)) + ); + + for (Map.Entry metaEntry : storageMeta.entrySet()) { + builder.append(newline()); + + String value = metaEntry.getValue(); + Component valueComponent; + if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { + valueComponent = formatBoolean(Boolean.parseBoolean(value)); + } else { + try { + int i = Integer.parseInt(value); + valueComponent = text(i, GREEN); + } catch (NumberFormatException e) { + valueComponent = text(value, WHITE); + } + } + + builder.append(prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(text(metaEntry.getKey())) + .append(text(": ")) + .append(valueComponent) + )); + } + })), + prefixed(text() + .color(AQUA) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.info.extensions-key")) + .append(text(':'))), + prefixed(text() + .color(WHITE) + .append(text(" ")) + .append(formatStringList(plugin.getExtensionManager().getLoadedExtensions().stream() + .map(e -> e.getClass().getSimpleName()) + .collect(Collectors.toList())))), + prefixed(text() + .color(AQUA) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.info.messaging-key")) + .append(text(": ")) + .append(plugin.getMessagingService().map(s -> text(s.getName(), WHITE)).orElse(translatable("luckperms.command.misc.none", WHITE)))), + prefixed(text() + .color(AQUA) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.info.instance-key")) + .append(text(':'))), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.info.static-contexts-key")) + .append(text(": ")) + .append(formatContextSetBracketed(plugin.getContextManager().getStaticContext(), translatable("luckperms.command.misc.none", WHITE)))), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.info.online-players-key")) + .append(text(": ")) + .append(text(plugin.getBootstrap().getPlayerCount(), WHITE)) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.info.online-players-unique") + .args(text(plugin.getConnectionListener().getUniqueConnections().size(), GREEN)) + ) + .append(CLOSE_BRACKET) + )), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.info.uptime-key")) + .append(text(": ")) + .append(text(DurationFormatter.CONCISE_LOW_ACCURACY.format(Duration.between(plugin.getBootstrap().getStartupTime(), Instant.now())), GRAY))), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.info.local-data-key")) + .append(text(": ")) + .append(translatable() + .key("luckperms.command.info.local-data") + .color(GRAY) + .args( + text(plugin.getUserManager().getAll().size(), GREEN), + text(plugin.getGroupManager().getAll().size(), GREEN), + text(plugin.getTrackManager().getAll().size(), GREEN) + ) + )) + ); + + Args1 CREATE_ERROR = name -> prefixed(translatable() + // "&cThere was an error whilst creating &4{}&c." + .key("luckperms.command.generic.create.error") + .color(RED) + .args(text(name, DARK_RED)) + .append(FULL_STOP) + ); + + Args1 DELETE_ERROR = name -> prefixed(translatable() + // "&cThere was an error whilst deleting &4{}&c." + .key("luckperms.command.generic.delete.error") + .color(RED) + .args(text(name, DARK_RED)) + .append(FULL_STOP) + ); + + Args0 DELETE_GROUP_ERROR_DEFAULT = () -> prefixed(translatable() + // "&cYou cannot delete the default group." + .key("luckperms.command.group.delete.not-default") + .color(RED) + .append(FULL_STOP) + ); + + Args0 GROUPS_LIST = () -> prefixed(translatable() + // "&aGroups: &7(name, weight, tracks)" + .key("luckperms.command.group.list.title") + .color(GREEN) + .append(text(": ")) + .append(text("(name, weight, tracks)", GRAY)) + ); + + Args3> GROUPS_LIST_ENTRY = (name, weight, tracks) -> prefixed(text() + .append(text("- ", WHITE)) + .append(text(name, DARK_AQUA)) + .append(text(" - ", GRAY)) + .append(text(weight, AQUA)) + .apply(builder -> { + if (!tracks.isEmpty()) { + builder.append(text(" - ", GRAY)); + builder.append(formatStringList(tracks)); + } + }) + ); + + Args1> TRACKS_LIST = list -> prefixed(translatable() + // "&aTracks: {}" + .key("luckperms.command.track.list.title") + .color(GREEN) + .append(text(": ")) + .append(formatStringList(list)) + ); + + Args4 PERMISSION_INFO = (holder, page, totalPages, totalEntries) -> prefixed(text() + // "&b{}'s Permissions: &7(page &f{}&7 of &f{}&7 - &f{}&7 entries)" + .color(AQUA) + .append(translatable() + .key("luckperms.command.generic.permission.info.title") + .args(text(holder)) + ) + .append(text(':')) + .append(text(" ")) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.misc.page") + .args(text(page, WHITE), text(totalPages, WHITE)) + ) + .append(text(" - ")) + .append(translatable() + .key("luckperms.command.misc.page-entries") + .args(text(totalEntries, WHITE)) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args1 PERMISSION_INFO_NO_DATA = holder -> prefixed(translatable() + // "&b{}&a does not have any permissions set." + .key("luckperms.command.generic.permission.info.empty") + .color(GREEN) + .args(text(holder, AQUA)) + .append(FULL_STOP) + ); + + Args3 PERMISSION_INFO_NODE_ENTRY = (node, holder, label) -> text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text(node.getKey(), node.getValue() ? GREEN : RED)) + .append(space()) + .append(formatContextSetBracketed(node.getContexts(), empty())) + .apply(builder -> { + String holderName = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); + boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); + + Component hover = join(newline(), + text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text(node.getKey(), node.getValue() ? GREEN : RED)), + text(), + translatable() + .key("luckperms.command.generic.permission.info.click-to-remove") + .color(GRAY) + .args(text(holderName)) + ); + + String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, holderName, holder.getType(), explicitGlobalContext); + + builder.hoverEvent(HoverEvent.showText(hover)); + builder.clickEvent(ClickEvent.suggestCommand(command)); + }) + .build(); + + Args3 PERMISSION_INFO_TEMPORARY_NODE_ENTRY = (node, holder, label) -> join(newline(), + text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text(node.getKey(), node.getValue() ? GREEN : RED)) + .append(space()) + .append(formatContextSetBracketed(node.getContexts(), empty())) + .apply(builder -> { + String holderName = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); + boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); + + Component hover = join(newline(), + text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text(node.getKey(), node.getValue() ? GREEN : RED)), + text(), + translatable() + .key("luckperms.command.generic.permission.info.click-to-remove") + .color(GRAY) + .args(text(holderName)) + ); + + String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, holderName, holder.getType(), explicitGlobalContext); + + builder.hoverEvent(HoverEvent.showText(hover)); + builder.clickEvent(ClickEvent.suggestCommand(command)); + }) + .build(), + text() + .color(DARK_GREEN) + .append(text("- ")) + .append(translatable("luckperms.command.generic.info.expires-in")) + .append(space()) + .append(text(DurationFormatter.LONG.format(node.getExpiryDuration()))) + .build() + ); + + Args4 PARENT_INFO = (holder, page, totalPages, totalEntries) -> prefixed(text() + // "&b{}'s Parents: &7(page &f{}&7 of &f{}&7 - &f{}&7 entries)" + .color(AQUA) + .append(translatable() + .key("luckperms.command.generic.parent.info.title") + .args(text(holder)) + ) + .append(text(':')) + .append(text(" ")) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.misc.page") + .args(text(page, WHITE), text(totalPages, WHITE)) + ) + .append(text(" - ")) + .append(translatable() + .key("luckperms.command.misc.page-entries") + .args(text(totalEntries, WHITE)) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args1 PARENT_INFO_NO_DATA = holder -> prefixed(translatable() + // "&b{}&a does not have any parents defined." + .key("luckperms.command.generic.parent.info.empty") + .color(GREEN) + .args(text(holder, AQUA)) + .append(FULL_STOP) + ); + + Args3 PARENT_INFO_NODE_ENTRY = (node, holder, label) -> text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text() + .content(node.getGroupName()) + .color(GREEN) + .apply(builder -> { + String holderName = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); + boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); + + Component hover = join(newline(), + text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text(node.getGroupName(), WHITE)), + text(), + translatable() + .key("luckperms.command.generic.parent.info.click-to-remove") + .color(GRAY) + .args(text(holderName)) + ); + + String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, holderName, holder.getType(), explicitGlobalContext); + + builder.hoverEvent(HoverEvent.showText(hover)); + builder.clickEvent(ClickEvent.suggestCommand(command)); + }) + ) + .append(space()) + .append(formatContextSetBracketed(node.getContexts(), empty())) + .build(); + + Args3 PARENT_INFO_TEMPORARY_NODE_ENTRY = (node, holder, label) -> join(newline(), + text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text() + .content(node.getGroupName()) + .color(GREEN) + .apply(builder -> { + String holderName = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); + boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); + + Component hover = join(newline(), + text() + .append(text('>', DARK_AQUA)) + .append(text(node.getGroupName(), WHITE)), + text(), + translatable() + .key("luckperms.command.generic.permission.info.click-to-remove") + .color(GRAY) + .args(text(holderName)) + ); + + String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, holderName, holder.getType(), explicitGlobalContext); + + builder.hoverEvent(HoverEvent.showText(hover)); + builder.clickEvent(ClickEvent.suggestCommand(command)); + }) + ) + .append(space()) + .append(formatContextSetBracketed(node.getContexts(), empty())) + .build(), + text() + .color(DARK_GREEN) + .append(text("- ")) + .append(translatable("luckperms.command.generic.info.expires-in")) + .append(space()) + .append(text(DurationFormatter.LONG.format(node.getExpiryDuration()))) + .build() + ); + + Args1 LIST_TRACKS = holder -> prefixed(translatable() + // "&b{}'s Tracks:" + .key("luckperms.command.generic.show-tracks.title") + .color(AQUA) + .args(text(holder)) + .append(text(':')) + ); + + Args2 LIST_TRACKS_ENTRY = (name, path) -> text() + // "&a{}: {}" + .color(GREEN) + .append(text(name)) + .append(text(": ")) + .append(path) + .build(); + + Args1 LIST_TRACKS_EMPTY = holder -> prefixed(translatable() + // "&b{}&a is not on any tracks." + .key("luckperms.command.generic.show-tracks.empty") + .color(GREEN) + .args(text(holder, AQUA)) + .append(FULL_STOP) + ); + + Args4 CHECK_PERMISSION = (holder, permission, value, context) -> prefixed(translatable() + // "&b{}&a has permission &b{}&a set to {}&a in context {}&a." + .key("luckperms.command.generic.permission.check-inherits") + .color(GREEN) + .args( + text(permission, AQUA), + formatTristate(value), + text(holder, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args5 CHECK_INHERITS_PERMISSION = (holder, permission, value, context, inheritedFrom) -> prefixed(translatable() + // "&b{}&a has permission &b{}&a set to {}&a in context {}&a. &7(inherited from &a{}&7)" + .key("luckperms.command.generic.permission.check-inherits") + .color(GREEN) + .args( + text(permission, AQUA), + formatTristate(value), + text(holder, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.generic.info.inherited-from")) + .append(space()) + .append(text(inheritedFrom, GREEN)) + .append(CLOSE_BRACKET) + ) + ); + + Args4 SETPERMISSION_SUCCESS = (permission, value, holder, context) -> prefixed(translatable() + // "&aSet &b{}&a to &b{}&a for &b{}&a in context {}&a." + .key("luckperms.command.generic.permission.set") + .color(GREEN) + .args( + text(permission, AQUA), + text(value, AQUA), + text(holder, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 ALREADY_HASPERMISSION = (holder, permission, context) -> prefixed(translatable() + // "&b{}&a already has &b{}&a set in context {}&a." + .key("luckperms.command.generic.permission.already-has") + .color(GREEN) + .args( + text(holder, AQUA), + text(permission, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args5 SETPERMISSION_TEMP_SUCCESS = (permission, value, holder, duration, context) -> prefixed(translatable() + // "&aSet &b{}&a to &b{}&a for &b{}&a for a duration of &b{}&a in context {}&a." + .key("luckperms.command.generic.permission.set-temp") + .color(GREEN) + .args( + text(permission, AQUA), + text(value, AQUA), + text(holder, AQUA), + text(DurationFormatter.LONG.format(duration), AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 ALREADY_HAS_TEMP_PERMISSION = (holder, permission, context) -> prefixed(translatable() + // "&b{}&a already has &b{}&a set temporarily in context {}&a." + .key("luckperms.command.generic.permission.already-has-temp") + .color(GREEN) + .args( + text(holder, AQUA), + text(permission, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 UNSETPERMISSION_SUCCESS = (permission, holder, context) -> prefixed(translatable() + // "&aUnset &b{}&a for &b{}&a in context {}&a." + .key("luckperms.command.generic.permission.unset") + .color(GREEN) + .args( + text(permission, AQUA), + text(holder, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 DOES_NOT_HAVE_PERMISSION = (holder, permission, context) -> prefixed(translatable() + // "&b{}&a does not have &b{}&a set in context {}&a." + .key("luckperms.command.generic.permission.doesnt-have") + .color(GREEN) + .args( + text(holder, AQUA), + text(permission, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 UNSET_TEMP_PERMISSION_SUCCESS = (permission, holder, context) -> prefixed(translatable() + // "&aUnset temporary permission &b{}&a for &b{}&a in context {}&a." + .key("luckperms.command.generic.permission.unset-temp") + .color(GREEN) + .args( + text(permission, AQUA), + text(holder, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args6 UNSET_TEMP_PERMISSION_SUBTRACT_SUCCESS = (permission, value, holder, duration, context, durationLess) -> prefixed(translatable() + // "&aSet &b{}&a to &b{}&a for &b{}&a for a duration of &b{}&a in context {}&a, &b{}&a less than before." + .key("luckperms.command.generic.permission.subtract") + .color(GREEN) + .args( + text(permission, AQUA), + text(value, AQUA), + text(holder, AQUA), + text(DurationFormatter.LONG.format(duration), AQUA), + formatContextSet(context), + text(DurationFormatter.LONG.format(durationLess), AQUA) + ) + .append(FULL_STOP) + ); + + Args3 DOES_NOT_HAVE_TEMP_PERMISSION = (holder, permission, context) -> prefixed(translatable() + // "&b{}&a does not have &b{}&a set temporarily in context {}&a." + .key("luckperms.command.generic.permission.doesnt-have-temp") + .color(GREEN) + .args( + text(holder, AQUA), + text(permission, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 SET_INHERIT_SUCCESS = (holder, parent, context) -> prefixed(translatable() + // "&b{}&a now inherits permissions from &b{}&a in context {}&a." + .key("luckperms.command.generic.parent.add") + .color(GREEN) + .args( + text(holder, AQUA), + text(parent, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args4 SET_TEMP_INHERIT_SUCCESS = (holder, parent, duration, context) -> prefixed(translatable() + // "&b{}&a now inherits permissions from &b{}&a for a duration of &b{}&a in context {}&a." + .key("luckperms.command.generic.parent.add-temp") + .color(GREEN) + .args( + text(holder, AQUA), + text(parent, AQUA), + text(DurationFormatter.LONG.format(duration), AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 SET_PARENT_SUCCESS = (holder, parent, context) -> prefixed(translatable() + // "&b{}&a had their existing parent groups cleared, and now only inherits &b{}&a in context {}&a." + .key("luckperms.command.generic.parent.set") + .color(GREEN) + .args( + text(holder, AQUA), + text(parent, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args4 SET_TRACK_PARENT_SUCCESS = (holder, track, parent, context) -> prefixed(translatable() + // "&b{}&a had their existing parent groups on track &b{}&a cleared, and now only inherits &b{}&a in context {}&a." + .key("luckperms.command.generic.parent.set-track") + .color(GREEN) + .args( + text(holder, AQUA), + text(track, AQUA), + text(parent, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 UNSET_INHERIT_SUCCESS = (holder, parent, context) -> prefixed(translatable() + // "&b{}&a no longer inherits permissions from &b{}&a in context {}&a." + .key("luckperms.command.generic.parent.remove") + .color(GREEN) + .args( + text(holder, AQUA), + text(parent, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 UNSET_TEMP_INHERIT_SUCCESS = (holder, parent, context) -> prefixed(translatable() + // "&b{}&a no longer temporarily inherits permissions from &b{}&a in context {}&a." + .key("luckperms.command.generic.parent.remove-temp") + .color(GREEN) + .args( + text(holder, AQUA), + text(parent, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args5 UNSET_TEMP_INHERIT_SUBTRACT_SUCCESS = (holder, parent, duration, context, durationLess) -> prefixed(translatable() + // "&b{}&a will inherit permissions from &b{}&a for a duration of &b{}&a in context {}&a, &b{}&a less than before." + .key("luckperms.command.generic.parent.subtract") + .color(GREEN) + .args( + text(holder, AQUA), + text(parent, AQUA), + text(DurationFormatter.LONG.format(duration), AQUA), + formatContextSet(context), + text(DurationFormatter.LONG.format(durationLess), AQUA) + ) + .append(FULL_STOP) + ); + + Args3 CLEAR_SUCCESS = (holder, context, removeCount) -> prefixed(translatable() + // "&b{}&a's nodes were cleared in context {}&a. (&b{}&a nodes were removed.)" + .key("luckperms.command.generic.clear") + .color(GREEN) + .args(text(holder, AQUA), formatContextSet(context)) + .append(FULL_STOP) + .append(space()) + .append(text() + .append(OPEN_BRACKET) + .append(translatable() + .key(removeCount == 1 ? "luckperms.command.generic.clear.node-removed-singular" : "luckperms.command.generic.clear.node-removed") + .args(text(removeCount)) + .color(AQUA) + .append(FULL_STOP) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args3 PERMISSION_CLEAR_SUCCESS = (holder, context, removeCount) -> prefixed(translatable() + // "&b{}&a's parents were cleared in context {}&a. (&b{}&a nodes were removed.)" + .key("luckperms.command.generic.permission.clear") + .color(GREEN) + .args(text(holder, AQUA), formatContextSet(context)) + .append(FULL_STOP) + .append(space()) + .append(text() + .append(OPEN_BRACKET) + .append(translatable() + .key(removeCount == 1 ? "luckperms.command.generic.clear.node-removed-singular" : "luckperms.command.generic.clear.node-removed") + .args(text(removeCount)) + .color(AQUA) + .append(FULL_STOP) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args3 PARENT_CLEAR_SUCCESS = (holder, context, removeCount) -> prefixed(translatable() + // "&b{}&a's parents were cleared in context {}&a. (&b{}&a nodes were removed.)" + .key("luckperms.command.generic.parent.clear-track") + .color(GREEN) + .args(text(holder, AQUA), formatContextSet(context)) + .append(FULL_STOP) + .append(space()) + .append(text() + .append(OPEN_BRACKET) + .append(translatable() + .key(removeCount == 1 ? "luckperms.command.generic.clear.node-removed-singular" : "luckperms.command.generic.clear.node-removed") + .args(text(removeCount)) + .color(AQUA) + .append(FULL_STOP) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args4 PARENT_CLEAR_TRACK_SUCCESS = (holder, track, context, removeCount) -> prefixed(translatable() + // "&b{}&a's parents on track &b{}&a were cleared in context {}&a. (&b{}&a nodes were removed.)" + .key("luckperms.command.generic.parent.clear-track") + .color(GREEN) + .args(text(holder, AQUA), text(track, AQUA), formatContextSet(context)) + .append(FULL_STOP) + .append(space()) + .append(text() + .append(OPEN_BRACKET) + .append(translatable() + .key(removeCount == 1 ? "luckperms.command.generic.clear.node-removed-singular" : "luckperms.command.generic.clear.node-removed") + .args(text(removeCount)) + .color(AQUA) + .append(FULL_STOP) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args4 META_CLEAR_SUCCESS = (holder, key, context, removeCount) -> prefixed(translatable() + // "&b{}&a's meta matching type &b{}&a was cleared in context {}&a. (&b{}&a nodes were removed.)" + .key("luckperms.command.generic.meta.clear") + .color(GREEN) + .args(text(holder, AQUA), text(key, AQUA), formatContextSet(context)) + .append(FULL_STOP) + .append(space()) + .append(text() + .append(OPEN_BRACKET) + .append(translatable() + .key(removeCount == 1 ? "luckperms.command.generic.clear.node-removed-singular" : "luckperms.command.generic.clear.node-removed") + .args(text(removeCount)) + .color(AQUA) + .append(FULL_STOP) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args1 ILLEGAL_DATE_ERROR = invalid -> prefixed(translatable() + // "&cCould not parse date &4{}&c." + .key("luckperms.command.misc.date-parse-error") + .color(RED) + .args(text(invalid, DARK_RED)) + .append(FULL_STOP) + ); + + Args0 PAST_DATE_ERROR = () -> prefixed(translatable() + // "&cYou cannot set a date in the past!" + .key("luckperms.command.misc.date-in-past-error") + .color(RED) + ); + + Args1 CHAT_META_PREFIX_HEADER = holder -> prefixed(translatable() + // "&b{}'s Prefixes" + .key("luckperms.command.generic.chat-meta.info.title-prefix") + .color(AQUA) + .args(text(holder)) + ); + + Args1 CHAT_META_SUFFIX_HEADER = holder -> prefixed(translatable() + // "&b{}'s Suffixes" + .key("luckperms.command.generic.chat-meta.info.title-suffix") + .color(AQUA) + .args(text(holder)) + ); + + Args1 META_HEADER = holder -> prefixed(translatable() + // "&b{}'s Meta" + .key("luckperms.command.generic.meta.info.title") + .color(AQUA) + .args(text(holder)) + ); + + Args3, PermissionHolder, String> CHAT_META_ENTRY = (node, holder, label) -> prefixed(text() + // "&b-> {} &f- &f'{}&f' &8(&7inherited from &a{}&8) {}" + .append(text("->", AQUA)) + .append(space()) + .append(text(node.getPriority(), AQUA)) + .append(text(" - ", WHITE)) + .append(text().color(WHITE).append(text('\'')).append(formatColoredValue(node.getMetaValue())).append(text('\''))) + .append(space()) + .append(text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .color(GRAY) + .key("luckperms.command.generic.info.inherited-from") + .append(space()) + .apply(builder -> { + InheritanceOriginMetadata origin = node.metadata(InheritanceOriginMetadata.KEY); + if (origin.wasInherited(holder.getIdentifier())) { + builder.append(text(origin.getOrigin().getName(), GREEN)); + } else { + builder.append(translatable("luckperms.command.generic.info.inherited-from-self", GREEN)); + } + }) + .append(CLOSE_BRACKET) + ) + .append(space()) + .append(formatContextSetBracketed(node.getContexts(), empty())) + .apply(builder -> { + String holderName = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); + boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); + + Component hover = join(newline(), + text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text(node.getPriority(), GREEN)) + .append(text(" - ", GRAY)) + .append(text(node.getMetaValue(), WHITE)), + text(), + translatable() + .key("luckperms.command.generic.chat-meta.info.click-to-remove") + .color(GRAY) + .args(text(node.getMetaType().toString()), text(holderName)) + ); + + String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, holderName, holder.getType(), explicitGlobalContext); + + builder.hoverEvent(HoverEvent.showText(hover)); + builder.clickEvent(ClickEvent.suggestCommand(command)); + }) + )); + + Args3 META_ENTRY = (node, holder, label) -> prefixed(text() + // "&b-> &a{} &f= &f'{}&f' &8(&7inherited from &a{}&8) {}" + .append(text("->", AQUA)) + .append(space()) + .append(text(node.getMetaKey(), GREEN)) + .append(text(" = ", WHITE)) + .append(text().color(WHITE).append(text('\'')).append(formatColoredValue(node.getMetaValue())).append(text('\''))) + .append(space()) + .append(text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .color(GRAY) + .key("luckperms.command.generic.info.inherited-from") + .append(space()) + .apply(builder -> { + InheritanceOriginMetadata origin = node.metadata(InheritanceOriginMetadata.KEY); + if (origin.wasInherited(holder.getIdentifier())) { + builder.append(text(origin.getOrigin().getName(), GREEN)); + } else { + builder.append(translatable("luckperms.command.generic.info.inherited-from-self", GREEN)); + } + }) + .append(CLOSE_BRACKET) + ) + .append(space()) + .append(formatContextSetBracketed(node.getContexts(), empty())) + .apply(builder -> { + String holderName = holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getPlainDisplayName(); + boolean explicitGlobalContext = !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty(); + + Component hover = join(newline(), + text() + .append(text('>', DARK_AQUA)) + .append(space()) + .append(text(node.getMetaKey(), WHITE)) + .append(text(" - ", GRAY)) + .append(text(node.getMetaValue(), WHITE)), + text(), + translatable() + .key("luckperms.command.generic.meta.info.click-to-remove") + .color(GRAY) + .args(text(holderName)) + ); + + String command = "/" + label + " " + NodeCommandFactory.undoCommand(node, holderName, holder.getType(), explicitGlobalContext); + + builder.hoverEvent(HoverEvent.showText(hover)); + builder.clickEvent(ClickEvent.suggestCommand(command)); + }) + )); + + Args1 CHAT_META_PREFIX_NONE = holder -> prefixed(translatable() + // "&b{} has no prefixes." + .key("luckperms.command.generic.chat-meta.info.none-prefix") + .color(AQUA) + .args(text(holder)) + .append(FULL_STOP) + ); + + Args1 CHAT_META_SUFFIX_NONE = holder -> prefixed(translatable() + // "&b{} has no suffixes." + .key("luckperms.command.generic.chat-meta.info.none-suffix") + .color(AQUA) + .args(text(holder)) + .append(FULL_STOP) + ); + + Args1 META_NONE = holder -> prefixed(translatable() + // "&b{} has no meta." + .key("luckperms.command.generic.meta.info.none") + .color(AQUA) + .args(text(holder)) + .append(FULL_STOP) + ); + + Args1 META_INVALID_PRIORITY = invalid -> prefixed(translatable() + // "&cInvalid priority &4{}&c. Expected a number." + .key("luckperms.command.misc.invalid-priority") + .color(RED) + .args(text(invalid, DARK_RED)) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.misc.expected-number")) + .append(FULL_STOP) + ); + + Args5 ALREADY_HAS_CHAT_META = (holder, type, value, priority, context) -> prefixed(translatable() + // "&b{}&a already has {} &f'{}&f'&a set at a priority of &b{}&a in context {}&a." + .key("luckperms.command.generic.chat-meta.already-has") + .color(GREEN) + .args( + text(holder, AQUA), + text(type.toString()), + text().color(WHITE).append(text('\'')).append(formatColoredValue(value)).append(text('\'')), + text(priority, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args5 ALREADY_HAS_TEMP_CHAT_META = (holder, type, value, priority, context) -> prefixed(translatable() + // "&b{}&a already has {} &f'{}&f'&a set temporarily at a priority of &b{}&a in context {}&a." + .key("luckperms.command.generic.chat-meta.already-has-temp") + .color(GREEN) + .args( + text(holder, AQUA), + text(type.toString()), + text().color(WHITE).append(text('\'')).append(formatColoredValue(value)).append(text('\'')), + text(priority, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args5 DOES_NOT_HAVE_CHAT_META = (holder, type, value, priority, context) -> prefixed(translatable() + // "&b{}&a doesn't have {} &f'{}&f'&a set at a priority of &b{}&a in context {}&a." + .key("luckperms.command.generic.chat-meta.doesnt-have") + .color(GREEN) + .args( + text(holder, AQUA), + text(type.toString()), + text().color(WHITE).append(text('\'')).append(formatColoredValue(value)).append(text('\'')), + text(priority, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args5 DOES_NOT_HAVE_TEMP_CHAT_META = (holder, type, value, priority, context) -> prefixed(translatable() + // "&b{}&a doesn't have {} &f'{}&f'&a set temporarily at a priority of &b{}&a in context {}&a." + .key("luckperms.command.generic.chat-meta.doesnt-have-temp") + .color(GREEN) + .args( + text(holder, AQUA), + text(type.toString()), + text().color(WHITE).append(text('\'')).append(formatColoredValue(value)).append(text('\'')), + text(priority, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args5 ADD_CHATMETA_SUCCESS = (holder, type, value, priority, context) -> prefixed(translatable() + // "&b{}&a had {} &f'{}&f'&a set at a priority of &b{}&a in context {}&a." + .key("luckperms.command.generic.chat-meta.add") + .color(GREEN) + .args( + text(holder, AQUA), + text(type.toString()), + text().color(WHITE).append(text('\'')).append(formatColoredValue(value)).append(text('\'')), + text(priority, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args6 ADD_TEMP_CHATMETA_SUCCESS = (holder, type, value, priority, duration, context) -> prefixed(translatable() + // "&b{}&a had {} &f'{}&f'&a set at a priority of &b{}&a for a duration of &b{}&a in context {}&a." + .key("luckperms.command.generic.chat-meta.add-temp") + .color(GREEN) + .args( + text(holder, AQUA), + text(type.toString()), + text().color(WHITE).append(text('\'')).append(formatColoredValue(value)).append(text('\'')), + text(priority, AQUA), + text(DurationFormatter.LONG.format(duration), AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args5 REMOVE_CHATMETA_SUCCESS = (holder, type, value, priority, context) -> prefixed(translatable() + // "&b{}&a had {} &f'{}&f'&a at priority &b{}&a removed in context {}&a." + .key("luckperms.command.generic.chat-meta.remove") + .color(GREEN) + .args( + text(holder, AQUA), + text(type.toString()), + text().color(WHITE).append(text('\'')).append(formatColoredValue(value)).append(text('\'')), + text(priority, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args4 BULK_REMOVE_CHATMETA_SUCCESS = (holder, type, priority, context) -> prefixed(translatable() + // "&b{}&a had all {}es at priority &b{}&a removed in context {}&a." + .key("luckperms.command.generic.chat-meta.remove-bulk") + .color(GREEN) + .args( + text(holder, AQUA), + text(type.toString() + "es"), + text(priority, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args5 REMOVE_TEMP_CHATMETA_SUCCESS = (holder, type, value, priority, context) -> prefixed(translatable() + // "&b{}&a had temporary {} &f'{}&f'&a at priority &b{}&a removed in context {}&a." + .key("luckperms.command.generic.chat-meta.remove-temp") + .color(GREEN) + .args( + text(holder, AQUA), + text(type.toString()), + text().color(WHITE).append(text('\'')).append(text(value)).append(text('\'')), + text(priority, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args4 BULK_REMOVE_TEMP_CHATMETA_SUCCESS = (holder, type, priority, context) -> prefixed(translatable() + // "&b{}&a had all temporary {}es at priority &b{}&a removed in context {}&a." + .key("luckperms.command.generic.chat-meta.remove-temp-bulk") + .color(GREEN) + .args( + text(holder, AQUA), + text(type.toString() + "es"), + text(priority, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args4 ALREADY_HAS_META = (holder, key, value, context) -> prefixed(translatable() + // "&b{}&a already has meta key &f'{}&f'&a set to &f'{}&f'&a in context {}&a." + .key("luckperms.command.generic.meta.already-has") + .color(GREEN) + .args( + text(holder, AQUA), + text().color(WHITE).append(text('\'')).append(text(key)).append(text('\'')), + text().color(WHITE).append(text('\'')).append(formatColoredValue(value)).append(text('\'')), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args4 ALREADY_HAS_TEMP_META = (holder, key, value, context) -> prefixed(translatable() + // "&b{}&a already has meta key &f'{}&f'&a temporarily set to &f'{}&f'&a in context {}&a." + .key("luckperms.command.generic.meta.already-has-temp") + .color(GREEN) + .args( + text(holder, AQUA), + text().color(WHITE).append(text('\'')).append(text(key)).append(text('\'')), + text().color(WHITE).append(text('\'')).append(formatColoredValue(value)).append(text('\'')), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 DOESNT_HAVE_META = (holder, key, context) -> prefixed(translatable() + // "&b{}&a doesn't have meta key &f'{}&f'&a set in context {}&a." + .key("luckperms.command.generic.meta.doesnt-have") + .color(GREEN) + .args( + text(holder, AQUA), + text().color(WHITE).append(text('\'')).append(text(key)).append(text('\'')), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 DOESNT_HAVE_TEMP_META = (holder, key, context) -> prefixed(translatable() + // "&b{}&a doesn't have meta key &f'{}&f'&a set temporarily in context {}&a." + .key("luckperms.command.generic.meta.doesnt-have-temp") + .color(GREEN) + .args( + text(holder, AQUA), + text().color(WHITE).append(text('\'')).append(text(key)).append(text('\'')), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args4 SET_META_SUCCESS = (key, value, holder, context) -> prefixed(translatable() + // "&aSet meta key &f'{}&f'&a to &f'{}&f'&a for &b{}&a in context {}&a." + .key("luckperms.command.generic.meta.set") + .color(GREEN) + .args( + text().color(WHITE).append(text('\'')).append(text(key)).append(text('\'')), + text().color(WHITE).append(text('\'')).append(formatColoredValue(value)).append(text('\'')), + text(holder, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args5 SET_META_TEMP_SUCCESS = (key, value, holder, duration, context) -> prefixed(translatable() + // "&aSet meta key &f'{}&f'&a to &f'{}&f'&a for &b{}&a for a duration of &b{}&a in context {}&a." + .key("luckperms.command.generic.meta.set-temp") + .color(GREEN) + .args( + text().color(WHITE).append(text('\'')).append(text(key)).append(text('\'')), + text().color(WHITE).append(text('\'')).append(formatColoredValue(value)).append(text('\'')), + text(holder, AQUA), + text(DurationFormatter.LONG.format(duration), AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 UNSET_META_SUCCESS = (key, holder, context) -> prefixed(translatable() + // "&aUnset meta key &f'{}&f'&a for &b{}&a in context {}&a." + .key("luckperms.command.generic.meta.unset") + .color(GREEN) + .args( + text().color(WHITE).append(text('\'')).append(text(key)).append(text('\'')), + text(holder, AQUA), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args3 UNSET_META_TEMP_SUCCESS = (key, holder, context) -> prefixed(translatable() + // "&aUnset temporary meta key &f'{}&f'&a for &b{}&a in context {}&a." + .key("luckperms.command.generic.meta.unset-temp") + .color(GREEN) + .args( + text().color(WHITE).append(text('\'')).append(text(key)).append(text('\'')), + text(holder, BLUE), + formatContextSet(context) + ) + .append(FULL_STOP) + ); + + Args0 BULK_UPDATE_MUST_USE_CONSOLE = () -> prefixed(translatable() + // "&cThe bulk update command can only be used from the console." + .key("luckperms.command.bulkupdate.must-use-console") + .color(RED) + .append(FULL_STOP) + ); + + Args0 BULK_UPDATE_INVALID_DATA_TYPE = () -> prefixed(translatable() + // "&cInvalid type. Was expecting 'all', 'users' or 'groups'." + .key("luckperms.command.bulkupdate.invalid-data-type") + .color(RED) + .args(text("'all', 'users' or 'groups'")) + .append(FULL_STOP) + ); + + Args1 BULK_UPDATE_INVALID_CONSTRAINT = invalid -> prefixed(translatable() + // &cInvalid constraint &4{}&c. Constraints should be in the format '&f &c'." + .key("luckperms.command.bulkupdate.invalid-constraint") + .color(RED) + .args(text(invalid, DARK_RED)) + .append(FULL_STOP) + .append(space()) + .append(translatable() + .key("luckperms.command.bulkupdate.invalid-constraint-format") + .args(text() + .append(text('\'')) + .append(text(" ", WHITE)) + .append(text('\'')) + ) + .append(FULL_STOP)) + ); + + Args1 BULK_UPDATE_INVALID_COMPARISON = invalid -> prefixed(translatable() + // "&cInvalid comparison operator '&4{}&c'. Expected one of the following: &f== != ~~ ~!" + .key("luckperms.command.bulkupdate.invalid-comparison") + .color(RED) + .args(text() + .append(text('\'')) + .append(text(invalid, DARK_RED)) + .append(text('\'')) + ) + .append(FULL_STOP) + .append(space()) + .append(translatable() + .key("luckperms.command.bulkupdate.invalid-comparison-format") + .color(WHITE) + .args(text("== != ~~ ~!"))) + ); + + Args1 BULK_UPDATE_QUEUED = id -> prefixed(translatable() + // "&aBulk update operation was queued. &7(&f{}&7)" + .key("luckperms.command.bulkupdate.queued") + .color(GREEN) + .append(FULL_STOP) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(text(id, WHITE)) + .append(CLOSE_BRACKET) + ) + ); + + Args2 BULK_UPDATE_CONFIRM = (label, id) -> prefixed(translatable() + // "&aRun &b/{} bulkupdate confirm {} &ato execute the update." + .key("luckperms.command.bulkupdate.confirm") + .color(GREEN) + .args(text("/" + label + " bulkupdate confirm " + id, AQUA)) + .append(FULL_STOP) + ); + + Args1 BULK_UPDATE_UNKNOWN_ID = id -> prefixed(translatable() + // "&aOperation with id &b{}&a does not exist or has expired." + .key("luckperms.command.bulkupdate.unknown-id") + .color(GREEN) + .args(text(id, AQUA)) + .append(FULL_STOP) + ); + + Args0 BULK_UPDATE_STARTING = () -> prefixed(translatable() + // "&aRunning bulk update." + .key("luckperms.command.bulkupdate.starting") + .color(GREEN) + .append(FULL_STOP) + ); + + Args0 BULK_UPDATE_SUCCESS = () -> prefixed(translatable() + // "&bBulk update completed successfully." + .key("luckperms.command.bulkupdate.success") + .color(AQUA) + .append(FULL_STOP) + ); + + Args0 BULK_UPDATE_FAILURE = () -> prefixed(translatable() + // "&cBulk update failed, check the console for errors." + .key("luckperms.command.bulkupdate.failure") + .color(RED) + .append(FULL_STOP) + ); + + Args4 USER_INFO_GENERAL = (username, uuid, mojang, online) -> join(newline(), + // "&b&l> &bUser Info: &f{}" + // "&f- &3UUID: &f{}" + // "&f &7(type: {}&7)" + // "&f- &3Status: {}" + prefixed(text() + .color(AQUA) + .append(text('>', style(BOLD))) + .append(space()) + .append(translatable("luckperms.command.user.info.title")) + .append(text(": ")) + .append(text(username, WHITE))), + prefixed(text() + .color(DARK_AQUA) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.user.info.uuid-key")) + .append(text(": ")) + .append(text(uuid, WHITE))), + prefixed(text() + .color(GRAY) + .append(text(" ")) + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.user.info.uuid-type-key")) + .append(text(": ")) + .append(mojang ? translatable("luckperms.command.user.info.uuid-type.mojang", DARK_GREEN) : translatable("luckperms.command.user.info.uuid-type.not-mojang", DARK_GRAY)) + .append(CLOSE_BRACKET)), + prefixed(text() + .color(DARK_AQUA) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.user.info.status-key")) + .append(text(": ")) + .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(), + // "&f- &aContextual Data: &7(mode: {}&7)" + // " &3Contexts: {}" + // " &3Prefix: {}" + // " &3Suffix: {}" + // " &3Primary Group: &f{}" + // " &3Meta: {}" + prefixed(text() + .append(text('-', WHITE)) + .append(space()) + .append(translatable("luckperms.command.generic.contextual-data.title", GREEN)) + .append(text(": ", GREEN)) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.generic.contextual-data.mode.key")) + .append(text(": ")) + .append(active ? translatable("luckperms.command.generic.contextual-data.mode.active-player", DARK_GREEN) : translatable("luckperms.command.generic.contextual-data.mode.server", DARK_GRAY)) + .append(CLOSE_BRACKET) + )), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.generic.contextual-data.contexts-key")) + .append(text(": ")) + .append(formatContextSetBracketed(contexts, translatable("luckperms.command.generic.contextual-data.null-result", AQUA)))), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.generic.contextual-data.prefix-key")) + .append(text(": ")) + .apply(builder -> { + if (prefix == null) { + builder.append(translatable("luckperms.command.generic.contextual-data.null-result", AQUA)); + } else { + builder.append(text() + .color(WHITE) + .append(text('"')) + .append(formatColoredValue(prefix)) + .append(text('"')) + ); + } + })), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.generic.contextual-data.suffix-key")) + .append(text(": ")) + .apply(builder -> { + if (suffix == null) { + builder.append(translatable("luckperms.command.generic.contextual-data.null-result", AQUA)); + } else { + builder.append(text() + .color(WHITE) + .append(text('"')) + .append(formatColoredValue(suffix)) + .append(text('"')) + ); + } + })), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.generic.contextual-data.primary-group-key")) + .append(text(": ")) + .append(text(primaryGroup, WHITE))), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.generic.contextual-data.meta-key")) + .append(text(": ")) + .apply(builder -> { + if (meta.isEmpty()) { + builder.append(translatable("luckperms.command.generic.contextual-data.null-result", AQUA)); + } else { + List entries = meta.entrySet().stream() + .flatMap(entry -> entry.getValue().stream().map(value -> Maps.immutableEntry(entry.getKey(), value))) + .map(entry -> text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(text(entry.getKey(), GRAY)) + .append(text('=', GRAY)) + .append(text().color(WHITE).append(formatColoredValue(entry.getValue()))) + .append(CLOSE_BRACKET) + .build() + ) + .collect(Collectors.toList()); + builder.append(join(space(), entries)); + } + })) + ); + + Args0 INFO_PARENT_HEADER = () -> prefixed(text() + .color(GREEN) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.generic.info.parent.title")) + .append(text(':')) + ); + + Args0 INFO_TEMP_PARENT_HEADER = () -> prefixed(text() + .color(GREEN) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.generic.info.parent.temporary-title")) + .append(text(':')) + ); + + Args1 INFO_PARENT_NODE_ENTRY = node -> prefixed(text() + .append(text(" >", DARK_AQUA)) + .append(space()) + .append(text(node.getGroupName(), WHITE)) + .append(space()) + .append(formatContextSetBracketed(node.getContexts(), empty())) + ); + + Args1 INFO_PARENT_TEMPORARY_NODE_ENTRY = node -> join(newline(), + prefixed(text() + .append(text(" > ", DARK_AQUA)) + .append(text(node.getGroupName(), WHITE)) + .append(space()) + .append(formatContextSetBracketed(node.getContexts(), empty()))), + prefixed(text() + .color(DARK_GREEN) + .append(text(" - ")) + .append(translatable("luckperms.command.generic.info.expires-in")) + .append(space()) + .append(text(DurationFormatter.LONG.format(node.getExpiryDuration())))) + ); + + Args0 USER_REMOVEGROUP_ERROR_PRIMARY = () -> prefixed(translatable() + // "&aYou cannot remove a user from their primary group." + .key("luckperms.command.user.removegroup.error-primary") + .color(GREEN) + .append(FULL_STOP) + ); + + Args2 USER_PRIMARYGROUP_SUCCESS = (user, group) -> prefixed(translatable() + // "&b{}&a's primary group was set to &b{}&a." + .key("luckperms.command.user.primarygroup.set") + .color(GREEN) + .args(text(user, AQUA), text(group, AQUA)) + .append(FULL_STOP) + ); + + Args1 USER_PRIMARYGROUP_WARN_OPTION = option -> prefixed(translatable() + // "&aWarning: The primary group calculation method being used by this server ({}) may not reflect this change." + .key("luckperms.command.user.primarygroup.warn-option") + .color(GREEN) + .args(text(option)) + .append(FULL_STOP) + ); + + Args2 USER_PRIMARYGROUP_ERROR_ALREADYHAS = (user, group) -> prefixed(translatable() + // "&b{}&a already has &b{}&a set as their primary group." + .key("luckperms.command.user.primarygroup.already-has") + .color(GREEN) + .args(text(user, AQUA), text(group, AQUA)) + .append(FULL_STOP) + ); + + Args2 USER_PRIMARYGROUP_ERROR_NOTMEMBER = (user, group) -> prefixed(translatable() + // "&b{}&a was not already a member of &b{}&a, adding them now." + .key("luckperms.command.user.primarygroup.not-member") + .color(GREEN) + .args(text(user, AQUA), text(group, AQUA)) + .append(FULL_STOP) + ); + + Args2 USER_TRACK_ERROR_NOT_CONTAIN_GROUP = (user, track) -> prefixed(translatable() + // "&b{}&a isn't already in any groups on &b{}&a." + .key("luckperms.command.user.track.error-not-contain-group") + .color(GREEN) + .args(text(user, AQUA), text(track, AQUA)) + .append(FULL_STOP) + ); + + Args0 USER_TRACK_ERROR_AMBIGUOUS_TRACK_SELECTION = () -> prefixed(translatable() + // "&cUnsure which track to use. Please specify it as an argument." + .key("luckperms.command.user.track.unsure-which-track") + .color(RED) + .append(FULL_STOP) + ); + + Args4 USER_TRACK_ADDED_TO_FIRST = (user, track, group, context) -> prefixed(translatable() + // "&b{}&a isn't in any groups on &b{}&a, so they were added to the first group, &b{}&a in context {}&a." + .key("luckperms.command.user.promote.added-to-first") + .color(GREEN) + .args(text(user, AQUA), text(track, AQUA), text(group, AQUA), formatContextSet(context)) + .append(FULL_STOP) + ); + + Args2 USER_PROMOTE_NOT_ON_TRACK = (user, track) -> prefixed(translatable() + // "&b{}&a isn't in any groups on &b{}&a, so was not promoted." + .key("luckperms.command.user.demote.end-of-track-not-removed") + .color(GREEN) + .args(text(user, AQUA), text(track, AQUA)) + .append(FULL_STOP) + ); + + Args5 USER_PROMOTE_SUCCESS = (user, track, from, to, context) -> prefixed(translatable() + // "&aPromoting &b{}&a along track &b{}&a from &b{}&a to &b{}&a in context {}&a." + .key("luckperms.command.user.promote.success") + .color(GREEN) + .args(text(user, AQUA), text(track, AQUA), text(from, AQUA), text(to, AQUA), formatContextSet(context)) + .append(FULL_STOP) + ); + + Args2 USER_PROMOTE_ERROR_ENDOFTRACK = (track, user) -> prefixed(translatable() + // "&aThe end of track &b{}&a was reached, unable to promote &b{}&a." + .key("luckperms.command.user.promote.end-of-track") + .color(GREEN) + .args(text(track, AQUA), text(user, AQUA)) + .append(FULL_STOP) + ); + + Args1 USER_PROMOTE_ERROR_MALFORMED = name -> join(newline(), + // "&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() + .key("luckperms.command.user.promote.next-group-deleted") + .color(GREEN) + .args(text(name, AQUA)) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.user.promote.unable-to-promote")) + .append(FULL_STOP)), + prefixed(translatable() + .key("luckperms.command.user.track.missing-group-advice") + .color(GREEN) + .append(FULL_STOP)) + ); + + Args5 USER_DEMOTE_SUCCESS = (user, track, from, to, context) -> prefixed(translatable() + // "&aDemoting &b{}&a along track &b{}&a from &b{}&a to &b{}&a in context {}&a." + .key("luckperms.command.user.demote.success") + .color(GREEN) + .args(text(user, AQUA), text(track, AQUA), text(from, AQUA), text(to, AQUA), formatContextSet(context)) + .append(FULL_STOP) + ); + + Args3 USER_DEMOTE_ENDOFTRACK = (track, user, group) -> prefixed(translatable() + // "&aThe end of track &b{}&a was reached, so &b{}&a was removed from &b{}&a." + .key("luckperms.command.user.demote.end-of-track") + .color(GREEN) + .args(text(track, AQUA), text(user, AQUA), text(group, AQUA)) + .append(FULL_STOP) + ); + + Args2 USER_DEMOTE_ENDOFTRACK_NOT_REMOVED = (track, user) -> prefixed(translatable() + // "&aThe end of track &b{}&a was reached, but &b{}&a was not removed from the first group." + .key("luckperms.command.user.demote.end-of-track-not-removed") + .color(GREEN) + .args(text(track, AQUA), text(user, AQUA)) + .append(FULL_STOP) + ); + + Args1 USER_DEMOTE_ERROR_MALFORMED = name -> join(newline(), + // "&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() + .key("luckperms.command.user.demote.previous-group-deleted") + .color(GREEN) + .args(text(name, AQUA)) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.user.demote.unable-to-demote")) + .append(FULL_STOP)), + prefixed(translatable() + .key("luckperms.command.user.track.missing-group-advice") + .color(GREEN) + .append(FULL_STOP)) + ); + + Args3 GROUP_INFO_GENERAL = (name, displayName, weight) -> join(newline(), + // "&b&l> &bGroup Info: &f{}" + // "&f- &3Display Name: &f{}" + // "&f- &3Weight: &f{}" + prefixed(text() + .color(AQUA) + .append(text('>', style(BOLD))) + .append(space()) + .append(translatable("luckperms.command.group.info.title")) + .append(text(": ")) + .append(text(name, WHITE))), + prefixed(text() + .color(DARK_AQUA) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.group.info.display-name-key")) + .append(text(": ")) + .append(text(displayName, WHITE))), + prefixed(text() + .color(DARK_AQUA) + .append(text("- ", WHITE)) + .append(translatable("luckperms.command.group.info.weight-key")) + .append(text(": ")) + .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(), + // "&f- &aContextual Data: &7(mode: &8server&7)" + // " &3Prefix: {}" + // " &3Suffix: {}" + // " &3Meta: {}" + prefixed(text() + .append(text('-', WHITE)) + .append(space()) + .append(translatable("luckperms.command.generic.contextual-data.title", GREEN)) + .append(text(": ", GREEN)) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.generic.contextual-data.mode.key")) + .append(text(": ")) + .append(translatable("luckperms.command.generic.contextual-data.mode.server", DARK_GRAY)) + .append(CLOSE_BRACKET) + )), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.generic.contextual-data.prefix-key")) + .append(text(": ")) + .apply(builder -> { + if (prefix == null) { + builder.append(translatable("luckperms.command.generic.contextual-data.null-result", AQUA)); + } else { + builder.append(text() + .color(WHITE) + .append(text('"')) + .append(text(prefix)) + .append(text('"')) + ); + } + })), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.generic.contextual-data.suffix-key")) + .append(text(": ")) + .apply(builder -> { + if (suffix == null) { + builder.append(translatable("luckperms.command.generic.contextual-data.null-result", AQUA)); + } else { + builder.append(text() + .color(WHITE) + .append(text('"')) + .append(text(suffix)) + .append(text('"')) + ); + } + })), + prefixed(text() + .color(DARK_AQUA) + .append(text(" ")) + .append(translatable("luckperms.command.generic.contextual-data.meta-key")) + .append(text(": ")) + .apply(builder -> { + if (meta.isEmpty()) { + builder.append(translatable("luckperms.command.generic.contextual-data.null-result", AQUA)); + } else { + List entries = meta.entrySet().stream() + .flatMap(entry -> entry.getValue().stream().map(value -> Maps.immutableEntry(entry.getKey(), value))) + .map(entry -> text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(text(entry.getKey(), GRAY)) + .append(text('=', GRAY)) + .append(text().color(WHITE).append(formatColoredValue(entry.getValue()))) + .append(CLOSE_BRACKET) + .build() + ) + .collect(Collectors.toList()); + builder.append(join(space(), entries)); + } + })) + ); + + Args2 GROUP_SET_WEIGHT = (weight, group) -> prefixed(translatable() + // "&aSet weight to &b{}&a for group &b{}&a." + .key("luckperms.command.group.setweight.set") + .color(GREEN) + .args(text(weight, AQUA), text(group, AQUA)) + .append(FULL_STOP) + ); + + Args1 GROUP_SET_DISPLAY_NAME_DOESNT_HAVE = group -> prefixed(translatable() + // "&b{}&a doesn't have a display name set." + .key("luckperms.command.group.setdisplayname.doesnt-have") + .color(GREEN) + .args(text(group, AQUA)) + .append(FULL_STOP) + ); + + Args2 GROUP_SET_DISPLAY_NAME_ALREADY_HAS = (group, displayName) -> prefixed(translatable() + // "&b{}&a already has a display name of &b{}&a." + .key("luckperms.command.group.setdisplayname.already-has") + .color(GREEN) + .args(text(group, AQUA), text(displayName, AQUA)) + .append(FULL_STOP) + ); + + Args2 GROUP_SET_DISPLAY_NAME_ALREADY_IN_USE = (displayName, group) -> prefixed(translatable() + // "&aThe display name &b{}&a is already being used by &b{}&a." + .key("luckperms.command.group.setdisplayname.already-in-use") + .color(GREEN) + .args(text(displayName, AQUA), text(group, AQUA)) + .append(FULL_STOP) + ); + + Args3 GROUP_SET_DISPLAY_NAME = (displayName, group, context) -> prefixed(translatable() + // "&aSet display name to &b{}&a for group &b{}&a in context {}&a." + .key("luckperms.command.group.setdisplayname.set") + .color(GREEN) + .args(text(displayName, AQUA), text(group, AQUA), formatContextSet(context)) + .append(FULL_STOP) + ); + + Args2 GROUP_SET_DISPLAY_NAME_REMOVED = (group, context) -> prefixed(translatable() + // "&aRemoved display name for group &b{}&a in context {}&a." + .key("luckperms.command.group.setdisplayname.removed") + .color(GREEN) + .args(text(group, AQUA), formatContextSet(context)) + .append(FULL_STOP) + ); + + Args2 TRACK_INFO = (name, path) -> join(newline(), + // "&b&l> &bShowing Track: &f{}" + "\n" + + // "&f- &7Path: &f{}", + prefixed(text() + .color(AQUA) + .append(text('>', style(BOLD))) + .append(space()) + .append(translatable("luckperms.command.track.info.showing-track")) + .append(text(": ")) + .append(text(name, WHITE))), + prefixed(text() + .color(GRAY) + .append(text('-', WHITE)) + .append(space()) + .append(translatable("luckperms.command.track.info.path-property")) + .append(text(": ")) + .append(path)) + ); + + Args1> TRACK_PATH = groups -> prefixed(formatTrackPath(groups)); + + Args2, String> TRACK_PATH_HIGHLIGHTED = (groups, highlighted) -> prefixed(formatTrackPath(groups, highlighted)); + + Args4, String, String, Boolean> TRACK_PATH_HIGHLIGHTED_PROGRESSION = (groups, highlightedFirst, highlightedSecond, reversed) -> prefixed(formatTrackPath(groups, highlightedFirst, highlightedSecond, reversed)); + + Args1 TRACK_CLEAR = name -> prefixed(translatable() + // "&b{}&a's groups track was cleared." + .key("luckperms.command.track.clear") + .color(GREEN) + .args(text(name, AQUA)) + .append(FULL_STOP) + ); + + Args2 TRACK_APPEND_SUCCESS = (group, track) -> prefixed(translatable() + // "&aGroup &b{}&a was appended to track &b{}&a." + .key("luckperms.command.track.append.success") + .color(GREEN) + .args(text(group, AQUA), text(track, AQUA)) + .append(FULL_STOP) + ); + + Args3 TRACK_INSERT_SUCCESS = (group, track, position) -> prefixed(translatable() + // "&aGroup &b{}&a was inserted into track &b{}&a at position &b{}&a." + .key("luckperms.command.track.insert.success") + .color(GREEN) + .args(text(group, AQUA), text(track, AQUA), text(position, AQUA)) + .append(FULL_STOP) + ); + + Args1 TRACK_INSERT_ERROR_NUMBER = invalid -> prefixed(translatable() + // "&cExpected number but instead received: {}" + .key("luckperms.command.track.insert.error-number") + .color(RED) + .args(text(invalid)) + .append(FULL_STOP) + ); + + Args1 TRACK_INSERT_ERROR_INVALID_POS = position -> prefixed(translatable() + // "&cUnable to insert at position &4{}&c. &7(invalid position)" + .key("luckperms.command.track.insert.error-invalid-pos") + .color(RED) + .args(text(position, DARK_RED)) + .append(FULL_STOP) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.track.insert.error-invalid-pos-reason")) + .append(CLOSE_BRACKET)) + ); + + Args2 TRACK_REMOVE_SUCCESS = (group, track) -> prefixed(translatable() + // "&aGroup &b{}&a was removed from track &b{}&a." + .key("luckperms.command.track.remove.success") + .color(GREEN) + .args(text(group, AQUA), text(track, AQUA)) + .append(FULL_STOP) + ); + + Args0 LOG_LOAD_ERROR = () -> prefixed(translatable() + // "&cThe log could not be loaded." + .key("luckperms.command.log.load-error") + .color(RED) + .append(FULL_STOP) + ); + + Args1 LOG_INVALID_PAGE_RANGE = maxPage -> prefixed(text() + // "&cInvalid page number. Please enter a value between &41&c and &4{}&c." + .color(RED) + .append(translatable("luckperms.command.log.invalid-page")) + .append(FULL_STOP) + .append(space()) + .append(translatable() + .key("luckperms.command.log.invalid-page-range") + .args(text(1, DARK_RED), text(maxPage, DARK_RED)) + ) + .append(FULL_STOP) + ); + + Args0 LOG_NO_ENTRIES = () -> prefixed(translatable() + // "&bNo log entries to show." + .key("luckperms.command.log.empty") + .color(AQUA) + .append(FULL_STOP) + ); + + Args2 LOG_ENTRY = (pos, action) -> join(newline(), + // "&b#{} &8(&7{} ago&8) &8(&e{}&8) [&a{}&8] (&b{}&8)" + // "&7> &f{}" + prefixed(text() + .append(text("#" + pos, AQUA)) + .append(space()) + .append(text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(text() + .content(DurationFormatter.CONCISE_LOW_ACCURACY.format(action.getDurationSince()) + " ago") + .color(GRAY) + ) + .append(CLOSE_BRACKET) + ) + .append(space()) + .append(text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(text(action.getSourceFriendlyString(), YELLOW)) + .append(CLOSE_BRACKET) + ) + .append(space()) + .append(text() + .color(DARK_GRAY) + .append(text('[')) + .append(text(LoggedAction.getTypeCharacter(action.getTarget().getType()), GREEN)) + .append(text(']')) + ) + .append(space()) + .append(text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(text(action.getTargetFriendlyString(), AQUA)) + .append(CLOSE_BRACKET) + )), + prefixed(text() + .append(text("> ", GRAY)) + .append(text(action.getDescription(), WHITE))) + ); + + Args0 LOG_NOTIFY_CONSOLE = () -> prefixed(translatable() + // "&cCannot toggle notifications for console." + .key("luckperms.command.log.notify.error-console") + .color(RED) + .append(FULL_STOP) + ); + + Args0 LOG_NOTIFY_TOGGLE_ON = () -> prefixed(translatable() + // "&aEnabled&b logging output." + .key("luckperms.command.log.notify.changed-state") + .color(AQUA) + .args(translatable("luckperms.command.log.notify.enabled-term", GREEN)) + .append(FULL_STOP) + ); + + Args0 LOG_NOTIFY_TOGGLE_OFF = () -> prefixed(translatable() + // "&cDisabled&b logging output." + .key("luckperms.command.log.notify.changed-state") + .color(AQUA) + .args(translatable("luckperms.command.log.notify.disabled-term", RED)) + .append(FULL_STOP) + ); + + Args0 LOG_NOTIFY_ALREADY_ON = () -> prefixed(translatable() + // "&cYou are already receiving notifications." + .key("luckperms.command.log.notify.already-on") + .color(RED) + .append(FULL_STOP) + ); + + Args0 LOG_NOTIFY_ALREADY_OFF = () -> prefixed(translatable() + // "&cYou aren't currently receiving notifications." + .key("luckperms.command.log.notify.already-off") + .color(RED) + .append(FULL_STOP) + ); + + Args0 LOG_NOTIFY_UNKNOWN = () -> prefixed(translatable() + // "&cState unknown. Expecting \"on\" or \"off\"." + .key("luckperms.command.log.notify.invalid-state") + .color(RED) + .args(text("\"on\""), text("\"off\"")) + .append(FULL_STOP) + ); + + Args3 LOG_SEARCH_HEADER = (query, page, totalPages) -> prefixed(text() + // "&aShowing recent actions for query &b{} &7(page &f{}&7 of &f{}&7)" + .color(GREEN) + .append(translatable() + .key("luckperms.command.log.show.search") + .args(text(query, AQUA)) + ) + .append(text(" ")) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.misc.page") + .args(text(page, WHITE), text(totalPages, WHITE)) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args2 LOG_RECENT_HEADER = (page, totalPages) -> prefixed(text() + // "&aShowing recent actions &7(page &f{}&7 of &f{}&7)" + .color(GREEN) + .append(translatable("luckperms.command.log.show.recent")) + .append(text(" ")) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.misc.page") + .args(text(page, WHITE), text(totalPages, WHITE)) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args3 LOG_RECENT_BY_HEADER = (name, page, totalPages) -> prefixed(text() + // "&aShowing recent actions by &b{} &7(page &f{}&7 of &f{}&7)" + .color(GREEN) + .append(translatable() + .key("luckperms.command.log.show.by") + .args(text(name, AQUA)) + ) + .append(text(" ")) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.misc.page") + .args(text(page, WHITE), text(totalPages, WHITE)) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args3 LOG_HISTORY_USER_HEADER = (name, page, totalPages) -> prefixed(text() + // "&aShowing history for user &b{} &7(page &f{}&7 of &f{}&7)" + .color(GREEN) + .append(translatable() + .key("luckperms.command.log.show.history") + .args(text("user"), text(name, AQUA)) + ) + .append(text(" ")) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.misc.page") + .args(text(page, WHITE), text(totalPages, WHITE)) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args3 LOG_HISTORY_GROUP_HEADER = (name, page, totalPages) -> prefixed(text() + // "&aShowing history for group &b{} &7(page &f{}&7 of &f{}&7)" + .color(GREEN) + .append(translatable() + .key("luckperms.command.log.show.history") + .args(text("group"), text(name, AQUA)) + ) + .append(text(" ")) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.misc.page") + .args(text(page, WHITE), text(totalPages, WHITE)) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args3 LOG_HISTORY_TRACK_HEADER = (name, page, totalPages) -> prefixed(text() + // "&aShowing history for track &b{} &7(page &f{}&7 of &f{}&7)" + .color(GREEN) + .append(translatable() + .key("luckperms.command.log.show.history") + .args(text("track"), text(name, AQUA)) + ) + .append(text(" ")) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(translatable() + .key("luckperms.command.misc.page") + .args(text(page, WHITE), text(totalPages, WHITE)) + ) + .append(CLOSE_BRACKET) + ) + ); + + Args0 IMPORT_ALREADY_RUNNING = () -> prefixed(text() + // "&cAnother import process is already running. Please wait for it to finish and try again." + .color(RED) + .append(translatable("luckperms.command.import.already-running")) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.misc.wait-to-finish")) + .append(FULL_STOP) + ); + + Args0 EXPORT_ALREADY_RUNNING = () -> prefixed(text() + // "&cAnother export process is already running. Please wait for it to finish and try again." + .color(RED) + .append(translatable("luckperms.command.export.already-running")) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.misc.wait-to-finish")) + .append(FULL_STOP) + ); + + Args1 FILE_NOT_WITHIN_DIRECTORY = file -> prefixed(text() + // "&cError: File &4{}&c must be a direct child of the data directory." + .color(RED) + .append(translatable("luckperms.command.import.error-term")) + .append(text(": ")) + .append(translatable("luckperms.command.misc.file-must-be-in-data", text(file, DARK_RED))) + .append(FULL_STOP) + ); + + Args1 EXPORT_FILE_ALREADY_EXISTS = file -> prefixed(text() + // "&cError: File &4{}&c already exists." + .color(RED) + .append(translatable("luckperms.command.export.error-term")) + .append(text(": ")) + .append(translatable("luckperms.command.export.file.already-exists", text(file, DARK_RED))) + .append(FULL_STOP) + ); + + Args1 EXPORT_FILE_NOT_WRITABLE = file -> prefixed(text() + // "&cError: File &4{}&c is not writable." + .color(RED) + .append(translatable("luckperms.command.export.error-term")) + .append(text(": ")) + .append(translatable("luckperms.command.export.file.not-writable", text(file, DARK_RED))) + .append(FULL_STOP) + ); + + Args0 EXPORT_FILE_FAILURE = () -> prefixed(translatable() + // "&cAn unexpected error occured whilst writing to the file." + .key("luckperms.command.export.file-unexpected-error-writing") + .color(RED) + .append(FULL_STOP) + ); + + Args1 EXPORT_FILE_SUCCESS = file -> prefixed(translatable() + // "&aSuccessfully exported to &b{}&a." + .key("luckperms.command.export.file.success") + .color(GREEN) + .args(text(file, AQUA)) + .append(FULL_STOP) + ); + + Args2 EXPORT_WEB_SUCCESS = (pasteId, label) -> join(newline(), + // "&aExport code: &7{}" + // "&7Use the following command to import:" + // "&a/{} import {} --upload" + prefixed(text() + .color(GREEN) + .append(translatable("luckperms.command.export.web.export-code")) + .append(text(": ")) + .append(text(pasteId, GRAY))), + translatable() + .key("luckperms.command.export.web.import-command-description") + .color(GRAY) + .append(text(":")), + text("/" + label + " import " + pasteId + " --upload", GREEN)); + + Args1 IMPORT_FILE_DOESNT_EXIST = file -> prefixed(text() + // "&cError: File &4{}&c does not exist." + .color(RED) + .append(translatable("luckperms.command.import.error-term")) + .append(text(": ")) + .append(translatable("luckperms.command.import.file.doesnt-exist", text(file, DARK_RED))) + .append(FULL_STOP) + ); + + Args1 IMPORT_FILE_NOT_READABLE = file -> prefixed(text() + // "&cError: File &4{}&c is not readable." + .color(RED) + .append(translatable("luckperms.command.import.error-term")) + .append(text(": ")) + .append(translatable("luckperms.command.import.file.not-readable", text(file, DARK_RED))) + .append(FULL_STOP) + ); + + Args0 IMPORT_FILE_READ_FAILURE = () -> prefixed(text() + // "&cAn unexpected error occured whilst reading from the import file. (is it the correct format?)" + .color(RED) + .append(translatable("luckperms.command.import.file.unexpected-error-reading")) + .append(FULL_STOP) + .append(space()) + .append(text() + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.import.file.correct-format")) + .append(CLOSE_BRACKET) + ) + ); + + Args1 IMPORT_WEB_INVALID_CODE = code -> prefixed(text() + // "&cInvalid code. &7({})" + .color(RED) + .append(translatable("luckperms.command.misc.invalid-code")) + .append(FULL_STOP) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(text(code)) + .append(CLOSE_BRACKET) + ) + ); + + Args2 HTTP_REQUEST_FAILURE = (code, message) -> prefixed(text() + // "&cUnable to communicate with bytebin. (response code &4{}&c, message='{}')" + .color(RED) + .append(translatable("luckperms.command.misc.bytebin-unable-to-communicate")) + .append(FULL_STOP) + .append(space()) + .append(text() + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.misc.response-code-key")) + .append(space()) + .append(text(code)) + .append(text(", ")) + .append(translatable("luckperms.command.misc.error-message-key")) + .append(text("='")) + .append(text(message)) + .append(text("'")) + .append(CLOSE_BRACKET) + ) + ); + + Args0 HTTP_UNKNOWN_FAILURE = () -> prefixed(text() + // "&cUnable to communicate with bytebin. Check the console for errors." + .color(RED) + .append(translatable("luckperms.command.misc.bytebin-unable-to-communicate")) + .append(FULL_STOP) + .append(space()) + .append(translatable("luckperms.command.misc.check-console-for-errors")) + .append(FULL_STOP) + ); + + Args1 IMPORT_UNABLE_TO_READ = code -> prefixed(text() + // "&cUnable to read data using the given code. &7({})" + .color(RED) + .append(translatable("luckperms.command.import.web.unable-to-read")) + .append(FULL_STOP) + .append(space()) + .append(text() + .color(GRAY) + .append(OPEN_BRACKET) + .append(text(code)) + .append(CLOSE_BRACKET) + ) + ); + + Args3 IMPORT_PROGRESS = (percent, processed, total) -> prefixed(text() + // "&b(Import) &b-> &f{}&f% complete &7- &b{}&f/&b{} &foperations complete." + .append(text() + .color(AQUA) + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.import.term")) + .append(CLOSE_BRACKET) + ) + .append(text(" -> ", AQUA)) + .append(translatable("luckperms.command.import.progress.percent", WHITE, text(percent))) + .append(text(" - ", GRAY)) + .append(translatable() + .key("luckperms.command.import.progress.operations") + .color(WHITE) + .args(text(processed, AQUA), text(total, AQUA)) + .append(FULL_STOP) + ) + ); + + Args0 IMPORT_START = () -> prefixed(text() + // "&b(Import) &b-> &fStarting import process." + .color(WHITE) + .append(text() + .color(AQUA) + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.import.term")) + .append(CLOSE_BRACKET) + ) + .append(text(" -> ", AQUA)) + .append(translatable("luckperms.command.import.starting")) + .append(FULL_STOP) + ); + + Args1 IMPORT_INFO = msg -> prefixed(text() + // "&b(Import) &b-> &f{}." + .color(WHITE) + .append(text() + .color(AQUA) + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.import.term")) + .append(CLOSE_BRACKET) + ) + .append(text(" -> ", AQUA)) + .append(text(msg)) + .append(FULL_STOP) + ); + + Args1 IMPORT_END_COMPLETE = seconds -> prefixed(text() + // "&b(Import) &a&lCOMPLETED &7- took &b{} &7seconds." + .color(GRAY) + .append(text() + .color(AQUA) + .append(OPEN_BRACKET) + .append(translatable("luckperms.command.import.term")) + .append(CLOSE_BRACKET) + ) + .append(space()) + .append(translatable("luckperms.command.import.completed", GREEN, BOLD)) + .append(text(" - ")) + .append(translatable("luckperms.command.import.duration", text(seconds, AQUA))) + .append(FULL_STOP) + ); + + static Component formatColoredValue(String value) { + return LegacyComponentSerializer.legacyAmpersand().deserialize(value).toBuilder() + .hoverEvent(HoverEvent.showText(text(value, WHITE))) + .build(); + } + + static Component formatContextBracketed(String key, String value) { + // &8(&7{}=&f{}&8) + return text() + .color(DARK_GRAY) + .append(OPEN_BRACKET) + .append(text(key, GRAY)) + .append(text('=', GRAY)) + .append(text(value, WHITE)) + .append(CLOSE_BRACKET) + .build(); + } + + static Component formatContextBracketed(Context context) { + return formatContextBracketed(context.getKey(), context.getValue()); + } + + static Component formatContext(String key, String value) { + // "&3{}=&b{}" + return text() + .content(key) + .color(DARK_AQUA) + .append(text('=')) + .append(text(value, AQUA)) + .build(); + } + + static Component formatContext(Context context) { + return formatContext(context.getKey(), context.getValue()); + } + + static Component formatContextSet(ContextSet set) { + // "&3server=&bsurvival&a, &3world=&bnether" + Iterator it = set.iterator(); + if (!it.hasNext()) { + return text("global", YELLOW); // "&eglobal" + } + + TextComponent.Builder builder = text().color(GREEN); + + builder.append(formatContext(it.next())); + while (it.hasNext()) { + builder.append(text(", ")); + builder.append(formatContext(it.next())); + } + + return builder.build(); + } + + static Component formatContextSetBracketed(ContextSet set, Component ifEmpty) { + // "&8(&7server=&fsurvival&8) &8(&7world=&fnether&8)" + Iterator it = set.iterator(); + if (!it.hasNext()) { + return ifEmpty; + } + + TextComponent.Builder builder = text(); + + builder.append(formatContextBracketed(it.next())); + while (it.hasNext()) { + builder.append(text(" ")); + builder.append(formatContextBracketed(it.next())); + } + + return builder.build(); + } + + static Component formatTrackPath(Collection groups) { + Iterator it = groups.iterator(); + if (!it.hasNext()) { + return translatable("luckperms.command.track.path.empty", GOLD); // "&6None" + } + + TextComponent.Builder builder = text().color(DARK_AQUA).content(it.next()); + + while (it.hasNext()) { + builder.append(text(" ---> ", AQUA)); + builder.append(text(it.next())); + } + + return builder.build(); + } + + static Component formatTrackPath(Collection groups, String highlighed) { + if (groups.isEmpty()) { + return translatable("luckperms.command.track.path.empty", AQUA); // "&bNone" + } + + TextComponent.Builder builder = text().color(DARK_AQUA); + + boolean first = true; + for (String group : groups) { + if (first) { + first = false; + } else { + builder.append(text(" ---> ", GRAY)); + } + + builder.append(group.equalsIgnoreCase(highlighed) ? text(group, AQUA) : text(group)); + } + + return builder.build(); + } + + static Component formatTrackPath(Collection groups, String highlightedFirst, String highlightedSecond, boolean reversed) { + if (groups.isEmpty()) { + return translatable("luckperms.command.track.path.empty", GOLD); // "&6None" + } + + TextComponent.Builder builder = text().color(DARK_AQUA); + + boolean first = true; + boolean highlight = false; + + for (String group : groups) { + if (first) { + first = false; + } else { + builder.append(text(reversed ? " <--- " : " ---> ", highlight ? DARK_RED : GRAY)); + } + + if (group.equalsIgnoreCase(highlightedFirst)) { + builder.append(text(group, AQUA)); + highlight = true; + } else if (group.equalsIgnoreCase(highlightedSecond)) { + builder.append(text(group, AQUA)); + highlight = false; + } else { + builder.append(text(group)); + } + } + + return builder.build(); + } + + static Component formatStringList(Collection strings) { + Iterator it = strings.iterator(); + if (!it.hasNext()) { + return translatable("luckperms.command.misc.none", AQUA); // "&bNone" + } + + TextComponent.Builder builder = text().color(DARK_AQUA).content(it.next()); + + while (it.hasNext()) { + builder.append(text(", ", GRAY)); + builder.append(text(it.next())); + } + + return builder.build(); + } + + static Component formatBoolean(boolean bool) { + return bool ? text("true", GREEN) : text("false", RED); + } + + static Component formatTristate(Tristate tristate) { + switch (tristate) { + case TRUE: + return text("true", GREEN); + case FALSE: + return text("false", RED); + default: + return text("undefined", GRAY); + } + } + + interface Args0 { + Component build(); + + default void send(Sender sender) { + sender.sendMessage(build()); + } + } + + interface Args1 { + Component build(A0 arg0); + + default void send(Sender sender, A0 arg0) { + sender.sendMessage(build(arg0)); + } + } + + interface Args2 { + Component build(A0 arg0, A1 arg1); + + default void send(Sender sender, A0 arg0, A1 arg1) { + sender.sendMessage(build(arg0, arg1)); + } + } + + interface Args3 { + Component build(A0 arg0, A1 arg1, A2 arg2); + + default void send(Sender sender, A0 arg0, A1 arg1, A2 arg2) { + sender.sendMessage(build(arg0, arg1, arg2)); + } + } + + interface Args4 { + Component build(A0 arg0, A1 arg1, A2 arg2, A3 arg3); + + default void send(Sender sender, A0 arg0, A1 arg1, A2 arg2, A3 arg3) { + sender.sendMessage(build(arg0, arg1, arg2, arg3)); + } + } + + interface Args5 { + Component build(A0 arg0, A1 arg1, A2 arg2, A3 arg3, A4 arg4); + + default void send(Sender sender, A0 arg0, A1 arg1, A2 arg2, A3 arg3, A4 arg4) { + sender.sendMessage(build(arg0, arg1, arg2, arg3, arg4)); + } + } + + interface Args6 { + Component build(A0 arg0, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5); + + default void send(Sender sender, A0 arg0, A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) { + sender.sendMessage(build(arg0, arg1, arg2, arg3, arg4, arg5)); + } + } + +} diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/TranslationManager.java b/common/src/main/java/me/lucko/luckperms/common/locale/TranslationManager.java new file mode 100644 index 000000000..549587f3e --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/locale/TranslationManager.java @@ -0,0 +1,121 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.luckperms.common.locale; + +import me.lucko.luckperms.common.plugin.LuckPermsPlugin; + +import net.kyori.adventure.key.Key; +import net.kyori.adventure.translation.GlobalTranslator; +import net.kyori.adventure.translation.TranslationRegistry; +import net.kyori.adventure.translation.Translator; +import net.kyori.adventure.util.UTF8ResourceBundleControl; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class TranslationManager { + /** The default locale used by LuckPerms messages */ + public static final Locale DEFAULT_LOCALE = Locale.ENGLISH; + + private final LuckPermsPlugin plugin; + private final TranslationRegistry registry; + + public TranslationManager(LuckPermsPlugin plugin) { + this.plugin = plugin; + + // create a translation registry for luckperms + this.registry = TranslationRegistry.create(Key.key("luckperms", "main")); + this.registry.defaultLocale(DEFAULT_LOCALE); + + // register it to the global source, so our translations can be picked up by adventure-platform + GlobalTranslator.get().addSource(this.registry); + } + + public void load() { + // load custom translations first, then the base (built-in) translations after. + loadCustom(); + loadBase(); + } + + /** + * Loads the base (English) translations from the jar file. + */ + private void loadBase() { + ResourceBundle bundle = ResourceBundle.getBundle("luckperms", DEFAULT_LOCALE, UTF8ResourceBundleControl.get()); + this.registry.registerAll(DEFAULT_LOCALE, bundle, false); + } + + /** + * Loads custom translations (in any language) from the plugin configuration folder. + */ + public void loadCustom() { + List translationFiles; + try (Stream stream = Files.list(this.plugin.getBootstrap().getConfigDirectory().resolve("translations"))) { + translationFiles = stream.filter(path -> path.getFileName().toString().endsWith(".properties")).collect(Collectors.toList()); + } catch (IOException e) { + translationFiles = Collections.emptyList(); + } + + for (Path translationFile : translationFiles) { + try { + loadCustomTranslationFile(translationFile); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + private void loadCustomTranslationFile(Path translationFile) { + String fileName = translationFile.getFileName().toString(); + String localeString = fileName.substring(0, fileName.length() - ".properties".length()); + Locale locale = parseLocale(localeString, null); + + if (locale == null) { + this.plugin.getLogger().warn("Unknown locale '" + localeString + "' - unable to register."); + return; + } + + this.registry.registerAll(locale, translationFile, true); + this.plugin.getLogger().info("Registered additional translations for " + locale.toLanguageTag()); + } + + public static Locale parseLocale(String locale, Locale defaultLocale) { + if (locale == null) { + return defaultLocale; + } + + Locale parsed = Translator.parseLocale(locale); + return parsed != null ? parsed : defaultLocale; + } + +} diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpec.java b/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpec.java deleted file mode 100644 index 27138e7ae..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpec.java +++ /dev/null @@ -1,668 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.locale.command; - -import me.lucko.luckperms.common.locale.LocaleManager; - -import java.util.List; - -/** - * An enumeration of the command defintion/usage messages used in the plugin. - * - *

The values in this enum are only defaults, and are only returned if no value for the key is present in the - * {@link LocaleManager}.

- */ -@SuppressWarnings("SpellCheckingInspection") -public enum CommandSpec { - - USER("A set of commands for managing users within LuckPerms. " + - "(A 'user' in LuckPerms is just a player, and can refer to a UUID or username)", - "/%s user " - ), - GROUP("A set of commands for managing groups within LuckPerms. " + - "Groups are just collections of permission assignments that can be given to users. " + - "New groups are made using the 'creategroup' command.", - "/%s group " - ), - TRACK("A set of commands for managing tracks within LuckPerms. " + - "Tracks are a ordered collection of groups which can be used for defining " + - "promotions and demotions.", - "/%s track " - ), - LOG("A set of commands for managing the logging functionality within LuckPerms.", "/%s log"), - - SYNC("Reloads all data from the plugins storage into memory, and applies any changes that are detected.", "/%s sync"), - INFO("Prints general information about the active plugin instance.", "/%s info"), - EDITOR("Creates a new web editor session", "/%s editor [type]", - Argument.list( - Argument.create("type", false, "the types to load into the editor. ('all', 'users' or 'groups')"), - Argument.create("filter", false, "permission to filter user entries by") - ) - ), - DEBUG("Produces a set of internal debugging output", "/%s debug"), - VERBOSE("Controls the plugins verbose permission check monitoring system.", "/%s verbose [filter]", - Argument.list( - Argument.create("on|record|off|upload|command", true, "whether to enable/disable logging, or to upload the logged output"), - Argument.create("filter", false, "the filter to match entries against"), - Argument.create(" ", false, "the player/command to run") - ) - ), - TREE("Generates a tree view (ordered list hierarchy) of all permissions known to LuckPerms.", "/%s tree [scope] [player]", - Argument.list( - Argument.create("scope", false, "the root of the tree. specify \".\" to include all permissions"), - Argument.create("player", false, "the name of an online player to check against") - ) - ), - SEARCH("Searchs for all of the users/groups with a specific permission", "/%s search ", - Argument.list( - Argument.create("permission", true, "the permission to search for"), - Argument.create("page", false, "the page to view") - ) - ), - CHECK("Performs a 'mock' permission check for an online player", "/%s check ", - Argument.list( - Argument.create("user", true, "the user to check"), - Argument.create("permission", true, "the permission to check for") - ) - ), - NETWORK_SYNC("Sync changes with the storage and request that all other servers on the network do the same", "/%s networksync"), - IMPORT("Imports data from a (previously created) export file", "/%s import ", - Argument.list( - Argument.create("file", true, "the file to import from"), - Argument.create("--replace", false, "replace existing data instead of merging") - ) - ), - EXPORT("Exports all permissions data to an 'export' file. Can be re-imported at a later time.", "/%s export ", - Argument.list( - Argument.create("file", true, "the file to export to"), - Argument.create("--without-users", false, "exclude users from the export") - ) - ), - RELOAD_CONFIG("Reload some of the config options", "/%s reloadconfig"), - BULK_UPDATE("Execute bulk change queries on all data", "/%s bulkupdate", - Argument.list( - Argument.create("data type", true, "the type of data being changed. ('all', 'users' or 'groups')"), - Argument.create("action", true, "the action to perform on the data. ('update' or 'delete')"), - Argument.create("action field", false, "the field to act upon. only required for 'update'. ('permission', 'server' or 'world')"), - Argument.create("action value", false, "the value to replace with. only required for 'update'."), - Argument.create("constraint...", false, "the constraints required for the update") - ) - ), - MIGRATION("Migration commands", "/%s migration"), - APPLY_EDITS("Applies permission changes made from the web editor", "/%s applyedits [target]", - Argument.list( - Argument.create("code", true, "the unique code for the data"), - Argument.create("target", false, "who to apply the data to") - ) - ), - - CREATE_GROUP("Create a new group", "/%s creategroup ", - Argument.list( - Argument.create("name", true, "the name of the group") - ) - ), - DELETE_GROUP("Delete a group", "/%s deletegroup ", - Argument.list( - Argument.create("name", true, "the name of the group") - ) - ), - LIST_GROUPS("List all groups on the platform", "/%s listgroups"), - - CREATE_TRACK("Create a new track", "/%s createtrack ", - Argument.list( - Argument.create("name", true, "the name of the track") - ) - ), - DELETE_TRACK("Delete a track", "/%s deletetrack ", - Argument.list( - Argument.create("name", true, "the name of the track") - ) - ), - LIST_TRACKS("List all tracks on the platform", "/%s listtracks"), - - USER_INFO("Shows info about the user"), - USER_SWITCHPRIMARYGROUP("Switches the user's primary group", - Argument.list( - Argument.create("group", true, "the group to switch to") - ) - ), - USER_PROMOTE("Promotes the user up a track", - Argument.list( - Argument.create("track", false, "the track to promote the user up"), - Argument.create("context...", false, "the contexts to promote the user in"), - Argument.create("--dont-add-to-first", false, "only promote the user if they're already on the track") - ) - ), - USER_DEMOTE("Demotes the user down a track", - Argument.list( - Argument.create("track", false, "the track to demote the user down"), - Argument.create("context...", false, "the contexts to demote the user in"), - Argument.create("--dont-remove-from-first", false, "prevent the user from being removed from the first group") - ) - ), - USER_CLONE("Clone the user", - Argument.list( - Argument.create("user", true, "the name/uuid of the user to clone onto") - ) - ), - - GROUP_INFO("Gives info about the group"), - GROUP_LISTMEMBERS("Show the users/groups who inherit from this group", - Argument.list( - Argument.create("page", false, "the page to view") - ) - ), - GROUP_SETWEIGHT("Set the groups weight", - Argument.list( - Argument.create("weight", true, "the weight to set") - ) - ), - GROUP_SET_DISPLAY_NAME("Set the groups display name", - Argument.list( - Argument.create("name", true, "the name to set"), - Argument.create("context...", false, "the contexts to set the name in") - ) - ), - GROUP_RENAME("Rename the group", - Argument.list( - Argument.create("name", true, "the new name") - ) - ), - GROUP_CLONE("Clone the group", - Argument.list( - Argument.create("name", true, "the name of the group to clone onto") - ) - ), - - HOLDER_EDITOR("Opens the web permission editor"), - HOLDER_SHOWTRACKS("Lists the tracks that the object is on"), - HOLDER_CLEAR("Removes all permissions, parents and meta", - Argument.list( - Argument.create("context...", false, "the contexts to filter by") - ) - ), - - PERMISSION("Edit permissions"), - PARENT("Edit inheritances"), - META("Edit metadata values"), - - PERMISSION_INFO("Lists the permission nodes the object has", - Argument.list( - Argument.create("page", false, "the page to view"), - Argument.create("sort mode", false, "how to sort the entries") - ) - ), - PERMISSION_SET("Sets a permission for the object", - Argument.list( - Argument.create("node", true, "the permission node to set"), - Argument.create("true|false", false, "the value of the node"), - Argument.create("context...", false, "the contexts to add the permission in") - ) - ), - PERMISSION_UNSET("Unsets a permission for the object", - Argument.list( - Argument.create("node", true, "the permission node to unset"), - Argument.create("context...", false, "the contexts to remove the permission in") - ) - ), - PERMISSION_SETTEMP("Sets a permission for the object temporarily", - Argument.list( - Argument.create("node", true, "the permission node to set"), - Argument.create("true|false", false, "the value of the node"), - Argument.create("duration", true, "the duration until the permission node expires"), - Argument.create("temporary modifier", false, "how the temporary permission should be applied"), - Argument.create("context...", false, "the contexts to add the permission in") - ) - ), - PERMISSION_UNSETTEMP("Unsets a temporary permission for the object", - Argument.list( - Argument.create("node", true, "the permission node to unset"), - Argument.create("duration", false, "the duration to subtract"), - Argument.create("context...", false, "the contexts to remove the permission in") - ) - ), - PERMISSION_CHECK("Checks to see if the object has a certain permission node", - Argument.list( - Argument.create("node", true, "the permission node to check for"), - Argument.create("context...", false, "the contexts to check in") - ) - ), - PERMISSION_CHECK_INHERITS("Checks to see if the object inherits a certain permission node", - Argument.list( - Argument.create("node", true, "the permission node to check for"), - Argument.create("context...", false, "the contexts to check in") - ) - ), - PERMISSION_CLEAR("Clears all permissions", - Argument.list( - Argument.create("context...", false, "the contexts to filter by") - ) - ), - - PARENT_INFO("Lists the groups that this object inherits from", - Argument.list( - Argument.create("page", false, "the page to view"), - Argument.create("sort mode", false, "how to sort the entries") - ) - ), - PARENT_SET("Removes all other groups the object inherits already and adds them to the one given", - Argument.list( - Argument.create("group", true, "the group to set to"), - Argument.create("context...", false, "the contexts to set the group in") - ) - ), - PARENT_ADD("Sets another group for the object to inherit permissions from", - Argument.list( - Argument.create("group", true, "the group to inherit from"), - Argument.create("context...", false, "the contexts to inherit the group in") - ) - ), - PARENT_REMOVE("Removes a previously set inheritance rule", - Argument.list( - Argument.create("group", true, "the group to remove"), - Argument.create("context...", false, "the contexts to remove the group in") - ) - ), - PARENT_SET_TRACK("Removes all other groups the object inherits from already on the given track and adds them to the one given", - Argument.list( - Argument.create("track", true, "the track to set on"), - Argument.create("group", true, "the group to set to, or a number relating to the position of the group on the given track"), - Argument.create("context...", false, "the contexts to set the group in") - ) - ), - PARENT_ADD_TEMP("Sets another group for the object to inherit permissions from temporarily", - Argument.list( - Argument.create("group", true, "the group to inherit from"), - Argument.create("duration", true, "the duration of the group membership"), - Argument.create("temporary modifier", false, "how the temporary permission should be applied"), - Argument.create("context...", false, "the contexts to inherit the group in") - ) - ), - PARENT_REMOVE_TEMP("Removes a previously set temporary inheritance rule", - Argument.list( - Argument.create("group", true, "the group to remove"), - Argument.create("duration", false, "the duration to subtract"), - Argument.create("context...", false, "the contexts to remove the group in") - ) - ), - PARENT_CLEAR("Clears all parents", - Argument.list( - Argument.create("context...", false, "the contexts to filter by") - ) - ), - PARENT_CLEAR_TRACK("Clears all parents on a given track", - Argument.list( - Argument.create("track", true, "the track to remove on"), - Argument.create("context...", false, "the contexts to filter by") - ) - ), - - META_INFO("Shows all chat meta"), - META_SET("Sets a meta value", - Argument.list( - Argument.create("key", true, "the key to set"), - Argument.create("value", true, "the value to set"), - Argument.create("context...", false, "the contexts to add the meta pair in") - ) - ), - META_UNSET("Unsets a meta value", - Argument.list( - Argument.create("key", true, "the key to unset"), - Argument.create("context...", false, "the contexts to remove the meta pair in") - ) - ), - META_SETTEMP("Sets a meta value temporarily", - Argument.list( - Argument.create("key", true, "the key to set"), - Argument.create("value", true, "the value to set"), - Argument.create("duration", true, "the duration until the meta value expires"), - Argument.create("context...", false, "the contexts to add the meta pair in") - ) - ), - META_UNSETTEMP("Unsets a temporary meta value", - Argument.list( - Argument.create("key", true, "the key to unset"), - Argument.create("context...", false, "the contexts to remove the meta pair in") - ) - ), - META_ADDPREFIX("Adds a prefix", - Argument.list( - Argument.create("priority", true, "the priority to add the prefix at"), - Argument.create("prefix", true, "the prefix string"), - Argument.create("context...", false, "the contexts to add the prefix in") - ) - ), - META_ADDSUFFIX("Adds a suffix", - Argument.list( - Argument.create("priority", true, "the priority to add the suffix at"), - Argument.create("suffix", true, "the suffix string"), - Argument.create("context...", false, "the contexts to add the suffix in") - ) - ), - META_SETPREFIX("Sets a prefix", - Argument.list( - Argument.create("priority", false, "the priority to set the prefix at"), - Argument.create("prefix", true, "the prefix string"), - Argument.create("context...", false, "the contexts to set the prefix in") - ) - ), - META_SETSUFFIX("Sets a suffix", - Argument.list( - Argument.create("priority", false, "the priority to set the suffix at"), - Argument.create("suffix", true, "the suffix string"), - Argument.create("context...", false, "the contexts to set the suffix in") - ) - ), - META_REMOVEPREFIX("Removes a prefix", - Argument.list( - Argument.create("priority", true, "the priority to remove the prefix at"), - Argument.create("prefix", false, "the prefix string"), - Argument.create("context...", false, "the contexts to remove the prefix in") - ) - ), - META_REMOVESUFFIX("Removes a suffix", - Argument.list( - Argument.create("priority", true, "the priority to remove the suffix at"), - Argument.create("suffix", false, "the suffix string"), - Argument.create("context...", false, "the contexts to remove the suffix in") - ) - ), - META_ADDTEMP_PREFIX("Adds a prefix temporarily", - Argument.list( - Argument.create("priority", true, "the priority to add the prefix at"), - Argument.create("prefix", true, "the prefix string"), - Argument.create("duration", true, "the duration until the prefix expires"), - Argument.create("context...", false, "the contexts to add the prefix in") - ) - ), - META_ADDTEMP_SUFFIX("Adds a suffix temporarily", - Argument.list( - Argument.create("priority", true, "the priority to add the suffix at"), - Argument.create("suffix", true, "the suffix string"), - Argument.create("duration", true, "the duration until the suffix expires"), - Argument.create("context...", false, "the contexts to add the suffix in") - ) - ), - META_SETTEMP_PREFIX("Sets a prefix temporarily", - Argument.list( - Argument.create("priority", true, "the priority to set the prefix at"), - Argument.create("prefix", true, "the prefix string"), - Argument.create("duration", true, "the duration until the prefix expires"), - Argument.create("context...", false, "the contexts to set the prefix in") - ) - ), - META_SETTEMP_SUFFIX("Sets a suffix temporarily", - Argument.list( - Argument.create("priority", true, "the priority to set the suffix at"), - Argument.create("suffix", true, "the suffix string"), - Argument.create("duration", true, "the duration until the suffix expires"), - Argument.create("context...", false, "the contexts to set the suffix in") - ) - ), - META_REMOVETEMP_PREFIX("Removes a temporary prefix", - Argument.list( - Argument.create("priority", true, "the priority to remove the prefix at"), - Argument.create("prefix", false, "the prefix string"), - Argument.create("context...", false, "the contexts to remove the prefix in") - ) - ), - META_REMOVETEMP_SUFFIX("Removes a temporary suffix", - Argument.list( - Argument.create("priority", true, "the priority to remove the suffix at"), - Argument.create("suffix", false, "the suffix string"), - Argument.create("context...", false, "the contexts to remove the suffix in") - ) - ), - META_CLEAR("Clears all meta", - Argument.list( - Argument.create("type", false, "the type of meta to remove"), - Argument.create("context...", false, "the contexts to filter by") - ) - ), - - TRACK_INFO("Gives info about the track"), - TRACK_APPEND("Appends a group onto the end of the track", - Argument.list( - Argument.create("group", true, "the group to append") - ) - ), - TRACK_INSERT("Inserts a group at a given position along the track", - Argument.list( - Argument.create("group", true, "the group to insert"), - Argument.create("position", true, "the position to insert the group at (the first position on the track is 1)") - ) - ), - TRACK_REMOVE("Removes a group from the track", - Argument.list( - Argument.create("group", true, "the group to remove") - ) - ), - TRACK_CLEAR("Clears the groups on the track"), - TRACK_RENAME("Rename the track", - Argument.list( - Argument.create("name", true, "the new name") - ) - ), - TRACK_CLONE("Clone the track", - Argument.list( - Argument.create("name", true, "the name of the track to clone onto") - ) - ), - - LOG_RECENT("View recent actions", - Argument.list( - Argument.create("user", false, "the name/uuid of the user to filter by"), - Argument.create("page", false, "the page number to view") - ) - ), - LOG_SEARCH("Search the log for an entry", - Argument.list( - Argument.create("query", true, "the query to search by"), - Argument.create("page", false, "the page number to view") - ) - ), - LOG_NOTIFY("Toggle log notifications", - Argument.list( - Argument.create("on|off", false, "whether to toggle on or off") - ) - ), - LOG_USER_HISTORY("View a user's history", - Argument.list( - Argument.create("user", true, "the name/uuid of the user"), - Argument.create("page", false, "the page number to view") - ) - ), - LOG_GROUP_HISTORY("View an group's history", - Argument.list( - Argument.create("group", true, "the name of the group"), - Argument.create("page", false, "the page number to view") - ) - ), - LOG_TRACK_HISTORY("View a track's history", - Argument.list( - Argument.create("track", true, "the name of the track"), - Argument.create("page", false, "the page number to view") - ) - ), - - SPONGE("Edit extra Sponge data", "/%s sponge ", - Argument.list( - Argument.create("collection", true, "the collection to query"), - Argument.create("subject", true, "the subject to modify") - ) - ), - SPONGE_PERMISSION_INFO("Shows info about the subject's permissions", - Argument.list( - Argument.create("contexts...", false, "the contexts to filter by") - ) - ), - SPONGE_PERMISSION_SET("Sets a permission for the Subject", - Argument.list( - Argument.create("node", true, "the permission node to set"), - Argument.create("tristate", true, "the value to set the permission to"), - Argument.create("contexts...", false, "the contexts to set the permission in") - ) - ), - SPONGE_PERMISSION_CLEAR("Clears the Subjects permissions", - Argument.list( - Argument.create("contexts...", false, "the contexts to clear permissions in") - ) - ), - SPONGE_PARENT_INFO("Shows info about the subject's parents", - Argument.list( - Argument.create("contexts...", false, "the contexts to filter by") - ) - ), - SPONGE_PARENT_ADD("Adds a parent to the Subject", - Argument.list( - Argument.create("collection", true, "the subject collection where the parent Subject is"), - Argument.create("subject", true, "the name of the parent Subject"), - Argument.create("contexts...", false, "the contexts to add the parent in") - ) - ), - SPONGE_PARENT_REMOVE("Removes a parent from the Subject", - Argument.list( - Argument.create("collection", true, "the subject collection where the parent Subject is"), - Argument.create("subject", true, "the name of the parent Subject"), - Argument.create("contexts...", false, "the contexts to remove the parent in") - ) - ), - SPONGE_PARENT_CLEAR("Clears the Subjects parents", - Argument.list( - Argument.create("contexts...", false, "the contexts to clear parents in") - ) - ), - SPONGE_OPTION_INFO("Shows info about the subject's options", - Argument.list( - Argument.create("contexts...", false, "the contexts to filter by") - ) - ), - SPONGE_OPTION_SET("Sets an option for the Subject", - Argument.list( - Argument.create("key", true, "the key to set"), - Argument.create("value", true, "the value to set the key to"), - Argument.create("contexts...", false, "the contexts to set the option in") - ) - ), - SPONGE_OPTION_UNSET("Unsets an option for the Subject", - Argument.list( - Argument.create("key", true, "the key to unset"), - Argument.create("contexts...", false, "the contexts to unset the key in") - ) - ), - SPONGE_OPTION_CLEAR("Clears the Subjects options", - Argument.list( - Argument.create("contexts...", false, "the contexts to clear options in") - ) - ), - - MIGRATION_COMMAND("Migration command"), - MIGRATION_GROUPMANAGER("Migration command", - Argument.list( - Argument.create("migrate as global", true, "if world permissions should be ignored, and just migrated as global") - ) - ), - MIGRATION_POWERFULPERMS("Migration command", - Argument.list( - Argument.create("address", true, "the address of the PP database"), - Argument.create("database", true, "the name of the PP database"), - Argument.create("username", true, "the username to log into the DB"), - Argument.create("password", true, "the password to log into the DB"), - Argument.create("db table", true, "the name of the PP table where player data is stored") - ) - ); - - private final String description; - private final String usage; - private final List args; - - CommandSpec(String description, String usage, List args) { - this.description = description; - this.usage = usage; - this.args = args; - } - - CommandSpec(String description, String usage) { - this(description, usage, null); - } - - CommandSpec(String description) { - this(description, null, null); - } - - CommandSpec(String description, List args) { - this(description, null, args); - } - - public String getDescription() { - return this.description; - } - - public String getUsage() { - return this.usage; - } - - public List getArgs() { - return this.args; - } - - /** - * Creates a {@link LocalizedCommandSpec} for the spec using the platforms locale manager. - * - * @param localeManager the locale manager to use for the spec - * @return a localized spec instance - */ - public LocalizedCommandSpec localize(LocaleManager localeManager) { - return new LocalizedCommandSpec(this, localeManager); - } - - /* - public static void main(String[] args) { - System.out.println("command-specs:"); - - for (CommandSpec spec : values()) { - String key = spec.name().replace('_', '-').toLowerCase(); - - System.out.println(" " + key + ":"); - - if (spec.description != null) { - System.out.println(" description: \"" + spec.description.replace("\"", "\\\"") + "\""); - } - if (spec.usage != null) { - System.out.println(" usage: \"" + spec.usage.replace("\"", "\\\"") + "\""); - } - - if (spec.args != null && !spec.args.isEmpty()) { - System.out.println(" args:"); - for (Argument arg : spec.args) { - System.out.println(" \"" + arg.getName() + "\": \"" + arg.getDescription().replace("\"", "\\\"") + "\""); - } - } - } - } - */ - -} diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpecData.java b/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpecData.java deleted file mode 100644 index c44ab27c7..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpecData.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.locale.command; - -import org.checkerframework.checker.nullness.qual.Nullable; - -import java.util.Map; -import java.util.Objects; - -/** - * The localized data for a {@link CommandSpec}. - */ -public final class CommandSpecData { - private final String description; - private final String usage; - private final Map args; - - public CommandSpecData(@Nullable String description, @Nullable String usage, @Nullable Map args) { - this.description = description; - this.usage = usage; - this.args = args; - } - - public @Nullable String getDescription() { - return this.description; - } - - public @Nullable String getUsage() { - return this.usage; - } - - public @Nullable Map getArgs() { - return this.args; - } - - @Override - public boolean equals(Object o) { - if (o == this) return true; - if (!(o instanceof CommandSpecData)) return false; - final CommandSpecData that = (CommandSpecData) o; - - return Objects.equals(this.getDescription(), that.getDescription()) && - Objects.equals(this.getUsage(), that.getUsage()) && - Objects.equals(this.getArgs(), that.getArgs()); - } - - @Override - public int hashCode() { - return Objects.hash(getDescription(), getUsage(), getArgs()); - } - - @Override - public String toString() { - return "CommandSpecData(" + - "description=" + this.getDescription() + ", " + - "usage=" + this.getUsage() + ", " + - "args=" + this.getArgs() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/command/LocalizedCommandSpec.java b/common/src/main/java/me/lucko/luckperms/common/locale/command/LocalizedCommandSpec.java deleted file mode 100644 index 097473f2b..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/locale/command/LocalizedCommandSpec.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.locale.command; - -import com.google.common.collect.ImmutableList; - -import me.lucko.luckperms.common.locale.LocaleManager; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; - -/** - * Represents a localized instance of a {@link CommandSpec}. - */ -public class LocalizedCommandSpec { - private final LocaleManager localeManager; - private final CommandSpec spec; - - public LocalizedCommandSpec(CommandSpec spec, LocaleManager localeManager) { - this.localeManager = localeManager; - this.spec = spec; - } - - public String description() { - CommandSpecData translation = this.localeManager.getTranslation(this.spec); - if (translation != null && translation.getDescription() != null) { - return translation.getDescription(); - } - - // fallback - return this.spec.getDescription(); - } - - public String usage() { - CommandSpecData translation = this.localeManager.getTranslation(this.spec); - if (translation != null && translation.getUsage() != null) { - return translation.getUsage(); - } - - // fallback - return this.spec.getUsage(); - } - - public List args() { - CommandSpecData translation = this.localeManager.getTranslation(this.spec); - if (translation == null || translation.getArgs() == null) { - // fallback - return this.spec.getArgs(); - } - - List args = new ArrayList<>(this.spec.getArgs()); - ListIterator it = args.listIterator(); - while (it.hasNext()) { - Argument next = it.next(); - String s = translation.getArgs().get(next.getName()); - - // if a translation for the given arg key is present, apply the new description. - if (s != null) { - it.set(Argument.create(next.getName(), next.isRequired(), s)); - } - } - - return ImmutableList.copyOf(args); - } - - public LocaleManager getLocaleManager() { - return this.localeManager; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java deleted file mode 100644 index eb5f5a1e0..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java +++ /dev/null @@ -1,611 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.locale.message; - -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.TextUtils; - -import net.kyori.text.TextComponent; - -import org.checkerframework.checker.nullness.qual.Nullable; - -/** - * An enumeration of some of the messages used within the plugin. - * - *

The values in this enum are only defaults, and are only returned if no value for the key is present in the - * {@link LocaleManager}.

- */ -@SuppressWarnings("SpellCheckingInspection") -public enum Message { - - /* - * General & Commands - */ - PREFIX("&7[&b&lL&3&lP&7] ", false), - - VIEW_AVAILABLE_COMMANDS_PROMPT("&3Use &a/{} help &3to view available commands.", true), - NO_PERMISSION_FOR_SUBCOMMANDS("&3You do not have permission to use any sub commands.", true), - FIRST_TIME_SETUP( - "{PREFIX}&3It seems that no permissions have been setup yet!" + "\n" + - "{PREFIX}&3Before you can use any of the LuckPerms commands in-game, you need to use the console to give yourself access." + "\n" + - "{PREFIX}&3Open your console and run:" + "\n" + - "{PREFIX} &3&l> &a{} user {} permission set luckperms.* true" + "\n\n" + - "{PREFIX}&3After you've done this, you can begin to define your permission assignments and groups." + "\n" + - "{PREFIX}&3Don't know where to start? Check here: &7https://github.com/lucko/LuckPerms/wiki/Usage", - false - ), - - BLANK("{}", true), - PLAYER_ONLINE("&aOnline", false), - PLAYER_OFFLINE("&cOffline", false), - LOADING_DATABASE_ERROR("&cA database error occurred whilst loading permissions data. Please try again later. If you are a server admin, please check the console for any errors.", true), - LOADING_STATE_ERROR("&cPermissions data for your user was not loaded during the pre-login stage - unable to continue. Please try again later. If you are a server admin, please check the console for any errors.", true), - LOADING_STATE_ERROR_CB_OFFLINE_MODE("&cPermissions data for your user was not loaded during the pre-login stage - this is likely due to a conflict between CraftBukkit and the online-mode setting. Please check the server console for more information.", true), - LOADING_SETUP_ERROR("&cAn unexpected error occurred whilst setting up your permissions data. Please try again later.", true), - OP_DISABLED("&bThe vanilla OP system is disabled on this server.", false), - OP_DISABLED_SPONGE("&2Please note that Server Operator status has no effect on Sponge permission checks when a permission plugin is installed. Please edit user data directly.", true), - - - /* - * Logging - */ - LOG( - "{PREFIX}&3LOG &3&l> &8(&e{}&8) [&a{}&8] (&b{}&8)" + "\n" + - "{PREFIX}&3LOG &3&l> &f{}", - false - ), - VERBOSE_LOG_PERMISSION("&3VB &3&l> &a{}&7 - &a{}&7 - {}{}", true), - VERBOSE_LOG_META("&3VB &3&l> &a{}&7 - &bmeta: &a{}&7 - &7{}", true), - EXPORT_LOG("&3EXPORT &3&l> &f{}", true), - EXPORT_LOG_PROGRESS("&3EXPORT &3&l> &7{}", true), - MIGRATION_LOG("&3MIGRATION &7[&3{}&7] &3&l> &f{}", true), - MIGRATION_LOG_PROGRESS("&3MIGRATION &7[&3{}&7] &3&l> &7{}", true), - - - /* - * Misc commands - */ - COMMAND_NOT_RECOGNISED("&cCommand not recognised.", true), - COMMAND_NO_PERMISSION("&cYou do not have permission to use this command!", true), - - MAIN_COMMAND_USAGE_HEADER("&b{} Sub Commands: &7({} ...)", true), - COMMAND_USAGE_ARGUMENT_JOIN("&3 - &7", false), - COMMAND_USAGE_BRIEF("&3> &a{}{}", false), - COMMAND_USAGE_DETAILED_HEADER( - "{PREFIX}&3&lCommand Usage &3- &b{}" + "\n" + - "{PREFIX}&b> &7{}", - false - ), - COMMAND_USAGE_DETAILED_ARGS_HEADER("&3Arguments:", true), - COMMAND_USAGE_DETAILED_ARG("&b- {}&3 -> &7{}", true), - REQUIRED_ARGUMENT("&8<&7{}&8>", false), - OPTIONAL_ARGUMENT("&8[&7{}&8]", false), - - - /* - * Loading / Saving - */ - USER_NOT_FOUND("&cA user for &4{}&c could not be found.", true), - USER_NOT_ONLINE("&aUser &b{}&a is not online.", true), - USER_SAVE_ERROR("&cThere was an error whilst saving user data for &4{}&c.", true), - - GROUP_NOT_FOUND("&cA group named &4{}&c could not be found.", true), - GROUP_SAVE_ERROR("&cThere was an error whilst saving group data for &4{}&c.", true), - - TRACK_NOT_FOUND("&cA track named &4{}&c could not be found.", true), - TRACK_SAVE_ERROR("&cThere was an error whilst saving track data for &4{}&c.", true), - - USER_INVALID_ENTRY("&4{}&c is not a valid username/uuid.", true), - GROUP_INVALID_ENTRY("&4{}&c is not a valid group name.", true), - TRACK_INVALID_ENTRY("&4{}&c is not a valid track name.", true), - SERVER_WORLD_INVALID_ENTRY("&cServer/world names can only contain alphanumeric characters and cannot exceed 36 characters in length.", true), - - - /* - * Commands - */ - VERBOSE_INVALID_FILTER("&4{}&c is not a valid verbose filter. &7({})", true), - VERBOSE_ON("&bVerbose logging &aenabled &bfor checks matching &aANY&b.", true), - VERBOSE_ON_QUERY("&bVerbose logging &aenabled &bfor checks matching &a{}&b.", true), - VERBOSE_ON_COMMAND("&bForcing &a{}&b to execute command &a/{}&b and reporting all checks made...", true), - VERBOSE_OFF("&bVerbose logging &cdisabled&b.", true), - VERBOSE_OFF_COMMAND("&bCommand execution complete.", true), - - VERBOSE_RECORDING_ON("&bVerbose recording &aenabled &bfor checks matching &aANY&b.", true), - VERBOSE_RECORDING_ON_QUERY("&bVerbose recording &aenabled &bfor checks matching &a{}&b.", true), - VERBOSE_UPLOAD_START("&bVerbose logging &cdisabled&b. Uploading results...", true), - VERBOSE_RESULTS_URL("&aVerbose results URL:", true), - - TREE_UPLOAD_START("&bGenerating permission tree...", true), - TREE_EMPTY("&cUnable to generate tree. No results were found.", true), - TREE_URL("&aPermission tree URL:", true), - - GENERIC_HTTP_REQUEST_FAILURE("&cUnable to communicate with the web app. (response code &4{}&c, message='{}')", true), - GENERIC_HTTP_UNKNOWN_FAILURE("&cUnable to communicate with the web app. Check the console for errors.", true), - - SEARCH_SEARCHING("&aSearching for users and groups with &bpermissions {}&a...", true), - SEARCH_SEARCHING_MEMBERS("&aSearching for users and groups who inherit from &b{}&a...", true), - SEARCH_RESULT_GROUP_DEFAULT("&7Note: when searching for members of the default group, offline players with no other permissions will not be shown!", true), - SEARCH_RESULT("&aFound &b{}&a entries from &b{}&a users and &b{}&a groups.", true), - - SEARCH_SHOWING_USERS("&bShowing user entries: &7(page &f{}&7 of &f{}&7 - &f{}&7 entries)", true), - SEARCH_SHOWING_GROUPS("&bShowing group entries: &7(page &f{}&7 of &f{}&7 - &f{}&7 entries)", true), - - APPLY_EDITS_INVALID_CODE("&cInvalid code. &7({})", true), - APPLY_EDITS_UNABLE_TO_READ("&cUnable to read data using the given code. &7({})", true), - APPLY_EDITS_UNKNOWN_TYPE("&cUnable to apply edit to the specified object type. &7({})", true), - APPLY_EDITS_TARGET_USER_NOT_UUID("&cTarget user &4{}&c is not a valid uuid.", true), - APPLY_EDITS_TARGET_USER_UNABLE_TO_LOAD("&cUnable to load target user &4{}&c.", true), - APPLY_EDITS_TARGET_UNKNOWN("&cInvalid target. &7({})", true), - APPLY_EDITS_TARGET_NO_CHANGES_PRESENT("&aNo changes were applied from the web editor. The returned data didn't contain any edits.", true), - APPLY_EDITS_SUCCESS("&aWeb editor data was applied to {} &b{}&a successfully.", true), - APPLY_EDITS_SUCCESS_SUMMARY("&7(&a{} &7{} and &c{} &7{})", true), - APPLY_EDITS_DIFF_ADDED("&a+ &f{}", false), - APPLY_EDITS_DIFF_REMOVED("&c- &f{}", false), - - EDITOR_NO_MATCH("&cUnable to open editor. No objects matched the desired type.", true), - EDITOR_START("&7Preparing a new editor session. Please wait...", true), - EDITOR_URL("&aClick the link below to open the editor:", true), - - EDITOR_HTTP_REQUEST_FAILURE("&cUnable to communicate with the editor. (response code &4{}&c, message='{}')", true), - EDITOR_HTTP_UNKNOWN_FAILURE("&cUnable to communicate with the editor. Check the console for errors.", true), - - CHECK_RESULT("&aPermission check result on user &b{}&a for permission &b{}&a: &f{}", true), - - CREATE_SUCCESS("&b{}&a was successfully created.", true), - DELETE_SUCCESS("&b{}&a was successfully deleted.", true), - RENAME_SUCCESS("&b{}&a was successfully renamed to &b{}&a.", true), - CLONE_SUCCESS("&b{}&a was successfully cloned onto &b{}&a.", true), - - ALREADY_INHERITS("&b{}&a already inherits from &b{}&a in context {}&a.", true), - DOES_NOT_INHERIT("&b{}&a does not inherit from &b{}&a in context {}&a.", true), - ALREADY_TEMP_INHERITS("&b{}&a already temporarily inherits from &b{}&a in context {}&a.", true), - DOES_NOT_TEMP_INHERIT("&b{}&a does not temporarily inherit from &b{}&a in context {}&a.", true), - - TRACK_ALREADY_CONTAINS("&b{}&a already contains &b{}&a.", true), - TRACK_DOES_NOT_CONTAIN("&b{}&a doesn't contain &b{}&a.", true), - TRACK_AMBIGUOUS_CALL("&4{}&c is a member of multiple groups on this track. Unable to determine their location.", true), - - ALREADY_EXISTS("&4{}&c already exists!", true), - DOES_NOT_EXIST("&4{}&c does not exist!", true), - - USER_LOAD_ERROR("&cAn unexpected error occurred. User not loaded.", true), - GROUP_LOAD_ERROR("&cAn unexpected error occurred. Group not loaded.", true), - GROUPS_LOAD_ERROR("&cAn unexpected error occurred. Unable to load all groups.", true), - - TRACK_LOAD_ERROR("&cAn unexpected error occurred. Track not loaded.", true), - TRACKS_LOAD_ERROR("&cAn unexpected error occurred. Unable to load all tracks.", true), - TRACK_EMPTY("&4{}&c cannot be used as it is empty or contains only one group.", true), - - UPDATE_TASK_REQUEST("&bAn update task has been requested. Please wait...", true), - UPDATE_TASK_COMPLETE("&aUpdate task complete.", true), - UPDATE_TASK_COMPLETE_NETWORK("&aUpdate task complete. Now attempting to push to other servers.", true), - UPDATE_TASK_PUSH_SUCCESS("&aOther servers were notified via &b{} Messaging &asuccessfully.", true), - UPDATE_TASK_PUSH_FAILURE("&cError whilst pushing changes to other servers.", true), - UPDATE_TASK_PUSH_FAILURE_NOT_SETUP("&cError whilst pushing changes to other servers. &7(a messaging service has not been configured)", true), - RELOAD_CONFIG_SUCCESS("&aThe configuration file was reloaded. &7(some options will only apply after the server has restarted)", true), - INFO_HEADER( - "{PREFIX}&2Running &b{} v{}&2 by &bLuck&2." + "\n" + - "{PREFIX}&f- &3Platform: &f{}" + "\n" + - "{PREFIX}&f- &3Server Brand: &f{}" + "\n" + - "{PREFIX}&f- &3Server Version:" + "\n" + - "{PREFIX} &f{}", - false - ), - - INFO_STORAGE( - "{PREFIX}&f- &bStorage:" + "\n" + - "{PREFIX} &3Type: &f{}", - false - ), - - INFO_STORAGE_META(" &3{}: {}", true), - - INFO_EXTENSIONS("&f- &bExtensions:", true), - INFO_EXTENSION_ENTRY(" &3{}", true), - - INFO_MIDDLE( - "{PREFIX}&f- &bMessaging: &f{}" + "\n" + - "{PREFIX}&f- &bInstance:" + "\n" + - "{PREFIX} &3Static contexts: &f{}" + "\n" + - "{PREFIX} &3Online Players: &a{} &7(&a{}&7 unique)" + "\n" + - "{PREFIX} &3Uptime: &7{}" + "\n" + - "{PREFIX} &3Local Data: &a{} &7users, &a{} &7groups, &a{} &7tracks", - false - ), - - DEBUG_START("&bGenerating debugging output...", true), - DEBUG_URL("&aDebug data URL:", true), - - CREATE_ERROR("&cThere was an error whilst creating &4{}&c.", true), - DELETE_ERROR("&cThere was an error whilst deleting &4{}&c.", true), - - DELETE_GROUP_ERROR_DEFAULT("&cYou cannot delete the default group.", true), - - GROUPS_LIST("&aGroups: &7(name, weight, tracks)", true), - GROUPS_LIST_ENTRY("&f- &3{} &7- &b{}", true), - GROUPS_LIST_ENTRY_WITH_TRACKS("&f- &3{} &7- &b{} &7- [&3{}&7]", true), - - TRACKS_LIST("&aTracks: {}", true), - - PERMISSION_INFO("&b{}'s Permissions: &7(page &f{}&7 of &f{}&7 - &f{}&7 entries)", true), - PERMISSION_INFO_NO_DATA("&b{}&a does not have any permissions set.", true), - - PARENT_INFO("&b{}'s Parents: &7(page &f{}&7 of &f{}&7 - &f{}&7 entries)", true), - PARENT_INFO_NO_DATA("&b{}&a does not have any parents defined.", true), - - LIST_TRACKS("&b{}'s Tracks:", true), - LIST_TRACKS_ENTRY("&a{}: {}", false), - LIST_TRACKS_EMPTY("&b{}&a is not on any tracks.", true), - - CONTEXT_PAIR_INLINE("&3{}=&b{}", false), - CONTEXT_PAIR_GLOBAL_INLINE("&eglobal", false), - CONTEXT_PAIR_SEP("&a, ", false), - - CONTEXT_PAIR("&8(&7{}=&f{}&8)", false), - - CHECK_PERMISSION("&b{}&a has permission &b{}&a set to {}&a in context {}&a.", true), - CHECK_INHERITS_PERMISSION("&b{}&a has permission &b{}&a set to {}&a in context {}&a. &7(inherited from &a{}&7)", true), - - SETPERMISSION_SUCCESS("&aSet &b{}&a to &b{}&a for &b{}&a in context {}&a.", true), - ALREADY_HASPERMISSION("&b{}&a already has &b{}&a set in context {}&a.", true), - - SETPERMISSION_TEMP_SUCCESS("&aSet &b{}&a to &b{}&a for &b{}&a for a duration of &b{}&a in context {}&a.", true), - ALREADY_HAS_TEMP_PERMISSION("&b{}&a already has &b{}&a set temporarily in context {}&a.", true), - - UNSETPERMISSION_SUCCESS("&aUnset &b{}&a for &b{}&a in context {}&a.", true), - DOES_NOT_HAVE_PERMISSION("&b{}&a does not have &b{}&a set in context {}&a.", true), - - UNSET_TEMP_PERMISSION_SUCCESS("&aUnset temporary permission &b{}&a for &b{}&a in context {}&a.", true), - UNSET_TEMP_PERMISSION_SUBTRACT_SUCCESS("&aSet &b{}&a to &b{}&a for &b{}&a for a duration of &b{}&a in context {}&a, &b{}&a less than before.", true), - DOES_NOT_HAVE_TEMP_PERMISSION("&b{}&a does not have &b{}&a set temporarily in context {}&a.", true), - - SET_INHERIT_SUCCESS("&b{}&a now inherits permissions from &b{}&a in context {}&a.", true), - SET_TEMP_INHERIT_SUCCESS("&b{}&a now inherits permissions from &b{}&a for a duration of &b{}&a in context {}&a.", true), - SET_PARENT_SUCCESS("&b{}&a had their existing parent groups cleared, and now only inherits &b{}&a in context {}&a.", true), - SET_TRACK_PARENT_SUCCESS("&b{}&a had their existing parent groups on track &b{}&a cleared, and now only inherits &b{}&a in context {}&a.", true), - UNSET_INHERIT_SUCCESS("&b{}&a no longer inherits permissions from &b{}&a in context {}&a.", true), - UNSET_TEMP_INHERIT_SUCCESS("&b{}&a no longer temporarily inherits permissions from &b{}&a in context {}&a.", true), - UNSET_TEMP_INHERIT_SUBTRACT_SUCCESS("&b{}&a will inherit permissions from &b{}&a for a duration of &b{}&a in context {}&a, &b{}&a less than before.", true), - - CLEAR_SUCCESS("&b{}&a's nodes were cleared in context {}&a. (&b{}&a nodes were removed.)", true), - CLEAR_SUCCESS_SINGULAR("&b{}&a's nodes were cleared in context {}&a. (&b{}&a node was removed.)", true), - PERMISSION_CLEAR_SUCCESS("&b{}&a's permissions were cleared in context {}&a. (&b{}&a nodes were removed.)", true), - PERMISSION_CLEAR_SUCCESS_SINGULAR("&b{}&a's permissions were cleared in context {}&a. (&b{}&a node was removed.)", true), - PARENT_CLEAR_SUCCESS("&b{}&a's parents were cleared in context {}&a. (&b{}&a nodes were removed.)", true), - PARENT_CLEAR_SUCCESS_SINGULAR("&b{}&a's parents were cleared in context {}&a. (&b{}&a node was removed.)", true), - - PARENT_CLEAR_TRACK_SUCCESS("&b{}&a's parents on track &b{}&a were cleared in context {}&a. (&b{}&a nodes were removed.)", true), - PARENT_CLEAR_TRACK_SUCCESS_SINGULAR("&b{}&a's parents on track &b{}&a were cleared in context {}&a. (&b{}&a node was removed.)", true), - - META_CLEAR_SUCCESS("&b{}&a's meta matching type &b{}&a was cleared in context {}&a. (&b{}&a nodes were removed.)", true), - META_CLEAR_SUCCESS_SINGULAR("&b{}&a's meta matching type &b{}&a was cleared in context {}&a. (&b{}&a node was removed.)", true), - - ILLEGAL_DATE_ERROR("&cCould not parse date &4{}&c.", true), - PAST_DATE_ERROR("&cYou cannot set a date in the past!", true), - - CHAT_META_PREFIX_HEADER("&b{}'s Prefixes", true), - CHAT_META_SUFFIX_HEADER("&b{}'s Suffixes", true), - META_HEADER("&b{}'s Meta", true), - CHAT_META_ENTRY("&b-> {} &f- &f'{}&f' &8(&7inherited from &a{}&8)", true), - CHAT_META_ENTRY_WITH_CONTEXT("&b-> {} &f- &f'{}&f' &8(&7inherited from &a{}&8){}", true), - META_ENTRY("&b-> &a{} &f= &f'{}&f' &8(&7inherited from &a{}&8)", true), - META_ENTRY_WITH_CONTEXT("&b-> &a{} &f= &f'{}&f' &8(&7inherited from &a{}&8){}", true), - CHAT_META_PREFIX_NONE("&b{} has no prefixes.", true), - CHAT_META_SUFFIX_NONE("&b{} has no suffixes.", true), - META_NONE("&b{} has no meta.", true), - - META_INVALID_PRIORITY("&cInvalid priority &4{}&c. Expected a number.", true), - - ALREADY_HAS_CHAT_META("&b{}&a already has {} &f'{}&f'&a set at a priority of &b{}&a in context {}&a.", true), - ALREADY_HAS_TEMP_CHAT_META("&b{}&a already has {} &f'{}&f'&a set temporarily at a priority of &b{}&a in context {}&a.", true), - - DOES_NOT_HAVE_CHAT_META("&b{}&a doesn't have {} &f'{}&f'&a set at a priority of &b{}&a in context {}&a.", true), - DOES_NOT_HAVE_TEMP_CHAT_META("&b{}&a doesn't have {} &f'{}&f'&a set temporarily at a priority of &b{}&a in context {}&a.", true), - - ADD_CHATMETA_SUCCESS("&b{}&a had {} &f'{}&f'&a set at a priority of &b{}&a in context {}&a.", true), - ADD_TEMP_CHATMETA_SUCCESS("&b{}&a had {} &f'{}&f'&a set at a priority of &b{}&a for a duration of &b{}&a in context {}&a.", true), - REMOVE_CHATMETA_SUCCESS("&b{}&a had {} &f'{}&f'&a at priority &b{}&a removed in context {}&a.", true), - BULK_REMOVE_CHATMETA_SUCCESS("&b{}&a had all {}es at priority &b{}&a removed in context {}&a.", true), - REMOVE_TEMP_CHATMETA_SUCCESS("&b{}&a had temporary {} &f'{}&f'&a at priority &b{}&a removed in context {}&a.", true), - BULK_REMOVE_TEMP_CHATMETA_SUCCESS("&b{}&a had all temporary {}es at priority &b{}&a removed in context {}&a.", true), - - ALREADY_HAS_META("&b{}&a already has meta key &f'{}&f'&a set to &f'{}&f'&a in context {}&a.", true), - ALREADY_HAS_TEMP_META("&b{}&a already has meta key &f'{}&f'&a temporarily set to &f'{}&f'&a in context {}&a.", true), - - DOESNT_HAVE_META("&b{}&a doesn't have meta key &f'{}&f'&a set in context {}&a.", true), - DOESNT_HAVE_TEMP_META("&b{}&a doesn't have meta key &f'{}&f'&a set temporarily in context {}&a.", true), - - SET_META_SUCCESS("&aSet meta key &f'{}&f'&a to &f'{}&f'&a for &b{}&a in context {}&a.", true), - SET_META_TEMP_SUCCESS("&aSet meta key &f'{}&f'&a to &f'{}&f'&a for &b{}&a for a duration of &b{}&a in context {}&a.", true), - UNSET_META_SUCCESS("&aUnset meta key &f'{}&f'&a for &b{}&a in context {}&a.", true), - UNSET_META_TEMP_SUCCESS("&aUnset temporary meta key &f'{}&f'&a for &b{}&a in context {}&a.", true), - - BULK_UPDATE_MUST_USE_CONSOLE("&cThe bulk update command can only be used from the console.", true), - BULK_UPDATE_INVALID_DATA_TYPE("&cInvalid type. Was expecting 'all', 'users' or 'groups'.", true), - BULK_UPDATE_INVALID_CONSTRAINT("&cInvalid constraint &4{}&c. Constraints should be in the format '&f &c'.", true), - BULK_UPDATE_INVALID_COMPARISON("&cInvalid comparison operator '&4{}&c'. Expected one of the following: &f== != ~~ ~!", true), - BULK_UPDATE_QUEUED("&aBulk update operation was queued. &7(&f{}&7)", true), - BULK_UPDATE_CONFIRM("&aRun &b/{} bulkupdate confirm {} &ato execute the update.", true), - BULK_UPDATE_UNKNOWN_ID("&aOperation with id &b{}&a does not exist or has expired.", true), - - BULK_UPDATE_STARTING("&aRunning bulk update.", true), - BULK_UPDATE_SUCCESS("&bBulk update completed successfully.", true), - BULK_UPDATE_FAILURE("&cBulk update failed. Check the console for errors.", true), - - USER_INFO_GENERAL( - "{PREFIX}&b&l> &bUser Info: &f{}" + "\n" + - "{PREFIX}&f- &3UUID: &f{}" + "\n" + - "{PREFIX}&f &7(type: {}&7)" + "\n" + - "{PREFIX}&f- &3Status: {}", - false - ), - USER_INFO_CONTEXTUAL_DATA( - "{PREFIX}&f- &aContextual Data: &7(mode: {}&7)" + "\n" + - "{PREFIX} &3Contexts: {}" + "\n" + - "{PREFIX} &3Prefix: {}" + "\n" + - "{PREFIX} &3Suffix: {}" + "\n" + - "{PREFIX} &3Primary Group: &f{}" + "\n" + - "{PREFIX} &3Meta: {}", - false - ), - - INFO_PARENT_HEADER("&f- &aParent Groups:", true), - INFO_TEMP_PARENT_HEADER("&f- &aTemporary Parent Groups:", true), - INFO_PARENT_ENTRY(" &3> &f{}{}", true), - INFO_PARENT_ENTRY_EXPIRY(" &2- expires in {}", true), - USER_REMOVEGROUP_ERROR_PRIMARY("&aYou cannot remove a user from their primary group.", true), - USER_PRIMARYGROUP_SUCCESS("&b{}&a's primary group was set to &b{}&a.", true), - USER_PRIMARYGROUP_WARN_OPTION("&aWarning: The primary group calculation method being used by this server &7({}) &amay not reflect this change.", true), - USER_PRIMARYGROUP_ERROR_ALREADYHAS("&b{}&a already has &b{}&a set as their primary group.", true), - USER_PRIMARYGROUP_ERROR_NOTMEMBER("&b{}&a was not already a member of &b{}&a, adding them now.", true), - USER_TRACK_ERROR_NOT_CONTAIN_GROUP("&b{}&a isn't already in any groups on &b{}&a.", true), - USER_TRACK_ERROR_AMBIGUOUS_TRACK_SELECTION("&cUnsure which track to use. Please specify it as an argument.", true), - - USER_TRACK_ADDED_TO_FIRST("&b{}&a isn't in any groups on this track, so they were added to the first group, &b{}&a in context {}&a.", true), - USER_PROMOTE_NOT_ON_TRACK("&b{}&a isn't in any groups on this track, so was not promoted.", true), - USER_PROMOTE_SUCCESS("&aPromoting &b{}&a along track &b{}&a from &b{}&a to &b{}&a in context {}&a.", true), - USER_PROMOTE_ERROR_ENDOFTRACK("&aThe end of track &b{}&a was reached. Unable to promote &b{}&a.", true), - USER_PROMOTE_ERROR_MALFORMED( - "{PREFIX}&aThe next group on the track, &b{}&a, no longer exists. Unable to promote user." + "\n" + - "{PREFIX}&aEither create the group, or remove it from the track and try again.", - false - ), - - USER_DEMOTE_SUCCESS("&aDemoting &b{}&a along track &b{}&a from &b{}&a to &b{}&a in context {}&a.", true), - USER_DEMOTE_ENDOFTRACK("&aThe end of track &b{}&a was reached, so &b{}&a was removed from &b{}&a.", true), - USER_DEMOTE_ENDOFTRACK_NOT_REMOVED("&aThe end of track &b{}&a was reached, but &b{}&a was not removed from the first group.", true), - USER_DEMOTE_ERROR_MALFORMED( - "{PREFIX}&aThe previous group on the track, &b{}&a, no longer exists. Unable to demote user." + "\n" + - "{PREFIX}&aEither create the group, or remove it from the track and try again.", - false - ), - - GROUP_INFO_GENERAL( - "{PREFIX}&b&l> &bGroup Info: &f{}" + "\n" + - "{PREFIX}&f- &3Display Name: &f{}" + "\n" + - "{PREFIX}&f- &3Weight: &f{}", - false - ), - GROUP_INFO_CONTEXTUAL_DATA( - "{PREFIX}&f- &aContextual Data: &7(mode: &8server&7)" + "\n" + - "{PREFIX} &3Prefix: {}" + "\n" + - "{PREFIX} &3Suffix: {}" + "\n" + - "{PREFIX} &3Meta: {}", - false - ), - - GROUP_SET_WEIGHT("&aSet weight to &b{}&a for group &b{}&a.", true), - - GROUP_SET_DISPLAY_NAME_DOESNT_HAVE("&b{}&a doesn't have a display name set.", true), - GROUP_SET_DISPLAY_NAME_ALREADY_HAS("&b{}&a already has a display name of &b{}&a.", true), - GROUP_SET_DISPLAY_NAME_ALREADY_IN_USE("&aThe display name &b{}&a is already being used by &b{}&a.", true), - GROUP_SET_DISPLAY_NAME("&aSet display name to &b{}&a for group &b{}&a in context {}&a.", true), - GROUP_SET_DISPLAY_NAME_REMOVED("&aRemoved display name for group &b{}&a in context {}&a.", true), - - TRACK_INFO( - "{PREFIX}&b&l> &bShowing Track: &f{}" + "\n" + - "{PREFIX}&f- &7Path: &f{}", - false - ), - TRACK_CLEAR("&b{}&a's groups track was cleared.", true), - TRACK_APPEND_SUCCESS("&aGroup &b{}&a was appended to track &b{}&a.", true), - TRACK_INSERT_SUCCESS("&aGroup &b{}&a was inserted into track &b{}&a at position &b{}&a.", true), - TRACK_INSERT_ERROR_NUMBER("&cExpected number but instead received: {}", true), - TRACK_INSERT_ERROR_INVALID_POS("&cUnable to insert at position &4{}&c. &7(invalid position)", true), - TRACK_REMOVE_SUCCESS("&aGroup &b{}&a was removed from track &b{}&a.", true), - - LOG_LOAD_ERROR("&cThe log could not be loaded.", true), - LOG_INVALID_PAGE("&cInvalid page number.", true), - LOG_INVALID_PAGE_RANGE("&cInvalid page number. Please enter a value between &41&c and &4{}&c.", true), - LOG_NO_ENTRIES("&bNo log entries to show.", true), - - LOG_ENTRY( - "{PREFIX}&b#{} &8(&7{} ago&8) &8(&e{}&8) [&a{}&8] (&b{}&8)" + "\n" + - "{PREFIX}&7> &f{}", - false - ), - - LOG_NOTIFY_CONSOLE("&cCannot toggle notifications for console.", true), - LOG_NOTIFY_TOGGLE_ON("&aEnabled&b logging output.", true), - LOG_NOTIFY_TOGGLE_OFF("&cDisabled&b logging output.", true), - LOG_NOTIFY_ALREADY_ON("&cYou are already receiving notifications.", true), - LOG_NOTIFY_ALREADY_OFF("&cYou aren't currently receiving notifications.", true), - LOG_NOTIFY_UNKNOWN("&cState unknown. Expecting \"on\" or \"off\".", true), - - LOG_SEARCH_HEADER("&aShowing recent actions for query &b{} &7(page &f{}&7 of &f{}&7)", true), - LOG_RECENT_HEADER("&aShowing recent actions &7(page &f{}&7 of &f{}&7)", true), - LOG_RECENT_BY_HEADER("&aShowing recent actions by &b{} &7(page &f{}&7 of &f{}&7)", true), - LOG_HISTORY_USER_HEADER("&aShowing history for user &b{} &7(page &f{}&7 of &f{}&7)", true), - LOG_HISTORY_GROUP_HEADER("&aShowing history for group &b{} &7(page &f{}&7 of &f{}&7)", true), - LOG_HISTORY_TRACK_HEADER("&aShowing history for track &b{} &7(page &f{}&7 of &f{}&7)", true), - - LOG_EXPORT_ALREADY_EXISTS("&cError: File &4{}&c already exists.", true), - LOG_EXPORT_NOT_WRITABLE("&cError: File &4{}&c is not writable.", true), - LOG_EXPORT_EMPTY("&cThe log is empty and therefore cannot be exported.", true), - LOG_EXPORT_FAILURE("&cAn unexpected error occured whilst writing to the file.", true), - LOG_EXPORT_SUCCESS("&aSuccessfully exported to &b{}&a.", true), - - IMPORT_ALREADY_RUNNING("&cAnother import process is already running. Please wait for it to finish and try again.", true), - EXPORT_ALREADY_RUNNING("&cAnother export process is already running. Please wait for it to finish and try again.", true), - FILE_NOT_WITHIN_DIRECTORY("&cError: File &4{}&c must be a direct child of the data directory.", true), - - EXPORT_CODE( - "&aExport code: &7{}" + "\n" + - "&7Use the following command to import:" + "\n" + - "&a/{} import {} --upload", - true - ), - - EXPORT_HTTP_REQUEST_FAILURE("&cUnable to communicate with bytebin. (response code &4{}&c, message='{}')", true), - EXPORT_HTTP_UNKNOWN_FAILURE("&cUnable to communicate with bytebin. Check the console for errors.", true), - - IMPORT_FILE_DOESNT_EXIST("&cError: File &4{}&c does not exist.", true), - IMPORT_FILE_NOT_READABLE("&cError: File &4{}&c is not readable.", true), - IMPORT_FILE_READ_FAILURE("&cAn unexpected error occured whilst reading from the import file. (is it the correct format?)", true), - - IMPORT_INVALID_CODE("&cInvalid code. &7({})", true), - IMPORT_HTTP_REQUEST_FAILURE("&cUnable to communicate with bytebin. (response code &4{}&c, message='{}')", true), - IMPORT_HTTP_UNKNOWN_FAILURE("&cUnable to communicate with bytebin. Check the console for errors.", true), - IMPORT_UNABLE_TO_READ("&cUnable to read data using the given code. &7({})", true), - - IMPORT_PROGRESS("&b(Import) &b-> &f{}&f% complete &7- &b{}&f/&b{} &foperations complete with &c{} &ferrors.", true), - IMPORT_PROGRESS_SIN("&b(Import) &b-> &f{}&f% complete &7- &b{}&f/&b{} &foperations complete with &c{} &ferror.", true), - IMPORT_START("&b(Import) &b-> &fStarting import process.", true), - IMPORT_INFO("&b(Import) &b-> &f{}.", true), - - IMPORT_END_COMPLETE("&b(Import) &a&lCOMPLETED &7- took &b{} &7seconds - &7No errors.", true), - IMPORT_END_COMPLETE_ERR("&b(Import) &a&lCOMPLETED &7- took &b{} &7seconds - &c{} errors.", true), - IMPORT_END_COMPLETE_ERR_SIN("&b(Import) &a&lCOMPLETED &7- took &b{} &7seconds - &c{} error.", true), - IMPORT_END_ERROR_HEADER( - "{PREFIX}&b(Import) &7------------> &fShowing Error #&b{} &7<------------" + "\n" + - "{PREFIX}&b(Import) &fWhilst executing: &3Command #{}" + "\n" + - "{PREFIX}&b(Import) &fCommand: &7{}" + "\n" + - "{PREFIX}&b(Import) &fType: &3{}" + "\n" + - "{PREFIX}&b(Import) &fOutput:", - false - ), - - IMPORT_END_ERROR_CONTENT("&b(Import) &b-> &c{}", true), - IMPORT_END_ERROR_FOOTER("&b(Import) &7<------------------------------------------>", true); - - private final String message; - private final boolean showPrefix; - - Message(String message, boolean showPrefix) { - // rewrite hardcoded placeholders according to their position - this.message = TextUtils.rewritePlaceholders(message); - this.showPrefix = showPrefix; - } - - public String getMessage() { - return this.message; - } - - private String getTranslatedMessage(@Nullable LocaleManager localeManager) { - String message = null; - if (localeManager != null) { - message = localeManager.getTranslation(this); - } - if (message == null) { - message = this.getMessage(); - } - return message; - } - - private String format(@Nullable LocaleManager localeManager, Object... objects) { - String prefix = PREFIX.getTranslatedMessage(localeManager); - String msg = format( - this.getTranslatedMessage(localeManager) - .replace("{PREFIX}", prefix) - .replace("\\n", "\n"), - objects - ); - return this.showPrefix ? prefix + msg : msg; - } - - public String asString(@Nullable LocaleManager localeManager, Object... objects) { - return colorize(format(localeManager, objects)); - } - - public TextComponent asComponent(@Nullable LocaleManager localeManager, Object... objects) { - return TextUtils.fromLegacy(format(localeManager, objects), TextUtils.AMPERSAND_CHAR); - } - - public void send(Sender sender, Object... objects) { - sender.sendMessage(asString(sender.getPlugin().getLocaleManager(), objects)); - } - - private static String format(String s, Object... objects) { - for (int i = 0; i < objects.length; i++) { - Object o = objects[i]; - s = s.replace("{" + i + "}", String.valueOf(o)); - } - return s; - } - - /** - * Colorizes a message. - * - * @param s the message to colorize - * @return a colored message - */ - public static String colorize(String s) { - char[] b = s.toCharArray(); - - for (int i = 0; i < b.length - 1; ++i) { - if (b[i] == '&' && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) { - b[i] = 167; - b[i + 1] = Character.toLowerCase(b[i + 1]); - } - } - - return new String(b); - } - - /* - public static void main(String[] args) { - for (Message message : values()) { - String key = message.name().replace('_', '-').toLowerCase(); - String value = message.message; - - if (!value.contains("\n")) { - System.out.println(key + ": \"" + value.replace("\"", "\\\"") + "\""); - } else { - System.out.println(key + ": >"); - String[] parts = value.split("\n"); - - for (int i = 0; i < parts.length; i++) { - String s = parts[i].replace("\"", "\\\""); - System.out.println(" " + s + (i == (parts.length - 1) ? "" : "\\n")); - } - } - } - } - */ - -} diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java index 0ad4ac73b..697a63cd0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java @@ -41,12 +41,11 @@ import me.lucko.luckperms.common.event.gen.GeneratedEventClass; import me.lucko.luckperms.common.extension.SimpleExtensionManager; import me.lucko.luckperms.common.http.BytebinClient; import me.lucko.luckperms.common.inheritance.InheritanceGraphFactory; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.TranslationManager; import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.messaging.MessagingFactory; import me.lucko.luckperms.common.plugin.logging.PluginLogger; -import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.Storage; import me.lucko.luckperms.common.storage.StorageFactory; import me.lucko.luckperms.common.storage.StorageType; @@ -72,13 +71,13 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { // init during load private DependencyManager dependencyManager; + private TranslationManager translationManager; // init during enable private VerboseHandler verboseHandler; private PermissionRegistry permissionRegistry; private LogDispatcher logDispatcher; private LuckPermsConfiguration configuration; - private LocaleManager localeManager; private BytebinClient bytebin; private FileWatcher fileWatcher = null; private Storage storage; @@ -98,13 +97,16 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { this.dependencyManager = new DependencyManager(this); this.dependencyManager.loadDependencies(getGlobalDependencies()); - // load the sender factory instance - setupSenderFactory(); + this.translationManager = new TranslationManager(this); + this.translationManager.load(); } public final void enable() { + // load the sender factory instance + setupSenderFactory(); + // send the startup banner - displayBanner(getConsoleSender()); + Message.STARTUP_BANNER.send(getConsoleSender(), getBootstrap()); // load some utilities early this.verboseHandler = new VerboseHandler(getBootstrap().getScheduler()); @@ -115,10 +117,6 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { getLogger().info("Loading configuration..."); this.configuration = new LuckPermsConfiguration(this, provideConfigurationAdapter()); - // load locale - this.localeManager = new LocaleManager(); - this.localeManager.tryLoad(this, getBootstrap().getConfigDirectory().resolve("lang.yml")); - // setup a bytebin instance OkHttpClient httpClient = new OkHttpClient.Builder() .callTimeout(15, TimeUnit.SECONDS) @@ -251,9 +249,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { protected Set getGlobalDependencies() { return EnumSet.of( - Dependency.TEXT, - Dependency.TEXT_SERIALIZER_GSON, - Dependency.TEXT_SERIALIZER_LEGACY, + Dependency.ADVENTURE, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, @@ -295,6 +291,11 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { return this.dependencyManager; } + @Override + public TranslationManager getTranslationManager() { + return this.translationManager; + } + @Override public VerboseHandler getVerboseHandler() { return this.verboseHandler; @@ -315,11 +316,6 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { return this.configuration; } - @Override - public LocaleManager getLocaleManager() { - return this.localeManager; - } - @Override public BytebinClient getBytebin() { return this.bytebin; @@ -370,13 +366,6 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { return this.eventDispatcher; } - private void displayBanner(Sender sender) { - sender.sendMessage(Message.colorize("&b &3 __ ")); - sender.sendMessage(Message.colorize("&b | &3|__) " + "&2" + getPluginName() + " &bv" + getBootstrap().getVersion())); - sender.sendMessage(Message.colorize("&b |___ &3| " + "&8Running on " + getBootstrap().getType().getFriendlyName() + " - " + getBootstrap().getServerBrand())); - sender.sendMessage(""); - } - public static String getPluginName() { LocalDate date = LocalDate.now(); if (date.getMonth() == Month.APRIL && date.getDayOfMonth() == 1) { diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java index 559f0352a..ffbd27351 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java @@ -37,7 +37,7 @@ import me.lucko.luckperms.common.event.EventDispatcher; import me.lucko.luckperms.common.extension.SimpleExtensionManager; import me.lucko.luckperms.common.http.BytebinClient; import me.lucko.luckperms.common.inheritance.InheritanceGraphFactory; -import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.TranslationManager; import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.Track; @@ -171,9 +171,9 @@ public interface LuckPermsPlugin { /** * Gets the instance providing locale translations for the plugin * - * @return the locale manager + * @return the translation manager */ - LocaleManager getLocaleManager(); + TranslationManager getTranslationManager(); /** * Gets the dependency manager for the plugin diff --git a/common/src/main/java/me/lucko/luckperms/common/sender/AbstractSender.java b/common/src/main/java/me/lucko/luckperms/common/sender/AbstractSender.java index 6c2cae656..6f11c0083 100644 --- a/common/src/main/java/me/lucko/luckperms/common/sender/AbstractSender.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/AbstractSender.java @@ -25,15 +25,20 @@ package me.lucko.luckperms.common.sender; -import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.Component; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; import net.luckperms.api.util.Tristate; import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; import java.util.UUID; /** @@ -42,8 +47,6 @@ import java.util.UUID; * @param the command sender type */ public final class AbstractSender implements Sender { - private static final Splitter NEW_LINE_SPLITTER = Splitter.on("\n"); - private final LuckPermsPlugin platform; private final SenderFactory factory; private final WeakReference sender; @@ -75,13 +78,11 @@ public final class AbstractSender implements Sender { } @Override - public void sendMessage(String message) { + public void sendMessage(Component message) { final T sender = this.sender.get(); if (sender != null) { - - // if it is console, split up the lines and send individually. if (isConsole()) { - for (String line : NEW_LINE_SPLITTER.split(message)) { + for (Component line : splitNewlines(message)) { this.factory.sendMessage(sender, line); } } else { @@ -90,19 +91,6 @@ public final class AbstractSender implements Sender { } } - @Override - public void sendMessage(Component message) { - if (isConsole()) { - sendMessage(TextUtils.toLegacy(message)); - return; - } - - final T sender = this.sender.get(); - if (sender != null) { - this.factory.sendMessage(sender, message); - } - } - @Override public Tristate getPermissionValue(String permission) { T sender = this.sender.get(); @@ -150,4 +138,42 @@ public final class AbstractSender implements Sender { public int hashCode() { return this.uniqueId.hashCode(); } + + // A small utility method which splits components built using + // > join(newLine(), components...) + // back into separate components. + private static Iterable splitNewlines(Component message) { + if (message instanceof TextComponent && message.style().isEmpty() && !message.children().isEmpty() && ((TextComponent) message).content().isEmpty()) { + LinkedList> split = new LinkedList<>(); + split.add(new ArrayList<>()); + + for (Component child : message.children()) { + if (Component.newline().equals(child)) { + split.add(new ArrayList<>()); + } else { + Iterator splitChildren = splitNewlines(child).iterator(); + if (splitChildren.hasNext()) { + split.getLast().add(splitChildren.next()); + } + while (splitChildren.hasNext()) { + split.add(new ArrayList<>()); + split.getLast().add(splitChildren.next()); + } + } + } + + return Iterables.transform(split, input -> { + switch (input.size()) { + case 0: + return Component.empty(); + case 1: + return input.get(0); + default: + return Component.join(Component.empty(), input); + } + }); + } + + return Collections.singleton(message); + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/sender/DummySender.java b/common/src/main/java/me/lucko/luckperms/common/sender/DummySender.java index 716460dec..8e21c7b99 100644 --- a/common/src/main/java/me/lucko/luckperms/common/sender/DummySender.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/DummySender.java @@ -26,9 +26,7 @@ package me.lucko.luckperms.common.sender; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.Component; import net.luckperms.api.util.Tristate; import java.util.UUID; @@ -45,18 +43,6 @@ public abstract class DummySender implements Sender { this.name = name; } - protected abstract void consumeMessage(String s); - - @Override - public void sendMessage(String message) { - consumeMessage(message); - } - - @Override - public void sendMessage(Component message) { - consumeMessage(TextUtils.toLegacy(message)); - } - @Override public Tristate getPermissionValue(String permission) { return Tristate.TRUE; diff --git a/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java b/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java index 11732f2f7..a9cd81d18 100644 --- a/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java @@ -28,9 +28,8 @@ package me.lucko.luckperms.common.sender; import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.context.ContextManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.Component; +import net.kyori.adventure.text.Component; import net.luckperms.api.context.DefaultContextKeys; import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.util.Tristate; @@ -105,15 +104,6 @@ public interface Sender { */ UUID getUniqueId(); - /** - * Send a message to the Sender. - * - *

Supports {@link TextUtils#SECTION_CHAR} for message formatting.

- * - * @param message the message to send. - */ - void sendMessage(String message); - /** * Send a json message to the Sender. * diff --git a/common/src/main/java/me/lucko/luckperms/common/sender/SenderFactory.java b/common/src/main/java/me/lucko/luckperms/common/sender/SenderFactory.java index 1e852bc81..f0de00db7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/sender/SenderFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/SenderFactory.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.sender; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import net.kyori.text.Component; +import net.kyori.adventure.text.Component; import net.luckperms.api.util.Tristate; import java.util.Objects; @@ -39,7 +39,7 @@ import java.util.UUID; * @param

the plugin type * @param the command sender type */ -public abstract class SenderFactory

{ +public abstract class SenderFactory

implements AutoCloseable { private final P plugin; public SenderFactory(P plugin) { @@ -54,8 +54,6 @@ public abstract class SenderFactory

{ protected abstract String getName(T sender); - protected abstract void sendMessage(T sender, String message); - protected abstract void sendMessage(T sender, Component message); protected abstract Tristate getPermissionValue(T sender, String node); @@ -68,4 +66,9 @@ public abstract class SenderFactory

{ Objects.requireNonNull(sender, "sender"); return new AbstractSender<>(this.plugin, this, sender); } + + @Override + public void close() { + + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/util/ProgressLogger.java b/common/src/main/java/me/lucko/luckperms/common/util/ProgressLogger.java index 43201e559..10b2f3431 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/ProgressLogger.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/ProgressLogger.java @@ -25,25 +25,31 @@ package me.lucko.luckperms.common.util; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.sender.Sender; +import net.kyori.adventure.text.Component; + import java.util.HashSet; import java.util.Set; +import java.util.function.Function; public class ProgressLogger { public static final int DEFAULT_NOTIFY_FREQUENCY = 500; - private final Message logMessage; - private final Message logProgressMessage; - private final String logPrefixParam; + private final Function logMessage; + private final Function logProgressMessage; private final Set listeners = new HashSet<>(); - public ProgressLogger(Message logMessage, Message logProgressMessage, String logPrefixParam) { - this.logMessage = logMessage; - this.logProgressMessage = logProgressMessage; - this.logPrefixParam = logPrefixParam; + public ProgressLogger(Message.Args1 logMessage, Message.Args1 logProgressMessage) { + this.logMessage = logMessage::build; + this.logProgressMessage = logProgressMessage::build; + } + + public ProgressLogger(Message.Args2 logMessage, Message.Args2 logProgressMessage, String logPrefixParam) { + this.logMessage = message -> logMessage.build(logPrefixParam, message); + this.logProgressMessage = message -> logProgressMessage.build(logPrefixParam, message); } public void addListener(Sender sender) { @@ -72,18 +78,10 @@ public class ProgressLogger { } } - private Object[] formParams(String content) { - if (this.logPrefixParam != null) { - return new Object[]{this.logPrefixParam, content}; - } else { - return new Object[]{content}; - } - } - - private void dispatchMessage(Message messageType, String content) { - Object[] params = formParams(content); + private void dispatchMessage(Function messageType, String content) { + final Component message = messageType.apply(content); for (Sender s : this.listeners) { - messageType.send(s, params); + s.sendMessage(message); } } } diff --git a/common/src/main/java/me/lucko/luckperms/common/util/TextUtils.java b/common/src/main/java/me/lucko/luckperms/common/util/TextUtils.java deleted file mode 100644 index f88b903de..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/util/TextUtils.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.util; - -import net.kyori.text.Component; -import net.kyori.text.TextComponent; -import net.kyori.text.serializer.legacy.LegacyComponentSerializer; - -import java.util.Arrays; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public final class TextUtils { - private TextUtils() {} - - public static final char SECTION_CHAR = '\u00A7'; // § - public static final char AMPERSAND_CHAR = '&'; - - public static String joinNewline(String... strings) { - return joinNewline(Arrays.stream(strings)); - } - - public static String joinNewline(Stream strings) { - return strings.collect(Collectors.joining("\n")); - } - - public static TextComponent fromLegacy(String input, char character) { - return LegacyComponentSerializer.legacy().deserialize(input, character); - } - - public static TextComponent fromLegacy(String input) { - return LegacyComponentSerializer.legacy().deserialize(input); - } - - public static String toLegacy(Component component, char character) { - return LegacyComponentSerializer.legacy().serialize(component, character); - } - - public static String toLegacy(Component component) { - return LegacyComponentSerializer.legacy().serialize(component); - } - - public static String rewritePlaceholders(String input) { - int i = 0; - while (input.contains("{}")) { - input = input.replaceFirst("\\{\\}", "{" + i++ + "}"); - } - return input; - } - -} diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java index 7ae1f2bce..5fd5028b0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java +++ b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java @@ -28,15 +28,13 @@ package me.lucko.luckperms.common.verbose; import com.google.gson.JsonObject; import me.lucko.luckperms.common.calculator.result.TristateResult; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.http.AbstractHttpClient; import me.lucko.luckperms.common.http.BytebinClient; import me.lucko.luckperms.common.http.UnsuccessfulRequestException; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.StackTracePrinter; -import me.lucko.luckperms.common.util.TextUtils; import me.lucko.luckperms.common.util.gson.GsonProvider; import me.lucko.luckperms.common.util.gson.JArray; import me.lucko.luckperms.common.util.gson.JObject; @@ -44,8 +42,10 @@ import me.lucko.luckperms.common.verbose.event.MetaCheckEvent; import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent; import me.lucko.luckperms.common.verbose.event.VerboseEvent; -import net.kyori.text.TextComponent; -import net.kyori.text.event.HoverEvent; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.ComponentLike; +import net.kyori.adventure.text.event.HoverEvent; +import net.kyori.adventure.text.format.NamedTextColor; import net.luckperms.api.query.QueryMode; import net.luckperms.api.util.Tristate; @@ -158,8 +158,7 @@ public class VerboseListener { Message.VERBOSE_LOG_PERMISSION.send(this.notifiedSender, permissionEvent.getCheckTarget(), permissionEvent.getPermission(), - getTristateColor(permissionEvent.getResult().result()), - permissionEvent.getResult().result().name().toLowerCase() + permissionEvent.getResult().result() ); } else if (event instanceof MetaCheckEvent) { MetaCheckEvent metaEvent = (MetaCheckEvent) event; @@ -175,19 +174,17 @@ public class VerboseListener { } // form a text component from the check trace - TextComponent textComponent; - + Component component; if (event instanceof PermissionCheckEvent) { PermissionCheckEvent permissionEvent = (PermissionCheckEvent) event; - textComponent = Message.VERBOSE_LOG_PERMISSION.asComponent(this.notifiedSender.getPlugin().getLocaleManager(), + component = Message.VERBOSE_LOG_PERMISSION.build( permissionEvent.getCheckTarget(), permissionEvent.getPermission(), - getTristateColor(permissionEvent.getResult().result()), - permissionEvent.getResult().result().name().toLowerCase() + permissionEvent.getResult().result() ); } else if (event instanceof MetaCheckEvent) { MetaCheckEvent metaEvent = (MetaCheckEvent) event; - textComponent = Message.VERBOSE_LOG_META.asComponent(this.notifiedSender.getPlugin().getLocaleManager(), + component = Message.VERBOSE_LOG_META.build( metaEvent.getCheckTarget(), metaEvent.getKey(), metaEvent.getResult() @@ -197,34 +194,62 @@ public class VerboseListener { } // build the hover text - List hover = new ArrayList<>(); + List hover = new ArrayList<>(); if (event instanceof PermissionCheckEvent) { PermissionCheckEvent permissionEvent = (PermissionCheckEvent) event; - hover.add("&aType: &2permission"); - hover.add("&bOrigin: &2" + permissionEvent.getOrigin().name()); + hover.add(Component.text() + .append(Component.text("Type: ", NamedTextColor.GREEN)) + .append(Component.text("permission", NamedTextColor.DARK_GREEN)) + ); + hover.add(Component.text() + .append(Component.text("Origin: ", NamedTextColor.AQUA)) + .append(Component.text(permissionEvent.getOrigin().name(), NamedTextColor.DARK_GREEN)) + ); TristateResult result = permissionEvent.getResult(); if (result.processorClass() != null) { - hover.add("&bProcessor: &2" + result.processorClass().getName()); + hover.add(Component.text() + .append(Component.text("Processor: ", NamedTextColor.AQUA)) + .append(Component.text(result.processorClass().getName(), NamedTextColor.DARK_GREEN)) + ); } if (result.cause() != null) { - hover.add("&bCause: &2" + result.cause()); + hover.add(Component.text() + .append(Component.text("Cause: ", NamedTextColor.AQUA)) + .append(Component.text(result.cause(), NamedTextColor.DARK_GREEN)) + ); } } if (event instanceof MetaCheckEvent) { MetaCheckEvent metaEvent = (MetaCheckEvent) event; - hover.add("&aType: &2meta"); - hover.add("&bOrigin: &2" + metaEvent.getOrigin().name()); + hover.add(Component.text() + .append(Component.text("Type: ", NamedTextColor.GREEN)) + .append(Component.text("meta", NamedTextColor.DARK_GREEN)) + ); + hover.add(Component.text() + .append(Component.text("Origin: ", NamedTextColor.AQUA)) + .append(Component.text(metaEvent.getOrigin().name(), NamedTextColor.DARK_GREEN)) + ); } if (event.getCheckQueryOptions().mode() == QueryMode.CONTEXTUAL) { - hover.add("&bContext: &r" + MessageUtils.contextSetToString(this.notifiedSender.getPlugin().getLocaleManager(), event.getCheckQueryOptions().context())); + hover.add(Component.text() + .append(Component.text("Context: ", NamedTextColor.AQUA)) + .append(Message.formatContextSet(event.getCheckQueryOptions().context())) + ); } - hover.add("&bThread: &r" + event.getCheckThread()); - hover.add("&bTrace: &r"); - Consumer printer = StackTracePrinter.elementToString(str -> hover.add("&7" + str)); + hover.add(Component.text() + .append(Component.text("Thread: ", NamedTextColor.AQUA)) + .append(Component.text(event.getCheckThread(), NamedTextColor.WHITE)) + ); + + hover.add(Component.text() + .append(Component.text("Trace: ", NamedTextColor.AQUA)) + ); + + Consumer printer = StackTracePrinter.elementToString(str -> hover.add(Component.text(str, NamedTextColor.GRAY))); int overflow; if (shouldFilterStackTrace(event)) { overflow = CHAT_FILTERED_PRINTER.process(event.getCheckTrace(), printer); @@ -232,13 +257,12 @@ public class VerboseListener { overflow = CHAT_UNFILTERED_PRINTER.process(event.getCheckTrace(), printer); } if (overflow != 0) { - hover.add("&f... and " + overflow + " more"); + hover.add(Component.text("... and " + overflow + " more", NamedTextColor.WHITE)); } // send the message - HoverEvent hoverEvent = HoverEvent.showText(TextUtils.fromLegacy(TextUtils.joinNewline(hover.stream()), TextUtils.AMPERSAND_CHAR)); - TextComponent text = textComponent.toBuilder().applyDeep(comp -> comp.hoverEvent(hoverEvent)).build(); - this.notifiedSender.sendMessage(text); + HoverEvent hoverEvent = HoverEvent.showText(Component.join(Component.newline(), hover)); + this.notifiedSender.sendMessage(component.hoverEvent(hoverEvent)); } private static boolean shouldFilterStackTrace(VerboseEvent event) { diff --git a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorRequest.java b/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorRequest.java index 835a91b9a..2c9a15bbe 100644 --- a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorRequest.java +++ b/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorRequest.java @@ -34,7 +34,7 @@ import me.lucko.luckperms.common.context.ContextSetJsonSerializer; import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; import me.lucko.luckperms.common.http.AbstractHttpClient; import me.lucko.luckperms.common.http.UnsuccessfulRequestException; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.node.utils.NodeJsonSerializer; @@ -44,11 +44,6 @@ import me.lucko.luckperms.common.util.gson.GsonProvider; import me.lucko.luckperms.common.util.gson.JArray; import me.lucko.luckperms.common.util.gson.JObject; -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 net.luckperms.api.context.ImmutableContextSet; import java.io.ByteArrayOutputStream; @@ -172,15 +167,7 @@ public class WebEditorRequest { // form a url for the editor String url = plugin.getConfiguration().get(ConfigKeys.WEB_EDITOR_URL_PATTERN) + pasteId; - - Message.EDITOR_URL.send(sender); - - Component message = TextComponent.builder(url).color(TextColor.AQUA) - .clickEvent(ClickEvent.openUrl(url)) - .hoverEvent(HoverEvent.showText(TextComponent.of("Click to open the editor.").color(TextColor.GRAY))) - .build(); - - sender.sendMessage(message); + Message.EDITOR_URL.send(sender, url); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorResponse.java b/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorResponse.java index 5b1b43805..38b80fc65 100644 --- a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorResponse.java +++ b/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorResponse.java @@ -32,11 +32,9 @@ import com.google.gson.JsonObject; import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; -import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; @@ -45,7 +43,6 @@ import me.lucko.luckperms.common.model.manager.group.GroupManager; import me.lucko.luckperms.common.node.utils.NodeJsonSerializer; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; -import me.lucko.luckperms.common.util.DurationFormatter; import me.lucko.luckperms.common.util.Uuids; import net.luckperms.api.actionlog.Action; @@ -205,16 +202,13 @@ public class WebEditorResponse { .build().submit(this.plugin, this.sender); } - String additionsSummary = "addition" + (additions == 1 ? "" : "s"); - String deletionsSummary = "deletion" + (deletions == 1 ? "" : "s"); - Message.APPLY_EDITS_SUCCESS.send(this.sender, type, holder.getFormattedDisplayName()); - Message.APPLY_EDITS_SUCCESS_SUMMARY.send(this.sender, additions, additionsSummary, deletions, deletionsSummary); + Message.APPLY_EDITS_SUCCESS_SUMMARY.send(this.sender, additions, deletions); for (Node n : diffAdded) { - Message.APPLY_EDITS_DIFF_ADDED.send(this.sender, formatNode(this.plugin.getLocaleManager(), n)); + Message.APPLY_EDITS_DIFF_ADDED.send(this.sender, n); } for (Node n : diffRemoved) { - Message.APPLY_EDITS_DIFF_REMOVED.send(this.sender, formatNode(this.plugin.getLocaleManager(), n)); + Message.APPLY_EDITS_DIFF_REMOVED.send(this.sender, n); } StorageAssistant.save(holder, this.sender, this.plugin); return true; @@ -265,13 +259,11 @@ public class WebEditorResponse { .build().submit(this.plugin, this.sender); } - String additionsSummary = "addition" + (additions == 1 ? "" : "s"); - String deletionsSummary = "deletion" + (deletions == 1 ? "" : "s"); - Message.APPLY_EDITS_SUCCESS.send(this.sender, "track", track.getName()); - Message.APPLY_EDITS_SUCCESS_SUMMARY.send(this.sender, additions, additionsSummary, deletions, deletionsSummary); - Message.APPLY_EDITS_DIFF_REMOVED.send(this.sender, before); - Message.APPLY_EDITS_DIFF_ADDED.send(this.sender, after); + Message.APPLY_EDITS_SUCCESS_SUMMARY.send(this.sender, additions, deletions); + Message.APPLY_EDITS_TRACK_BEFORE.send(this.sender, before); + Message.APPLY_EDITS_TRACK_AFTER.send(this.sender, after); + StorageAssistant.save(track, this.sender, this.plugin); return true; } @@ -386,11 +378,6 @@ public class WebEditorResponse { return true; } - private static String formatNode(LocaleManager localeManager, Node n) { - return n.getKey() + " &7(" + (n.getValue() ? "&a" : "&c") + n.getValue() + "&7)" + MessageUtils.getAppendableNodeContextString(localeManager, n) + - (n.hasExpiry() ? " &7(" + DurationFormatter.CONCISE.format(n.getExpiryDuration()) + ")" : ""); - } - private static Set getAdded(Collection before, Collection after) { Set added = new LinkedHashSet<>(after); added.removeAll(before); diff --git a/common/src/main/resources/luckperms_en.properties b/common/src/main/resources/luckperms_en.properties new file mode 100644 index 000000000..88f24e991 --- /dev/null +++ b/common/src/main/resources/luckperms_en.properties @@ -0,0 +1,589 @@ +luckperms.logs.actionlog-prefix=LOG +luckperms.logs.verbose-prefix=VB +luckperms.logs.export-prefix=EXPORT +luckperms.logs.migration-prefix=MIGRATION +luckperms.commandsystem.available-commands=Use {0} to view available commands +luckperms.commandsystem.command-not-recognised=Command not recognised +luckperms.commandsystem.no-permission=You do not have permission to use this command! +luckperms.commandsystem.no-permission-subcommands=You do not have permission to use any sub commands +luckperms.commandsystem.usage.sub-commands-header=Sub Commands +luckperms.commandsystem.usage.usage-header=Command Usage +luckperms.commandsystem.usage.arguments-header=Arguments +luckperms.first-time.no-permissions-setup=It seems that no permissions have been setup yet! +luckperms.first-time.use-console-to-give-access=Before you can use any of the LuckPerms commands in-game, you need to use the console to give yourself access +luckperms.first-time.console-command-prompt=Open your console and run +luckperms.first-time.next-step=After you''ve done this, you can begin to define your permission assignments and groups +luckperms.first-time.wiki-prompt=Don''t know where to start? Check here: {0} +luckperms.login.try-again=Please try again later +luckperms.login.loading-database-error=A database error occurred whilst loading permissions data +luckperms.login.server-admin-check-console-errors=If you are a server admin, please check the console for any errors +luckperms.login.server-admin-check-console-info=Please check the server console for more information +luckperms.login.data-not-loaded-at-pre=Permissions data for your user was not loaded during the pre-login stage +luckperms.login.unable-to-continue=unable to continue +luckperms.login.craftbukkit-offline-mode-error=this is likely due to a conflict between CraftBukkit and the online-mode setting +luckperms.login.unexpected-error=An unexpected error occurred whilst setting up your permissions data +luckperms.opsystem.disabled=The vanilla OP system is disabled on this server +luckperms.opsystem.sponge-warning=Please note that Server Operator status has no effect on Sponge permission checks when a permission plugin is installed, you must edit user data directly +luckperms.command.misc.invalid-code=Invalid code +luckperms.command.misc.response-code-key=response code +luckperms.command.misc.error-message-key=message +luckperms.command.misc.bytebin-unable-to-communicate=Unable to communicate with bytebin +luckperms.command.misc.webapp-unable-to-communicate=Unable to communicate with the web app +luckperms.command.misc.check-console-for-errors=Check the console for errors +luckperms.command.misc.file-must-be-in-data=File {0} must be a direct child of the data directory +luckperms.command.misc.wait-to-finish=Please wait for it to finish and try again +luckperms.command.misc.invalid-priority=Invalid priority {0} +luckperms.command.misc.expected-number=Expected a number +luckperms.command.misc.date-parse-error=Could not parse date {0} +luckperms.command.misc.date-in-past-error=You cannot set a date in the past! +luckperms.command.misc.page=page {0} of {1} +luckperms.command.misc.page-entries={0} entries +luckperms.command.misc.none=None +luckperms.command.misc.loading.error.unexpected=An unexpected error occurred +luckperms.command.misc.loading.error.user=User not loaded +luckperms.command.misc.loading.error.user-specific=Unable to load target user {0} +luckperms.command.misc.loading.error.user-not-found=A user for {0} could not be found +luckperms.command.misc.loading.error.user-save-error=There was an error whilst saving user data for {0} +luckperms.command.misc.loading.error.user-not-online=User {0} is not online +luckperms.command.misc.loading.error.user-invalid={0} is not a valid username/uuid +luckperms.command.misc.loading.error.user-not-uuid=Target user {0} is not a valid uuid +luckperms.command.misc.loading.error.group=Group not loaded +luckperms.command.misc.loading.error.all-groups=Unable to load all groups +luckperms.command.misc.loading.error.group-not-found=A group named {0} could not be found +luckperms.command.misc.loading.error.group-save-error=There was an error whilst saving group data for {0} +luckperms.command.misc.loading.error.group-invalid={0} is not a valid group name +luckperms.command.misc.loading.error.track=Track not loaded +luckperms.command.misc.loading.error.all-tracks=Unable to load all tracks +luckperms.command.misc.loading.error.track-not-found=A track named {0} could not be found +luckperms.command.misc.loading.error.track-save-error=There was an error whilst saving track data for {0} +luckperms.command.misc.loading.error.track-invalid={0} is not a valid track name +luckperms.command.check.result=Permission check result on user {0} for permission {1} +luckperms.command.editor.no-match=Unable to open editor, no objects matched the desired type +luckperms.command.editor.start=Preparing a new editor session, please wait... +luckperms.command.editor.url=Click the link below to open the editor +luckperms.command.editor.unable-to-communicate=Unable to communicate with the editor +luckperms.command.editor.apply-edits.success=Web editor data was applied to {0} {1} successfully +luckperms.command.editor.apply-edits.success-summary={0} {1} and {2} {3} +luckperms.command.editor.apply-edits.success.additions=additions +luckperms.command.editor.apply-edits.success.additions-singular=addition +luckperms.command.editor.apply-edits.success.deletions=deletions +luckperms.command.editor.apply-edits.success.deletions-singular=deletion +luckperms.command.editor.apply-edits.no-changes=No changes were applied from the web editor, the returned data didn''t contain any edits +luckperms.command.editor.apply-edits.unknown-type=Unable to apply edit to the specified object type +luckperms.command.editor.apply-edits.unable-to-read=Unable to read data using the given code +luckperms.command.search.searching.permission=Searching for users and groups with {0} +luckperms.command.search.searching.inherit=Searching for users and groups who inherit from {0} +luckperms.command.search.result=Found {0} entries from {1} users and {2} groups +luckperms.command.search.result.default-notice=Note: when searching for members of the default group, offline players with no other permissions will not be shown! +luckperms.command.search.showing-users=Showing user entries +luckperms.command.search.showing-groups=Showing group entries +luckperms.command.tree.start=Generating permission tree, please wait... +luckperms.command.tree.empty=Unable to generate tree, no results were found +luckperms.command.tree.url=Permission tree URL +luckperms.command.verbose.invalid-filter={0} is not a valid verbose filter +luckperms.command.verbose.enabled=Verbose logging {0} for checks matching {0} +luckperms.command.verbose.command-exec=Forcing {0} to execute command {1} and reporting all checks made... +luckperms.command.verbose.off=Verbose logging {0} +luckperms.command.verbose.command-exec-complete=Command execution complete +luckperms.command.verbose.enabled-recording=Verbose recording {0} for checks matching {0} +luckperms.command.verbose.uploading=Verbose logging {0}, uploading results... +luckperms.command.verbose.url=Verbose results URL +luckperms.command.verbose.enabled-term=enabled +luckperms.command.verbose.disabled-term=disabled +luckperms.command.verbose.query-any=ANY +luckperms.command.info.running-plugin=Running +luckperms.command.info.platform-key=Platform +luckperms.command.info.server-brand-key=Server Brand +luckperms.command.info.server-version-key=Server Version +luckperms.command.info.storage-key=Storage +luckperms.command.info.storage-type-key=Type +luckperms.command.info.extensions-key=Extensions +luckperms.command.info.messaging-key=Messaging +luckperms.command.info.instance-key=Instance +luckperms.command.info.static-contexts-key=Static contexts +luckperms.command.info.online-players-key=Online Players +luckperms.command.info.online-players-unique={0} unique +luckperms.command.info.uptime-key=Uptime +luckperms.command.info.local-data-key=Local Data +luckperms.command.info.local-data={0} users, {1} groups, {2} tracks +luckperms.command.generic.create.success={0} was successfully created +luckperms.command.generic.create.error=There was an error whilst creating {0} +luckperms.command.generic.create.error-already-exists={0} already exists! +luckperms.command.generic.delete.success={0} was successfully deleted +luckperms.command.generic.delete.error=There was an error whilst deleting {0} +luckperms.command.generic.delete.error-doesnt-exist={0} does not exist! +luckperms.command.generic.rename.success={0} was successfully renamed to {1} +luckperms.command.generic.clone.success={0} was successfully cloned onto {1} +luckperms.command.generic.info.parent.title=Parent Groups +luckperms.command.generic.info.parent.temporary-title=Temporary Parent Groups +luckperms.command.generic.info.expires-in=expires in +luckperms.command.generic.info.inherited-from=inherited from +luckperms.command.generic.info.inherited-from-self=self +luckperms.command.generic.show-tracks.title={0}''s Tracks +luckperms.command.generic.show-tracks.empty={0} is not on any tracks +luckperms.command.generic.clear.node-removed={0} nodes were removed +luckperms.command.generic.clear.node-removed-singular={0} node was removed +luckperms.command.generic.clear={0}''s nodes were cleared in context {1} +luckperms.command.generic.permission.info.title={0}''s Permissions +luckperms.command.generic.permission.info.empty={0} does not have any permissions set +luckperms.command.generic.permission.info.click-to-remove=Click to remove this node from {0} +luckperms.command.generic.permission.check={0} has permission {1} set to {2} in context {3} +luckperms.command.generic.permission.check-inherits={0} has permission {1} set to {2} in context {3} +luckperms.command.generic.permission.set=Set {0} to {1} for {2} in context {3} +luckperms.command.generic.permission.already-has={0} already has {1} set in context {2} +luckperms.command.generic.permission.set-temp=Set {0} to {1} for {2} for a duration of {3} in context {4} +luckperms.command.generic.permission.already-has-temp={0} already has {1} set temporarily in context {2} +luckperms.command.generic.permission.unset=Unset {0} for {1} in context {2} +luckperms.command.generic.permission.doesnt-have={0} does not have {1} set in context {2} +luckperms.command.generic.permission.unset-temp=Unset temporary permission {0} for {1} in context {2} +luckperms.command.generic.permission.subtract=Set {0} to {1} for {2} for a duration of {3} in context {4}, {5} less than before +luckperms.command.generic.permission.doesnt-have-temp={0} does not have {1} set temporarily in context {2} +luckperms.command.generic.permission.clear={0}''s permissions were cleared in context {1} +luckperms.command.generic.parent.info.title={0}''s Parents +luckperms.command.generic.parent.info.empty={0} does not have any parents defined +luckperms.command.generic.parent.info.click-to-remove=Click to remove this parent from {0} +luckperms.command.generic.parent.add={0} now inherits permissions from {1} in context {2} +luckperms.command.generic.parent.add-temp={0} now inherits permissions from {1} for a duration of {2} in context {3} +luckperms.command.generic.parent.set={0} had their existing parent groups cleared, and now only inherits {1} in context {2} +luckperms.command.generic.parent.set-track={0} had their existing parent groups on track {1} cleared, and now only inherits {2} in context {3} +luckperms.command.generic.parent.remove={0} no longer inherits permissions from {1} in context {2} +luckperms.command.generic.parent.remove-temp={0} no longer temporarily inherits permissions from {1} in context {2} +luckperms.command.generic.parent.subtract={0} will inherit permissions from {1} for a duration of {2} in context {3}, {4} less than before +luckperms.command.generic.parent.clear={0}''s parents were cleared in context {1} +luckperms.command.generic.parent.clear-track={0}''s parents on track {1} were cleared in context {2} +luckperms.command.generic.parent.already-inherits={0} already inherits from {1} in context {2} +luckperms.command.generic.parent.doesnt-inherit={0} does not inherit from {1} in context {2} +luckperms.command.generic.parent.already-temp-inherits={0} already temporarily inherits from {1} in context {2} +luckperms.command.generic.parent.doesnt-temp-inherit={0} does not temporarily inherit from {1} in context {2} +luckperms.command.generic.chat-meta.info.title-prefix={0}''s Prefixes +luckperms.command.generic.chat-meta.info.title-suffix={0}''s Suffixes +luckperms.command.generic.chat-meta.info.none-prefix={0} has no prefixes +luckperms.command.generic.chat-meta.info.none-suffix={0} has no suffixes +luckperms.command.generic.chat-meta.info.click-to-remove=Click to remove this {0} from {1} +luckperms.command.generic.chat-meta.already-has={0} already has {1} {2} set at a priority of {3} in context {4} +luckperms.command.generic.chat-meta.already-has-temp={0} already has {1} {2} set temporarily at a priority of {3} in context {4} +luckperms.command.generic.chat-meta.doesnt-have={0} doesn''t have {1} {2} set at a priority of {3} in context {4} +luckperms.command.generic.chat-meta.doesnt-have-temp={0} doesn''t have {1} {2} set temporarily at a priority of {3} in context {4} +luckperms.command.generic.chat-meta.add={0} had {1} {2} set at a priority of {3} in context {4} +luckperms.command.generic.chat-meta.add-temp={0} had {1} {2} set at a priority of {3} for a duration of {4} in context {5} +luckperms.command.generic.chat-meta.remove={0} had {1} {2} at priority {3} removed in context {4} +luckperms.command.generic.chat-meta.remove-bulk={0} had all {1} at priority {2} removed in context {3} +luckperms.command.generic.chat-meta.remove-temp={0} had temporary {1} {2} at priority {3} removed in context {4} +luckperms.command.generic.chat-meta.remove-temp-bulk={0} had all temporary {1} at priority {2} removed in context {3} +luckperms.command.generic.meta.info.title={0}''s Meta +luckperms.command.generic.meta.info.none={0} has no meta +luckperms.command.generic.meta.info.click-to-remove=Click to remove this meta node from {0} +luckperms.command.generic.meta.already-has={0} already has meta key {1} set to {2} in context {3} +luckperms.command.generic.meta.already-has-temp={0} already has meta key {1} temporarily set to {2} in context {3} +luckperms.command.generic.meta.doesnt-have={0} doesn''t have meta key {1} set in context {2} +luckperms.command.generic.meta.doesnt-have-temp={0} doesn''t have meta key {1} set temporarily in context {2} +luckperms.command.generic.meta.set=Set meta key {0} to {1} for {2} in context {3} +luckperms.command.generic.meta.set-temp=Set meta key {0} to {1} for {2} for a duration of {3} in context {4} +luckperms.command.generic.meta.unset=Unset meta key {0} for {1} in context {2} +luckperms.command.generic.meta.unset-temp=Unset temporary meta key {0} for {1} in context {2} +luckperms.command.generic.meta.clear={0}''s meta matching type {1} was cleared in context {2} +luckperms.command.generic.contextual-data.title=Contextual Data +luckperms.command.generic.contextual-data.mode.key=mode +luckperms.command.generic.contextual-data.mode.server=server +luckperms.command.generic.contextual-data.mode.active-player=active player +luckperms.command.generic.contextual-data.contexts-key=Contexts +luckperms.command.generic.contextual-data.prefix-key=Prefix +luckperms.command.generic.contextual-data.suffix-key=Suffix +luckperms.command.generic.contextual-data.primary-group-key=Primary Group +luckperms.command.generic.contextual-data.meta-key=Meta +luckperms.command.generic.contextual-data.null-result=None +luckperms.command.user.info.title=User Info +luckperms.command.user.info.uuid-key=UUID +luckperms.command.user.info.uuid-type-key=type +luckperms.command.user.info.uuid-type.mojang=mojang +luckperms.command.user.info.uuid-type.not-mojang=offline +luckperms.command.user.info.status-key=Status +luckperms.command.user.info.status.online=Online +luckperms.command.user.info.status.offline=Offline +luckperms.command.user.removegroup.error-primary=You cannot remove a user from their primary group +luckperms.command.user.primarygroup.not-member={0} was not already a member of {1}, adding them now +luckperms.command.user.primarygroup.already-has={0} already has {1} set as their primary group +luckperms.command.user.primarygroup.warn-option=Warning: The primary group calculation method being used by this server ({0}) may not reflect this change +luckperms.command.user.primarygroup.set={0}''s primary group was set to {1} +luckperms.command.user.track.error-not-contain-group={0} isn''t already in any groups on {1} +luckperms.command.user.track.unsure-which-track=Unsure which track to use, please specify it as an argument +luckperms.command.user.track.missing-group-advice=Either create the group, or remove it from the track and try again +luckperms.command.user.promote.added-to-first={0} isn''t in any groups on {1}, so they were added to the first group, {2} in context {3} +luckperms.command.user.promote.not-on-track={0} isn''t in any groups on {1}, so was not promoted +luckperms.command.user.promote.success=Promoting {0} along track {1} from {2} to {3} in context {4} +luckperms.command.user.promote.end-of-track=The end of track {0} was reached, unable to promote {1} +luckperms.command.user.promote.next-group-deleted=The next group on the track, {0}, no longer exists +luckperms.command.user.promote.unable-to-promote=Unable to promote user +luckperms.command.user.demote.success=Demoting {0} along track {1} from {2} to {3} in context {4} +luckperms.command.user.demote.end-of-track=The end of track {0} was reached, so {1} was removed from {2} +luckperms.command.user.demote.end-of-track-not-removed=The end of track {0} was reached, but {1} was not removed from the first group +luckperms.command.user.demote.previous-group-deleted=The previous group on the track, {0}, no longer exists +luckperms.command.user.demote.unable-to-demote=Unable to demote user +luckperms.command.group.list.title=Groups +luckperms.command.group.delete.not-default=You cannot delete the default group +luckperms.command.group.info.title=Group Info +luckperms.command.group.info.display-name-key=Display Name +luckperms.command.group.info.weight-key=Weight +luckperms.command.group.setweight.set=Set weight to {0} for group {1} +luckperms.command.group.setdisplayname.doesnt-have={0} doesn''t have a display name set +luckperms.command.group.setdisplayname.already-has={0} already has a display name of {1} +luckperms.command.group.setdisplayname.already-in-use=The display name {0} is already being used by {1} +luckperms.command.group.setdisplayname.set=Set display name to {0} for group {1} in context {2} +luckperms.command.group.setdisplayname.removed=Removed display name for group {0} in context {1} +luckperms.command.track.list.title=Tracks +luckperms.command.track.path.empty=None +luckperms.command.track.info.showing-track=Showing Track +luckperms.command.track.info.path-property=Path +luckperms.command.track.clear={0}''s groups track was cleared +luckperms.command.track.append.success=Group {0} was appended to track {1}. +luckperms.command.track.insert.success=Group {0} was inserted into track {1} at position {2} +luckperms.command.track.insert.error-number=Expected number but instead received: {0} +luckperms.command.track.insert.error-invalid-pos=Unable to insert at position {0} +luckperms.command.track.insert.error-invalid-pos-reason=invalid position +luckperms.command.track.remove.success=Group {0} was removed from track {1} +luckperms.command.track.error-empty={0} cannot be used as it is empty or contains only one group +luckperms.command.track.error-multiple-groups={0} is a member of multiple groups on this track +luckperms.command.track.error-ambiguous=Unable to determine their location +luckperms.command.track.already-contains={0} already contains {1} +luckperms.command.track.doesnt-contain={0} doesn''t contain {1} +luckperms.command.log.load-error=The log could not be loaded +luckperms.command.log.invalid-page=Invalid page number +luckperms.command.log.invalid-page-range=Please enter a value between {0} and {1} +luckperms.command.log.empty=No log entries to show +luckperms.command.log.notify.error-console=Cannot toggle notifications for console +luckperms.command.log.notify.enabled-term=Enabled +luckperms.command.log.notify.disabled-term=Disabled +luckperms.command.log.notify.changed-state={0} logging output +luckperms.command.log.notify.already-on=You are already receiving notifications +luckperms.command.log.notify.already-off=You aren''t currently receiving notifications +luckperms.command.log.notify.invalid-state=State unknown. Expecting {0} or {1} +luckperms.command.log.show.search=Showing recent actions for query {0} +luckperms.command.log.show.recent=Showing recent actions +luckperms.command.log.show.by=Showing recent actions by {0} +luckperms.command.log.show.history=Showing history for {0} {1} +luckperms.command.export.error-term=Error +luckperms.command.export.already-running=Another export process is already running +luckperms.command.export.file.already-exists=File {0} already exists +luckperms.command.export.file.not-writable=File {0} is not writable +luckperms.command.export.file.success=Successfully exported to {0} +luckperms.command.export.file-unexpected-error-writing=An unexpected error occurred whilst writing to the file +luckperms.command.export.web.export-code=Export code +luckperms.command.export.web.import-command-description=Use the following command to import +luckperms.command.import.term=Import +luckperms.command.import.error-term=Error +luckperms.command.import.already-running=Another import process is already running +luckperms.command.import.file.doesnt-exist=File {0} does not exist +luckperms.command.import.file.not-readable=File {0} is not readable +luckperms.command.import.file.unexpected-error-reading=An unexpected error occurred whilst reading from the import file +luckperms.command.import.file.correct-format=is it the correct format? +luckperms.command.import.web.unable-to-read=Unable to read data using the given code +luckperms.command.import.progress.percent={0}% complete +luckperms.command.import.progress.operations={0}/{1} operations complete +luckperms.command.import.starting=Starting import process +luckperms.command.import.completed=COMPLETED +luckperms.command.import.duration=took {0} seconds +luckperms.command.bulkupdate.must-use-console=The bulk update command can only be used from the console +luckperms.command.bulkupdate.invalid-data-type=Invalid type, was expecting {0} +luckperms.command.bulkupdate.invalid-constraint=Invalid constraint {0} +luckperms.command.bulkupdate.invalid-constraint-format=Constraints should be in the format {0} +luckperms.command.bulkupdate.invalid-comparison=Invalid comparison operator {0} +luckperms.command.bulkupdate.invalid-comparison-format=Expected one of the following: {0} +luckperms.command.bulkupdate.queued=Bulk update operation was queued +luckperms.command.bulkupdate.confirm=Run {0} to execute the update +luckperms.command.bulkupdate.unknown-id=Operation with id {0} does not exist or has expired +luckperms.command.bulkupdate.starting=Running bulk update +luckperms.command.bulkupdate.success=Bulk update completed successfully +luckperms.command.bulkupdate.failure=Bulk update failed, check the console for errors +luckperms.command.update-task.request=An update task has been requested, please wait +luckperms.command.update-task.complete=Update task complete +luckperms.command.update-task.push.attempting=Now attempting to push to other servers +luckperms.command.update-task.push.complete=Other servers were notified via {0} successfully +luckperms.command.update-task.push.error=Error whilst pushing changes to other servers +luckperms.command.update-task.push.error-not-setup=Cannot push changes to other servers as a messaging service has not been configured +luckperms.command.reload-config.success=The configuration file was reloaded +luckperms.command.reload-config.restart-note=some options will only apply after the server has restarted +luckperms.usage.user.description=A set of commands for managing users within LuckPerms. (A ''user'' in LuckPerms is just a player, and can refer to a UUID or username) +luckperms.usage.group.description=A set of commands for managing groups within LuckPerms. Groups are just collections of permission assignments that can be given to users. New groups are made using the ''creategroup'' command. +luckperms.usage.track.description=A set of commands for managing tracks within LuckPerms. Tracks are a ordered collection of groups which can be used for defining promotions and demotions. +luckperms.usage.log.description=A set of commands for managing the logging functionality within LuckPerms. +luckperms.usage.sync.description=Reloads all data from the plugins storage into memory, and applies any changes that are detected. +luckperms.usage.info.description=Prints general information about the active plugin instance. +luckperms.usage.editor.description=Creates a new web editor session +luckperms.usage.editor.argument.type=the types to load into the editor. (''all'', ''users'' or ''groups'') +luckperms.usage.editor.argument.filter=permission to filter user entries by +luckperms.usage.debug.description=Produces a set of internal debugging output +luckperms.usage.verbose.description=Controls the plugins verbose permission check monitoring system. +luckperms.usage.verbose.argument.action=whether to enable/disable logging, or to upload the logged output +luckperms.usage.verbose.argument.filter=the filter to match entries against +luckperms.usage.verbose.argument.commandas=the player/command to run +luckperms.usage.tree.description=Generates a tree view (ordered list hierarchy) of all permissions known to LuckPerms. +luckperms.usage.tree.argument.scope=the root of the tree. specify "." to include all permissions +luckperms.usage.tree.argument.player=the name of an online player to check against +luckperms.usage.search.description=Searchs for all of the users/groups with a specific permission +luckperms.usage.search.argument.permission=the permission to search for +luckperms.usage.search.argument.page=the page to view +luckperms.usage.check.description=Performs a ''mock'' permission check for an online player +luckperms.usage.check.argument.user=the user to check +luckperms.usage.check.argument.permission=the permission to check for +luckperms.usage.network-sync.description=Sync changes with the storage and request that all other servers on the network do the same +luckperms.usage.import.description=Imports data from a (previously created) export file +luckperms.usage.import.argument.file=the file to import from +luckperms.usage.import.argument.replace=replace existing data instead of merging +luckperms.usage.export.description=Exports all permissions data to an ''export'' file. Can be re-imported at a later time. +luckperms.usage.export.argument.file=the file to export to +luckperms.usage.export.argument.without-users=exclude users from the export +luckperms.usage.reload-config.description=Reload some of the config options +luckperms.usage.bulk-update.description=Execute bulk change queries on all data +luckperms.usage.bulk-update.argument.data-type=the type of data being changed. (''all'', ''users'' or ''groups'') +luckperms.usage.bulk-update.argument.action=the action to perform on the data. (''update'' or ''delete'') +luckperms.usage.bulk-update.argument.action-field=the field to act upon. only required for ''update''. (''permission'', ''server'' or ''world'') +luckperms.usage.bulk-update.argument.action-value=the value to replace with. only required for ''update''. +luckperms.usage.bulk-update.argument.constraint=the constraints required for the update +luckperms.usage.migration.description=Migration commands +luckperms.usage.apply-edits.description=Applies permission changes made from the web editor +luckperms.usage.apply-edits.argument.code=the unique code for the data +luckperms.usage.apply-edits.argument.target=who to apply the data to +luckperms.usage.create-group.description=Create a new group +luckperms.usage.create-group.argument.name=the name of the group +luckperms.usage.delete-group.description=Delete a group +luckperms.usage.delete-group.argument.name=the name of the group +luckperms.usage.list-groups.description=List all groups on the platform +luckperms.usage.create-track.description=Create a new track +luckperms.usage.create-track.argument.name=the name of the track +luckperms.usage.delete-track.description=Delete a track +luckperms.usage.delete-track.argument.name=the name of the track +luckperms.usage.list-tracks.description=List all tracks on the platform +luckperms.usage.user-info.description=Shows info about the user +luckperms.usage.user-switchprimarygroup.description=Switches the user''s primary group +luckperms.usage.user-switchprimarygroup.argument.group=the group to switch to +luckperms.usage.user-promote.description=Promotes the user up a track +luckperms.usage.user-promote.argument.track=the track to promote the user up +luckperms.usage.user-promote.argument.context=the contexts to promote the user in +luckperms.usage.user-promote.argument.dont-add-to-first=only promote the user if they''re already on the track +luckperms.usage.user-demote.description=Demotes the user down a track +luckperms.usage.user-demote.argument.track=the track to demote the user down +luckperms.usage.user-demote.argument.context=the contexts to demote the user in +luckperms.usage.user-demote.argument.dont-remove-from-first=prevent the user from being removed from the first group +luckperms.usage.user-clone.description=Clone the user +luckperms.usage.user-clone.argument.user=the name/uuid of the user to clone onto +luckperms.usage.group-info.description=Gives info about the group +luckperms.usage.group-listmembers.description=Show the users/groups who inherit from this group +luckperms.usage.group-listmembers.argument.page=the page to view +luckperms.usage.group-setweight.description=Set the groups weight +luckperms.usage.group-setweight.argument.weight=the weight to set +luckperms.usage.group-set-display-name.description=Set the groups display name +luckperms.usage.group-set-display-name.argument.name=the name to set +luckperms.usage.group-set-display-name.argument.context=the contexts to set the name in +luckperms.usage.group-rename.description=Rename the group +luckperms.usage.group-rename.argument.name=the new name +luckperms.usage.group-clone.description=Clone the group +luckperms.usage.group-clone.argument.name=the name of the group to clone onto +luckperms.usage.holder-editor.description=Opens the web permission editor +luckperms.usage.holder-showtracks.description=Lists the tracks that the object is on +luckperms.usage.holder-clear.description=Removes all permissions, parents and meta +luckperms.usage.holder-clear.argument.context=the contexts to filter by +luckperms.usage.permission.description=Edit permissions +luckperms.usage.parent.description=Edit inheritances +luckperms.usage.meta.description=Edit metadata values +luckperms.usage.permission-info.description=Lists the permission nodes the object has +luckperms.usage.permission-info.argument.page=the page to view +luckperms.usage.permission-info.argument.sort-mode=how to sort the entries +luckperms.usage.permission-set.description=Sets a permission for the object +luckperms.usage.permission-set.argument.node=the permission node to set +luckperms.usage.permission-set.argument.value=the value of the node +luckperms.usage.permission-set.argument.context=the contexts to add the permission in +luckperms.usage.permission-unset.description=Unsets a permission for the object +luckperms.usage.permission-unset.argument.node=the permission node to unset +luckperms.usage.permission-unset.argument.context=the contexts to remove the permission in +luckperms.usage.permission-settemp.description=Sets a permission for the object temporarily +luckperms.usage.permission-settemp.argument.node=the permission node to set +luckperms.usage.permission-settemp.argument.value=the value of the node +luckperms.usage.permission-settemp.argument.duration=the duration until the permission node expires +luckperms.usage.permission-settemp.argument.temporary-modifier=how the temporary permission should be applied +luckperms.usage.permission-settemp.argument.context=the contexts to add the permission in +luckperms.usage.permission-unsettemp.description=Unsets a temporary permission for the object +luckperms.usage.permission-unsettemp.argument.node=the permission node to unset +luckperms.usage.permission-unsettemp.argument.duration=the duration to subtract +luckperms.usage.permission-unsettemp.argument.context=the contexts to remove the permission in +luckperms.usage.permission-check.description=Checks to see if the object has a certain permission node +luckperms.usage.permission-check.argument.node=the permission node to check for +luckperms.usage.permission-check.argument.context=the contexts to check in +luckperms.usage.permission-check-inherits.description=Checks to see if the object inherits a certain permission node +luckperms.usage.permission-check-inherits.argument.node=the permission node to check for +luckperms.usage.permission-check-inherits.argument.context=the contexts to check in +luckperms.usage.permission-clear.description=Clears all permissions +luckperms.usage.permission-clear.argument.context=the contexts to filter by +luckperms.usage.parent-info.description=Lists the groups that this object inherits from +luckperms.usage.parent-info.argument.page=the page to view +luckperms.usage.parent-info.argument.sort-mode=how to sort the entries +luckperms.usage.parent-set.description=Removes all other groups the object inherits already and adds them to the one given +luckperms.usage.parent-set.argument.group=the group to set to +luckperms.usage.parent-set.argument.context=the contexts to set the group in +luckperms.usage.parent-add.description=Sets another group for the object to inherit permissions from +luckperms.usage.parent-add.argument.group=the group to inherit from +luckperms.usage.parent-add.argument.context=the contexts to inherit the group in +luckperms.usage.parent-remove.description=Removes a previously set inheritance rule +luckperms.usage.parent-remove.argument.group=the group to remove +luckperms.usage.parent-remove.argument.context=the contexts to remove the group in +luckperms.usage.parent-set-track.description=Removes all other groups the object inherits from already on the given track and adds them to the one given +luckperms.usage.parent-set-track.argument.track=the track to set on +luckperms.usage.parent-set-track.argument.group=the group to set to, or a number relating to the position of the group on the given track +luckperms.usage.parent-set-track.argument.context=the contexts to set the group in +luckperms.usage.parent-add-temp.description=Sets another group for the object to inherit permissions from temporarily +luckperms.usage.parent-add-temp.argument.group=the group to inherit from +luckperms.usage.parent-add-temp.argument.duration=the duration of the group membership +luckperms.usage.parent-add-temp.argument.temporary-modifier=how the temporary permission should be applied +luckperms.usage.parent-add-temp.argument.context=the contexts to inherit the group in +luckperms.usage.parent-remove-temp.description=Removes a previously set temporary inheritance rule +luckperms.usage.parent-remove-temp.argument.group=the group to remove +luckperms.usage.parent-remove-temp.argument.duration=the duration to subtract +luckperms.usage.parent-remove-temp.argument.context=the contexts to remove the group in +luckperms.usage.parent-clear.description=Clears all parents +luckperms.usage.parent-clear.argument.context=the contexts to filter by +luckperms.usage.parent-clear-track.description=Clears all parents on a given track +luckperms.usage.parent-clear-track.argument.track=the track to remove on +luckperms.usage.parent-clear-track.argument.context=the contexts to filter by +luckperms.usage.meta-info.description=Shows all chat meta +luckperms.usage.meta-set.description=Sets a meta value +luckperms.usage.meta-set.argument.key=the key to set +luckperms.usage.meta-set.argument.value=the value to set +luckperms.usage.meta-set.argument.context=the contexts to add the meta pair in +luckperms.usage.meta-unset.description=Unsets a meta value +luckperms.usage.meta-unset.argument.key=the key to unset +luckperms.usage.meta-unset.argument.context=the contexts to remove the meta pair in +luckperms.usage.meta-settemp.description=Sets a meta value temporarily +luckperms.usage.meta-settemp.argument.key=the key to set +luckperms.usage.meta-settemp.argument.value=the value to set +luckperms.usage.meta-settemp.argument.duration=the duration until the meta value expires +luckperms.usage.meta-settemp.argument.context=the contexts to add the meta pair in +luckperms.usage.meta-unsettemp.description=Unsets a temporary meta value +luckperms.usage.meta-unsettemp.argument.key=the key to unset +luckperms.usage.meta-unsettemp.argument.context=the contexts to remove the meta pair in +luckperms.usage.meta-addprefix.description=Adds a prefix +luckperms.usage.meta-addprefix.argument.priority=the priority to add the prefix at +luckperms.usage.meta-addprefix.argument.prefix=the prefix string +luckperms.usage.meta-addprefix.argument.context=the contexts to add the prefix in +luckperms.usage.meta-addsuffix.description=Adds a suffix +luckperms.usage.meta-addsuffix.argument.priority=the priority to add the suffix at +luckperms.usage.meta-addsuffix.argument.suffix=the suffix string +luckperms.usage.meta-addsuffix.argument.context=the contexts to add the suffix in +luckperms.usage.meta-setprefix.description=Sets a prefix +luckperms.usage.meta-setprefix.argument.priority=the priority to set the prefix at +luckperms.usage.meta-setprefix.argument.prefix=the prefix string +luckperms.usage.meta-setprefix.argument.context=the contexts to set the prefix in +luckperms.usage.meta-setsuffix.description=Sets a suffix +luckperms.usage.meta-setsuffix.argument.priority=the priority to set the suffix at +luckperms.usage.meta-setsuffix.argument.suffix=the suffix string +luckperms.usage.meta-setsuffix.argument.context=the contexts to set the suffix in +luckperms.usage.meta-removeprefix.description=Removes a prefix +luckperms.usage.meta-removeprefix.argument.priority=the priority to remove the prefix at +luckperms.usage.meta-removeprefix.argument.prefix=the prefix string +luckperms.usage.meta-removeprefix.argument.context=the contexts to remove the prefix in +luckperms.usage.meta-removesuffix.description=Removes a suffix +luckperms.usage.meta-removesuffix.argument.priority=the priority to remove the suffix at +luckperms.usage.meta-removesuffix.argument.suffix=the suffix string +luckperms.usage.meta-removesuffix.argument.context=the contexts to remove the suffix in +luckperms.usage.meta-addtemp-prefix.description=Adds a prefix temporarily +luckperms.usage.meta-addtemp-prefix.argument.priority=the priority to add the prefix at +luckperms.usage.meta-addtemp-prefix.argument.prefix=the prefix string +luckperms.usage.meta-addtemp-prefix.argument.duration=the duration until the prefix expires +luckperms.usage.meta-addtemp-prefix.argument.context=the contexts to add the prefix in +luckperms.usage.meta-addtemp-suffix.description=Adds a suffix temporarily +luckperms.usage.meta-addtemp-suffix.argument.priority=the priority to add the suffix at +luckperms.usage.meta-addtemp-suffix.argument.suffix=the suffix string +luckperms.usage.meta-addtemp-suffix.argument.duration=the duration until the suffix expires +luckperms.usage.meta-addtemp-suffix.argument.context=the contexts to add the suffix in +luckperms.usage.meta-settemp-prefix.description=Sets a prefix temporarily +luckperms.usage.meta-settemp-prefix.argument.priority=the priority to set the prefix at +luckperms.usage.meta-settemp-prefix.argument.prefix=the prefix string +luckperms.usage.meta-settemp-prefix.argument.duration=the duration until the prefix expires +luckperms.usage.meta-settemp-prefix.argument.context=the contexts to set the prefix in +luckperms.usage.meta-settemp-suffix.description=Sets a suffix temporarily +luckperms.usage.meta-settemp-suffix.argument.priority=the priority to set the suffix at +luckperms.usage.meta-settemp-suffix.argument.suffix=the suffix string +luckperms.usage.meta-settemp-suffix.argument.duration=the duration until the suffix expires +luckperms.usage.meta-settemp-suffix.argument.context=the contexts to set the suffix in +luckperms.usage.meta-removetemp-prefix.description=Removes a temporary prefix +luckperms.usage.meta-removetemp-prefix.argument.priority=the priority to remove the prefix at +luckperms.usage.meta-removetemp-prefix.argument.prefix=the prefix string +luckperms.usage.meta-removetemp-prefix.argument.context=the contexts to remove the prefix in +luckperms.usage.meta-removetemp-suffix.description=Removes a temporary suffix +luckperms.usage.meta-removetemp-suffix.argument.priority=the priority to remove the suffix at +luckperms.usage.meta-removetemp-suffix.argument.suffix=the suffix string +luckperms.usage.meta-removetemp-suffix.argument.context=the contexts to remove the suffix in +luckperms.usage.meta-clear.description=Clears all meta +luckperms.usage.meta-clear.argument.type=the type of meta to remove +luckperms.usage.meta-clear.argument.context=the contexts to filter by +luckperms.usage.track-info.description=Gives info about the track +luckperms.usage.track-append.description=Appends a group onto the end of the track +luckperms.usage.track-append.argument.group=the group to append +luckperms.usage.track-insert.description=Inserts a group at a given position along the track +luckperms.usage.track-insert.argument.group=the group to insert +luckperms.usage.track-insert.argument.position=the position to insert the group at (the first position on the track is 1) +luckperms.usage.track-remove.description=Removes a group from the track +luckperms.usage.track-remove.argument.group=the group to remove +luckperms.usage.track-clear.description=Clears the groups on the track +luckperms.usage.track-rename.description=Rename the track +luckperms.usage.track-rename.argument.name=the new name +luckperms.usage.track-clone.description=Clone the track +luckperms.usage.track-clone.argument.name=the name of the track to clone onto +luckperms.usage.log-recent.description=View recent actions +luckperms.usage.log-recent.argument.user=the name/uuid of the user to filter by +luckperms.usage.log-recent.argument.page=the page number to view +luckperms.usage.log-search.description=Search the log for an entry +luckperms.usage.log-search.argument.query=the query to search by +luckperms.usage.log-search.argument.page=the page number to view +luckperms.usage.log-notify.description=Toggle log notifications +luckperms.usage.log-notify.argument.toggle=whether to toggle on or off +luckperms.usage.log-user-history.description=View a user''s history +luckperms.usage.log-user-history.argument.user=the name/uuid of the user +luckperms.usage.log-user-history.argument.page=the page number to view +luckperms.usage.log-group-history.description=View an group''s history +luckperms.usage.log-group-history.argument.group=the name of the group +luckperms.usage.log-group-history.argument.page=the page number to view +luckperms.usage.log-track-history.description=View a track''s history +luckperms.usage.log-track-history.argument.track=the name of the track +luckperms.usage.log-track-history.argument.page=the page number to view +luckperms.usage.sponge.description=Edit extra Sponge data +luckperms.usage.sponge.argument.collection=the collection to query +luckperms.usage.sponge.argument.subject=the subject to modify +luckperms.usage.sponge-permission-info.description=Shows info about the subject''s permissions +luckperms.usage.sponge-permission-info.argument.contexts=the contexts to filter by +luckperms.usage.sponge-permission-set.description=Sets a permission for the Subject +luckperms.usage.sponge-permission-set.argument.node=the permission node to set +luckperms.usage.sponge-permission-set.argument.tristate=the value to set the permission to +luckperms.usage.sponge-permission-set.argument.contexts=the contexts to set the permission in +luckperms.usage.sponge-permission-clear.description=Clears the Subjects permissions +luckperms.usage.sponge-permission-clear.argument.contexts=the contexts to clear permissions in +luckperms.usage.sponge-parent-info.description=Shows info about the subject''s parents +luckperms.usage.sponge-parent-info.argument.contexts=the contexts to filter by +luckperms.usage.sponge-parent-add.description=Adds a parent to the Subject +luckperms.usage.sponge-parent-add.argument.collection=the subject collection where the parent Subject is +luckperms.usage.sponge-parent-add.argument.subject=the name of the parent Subject +luckperms.usage.sponge-parent-add.argument.contexts=the contexts to add the parent in +luckperms.usage.sponge-parent-remove.description=Removes a parent from the Subject +luckperms.usage.sponge-parent-remove.argument.collection=the subject collection where the parent Subject is +luckperms.usage.sponge-parent-remove.argument.subject=the name of the parent Subject +luckperms.usage.sponge-parent-remove.argument.contexts=the contexts to remove the parent in +luckperms.usage.sponge-parent-clear.description=Clears the Subjects parents +luckperms.usage.sponge-parent-clear.argument.contexts=the contexts to clear parents in +luckperms.usage.sponge-option-info.description=Shows info about the subject''s options +luckperms.usage.sponge-option-info.argument.contexts=the contexts to filter by +luckperms.usage.sponge-option-set.description=Sets an option for the Subject +luckperms.usage.sponge-option-set.argument.key=the key to set +luckperms.usage.sponge-option-set.argument.value=the value to set the key to +luckperms.usage.sponge-option-set.argument.contexts=the contexts to set the option in +luckperms.usage.sponge-option-unset.description=Unsets an option for the Subject +luckperms.usage.sponge-option-unset.argument.key=the key to unset +luckperms.usage.sponge-option-unset.argument.contexts=the contexts to unset the key in +luckperms.usage.sponge-option-clear.description=Clears the Subjects options +luckperms.usage.sponge-option-clear.argument.contexts=the contexts to clear options in +luckperms.usage.migration-command.description=Migration command +luckperms.usage.migration-groupmanager.description=Migration command +luckperms.usage.migration-groupmanager.argument.migrate-as-global=if world permissions should be ignored, and just migrated as global +luckperms.usage.migration-powerfulperms.description=Migration command +luckperms.usage.migration-powerfulperms.argument.address=the address of the PP database +luckperms.usage.migration-powerfulperms.argument.database=the name of the PP database +luckperms.usage.migration-powerfulperms.argument.username=the username to log into the DB +luckperms.usage.migration-powerfulperms.argument.password=the password to log into the DB +luckperms.usage.migration-powerfulperms.argument.db-table=the name of the PP table where player data is stored diff --git a/nukkit/build.gradle b/nukkit/build.gradle index f95cff210..24de20678 100644 --- a/nukkit/build.gradle +++ b/nukkit/build.gradle @@ -28,7 +28,7 @@ shadowJar { include(dependency('me.lucko.luckperms:.*')) } - relocate 'net.kyori.text', 'me.lucko.luckperms.lib.text' + relocate 'net.kyori.adventure', 'me.lucko.luckperms.lib.adventure' relocate 'net.kyori.event', 'me.lucko.luckperms.lib.eventbus' relocate 'com.github.benmanes.caffeine', 'me.lucko.luckperms.lib.caffeine' relocate 'okio', 'me.lucko.luckperms.lib.okio' diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSenderFactory.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSenderFactory.java index 746f159a4..f9fe2ae49 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSenderFactory.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSenderFactory.java @@ -25,17 +25,19 @@ package me.lucko.luckperms.nukkit; +import me.lucko.luckperms.common.locale.TranslationManager; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.sender.SenderFactory; -import me.lucko.luckperms.common.util.TextUtils; -import net.kyori.text.Component; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import net.kyori.adventure.translation.GlobalTranslator; import net.luckperms.api.util.Tristate; import cn.nukkit.Player; import cn.nukkit.command.CommandSender; -import cn.nukkit.command.ConsoleCommandSender; +import java.util.Locale; import java.util.UUID; public class NukkitSenderFactory extends SenderFactory { @@ -59,22 +61,15 @@ public class NukkitSenderFactory extends SenderFactory getGlobalDependencies() { Set dependencies = super.getGlobalDependencies(); - dependencies.add(Dependency.TEXT_ADAPTER_SPONGEAPI); + dependencies.add(Dependency.ADVENTURE_PLATFORM); + dependencies.add(Dependency.ADVENTURE_PLATFORM_SPONGEAPI); dependencies.add(Dependency.CONFIGURATE_CORE); dependencies.add(Dependency.CONFIGURATE_HOCON); dependencies.add(Dependency.HOCON_CONFIG); @@ -271,8 +274,8 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin { } else { return new DummySender(this, Sender.CONSOLE_UUID, Sender.CONSOLE_NAME) { @Override - protected void consumeMessage(String s) { - LPSpongePlugin.this.bootstrap.getPluginLogger().info(s); + public void sendMessage(Component message) { + LPSpongePlugin.this.bootstrap.getPluginLogger().info(LegacyComponentSerializer.legacySection().serialize(message)); } }; } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java index e491cdf8d..7204313b0 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java @@ -29,19 +29,21 @@ import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.sender.SenderFactory; import me.lucko.luckperms.sponge.service.CompatibilityUtil; -import net.kyori.text.Component; -import net.kyori.text.adapter.spongeapi.TextAdapter; +import net.kyori.adventure.platform.spongeapi.SpongeAudiences; +import net.kyori.adventure.text.Component; import net.luckperms.api.util.Tristate; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.entity.living.player.Player; -import org.spongepowered.api.text.serializer.TextSerializers; import java.util.UUID; public class SpongeSenderFactory extends SenderFactory { + private final SpongeAudiences audiences; + public SpongeSenderFactory(LPSpongePlugin plugin) { super(plugin); + this.audiences = SpongeAudiences.create(plugin.getBootstrap().getPluginContainer(), plugin.getBootstrap().getGame()); } @Override @@ -60,15 +62,9 @@ public class SpongeSenderFactory extends SenderFactory { - public OptionClear(LocaleManager locale) { - super(CommandSpec.SPONGE_OPTION_CLEAR.localize(locale), "clear", CommandPermission.SPONGE_OPTION_CLEAR, Predicates.alwaysFalse()); + public OptionClear() { + super(CommandSpec.SPONGE_OPTION_CLEAR, "clear", CommandPermission.SPONGE_OPTION_CLEAR, Predicates.alwaysFalse()); } @Override @@ -49,10 +47,10 @@ public class OptionClear extends ChildCommand { ImmutableContextSet contextSet = args.getContextOrEmpty(0); if (contextSet.isEmpty()) { subjectData.clearOptions(); - Message.BLANK.send(sender, "&aCleared options matching contexts &bANY&a."); + SpongeCommandUtils.sendPrefixed(sender, "&aCleared options matching contexts &bANY&a."); } else { subjectData.clearOptions(contextSet); - Message.BLANK.send(sender, "&aCleared options matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager())); + SpongeCommandUtils.sendPrefixed(sender, "&aCleared options matching contexts &b" + SpongeCommandUtils.contextToString(contextSet)); } return CommandResult.SUCCESS; } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionInfo.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionInfo.java index 4f49130cc..8bee6564e 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionInfo.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionInfo.java @@ -30,10 +30,8 @@ import com.google.common.collect.ImmutableMap; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -44,34 +42,34 @@ import net.luckperms.api.context.ImmutableContextSet; import java.util.Map; public class OptionInfo extends ChildCommand { - public OptionInfo(LocaleManager locale) { - super(CommandSpec.SPONGE_OPTION_INFO.localize(locale), "info", CommandPermission.SPONGE_OPTION_INFO, Predicates.alwaysFalse()); + public OptionInfo() { + super(CommandSpec.SPONGE_OPTION_INFO, "info", CommandPermission.SPONGE_OPTION_INFO, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, ArgumentList args, String label) { ImmutableContextSet contextSet = args.getContextOrEmpty(0); if (contextSet.isEmpty()) { - Message.BLANK.send(sender, "&aShowing options matching contexts &bANY&a."); + SpongeCommandUtils.sendPrefixed(sender, "&aShowing options matching contexts &bANY&a."); Map> options = subjectData.getAllOptions(); if (options.isEmpty()) { - Message.BLANK.send(sender, "That subject does not have any options defined."); + SpongeCommandUtils.sendPrefixed(sender, "That subject does not have any options defined."); return CommandResult.SUCCESS; } for (Map.Entry> e : options.entrySet()) { - Message.BLANK.send(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.optionsToString(e.getValue())); + SpongeCommandUtils.sendPrefixed(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.optionsToString(e.getValue())); } } else { Map options = subjectData.getOptions(contextSet); if (options.isEmpty()) { - Message.BLANK.send(sender, "That subject does not have any options defined in those contexts."); + SpongeCommandUtils.sendPrefixed(sender, "That subject does not have any options defined in those contexts."); return CommandResult.SUCCESS; } - Message.BLANK.send(sender, "&aShowing options matching contexts &b" + - SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.optionsToString(options)); + SpongeCommandUtils.sendPrefixed(sender, "&aShowing options matching contexts &b" + + SpongeCommandUtils.contextToString(contextSet) + "&a.\n" + SpongeCommandUtils.optionsToString(options)); } return CommandResult.SUCCESS; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionSet.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionSet.java index 2d540986d..2b97888a7 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionSet.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionSet.java @@ -28,10 +28,8 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -40,8 +38,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData; import net.luckperms.api.context.ImmutableContextSet; public class OptionSet extends ChildCommand { - public OptionSet(LocaleManager locale) { - super(CommandSpec.SPONGE_OPTION_SET.localize(locale), "set", CommandPermission.SPONGE_OPTION_SET, Predicates.inRange(0, 1)); + public OptionSet() { + super(CommandSpec.SPONGE_OPTION_SET, "set", CommandPermission.SPONGE_OPTION_SET, Predicates.inRange(0, 1)); } @Override @@ -51,9 +49,9 @@ public class OptionSet extends ChildCommand { ImmutableContextSet contextSet = args.getContextOrEmpty(2); if (subjectData.setOption(contextSet, key, value).join()) { - Message.BLANK.send(sender, "&aSet &f\"" + key + "&f\"&a to &f\"" + value + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager())); + SpongeCommandUtils.sendPrefixed(sender, "&aSet &f\"" + key + "&f\"&a to &f\"" + value + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet)); } else { - Message.BLANK.send(sender, "Unable to set option. Does the Subject already have it set?"); + SpongeCommandUtils.sendPrefixed(sender, "Unable to set option. Does the Subject already have it set?"); } return CommandResult.SUCCESS; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionUnset.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionUnset.java index d1f716a17..d171e2463 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionUnset.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionUnset.java @@ -28,10 +28,8 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -40,8 +38,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData; import net.luckperms.api.context.ImmutableContextSet; public class OptionUnset extends ChildCommand { - public OptionUnset(LocaleManager locale) { - super(CommandSpec.SPONGE_OPTION_UNSET.localize(locale), "unset", CommandPermission.SPONGE_OPTION_UNSET, Predicates.is(0)); + public OptionUnset() { + super(CommandSpec.SPONGE_OPTION_UNSET, "unset", CommandPermission.SPONGE_OPTION_UNSET, Predicates.is(0)); } @Override @@ -50,9 +48,9 @@ public class OptionUnset extends ChildCommand { ImmutableContextSet contextSet = args.getContextOrEmpty(1); if (subjectData.unsetOption(contextSet, key).join()) { - Message.BLANK.send(sender, "&aUnset &f\"" + key + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager())); + SpongeCommandUtils.sendPrefixed(sender, "&aUnset &f\"" + key + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet)); } else { - Message.BLANK.send(sender, "Unable to unset option. Are you sure the Subject has it set?"); + SpongeCommandUtils.sendPrefixed(sender, "Unable to unset option. Are you sure the Subject has it set?"); } return CommandResult.SUCCESS; } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentAdd.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentAdd.java index 39f04447c..5a6cbf8ac 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentAdd.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentAdd.java @@ -28,10 +28,8 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -45,8 +43,8 @@ import net.luckperms.api.context.ImmutableContextSet; import org.spongepowered.api.Sponge; public class ParentAdd extends ChildCommand { - public ParentAdd(LocaleManager locale) { - super(CommandSpec.SPONGE_PARENT_ADD.localize(locale), "add", CommandPermission.SPONGE_PARENT_ADD, Predicates.inRange(0, 1)); + public ParentAdd() { + super(CommandSpec.SPONGE_PARENT_ADD, "add", CommandPermission.SPONGE_PARENT_ADD, Predicates.inRange(0, 1)); } @Override @@ -57,21 +55,21 @@ public class ParentAdd extends ChildCommand { LPPermissionService service = Sponge.getServiceManager().provideUnchecked(LPPermissionService.class); if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(collection))) { - Message.BLANK.send(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't already exist."); + SpongeCommandUtils.sendPrefixed(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't already exist."); } LPSubjectCollection c = service.getCollection(collection); if (!c.hasRegistered(name).join()) { - Message.BLANK.send(sender, "Warning: Subject '&4" + name + "&c' doesn't already exist."); + SpongeCommandUtils.sendPrefixed(sender, "Warning: Subject '&4" + name + "&c' doesn't already exist."); } LPSubject subject = c.loadSubject(name).join(); if (subjectData.addParent(contextSet, subject.toReference()).join()) { - Message.BLANK.send(sender, "&aAdded parent &b" + subject.getParentCollection().getIdentifier() + - "&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager())); + SpongeCommandUtils.sendPrefixed(sender, "&aAdded parent &b" + subject.getParentCollection().getIdentifier() + + "&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet)); } else { - Message.BLANK.send(sender, "Unable to add parent. Does the Subject already have it added?"); + SpongeCommandUtils.sendPrefixed(sender, "Unable to add parent. Does the Subject already have it added?"); } return CommandResult.SUCCESS; } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentClear.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentClear.java index fa036432e..d34530cda 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentClear.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentClear.java @@ -28,10 +28,8 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -40,8 +38,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData; import net.luckperms.api.context.ImmutableContextSet; public class ParentClear extends ChildCommand { - public ParentClear(LocaleManager locale) { - super(CommandSpec.SPONGE_PARENT_CLEAR.localize(locale), "clear", CommandPermission.SPONGE_PARENT_CLEAR, Predicates.alwaysFalse()); + public ParentClear() { + super(CommandSpec.SPONGE_PARENT_CLEAR, "clear", CommandPermission.SPONGE_PARENT_CLEAR, Predicates.alwaysFalse()); } @Override @@ -49,10 +47,10 @@ public class ParentClear extends ChildCommand { ImmutableContextSet contextSet = args.getContextOrEmpty(0); if (contextSet.isEmpty()) { subjectData.clearParents(); - Message.BLANK.send(sender, "&aCleared parents matching contexts &bANY&a."); + SpongeCommandUtils.sendPrefixed(sender, "&aCleared parents matching contexts &bANY&a."); } else { subjectData.clearParents(contextSet); - Message.BLANK.send(sender, "&aCleared parents matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager())); + SpongeCommandUtils.sendPrefixed(sender, "&aCleared parents matching contexts &b" + SpongeCommandUtils.contextToString(contextSet)); } return CommandResult.SUCCESS; } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentInfo.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentInfo.java index f18b3a797..b369ac6a5 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentInfo.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentInfo.java @@ -30,10 +30,8 @@ import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -46,34 +44,34 @@ import java.util.List; import java.util.Map; public class ParentInfo extends ChildCommand { - public ParentInfo(LocaleManager locale) { - super(CommandSpec.SPONGE_PARENT_INFO.localize(locale), "info", CommandPermission.SPONGE_PARENT_INFO, Predicates.alwaysFalse()); + public ParentInfo() { + super(CommandSpec.SPONGE_PARENT_INFO, "info", CommandPermission.SPONGE_PARENT_INFO, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, ArgumentList args, String label) { ImmutableContextSet contextSet = args.getContextOrEmpty(0); if (contextSet.isEmpty()) { - Message.BLANK.send(sender, "&aShowing parents matching contexts &bANY&a."); + SpongeCommandUtils.sendPrefixed(sender, "&aShowing parents matching contexts &bANY&a."); Map> parents = subjectData.getAllParents(); if (parents.isEmpty()) { - Message.BLANK.send(sender, "That subject does not have any parents defined."); + SpongeCommandUtils.sendPrefixed(sender, "That subject does not have any parents defined."); return CommandResult.SUCCESS; } for (Map.Entry> e : parents.entrySet()) { - Message.BLANK.send(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.parentsToString(e.getValue())); + SpongeCommandUtils.sendPrefixed(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.parentsToString(e.getValue())); } } else { List parents = subjectData.getParents(contextSet); if (parents.isEmpty()) { - Message.BLANK.send(sender, "That subject does not have any parents defined in those contexts."); + SpongeCommandUtils.sendPrefixed(sender, "That subject does not have any parents defined in those contexts."); return CommandResult.SUCCESS; } - Message.BLANK.send(sender, "&aShowing parents matching contexts &b" + - SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.parentsToString(parents)); + SpongeCommandUtils.sendPrefixed(sender, "&aShowing parents matching contexts &b" + + SpongeCommandUtils.contextToString(contextSet) + "&a.\n" + SpongeCommandUtils.parentsToString(parents)); } return CommandResult.SUCCESS; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentRemove.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentRemove.java index 001880e23..6457c2f85 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentRemove.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/ParentRemove.java @@ -28,10 +28,8 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -45,8 +43,8 @@ import net.luckperms.api.context.ImmutableContextSet; import org.spongepowered.api.Sponge; public class ParentRemove extends ChildCommand { - public ParentRemove(LocaleManager locale) { - super(CommandSpec.SPONGE_PARENT_REMOVE.localize(locale), "remove", CommandPermission.SPONGE_PARENT_REMOVE, Predicates.inRange(0, 1)); + public ParentRemove() { + super(CommandSpec.SPONGE_PARENT_REMOVE, "remove", CommandPermission.SPONGE_PARENT_REMOVE, Predicates.inRange(0, 1)); } @Override @@ -57,21 +55,21 @@ public class ParentRemove extends ChildCommand { LPPermissionService service = Sponge.getServiceManager().provideUnchecked(LPPermissionService.class); if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(collection))) { - Message.BLANK.send(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't exist."); + SpongeCommandUtils.sendPrefixed(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't exist."); } LPSubjectCollection c = service.getCollection(collection); if (!c.hasRegistered(name).join()) { - Message.BLANK.send(sender, "Warning: Subject '&4" + name + "&c' doesn't exist."); + SpongeCommandUtils.sendPrefixed(sender, "Warning: Subject '&4" + name + "&c' doesn't exist."); } LPSubject subject = c.loadSubject(name).join(); if (subjectData.removeParent(contextSet, subject.toReference()).join()) { - Message.BLANK.send(sender, "&aRemoved parent &b" + subject.getParentCollection().getIdentifier() + - "&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager())); + SpongeCommandUtils.sendPrefixed(sender, "&aRemoved parent &b" + subject.getParentCollection().getIdentifier() + + "&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet)); } else { - Message.BLANK.send(sender, "Unable to remove parent. Are you sure the Subject has it added?"); + SpongeCommandUtils.sendPrefixed(sender, "Unable to remove parent. Are you sure the Subject has it added?"); } return CommandResult.SUCCESS; } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionClear.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionClear.java index 58db8b49a..8413c338c 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionClear.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionClear.java @@ -28,10 +28,8 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -40,8 +38,8 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData; import net.luckperms.api.context.ImmutableContextSet; public class PermissionClear extends ChildCommand { - public PermissionClear(LocaleManager locale) { - super(CommandSpec.SPONGE_PERMISSION_CLEAR.localize(locale), "clear", CommandPermission.SPONGE_PERMISSION_CLEAR, Predicates.alwaysFalse()); + public PermissionClear() { + super(CommandSpec.SPONGE_PERMISSION_CLEAR, "clear", CommandPermission.SPONGE_PERMISSION_CLEAR, Predicates.alwaysFalse()); } @Override @@ -49,10 +47,10 @@ public class PermissionClear extends ChildCommand { ImmutableContextSet contextSet = args.getContextOrEmpty(0); if (contextSet.isEmpty()) { subjectData.clearPermissions(); - Message.BLANK.send(sender, "&aCleared permissions matching contexts &bANY&a."); + SpongeCommandUtils.sendPrefixed(sender, "&aCleared permissions matching contexts &bANY&a."); } else { subjectData.clearPermissions(contextSet); - Message.BLANK.send(sender, "&aCleared permissions matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager())); + SpongeCommandUtils.sendPrefixed(sender, "&aCleared permissions matching contexts &b" + SpongeCommandUtils.contextToString(contextSet)); } return CommandResult.SUCCESS; } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionInfo.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionInfo.java index 2de6c1523..7ed9455fb 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionInfo.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionInfo.java @@ -30,10 +30,8 @@ import com.google.common.collect.ImmutableMap; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -44,34 +42,34 @@ import net.luckperms.api.context.ImmutableContextSet; import java.util.Map; public class PermissionInfo extends ChildCommand { - public PermissionInfo(LocaleManager locale) { - super(CommandSpec.SPONGE_PERMISSION_INFO.localize(locale), "info", CommandPermission.SPONGE_PERMISSION_INFO, Predicates.alwaysFalse()); + public PermissionInfo() { + super(CommandSpec.SPONGE_PERMISSION_INFO, "info", CommandPermission.SPONGE_PERMISSION_INFO, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, ArgumentList args, String label) { ImmutableContextSet contextSet = args.getContextOrEmpty(0); if (contextSet.isEmpty()) { - Message.BLANK.send(sender, "&aShowing permissions matching contexts &bANY&a."); + SpongeCommandUtils.sendPrefixed(sender, "&aShowing permissions matching contexts &bANY&a."); Map> permissions = subjectData.getAllPermissions(); if (permissions.isEmpty()) { - Message.BLANK.send(sender, "That subject does not have any permissions defined."); + SpongeCommandUtils.sendPrefixed(sender, "That subject does not have any permissions defined."); return CommandResult.SUCCESS; } for (Map.Entry> e : permissions.entrySet()) { - Message.BLANK.send(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.nodesToString(e.getValue())); + SpongeCommandUtils.sendPrefixed(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.nodesToString(e.getValue())); } } else { Map permissions = subjectData.getPermissions(contextSet); if (permissions.isEmpty()) { - Message.BLANK.send(sender, "That subject does not have any permissions defined in those contexts."); + SpongeCommandUtils.sendPrefixed(sender, "That subject does not have any permissions defined in those contexts."); return CommandResult.SUCCESS; } - Message.BLANK.send(sender, "&aShowing permissions matching contexts &b" + - SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.nodesToString(permissions)); + SpongeCommandUtils.sendPrefixed(sender, "&aShowing permissions matching contexts &b" + + SpongeCommandUtils.contextToString(contextSet) + "&a.\n" + SpongeCommandUtils.nodesToString(permissions)); } return CommandResult.SUCCESS; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionSet.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionSet.java index 851263e42..f9d9a0d41 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionSet.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/PermissionSet.java @@ -29,10 +29,8 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -42,8 +40,8 @@ import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.util.Tristate; public class PermissionSet extends ChildCommand { - public PermissionSet(LocaleManager locale) { - super(CommandSpec.SPONGE_PERMISSION_SET.localize(locale), "set", CommandPermission.SPONGE_PERMISSION_SET, Predicates.inRange(0, 1)); + public PermissionSet() { + super(CommandSpec.SPONGE_PERMISSION_SET, "set", CommandPermission.SPONGE_PERMISSION_SET, Predicates.inRange(0, 1)); } @Override @@ -53,9 +51,9 @@ public class PermissionSet extends ChildCommand { ImmutableContextSet contextSet = args.getContextOrEmpty(2); if (subjectData.setPermission(contextSet, node, tristate).join()) { - Message.BLANK.send(sender, "&aSet &b" + node + "&a to &b" + tristate.toString().toLowerCase() + "&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager())); + SpongeCommandUtils.sendPrefixed(sender, "&aSet &b" + node + "&a to &b" + tristate.toString().toLowerCase() + "&a in context " + SpongeCommandUtils.contextToString(contextSet)); } else { - Message.BLANK.send(sender, "Unable to set permission. Does the Subject already have it set?"); + SpongeCommandUtils.sendPrefixed(sender, "Unable to set permission. Does the Subject already have it set?"); } return CommandResult.SUCCESS; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeCommandUtils.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeCommandUtils.java index 24764c33c..501829e7b 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeCommandUtils.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeCommandUtils.java @@ -27,28 +27,41 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.common.command.utils.ArgumentException; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.sponge.service.model.LPSubjectReference; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.luckperms.api.context.ContextSet; import net.luckperms.api.util.Tristate; +import java.util.Collection; import java.util.Map; public final class SpongeCommandUtils { private SpongeCommandUtils() {} + public static void sendPrefixed(Sender sender, String message) { + sender.sendMessage(Message.prefixed(LegacyComponentSerializer.legacyAmpersand().deserialize(message))); + } + public static Tristate parseTristate(int index, ArgumentList args) throws ArgumentException { String s = args.get(index).toLowerCase(); - if (s.equals("1") || s.equals("true") || s.equals("t")) { - return Tristate.TRUE; - } - if (s.equals("0") || s.equals("null") || s.equals("none") || s.equals("undefined") || s.equals("undef")) { - return Tristate.UNDEFINED; - } - if (s.equals("-1") || s.equals("false") || s.equals("f")) { - return Tristate.FALSE; + switch (s) { + case "1": + case "true": + case "t": + return Tristate.TRUE; + case "0": + case "null": + case "none": + case "undefined": + case "undef": + return Tristate.UNDEFINED; + case "-1": + case "false": + case "f": + return Tristate.FALSE; } throw new ArgumentException.DetailedUsage(); } @@ -88,8 +101,12 @@ public final class SpongeCommandUtils { return sb.toString(); } - public static String contextToString(ContextSet set, LocaleManager localeManager) { - return MessageUtils.contextSetToString(localeManager, set); + public static String toCommaSep(Collection strings) { + return LegacyComponentSerializer.legacyAmpersand().serialize(Message.formatStringList(strings)); + } + + public static String contextToString(ContextSet set) { + return LegacyComponentSerializer.legacyAmpersand().serialize(Message.formatContextSet(set)); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeParentCommand.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeParentCommand.java index 9c1db10a9..787f7d57b 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeParentCommand.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeParentCommand.java @@ -32,11 +32,9 @@ import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.abstraction.Command; import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.command.utils.MessageUtils; -import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.command.CommandSpec; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; @@ -57,29 +55,26 @@ public class SpongeParentCommand extends Command { private final Map>> children; public SpongeParentCommand(LPSpongePlugin plugin) { - super(CommandSpec.SPONGE.localize(plugin.getLocaleManager()), "Sponge", null, Predicates.alwaysFalse()); - - LocaleManager locale = plugin.getLocaleManager(); - + super(CommandSpec.SPONGE, "Sponge", null, Predicates.alwaysFalse()); this.children = ImmutableMap.>>builder() .put("permission", ImmutableList.>builder() - .add(new PermissionInfo(locale)) - .add(new PermissionSet(locale)) - .add(new PermissionClear(locale)) + .add(new PermissionInfo()) + .add(new PermissionSet()) + .add(new PermissionClear()) .build() ) .put("parent", ImmutableList.>builder() - .add(new ParentInfo(locale)) - .add(new ParentAdd(locale)) - .add(new ParentRemove(locale)) - .add(new ParentClear(locale)) + .add(new ParentInfo()) + .add(new ParentAdd()) + .add(new ParentRemove()) + .add(new ParentClear()) .build() ) .put("option", ImmutableList.>builder() - .add(new OptionInfo(locale)) - .add(new OptionSet(locale)) - .add(new OptionUnset(locale)) - .add(new OptionClear(locale)) + .add(new OptionInfo()) + .add(new OptionSet()) + .add(new OptionUnset()) + .add(new OptionClear()) .build() ) .build(); @@ -92,8 +87,8 @@ public class SpongeParentCommand extends Command { LuckPermsService service = this.plugin.getService(); if (args.size() < 1) { - Message.BLANK.send(sender, "&aCurrent Subject Collections:\n" + - MessageUtils.toCommaSep(service.getLoadedCollections().keySet().stream() + SpongeCommandUtils.sendPrefixed(sender, "&aCurrent Subject Collections:\n" + + SpongeCommandUtils.toCommaSep(service.getLoadedCollections().keySet().stream() .filter(s -> !s.equalsIgnoreCase("user") && !s.equalsIgnoreCase("group")) .sorted() .collect(Collectors.toList()) @@ -104,12 +99,12 @@ public class SpongeParentCommand extends Command { String subjectCollection = args.get(0); if (subjectCollection.equalsIgnoreCase("user") || subjectCollection.equalsIgnoreCase("group")) { - Message.BLANK.send(sender, "Please use the main LuckPerms commands to edit users and groups."); + SpongeCommandUtils.sendPrefixed(sender, "Please use the main LuckPerms commands to edit users and groups."); return CommandResult.STATE_ERROR; } if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(subjectCollection))) { - Message.BLANK.send(sender, "Warning: SubjectCollection '&4" + subjectCollection + "&c' doesn't already exist. Creating it now."); + SpongeCommandUtils.sendPrefixed(sender, "Warning: SubjectCollection '&4" + subjectCollection + "&c' doesn't already exist. Creating it now."); } LPSubjectCollection collection = service.getCollection(subjectCollection); @@ -123,9 +118,9 @@ public class SpongeParentCommand extends Command { List extra = subjects.subList(50, subjects.size()); int overflow = extra.size(); extra.clear(); - Message.BLANK.send(sender, "&aCurrent Subjects:\n" + MessageUtils.toCommaSep(subjects) + "&b ... and &a" + overflow + " &bmore."); + SpongeCommandUtils.sendPrefixed(sender, "&aCurrent Subjects:\n" + SpongeCommandUtils.toCommaSep(subjects) + "&b ... and &a" + overflow + " &bmore."); } else { - Message.BLANK.send(sender, "&aCurrent Subjects:\n" + MessageUtils.toCommaSep(subjects)); + SpongeCommandUtils.sendPrefixed(sender, "&aCurrent Subjects:\n" + SpongeCommandUtils.toCommaSep(subjects)); } return CommandResult.SUCCESS; @@ -171,7 +166,7 @@ public class SpongeParentCommand extends Command { String subjectId = args.get(1); if (!collection.hasRegistered(subjectId).join()) { - Message.BLANK.send(sender, "Warning: Subject '&4" + subjectId + "&c' doesn't already exist. Creating it now."); + SpongeCommandUtils.sendPrefixed(sender, "Warning: Subject '&4" + subjectId + "&c' doesn't already exist. Creating it now."); } LPSubject subject = collection.loadSubject(subjectId).join(); @@ -188,19 +183,19 @@ public class SpongeParentCommand extends Command { @Override public void sendUsage(Sender sender, String label) { - Message.BLANK.send(sender, "&3> &a" + String.format(getUsage(), label)); + SpongeCommandUtils.sendPrefixed(sender, "&3> &a" + String.format(getUsage(), label)); } @Override public void sendDetailedUsage(Sender sender, String label) { - Message.BLANK.send(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s sponge [-transient]", label) + " ...)"); + SpongeCommandUtils.sendPrefixed(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s sponge [-transient]", label) + " ...)"); for (String s : Arrays.asList("Permission", "Parent", "Option")) { List> subs = this.children.get(s.toLowerCase()).stream() .filter(sub -> sub.isAuthorized(sender)) .collect(Collectors.toList()); if (!subs.isEmpty()) { - Message.BLANK.send(sender, "&3>> &b" + s); + SpongeCommandUtils.sendPrefixed(sender, "&3>> &b" + s); for (Command sub : subs) { sub.sendUsage(sender, label); } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java b/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java index ed8801019..f6ac2a5f0 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java @@ -26,17 +26,21 @@ package me.lucko.luckperms.sponge.listeners; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.TranslationManager; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener; import me.lucko.luckperms.sponge.LPSpongePlugin; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.spongeapi.SpongeComponentSerializer; +import net.kyori.adventure.translation.GlobalTranslator; + import org.spongepowered.api.event.Listener; import org.spongepowered.api.event.Order; import org.spongepowered.api.event.filter.IsCancelled; import org.spongepowered.api.event.network.ClientConnectionEvent; import org.spongepowered.api.profile.GameProfile; -import org.spongepowered.api.text.serializer.TextSerializers; import org.spongepowered.api.util.Tristate; import java.util.Collections; @@ -97,8 +101,8 @@ public class SpongeConnectionListener extends AbstractConnectionListener { e.setCancelled(true); e.setMessageCancelled(false); - //noinspection deprecation - e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager()))); + Component reason = GlobalTranslator.render(Message.LOADING_DATABASE_ERROR.build(), TranslationManager.DEFAULT_LOCALE); + e.setMessage(SpongeComponentSerializer.get().serialize(reason)); this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(profile.getUniqueId(), username, null); } } @@ -151,8 +155,8 @@ public class SpongeConnectionListener extends AbstractConnectionListener { e.setCancelled(true); e.setMessageCancelled(false); - //noinspection deprecation - e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_STATE_ERROR.asString(this.plugin.getLocaleManager()))); + Component reason = GlobalTranslator.render(Message.LOADING_STATE_ERROR.build(), TranslationManager.DEFAULT_LOCALE); + e.setMessage(SpongeComponentSerializer.get().serialize(reason)); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongePlatformListener.java b/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongePlatformListener.java index a68f24805..15534a25f 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongePlatformListener.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongePlatformListener.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.sponge.listeners; -import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.sponge.LPSpongePlugin; import org.spongepowered.api.command.CommandSource; diff --git a/velocity/build.gradle b/velocity/build.gradle index 05130082f..a81373103 100644 --- a/velocity/build.gradle +++ b/velocity/build.gradle @@ -10,8 +10,8 @@ repositories { dependencies { compile project(':common') - compileOnly 'com.velocitypowered:velocity-api:1.0-SNAPSHOT' - annotationProcessor 'com.velocitypowered:velocity-api:1.0-SNAPSHOT' + compileOnly 'com.velocitypowered:velocity-api:1.1.0-SNAPSHOT' + annotationProcessor 'com.velocitypowered:velocity-api:1.1.0-SNAPSHOT' } blossom { @@ -27,7 +27,7 @@ shadowJar { include(dependency('me.lucko.luckperms:.*')) } - //relocate 'net.kyori.text', 'me.lucko.luckperms.lib.text' + //relocate 'net.kyori.adventure', 'me.lucko.luckperms.lib.adventure' relocate 'net.kyori.event', 'me.lucko.luckperms.lib.eventbus' relocate 'com.github.benmanes.caffeine', 'me.lucko.luckperms.lib.caffeine' relocate 'okio', 'me.lucko.luckperms.lib.okio' diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/LPVelocityPlugin.java b/velocity/src/main/java/me/lucko/luckperms/velocity/LPVelocityPlugin.java index 1ee7d93f7..2b072d02b 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/LPVelocityPlugin.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/LPVelocityPlugin.java @@ -98,9 +98,7 @@ public class LPVelocityPlugin extends AbstractLuckPermsPlugin { dependencies.add(Dependency.SNAKEYAML); // already included in the proxy - dependencies.remove(Dependency.TEXT); - dependencies.remove(Dependency.TEXT_SERIALIZER_GSON); - dependencies.remove(Dependency.TEXT_SERIALIZER_LEGACY); + dependencies.remove(Dependency.ADVENTURE); return dependencies; } diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/VelocitySenderFactory.java b/velocity/src/main/java/me/lucko/luckperms/velocity/VelocitySenderFactory.java index c62b506b9..e96439bd0 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/VelocitySenderFactory.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/VelocitySenderFactory.java @@ -28,14 +28,16 @@ package me.lucko.luckperms.velocity; import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.proxy.Player; +import me.lucko.luckperms.common.locale.TranslationManager; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.sender.SenderFactory; -import me.lucko.luckperms.common.util.TextUtils; import me.lucko.luckperms.velocity.service.CompatibilityUtil; -import net.kyori.text.Component; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.translation.GlobalTranslator; import net.luckperms.api.util.Tristate; +import java.util.Locale; import java.util.UUID; public class VelocitySenderFactory extends SenderFactory { @@ -59,14 +61,14 @@ public class VelocitySenderFactory extends SenderFactory { @@ -141,7 +144,7 @@ public class VelocityConnectionListener extends AbstractConnectionListener { return; } - this.plugin.getSenderFactory().wrap(player).sendMessage(Message.LOADING_STATE_ERROR.asComponent(this.plugin.getLocaleManager())); + Message.LOADING_STATE_ERROR.send(this.plugin.getSenderFactory().wrap(player)); }, 1, TimeUnit.SECONDS); } }