From 907d7169294b859c3aa4e0d693608c9de697d4de Mon Sep 17 00:00:00 2001 From: Luck Date: Mon, 12 Mar 2018 21:25:29 +0000 Subject: [PATCH] Reorganise commands --- .../bukkit/BukkitCommandExecutor.java | 4 +- .../bukkit/BukkitSchedulerAdapter.java | 4 +- .../luckperms/bukkit/BukkitSenderFactory.java | 4 +- .../luckperms/bukkit/LPBukkitPlugin.java | 4 +- .../listeners/BukkitConnectionListener.java | 2 +- .../listeners/BukkitPlatformListener.java | 2 +- .../migration/MigrationBPermissions.java | 22 +- .../migration/MigrationGroupManager.java | 28 +- .../migration/MigrationPermissionsBukkit.java | 20 +- .../migration/MigrationPermissionsEx.java | 20 +- .../migration/MigrationPowerfulPerms.java | 20 +- .../migration/MigrationZPermissions.java | 22 +- .../luckperms/bukkit/vault/VaultChatHook.java | 2 +- .../bukkit/vault/VaultPermissionHook.java | 2 +- .../bungee/BungeeCommandExecutor.java | 4 +- .../bungee/BungeeSchedulerAdapter.java | 4 +- .../luckperms/bungee/BungeeSenderFactory.java | 4 +- .../luckperms/bungee/LPBungeePlugin.java | 4 +- .../listeners/BungeeConnectionListener.java | 2 +- .../migration/MigrationBungeePerms.java | 20 +- .../common/actionlog/ExtendedLogEntry.java | 46 +- .../lucko/luckperms/common/actionlog/Log.java | 2 +- .../common/actionlog/LogDispatcher.java | 8 +- .../luckperms/common/backup/Exporter.java | 16 +- .../luckperms/common/backup/Importer.java | 28 +- .../{commands => command}/CommandManager.java | 85 +-- .../{commands => command}/CommandResult.java | 21 +- .../abstraction/Command.java | 25 +- .../abstraction}/CommandException.java | 2 +- .../abstraction/MainCommand.java | 19 +- .../abstraction/SharedMainCommand.java | 37 +- .../abstraction/SharedSubCommand.java | 55 +- .../abstraction/SingleCommand.java | 31 +- .../command/abstraction/SubCommand.java | 75 ++ .../access}/ArgumentPermissions.java | 43 +- .../access}/CommandPermission.java | 16 +- .../utils/ArgumentParser.java} | 32 +- .../utils/MessageUtils.java} | 34 +- .../{commands => command}/utils/SortMode.java | 2 +- .../{commands => command}/utils/SortType.java | 2 +- .../command/utils/StorageAssistant.java | 127 ++++ .../common/command/utils/TabCompletions.java | 124 ++++ .../commands/abstraction/SubCommand.java | 240 ------- .../{impl => }/generic/meta/CommandMeta.java | 10 +- .../generic/meta/MetaAddChatMeta.java | 39 +- .../generic/meta/MetaAddTempChatMeta.java | 43 +- .../{impl => }/generic/meta/MetaClear.java | 33 +- .../{impl => }/generic/meta/MetaInfo.java | 42 +- .../generic/meta/MetaRemoveChatMeta.java | 43 +- .../generic/meta/MetaRemoveTempChatMeta.java | 43 +- .../{impl => }/generic/meta/MetaSet.java | 33 +- .../{impl => }/generic/meta/MetaSetTemp.java | 39 +- .../{impl => }/generic/meta/MetaUnset.java | 33 +- .../generic/meta/MetaUnsetTemp.java | 33 +- .../{impl => }/generic/other/HolderClear.java | 34 +- .../generic/other/HolderEditor.java | 22 +- .../generic/other/HolderShowTracks.java | 24 +- .../generic/parent/CommandParent.java | 10 +- .../{impl => }/generic/parent/ParentAdd.java | 37 +- .../generic/parent/ParentAddTemp.java | 43 +- .../generic/parent/ParentClear.java | 33 +- .../generic/parent/ParentClearTrack.java | 35 +- .../{impl => }/generic/parent/ParentInfo.java | 35 +- .../generic/parent/ParentRemove.java | 37 +- .../generic/parent/ParentRemoveTemp.java | 37 +- .../{impl => }/generic/parent/ParentSet.java | 35 +- .../generic/parent/ParentSetTrack.java | 39 +- .../parent/UserSwitchPrimaryGroup.java | 23 +- .../generic/permission/CommandPermission.java | 10 +- .../generic/permission/PermissionCheck.java | 34 +- .../permission/PermissionCheckInherits.java | 34 +- .../generic/permission/PermissionInfo.java | 35 +- .../generic/permission/PermissionSet.java | 41 +- .../generic/permission/PermissionSetTemp.java | 45 +- .../generic/permission/PermissionUnset.java | 37 +- .../permission/PermissionUnsetTemp.java | 37 +- .../{impl => }/group/CreateGroup.java | 16 +- .../{impl => }/group/DeleteGroup.java | 20 +- .../commands/{impl => }/group/GroupClone.java | 21 +- .../commands/{impl => }/group/GroupInfo.java | 24 +- .../{impl => }/group/GroupListMembers.java | 31 +- .../{impl => }/group/GroupMainCommand.java | 26 +- .../{impl => }/group/GroupRename.java | 19 +- .../{impl => }/group/GroupSetDisplayName.java | 27 +- .../{impl => }/group/GroupSetWeight.java | 27 +- .../commands/{impl => }/group/ListGroups.java | 22 +- .../{impl => }/log/LogGroupHistory.java | 19 +- .../{impl => }/log/LogMainCommand.java | 14 +- .../commands/{impl => }/log/LogNotify.java | 16 +- .../commands/{impl => }/log/LogRecent.java | 16 +- .../commands/{impl => }/log/LogSearch.java | 16 +- .../{impl => }/log/LogTrackHistory.java | 19 +- .../{impl => }/log/LogUserHistory.java | 16 +- .../migration/MigrationMainCommand.java | 20 +- .../{impl => }/migration/MigrationUtils.java | 2 +- .../{impl => }/misc/ApplyEditsCommand.java | 28 +- .../{impl => }/misc/BulkUpdateCommand.java | 28 +- .../{impl => }/misc/CheckCommand.java | 24 +- .../{impl => }/misc/DebugCommand.java | 20 +- .../{impl => }/misc/EditorCommand.java | 26 +- .../{impl => }/misc/ExportCommand.java | 16 +- .../{impl => }/misc/ImportCommand.java | 16 +- .../commands/{impl => }/misc/InfoCommand.java | 20 +- .../{impl => }/misc/NetworkSyncCommand.java | 16 +- .../{impl => }/misc/ReloadConfigCommand.java | 16 +- .../{impl => }/misc/SearchCommand.java | 33 +- .../commands/{impl => }/misc/SyncCommand.java | 16 +- .../commands/{impl => }/misc/TreeCommand.java | 16 +- .../{impl => }/misc/VerboseCommand.java | 16 +- .../{impl => }/track/CreateTrack.java | 16 +- .../{impl => }/track/DeleteTrack.java | 20 +- .../commands/{impl => }/track/ListTracks.java | 20 +- .../{impl => }/track/TrackAppend.java | 26 +- .../commands/{impl => }/track/TrackClear.java | 19 +- .../commands/{impl => }/track/TrackClone.java | 19 +- .../commands/{impl => }/track/TrackInfo.java | 20 +- .../{impl => }/track/TrackInsert.java | 26 +- .../{impl => }/track/TrackMainCommand.java | 14 +- .../{impl => }/track/TrackRemove.java | 26 +- .../{impl => }/track/TrackRename.java | 19 +- .../commands/{impl => }/user/UserClone.java | 21 +- .../commands/{impl => }/user/UserDemote.java | 38 +- .../commands/{impl => }/user/UserInfo.java | 30 +- .../{impl => }/user/UserMainCommand.java | 26 +- .../commands/{impl => }/user/UserPromote.java | 40 +- .../common/commands/utils/MetaComparator.java | 46 -- .../luckperms/common/event/EventFactory.java | 2 +- .../common/event/impl/EventLogNotify.java | 2 +- .../common/event/model/EntitySender.java | 2 +- .../luckperms/common/locale/CommandSpec.java | 665 ------------------ .../common/locale/LocaleManager.java | 3 + .../common/locale/SimpleLocaleManager.java | 3 + .../Arg.java => locale/command/Argument.java} | 12 +- .../common/locale/command/CommandSpec.java | 665 ++++++++++++++++++ .../locale/{ => command}/CommandSpecData.java | 18 +- .../LocalizedCommandSpec.java} | 8 +- .../common/locale/{ => message}/Message.java | 19 +- .../common/logging/ProgressLogger.java | 4 +- .../common/logging/SenderLogger.java | 8 +- .../messaging/message/LogMessageImpl.java | 2 +- .../plugin/AbstractLuckPermsPlugin.java | 18 +- .../common/plugin/LuckPermsPlugin.java | 6 +- .../{commands => }/sender/AbstractSender.java | 2 +- .../{commands => }/sender/DummySender.java | 4 +- .../common/{commands => }/sender/Sender.java | 6 +- .../{commands => }/sender/SenderFactory.java | 2 +- .../storage/dao/file/FileActionLogger.java | 2 +- .../luckperms/common/treeview/TreeView.java | 4 +- .../common/utils/CollationKeyCache.java | 2 +- .../{SafeIteration.java => Iterators.java} | 20 +- .../luckperms/common/utils/Predicates.java | 50 +- .../common/verbose/VerboseHandler.java | 2 +- .../common/verbose/VerboseListener.java | 12 +- .../common/{utils => }/web/HttpClient.java | 2 +- .../common/{utils => }/web/Pastebin.java | 2 +- .../{utils => }/web/StandardPastebin.java | 2 +- .../common/{webeditor => web}/WebEditor.java | 8 +- .../luckperms/nukkit/LPNukkitPlugin.java | 4 +- .../nukkit/NukkitCommandExecutor.java | 4 +- .../nukkit/NukkitSchedulerAdapter.java | 4 +- .../luckperms/nukkit/NukkitSenderFactory.java | 4 +- .../listeners/NukkitConnectionListener.java | 2 +- .../listeners/NukkitPlatformListener.java | 2 +- .../luckperms/sponge/LPSpongePlugin.java | 10 +- .../sponge/SpongeCommandExecutor.java | 4 +- .../sponge/SpongeSchedulerAdapter.java | 4 +- .../luckperms/sponge/SpongeSenderFactory.java | 4 +- .../sponge/commands/OptionClear.java | 22 +- .../luckperms/sponge/commands/OptionInfo.java | 28 +- .../luckperms/sponge/commands/OptionSet.java | 22 +- .../sponge/commands/OptionUnset.java | 22 +- .../luckperms/sponge/commands/ParentAdd.java | 26 +- .../sponge/commands/ParentClear.java | 22 +- .../luckperms/sponge/commands/ParentInfo.java | 28 +- .../sponge/commands/ParentRemove.java | 26 +- .../sponge/commands/PermissionClear.java | 22 +- .../sponge/commands/PermissionInfo.java | 28 +- .../sponge/commands/PermissionSet.java | 24 +- .../sponge/commands/SpongeCommandUtils.java | 10 +- .../sponge/commands/SpongeMainCommand.java | 38 +- .../listeners/SpongeConnectionListener.java | 2 +- .../listeners/SpongePlatformListener.java | 2 +- 182 files changed, 2754 insertions(+), 2627 deletions(-) rename common/src/main/java/me/lucko/luckperms/common/{commands => command}/CommandManager.java (87%) rename common/src/main/java/me/lucko/luckperms/common/{commands => command}/CommandResult.java (83%) rename common/src/main/java/me/lucko/luckperms/common/{commands => command}/abstraction/Command.java (87%) rename common/src/main/java/me/lucko/luckperms/common/{commands => command/abstraction}/CommandException.java (96%) rename common/src/main/java/me/lucko/luckperms/common/{commands => command}/abstraction/MainCommand.java (91%) rename common/src/main/java/me/lucko/luckperms/common/{commands => command}/abstraction/SharedMainCommand.java (84%) rename common/src/main/java/me/lucko/luckperms/common/{commands => command}/abstraction/SharedSubCommand.java (68%) rename common/src/main/java/me/lucko/luckperms/common/{commands => command}/abstraction/SingleCommand.java (71%) create mode 100644 common/src/main/java/me/lucko/luckperms/common/command/abstraction/SubCommand.java rename common/src/main/java/me/lucko/luckperms/common/{commands => command/access}/ArgumentPermissions.java (85%) rename common/src/main/java/me/lucko/luckperms/common/{commands => command/access}/CommandPermission.java (92%) rename common/src/main/java/me/lucko/luckperms/common/{commands/utils/ArgumentUtils.java => command/utils/ArgumentParser.java} (87%) rename common/src/main/java/me/lucko/luckperms/common/{commands/utils/CommandUtils.java => command/utils/MessageUtils.java} (88%) rename common/src/main/java/me/lucko/luckperms/common/{commands => command}/utils/SortMode.java (98%) rename common/src/main/java/me/lucko/luckperms/common/{commands => command}/utils/SortType.java (96%) create mode 100644 common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java create mode 100644 common/src/main/java/me/lucko/luckperms/common/command/utils/TabCompletions.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/meta/CommandMeta.java (87%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/meta/MetaAddChatMeta.java (77%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/meta/MetaAddTempChatMeta.java (78%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/meta/MetaClear.java (77%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/meta/MetaInfo.java (85%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/meta/MetaRemoveChatMeta.java (79%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/meta/MetaRemoveTempChatMeta.java (79%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/meta/MetaSet.java (77%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/meta/MetaSetTemp.java (76%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/meta/MetaUnset.java (72%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/meta/MetaUnsetTemp.java (72%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/other/HolderClear.java (72%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/other/HolderEditor.java (81%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/other/HolderShowTracks.java (82%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/parent/CommandParent.java (85%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/parent/ParentAdd.java (74%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/parent/ParentAddTemp.java (74%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/parent/ParentClear.java (72%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/parent/ParentClearTrack.java (78%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/parent/ParentInfo.java (82%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/parent/ParentRemove.java (76%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/parent/ParentRemoveTemp.java (72%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/parent/ParentSet.java (74%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/parent/ParentSetTrack.java (77%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/parent/UserSwitchPrimaryGroup.java (82%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/permission/CommandPermission.java (83%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/permission/PermissionCheck.java (69%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/permission/PermissionCheckInherits.java (70%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/permission/PermissionInfo.java (83%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/permission/PermissionSet.java (70%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/permission/PermissionSetTemp.java (71%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/permission/PermissionUnset.java (72%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/generic/permission/PermissionUnsetTemp.java (72%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/group/CreateGroup.java (84%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/group/DeleteGroup.java (83%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/group/GroupClone.java (81%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/group/GroupInfo.java (81%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/group/GroupListMembers.java (86%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/group/GroupMainCommand.java (81%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/group/GroupRename.java (83%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/group/GroupSetDisplayName.java (79%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/group/GroupSetWeight.java (73%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/group/ListGroups.java (84%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/log/LogGroupHistory.java (85%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/log/LogMainCommand.java (90%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/log/LogNotify.java (89%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/log/LogRecent.java (92%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/log/LogSearch.java (87%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/log/LogTrackHistory.java (85%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/log/LogUserHistory.java (90%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/migration/MigrationMainCommand.java (88%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/migration/MigrationUtils.java (97%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/ApplyEditsCommand.java (86%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/BulkUpdateCommand.java (86%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/CheckCommand.java (80%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/DebugCommand.java (95%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/EditorCommand.java (85%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/ExportCommand.java (86%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/ImportCommand.java (86%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/InfoCommand.java (84%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/NetworkSyncCommand.java (82%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/ReloadConfigCommand.java (77%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/SearchCommand.java (85%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/SyncCommand.java (78%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/TreeCommand.java (88%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/misc/VerboseCommand.java (91%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/track/CreateTrack.java (84%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/track/DeleteTrack.java (81%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/track/ListTracks.java (75%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/track/TrackAppend.java (77%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/track/TrackClear.java (76%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/track/TrackClone.java (81%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/track/TrackInfo.java (73%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/track/TrackInsert.java (80%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/track/TrackMainCommand.java (88%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/track/TrackRemove.java (76%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/track/TrackRename.java (83%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/user/UserClone.java (85%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/user/UserDemote.java (83%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/user/UserInfo.java (83%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/user/UserMainCommand.java (85%) rename common/src/main/java/me/lucko/luckperms/common/commands/{impl => }/user/UserPromote.java (83%) delete mode 100644 common/src/main/java/me/lucko/luckperms/common/commands/utils/MetaComparator.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/locale/CommandSpec.java rename common/src/main/java/me/lucko/luckperms/common/{commands/Arg.java => locale/command/Argument.java} (84%) create mode 100644 common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpec.java rename common/src/main/java/me/lucko/luckperms/common/locale/{ => command}/CommandSpecData.java (84%) rename common/src/main/java/me/lucko/luckperms/common/locale/{LocalizedSpec.java => command/LocalizedCommandSpec.java} (90%) rename common/src/main/java/me/lucko/luckperms/common/locale/{ => message}/Message.java (98%) rename common/src/main/java/me/lucko/luckperms/common/{commands => }/sender/AbstractSender.java (98%) rename common/src/main/java/me/lucko/luckperms/common/{commands => }/sender/DummySender.java (96%) rename common/src/main/java/me/lucko/luckperms/common/{commands => }/sender/Sender.java (96%) rename common/src/main/java/me/lucko/luckperms/common/{commands => }/sender/SenderFactory.java (97%) rename common/src/main/java/me/lucko/luckperms/common/utils/{SafeIteration.java => Iterators.java} (81%) rename common/src/main/java/me/lucko/luckperms/common/{utils => }/web/HttpClient.java (98%) rename common/src/main/java/me/lucko/luckperms/common/{utils => }/web/Pastebin.java (98%) rename common/src/main/java/me/lucko/luckperms/common/{utils => }/web/StandardPastebin.java (99%) rename common/src/main/java/me/lucko/luckperms/common/{webeditor => web}/WebEditor.java (97%) diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitCommandExecutor.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitCommandExecutor.java index 99de2c8ca..8aa68d018 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitCommandExecutor.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitCommandExecutor.java @@ -28,8 +28,8 @@ package me.lucko.luckperms.bukkit; import com.google.common.base.Joiner; import com.google.common.base.Splitter; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.sender.Sender; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSchedulerAdapter.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSchedulerAdapter.java index 4c7513686..15b1af4bf 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSchedulerAdapter.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSchedulerAdapter.java @@ -29,7 +29,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; import me.lucko.luckperms.common.plugin.SchedulerAdapter; import me.lucko.luckperms.common.plugin.SchedulerTask; -import me.lucko.luckperms.common.utils.SafeIteration; +import me.lucko.luckperms.common.utils.Iterators; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitTask; @@ -105,7 +105,7 @@ public class BukkitSchedulerAdapter implements SchedulerAdapter { @Override public void shutdown() { - SafeIteration.iterate(this.tasks, SchedulerTask::cancel); + Iterators.iterate(this.tasks, SchedulerTask::cancel); // wait for executor this.asyncFallback.shutdown(); 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 04c1f2cc9..3d863fcbc 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java @@ -29,9 +29,9 @@ import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.bukkit.compat.BukkitJsonMessageHandler; import me.lucko.luckperms.bukkit.compat.ReflectionUtil; import me.lucko.luckperms.bukkit.compat.SpigotJsonMessageHandler; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.sender.SenderFactory; +import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.SenderFactory; import me.lucko.luckperms.common.utils.TextUtils; import net.kyori.text.Component; diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java index f8e824bb4..e44d44d78 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java @@ -44,8 +44,7 @@ import me.lucko.luckperms.bukkit.model.server.LPPermissionMap; import me.lucko.luckperms.bukkit.model.server.LPSubscriptionMap; import me.lucko.luckperms.bukkit.vault.VaultHookManager; import me.lucko.luckperms.common.calculators.PlatformCalculatorFactory; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter; import me.lucko.luckperms.common.contexts.ContextManager; @@ -56,6 +55,7 @@ import me.lucko.luckperms.common.managers.user.StandardUserManager; import me.lucko.luckperms.common.messaging.MessagingFactory; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.tasks.CacheHousekeepingTask; import me.lucko.luckperms.common.tasks.ExpireTemporaryTask; 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 f8a722a6d..c4fc5479f 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 @@ -30,7 +30,7 @@ import me.lucko.luckperms.bukkit.model.permissible.LPPermissible; import me.lucko.luckperms.bukkit.model.permissible.PermissibleInjector; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.listener.AbstractConnectionListener; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.User; import org.bukkit.entity.Player; 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 cd67c0567..0d7764b2a 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; +import me.lucko.luckperms.common.locale.message.Message; import org.bukkit.command.CommandSender; import org.bukkit.event.Cancellable; 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 69a70af4a..1542678bc 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 @@ -33,20 +33,20 @@ import de.bananaco.bpermissions.api.WorldManager; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +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.logging.ProgressLogger; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; +import me.lucko.luckperms.common.utils.Iterators; import me.lucko.luckperms.common.utils.Predicates; -import me.lucko.luckperms.common.utils.SafeIteration; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; @@ -58,7 +58,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; -import static me.lucko.luckperms.common.commands.CommandPermission.MIGRATION; +import static me.lucko.luckperms.common.command.access.CommandPermission.MIGRATION; public class MigrationBPermissions extends SubCommand { private static final Field UCONFIG_FIELD; @@ -72,7 +72,7 @@ public class MigrationBPermissions extends SubCommand { } public MigrationBPermissions(LocaleManager locale) { - super(CommandSpec.MIGRATION_COMMAND.spec(locale), "bpermissions", MIGRATION, Predicates.alwaysFalse()); + super(CommandSpec.MIGRATION_COMMAND.localize(locale), "bpermissions", MIGRATION, Predicates.alwaysFalse()); } @Override @@ -124,14 +124,14 @@ public class MigrationBPermissions extends SubCommand { // Migrate one world at a time. log.log("Starting world migration."); - SafeIteration.iterate(worldManager.getAllWorlds(), world -> { + Iterators.iterate(worldManager.getAllWorlds(), world -> { log.log("Migrating world: " + world.getName()); // Migrate all groups log.log("Starting group migration in world " + world.getName() + "."); AtomicInteger groupCount = new AtomicInteger(0); - SafeIteration.iterate(world.getAll(CalculableType.GROUP), group -> { + Iterators.iterate(world.getAll(CalculableType.GROUP), group -> { String groupName = MigrationUtils.standardizeName(group.getName()); if (group.getName().equalsIgnoreCase(world.getDefaultGroup())) { groupName = NodeFactory.DEFAULT_GROUP_NAME; @@ -153,7 +153,7 @@ public class MigrationBPermissions extends SubCommand { // Migrate all users log.log("Starting user migration in world " + world.getName() + "."); AtomicInteger userCount = new AtomicInteger(0); - SafeIteration.iterate(world.getAll(CalculableType.USER), user -> { + Iterators.iterate(world.getAll(CalculableType.USER), user -> { // There is no mention of UUIDs in the API. I assume that name = uuid. idk? UUID uuid = BukkitMigrationUtils.lookupUuid(log, user.getName()); if (uuid == null) { 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 c0003a505..37bfceb0a 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,20 +28,20 @@ package me.lucko.luckperms.bukkit.migration; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +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.logging.ProgressLogger; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; +import me.lucko.luckperms.common.utils.Iterators; import me.lucko.luckperms.common.utils.Predicates; -import me.lucko.luckperms.common.utils.SafeIteration; import org.anjocaido.groupmanager.GlobalGroups; import org.anjocaido.groupmanager.GroupManager; @@ -62,7 +62,7 @@ import java.util.stream.Collectors; public class MigrationGroupManager extends SubCommand { public MigrationGroupManager(LocaleManager locale) { - super(CommandSpec.MIGRATION_GROUPMANAGER.spec(locale), "groupmanager", CommandPermission.MIGRATION, Predicates.is(0)); + super(CommandSpec.MIGRATION_GROUPMANAGER.localize(locale), "groupmanager", CommandPermission.MIGRATION, Predicates.is(0)); } @Override @@ -93,7 +93,7 @@ public class MigrationGroupManager extends SubCommand { GlobalGroups gg = GroupManager.getGlobalGroups(); AtomicInteger globalGroupCount = new AtomicInteger(0); - SafeIteration.iterate(gg.getGroupList(), g -> { + Iterators.iterate(gg.getGroupList(), g -> { String groupName = MigrationUtils.standardizeName(g.getName()); Group group = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join(); @@ -120,13 +120,13 @@ public class MigrationGroupManager extends SubCommand { // Collect data for all users and groups. log.log("Collecting user and group data."); - SafeIteration.iterate(worlds, String::toLowerCase, world -> { + Iterators.iterate(worlds, String::toLowerCase, world -> { log.log("Querying world " + world); WorldDataHolder wdh = wh.getWorldData(world); AtomicInteger groupWorldCount = new AtomicInteger(0); - SafeIteration.iterate(wdh.getGroupList(), group -> { + Iterators.iterate(wdh.getGroupList(), group -> { String groupName = MigrationUtils.standardizeName(group.getName()); groups.putIfAbsent(groupName, new HashSet<>()); @@ -160,7 +160,7 @@ public class MigrationGroupManager extends SubCommand { log.log("Migrated " + groupWorldCount.get() + " groups in world " + world); AtomicInteger userWorldCount = new AtomicInteger(0); - SafeIteration.iterate(wdh.getUserList(), user -> { + Iterators.iterate(wdh.getUserList(), user -> { UUID uuid = BukkitMigrationUtils.lookupUuid(log, user.getUUID()); if (uuid == null) { return; @@ -210,7 +210,7 @@ public class MigrationGroupManager extends SubCommand { log.log("Starting group migration."); AtomicInteger groupCount = new AtomicInteger(0); - SafeIteration.iterate(groups.entrySet(), e -> { + Iterators.iterate(groups.entrySet(), e -> { Group group = plugin.getStorage().createAndLoadGroup(e.getKey(), CreationCause.INTERNAL).join(); for (Node node : e.getValue()) { @@ -224,7 +224,7 @@ public class MigrationGroupManager extends SubCommand { log.log("Starting user migration."); AtomicInteger userCount = new AtomicInteger(0); - SafeIteration.iterate(users.entrySet(), e -> { + Iterators.iterate(users.entrySet(), e -> { User user = plugin.getStorage().loadUser(e.getKey(), null).join(); for (Node node : e.getValue()) { 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 8cb2b7ed7..ed3eec467 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 @@ -28,21 +28,21 @@ package me.lucko.luckperms.bukkit.migration; import com.platymuus.bukkit.permissions.PermissionsPlugin; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +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.logging.ProgressLogger; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; +import me.lucko.luckperms.common.utils.Iterators; import me.lucko.luckperms.common.utils.Predicates; -import me.lucko.luckperms.common.utils.SafeIteration; import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; @@ -54,7 +54,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class MigrationPermissionsBukkit extends SubCommand { public MigrationPermissionsBukkit(LocaleManager locale) { - super(CommandSpec.MIGRATION_COMMAND.spec(locale), "permissionsbukkit", CommandPermission.MIGRATION, Predicates.alwaysFalse()); + super(CommandSpec.MIGRATION_COMMAND.localize(locale), "permissionsbukkit", CommandPermission.MIGRATION, Predicates.alwaysFalse()); } @Override @@ -79,7 +79,7 @@ public class MigrationPermissionsBukkit extends SubCommand { ConfigurationSection groupsSection = config.getConfigurationSection("groups"); - SafeIteration.iterate(groupsSection.getKeys(false), key -> { + Iterators.iterate(groupsSection.getKeys(false), key -> { final String groupName = MigrationUtils.standardizeName(key); Group lpGroup = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join(); @@ -99,7 +99,7 @@ public class MigrationPermissionsBukkit extends SubCommand { ConfigurationSection usersSection = config.getConfigurationSection("users"); - SafeIteration.iterate(usersSection.getKeys(false), key -> { + Iterators.iterate(usersSection.getKeys(false), key -> { UUID uuid = BukkitMigrationUtils.lookupUuid(log, key); if (uuid == null) { return; 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 8355b1a1c..86e0241dd 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 @@ -28,13 +28,12 @@ package me.lucko.luckperms.bukkit.migration; import com.google.common.base.Strings; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +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.logging.ProgressLogger; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; @@ -42,8 +41,9 @@ import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; +import me.lucko.luckperms.common.utils.Iterators; import me.lucko.luckperms.common.utils.Predicates; -import me.lucko.luckperms.common.utils.SafeIteration; import org.bukkit.Bukkit; @@ -86,7 +86,7 @@ public class MigrationPermissionsEx extends SubCommand { } public MigrationPermissionsEx(LocaleManager locale) { - super(CommandSpec.MIGRATION_COMMAND.spec(locale), "permissionsex", CommandPermission.MIGRATION, Predicates.alwaysFalse()); + super(CommandSpec.MIGRATION_COMMAND.localize(locale), "permissionsex", CommandPermission.MIGRATION, Predicates.alwaysFalse()); } @SuppressWarnings("deprecation") @@ -117,7 +117,7 @@ public class MigrationPermissionsEx extends SubCommand { log.log("Starting group migration."); AtomicInteger groupCount = new AtomicInteger(0); Set ladders = new HashSet<>(); - SafeIteration.iterate(manager.getGroupList(), group -> { + Iterators.iterate(manager.getGroupList(), group -> { int groupWeight = maxWeight - group.getRank(); final String groupName = MigrationUtils.standardizeName(group.getName()); @@ -161,7 +161,7 @@ public class MigrationPermissionsEx extends SubCommand { // Increment the max weight from the group migrations. All user meta should override. int userWeight = maxWeight + 5; - SafeIteration.iterate(manager.getUsers(), user -> { + Iterators.iterate(manager.getUsers(), user -> { UUID u = BukkitMigrationUtils.lookupUuid(log, user.getIdentifier()); if (u == null) { return; 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 3ec9df80c..4b9c66ff8 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 @@ -35,21 +35,21 @@ import com.zaxxer.hikari.HikariDataSource; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.commands.migration.MigrationUtils; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.logging.ProgressLogger; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.StorageType; +import me.lucko.luckperms.common.utils.Iterators; import me.lucko.luckperms.common.utils.Predicates; -import me.lucko.luckperms.common.utils.SafeIteration; import org.bukkit.Bukkit; @@ -68,12 +68,12 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicInteger; -import static me.lucko.luckperms.common.commands.CommandPermission.MIGRATION; +import static me.lucko.luckperms.common.command.access.CommandPermission.MIGRATION; // Only supports the latest versions of the PP API. (it seems to change randomly almost every release) public class MigrationPowerfulPerms extends SubCommand { public MigrationPowerfulPerms(LocaleManager locale) { - super(CommandSpec.MIGRATION_POWERFULPERMS.spec(locale), "powerfulperms", MIGRATION, Predicates.not(5)); + super(CommandSpec.MIGRATION_POWERFULPERMS.localize(locale), "powerfulperms", MIGRATION, Predicates.not(5)); } @Override @@ -159,7 +159,7 @@ public class MigrationPowerfulPerms extends SubCommand { // Groups first. log.log("Starting group migration."); AtomicInteger groupCount = new AtomicInteger(0); - SafeIteration.iterate(groups, g -> { + Iterators.iterate(groups, g -> { maxWeight.set(Math.max(maxWeight.get(), g.getRank())); String groupName = MigrationUtils.standardizeName(g.getName()); @@ -219,7 +219,7 @@ public class MigrationPowerfulPerms extends SubCommand { maxWeight.addAndGet(5); // Migrate all users and their groups - SafeIteration.iterate(uuids, uuid -> { + Iterators.iterate(uuids, uuid -> { // Create a LuckPerms user for the UUID User user = plugin.getStorage().loadUser(uuid, null).join(); 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 38a2948e0..c9a0689cc 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,13 +28,12 @@ package me.lucko.luckperms.bukkit.migration; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +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.logging.ProgressLogger; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; @@ -42,8 +41,9 @@ import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; +import me.lucko.luckperms.common.utils.Iterators; import me.lucko.luckperms.common.utils.Predicates; -import me.lucko.luckperms.common.utils.SafeIteration; import org.bukkit.Bukkit; import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService; @@ -64,7 +64,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class MigrationZPermissions extends SubCommand { public MigrationZPermissions(LocaleManager locale) { - super(CommandSpec.MIGRATION_COMMAND.spec(locale), "zpermissions", CommandPermission.MIGRATION, Predicates.alwaysFalse()); + super(CommandSpec.MIGRATION_COMMAND.localize(locale), "zpermissions", CommandPermission.MIGRATION, Predicates.alwaysFalse()); } @Override @@ -104,7 +104,7 @@ public class MigrationZPermissions extends SubCommand { AtomicInteger groupCount = new AtomicInteger(0); AtomicInteger maxWeight = new AtomicInteger(0); - SafeIteration.iterate(internalService.getEntities(true), entity -> { + Iterators.iterate(internalService.getEntities(true), entity -> { String groupName = MigrationUtils.standardizeName(entity.getDisplayName()); Group group = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join(); @@ -138,7 +138,7 @@ public class MigrationZPermissions extends SubCommand { // Migrate all tracks log.log("Starting track migration."); AtomicInteger trackCount = new AtomicInteger(0); - SafeIteration.iterate(service.getAllTracks(), t -> { + Iterators.iterate(service.getAllTracks(), t -> { String trackName = MigrationUtils.standardizeName(t); Track track = plugin.getStorage().createAndLoadTrack(trackName, CreationCause.INTERNAL).join(); track.setGroups(service.getTrackGroups(t)); @@ -156,7 +156,7 @@ public class MigrationZPermissions extends SubCommand { Set usersToMigrate = new HashSet<>(userParents.keySet()); usersToMigrate.addAll(service.getAllPlayersUUID()); - SafeIteration.iterate(usersToMigrate, u -> { + Iterators.iterate(usersToMigrate, u -> { PermissionEntity entity = internalService.getEntity(null, u, false); String username = null; diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultChatHook.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultChatHook.java index 58f787db1..7e5e4eda4 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultChatHook.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultChatHook.java @@ -34,7 +34,7 @@ import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.common.caching.type.MetaAccumulator; import me.lucko.luckperms.common.caching.type.MetaCache; -import me.lucko.luckperms.common.commands.CommandManager; +import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java index 3faf2fc79..ab27c5a5d 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java @@ -34,7 +34,7 @@ import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.common.caching.type.PermissionCache; -import me.lucko.luckperms.common.commands.CommandManager; +import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeCommandExecutor.java b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeCommandExecutor.java index 2fa3a9ea2..3c04f98ee 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeCommandExecutor.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeCommandExecutor.java @@ -28,8 +28,8 @@ package me.lucko.luckperms.bungee; import com.google.common.base.Joiner; import com.google.common.base.Splitter; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.sender.Sender; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.plugin.Command; diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSchedulerAdapter.java b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSchedulerAdapter.java index b94786363..f419b718b 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSchedulerAdapter.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSchedulerAdapter.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.bungee; import me.lucko.luckperms.common.plugin.SchedulerAdapter; import me.lucko.luckperms.common.plugin.SchedulerTask; -import me.lucko.luckperms.common.utils.SafeIteration; +import me.lucko.luckperms.common.utils.Iterators; import net.md_5.bungee.api.scheduler.ScheduledTask; import net.md_5.bungee.api.scheduler.TaskScheduler; @@ -109,7 +109,7 @@ public class BungeeSchedulerAdapter implements SchedulerAdapter { @Override public void shutdown() { - SafeIteration.iterate(this.tasks, SchedulerTask::cancel); + Iterators.iterate(this.tasks, SchedulerTask::cancel); } private static final class BungeeSchedulerTask implements SchedulerTask { 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 212b54b82..062acfef1 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java @@ -27,9 +27,9 @@ package me.lucko.luckperms.bungee; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.bungee.event.TristateCheckEvent; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.sender.SenderFactory; +import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.SenderFactory; import me.lucko.luckperms.common.utils.TextUtils; import net.kyori.text.Component; diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java index 4ac213545..1a7086d6b 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java @@ -35,8 +35,7 @@ import me.lucko.luckperms.bungee.listeners.BungeeConnectionListener; import me.lucko.luckperms.bungee.listeners.BungeePermissionCheckListener; import me.lucko.luckperms.bungee.messaging.BungeeMessagingFactory; import me.lucko.luckperms.common.calculators.PlatformCalculatorFactory; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter; import me.lucko.luckperms.common.contexts.ContextManager; import me.lucko.luckperms.common.listener.ConnectionListener; @@ -46,6 +45,7 @@ import me.lucko.luckperms.common.managers.user.StandardUserManager; import me.lucko.luckperms.common.messaging.MessagingFactory; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.tasks.CacheHousekeepingTask; import me.lucko.luckperms.common.tasks.ExpireTemporaryTask; 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 f6a30a05b..b9ac65b4c 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 @@ -28,7 +28,7 @@ package me.lucko.luckperms.bungee.listeners; import me.lucko.luckperms.bungee.LPBungeePlugin; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.listener.AbstractConnectionListener; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.User; import net.md_5.bungee.api.chat.TextComponent; 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 53bdb3502..26774be2f 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 @@ -26,19 +26,19 @@ package me.lucko.luckperms.bungee.migration; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.impl.migration.MigrationUtils; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +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.logging.ProgressLogger; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; +import me.lucko.luckperms.common.utils.Iterators; import me.lucko.luckperms.common.utils.Predicates; -import me.lucko.luckperms.common.utils.SafeIteration; import net.alpenblock.bungeeperms.BungeePerms; import net.alpenblock.bungeeperms.Group; @@ -52,7 +52,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class MigrationBungeePerms extends SubCommand { public MigrationBungeePerms(LocaleManager locale) { - super(CommandSpec.MIGRATION_COMMAND.spec(locale), "bungeeperms", CommandPermission.MIGRATION, Predicates.alwaysFalse()); + super(CommandSpec.MIGRATION_COMMAND.localize(locale), "bungeeperms", CommandPermission.MIGRATION, Predicates.alwaysFalse()); } @Override @@ -82,7 +82,7 @@ public class MigrationBungeePerms extends SubCommand { // Migrate all groups. log.log("Starting group migration."); AtomicInteger groupCount = new AtomicInteger(0); - SafeIteration.iterate(groups, g -> { + Iterators.iterate(groups, g -> { int groupWeight = maxWeight - g.getRank(); // Make a LuckPerms group for the one being migrated @@ -104,7 +104,7 @@ public class MigrationBungeePerms extends SubCommand { // Increment the max weight from the group migrations. All user meta should override. int userWeight = maxWeight + 5; - SafeIteration.iterate(bp.getPermissionsManager().getBackEnd().loadUsers(), u -> { + Iterators.iterate(bp.getPermissionsManager().getBackEnd().loadUsers(), u -> { if (u.getUUID() == null) { log.logError("Could not parse UUID for user: " + u.getName()); return; diff --git a/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java index 8616dd682..72ca61104 100644 --- a/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java +++ b/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java @@ -30,12 +30,12 @@ import com.google.common.base.Strings; import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.context.ContextSet; -import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; 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.utils.DateUtil; import java.util.ArrayList; @@ -70,8 +70,8 @@ public class ExtendedLogEntry implements LogEntry { * * @return a new builder */ - public static ExtendedLogEntryBuilder build() { - return new ExtendedLogEntryBuilder(); + public static Builder build() { + return new Builder(); } private final long timestamp; @@ -207,7 +207,7 @@ public class ExtendedLogEntry implements LogEntry { return result; } - public static class ExtendedLogEntryBuilder implements LogEntry.Builder { + public static class Builder implements LogEntry.Builder { private long timestamp = 0L; private UUID actor = null; @@ -219,88 +219,88 @@ public class ExtendedLogEntry implements LogEntry { @Nonnull @Override - public ExtendedLogEntryBuilder setTimestamp(long timestamp) { + public Builder setTimestamp(long timestamp) { this.timestamp = timestamp; return this; } @Nonnull @Override - public ExtendedLogEntryBuilder setActor(@Nonnull UUID actor) { + public Builder setActor(@Nonnull UUID actor) { this.actor = Objects.requireNonNull(actor, "actor"); return this; } @Nonnull @Override - public ExtendedLogEntryBuilder setActorName(@Nonnull String actorName) { + public Builder setActorName(@Nonnull String actorName) { this.actorName = Objects.requireNonNull(actorName, "actorName"); return this; } @Nonnull @Override - public ExtendedLogEntryBuilder setType(@Nonnull Type type) { + public Builder setType(@Nonnull Type type) { this.type = Objects.requireNonNull(type, "type"); return this; } @Nonnull @Override - public ExtendedLogEntryBuilder setActed(UUID acted) { + public Builder setActed(UUID acted) { this.acted = acted; // nullable return this; } @Nonnull @Override - public ExtendedLogEntryBuilder setActedName(@Nonnull String actedName) { + public Builder setActedName(@Nonnull String actedName) { this.actedName = Objects.requireNonNull(actedName, "actedName"); return this; } @Nonnull @Override - public ExtendedLogEntryBuilder setAction(@Nonnull String action) { + public Builder setAction(@Nonnull String action) { this.action = Objects.requireNonNull(action, "action"); return this; } - public ExtendedLogEntryBuilder timestamp(long timestamp) { + public Builder timestamp(long timestamp) { return setTimestamp(timestamp); } - public ExtendedLogEntryBuilder actor(UUID actor) { + public Builder actor(UUID actor) { return setActor(actor); } - public ExtendedLogEntryBuilder actorName(String actorName) { + public Builder actorName(String actorName) { return setActorName(actorName); } - public ExtendedLogEntryBuilder type(Type type) { + public Builder type(Type type) { return setType(type); } - public ExtendedLogEntryBuilder acted(UUID acted) { + public Builder acted(UUID acted) { return setActed(acted); } - public ExtendedLogEntryBuilder actedName(String actedName) { + public Builder actedName(String actedName) { return setActedName(actedName); } - public ExtendedLogEntryBuilder action(String action) { + public Builder action(String action) { return setAction(action); } - public ExtendedLogEntryBuilder actor(Sender actor) { + public Builder actor(Sender actor) { actorName(actor.getNameWithLocation()); actor(actor.getUuid()); return this; } - public ExtendedLogEntryBuilder acted(PermissionHolder acted) { + public Builder acted(PermissionHolder acted) { if (acted.getType().isUser()) { actedName(((User) acted).getName().orElse("null")); acted(((User) acted).getUuid()); @@ -312,13 +312,13 @@ public class ExtendedLogEntry implements LogEntry { return this; } - public ExtendedLogEntryBuilder acted(Track track) { + public Builder acted(Track track) { actedName(track.getName()); type(Type.TRACK); return this; } - public ExtendedLogEntryBuilder action(Object... args) { + public Builder action(Object... args) { List parts = new ArrayList<>(); for (Object o : args) { @@ -367,7 +367,7 @@ public class ExtendedLogEntry implements LogEntry { @Override public String toString() { - return "ExtendedLogEntry.ExtendedLogEntryBuilder(" + + return "ExtendedLogEntry.Builder(" + "timestamp=" + this.timestamp + ", " + "actor=" + this.actor + ", " + "actorName=" + this.actorName + ", " + diff --git a/common/src/main/java/me/lucko/luckperms/common/actionlog/Log.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/Log.java index 1519a9564..3069c1597 100644 --- a/common/src/main/java/me/lucko/luckperms/common/actionlog/Log.java +++ b/common/src/main/java/me/lucko/luckperms/common/actionlog/Log.java @@ -44,7 +44,7 @@ public class Log { return new Builder(); } - public synchronized static Log empty() { + public static synchronized Log empty() { if (empty == null) { empty = builder().build(); } 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 77d4b4989..1ef9ede87 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 @@ -27,13 +27,13 @@ package me.lucko.luckperms.common.actionlog; import me.lucko.luckperms.api.event.log.LogBroadcastEvent; import me.lucko.luckperms.api.event.log.LogNotifyEvent; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.impl.log.LogNotify; -import me.lucko.luckperms.common.commands.sender.Sender; +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; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import java.util.Optional; 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 ea4b8c815..a2fb6ab55 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 @@ -26,9 +26,7 @@ package me.lucko.luckperms.common.backup; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.logging.ProgressLogger; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.Track; @@ -36,6 +34,7 @@ import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.references.HolderType; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.Storage; import me.lucko.luckperms.common.utils.Cycle; @@ -56,6 +55,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Consumer; +import java.util.function.Supplier; import java.util.stream.Collectors; /** @@ -181,7 +181,7 @@ public class Exporter implements Runnable { write(writer, "# Export users"); // divide into 16 pools. - Cycle> userPools = new Cycle<>(CommandUtils.nInstances(32, ArrayList::new)); + Cycle> userPools = new Cycle<>(nInstances(32, ArrayList::new)); for (UUID uuid : users) { userPools.next().add(uuid); } @@ -265,4 +265,12 @@ public class Exporter implements Runnable { e.printStackTrace(); } } + + private static List nInstances(int count, Supplier supplier) { + List ret = new ArrayList<>(count); + for (int i = 0; i < count; i++) { + ret.add(supplier.get()); + } + return ret; + } } 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 263972633..b44b3e30a 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 @@ -28,12 +28,11 @@ package me.lucko.luckperms.common.backup; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.sender.DummySender; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.sender.DummySender; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Cycle; import java.util.ArrayList; @@ -45,6 +44,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Supplier; import java.util.stream.Collectors; /** @@ -95,7 +95,7 @@ public class Importer implements Runnable { } // divide commands up into pools - Cycle> commandPools = new Cycle<>(CommandUtils.nInstances(128, ArrayList::new)); + Cycle> commandPools = new Cycle<>(nInstances(128, ArrayList::new)); String lastTarget = null; for (ImportCommand cmd : this.toExecute) { @@ -151,7 +151,7 @@ public class Importer implements Runnable { long endTime = System.currentTimeMillis(); double seconds = (endTime - startTime) / 1000; - int errors = (int) this.toExecute.stream().filter(v -> !v.getResult().asBoolean()).count(); + int errors = (int) this.toExecute.stream().filter(v -> v.getResult().wasFailure()).count(); switch (errors) { case 0: @@ -167,7 +167,7 @@ public class Importer implements Runnable { AtomicInteger errIndex = new AtomicInteger(1); for (ImportCommand e : this.toExecute) { - if (e.getResult() != null && !e.getResult().asBoolean()) { + if (e.getResult() != null && e.getResult().wasFailure()) { this.notify.forEach(s -> { Message.IMPORT_END_ERROR_HEADER.send(s, errIndex.get(), e.getId(), e.getCommand(), e.getResult().toString()); for (String out : e.getOutput()) { @@ -183,7 +183,7 @@ public class Importer implements Runnable { private void sendProgress(int processedCount) { int percent = (processedCount * 100) / this.commands.size(); - int errors = (int) this.toExecute.stream().filter(v -> v.isCompleted() && !v.getResult().asBoolean()).count(); + int errors = (int) this.toExecute.stream().filter(v -> v.isCompleted() && v.getResult().wasFailure()).count(); if (errors == 1) { this.notify.forEach(s -> Message.IMPORT_PROGRESS_SIN.send(s, percent, processedCount, this.commands.size(), errors)); @@ -315,4 +315,12 @@ public class Importer implements Runnable { } } + private static List nInstances(int count, Supplier supplier) { + List ret = new ArrayList<>(count); + for (int i = 0; i < count; i++) { + ret.add(supplier.get()); + } + return ret; + } + } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java similarity index 87% rename from common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java rename to common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java index a7ec37128..993bef626 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java @@ -23,42 +23,44 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands; +package me.lucko.luckperms.common.command; import com.google.common.collect.ImmutableList; -import me.lucko.luckperms.common.commands.abstraction.Command; -import me.lucko.luckperms.common.commands.impl.group.CreateGroup; -import me.lucko.luckperms.common.commands.impl.group.DeleteGroup; -import me.lucko.luckperms.common.commands.impl.group.GroupMainCommand; -import me.lucko.luckperms.common.commands.impl.group.ListGroups; -import me.lucko.luckperms.common.commands.impl.log.LogMainCommand; -import me.lucko.luckperms.common.commands.impl.migration.MigrationMainCommand; -import me.lucko.luckperms.common.commands.impl.misc.ApplyEditsCommand; -import me.lucko.luckperms.common.commands.impl.misc.BulkUpdateCommand; -import me.lucko.luckperms.common.commands.impl.misc.CheckCommand; -import me.lucko.luckperms.common.commands.impl.misc.DebugCommand; -import me.lucko.luckperms.common.commands.impl.misc.EditorCommand; -import me.lucko.luckperms.common.commands.impl.misc.ExportCommand; -import me.lucko.luckperms.common.commands.impl.misc.ImportCommand; -import me.lucko.luckperms.common.commands.impl.misc.InfoCommand; -import me.lucko.luckperms.common.commands.impl.misc.NetworkSyncCommand; -import me.lucko.luckperms.common.commands.impl.misc.ReloadConfigCommand; -import me.lucko.luckperms.common.commands.impl.misc.SearchCommand; -import me.lucko.luckperms.common.commands.impl.misc.SyncCommand; -import me.lucko.luckperms.common.commands.impl.misc.TreeCommand; -import me.lucko.luckperms.common.commands.impl.misc.VerboseCommand; -import me.lucko.luckperms.common.commands.impl.track.CreateTrack; -import me.lucko.luckperms.common.commands.impl.track.DeleteTrack; -import me.lucko.luckperms.common.commands.impl.track.ListTracks; -import me.lucko.luckperms.common.commands.impl.track.TrackMainCommand; -import me.lucko.luckperms.common.commands.impl.user.UserMainCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; +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.utils.ArgumentParser; +import me.lucko.luckperms.common.command.utils.MessageUtils; +import me.lucko.luckperms.common.commands.group.CreateGroup; +import me.lucko.luckperms.common.commands.group.DeleteGroup; +import me.lucko.luckperms.common.commands.group.GroupMainCommand; +import me.lucko.luckperms.common.commands.group.ListGroups; +import me.lucko.luckperms.common.commands.log.LogMainCommand; +import me.lucko.luckperms.common.commands.migration.MigrationMainCommand; +import me.lucko.luckperms.common.commands.misc.ApplyEditsCommand; +import me.lucko.luckperms.common.commands.misc.BulkUpdateCommand; +import me.lucko.luckperms.common.commands.misc.CheckCommand; +import me.lucko.luckperms.common.commands.misc.DebugCommand; +import me.lucko.luckperms.common.commands.misc.EditorCommand; +import me.lucko.luckperms.common.commands.misc.ExportCommand; +import me.lucko.luckperms.common.commands.misc.ImportCommand; +import me.lucko.luckperms.common.commands.misc.InfoCommand; +import me.lucko.luckperms.common.commands.misc.NetworkSyncCommand; +import me.lucko.luckperms.common.commands.misc.ReloadConfigCommand; +import me.lucko.luckperms.common.commands.misc.SearchCommand; +import me.lucko.luckperms.common.commands.misc.SyncCommand; +import me.lucko.luckperms.common.commands.misc.TreeCommand; +import me.lucko.luckperms.common.commands.misc.VerboseCommand; +import me.lucko.luckperms.common.commands.track.CreateTrack; +import me.lucko.luckperms.common.commands.track.DeleteTrack; +import me.lucko.luckperms.common.commands.track.ListTracks; +import me.lucko.luckperms.common.commands.track.TrackMainCommand; +import me.lucko.luckperms.common.commands.user.UserMainCommand; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.utils.TextUtils; import net.kyori.text.TextComponent; @@ -99,7 +101,6 @@ public class CommandManager { public CommandManager(LuckPermsPlugin plugin) { this.plugin = plugin; - LocaleManager locale = plugin.getLocaleManager(); this.mainCommands = ImmutableList.builder() @@ -159,7 +160,7 @@ public class CommandManager { // Handle no arguments if (arguments.isEmpty() || (arguments.size() == 1 && arguments.get(0).trim().isEmpty())) { - CommandUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2."); + MessageUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2."); if (this.mainCommands.stream().anyMatch(c -> c.shouldDisplay() && c.isAuthorized(sender))) { Message.VIEW_AVAILABLE_COMMANDS_PROMPT.send(sender, label); } else { @@ -257,7 +258,7 @@ public class CommandManager { } private void sendCommandUsage(Sender sender, String label) { - CommandUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2."); + MessageUtils.sendPluginMessage(sender, "&2Running &bLuckPerms v" + this.plugin.getBootstrap().getVersion() + "&2."); this.mainCommands.stream() .filter(Command::shouldDisplay) .filter(c -> c.isAuthorized(sender)) @@ -282,29 +283,29 @@ public class CommandManager { } public static CommandResult handleException(CommandException e, Sender sender, String label, Command command) { - if (e instanceof ArgumentUtils.ArgumentException) { - if (e instanceof ArgumentUtils.DetailedUsageException) { + if (e instanceof ArgumentParser.ArgumentException) { + if (e instanceof ArgumentParser.DetailedUsageException) { command.sendDetailedUsage(sender, label); return CommandResult.INVALID_ARGS; } - if (e instanceof ArgumentUtils.InvalidServerWorldException) { + if (e instanceof ArgumentParser.InvalidServerWorldException) { Message.SERVER_WORLD_INVALID_ENTRY.send(sender); return CommandResult.INVALID_ARGS; } - if (e instanceof ArgumentUtils.PastDateException) { + if (e instanceof ArgumentParser.PastDateException) { Message.PAST_DATE_ERROR.send(sender); return CommandResult.INVALID_ARGS; } - if (e instanceof ArgumentUtils.InvalidDateException) { - Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentUtils.InvalidDateException) e).getInvalidDate()); + if (e instanceof ArgumentParser.InvalidDateException) { + Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentParser.InvalidDateException) e).getInvalidDate()); return CommandResult.INVALID_ARGS; } - if (e instanceof ArgumentUtils.InvalidPriorityException) { - Message.META_INVALID_PRIORITY.send(sender, ((ArgumentUtils.InvalidPriorityException) e).getInvalidPriority()); + if (e instanceof ArgumentParser.InvalidPriorityException) { + Message.META_INVALID_PRIORITY.send(sender, ((ArgumentParser.InvalidPriorityException) e).getInvalidPriority()); return CommandResult.INVALID_ARGS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/CommandResult.java b/common/src/main/java/me/lucko/luckperms/common/command/CommandResult.java similarity index 83% rename from common/src/main/java/me/lucko/luckperms/common/commands/CommandResult.java rename to common/src/main/java/me/lucko/luckperms/common/command/CommandResult.java index ad935589a..036142987 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/CommandResult.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/CommandResult.java @@ -23,8 +23,11 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands; +package me.lucko.luckperms.common.command; +/** + * Represents the result of a commands execution + */ public enum CommandResult { SUCCESS(true), FAILURE(false), @@ -34,18 +37,14 @@ public enum CommandResult { INVALID_ARGS(false), NO_PERMISSION(false); - public static CommandResult of(boolean b) { - return b ? SUCCESS : FAILURE; + private final boolean wasSuccess; + + CommandResult(boolean wasSuccess) { + this.wasSuccess = wasSuccess; } - private final boolean value; - - CommandResult(boolean value) { - this.value = value; - } - - public boolean asBoolean() { - return this.value; + public boolean wasFailure() { + return !this.wasSuccess; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/Command.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/Command.java similarity index 87% rename from common/src/main/java/me/lucko/luckperms/common/commands/abstraction/Command.java rename to common/src/main/java/me/lucko/luckperms/common/command/abstraction/Command.java index 3837970d4..182b67d9d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/Command.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/Command.java @@ -23,17 +23,16 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.abstraction; +package me.lucko.luckperms.common.command.abstraction; import com.google.common.collect.ImmutableList; -import me.lucko.luckperms.common.commands.Arg; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.LocalizedSpec; +import me.lucko.luckperms.common.command.CommandResult; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.Collections; @@ -58,7 +57,7 @@ public abstract class Command { * Contains details about usage, description, etc */ @Nonnull - private final LocalizedSpec spec; + private final LocalizedCommandSpec spec; /** * The name of the command. Should be properly capitalised. @@ -84,7 +83,7 @@ public abstract class Command { @Nullable private final List> children; - public Command(@Nonnull LocalizedSpec spec, @Nonnull String name, @Nullable CommandPermission permission, @Nonnull Predicate argumentCheck, @Nullable List> children) { + public Command(@Nonnull LocalizedCommandSpec spec, @Nonnull String name, @Nullable CommandPermission permission, @Nonnull Predicate argumentCheck, @Nullable List> children) { this.spec = spec; this.name = name; this.permission = permission; @@ -92,11 +91,11 @@ public abstract class Command { this.children = children == null ? null : ImmutableList.copyOf(children); } - public Command(@Nonnull LocalizedSpec spec, @Nonnull String name, @Nullable CommandPermission permission, @Nonnull Predicate argumentCheck) { + public Command(@Nonnull LocalizedCommandSpec spec, @Nonnull String name, @Nullable CommandPermission permission, @Nonnull Predicate argumentCheck) { this(spec, name, permission, argumentCheck, null); } - public Command(@Nonnull LocalizedSpec spec, @Nonnull String name, @Nonnull Predicate argumentCheck) { + public Command(@Nonnull LocalizedCommandSpec spec, @Nonnull String name, @Nonnull Predicate argumentCheck) { this(spec, name, null, argumentCheck, null); } @@ -106,7 +105,7 @@ public abstract class Command { * @return the command spec */ @Nonnull - public LocalizedSpec getSpec() { + public LocalizedCommandSpec getSpec() { return this.spec; } @@ -178,7 +177,7 @@ public abstract class Command { * * @return the commands arguments */ - public Optional> getArgs() { + public Optional> getArgs() { return Optional.ofNullable(getSpec().args()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/CommandException.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/CommandException.java similarity index 96% rename from common/src/main/java/me/lucko/luckperms/common/commands/CommandException.java rename to common/src/main/java/me/lucko/luckperms/common/command/abstraction/CommandException.java index c1acded52..263be0f16 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/CommandException.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/CommandException.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands; +package me.lucko.luckperms.common.command.abstraction; /** * Exception to be thrown if there is an error processing a command diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/MainCommand.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/MainCommand.java similarity index 91% rename from common/src/main/java/me/lucko/luckperms/common/commands/abstraction/MainCommand.java rename to common/src/main/java/me/lucko/luckperms/common/command/abstraction/MainCommand.java index e6d26b393..03ad1a1bc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/MainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/MainCommand.java @@ -23,16 +23,15 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.abstraction; +package me.lucko.luckperms.common.command.abstraction; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.LocalizedSpec; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.utils.MessageUtils; +import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; +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.utils.Predicates; import java.util.ArrayList; @@ -50,7 +49,7 @@ public abstract class MainCommand extends Command { // equals 2 if the command does take a mid argument, e.g. /lp user sub-command.... private final int minArgs; - public MainCommand(LocalizedSpec spec, String name, int minArgs, List> children) { + public MainCommand(LocalizedCommandSpec spec, String name, int minArgs, List> children) { super(spec, name, null, Predicates.alwaysFalse(), children); this.minArgs = minArgs; } @@ -172,7 +171,7 @@ public abstract class MainCommand extends Command { .collect(Collectors.toList()); if (!subs.isEmpty()) { - CommandUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format(getUsage(), label) + " ...)"); + MessageUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format(getUsage(), label) + " ...)"); for (Command s : subs) { s.sendUsage(sender, label); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SharedMainCommand.java similarity index 84% rename from common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedMainCommand.java rename to common/src/main/java/me/lucko/luckperms/common/command/abstraction/SharedMainCommand.java index 4f50814f8..3e66630b3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SharedMainCommand.java @@ -23,17 +23,16 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.abstraction; +package me.lucko.luckperms.common.command.abstraction; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.LocalizedSpec; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +import me.lucko.luckperms.common.command.utils.MessageUtils; +import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; import java.util.ArrayList; @@ -56,7 +55,7 @@ public class SharedMainCommand extends SubCommand */ private final boolean user; - public SharedMainCommand(LocalizedSpec spec, String name, boolean user, List secondaryCommands) { + public SharedMainCommand(LocalizedCommandSpec spec, String name, boolean user, List secondaryCommands) { super(spec, name, null, Predicates.alwaysFalse()); this.secondaryCommands = secondaryCommands; this.user = user; @@ -144,9 +143,9 @@ public class SharedMainCommand extends SubCommand if (!subs.isEmpty()) { if (user) { - CommandUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s user " + getName().toLowerCase() + " ...)", label)); + MessageUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s user " + getName().toLowerCase() + " ...)", label)); } else { - CommandUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s group " + getName().toLowerCase() + " ...)", label)); + MessageUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s group " + getName().toLowerCase() + " ...)", label)); } for (SharedSubCommand s : subs) { @@ -159,29 +158,29 @@ public class SharedMainCommand extends SubCommand } private static CommandResult handleException(CommandException e, Sender sender, SharedSubCommand command) { - if (e instanceof ArgumentUtils.ArgumentException) { - if (e instanceof ArgumentUtils.DetailedUsageException) { + if (e instanceof ArgumentParser.ArgumentException) { + if (e instanceof ArgumentParser.DetailedUsageException) { command.sendDetailedUsage(sender); return CommandResult.INVALID_ARGS; } - if (e instanceof ArgumentUtils.InvalidServerWorldException) { + if (e instanceof ArgumentParser.InvalidServerWorldException) { Message.SERVER_WORLD_INVALID_ENTRY.send(sender); return CommandResult.INVALID_ARGS; } - if (e instanceof ArgumentUtils.PastDateException) { + if (e instanceof ArgumentParser.PastDateException) { Message.PAST_DATE_ERROR.send(sender); return CommandResult.INVALID_ARGS; } - if (e instanceof ArgumentUtils.InvalidDateException) { - Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentUtils.InvalidDateException) e).getInvalidDate()); + if (e instanceof ArgumentParser.InvalidDateException) { + Message.ILLEGAL_DATE_ERROR.send(sender, ((ArgumentParser.InvalidDateException) e).getInvalidDate()); return CommandResult.INVALID_ARGS; } - if (e instanceof ArgumentUtils.InvalidPriorityException) { - Message.META_INVALID_PRIORITY.send(sender, ((ArgumentUtils.InvalidPriorityException) e).getInvalidPriority()); + if (e instanceof ArgumentParser.InvalidPriorityException) { + Message.META_INVALID_PRIORITY.send(sender, ((ArgumentParser.InvalidPriorityException) e).getInvalidPriority()); return CommandResult.INVALID_ARGS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedSubCommand.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SharedSubCommand.java similarity index 68% rename from common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedSubCommand.java rename to common/src/main/java/me/lucko/luckperms/common/command/abstraction/SharedSubCommand.java index eda42409a..84ed46902 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SharedSubCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SharedSubCommand.java @@ -23,19 +23,16 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.abstraction; +package me.lucko.luckperms.common.command.abstraction; -import me.lucko.luckperms.common.commands.Arg; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.LocalizedSpec; -import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.MessageUtils; +import me.lucko.luckperms.common.locale.command.Argument; +import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; import me.lucko.luckperms.common.model.PermissionHolder; -import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import java.util.Collections; import java.util.List; @@ -47,7 +44,7 @@ import java.util.function.Predicate; */ public abstract class SharedSubCommand { - private final LocalizedSpec spec; + private final LocalizedCommandSpec spec; /** * The name of the sub command @@ -65,7 +62,7 @@ public abstract class SharedSubCommand { */ private final Predicate argumentCheck; - public SharedSubCommand(LocalizedSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission, Predicate argumentCheck) { + public SharedSubCommand(LocalizedCommandSpec spec, String name, CommandPermission userPermission, CommandPermission groupPermission, Predicate argumentCheck) { this.spec = spec; this.name = name; this.userPermission = userPermission; @@ -79,7 +76,7 @@ public abstract class SharedSubCommand { return Collections.emptyList(); } - public LocalizedSpec getSpec() { + public LocalizedCommandSpec getSpec() { return this.spec; } @@ -103,21 +100,21 @@ public abstract class SharedSubCommand { StringBuilder sb = new StringBuilder(); if (getArgs() != null) { sb.append("&3 - &7"); - for (Arg arg : getArgs()) { + for (Argument arg : getArgs()) { sb.append(arg.asPrettyString()).append(" "); } } - CommandUtils.sendPluginMessage(sender, "&3> &a" + getName() + sb.toString()); + MessageUtils.sendPluginMessage(sender, "&3> &a" + getName() + sb.toString()); } public void sendDetailedUsage(Sender sender) { - CommandUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName()); - CommandUtils.sendPluginMessage(sender, "&b> &7" + getDescription()); + MessageUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName()); + MessageUtils.sendPluginMessage(sender, "&b> &7" + getDescription()); if (getArgs() != null) { - CommandUtils.sendPluginMessage(sender, "&3Arguments:"); - for (Arg arg : getArgs()) { - CommandUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription()); + MessageUtils.sendPluginMessage(sender, "&3Arguments:"); + for (Argument arg : getArgs()) { + MessageUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription()); } } } @@ -130,24 +127,8 @@ public abstract class SharedSubCommand { return this.spec.description(); } - public List getArgs() { + public List getArgs() { return this.spec.args(); } - public static void save(PermissionHolder holder, Sender sender, LuckPermsPlugin plugin) { - if (holder.getType().isUser()) { - User user = ((User) holder); - SubCommand.save(user, sender, plugin); - return; - } - - if (holder.getType().isGroup()) { - Group group = ((Group) holder); - SubCommand.save(group, sender, plugin); - return; - } - - throw new IllegalArgumentException(); - } - } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SingleCommand.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SingleCommand.java similarity index 71% rename from common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SingleCommand.java rename to common/src/main/java/me/lucko/luckperms/common/command/abstraction/SingleCommand.java index fac976349..cadf9249a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SingleCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SingleCommand.java @@ -23,16 +23,15 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.abstraction; +package me.lucko.luckperms.common.command.abstraction; -import me.lucko.luckperms.common.commands.Arg; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.LocalizedSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.MessageUtils; +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 java.util.List; import java.util.function.Predicate; @@ -42,7 +41,7 @@ import java.util.function.Predicate; */ public abstract class SingleCommand extends Command { - public SingleCommand(LocalizedSpec spec, String name, CommandPermission permission, Predicate argumentCheck) { + public SingleCommand(LocalizedCommandSpec spec, String name, CommandPermission permission, Predicate argumentCheck) { super(spec, name, permission, argumentCheck, null); } @@ -58,22 +57,22 @@ public abstract class SingleCommand extends Command { StringBuilder sb = new StringBuilder(); if (getArgs().isPresent()) { sb.append("&3 - &7"); - for (Arg arg : getArgs().get()) { + for (Argument arg : getArgs().get()) { sb.append(arg.asPrettyString()).append(" "); } } - CommandUtils.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString()); + MessageUtils.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString()); } @Override public void sendDetailedUsage(Sender sender, String label) { - CommandUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName()); - CommandUtils.sendPluginMessage(sender, "&b> &7" + getDescription()); + MessageUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName()); + MessageUtils.sendPluginMessage(sender, "&b> &7" + getDescription()); if (getArgs().isPresent()) { - CommandUtils.sendPluginMessage(sender, "&3Arguments:"); - for (Arg arg : getArgs().get()) { - CommandUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription()); + MessageUtils.sendPluginMessage(sender, "&3Arguments:"); + for (Argument arg : getArgs().get()) { + MessageUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription()); } } } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SubCommand.java b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SubCommand.java new file mode 100644 index 000000000..576398e67 --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/command/abstraction/SubCommand.java @@ -0,0 +1,75 @@ +/* + * 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.abstraction; + +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.MessageUtils; +import me.lucko.luckperms.common.locale.command.Argument; +import me.lucko.luckperms.common.locale.command.LocalizedCommandSpec; +import me.lucko.luckperms.common.sender.Sender; + +import java.util.function.Predicate; + +/** + * Abstract SubCommand class + */ +public abstract class SubCommand extends Command { + + public SubCommand(LocalizedCommandSpec spec, String name, CommandPermission permission, Predicate argumentCheck) { + super(spec, name, permission, argumentCheck); + } + + /** + * Send the command usage to a sender + * + * @param sender the sender to send the usage to + */ + @Override + public void sendUsage(Sender sender, String label) { + StringBuilder sb = new StringBuilder(); + if (getArgs().isPresent()) { + sb.append("&3 - &7"); + for (Argument arg : getArgs().get()) { + sb.append(arg.asPrettyString()).append(" "); + } + } + + MessageUtils.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString()); + } + + @Override + public void sendDetailedUsage(Sender sender, String label) { + MessageUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName()); + MessageUtils.sendPluginMessage(sender, "&b> &7" + getDescription()); + if (getArgs().isPresent()) { + MessageUtils.sendPluginMessage(sender, "&3Arguments:"); + for (Argument arg : getArgs().get()) { + MessageUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription()); + } + } + } + +} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/ArgumentPermissions.java b/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java similarity index 85% rename from common/src/main/java/me/lucko/luckperms/common/commands/ArgumentPermissions.java rename to common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java index fdba227dd..5323d615f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/ArgumentPermissions.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java @@ -23,21 +23,24 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands; +package me.lucko.luckperms.common.command.access; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.ContextSet; -import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import java.util.Map; import java.util.function.BiFunction; import java.util.function.Function; +/** + * Implements argument based permission checks for use in command implementations. + */ public final class ArgumentPermissions { private static final String USER_MODIFY_SELF = CommandPermission.ROOT + "modify.user.self"; private static final String USER_MODIFY_OTHERS = CommandPermission.ROOT + "modify.user.others"; @@ -52,6 +55,15 @@ public final class ArgumentPermissions { private static final String CONTEXT_USE_GLOBAL = CommandPermission.ROOT + "usecontext.global"; private static final BiFunction CONTEXT_USE = (k, v) -> CommandPermission.ROOT + "usecontext." + k + "." + v; + /** + * Checks if the sender has permission to use the given arguments + * + * @param plugin the plugin instance + * @param sender the sender to check + * @param base the base permission for the command + * @param args the arguments the sender is trying to use + * @return true if the sender should NOT be allowed to use the arguments, true if they should + */ public static boolean checkArguments(LuckPermsPlugin plugin, Sender sender, CommandPermission base, String... args) { if (!plugin.getConfiguration().get(ConfigKeys.USE_ARGUMENT_BASED_COMMAND_PERMISSIONS)) { return false; @@ -69,6 +81,15 @@ public final class ArgumentPermissions { return !sender.hasPermission(permission.toString()); } + /** + * Checks if the sender has permission to modify the given target + * + * @param plugin the plugin instance + * @param sender the sender to check + * @param base the base permission for the command + * @param target the object the sender is truing to modify + * @return true if the sender should NOT be allowed to modify the target, true if they should + */ public static boolean checkModifyPerms(LuckPermsPlugin plugin, Sender sender, CommandPermission base, Object target) { if (!plugin.getConfiguration().get(ConfigKeys.USE_ARGUMENT_BASED_COMMAND_PERMISSIONS)) { return false; @@ -125,6 +146,15 @@ public final class ArgumentPermissions { } } + /** + * Checks if the sender has permission to view the given target + * + * @param plugin the plugin instance + * @param sender the sender to check + * @param base the base permission for the command + * @param target the object the sender is truing to view + * @return true if the sender should NOT be allowed to view the target, true if they should + */ public static boolean checkViewPerms(LuckPermsPlugin plugin, Sender sender, CommandPermission base, Object target) { if (!plugin.getConfiguration().get(ConfigKeys.USE_ARGUMENT_BASED_COMMAND_PERMISSIONS)) { return false; @@ -181,6 +211,15 @@ public final class ArgumentPermissions { return false; } + /** + * Checks if the sender has permission to act within a given set of contexts + * + * @param plugin the plugin instance + * @param sender the sender to check + * @param base the base permission for the command + * @param contextSet the contexts the sender is trying to act within + * @return true if the sender should NOT be allowed to act, true if they should + */ public static boolean checkContext(LuckPermsPlugin plugin, Sender sender, CommandPermission base, ContextSet contextSet) { if (!plugin.getConfiguration().get(ConfigKeys.USE_ARGUMENT_BASED_COMMAND_PERMISSIONS)) { return false; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/CommandPermission.java b/common/src/main/java/me/lucko/luckperms/common/command/access/CommandPermission.java similarity index 92% rename from common/src/main/java/me/lucko/luckperms/common/commands/CommandPermission.java rename to common/src/main/java/me/lucko/luckperms/common/command/access/CommandPermission.java index 904311be1..dde4025c5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/CommandPermission.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/access/CommandPermission.java @@ -23,16 +23,16 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands; +package me.lucko.luckperms.common.command.access; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.sender.Sender; -import static me.lucko.luckperms.common.commands.CommandPermission.Type.GROUP; -import static me.lucko.luckperms.common.commands.CommandPermission.Type.LOG; -import static me.lucko.luckperms.common.commands.CommandPermission.Type.NONE; -import static me.lucko.luckperms.common.commands.CommandPermission.Type.SPONGE; -import static me.lucko.luckperms.common.commands.CommandPermission.Type.TRACK; -import static me.lucko.luckperms.common.commands.CommandPermission.Type.USER; +import static me.lucko.luckperms.common.command.access.CommandPermission.Type.GROUP; +import static me.lucko.luckperms.common.command.access.CommandPermission.Type.LOG; +import static me.lucko.luckperms.common.command.access.CommandPermission.Type.NONE; +import static me.lucko.luckperms.common.command.access.CommandPermission.Type.SPONGE; +import static me.lucko.luckperms.common.command.access.CommandPermission.Type.TRACK; +import static me.lucko.luckperms.common.command.access.CommandPermission.Type.USER; /** * An enumeration of the permissions required to execute built in LuckPerms commands. diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/utils/ArgumentUtils.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentParser.java similarity index 87% rename from common/src/main/java/me/lucko/luckperms/common/commands/utils/ArgumentUtils.java rename to common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentParser.java index 63ca749da..6f9d591f4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/utils/ArgumentUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentParser.java @@ -23,12 +23,12 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.utils; +package me.lucko.luckperms.common.command.utils; import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.CommandException; +import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.model.TemporaryModifier; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.storage.DataConstraints; @@ -41,13 +41,13 @@ import java.util.Optional; /** * Utility class to help process arguments, and throw checked exceptions if the arguments are invalid. */ -public class ArgumentUtils { +public class ArgumentParser { - public static String handleString(int index, List args) { + public static String parseString(int index, List args) { return args.get(index).replace("{SPACE}", " "); } - public static String handleStringOrElse(int index, List args, String other) { + public static String parseStringOrElse(int index, List args, String other) { if (index < 0 || index >= args.size()) { return other; } @@ -55,7 +55,7 @@ public class ArgumentUtils { return args.get(index).replace("{SPACE}", " "); } - public static int handleIntOrElse(int index, List args, int other) { + public static int parseIntOrElse(int index, List args, int other) { if (index < 0 || index >= args.size()) { return other; } @@ -67,7 +67,7 @@ public class ArgumentUtils { } } - public static String handleName(int index, List args) throws ArgumentException { + public static String parseName(int index, List args) throws ArgumentException { String groupName = args.get(index).toLowerCase(); if (!DataConstraints.GROUP_NAME_TEST.test(groupName)) { throw new DetailedUsageException(); @@ -75,7 +75,7 @@ public class ArgumentUtils { return groupName; } - public static String handleNameWithSpace(int index, List args) throws ArgumentException { + public static String parseNameWithSpace(int index, List args) throws ArgumentException { String groupName = args.get(index).toLowerCase(); if (!DataConstraints.GROUP_NAME_TEST_ALLOW_SPACE.test(groupName)) { throw new DetailedUsageException(); @@ -83,7 +83,7 @@ public class ArgumentUtils { return groupName; } - public static boolean handleBoolean(int index, List args) { + public static boolean parseBoolean(int index, List args) { if (index < args.size()) { String bool = args.get(index); if (bool.equalsIgnoreCase("true") || bool.equalsIgnoreCase("false")) { @@ -95,7 +95,7 @@ public class ArgumentUtils { return true; } - public static long handleDuration(int index, List args) throws ArgumentException { + public static long parseDuration(int index, List args) throws ArgumentException { long duration; try { duration = Long.parseLong(args.get(index)); @@ -114,7 +114,7 @@ public class ArgumentUtils { return duration; } - public static Optional handleTemporaryModifier(int index, List args) { + public static Optional parseTemporaryModifier(int index, List args) { if (index < 0 || index >= args.size()) { return Optional.empty(); } @@ -129,7 +129,7 @@ public class ArgumentUtils { } } - public static MutableContextSet handleContext(int fromIndex, List args, LuckPermsPlugin plugin) throws CommandException { + public static MutableContextSet parseContext(int fromIndex, List args, LuckPermsPlugin plugin) throws CommandException { if (args.size() > fromIndex) { MutableContextSet set = MutableContextSet.create(); @@ -169,7 +169,7 @@ public class ArgumentUtils { } } - public static MutableContextSet sanitizeContexts(MutableContextSet set) throws ArgumentException { + private static MutableContextSet sanitizeContexts(MutableContextSet set) throws ArgumentException { // remove any potential "global" context mappings set.remove(Contexts.SERVER_KEY, "global"); set.remove(Contexts.WORLD_KEY, "global"); @@ -213,7 +213,7 @@ public class ArgumentUtils { return set; } - public static int handlePriority(int index, List args) throws ArgumentException { + public static int parsePriority(int index, List args) throws ArgumentException { try { return Integer.parseInt(args.get(index)); } catch (NumberFormatException e) { @@ -221,7 +221,7 @@ public class ArgumentUtils { } } - public static ImmutableContextSet handleContextSponge(int fromIndex, List args) { + public static ImmutableContextSet parseContextSponge(int fromIndex, List args) { if (args.size() <= fromIndex) { return ImmutableContextSet.empty(); } @@ -248,7 +248,7 @@ public class ArgumentUtils { return contextSet.makeImmutable(); } - public static abstract class ArgumentException extends CommandException {} + public abstract static class ArgumentException extends CommandException {} public static class DetailedUsageException extends ArgumentException {} public static class InvalidServerWorldException extends ArgumentException {} public static class PastDateException extends ArgumentException {} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/utils/CommandUtils.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java similarity index 88% rename from common/src/main/java/me/lucko/luckperms/common/commands/utils/CommandUtils.java rename to common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java index d6a77a3a1..c4b6bd55e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/utils/CommandUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java @@ -23,24 +23,21 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.utils; +package me.lucko.luckperms.common.command.utils; import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.ContextSet; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.sender.Sender; -import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.function.Supplier; import java.util.regex.Pattern; -public final class CommandUtils { +public final class MessageUtils { private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]"); /** @@ -86,27 +83,6 @@ public final class CommandUtils { return s == null ? null : STRIP_COLOR_PATTERN.matcher(s).replaceAll(""); } - public static List nInstances(int count, Supplier supplier) { - List ret = new ArrayList<>(count); - for (int i = 0; i < count; i++) { - ret.add(supplier.get()); - } - return ret; - } - - public static List> divideList(Iterable source, int size) { - List> lists = new ArrayList<>(); - Iterator it = source.iterator(); - while (it.hasNext()) { - List subList = new ArrayList<>(); - for (int i = 0; it.hasNext() && i < size; i++) { - subList.add(it.next()); - } - lists.add(subList); - } - return lists; - } - public static String toCommaSep(Collection strings) { if (strings.isEmpty()) { return "&bNone"; @@ -231,6 +207,6 @@ public final class CommandUtils { return sb.delete(sb.length() - Message.CONTEXT_PAIR_SEP.asString(null).length(), sb.length()).toString(); } - private CommandUtils() {} + private MessageUtils() {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/utils/SortMode.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/SortMode.java similarity index 98% rename from common/src/main/java/me/lucko/luckperms/common/commands/utils/SortMode.java rename to common/src/main/java/me/lucko/luckperms/common/command/utils/SortMode.java index 2e036ec5f..1af04d115 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/utils/SortMode.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/SortMode.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.utils; +package me.lucko.luckperms.common.command.utils; import java.util.List; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/utils/SortType.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/SortType.java similarity index 96% rename from common/src/main/java/me/lucko/luckperms/common/commands/utils/SortType.java rename to common/src/main/java/me/lucko/luckperms/common/command/utils/SortType.java index ea2046f4f..7a08413f6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/utils/SortType.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/SortType.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.utils; +package me.lucko.luckperms.common.command.utils; public enum SortType { 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 new file mode 100644 index 000000000..c61795f9a --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java @@ -0,0 +1,127 @@ +/* + * 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.config.ConfigKeys; +import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.messaging.InternalMessagingService; +import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.PermissionHolder; +import me.lucko.luckperms.common.model.Track; +import me.lucko.luckperms.common.model.User; +import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; + +import java.util.Optional; + +/** + * Utility methods for saving users, groups and tracks. + */ +public final class StorageAssistant { + + public static void save(User user, Sender sender, LuckPermsPlugin plugin) { + try { + plugin.getStorage().noBuffer().saveUser(user).get(); + } catch (Exception e) { + e.printStackTrace(); + Message.USER_SAVE_ERROR.send(sender, user.getFriendlyName()); + return; + } + + if (sender.isImport()) { + user.getRefreshBuffer().request(); + } else { + user.getRefreshBuffer().requestDirectly(); + } + + if (!sender.isImport()) { + Optional messagingService = plugin.getMessagingService(); + if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) { + messagingService.get().pushUserUpdate(user); + } + } + } + + public static void save(Group group, Sender sender, LuckPermsPlugin plugin) { + try { + plugin.getStorage().noBuffer().saveGroup(group).get(); + } catch (Exception e) { + e.printStackTrace(); + Message.GROUP_SAVE_ERROR.send(sender, group.getFriendlyName()); + return; + } + + if (sender.isImport()) { + plugin.getUpdateTaskBuffer().request(); + } else { + plugin.getUpdateTaskBuffer().requestDirectly(); + } + + if (!sender.isImport()) { + Optional messagingService = plugin.getMessagingService(); + if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) { + messagingService.get().getUpdateBuffer().request(); + } + } + } + + public static void save(Track track, Sender sender, LuckPermsPlugin plugin) { + try { + plugin.getStorage().noBuffer().saveTrack(track).get(); + } catch (Exception e) { + e.printStackTrace(); + Message.TRACK_SAVE_ERROR.send(sender, track.getName()); + return; + } + + if (sender.isImport()) { + plugin.getUpdateTaskBuffer().request(); + } else { + plugin.getUpdateTaskBuffer().requestDirectly(); + } + + if (!sender.isImport()) { + Optional messagingService = plugin.getMessagingService(); + if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) { + messagingService.get().getUpdateBuffer().request(); + } + } + } + + public static void save(PermissionHolder holder, Sender sender, LuckPermsPlugin plugin) { + if (holder.getType().isUser()) { + User user = ((User) holder); + save(user, sender, plugin); + } else if (holder.getType().isGroup()) { + Group group = ((Group) holder); + save(group, sender, plugin); + } else { + throw new IllegalArgumentException(); + } + } + + private StorageAssistant() {} +} diff --git a/common/src/main/java/me/lucko/luckperms/common/command/utils/TabCompletions.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/TabCompletions.java new file mode 100644 index 000000000..98e15ec4a --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/TabCompletions.java @@ -0,0 +1,124 @@ +/* + * 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 com.google.common.base.Splitter; + +import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.treeview.PermissionVault; +import me.lucko.luckperms.common.treeview.TreeNode; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Utility methods for handling tab completion. + */ +public final class TabCompletions { + + public static List getGroupTabComplete(List args, LuckPermsPlugin plugin) { + return getTabComplete(new ArrayList<>(plugin.getGroupManager().getAll().keySet()), args); + } + + public static List getTrackTabComplete(List args, LuckPermsPlugin plugin) { + return getTabComplete(new ArrayList<>(plugin.getTrackManager().getAll().keySet()), args); + } + + public static List getBoolTabComplete(List args) { + if (args.size() == 2) { + return Arrays.asList("true", "false"); + } else { + return Collections.emptyList(); + } + } + + public static List getPermissionTabComplete(List args, PermissionVault cache) { + if (args.size() <= 1) { + if (args.isEmpty() || args.get(0).equals("")) { + return cache.getRootNode().getChildren() + .map(Map::keySet) + .map(s -> (List) new ArrayList<>(s)) + .orElse(Collections.emptyList()); + } + + String start = args.get(0).toLowerCase(); + List parts = new ArrayList<>(Splitter.on('.').splitToList(start)); + TreeNode root = cache.getRootNode(); + + if (parts.size() <= 1) { + if (!root.getChildren().isPresent()) { + return Collections.emptyList(); + } + + return root.getChildren().get().keySet().stream().filter(s -> s.startsWith(start)).collect(Collectors.toList()); + } + + String incomplete = parts.remove(parts.size() - 1); + + for (String s : parts) { + if (!root.getChildren().isPresent()) { + return Collections.emptyList(); + } + + TreeNode n = root.getChildren().get().get(s); + if (n == null) { + return Collections.emptyList(); + } + + root = n; + } + + if (!root.getChildren().isPresent()) { + return Collections.emptyList(); + } + + return root.getChildren().get().keySet().stream() + .filter(s -> s.startsWith(incomplete)) + .map(s -> parts.stream().collect(Collectors.joining(".")) + "." + s) + .collect(Collectors.toList()); + } + + return Collections.emptyList(); + } + + private static List getTabComplete(List options, List args) { + if (args.size() <= 1) { + if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) { + return options; + } + + return options.stream().filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase())).collect(Collectors.toList()); + } + + return Collections.emptyList(); + } + + private TabCompletions() {} +} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java deleted file mode 100644 index 84c82d495..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/commands/abstraction/SubCommand.java +++ /dev/null @@ -1,240 +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.commands.abstraction; - -import com.google.common.base.Splitter; - -import me.lucko.luckperms.common.commands.Arg; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.LocalizedSpec; -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.Track; -import me.lucko.luckperms.common.model.User; -import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import me.lucko.luckperms.common.treeview.PermissionVault; -import me.lucko.luckperms.common.treeview.TreeNode; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -/** - * Abstract SubCommand class - */ -public abstract class SubCommand extends Command { - - public SubCommand(LocalizedSpec spec, String name, CommandPermission permission, Predicate argumentCheck) { - super(spec, name, permission, argumentCheck); - } - - /** - * Send the command usage to a sender - * - * @param sender the sender to send the usage to - */ - @Override - public void sendUsage(Sender sender, String label) { - StringBuilder sb = new StringBuilder(); - if (getArgs().isPresent()) { - sb.append("&3 - &7"); - for (Arg arg : getArgs().get()) { - sb.append(arg.asPrettyString()).append(" "); - } - } - - CommandUtils.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString()); - } - - @Override - public void sendDetailedUsage(Sender sender, String label) { - CommandUtils.sendPluginMessage(sender, "&3&lCommand Usage &3- &b" + getName()); - CommandUtils.sendPluginMessage(sender, "&b> &7" + getDescription()); - if (getArgs().isPresent()) { - CommandUtils.sendPluginMessage(sender, "&3Arguments:"); - for (Arg arg : getArgs().get()) { - CommandUtils.sendPluginMessage(sender, "&b- " + arg.asPrettyString() + "&3 -> &7" + arg.getDescription()); - } - } - } - - /* Utility methods used by #tabComplete and #execute implementations in sub classes */ - - public static List getGroupTabComplete(List args, LuckPermsPlugin plugin) { - return getTabComplete(new ArrayList<>(plugin.getGroupManager().getAll().keySet()), args); - } - - public static List getTrackTabComplete(List args, LuckPermsPlugin plugin) { - return getTabComplete(new ArrayList<>(plugin.getTrackManager().getAll().keySet()), args); - } - - public static List getBoolTabComplete(List args) { - if (args.size() == 2) { - return Arrays.asList("true", "false"); - } else { - return Collections.emptyList(); - } - } - - public static List getPermissionTabComplete(List args, PermissionVault cache) { - if (args.size() <= 1) { - if (args.isEmpty() || args.get(0).equals("")) { - return cache.getRootNode().getChildren() - .map(Map::keySet) - .map(s -> (List) new ArrayList<>(s)) - .orElse(Collections.emptyList()); - } - - String start = args.get(0).toLowerCase(); - List parts = new ArrayList<>(Splitter.on('.').splitToList(start)); - TreeNode root = cache.getRootNode(); - - if (parts.size() <= 1) { - if (!root.getChildren().isPresent()) { - return Collections.emptyList(); - } - - return root.getChildren().get().keySet().stream().filter(s -> s.startsWith(start)).collect(Collectors.toList()); - } - - String incomplete = parts.remove(parts.size() - 1); - - for (String s : parts) { - if (!root.getChildren().isPresent()) { - return Collections.emptyList(); - } - - TreeNode n = root.getChildren().get().get(s); - if (n == null) { - return Collections.emptyList(); - } - - root = n; - } - - if (!root.getChildren().isPresent()) { - return Collections.emptyList(); - } - - return root.getChildren().get().keySet().stream() - .filter(s -> s.startsWith(incomplete)) - .map(s -> parts.stream().collect(Collectors.joining(".")) + "." + s) - .collect(Collectors.toList()); - } - - return Collections.emptyList(); - } - - public static List getTabComplete(List options, List args) { - if (args.size() <= 1) { - if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) { - return options; - } - - return options.stream().filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase())).collect(Collectors.toList()); - } - - return Collections.emptyList(); - } - - public static void save(User user, Sender sender, LuckPermsPlugin plugin) { - try { - plugin.getStorage().noBuffer().saveUser(user).get(); - } catch (Exception e) { - e.printStackTrace(); - Message.USER_SAVE_ERROR.send(sender, user.getFriendlyName()); - return; - } - - if (sender.isImport()) { - user.getRefreshBuffer().request(); - } else { - user.getRefreshBuffer().requestDirectly(); - } - - if (!sender.isImport()) { - Optional messagingService = plugin.getMessagingService(); - if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) { - messagingService.get().pushUserUpdate(user); - } - } - } - - public static void save(Group group, Sender sender, LuckPermsPlugin plugin) { - try { - plugin.getStorage().noBuffer().saveGroup(group).get(); - } catch (Exception e) { - e.printStackTrace(); - Message.GROUP_SAVE_ERROR.send(sender, group.getFriendlyName()); - return; - } - - if (sender.isImport()) { - plugin.getUpdateTaskBuffer().request(); - } else { - plugin.getUpdateTaskBuffer().requestDirectly(); - } - - if (!sender.isImport()) { - Optional messagingService = plugin.getMessagingService(); - if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) { - messagingService.get().getUpdateBuffer().request(); - } - } - } - - public static void save(Track track, Sender sender, LuckPermsPlugin plugin) { - try { - plugin.getStorage().noBuffer().saveTrack(track).get(); - } catch (Exception e) { - e.printStackTrace(); - Message.TRACK_SAVE_ERROR.send(sender, track.getName()); - return; - } - - if (sender.isImport()) { - plugin.getUpdateTaskBuffer().request(); - } else { - plugin.getUpdateTaskBuffer().requestDirectly(); - } - - if (!sender.isImport()) { - Optional messagingService = plugin.getMessagingService(); - if (messagingService.isPresent() && plugin.getConfiguration().get(ConfigKeys.AUTO_PUSH_UPDATES)) { - messagingService.get().getUpdateBuffer().request(); - } - } - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/CommandMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/CommandMeta.java similarity index 87% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/CommandMeta.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/CommandMeta.java index bfc0387ac..b701fa383 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/CommandMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/CommandMeta.java @@ -23,20 +23,20 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.meta; +package me.lucko.luckperms.common.commands.generic.meta; import com.google.common.collect.ImmutableList; import me.lucko.luckperms.api.ChatMetaType; -import me.lucko.luckperms.common.commands.abstraction.SharedMainCommand; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.abstraction.SharedMainCommand; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.model.PermissionHolder; public class CommandMeta extends SharedMainCommand { public CommandMeta(LocaleManager locale, boolean user) { - super(CommandSpec.META.spec(locale), "Meta", user, ImmutableList.builder() + super(CommandSpec.META.localize(locale), "Meta", user, ImmutableList.builder() .add(new MetaInfo(locale)) .add(new MetaSet(locale)) .add(new MetaUnset(locale)) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddChatMeta.java similarity index 77% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddChatMeta.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddChatMeta.java index ffc85c10d..345985423 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddChatMeta.java @@ -23,27 +23,28 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.meta; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -57,7 +58,7 @@ public class MetaAddChatMeta extends SharedSubCommand { public MetaAddChatMeta(LocaleManager locale, ChatMetaType type) { super( - type == ChatMetaType.PREFIX ? CommandSpec.META_ADDPREFIX.spec(locale) : CommandSpec.META_ADDSUFFIX.spec(locale), + type == ChatMetaType.PREFIX ? CommandSpec.META_ADDPREFIX.localize(locale) : CommandSpec.META_ADDSUFFIX.localize(locale), "add" + type.name().toLowerCase(), type == ChatMetaType.PREFIX ? CommandPermission.USER_META_ADD_PREFIX : CommandPermission.USER_META_ADD_SUFFIX, type == ChatMetaType.PREFIX ? CommandPermission.GROUP_META_ADD_PREFIX : CommandPermission.GROUP_META_ADD_SUFFIX, @@ -73,9 +74,9 @@ public class MetaAddChatMeta extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - int priority = ArgumentUtils.handlePriority(0, args); - String meta = ArgumentUtils.handleString(1, args); - MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin); + int priority = ArgumentParser.parsePriority(0, args); + String meta = ArgumentParser.parseString(1, args); + MutableContextSet context = ArgumentParser.parseContext(2, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -84,7 +85,7 @@ public class MetaAddChatMeta extends SharedSubCommand { DataMutateResult result = holder.setPermission(NodeFactory.buildChatMetaNode(this.type, priority, meta).withExtraContext(context).build()); if (result.asBoolean()) { - TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder(); + TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder(); HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy( "¥3Raw " + this.type.name().toLowerCase() + ": ¥r" + meta, '¥' @@ -96,10 +97,10 @@ public class MetaAddChatMeta extends SharedSubCommand { .action("meta" , "add" + this.type.name().toLowerCase(), priority, meta, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_HAS_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)); + Message.ALREADY_HAS_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempChatMeta.java similarity index 78% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddTempChatMeta.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempChatMeta.java index ad1fd7678..b125ba32d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaAddTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempChatMeta.java @@ -23,30 +23,31 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.meta; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.TemporaryModifier; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -62,7 +63,7 @@ public class MetaAddTempChatMeta extends SharedSubCommand { public MetaAddTempChatMeta(LocaleManager locale, ChatMetaType type) { super( - type == ChatMetaType.PREFIX ? CommandSpec.META_ADDTEMP_PREFIX.spec(locale) : CommandSpec.META_ADDTEMP_SUFFIX.spec(locale), + type == ChatMetaType.PREFIX ? CommandSpec.META_ADDTEMP_PREFIX.localize(locale) : CommandSpec.META_ADDTEMP_SUFFIX.localize(locale), "addtemp" + type.name().toLowerCase(), type == ChatMetaType.PREFIX ? CommandPermission.USER_META_ADD_TEMP_PREFIX : CommandPermission.USER_META_ADD_TEMP_SUFFIX, type == ChatMetaType.PREFIX ? CommandPermission.GROUP_META_ADD_TEMP_PREFIX : CommandPermission.GROUP_META_ADD_TEMP_SUFFIX, @@ -78,11 +79,11 @@ public class MetaAddTempChatMeta extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - int priority = ArgumentUtils.handlePriority(0, args); - String meta = ArgumentUtils.handleString(1, args); - long duration = ArgumentUtils.handleDuration(2, args); - TemporaryModifier modifier = ArgumentUtils.handleTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR)); - MutableContextSet context = ArgumentUtils.handleContext(3, args, plugin); + int priority = ArgumentParser.parsePriority(0, args); + String meta = ArgumentParser.parseString(1, args); + long duration = ArgumentParser.parseDuration(2, args); + TemporaryModifier modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR)); + MutableContextSet context = ArgumentParser.parseContext(3, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -94,7 +95,7 @@ public class MetaAddTempChatMeta extends SharedSubCommand { if (ret.getKey().asBoolean()) { duration = ret.getValue().getExpiryUnixTime(); - TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder(); + TextComponent.Builder builder = TextUtils.fromLegacy(Message.ADD_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, DateUtil.formatDateDiff(duration), MessageUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder(); HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy( "¥3Raw " + this.type.name().toLowerCase() + ": ¥r" + meta, '¥' @@ -106,10 +107,10 @@ public class MetaAddTempChatMeta extends SharedSubCommand { .action("meta" , "addtemp" + this.type.name().toLowerCase(), priority, meta, duration, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_HAS_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)); + Message.ALREADY_HAS_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java similarity index 77% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaClear.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java index 4924c0f88..41546c2ab 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java @@ -23,32 +23,33 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.meta; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.MetaType; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class MetaClear extends SharedSubCommand { public MetaClear(LocaleManager locale) { - super(CommandSpec.META_CLEAR.spec(locale), "clear", CommandPermission.USER_META_CLEAR, CommandPermission.GROUP_META_CLEAR, Predicates.alwaysFalse()); + super(CommandSpec.META_CLEAR.localize(locale), "clear", CommandPermission.USER_META_CLEAR, CommandPermission.GROUP_META_CLEAR, Predicates.alwaysFalse()); } @Override @@ -88,7 +89,7 @@ public class MetaClear extends SharedSubCommand { int before = holder.getEnduringNodes().size(); - MutableContextSet context = ArgumentUtils.handleContext(0, args, plugin); + MutableContextSet context = ArgumentParser.parseContext(0, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -103,16 +104,16 @@ public class MetaClear extends SharedSubCommand { int changed = before - holder.getEnduringNodes().size(); if (changed == 1) { - Message.META_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), CommandUtils.contextSetToString(context), changed); + Message.META_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), MessageUtils.contextSetToString(context), changed); } else { - Message.META_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), CommandUtils.contextSetToString(context), changed); + Message.META_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), type.name().toLowerCase(), MessageUtils.contextSetToString(context), changed); } ExtendedLogEntry.build().actor(sender).acted(holder) .action("meta", "clear", context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java similarity index 85% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java index 0b597fad9..d041e4469 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java @@ -23,27 +23,27 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.meta; +package me.lucko.luckperms.common.commands.generic.meta; import com.google.common.collect.Maps; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.LocalizedNode; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.commands.utils.MetaComparator; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +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.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; +import me.lucko.luckperms.common.node.NodeWithContextComparator; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -52,6 +52,7 @@ import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; +import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -66,7 +67,7 @@ public class MetaInfo extends SharedSubCommand { } public MetaInfo(LocaleManager locale) { - super(CommandSpec.META_INFO.spec(locale), "info", CommandPermission.USER_META_INFO, CommandPermission.GROUP_META_INFO, Predicates.alwaysFalse()); + super(CommandSpec.META_INFO.localize(locale), "info", CommandPermission.USER_META_INFO, CommandPermission.GROUP_META_INFO, Predicates.alwaysFalse()); } @Override @@ -123,7 +124,7 @@ public class MetaInfo extends SharedSubCommand { for (LocalizedNode m : meta) { String location = processLocation(m, holder); if (m.hasSpecificContext()) { - String context = CommandUtils.getAppendableNodeContextString(m); + String context = MessageUtils.getAppendableNodeContextString(m); TextComponent.Builder builder = TextUtils.fromLegacy(Message.META_ENTRY_WITH_CONTEXT.asString(sender.getPlatform().getLocaleManager(), m.getMeta().getKey(), m.getMeta().getValue(), location, context), CommandManager.SECTION_CHAR).toBuilder(); builder.applyDeep(makeFancy(holder, label, m)); sender.sendMessage(builder.build()); @@ -139,7 +140,7 @@ public class MetaInfo extends SharedSubCommand { for (Map.Entry e : meta) { String location = processLocation(e.getValue(), holder); if (e.getValue().hasSpecificContext()) { - String context = CommandUtils.getAppendableNodeContextString(e.getValue()); + String context = MessageUtils.getAppendableNodeContextString(e.getValue()); TextComponent.Builder builder = TextUtils.fromLegacy(Message.CHAT_META_ENTRY_WITH_CONTEXT.asString(sender.getPlatform().getLocaleManager(), e.getKey(), type.getEntry(e.getValue()).getValue(), location, context), CommandManager.SECTION_CHAR).toBuilder(); builder.applyDeep(makeFancy(type, holder, label, e.getValue())); sender.sendMessage(builder.build()); @@ -198,4 +199,17 @@ public class MetaInfo extends SharedSubCommand { component.clickEvent(clickEvent); }; } + + private static final class MetaComparator implements Comparator> { + public static final MetaComparator INSTANCE = new MetaComparator(); + + @Override + public int compare(Map.Entry o1, Map.Entry o2) { + int result = Integer.compare(o1.getKey(), o2.getKey()); + if (result != 0) { + return result; + } + return NodeWithContextComparator.normal().compare(o1.getValue(), o2.getValue()); + } + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java similarity index 79% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveChatMeta.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java index 6a43bbfa8..2542867a5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java @@ -23,27 +23,28 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.meta; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -57,7 +58,7 @@ public class MetaRemoveChatMeta extends SharedSubCommand { public MetaRemoveChatMeta(LocaleManager locale, ChatMetaType type) { super( - type == ChatMetaType.PREFIX ? CommandSpec.META_REMOVEPREFIX.spec(locale) : CommandSpec.META_REMOVESUFFIX.spec(locale), + type == ChatMetaType.PREFIX ? CommandSpec.META_REMOVEPREFIX.localize(locale) : CommandSpec.META_REMOVESUFFIX.localize(locale), "remove" + type.name().toLowerCase(), type == ChatMetaType.PREFIX ? CommandPermission.USER_META_REMOVE_PREFIX : CommandPermission.USER_META_REMOVE_SUFFIX, type == ChatMetaType.PREFIX ? CommandPermission.GROUP_META_REMOVE_PREFIX : CommandPermission.GROUP_META_REMOVE_SUFFIX, @@ -73,9 +74,9 @@ public class MetaRemoveChatMeta extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - int priority = ArgumentUtils.handlePriority(0, args); - String meta = ArgumentUtils.handleStringOrElse(1, args, "null"); - MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin); + int priority = ArgumentParser.parsePriority(0, args); + String meta = ArgumentParser.parseStringOrElse(1, args, "null"); + MutableContextSet context = ArgumentParser.parseContext(2, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -90,20 +91,20 @@ public class MetaRemoveChatMeta extends SharedSubCommand { !n.isTemporary() && n.getFullContexts().makeImmutable().equals(context.makeImmutable()) ); - Message.BULK_REMOVE_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), priority, CommandUtils.contextSetToString(context)); + Message.BULK_REMOVE_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), priority, MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("meta" , "remove" + this.type.name().toLowerCase(), priority, "*", context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } DataMutateResult result = holder.unsetPermission(NodeFactory.buildChatMetaNode(this.type, priority, meta).withExtraContext(context).build()); if (result.asBoolean()) { - TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder(); + TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder(); HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy( "¥3Raw " + this.type.name().toLowerCase() + ": ¥r" + meta, '¥' @@ -115,10 +116,10 @@ public class MetaRemoveChatMeta extends SharedSubCommand { .action("meta" , "remove" + this.type.name().toLowerCase(), priority, meta, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_HAVE_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)); + Message.DOES_NOT_HAVE_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java similarity index 79% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveTempChatMeta.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java index 1b6cc04ba..2a30b2019 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaRemoveTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java @@ -23,27 +23,28 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.meta; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.ChatMetaType; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -57,7 +58,7 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand { public MetaRemoveTempChatMeta(LocaleManager locale, ChatMetaType type) { super( - type == ChatMetaType.PREFIX ? CommandSpec.META_REMOVETEMP_PREFIX.spec(locale) : CommandSpec.META_REMOVETEMP_SUFFIX.spec(locale), + type == ChatMetaType.PREFIX ? CommandSpec.META_REMOVETEMP_PREFIX.localize(locale) : CommandSpec.META_REMOVETEMP_SUFFIX.localize(locale), "removetemp" + type.name().toLowerCase(), type == ChatMetaType.PREFIX ? CommandPermission.USER_META_REMOVE_TEMP_PREFIX : CommandPermission.USER_META_REMOVE_TEMP_SUFFIX, type == ChatMetaType.PREFIX ? CommandPermission.GROUP_META_REMOVE_TEMP_PREFIX : CommandPermission.GROUP_META_REMOVE_TEMP_SUFFIX, @@ -73,9 +74,9 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - int priority = ArgumentUtils.handlePriority(0, args); - String meta = ArgumentUtils.handleStringOrElse(1, args, "null"); - MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin); + int priority = ArgumentParser.parsePriority(0, args); + String meta = ArgumentParser.parseStringOrElse(1, args, "null"); + MutableContextSet context = ArgumentParser.parseContext(2, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -90,20 +91,20 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand { !n.isPermanent() && n.getFullContexts().makeImmutable().equals(context.makeImmutable()) ); - Message.BULK_REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), priority, CommandUtils.contextSetToString(context)); + Message.BULK_REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), priority, MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("meta" , "removetemp" + this.type.name().toLowerCase(), priority, "*", context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } DataMutateResult result = holder.unsetPermission(NodeFactory.buildChatMetaNode(this.type, priority, meta).setExpiry(10L).withExtraContext(context).build()); if (result.asBoolean()) { - TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder(); + TextComponent.Builder builder = TextUtils.fromLegacy(Message.REMOVE_TEMP_CHATMETA_SUCCESS.asString(plugin.getLocaleManager(), holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder(); HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy( "¥3Raw " + this.type.name().toLowerCase() + ": ¥r" + meta, '¥' @@ -115,10 +116,10 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand { .action("meta" , "removetemp" + this.type.name().toLowerCase(), priority, meta, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_HAVE_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, CommandUtils.contextSetToString(context)); + Message.DOES_NOT_HAVE_TEMP_CHAT_META.send(sender, holder.getFriendlyName(), this.type.name().toLowerCase(), meta, priority, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java similarity index 77% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSet.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java index dbe31d547..73abc0db3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java @@ -23,25 +23,26 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.meta; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -52,7 +53,7 @@ import java.util.List; public class MetaSet extends SharedSubCommand { public MetaSet(LocaleManager locale) { - super(CommandSpec.META_SET.spec(locale), "set", CommandPermission.USER_META_SET, CommandPermission.GROUP_META_SET, Predicates.inRange(0, 1)); + super(CommandSpec.META_SET.localize(locale), "set", CommandPermission.USER_META_SET, CommandPermission.GROUP_META_SET, Predicates.inRange(0, 1)); } @Override @@ -64,7 +65,7 @@ public class MetaSet extends SharedSubCommand { String key = args.get(0); String value = args.get(1); - MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin); + MutableContextSet context = ArgumentParser.parseContext(2, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -79,14 +80,14 @@ public class MetaSet extends SharedSubCommand { Node n = NodeFactory.buildMetaNode(key, value).withExtraContext(context).build(); if (holder.hasPermission(n).asBoolean()) { - Message.ALREADY_HAS_META.send(sender, holder.getFriendlyName(), key, value, CommandUtils.contextSetToString(context)); + Message.ALREADY_HAS_META.send(sender, holder.getFriendlyName(), key, value, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } holder.clearMetaKeys(key, context, false); holder.setPermission(n); - TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), CommandUtils.contextSetToString(context))).toBuilder(); + TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), MessageUtils.contextSetToString(context))).toBuilder(); HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy( TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value), '¥' @@ -98,7 +99,7 @@ public class MetaSet extends SharedSubCommand { .action("meta", "set", key, value, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java similarity index 76% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSetTemp.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java index 294b568f4..32096d6ee 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java @@ -23,28 +23,29 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.meta; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.TemporaryModifier; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -56,7 +57,7 @@ import java.util.List; public class MetaSetTemp extends SharedSubCommand { public MetaSetTemp(LocaleManager locale) { - super(CommandSpec.META_SETTEMP.spec(locale), "settemp", CommandPermission.USER_META_SET_TEMP, CommandPermission.GROUP_META_SET_TEMP, Predicates.inRange(0, 2)); + super(CommandSpec.META_SETTEMP.localize(locale), "settemp", CommandPermission.USER_META_SET_TEMP, CommandPermission.GROUP_META_SET_TEMP, Predicates.inRange(0, 2)); } @Override @@ -68,9 +69,9 @@ public class MetaSetTemp extends SharedSubCommand { String key = args.get(0); String value = args.get(1); - long duration = ArgumentUtils.handleDuration(2, args); - TemporaryModifier modifier = ArgumentUtils.handleTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR)); - MutableContextSet context = ArgumentUtils.handleContext(3, args, plugin); + long duration = ArgumentParser.parseDuration(2, args); + TemporaryModifier modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR)); + MutableContextSet context = ArgumentParser.parseContext(3, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -85,14 +86,14 @@ public class MetaSetTemp extends SharedSubCommand { Node n = NodeFactory.buildMetaNode(key, value).withExtraContext(context).setExpiry(duration).build(); if (holder.hasPermission(n).asBoolean()) { - Message.ALREADY_HAS_TEMP_META.send(sender, holder.getFriendlyName(), key, value, CommandUtils.contextSetToString(context)); + Message.ALREADY_HAS_TEMP_META.send(sender, holder.getFriendlyName(), key, value, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } holder.clearMetaKeys(key, context, true); duration = holder.setPermission(n, modifier).getValue().getExpiryUnixTime(); - TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_TEMP_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder(); + TextComponent.Builder builder = TextUtils.fromLegacy(Message.SET_META_TEMP_SUCCESS.asString(plugin.getLocaleManager(), key, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), MessageUtils.contextSetToString(context)), CommandManager.SECTION_CHAR).toBuilder(); HoverEvent event = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextUtils.fromLegacy( TextUtils.joinNewline("¥3Raw key: ¥r" + key, "¥3Raw value: ¥r" + value), '¥' @@ -104,7 +105,7 @@ public class MetaSetTemp extends SharedSubCommand { .action("meta", "settemp", key, value, duration, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnset.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java similarity index 72% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnset.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java index 9837c4b07..40fb57bac 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnset.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java @@ -23,30 +23,31 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.meta; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; import java.util.List; public class MetaUnset extends SharedSubCommand { public MetaUnset(LocaleManager locale) { - super(CommandSpec.META_UNSET.spec(locale), "unset", CommandPermission.USER_META_UNSET, CommandPermission.GROUP_META_UNSET, Predicates.is(0)); + super(CommandSpec.META_UNSET.localize(locale), "unset", CommandPermission.USER_META_UNSET, CommandPermission.GROUP_META_UNSET, Predicates.is(0)); } @Override @@ -57,7 +58,7 @@ public class MetaUnset extends SharedSubCommand { } String key = args.get(0); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -70,16 +71,16 @@ public class MetaUnset extends SharedSubCommand { } if (holder.clearMetaKeys(key, context, false)) { - Message.UNSET_META_SUCCESS.send(sender, key, holder.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.UNSET_META_SUCCESS.send(sender, key, holder.getFriendlyName(), MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("meta", "unset", key, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOESNT_HAVE_META.send(sender, holder.getFriendlyName(), key, CommandUtils.contextSetToString(context)); + Message.DOESNT_HAVE_META.send(sender, holder.getFriendlyName(), key, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnsetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java similarity index 72% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnsetTemp.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java index 0effedd84..e79b7cd99 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaUnsetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java @@ -23,30 +23,31 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.meta; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; import java.util.List; public class MetaUnsetTemp extends SharedSubCommand { public MetaUnsetTemp(LocaleManager locale) { - super(CommandSpec.META_UNSETTEMP.spec(locale), "unsettemp", CommandPermission.USER_META_UNSET_TEMP, CommandPermission.GROUP_META_UNSET_TEMP, Predicates.is(0)); + super(CommandSpec.META_UNSETTEMP.localize(locale), "unsettemp", CommandPermission.USER_META_UNSET_TEMP, CommandPermission.GROUP_META_UNSET_TEMP, Predicates.is(0)); } @Override @@ -57,7 +58,7 @@ public class MetaUnsetTemp extends SharedSubCommand { } String key = args.get(0); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -70,16 +71,16 @@ public class MetaUnsetTemp extends SharedSubCommand { } if (holder.clearMetaKeys(key, context, true)) { - Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFriendlyName(), MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("meta", "unsettemp", key, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOESNT_HAVE_TEMP_META.send(sender, holder.getFriendlyName(), key, CommandUtils.contextSetToString(context)); + Message.DOESNT_HAVE_TEMP_META.send(sender, holder.getFriendlyName(), key, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderClear.java similarity index 72% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderClear.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderClear.java index 6456ae465..10c790e14 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderClear.java @@ -23,31 +23,31 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.other; +package me.lucko.luckperms.common.commands.generic.other; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; import java.util.List; public class HolderClear extends SubCommand { public HolderClear(LocaleManager locale, boolean user) { - super(CommandSpec.HOLDER_CLEAR.spec(locale), "clear", user ? CommandPermission.USER_CLEAR : CommandPermission.GROUP_CLEAR, Predicates.alwaysFalse()); + super(CommandSpec.HOLDER_CLEAR.localize(locale), "clear", user ? CommandPermission.USER_CLEAR : CommandPermission.GROUP_CLEAR, Predicates.alwaysFalse()); } @Override @@ -59,7 +59,7 @@ public class HolderClear extends SubCommand { int before = holder.getEnduringNodes().size(); - MutableContextSet context = ArgumentUtils.handleContext(0, args, plugin); + MutableContextSet context = ArgumentParser.parseContext(0, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, getPermission().get(), context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -74,16 +74,16 @@ public class HolderClear extends SubCommand { int changed = before - holder.getEnduringNodes().size(); if (changed == 1) { - Message.CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed); + Message.CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed); } else { - Message.CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed); + Message.CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed); } ExtendedLogEntry.build().actor(sender).acted(holder) .action("clear", context) .build().submit(plugin, sender); - SharedSubCommand.save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderEditor.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderEditor.java similarity index 81% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderEditor.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderEditor.java index ab9a67f30..192f2a6dc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderEditor.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderEditor.java @@ -23,24 +23,24 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.other; +package me.lucko.luckperms.common.commands.generic.other; import com.google.gson.JsonObject; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; -import me.lucko.luckperms.common.utils.web.StandardPastebin; -import me.lucko.luckperms.common.webeditor.WebEditor; +import me.lucko.luckperms.common.web.StandardPastebin; +import me.lucko.luckperms.common.web.WebEditor; import net.kyori.text.Component; import net.kyori.text.TextComponent; @@ -53,7 +53,7 @@ import java.util.List; public class HolderEditor extends SubCommand { public HolderEditor(LocaleManager locale, boolean user) { - super(CommandSpec.HOLDER_EDITOR.spec(locale), "editor", user ? CommandPermission.USER_EDITOR : CommandPermission.GROUP_EDITOR, Predicates.alwaysFalse()); + super(CommandSpec.HOLDER_EDITOR.localize(locale), "editor", user ? CommandPermission.USER_EDITOR : CommandPermission.GROUP_EDITOR, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderShowTracks.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderShowTracks.java similarity index 82% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderShowTracks.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderShowTracks.java index f2ead4d4e..7ebc27ba7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/other/HolderShowTracks.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderShowTracks.java @@ -23,24 +23,24 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.other; +package me.lucko.luckperms.common.commands.generic.other; import com.google.common.collect.Maps; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +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.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.PermissionHolder; 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.utils.Predicates; import java.util.ArrayList; @@ -51,7 +51,7 @@ import java.util.stream.Collectors; public class HolderShowTracks extends SubCommand { public HolderShowTracks(LocaleManager locale, boolean user) { - super(CommandSpec.HOLDER_SHOWTRACKS.spec(locale), "showtracks", user ? CommandPermission.USER_SHOW_TRACKS : CommandPermission.GROUP_SHOW_TRACKS, Predicates.alwaysFalse()); + super(CommandSpec.HOLDER_SHOWTRACKS.localize(locale), "showtracks", user ? CommandPermission.USER_SHOW_TRACKS : CommandPermission.GROUP_SHOW_TRACKS, Predicates.alwaysFalse()); } @Override @@ -86,7 +86,7 @@ public class HolderShowTracks extends SubCommand .collect(Collectors.toList()); for (Track t : tracks) { - lines.add(Maps.immutableEntry(t, CommandUtils.listToArrowSep(t.getGroups(), groupName) + CommandUtils.getAppendableNodeContextString(node))); + lines.add(Maps.immutableEntry(t, MessageUtils.listToArrowSep(t.getGroups(), groupName) + MessageUtils.getAppendableNodeContextString(node))); } } } else { @@ -97,7 +97,7 @@ public class HolderShowTracks extends SubCommand .collect(Collectors.toList()); for (Track t : tracks) { - lines.add(Maps.immutableEntry(t, CommandUtils.listToArrowSep(t.getGroups(), groupName))); + lines.add(Maps.immutableEntry(t, MessageUtils.listToArrowSep(t.getGroups(), groupName))); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/CommandParent.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/CommandParent.java similarity index 85% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/CommandParent.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/CommandParent.java index 739f60f9a..2a6fe85b4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/CommandParent.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/CommandParent.java @@ -23,21 +23,21 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.parent; +package me.lucko.luckperms.common.commands.generic.parent; import com.google.common.collect.ImmutableList; -import me.lucko.luckperms.common.commands.abstraction.SharedMainCommand; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.abstraction.SharedMainCommand; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.model.PermissionHolder; import java.util.Collections; public class CommandParent extends SharedMainCommand { public CommandParent(LocaleManager locale, boolean user) { - super(CommandSpec.PARENT.spec(locale), "Parent", user, ImmutableList.builder() + super(CommandSpec.PARENT.localize(locale), "Parent", user, ImmutableList.builder() .add(new ParentInfo(locale)) .add(new ParentSet(locale)) .add(new ParentAdd(locale)) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAdd.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java similarity index 74% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAdd.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java index d6c7fbb66..53e0cc5bc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAdd.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java @@ -23,35 +23,36 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.parent; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +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.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete; public class ParentAdd extends SharedSubCommand { public ParentAdd(LocaleManager locale) { - super(CommandSpec.PARENT_ADD.spec(locale), "add", CommandPermission.USER_PARENT_ADD, CommandPermission.GROUP_PARENT_ADD, Predicates.is(0)); + super(CommandSpec.PARENT_ADD.localize(locale), "add", CommandPermission.USER_PARENT_ADD, CommandPermission.GROUP_PARENT_ADD, Predicates.is(0)); } @Override @@ -61,8 +62,8 @@ public class ParentAdd extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - String groupName = ArgumentUtils.handleName(0, args); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + String groupName = ArgumentParser.parseName(0, args); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null); if (group == null) { @@ -83,16 +84,16 @@ public class ParentAdd extends SharedSubCommand { DataMutateResult result = holder.setPermission(NodeFactory.buildGroupNode(group.getName()).withExtraContext(context).build()); if (result.asBoolean()) { - Message.SET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.SET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("parent", "add", group.getName(), context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.ALREADY_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAddTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java similarity index 74% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAddTemp.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java index a31802f4f..0614bf11d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentAddTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java @@ -23,40 +23,41 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.parent; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.PermissionHolder; import me.lucko.luckperms.common.model.TemporaryModifier; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.Map; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete; public class ParentAddTemp extends SharedSubCommand { public ParentAddTemp(LocaleManager locale) { - super(CommandSpec.PARENT_ADD_TEMP.spec(locale), "addtemp", CommandPermission.USER_PARENT_ADD_TEMP, CommandPermission.GROUP_PARENT_ADD_TEMP, Predicates.inRange(0, 1)); + super(CommandSpec.PARENT_ADD_TEMP.localize(locale), "addtemp", CommandPermission.USER_PARENT_ADD_TEMP, CommandPermission.GROUP_PARENT_ADD_TEMP, Predicates.inRange(0, 1)); } @Override @@ -66,10 +67,10 @@ public class ParentAddTemp extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - String groupName = ArgumentUtils.handleName(0, args); - long duration = ArgumentUtils.handleDuration(1, args); - TemporaryModifier modifier = ArgumentUtils.handleTemporaryModifier(2, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR)); - MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin); + String groupName = ArgumentParser.parseName(0, args); + long duration = ArgumentParser.parseDuration(1, args); + TemporaryModifier modifier = ArgumentParser.parseTemporaryModifier(2, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR)); + MutableContextSet context = ArgumentParser.parseContext(2, args, plugin); Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null); if (group == null) { @@ -88,7 +89,7 @@ public class ParentAddTemp extends SharedSubCommand { } if (group.getName().equalsIgnoreCase(holder.getObjectName())) { - Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } @@ -96,16 +97,16 @@ public class ParentAddTemp extends SharedSubCommand { if (ret.getKey().asBoolean()) { duration = ret.getValue().getExpiryUnixTime(); - Message.SET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context)); + Message.SET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), DateUtil.formatDateDiff(duration), MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("parent", "addtemp", group.getName(), duration, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java similarity index 72% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClear.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java index a25a951b8..6763c6a5a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java @@ -23,30 +23,31 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.parent; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; import java.util.List; public class ParentClear extends SharedSubCommand { public ParentClear(LocaleManager locale) { - super(CommandSpec.PARENT_CLEAR.spec(locale), "clear", CommandPermission.USER_PARENT_CLEAR, CommandPermission.GROUP_PARENT_CLEAR, Predicates.alwaysFalse()); + super(CommandSpec.PARENT_CLEAR.localize(locale), "clear", CommandPermission.USER_PARENT_CLEAR, CommandPermission.GROUP_PARENT_CLEAR, Predicates.alwaysFalse()); } @Override @@ -58,7 +59,7 @@ public class ParentClear extends SharedSubCommand { int before = holder.getEnduringNodes().size(); - MutableContextSet context = ArgumentUtils.handleContext(0, args, plugin); + MutableContextSet context = ArgumentParser.parseContext(0, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -73,16 +74,16 @@ public class ParentClear extends SharedSubCommand { int changed = before - holder.getEnduringNodes().size(); if (changed == 1) { - Message.PARENT_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed); + Message.PARENT_CLEAR_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed); } else { - Message.PARENT_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), CommandUtils.contextSetToString(context), changed); + Message.PARENT_CLEAR_SUCCESS.send(sender, holder.getFriendlyName(), MessageUtils.contextSetToString(context), changed); } ExtendedLogEntry.build().actor(sender).acted(holder) .action("parent", "clear", context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClearTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java similarity index 78% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClearTrack.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java index 64ebf005b..6a02941a3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentClearTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java @@ -23,35 +23,36 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.parent; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; 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.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getTrackTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getTrackTabComplete; public class ParentClearTrack extends SharedSubCommand { public ParentClearTrack(LocaleManager locale) { - super(CommandSpec.PARENT_CLEAR_TRACK.spec(locale), "cleartrack", CommandPermission.USER_PARENT_CLEAR_TRACK, CommandPermission.GROUP_PARENT_CLEAR_TRACK, Predicates.is(0)); + super(CommandSpec.PARENT_CLEAR_TRACK.localize(locale), "cleartrack", CommandPermission.USER_PARENT_CLEAR_TRACK, CommandPermission.GROUP_PARENT_CLEAR_TRACK, Predicates.is(0)); } @Override @@ -80,7 +81,7 @@ public class ParentClearTrack extends SharedSubCommand { int before = holder.getEnduringNodes().size(); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -105,16 +106,16 @@ public class ParentClearTrack extends SharedSubCommand { int changed = before - holder.getEnduringNodes().size(); if (changed == 1) { - Message.PARENT_CLEAR_TRACK_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), track.getName(), CommandUtils.contextSetToString(context), changed); + Message.PARENT_CLEAR_TRACK_SUCCESS_SINGULAR.send(sender, holder.getFriendlyName(), track.getName(), MessageUtils.contextSetToString(context), changed); } else { - Message.PARENT_CLEAR_TRACK_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), CommandUtils.contextSetToString(context), changed); + Message.PARENT_CLEAR_TRACK_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), MessageUtils.contextSetToString(context), changed); } ExtendedLogEntry.build().actor(sender).acted(holder) .action("parent", "cleartrack", track.getName(), context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java similarity index 82% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java index a843c66d0..a38a6c072 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java @@ -23,29 +23,30 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.parent; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.LocalizedNode; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.commands.utils.SortMode; -import me.lucko.luckperms.common.commands.utils.SortType; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.node.NodeWithContextComparator; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.CollationKeyCache; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Iterators; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -62,7 +63,7 @@ import java.util.function.Consumer; public class ParentInfo extends SharedSubCommand { public ParentInfo(LocaleManager locale) { - super(CommandSpec.PARENT_INFO.spec(locale), "info", CommandPermission.USER_PARENT_INFO, CommandPermission.GROUP_PARENT_INFO, Predicates.notInRange(0, 2)); + super(CommandSpec.PARENT_INFO.localize(locale), "info", CommandPermission.USER_PARENT_INFO, CommandPermission.GROUP_PARENT_INFO, Predicates.notInRange(0, 2)); } @Override @@ -72,7 +73,7 @@ public class ParentInfo extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - int page = ArgumentUtils.handleIntOrElse(0, args, 1); + int page = ArgumentParser.parseIntOrElse(0, args, 1); SortMode sortMode = SortMode.determine(args); // get the holders nodes @@ -98,7 +99,7 @@ public class ParentInfo extends SharedSubCommand { } int pageIndex = page - 1; - List> pages = CommandUtils.divideList(nodes, 19); + List> pages = Iterators.divideIterable(nodes, 19); if (pageIndex < 0 || pageIndex >= pages.size()) { page = 1; @@ -112,7 +113,7 @@ public class ParentInfo extends SharedSubCommand { // send content for (LocalizedNode node : content) { - String s = "&3> &a" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node); + String s = "&3> &a" + node.getGroupName() + MessageUtils.getAppendableNodeContextString(node); if (node.isTemporary()) { s += "\n&2 expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java similarity index 76% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java index 01142e9a4..8d024b022 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java @@ -23,36 +23,37 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.parent; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete; public class ParentRemove extends SharedSubCommand { public ParentRemove(LocaleManager locale) { - super(CommandSpec.PARENT_REMOVE.spec(locale), "remove", CommandPermission.USER_PARENT_REMOVE, CommandPermission.GROUP_PARENT_REMOVE, Predicates.is(0)); + super(CommandSpec.PARENT_REMOVE.localize(locale), "remove", CommandPermission.USER_PARENT_REMOVE, CommandPermission.GROUP_PARENT_REMOVE, Predicates.is(0)); } @Override @@ -62,8 +63,8 @@ public class ParentRemove extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - String groupName = ArgumentUtils.handleNameWithSpace(0, args); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + String groupName = ArgumentParser.parseNameWithSpace(0, args); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -91,7 +92,7 @@ public class ParentRemove extends SharedSubCommand { DataMutateResult result = holder.unsetPermission(NodeFactory.buildGroupNode(groupName).withExtraContext(context).build()); if (result.asBoolean()) { - Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context)); + Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("parent", "remove", groupName, context) @@ -101,10 +102,10 @@ public class ParentRemove extends SharedSubCommand { plugin.getUserManager().giveDefaultIfNeeded(((User) holder), false); } - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_INHERIT.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context)); + Message.DOES_NOT_INHERIT.send(sender, holder.getFriendlyName(), groupName, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemoveTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java similarity index 72% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemoveTemp.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java index 02f5bbae0..27fbe8e10 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemoveTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java @@ -23,34 +23,35 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.parent; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete; public class ParentRemoveTemp extends SharedSubCommand { public ParentRemoveTemp(LocaleManager locale) { - super(CommandSpec.PARENT_REMOVE_TEMP.spec(locale), "removetemp", CommandPermission.USER_PARENT_REMOVE_TEMP, CommandPermission.GROUP_PARENT_REMOVE_TEMP, Predicates.is(0)); + super(CommandSpec.PARENT_REMOVE_TEMP.localize(locale), "removetemp", CommandPermission.USER_PARENT_REMOVE_TEMP, CommandPermission.GROUP_PARENT_REMOVE_TEMP, Predicates.is(0)); } @Override @@ -60,8 +61,8 @@ public class ParentRemoveTemp extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - String groupName = ArgumentUtils.handleNameWithSpace(0, args); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + String groupName = ArgumentParser.parseNameWithSpace(0, args); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -76,16 +77,16 @@ public class ParentRemoveTemp extends SharedSubCommand { DataMutateResult result = holder.unsetPermission(NodeFactory.buildGroupNode(groupName).setExpiry(10L).withExtraContext(context).build()); if (result.asBoolean()) { - Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context)); + Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName, MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("parent", "removetemp", groupName, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_TEMP_INHERIT.send(sender, holder.getFriendlyName(), groupName, CommandUtils.contextSetToString(context)); + Message.DOES_NOT_TEMP_INHERIT.send(sender, holder.getFriendlyName(), groupName, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java similarity index 74% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSet.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java index dd9d9d54a..8819a0565 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java @@ -23,35 +23,36 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.parent; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +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.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete; public class ParentSet extends SharedSubCommand { public ParentSet(LocaleManager locale) { - super(CommandSpec.PARENT_SET.spec(locale), "set", CommandPermission.USER_PARENT_SET, CommandPermission.GROUP_PARENT_SET, Predicates.is(0)); + super(CommandSpec.PARENT_SET.localize(locale), "set", CommandPermission.USER_PARENT_SET, CommandPermission.GROUP_PARENT_SET, Predicates.is(0)); } @Override @@ -61,8 +62,8 @@ public class ParentSet extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - String groupName = ArgumentUtils.handleName(0, args); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + String groupName = ArgumentParser.parseName(0, args); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null); if (group == null) { @@ -86,13 +87,13 @@ public class ParentSet extends SharedSubCommand { ((User) holder).getPrimaryGroup().setStoredValue(group.getName()); } - Message.SET_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.SET_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), group.getFriendlyName(), MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("parent", "set", group.getName(), context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSetTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java similarity index 77% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSetTrack.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java index dfdd03a89..c55cf2ad5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentSetTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java @@ -23,37 +23,38 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.parent; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +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.PermissionHolder; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getTrackTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getTrackTabComplete; public class ParentSetTrack extends SharedSubCommand { public ParentSetTrack(LocaleManager locale) { - super(CommandSpec.PARENT_SET_TRACK.spec(locale), "settrack", CommandPermission.USER_PARENT_SET_TRACK, CommandPermission.GROUP_PARENT_SET_TRACK, Predicates.inRange(0, 1)); + super(CommandSpec.PARENT_SET_TRACK.localize(locale), "settrack", CommandPermission.USER_PARENT_SET_TRACK, CommandPermission.GROUP_PARENT_SET_TRACK, Predicates.inRange(0, 1)); } @Override @@ -80,7 +81,7 @@ public class ParentSetTrack extends SharedSubCommand { return CommandResult.STATE_ERROR; } - int index = ArgumentUtils.handleIntOrElse(1, args, -1); + int index = ArgumentParser.parseIntOrElse(1, args, -1); String groupName; if (index > 0) { List trackGroups = track.getGroups(); @@ -90,14 +91,14 @@ public class ParentSetTrack extends SharedSubCommand { } groupName = track.getGroups().get(index - 1); } else { - groupName = ArgumentUtils.handleName(1, args); + groupName = ArgumentParser.parseName(1, args); if (!track.containsGroup(groupName)) { Message.TRACK_DOES_NOT_CONTAIN.send(sender, track.getName(), groupName); return CommandResult.INVALID_ARGS; } } - MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin); + MutableContextSet context = ArgumentParser.parseContext(2, args, plugin); Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null); if (group == null) { @@ -118,13 +119,13 @@ public class ParentSetTrack extends SharedSubCommand { holder.removeIf(node -> node.isGroupNode() && node.getFullContexts().equals(context) && track.containsGroup(node.getGroupName())); holder.setPermission(NodeFactory.buildGroupNode(group.getName()).withExtraContext(context).build()); - Message.SET_TRACK_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), group.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.SET_TRACK_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), track.getName(), group.getFriendlyName(), MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("parent", "settrack", track.getName(), groupName, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/UserSwitchPrimaryGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java similarity index 82% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/UserSwitchPrimaryGroup.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java index 3a1d73408..5ee8b6ba4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/UserSwitchPrimaryGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java @@ -23,32 +23,33 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.parent; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getGroupTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getGroupTabComplete; public class UserSwitchPrimaryGroup extends SharedSubCommand { public UserSwitchPrimaryGroup(LocaleManager locale) { - super(CommandSpec.USER_SWITCHPRIMARYGROUP.spec(locale), "switchprimarygroup", CommandPermission.USER_PARENT_SWITCHPRIMARYGROUP, null, Predicates.not(1)); + super(CommandSpec.USER_SWITCHPRIMARYGROUP.localize(locale), "switchprimarygroup", CommandPermission.USER_PARENT_SWITCHPRIMARYGROUP, null, Predicates.not(1)); } @Override @@ -91,7 +92,7 @@ public class UserSwitchPrimaryGroup extends SharedSubCommand { .action("parent", "switchprimarygroup", group.getName()) .build().submit(plugin, sender); - save(user, sender, plugin); + StorageAssistant.save(user, sender, plugin); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/CommandPermission.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/CommandPermission.java similarity index 83% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/CommandPermission.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/CommandPermission.java index d511fc34c..0b57d293c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/CommandPermission.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/CommandPermission.java @@ -23,19 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.permission; +package me.lucko.luckperms.common.commands.generic.permission; import com.google.common.collect.ImmutableList; -import me.lucko.luckperms.common.commands.abstraction.SharedMainCommand; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.abstraction.SharedMainCommand; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.model.PermissionHolder; public class CommandPermission extends SharedMainCommand { public CommandPermission(LocaleManager locale, boolean user) { - super(CommandSpec.PERMISSION.spec(locale), "Permission", user, ImmutableList.builder() + super(CommandSpec.PERMISSION.localize(locale), "Permission", user, ImmutableList.builder() .add(new PermissionInfo(locale)) .add(new PermissionSet(locale)) .add(new PermissionUnset(locale)) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheck.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheck.java similarity index 69% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheck.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheck.java index 3724906a3..276068c79 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheck.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheck.java @@ -23,34 +23,34 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.permission; +package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.api.StandardNodeEquality; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete; public class PermissionCheck extends SharedSubCommand { public PermissionCheck(LocaleManager locale) { - super(CommandSpec.PERMISSION_CHECK.spec(locale), "check", CommandPermission.USER_PERM_CHECK, CommandPermission.GROUP_PERM_CHECK, Predicates.is(0)); + super(CommandSpec.PERMISSION_CHECK.localize(locale), "check", CommandPermission.USER_PERM_CHECK, CommandPermission.GROUP_PERM_CHECK, Predicates.is(0)); } @Override @@ -60,13 +60,13 @@ public class PermissionCheck extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - String node = ArgumentUtils.handleString(0, args); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + String node = ArgumentParser.parseString(0, args); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); Tristate result = holder.hasPermission(NodeFactory.builder(node).withExtraContext(context).build(), StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY); - String s = CommandUtils.formatTristate(result); + String s = MessageUtils.formatTristate(result); - Message.CHECK_PERMISSION.send(sender, holder.getFriendlyName(), node, s, CommandUtils.contextSetToString(context)); + Message.CHECK_PERMISSION.send(sender, holder.getFriendlyName(), node, s, MessageUtils.contextSetToString(context)); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheckInherits.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheckInherits.java similarity index 70% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheckInherits.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheckInherits.java index 70a7a379a..433224e19 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionCheckInherits.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheckInherits.java @@ -23,34 +23,34 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.permission; +package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.api.StandardNodeEquality; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.InheritanceInfo; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete; public class PermissionCheckInherits extends SharedSubCommand { public PermissionCheckInherits(LocaleManager locale) { - super(CommandSpec.PERMISSION_CHECK_INHERITS.spec(locale), "checkinherits", CommandPermission.USER_PERM_CHECK_INHERITS, CommandPermission.GROUP_PERM_CHECK_INHERITS, Predicates.is(0)); + super(CommandSpec.PERMISSION_CHECK_INHERITS.localize(locale), "checkinherits", CommandPermission.USER_PERM_CHECK_INHERITS, CommandPermission.GROUP_PERM_CHECK_INHERITS, Predicates.is(0)); } @Override @@ -60,8 +60,8 @@ public class PermissionCheckInherits extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - String node = ArgumentUtils.handleString(0, args); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + String node = ArgumentParser.parseString(0, args); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); InheritanceInfo result = holder.searchForInheritedMatch(NodeFactory.builder(node).withExtraContext(context).build(), StandardNodeEquality.IGNORE_VALUE_OR_IF_TEMPORARY); @@ -70,8 +70,8 @@ public class PermissionCheckInherits extends SharedSubCommand { location = "self"; } - String s = CommandUtils.formatTristate(result.getResult()); - Message.CHECK_INHERITS_PERMISSION.send(sender, holder.getFriendlyName(), node, s, CommandUtils.contextSetToString(context), String.valueOf(location)); + String s = MessageUtils.formatTristate(result.getResult()); + Message.CHECK_INHERITS_PERMISSION.send(sender, holder.getFriendlyName(), node, s, MessageUtils.contextSetToString(context), String.valueOf(location)); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionInfo.java similarity index 83% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionInfo.java index 3c87bf542..20d126e20 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionInfo.java @@ -23,29 +23,30 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.permission; +package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.api.LocalizedNode; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.commands.utils.SortMode; -import me.lucko.luckperms.common.commands.utils.SortType; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.node.NodeWithContextComparator; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.CollationKeyCache; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Iterators; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -62,7 +63,7 @@ import java.util.function.Consumer; public class PermissionInfo extends SharedSubCommand { public PermissionInfo(LocaleManager locale) { - super(CommandSpec.PERMISSION_INFO.spec(locale), "info", CommandPermission.USER_PERM_INFO, CommandPermission.GROUP_PERM_INFO, Predicates.notInRange(0, 2)); + super(CommandSpec.PERMISSION_INFO.localize(locale), "info", CommandPermission.USER_PERM_INFO, CommandPermission.GROUP_PERM_INFO, Predicates.notInRange(0, 2)); } @Override @@ -72,7 +73,7 @@ public class PermissionInfo extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - int page = ArgumentUtils.handleIntOrElse(0, args, 1); + int page = ArgumentParser.parseIntOrElse(0, args, 1); SortMode sortMode = SortMode.determine(args); // get the holders nodes @@ -103,7 +104,7 @@ public class PermissionInfo extends SharedSubCommand { } int pageIndex = page - 1; - List> pages = CommandUtils.divideList(nodes, 19); + List> pages = Iterators.divideIterable(nodes, 19); if (pageIndex < 0 || pageIndex >= pages.size()) { page = 1; @@ -117,7 +118,7 @@ public class PermissionInfo extends SharedSubCommand { // send content for (LocalizedNode node : content) { - String s = "&3> " + (node.getValuePrimitive() ? "&a" : "&c") + node.getPermission() + (sender.isConsole() ? " &7(" + node.getValuePrimitive() + "&7)" : "") + CommandUtils.getAppendableNodeContextString(node); + String s = "&3> " + (node.getValuePrimitive() ? "&a" : "&c") + node.getPermission() + (sender.isConsole() ? " &7(" + node.getValuePrimitive() + "&7)" : "") + MessageUtils.getAppendableNodeContextString(node); if (node.isTemporary()) { s += "\n&2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java similarity index 70% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSet.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java index a057ad593..a0ef8d6d7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java @@ -23,35 +23,36 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.permission; +package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getBoolTabComplete; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getBoolTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete; public class PermissionSet extends SharedSubCommand { public PermissionSet(LocaleManager locale) { - super(CommandSpec.PERMISSION_SET.spec(locale), "set", CommandPermission.USER_PERM_SET, CommandPermission.GROUP_PERM_SET, Predicates.is(0)); + super(CommandSpec.PERMISSION_SET.localize(locale), "set", CommandPermission.USER_PERM_SET, CommandPermission.GROUP_PERM_SET, Predicates.is(0)); } @Override @@ -61,9 +62,9 @@ public class PermissionSet extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - String node = ArgumentUtils.handleString(0, args); - boolean value = ArgumentUtils.handleBoolean(1, args); - MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin); + String node = ArgumentParser.parseString(0, args); + boolean value = ArgumentParser.parseBoolean(1, args); + MutableContextSet context = ArgumentParser.parseContext(2, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -78,16 +79,16 @@ public class PermissionSet extends SharedSubCommand { DataMutateResult result = holder.setPermission(NodeFactory.builder(node).setValue(value).withExtraContext(context).build()); if (result.asBoolean()) { - Message.SETPERMISSION_SUCCESS.send(sender, node, value, holder.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.SETPERMISSION_SUCCESS.send(sender, node, value, holder.getFriendlyName(), MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("permission", "set", node, value, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_HASPERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context)); + Message.ALREADY_HASPERMISSION.send(sender, holder.getFriendlyName(), node, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java similarity index 71% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSetTemp.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java index 982fd86e4..03e9e30bb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java @@ -23,40 +23,41 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.permission; +package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.TemporaryModifier; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.Map; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getBoolTabComplete; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getBoolTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete; public class PermissionSetTemp extends SharedSubCommand { public PermissionSetTemp(LocaleManager locale) { - super(CommandSpec.PERMISSION_SETTEMP.spec(locale), "settemp", CommandPermission.USER_PERM_SET_TEMP, CommandPermission.GROUP_PERM_SET_TEMP, Predicates.inRange(0, 2)); + super(CommandSpec.PERMISSION_SETTEMP.localize(locale), "settemp", CommandPermission.USER_PERM_SET_TEMP, CommandPermission.GROUP_PERM_SET_TEMP, Predicates.inRange(0, 2)); } @Override @@ -66,11 +67,11 @@ public class PermissionSetTemp extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - String node = ArgumentUtils.handleString(0, args); - boolean value = ArgumentUtils.handleBoolean(1, args); - long duration = ArgumentUtils.handleDuration(2, args); - TemporaryModifier modifier = ArgumentUtils.handleTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR)); - MutableContextSet context = ArgumentUtils.handleContext(3, args, plugin); + String node = ArgumentParser.parseString(0, args); + boolean value = ArgumentParser.parseBoolean(1, args); + long duration = ArgumentParser.parseDuration(2, args); + TemporaryModifier modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR)); + MutableContextSet context = ArgumentParser.parseContext(3, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -86,16 +87,16 @@ public class PermissionSetTemp extends SharedSubCommand { if (result.getKey().asBoolean()) { duration = result.getValue().getExpiryUnixTime(); - Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), CommandUtils.contextSetToString(context)); + Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, value, holder.getFriendlyName(), DateUtil.formatDateDiff(duration), MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("permission", "settemp", node, value, duration, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.ALREADY_HAS_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context)); + Message.ALREADY_HAS_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnset.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java similarity index 72% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnset.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java index e0ca69b27..ada943779 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnset.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java @@ -23,34 +23,35 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.permission; +package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete; public class PermissionUnset extends SharedSubCommand { public PermissionUnset(LocaleManager locale) { - super(CommandSpec.PERMISSION_UNSET.spec(locale), "unset", CommandPermission.USER_PERM_UNSET, CommandPermission.GROUP_PERM_UNSET, Predicates.is(0)); + super(CommandSpec.PERMISSION_UNSET.localize(locale), "unset", CommandPermission.USER_PERM_UNSET, CommandPermission.GROUP_PERM_UNSET, Predicates.is(0)); } @Override @@ -60,8 +61,8 @@ public class PermissionUnset extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - String node = ArgumentUtils.handleString(0, args); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + String node = ArgumentParser.parseString(0, args); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -76,16 +77,16 @@ public class PermissionUnset extends SharedSubCommand { DataMutateResult result = holder.unsetPermission(NodeFactory.builder(node).withExtraContext(context).build()); if (result.asBoolean()) { - Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("permission", "unset", node, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_HAVE_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context)); + Message.DOES_NOT_HAVE_PERMISSION.send(sender, holder.getFriendlyName(), node, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnsetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java similarity index 72% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnsetTemp.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java index e8db2788f..e1b72a61d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionUnsetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java @@ -23,34 +23,35 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.generic.permission; +package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; -import static me.lucko.luckperms.common.commands.abstraction.SubCommand.getPermissionTabComplete; +import static me.lucko.luckperms.common.command.utils.TabCompletions.getPermissionTabComplete; public class PermissionUnsetTemp extends SharedSubCommand { public PermissionUnsetTemp(LocaleManager locale) { - super(CommandSpec.PERMISSION_UNSETTEMP.spec(locale), "unsettemp", CommandPermission.USER_PERM_UNSET_TEMP, CommandPermission.GROUP_PERM_UNSET_TEMP, Predicates.is(0)); + super(CommandSpec.PERMISSION_UNSETTEMP.localize(locale), "unsettemp", CommandPermission.USER_PERM_UNSET_TEMP, CommandPermission.GROUP_PERM_UNSET_TEMP, Predicates.is(0)); } @Override @@ -60,8 +61,8 @@ public class PermissionUnsetTemp extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - String node = ArgumentUtils.handleString(0, args); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + String node = ArgumentParser.parseString(0, args); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -76,16 +77,16 @@ public class PermissionUnsetTemp extends SharedSubCommand { DataMutateResult result = holder.unsetPermission(NodeFactory.builder(node).setExpiry(10L).withExtraContext(context).build()); if (result.asBoolean()) { - Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFriendlyName(), MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(holder) .action("permission", "unsettemp", node, context) .build().submit(plugin, sender); - save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return CommandResult.SUCCESS; } else { - Message.DOES_NOT_HAVE_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, CommandUtils.contextSetToString(context)); + Message.DOES_NOT_HAVE_TEMP_PERMISSION.send(sender, holder.getFriendlyName(), node, MessageUtils.contextSetToString(context)); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/CreateGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/CreateGroup.java similarity index 84% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/group/CreateGroup.java rename to common/src/main/java/me/lucko/luckperms/common/commands/group/CreateGroup.java index 4308d8639..56daae361 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/CreateGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/CreateGroup.java @@ -23,19 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.group; +package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +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.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; @@ -43,7 +43,7 @@ import java.util.List; public class CreateGroup extends SingleCommand { public CreateGroup(LocaleManager locale) { - super(CommandSpec.CREATE_GROUP.spec(locale), "CreateGroup", CommandPermission.CREATE_GROUP, Predicates.not(1)); + super(CommandSpec.CREATE_GROUP.localize(locale), "CreateGroup", CommandPermission.CREATE_GROUP, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/DeleteGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/DeleteGroup.java similarity index 83% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/group/DeleteGroup.java rename to common/src/main/java/me/lucko/luckperms/common/commands/group/DeleteGroup.java index 71afeba5d..204e65834 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/DeleteGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/DeleteGroup.java @@ -23,29 +23,29 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.group; +package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.event.cause.DeletionCause; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +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.utils.TabCompletions; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class DeleteGroup extends SingleCommand { public DeleteGroup(LocaleManager locale) { - super(CommandSpec.DELETE_GROUP.spec(locale), "DeleteGroup", CommandPermission.DELETE_GROUP, Predicates.not(1)); + super(CommandSpec.DELETE_GROUP.localize(locale), "DeleteGroup", CommandPermission.DELETE_GROUP, Predicates.not(1)); } @Override @@ -88,6 +88,6 @@ public class DeleteGroup extends SingleCommand { @Override public List tabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return SubCommand.getGroupTabComplete(args, plugin); + return TabCompletions.getGroupTabComplete(args, plugin); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupClone.java similarity index 81% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupClone.java rename to common/src/main/java/me/lucko/luckperms/common/commands/group/GroupClone.java index f85f1a6cd..68253ee68 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupClone.java @@ -23,20 +23,21 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.group; +package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; @@ -44,7 +45,7 @@ import java.util.List; public class GroupClone extends SubCommand { public GroupClone(LocaleManager locale) { - super(CommandSpec.GROUP_CLONE.spec(locale), "clone", CommandPermission.GROUP_CLONE, Predicates.not(1)); + super(CommandSpec.GROUP_CLONE.localize(locale), "clone", CommandPermission.GROUP_CLONE, Predicates.not(1)); } @Override @@ -79,7 +80,7 @@ public class GroupClone extends SubCommand { .action("clone", group.getName()) .build().submit(plugin, sender); - save(newGroup, sender, plugin); + StorageAssistant.save(newGroup, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupInfo.java similarity index 81% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupInfo.java rename to common/src/main/java/me/lucko/luckperms/common/commands/group/GroupInfo.java index d14f2b0fd..6feda4469 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupInfo.java @@ -23,20 +23,20 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.group; +package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +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.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -46,7 +46,7 @@ import java.util.stream.Collectors; public class GroupInfo extends SubCommand { public GroupInfo(LocaleManager locale) { - super(CommandSpec.GROUP_INFO.spec(locale), "info", CommandPermission.GROUP_INFO, Predicates.alwaysFalse()); + super(CommandSpec.GROUP_INFO.localize(locale), "info", CommandPermission.GROUP_INFO, Predicates.alwaysFalse()); } @Override @@ -75,14 +75,14 @@ public class GroupInfo extends SubCommand { if (!parents.isEmpty()) { Message.INFO_PARENT_HEADER.send(sender); for (Node node : parents) { - Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node)); + Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + MessageUtils.getAppendableNodeContextString(node)); } } if (!tempParents.isEmpty()) { Message.INFO_TEMP_PARENT_HEADER.send(sender); for (Node node : tempParents) { - Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node)); + Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + MessageUtils.getAppendableNodeContextString(node)); Message.EMPTY.send(sender, "&f- &2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime())); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupListMembers.java similarity index 86% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java rename to common/src/main/java/me/lucko/luckperms/common/commands/group/GroupListMembers.java index e0f4cabc2..2ebe95298 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupListMembers.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.group; +package me.lucko.luckperms.common.commands.group; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; @@ -31,22 +31,23 @@ import com.google.common.collect.Maps; import me.lucko.luckperms.api.HeldPermission; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.references.HolderType; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Iterators; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -65,7 +66,7 @@ import java.util.stream.Collectors; public class GroupListMembers extends SubCommand { public GroupListMembers(LocaleManager locale) { - super(CommandSpec.GROUP_LISTMEMBERS.spec(locale), "listmembers", CommandPermission.GROUP_LIST_MEMBERS, Predicates.notInRange(0, 1)); + super(CommandSpec.GROUP_LISTMEMBERS.localize(locale), "listmembers", CommandPermission.GROUP_LIST_MEMBERS, Predicates.notInRange(0, 1)); } @Override @@ -76,7 +77,7 @@ public class GroupListMembers extends SubCommand { } String query = NodeFactory.groupNode(group.getName()); - int page = ArgumentUtils.handleIntOrElse(0, args, 1); + int page = ArgumentParser.parseIntOrElse(0, args, 1); Message.SEARCH_SEARCHING_MEMBERS.send(sender, group.getName()); @@ -121,7 +122,7 @@ public class GroupListMembers extends SubCommand { }); int pageIndex = page - 1; - List>> pages = CommandUtils.divideList(results, 15); + List>> pages = Iterators.divideIterable(results, 15); if (pageIndex < 0 || pageIndex >= pages.size()) { page = 1; @@ -138,7 +139,7 @@ public class GroupListMembers extends SubCommand { headerMessage.send(sender, page, pages.size(), results.size()); for (Map.Entry> ent : mappedContent) { - String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().asNode()) + CommandUtils.getAppendableNodeContextString(ent.getValue().asNode()); + String s = "&3> &b" + ent.getKey() + " " + getNodeExpiryString(ent.getValue().asNode()) + MessageUtils.getAppendableNodeContextString(ent.getValue().asNode()); TextComponent message = TextUtils.fromLegacy(s, CommandManager.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue())).build(); sender.sendMessage(message); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupMainCommand.java similarity index 81% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupMainCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/group/GroupMainCommand.java index 88227c491..fec052363 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupMainCommand.java @@ -23,26 +23,26 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.group; +package me.lucko.luckperms.common.commands.group; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; import com.google.common.collect.ImmutableList; -import me.lucko.luckperms.common.commands.abstraction.Command; -import me.lucko.luckperms.common.commands.abstraction.MainCommand; -import me.lucko.luckperms.common.commands.impl.generic.meta.CommandMeta; -import me.lucko.luckperms.common.commands.impl.generic.other.HolderClear; -import me.lucko.luckperms.common.commands.impl.generic.other.HolderEditor; -import me.lucko.luckperms.common.commands.impl.generic.other.HolderShowTracks; -import me.lucko.luckperms.common.commands.impl.generic.parent.CommandParent; -import me.lucko.luckperms.common.commands.impl.generic.permission.CommandPermission; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.abstraction.Command; +import me.lucko.luckperms.common.command.abstraction.MainCommand; +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; +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.Message; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import java.util.ArrayList; import java.util.List; @@ -60,7 +60,7 @@ public class GroupMainCommand extends MainCommand { .build(key -> new ReentrantLock()); public GroupMainCommand(LocaleManager locale) { - super(CommandSpec.GROUP.spec(locale), "Group", 2, ImmutableList.>builder() + super(CommandSpec.GROUP.localize(locale), "Group", 2, ImmutableList.>builder() .add(new GroupInfo(locale)) .add(new CommandPermission<>(locale, false)) .add(new CommandParent<>(locale, false)) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupRename.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupRename.java similarity index 83% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupRename.java rename to common/src/main/java/me/lucko/luckperms/common/commands/group/GroupRename.java index 9d0bfa575..c897671af 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupRename.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupRename.java @@ -23,20 +23,21 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.group; +package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.api.event.cause.DeletionCause; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; @@ -44,7 +45,7 @@ import java.util.List; public class GroupRename extends SubCommand { public GroupRename(LocaleManager locale) { - super(CommandSpec.GROUP_RENAME.spec(locale), "rename", CommandPermission.GROUP_RENAME, Predicates.not(1)); + super(CommandSpec.GROUP_RENAME.localize(locale), "rename", CommandPermission.GROUP_RENAME, Predicates.not(1)); } @Override @@ -85,7 +86,7 @@ public class GroupRename extends SubCommand { .action("rename", newGroup.getName()) .build().submit(plugin, sender); - save(newGroup, sender, plugin); + StorageAssistant.save(newGroup, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupSetDisplayName.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java similarity index 79% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupSetDisplayName.java rename to common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java index aff179cec..2671b2e86 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupSetDisplayName.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java @@ -23,28 +23,29 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.group; +package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class GroupSetDisplayName extends SubCommand { public GroupSetDisplayName(LocaleManager locale) { - super(CommandSpec.GROUP_SET_DISPLAY_NAME.spec(locale), "setdisplayname", CommandPermission.GROUP_SET_DISPLAY_NAME, Predicates.not(1)); + super(CommandSpec.GROUP_SET_DISPLAY_NAME.localize(locale), "setdisplayname", CommandPermission.GROUP_SET_DISPLAY_NAME, Predicates.not(1)); } @Override @@ -54,7 +55,7 @@ public class GroupSetDisplayName extends SubCommand { return CommandResult.NO_PERMISSION; } - String name = ArgumentUtils.handleString(0, args); + String name = ArgumentParser.parseString(0, args); String previousName = group.getDisplayName().orElse(null); if (previousName == null && name.equals(group.getName())) { @@ -82,7 +83,7 @@ public class GroupSetDisplayName extends SubCommand { .action("setdisplayname", name) .build().submit(plugin, sender); - save(group, sender, plugin); + StorageAssistant.save(group, sender, plugin); return CommandResult.SUCCESS; } @@ -94,7 +95,7 @@ public class GroupSetDisplayName extends SubCommand { .action("setdisplayname", name) .build().submit(plugin, sender); - save(group, sender, plugin); + StorageAssistant.save(group, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupSetWeight.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java similarity index 73% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupSetWeight.java rename to common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java index 29f390af9..3bad02c4c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupSetWeight.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java @@ -23,29 +23,30 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.group; +package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class GroupSetWeight extends SubCommand { public GroupSetWeight(LocaleManager locale) { - super(CommandSpec.GROUP_SETWEIGHT.spec(locale), "setweight", CommandPermission.GROUP_SET_WEIGHT, Predicates.not(1)); + super(CommandSpec.GROUP_SETWEIGHT.localize(locale), "setweight", CommandPermission.GROUP_SET_WEIGHT, Predicates.not(1)); } @Override @@ -55,7 +56,7 @@ public class GroupSetWeight extends SubCommand { return CommandResult.NO_PERMISSION; } - int weight = ArgumentUtils.handlePriority(0, args); + int weight = ArgumentParser.parsePriority(0, args); group.removeIf(n -> NodeFactory.parseWeightNode(n.getPermission()) != null); group.setPermission(NodeFactory.buildWeightNode(weight).build()); @@ -66,7 +67,7 @@ public class GroupSetWeight extends SubCommand { .action("setweight", weight) .build().submit(plugin, sender); - save(group, sender, plugin); + StorageAssistant.save(group, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/ListGroups.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/ListGroups.java similarity index 84% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/group/ListGroups.java rename to common/src/main/java/me/lucko/luckperms/common/commands/group/ListGroups.java index 5fff3b89c..94d5aa69a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/ListGroups.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/ListGroups.java @@ -23,19 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.group; +package me.lucko.luckperms.common.commands.group; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandManager; +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.utils.MessageUtils; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -49,7 +49,7 @@ import java.util.stream.Collectors; public class ListGroups extends SingleCommand { public ListGroups(LocaleManager locale) { - super(CommandSpec.LIST_GROUPS.spec(locale), "ListGroups", CommandPermission.LIST_GROUPS, Predicates.alwaysFalse()); + super(CommandSpec.LIST_GROUPS.localize(locale), "ListGroups", CommandPermission.LIST_GROUPS, Predicates.alwaysFalse()); } @Override @@ -82,7 +82,7 @@ public class ListGroups extends SingleCommand { component = TextUtils.fromLegacy(Message.GROUPS_LIST_ENTRY_WITH_TRACKS.asString(plugin.getLocaleManager(), group.getFriendlyName(), group.getWeight().orElse(0), - CommandUtils.toCommaSep(tracks) + MessageUtils.toCommaSep(tracks) ), CommandManager.SECTION_CHAR); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogGroupHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogGroupHistory.java similarity index 85% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogGroupHistory.java rename to common/src/main/java/me/lucko/luckperms/common/commands/log/LogGroupHistory.java index c0bc9d810..65669cae4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogGroupHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogGroupHistory.java @@ -23,18 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log; +package me.lucko.luckperms.common.commands.log; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; import me.lucko.luckperms.common.actionlog.Log; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.TabCompletions; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.storage.DataConstraints; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -47,7 +48,7 @@ public class LogGroupHistory extends SubCommand { private static final int ENTRIES_PER_PAGE = 10; public LogGroupHistory(LocaleManager locale) { - super(CommandSpec.LOG_GROUP_HISTORY.spec(locale), "grouphistory", CommandPermission.LOG_GROUP_HISTORY, Predicates.notInRange(1, 2)); + super(CommandSpec.LOG_GROUP_HISTORY.localize(locale), "grouphistory", CommandPermission.LOG_GROUP_HISTORY, Predicates.notInRange(1, 2)); } @Override @@ -107,6 +108,6 @@ public class LogGroupHistory extends SubCommand { @Override public List tabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return getGroupTabComplete(args, plugin); + return TabCompletions.getGroupTabComplete(args, plugin); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogMainCommand.java similarity index 90% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogMainCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/log/LogMainCommand.java index 2e5e6e731..4314dc2c8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogMainCommand.java @@ -23,18 +23,18 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log; +package me.lucko.luckperms.common.commands.log; import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.actionlog.Log; -import me.lucko.luckperms.common.commands.abstraction.Command; -import me.lucko.luckperms.common.commands.abstraction.MainCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.abstraction.Command; +import me.lucko.luckperms.common.command.abstraction.MainCommand; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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 java.util.Collections; import java.util.List; @@ -46,7 +46,7 @@ public class LogMainCommand extends MainCommand { private final ReentrantLock lock = new ReentrantLock(); public LogMainCommand(LocaleManager locale) { - super(CommandSpec.LOG.spec(locale), "Log", 1, ImmutableList.>builder() + super(CommandSpec.LOG.localize(locale), "Log", 1, ImmutableList.>builder() .add(new LogRecent(locale)) .add(new LogSearch(locale)) .add(new LogNotify(locale)) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogNotify.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java similarity index 89% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogNotify.java rename to common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java index 8760e3ae7..8c27bd7a4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogNotify.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java @@ -23,20 +23,20 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log; +package me.lucko.luckperms.common.commands.log; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.actionlog.Log; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; @@ -45,7 +45,7 @@ import java.util.UUID; public class LogNotify extends SubCommand { public LogNotify(LocaleManager locale) { - super(CommandSpec.LOG_NOTIFY.spec(locale), "notify", CommandPermission.LOG_NOTIFY, Predicates.notInRange(0, 1)); + super(CommandSpec.LOG_NOTIFY.localize(locale), "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/impl/log/LogRecent.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogRecent.java similarity index 92% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogRecent.java rename to common/src/main/java/me/lucko/luckperms/common/commands/log/LogRecent.java index 2eca1c24d..d26057edc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogRecent.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogRecent.java @@ -23,19 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log; +package me.lucko.luckperms.common.commands.log; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; import me.lucko.luckperms.common.actionlog.Log; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.storage.DataConstraints; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -50,7 +50,7 @@ public class LogRecent extends SubCommand { private static final int ENTRIES_PER_PAGE = 10; public LogRecent(LocaleManager locale) { - super(CommandSpec.LOG_RECENT.spec(locale), "recent", CommandPermission.LOG_RECENT, Predicates.notInRange(0, 2)); + super(CommandSpec.LOG_RECENT.localize(locale), "recent", CommandPermission.LOG_RECENT, Predicates.notInRange(0, 2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogSearch.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogSearch.java similarity index 87% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogSearch.java rename to common/src/main/java/me/lucko/luckperms/common/commands/log/LogSearch.java index e95253067..540854c5e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogSearch.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogSearch.java @@ -23,18 +23,18 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log; +package me.lucko.luckperms.common.commands.log; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; import me.lucko.luckperms.common.actionlog.Log; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -47,7 +47,7 @@ public class LogSearch extends SubCommand { private static final int ENTRIES_PER_PAGE = 10; public LogSearch(LocaleManager locale) { - super(CommandSpec.LOG_SEARCH.spec(locale), "search", CommandPermission.LOG_SEARCH, Predicates.is(0)); + super(CommandSpec.LOG_SEARCH.localize(locale), "search", CommandPermission.LOG_SEARCH, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogTrackHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogTrackHistory.java similarity index 85% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogTrackHistory.java rename to common/src/main/java/me/lucko/luckperms/common/commands/log/LogTrackHistory.java index ab9d7ce3d..692638b87 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogTrackHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogTrackHistory.java @@ -23,18 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log; +package me.lucko.luckperms.common.commands.log; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; import me.lucko.luckperms.common.actionlog.Log; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.TabCompletions; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.storage.DataConstraints; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -47,7 +48,7 @@ public class LogTrackHistory extends SubCommand { private static final int ENTRIES_PER_PAGE = 10; public LogTrackHistory(LocaleManager locale) { - super(CommandSpec.LOG_TRACK_HISTORY.spec(locale), "trackhistory", CommandPermission.LOG_TRACK_HISTORY, Predicates.notInRange(1, 2)); + super(CommandSpec.LOG_TRACK_HISTORY.localize(locale), "trackhistory", CommandPermission.LOG_TRACK_HISTORY, Predicates.notInRange(1, 2)); } @Override @@ -107,6 +108,6 @@ public class LogTrackHistory extends SubCommand { @Override public List tabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return getTrackTabComplete(args, plugin); + return TabCompletions.getTrackTabComplete(args, plugin); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogUserHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogUserHistory.java similarity index 90% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogUserHistory.java rename to common/src/main/java/me/lucko/luckperms/common/commands/log/LogUserHistory.java index 00f39bd1e..408b4cda1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/log/LogUserHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogUserHistory.java @@ -23,19 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.log; +package me.lucko.luckperms.common.commands.log; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; import me.lucko.luckperms.common.actionlog.Log; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.storage.DataConstraints; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -50,7 +50,7 @@ public class LogUserHistory extends SubCommand { private static final int ENTRIES_PER_PAGE = 10; public LogUserHistory(LocaleManager locale) { - super(CommandSpec.LOG_USER_HISTORY.spec(locale), "userhistory", CommandPermission.LOG_USER_HISTORY, Predicates.notInRange(1, 2)); + super(CommandSpec.LOG_USER_HISTORY.localize(locale), "userhistory", CommandPermission.LOG_USER_HISTORY, Predicates.notInRange(1, 2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationMainCommand.java similarity index 88% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationMainCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationMainCommand.java index c50c556c0..e566f6445 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationMainCommand.java @@ -23,19 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.migration; +package me.lucko.luckperms.common.commands.migration; import com.google.common.collect.ImmutableBiMap; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.Command; -import me.lucko.luckperms.common.commands.abstraction.MainCommand; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.Command; +import me.lucko.luckperms.common.command.abstraction.MainCommand; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; 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.utils.Predicates; import java.util.ArrayList; @@ -65,7 +65,7 @@ public class MigrationMainCommand extends MainCommand { private boolean display = true; public MigrationMainCommand(LocaleManager locale) { - super(CommandSpec.MIGRATION.spec(locale), "Migration", 1, null); + super(CommandSpec.MIGRATION.localize(locale), "Migration", 1, null); } @Nonnull @@ -77,7 +77,7 @@ public class MigrationMainCommand extends MainCommand { // Add dummy command to show in the list. if (this.commands.isEmpty()) { this.display = false; - this.commands.add(new SubCommand(CommandSpec.MIGRATION_COMMAND.spec(getSpec().getLocaleManager()), "No available plugins to migrate from", CommandPermission.MIGRATION, Predicates.alwaysFalse()) { + this.commands.add(new SubCommand(CommandSpec.MIGRATION_COMMAND.localize(getSpec().getLocaleManager()), "No available plugins to migrate from", CommandPermission.MIGRATION, Predicates.alwaysFalse()) { @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List args, String label) { return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationUtils.java b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationUtils.java similarity index 97% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationUtils.java rename to common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationUtils.java index 0eea849bd..7b1f90a50 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/migration/MigrationUtils.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.migration; +package me.lucko.luckperms.common.commands.migration; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.model.Group; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ApplyEditsCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ApplyEditsCommand.java similarity index 86% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ApplyEditsCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/ApplyEditsCommand.java index 0ad19c7a3..26faa785a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ApplyEditsCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ApplyEditsCommand.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; import com.google.common.collect.Maps; import com.google.gson.JsonArray; @@ -32,22 +32,22 @@ import com.google.gson.JsonObject; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SharedSubCommand; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +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.utils.MessageUtils; +import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.NodeModel; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; -import me.lucko.luckperms.common.webeditor.WebEditor; +import me.lucko.luckperms.common.web.WebEditor; import java.util.HashSet; import java.util.List; @@ -57,7 +57,7 @@ import java.util.stream.Collectors; public class ApplyEditsCommand extends SingleCommand { public ApplyEditsCommand(LocaleManager locale) { - super(CommandSpec.APPLY_EDITS.spec(locale), "ApplyEdits", CommandPermission.APPLY_EDITS, Predicates.notInRange(1, 2)); + super(CommandSpec.APPLY_EDITS.localize(locale), "ApplyEdits", CommandPermission.APPLY_EDITS, Predicates.notInRange(1, 2)); } @Override @@ -135,12 +135,12 @@ public class ApplyEditsCommand extends SingleCommand { for (Node n : diff.getValue()) { Message.APPLY_EDITS_DIFF_REMOVED.send(sender, formatNode(n)); } - SharedSubCommand.save(holder, sender, plugin); + StorageAssistant.save(holder, sender, plugin); return true; } private static String formatNode(Node n) { - return n.getPermission() + " &7(" + (n.getValuePrimitive() ? "&a" : "&c") + n.getValuePrimitive() + "&7)" + CommandUtils.getAppendableNodeContextString(n) + + return n.getPermission() + " &7(" + (n.getValuePrimitive() ? "&a" : "&c") + n.getValuePrimitive() + "&7)" + MessageUtils.getAppendableNodeContextString(n) + (n.isTemporary() ? " &7(" + DateUtil.formatDateDiffShort(n.getExpiryUnixTime()) + ")" : ""); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/BulkUpdateCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/BulkUpdateCommand.java similarity index 86% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/BulkUpdateCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/BulkUpdateCommand.java index 2cd49d540..a9b734b81 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/BulkUpdateCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/BulkUpdateCommand.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Caffeine; @@ -37,16 +37,16 @@ import me.lucko.luckperms.common.bulkupdate.comparisons.Comparison; import me.lucko.luckperms.common.bulkupdate.comparisons.StandardComparison; import me.lucko.luckperms.common.bulkupdate.constraint.Constraint; import me.lucko.luckperms.common.bulkupdate.constraint.QueryField; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +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.utils.ArgumentParser; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.utils.Predicates; import java.util.List; @@ -57,7 +57,7 @@ public class BulkUpdateCommand extends SingleCommand { private final Cache pendingOperations = Caffeine.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(); public BulkUpdateCommand(LocaleManager locale) { - super(CommandSpec.BULK_UPDATE.spec(locale), "BulkUpdate", CommandPermission.BULK_UPDATE, Predicates.alwaysFalse()); + super(CommandSpec.BULK_UPDATE.localize(locale), "BulkUpdate", CommandPermission.BULK_UPDATE, Predicates.alwaysFalse()); } @Override @@ -86,7 +86,7 @@ public class BulkUpdateCommand extends SingleCommand { } if (args.size() < 2) { - throw new ArgumentUtils.DetailedUsageException(); + throw new ArgumentParser.DetailedUsageException(); } BulkUpdateBuilder bulkUpdateBuilder = BulkUpdateBuilder.create(); @@ -105,20 +105,20 @@ public class BulkUpdateCommand extends SingleCommand { break; case "update": if (args.size() < 2) { - throw new ArgumentUtils.DetailedUsageException(); + throw new ArgumentParser.DetailedUsageException(); } String field = args.remove(0); QueryField queryField = QueryField.of(field); if (queryField == null) { - throw new ArgumentUtils.DetailedUsageException(); + throw new ArgumentParser.DetailedUsageException(); } String value = args.remove(0); bulkUpdateBuilder.action(UpdateAction.of(queryField, value)); break; default: - throw new ArgumentUtils.DetailedUsageException(); + throw new ArgumentParser.DetailedUsageException(); } for (String constraint : args) { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/CheckCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/CheckCommand.java similarity index 80% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/CheckCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/CheckCommand.java index 16717996a..ae8478d44 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/CheckCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/CheckCommand.java @@ -23,20 +23,20 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; import me.lucko.luckperms.api.Tristate; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +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.utils.MessageUtils; +import me.lucko.luckperms.common.command.utils.TabCompletions; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; import me.lucko.luckperms.common.utils.Uuids; import me.lucko.luckperms.common.verbose.CheckOrigin; @@ -47,7 +47,7 @@ import java.util.stream.Collectors; public class CheckCommand extends SingleCommand { public CheckCommand(LocaleManager locale) { - super(CommandSpec.CHECK.spec(locale), "Check", CommandPermission.CHECK, Predicates.not(2)); + super(CommandSpec.CHECK.localize(locale), "Check", CommandPermission.CHECK, Predicates.not(2)); } @Override @@ -69,7 +69,7 @@ public class CheckCommand extends SingleCommand { } Tristate tristate = user.getCachedData().getPermissionData(plugin.getContextForUser(user).orElse(plugin.getContextManager().getStaticContexts())).getPermissionValue(permission, CheckOrigin.INTERNAL); - Message.CHECK_RESULT.send(sender, user.getFriendlyName(), permission, CommandUtils.formatTristate(tristate)); + Message.CHECK_RESULT.send(sender, user.getFriendlyName(), permission, MessageUtils.formatTristate(tristate)); return CommandResult.SUCCESS; } @@ -84,6 +84,6 @@ public class CheckCommand extends SingleCommand { } args.remove(0); - return SubCommand.getPermissionTabComplete(args, plugin.getPermissionVault()); + return TabCompletions.getPermissionTabComplete(args, plugin.getPermissionVault()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/DebugCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/DebugCommand.java similarity index 95% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/DebugCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/DebugCommand.java index 0f18bd1da..a909c16da 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/DebugCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/DebugCommand.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -37,23 +37,23 @@ import me.lucko.luckperms.api.metastacking.MetaStackDefinition; import me.lucko.luckperms.api.metastacking.MetaStackElement; import me.lucko.luckperms.common.caching.type.MetaCache; import me.lucko.luckperms.common.caching.type.PermissionCache; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; +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.contexts.ContextSetJsonSerializer; import me.lucko.luckperms.common.contexts.ProxiedContextCalculator; -import me.lucko.luckperms.common.locale.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.processors.PermissionProcessor; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.gson.JArray; import me.lucko.luckperms.common.utils.gson.JObject; -import me.lucko.luckperms.common.utils.web.Pastebin; -import me.lucko.luckperms.common.utils.web.StandardPastebin; +import me.lucko.luckperms.common.web.Pastebin; +import me.lucko.luckperms.common.web.StandardPastebin; import net.kyori.text.Component; import net.kyori.text.TextComponent; @@ -73,7 +73,7 @@ public class DebugCommand extends SingleCommand { private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); public DebugCommand(LocaleManager locale) { - super(CommandSpec.DEBUG.spec(locale), "Debug", CommandPermission.DEBUG, Predicates.alwaysFalse()); + super(CommandSpec.DEBUG.localize(locale), "Debug", CommandPermission.DEBUG, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/EditorCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java similarity index 85% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/EditorCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java index 894ffaf67..a5d5d195d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/EditorCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java @@ -23,25 +23,25 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; import com.google.gson.JsonObject; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; +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.utils.ArgumentParser; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; -import me.lucko.luckperms.common.utils.web.StandardPastebin; -import me.lucko.luckperms.common.webeditor.WebEditor; +import me.lucko.luckperms.common.web.StandardPastebin; +import me.lucko.luckperms.common.web.WebEditor; import net.kyori.text.Component; import net.kyori.text.TextComponent; @@ -54,7 +54,7 @@ import java.util.List; public class EditorCommand extends SingleCommand { public EditorCommand(LocaleManager locale) { - super(CommandSpec.EDITOR.spec(locale), "Editor", CommandPermission.EDITOR, Predicates.notInRange(0, 1)); + super(CommandSpec.EDITOR.localize(locale), "Editor", CommandPermission.EDITOR, Predicates.notInRange(0, 1)); } @Override @@ -62,7 +62,7 @@ public class EditorCommand extends SingleCommand { Type type = Type.ALL; // parse type - String typeString = ArgumentUtils.handleStringOrElse(0, args, null); + String typeString = ArgumentParser.parseStringOrElse(0, args, null); if (typeString != null) { try { type = Type.valueOf(typeString.toUpperCase()); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ExportCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ExportCommand.java similarity index 86% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ExportCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/ExportCommand.java index 703be3dbe..e1f238ea2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ExportCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ExportCommand.java @@ -23,17 +23,17 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; import me.lucko.luckperms.common.backup.Exporter; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +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.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.utils.Predicates; import java.io.File; @@ -47,7 +47,7 @@ public class ExportCommand extends SingleCommand { private final AtomicBoolean running = new AtomicBoolean(false); public ExportCommand(LocaleManager locale) { - super(CommandSpec.EXPORT.spec(locale), "Export", CommandPermission.EXPORT, Predicates.not(1)); + super(CommandSpec.EXPORT.localize(locale), "Export", CommandPermission.EXPORT, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ImportCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ImportCommand.java similarity index 86% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ImportCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/ImportCommand.java index 85730745f..162d30686 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ImportCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ImportCommand.java @@ -23,17 +23,17 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; import me.lucko.luckperms.common.backup.Importer; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +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.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.utils.Predicates; import java.io.File; @@ -48,7 +48,7 @@ public class ImportCommand extends SingleCommand { private final AtomicBoolean running = new AtomicBoolean(false); public ImportCommand(LocaleManager locale) { - super(CommandSpec.IMPORT.spec(locale), "Import", CommandPermission.IMPORT, Predicates.not(1)); + super(CommandSpec.IMPORT.localize(locale), "Import", CommandPermission.IMPORT, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/InfoCommand.java similarity index 84% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/InfoCommand.java index 652ee0853..dab5352df 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/InfoCommand.java @@ -23,18 +23,18 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +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.utils.MessageUtils; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -43,7 +43,7 @@ import java.util.Map; public class InfoCommand extends SingleCommand { public InfoCommand(LocaleManager locale) { - super(CommandSpec.INFO.spec(locale), "Info", CommandPermission.INFO, Predicates.alwaysFalse()); + super(CommandSpec.INFO.localize(locale), "Info", CommandPermission.INFO, Predicates.alwaysFalse()); } @Override @@ -77,7 +77,7 @@ public class InfoCommand extends SingleCommand { private static String formatValue(String value) { if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { - return CommandUtils.formatBoolean(Boolean.parseBoolean(value)); + return MessageUtils.formatBoolean(Boolean.parseBoolean(value)); } try { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/NetworkSyncCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/NetworkSyncCommand.java similarity index 82% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/NetworkSyncCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/NetworkSyncCommand.java index 9ba7adf91..c593c57b4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/NetworkSyncCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/NetworkSyncCommand.java @@ -23,17 +23,17 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +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.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import java.util.List; @@ -41,7 +41,7 @@ import java.util.Optional; public class NetworkSyncCommand extends SingleCommand { public NetworkSyncCommand(LocaleManager locale) { - super(CommandSpec.NETWORK_SYNC.spec(locale), "NetworkSync", CommandPermission.SYNC, Predicates.alwaysFalse()); + super(CommandSpec.NETWORK_SYNC.localize(locale), "NetworkSync", CommandPermission.SYNC, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ReloadConfigCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ReloadConfigCommand.java similarity index 77% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ReloadConfigCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/ReloadConfigCommand.java index 622ede654..5dfa3c112 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/ReloadConfigCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ReloadConfigCommand.java @@ -23,23 +23,23 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +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.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.utils.Predicates; import java.util.List; public class ReloadConfigCommand extends SingleCommand { public ReloadConfigCommand(LocaleManager locale) { - super(CommandSpec.RELOAD_CONFIG.spec(locale), "ReloadConfig", CommandPermission.RELOAD_CONFIG, Predicates.alwaysFalse()); + super(CommandSpec.RELOAD_CONFIG.localize(locale), "ReloadConfig", CommandPermission.RELOAD_CONFIG, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/SearchCommand.java similarity index 85% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/SearchCommand.java index 3ccda11f7..e57cbd835 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/SearchCommand.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; @@ -31,21 +31,22 @@ import com.google.common.collect.Maps; import me.lucko.luckperms.api.HeldPermission; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandManager; +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.utils.ArgumentParser; +import me.lucko.luckperms.common.command.utils.MessageUtils; +import me.lucko.luckperms.common.command.utils.TabCompletions; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.references.HolderType; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Iterators; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.TextUtils; @@ -64,13 +65,13 @@ import java.util.stream.Collectors; public class SearchCommand extends SingleCommand { public SearchCommand(LocaleManager locale) { - super(CommandSpec.SEARCH.spec(locale), "Search", CommandPermission.SEARCH, Predicates.notInRange(1, 2)); + super(CommandSpec.SEARCH.localize(locale), "Search", CommandPermission.SEARCH, Predicates.notInRange(1, 2)); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List args, String label) { String query = args.get(0); - int page = ArgumentUtils.handleIntOrElse(1, args, 1); + int page = ArgumentParser.parseIntOrElse(1, args, 1); Message.SEARCH_SEARCHING.send(sender, query); @@ -103,7 +104,7 @@ public class SearchCommand extends SingleCommand { @Override public List tabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return SubCommand.getPermissionTabComplete(args, plugin.getPermissionVault()); + return TabCompletions.getPermissionTabComplete(args, plugin.getPermissionVault()); } private static void sendResult(Sender sender, List> results, Function lookupFunction, Message headerMessage, HolderType holderType, String label, int page) { @@ -120,7 +121,7 @@ public class SearchCommand extends SingleCommand { }); int pageIndex = page - 1; - List>> pages = CommandUtils.divideList(results, 15); + List>> pages = Iterators.divideIterable(results, 15); if (pageIndex < 0 || pageIndex >= pages.size()) { page = 1; @@ -137,7 +138,7 @@ public class SearchCommand extends SingleCommand { headerMessage.send(sender, page, pages.size(), results.size()); for (Map.Entry> ent : mappedContent) { - String s = "&3> &b" + ent.getKey() + " &7- " + (ent.getValue().getValue() ? "&a" : "&c") + ent.getValue().getValue() + getNodeExpiryString(ent.getValue().asNode()) + CommandUtils.getAppendableNodeContextString(ent.getValue().asNode()); + String s = "&3> &b" + ent.getKey() + " &7- " + (ent.getValue().getValue() ? "&a" : "&c") + ent.getValue().getValue() + getNodeExpiryString(ent.getValue().asNode()) + MessageUtils.getAppendableNodeContextString(ent.getValue().asNode()); TextComponent message = TextUtils.fromLegacy(s, CommandManager.AMPERSAND_CHAR).toBuilder().applyDeep(makeFancy(ent.getKey(), holderType, label, ent.getValue())).build(); sender.sendMessage(message); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SyncCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/SyncCommand.java similarity index 78% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SyncCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/SyncCommand.java index 09a1d4e53..6d7de07f5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SyncCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/SyncCommand.java @@ -23,23 +23,23 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +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.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.utils.Predicates; import java.util.List; public class SyncCommand extends SingleCommand { public SyncCommand(LocaleManager locale) { - super(CommandSpec.SYNC.spec(locale), "Sync", CommandPermission.SYNC, Predicates.alwaysFalse()); + super(CommandSpec.SYNC.localize(locale), "Sync", CommandPermission.SYNC, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/TreeCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/TreeCommand.java similarity index 88% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/TreeCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/TreeCommand.java index 0085b87fa..aa465d8cb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/TreeCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/TreeCommand.java @@ -23,19 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; import me.lucko.luckperms.common.caching.type.PermissionCache; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; +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.config.ConfigKeys; -import me.lucko.luckperms.common.locale.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.treeview.TreeView; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.Uuids; @@ -51,7 +51,7 @@ import java.util.UUID; public class TreeCommand extends SingleCommand { public TreeCommand(LocaleManager locale) { - super(CommandSpec.TREE.spec(locale), "Tree", CommandPermission.TREE, Predicates.alwaysFalse()); + super(CommandSpec.TREE.localize(locale), "Tree", CommandPermission.TREE, Predicates.alwaysFalse()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/VerboseCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/VerboseCommand.java similarity index 91% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/VerboseCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/misc/VerboseCommand.java index d0fa0b81a..0a1ae4004 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/VerboseCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/VerboseCommand.java @@ -23,19 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.misc; +package me.lucko.luckperms.common.commands.misc; import com.google.common.collect.ImmutableList; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; +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.config.ConfigKeys; -import me.lucko.luckperms.common.locale.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.utils.Predicates; import me.lucko.luckperms.common.verbose.InvalidFilterException; import me.lucko.luckperms.common.verbose.VerboseFilter; @@ -55,7 +55,7 @@ import java.util.stream.Stream; public class VerboseCommand extends SingleCommand { public VerboseCommand(LocaleManager locale) { - super(CommandSpec.VERBOSE.spec(locale), "Verbose", CommandPermission.VERBOSE, Predicates.is(0)); + super(CommandSpec.VERBOSE.localize(locale), "Verbose", CommandPermission.VERBOSE, Predicates.is(0)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/CreateTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/CreateTrack.java similarity index 84% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/track/CreateTrack.java rename to common/src/main/java/me/lucko/luckperms/common/commands/track/CreateTrack.java index be9a38223..9de7f2dad 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/CreateTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/CreateTrack.java @@ -23,19 +23,19 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.track; +package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +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.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; @@ -43,7 +43,7 @@ import java.util.List; public class CreateTrack extends SingleCommand { public CreateTrack(LocaleManager locale) { - super(CommandSpec.CREATE_TRACK.spec(locale), "CreateTrack", CommandPermission.CREATE_TRACK, Predicates.not(1)); + super(CommandSpec.CREATE_TRACK.localize(locale), "CreateTrack", CommandPermission.CREATE_TRACK, Predicates.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/DeleteTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/DeleteTrack.java similarity index 81% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/track/DeleteTrack.java rename to common/src/main/java/me/lucko/luckperms/common/commands/track/DeleteTrack.java index baf7ae29a..1cae0d195 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/DeleteTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/DeleteTrack.java @@ -23,28 +23,28 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.track; +package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.event.cause.DeletionCause; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +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.utils.TabCompletions; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; import java.util.List; public class DeleteTrack extends SingleCommand { public DeleteTrack(LocaleManager locale) { - super(CommandSpec.DELETE_TRACK.spec(locale), "DeleteTrack", CommandPermission.DELETE_TRACK, Predicates.not(1)); + super(CommandSpec.DELETE_TRACK.localize(locale), "DeleteTrack", CommandPermission.DELETE_TRACK, Predicates.not(1)); } @Override @@ -80,6 +80,6 @@ public class DeleteTrack extends SingleCommand { @Override public List tabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return SubCommand.getTrackTabComplete(args, plugin); + return TabCompletions.getTrackTabComplete(args, plugin); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/ListTracks.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/ListTracks.java similarity index 75% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/track/ListTracks.java rename to common/src/main/java/me/lucko/luckperms/common/commands/track/ListTracks.java index ac77cf243..743fb6b07 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/ListTracks.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/ListTracks.java @@ -23,17 +23,17 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.track; +package me.lucko.luckperms.common.commands.track; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SingleCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +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.utils.MessageUtils; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.utils.Predicates; import java.util.List; @@ -41,7 +41,7 @@ import java.util.stream.Collectors; public class ListTracks extends SingleCommand { public ListTracks(LocaleManager locale) { - super(CommandSpec.LIST_TRACKS.spec(locale), "ListTracks", CommandPermission.LIST_TRACKS, Predicates.alwaysFalse()); + super(CommandSpec.LIST_TRACKS.localize(locale), "ListTracks", CommandPermission.LIST_TRACKS, Predicates.alwaysFalse()); } @Override @@ -54,7 +54,7 @@ public class ListTracks extends SingleCommand { return CommandResult.LOADING_ERROR; } - Message.TRACKS_LIST.send(sender, CommandUtils.toCommaSep(plugin.getTrackManager().getAll().keySet().stream().sorted().collect(Collectors.toList()))); + Message.TRACKS_LIST.send(sender, MessageUtils.toCommaSep(plugin.getTrackManager().getAll().keySet().stream().sorted().collect(Collectors.toList()))); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackAppend.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackAppend.java similarity index 77% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackAppend.java rename to common/src/main/java/me/lucko/luckperms/common/commands/track/TrackAppend.java index f8b4d1113..44f5390f3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackAppend.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackAppend.java @@ -23,21 +23,23 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.track; +package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +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.command.utils.TabCompletions; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; @@ -45,7 +47,7 @@ import java.util.List; public class TrackAppend extends SubCommand { public TrackAppend(LocaleManager locale) { - super(CommandSpec.TRACK_APPEND.spec(locale), "append", CommandPermission.TRACK_APPEND, Predicates.not(1)); + super(CommandSpec.TRACK_APPEND.localize(locale), "append", CommandPermission.TRACK_APPEND, Predicates.not(1)); } @Override @@ -67,14 +69,14 @@ public class TrackAppend extends SubCommand { if (result.asBoolean()) { Message.TRACK_APPEND_SUCCESS.send(sender, group.getName(), track.getName()); if (track.getGroups().size() > 1) { - Message.EMPTY.send(sender, CommandUtils.listToArrowSep(track.getGroups(), group.getName())); + Message.EMPTY.send(sender, MessageUtils.listToArrowSep(track.getGroups(), group.getName())); } ExtendedLogEntry.build().actor(sender).acted(track) .action("append", group.getName()) .build().submit(plugin, sender); - save(track, sender, plugin); + StorageAssistant.save(track, sender, plugin); return CommandResult.SUCCESS; } else { Message.TRACK_ALREADY_CONTAINS.send(sender, track.getName(), group.getName()); @@ -84,6 +86,6 @@ public class TrackAppend extends SubCommand { @Override public List tabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return getGroupTabComplete(args, plugin); + return TabCompletions.getGroupTabComplete(args, plugin); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClear.java similarity index 76% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClear.java rename to common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClear.java index b6a1c4548..563449c55 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClear.java @@ -23,25 +23,26 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.track; +package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; import java.util.List; public class TrackClear extends SubCommand { public TrackClear(LocaleManager locale) { - super(CommandSpec.TRACK_CLEAR.spec(locale), "clear", CommandPermission.TRACK_CLEAR, Predicates.alwaysFalse()); + super(CommandSpec.TRACK_CLEAR.localize(locale), "clear", CommandPermission.TRACK_CLEAR, Predicates.alwaysFalse()); } @Override @@ -53,7 +54,7 @@ public class TrackClear extends SubCommand { .action("clear") .build().submit(plugin, sender); - save(track, sender, plugin); + StorageAssistant.save(track, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClone.java similarity index 81% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClone.java rename to common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClone.java index 9b9c52685..2d78fe727 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClone.java @@ -23,19 +23,20 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.track; +package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; @@ -43,7 +44,7 @@ import java.util.List; public class TrackClone extends SubCommand { public TrackClone(LocaleManager locale) { - super(CommandSpec.TRACK_CLONE.spec(locale), "clone", CommandPermission.TRACK_CLONE, Predicates.not(1)); + super(CommandSpec.TRACK_CLONE.localize(locale), "clone", CommandPermission.TRACK_CLONE, Predicates.not(1)); } @Override @@ -68,7 +69,7 @@ public class TrackClone extends SubCommand { .action("clone", newTrack.getName()) .build().submit(plugin, sender); - save(newTrack, sender, plugin); + StorageAssistant.save(newTrack, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInfo.java similarity index 73% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInfo.java rename to common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInfo.java index b7493ca14..dd85be593 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInfo.java @@ -23,30 +23,30 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.track; +package me.lucko.luckperms.common.commands.track; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +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.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.Predicates; import java.util.List; public class TrackInfo extends SubCommand { public TrackInfo(LocaleManager locale) { - super(CommandSpec.TRACK_INFO.spec(locale), "info", CommandPermission.TRACK_INFO, Predicates.alwaysFalse()); + super(CommandSpec.TRACK_INFO.localize(locale), "info", CommandPermission.TRACK_INFO, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track track, List args, String label) { - Message.TRACK_INFO.send(sender, track.getName(), CommandUtils.listToArrowSep(track.getGroups())); + Message.TRACK_INFO.send(sender, track.getName(), MessageUtils.listToArrowSep(track.getGroups())); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInsert.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInsert.java similarity index 80% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInsert.java rename to common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInsert.java index 596b175c7..72197df45 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackInsert.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInsert.java @@ -23,21 +23,23 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.track; +package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +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.command.utils.TabCompletions; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; @@ -45,7 +47,7 @@ import java.util.List; public class TrackInsert extends SubCommand { public TrackInsert(LocaleManager locale) { - super(CommandSpec.TRACK_INSERT.spec(locale), "insert", CommandPermission.TRACK_INSERT, Predicates.not(2)); + super(CommandSpec.TRACK_INSERT.localize(locale), "insert", CommandPermission.TRACK_INSERT, Predicates.not(2)); } @Override @@ -76,14 +78,14 @@ public class TrackInsert extends SubCommand { if (result.asBoolean()) { Message.TRACK_INSERT_SUCCESS.send(sender, group.getName(), track.getName(), pos); if (track.getGroups().size() > 1) { - Message.EMPTY.send(sender, CommandUtils.listToArrowSep(track.getGroups(), group.getName())); + Message.EMPTY.send(sender, MessageUtils.listToArrowSep(track.getGroups(), group.getName())); } ExtendedLogEntry.build().actor(sender).acted(track) .action("insert", group.getName(), pos) .build().submit(plugin, sender); - save(track, sender, plugin); + StorageAssistant.save(track, sender, plugin); return CommandResult.SUCCESS; } else { Message.TRACK_ALREADY_CONTAINS.send(sender, track.getName(), group.getName()); @@ -98,6 +100,6 @@ public class TrackInsert extends SubCommand { @Override public List tabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return getGroupTabComplete(args, plugin); + return TabCompletions.getGroupTabComplete(args, plugin); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackMainCommand.java similarity index 88% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackMainCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/track/TrackMainCommand.java index 515960a0a..fb7e3d12d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackMainCommand.java @@ -23,20 +23,20 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.track; +package me.lucko.luckperms.common.commands.track; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; import com.google.common.collect.ImmutableList; -import me.lucko.luckperms.common.commands.abstraction.Command; -import me.lucko.luckperms.common.commands.abstraction.MainCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.abstraction.Command; +import me.lucko.luckperms.common.command.abstraction.MainCommand; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import java.util.ArrayList; import java.util.List; @@ -54,7 +54,7 @@ public class TrackMainCommand extends MainCommand { .build(key -> new ReentrantLock()); public TrackMainCommand(LocaleManager locale) { - super(CommandSpec.TRACK.spec(locale), "Track", 2, ImmutableList.>builder() + super(CommandSpec.TRACK.localize(locale), "Track", 2, ImmutableList.>builder() .add(new TrackInfo(locale)) .add(new TrackAppend(locale)) .add(new TrackInsert(locale)) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRemove.java similarity index 76% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRemove.java rename to common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRemove.java index 1468d8772..ff0e5d7a9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRemove.java @@ -23,20 +23,22 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.track; +package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.DataMutateResult; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +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.command.utils.TabCompletions; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; @@ -44,7 +46,7 @@ import java.util.List; public class TrackRemove extends SubCommand { public TrackRemove(LocaleManager locale) { - super(CommandSpec.TRACK_REMOVE.spec(locale), "remove", CommandPermission.TRACK_REMOVE, Predicates.not(1)); + super(CommandSpec.TRACK_REMOVE.localize(locale), "remove", CommandPermission.TRACK_REMOVE, Predicates.not(1)); } @Override @@ -60,14 +62,14 @@ public class TrackRemove extends SubCommand { if (result.asBoolean()) { Message.TRACK_REMOVE_SUCCESS.send(sender, groupName, track.getName()); if (track.getGroups().size() > 1) { - Message.EMPTY.send(sender, CommandUtils.listToArrowSep(track.getGroups())); + Message.EMPTY.send(sender, MessageUtils.listToArrowSep(track.getGroups())); } ExtendedLogEntry.build().actor(sender).acted(track) .action("remove", groupName) .build().submit(plugin, sender); - save(track, sender, plugin); + StorageAssistant.save(track, sender, plugin); return CommandResult.SUCCESS; } else { Message.TRACK_DOES_NOT_CONTAIN.send(sender, track.getName(), groupName); @@ -77,6 +79,6 @@ public class TrackRemove extends SubCommand { @Override public List tabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return getGroupTabComplete(args, plugin); + return TabCompletions.getGroupTabComplete(args, plugin); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRename.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRename.java similarity index 83% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRename.java rename to common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRename.java index db35e67ea..e4e16e426 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/track/TrackRename.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRename.java @@ -23,20 +23,21 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.track; +package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.api.event.cause.DeletionCause; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; @@ -44,7 +45,7 @@ import java.util.List; public class TrackRename extends SubCommand { public TrackRename(LocaleManager locale) { - super(CommandSpec.TRACK_RENAME.spec(locale), "rename", CommandPermission.TRACK_RENAME, Predicates.not(1)); + super(CommandSpec.TRACK_RENAME.localize(locale), "rename", CommandPermission.TRACK_RENAME, Predicates.not(1)); } @Override @@ -85,7 +86,7 @@ public class TrackRename extends SubCommand { .action("rename", newTrack.getName()) .build().submit(plugin, sender); - save(newTrack, sender, plugin); + StorageAssistant.save(newTrack, sender, plugin); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserClone.java similarity index 85% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserClone.java rename to common/src/main/java/me/lucko/luckperms/common/commands/user/UserClone.java index 9cf785889..5b55ef8aa 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserClone.java @@ -23,20 +23,21 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.user; +package me.lucko.luckperms.common.commands.user; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.common.utils.Uuids; @@ -46,7 +47,7 @@ import java.util.UUID; public class UserClone extends SubCommand { public UserClone(LocaleManager locale) { - super(CommandSpec.USER_CLONE.spec(locale), "clone", CommandPermission.USER_CLONE, Predicates.not(1)); + super(CommandSpec.USER_CLONE.localize(locale), "clone", CommandPermission.USER_CLONE, Predicates.not(1)); } @Override @@ -106,7 +107,7 @@ public class UserClone extends SubCommand { .action("clone", user.getName()) .build().submit(plugin, sender); - save(otherUser, sender, plugin); + StorageAssistant.save(otherUser, sender, plugin); plugin.getUserManager().cleanup(otherUser); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserDemote.java similarity index 83% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java rename to common/src/main/java/me/lucko/luckperms/common/commands/user/UserDemote.java index 1c47fbdf0..4b133333a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserDemote.java @@ -23,29 +23,31 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.user; +package me.lucko.luckperms.common.commands.user; import com.google.common.collect.Iterables; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +import me.lucko.luckperms.common.command.utils.MessageUtils; +import me.lucko.luckperms.common.command.utils.StorageAssistant; +import me.lucko.luckperms.common.command.utils.TabCompletions; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.Track; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; @@ -55,7 +57,7 @@ import java.util.stream.Collectors; public class UserDemote extends SubCommand { public UserDemote(LocaleManager locale) { - super(CommandSpec.USER_DEMOTE.spec(locale), "demote", CommandPermission.USER_DEMOTE, Predicates.is(0)); + super(CommandSpec.USER_DEMOTE.localize(locale), "demote", CommandPermission.USER_DEMOTE, Predicates.is(0)); } @Override @@ -83,7 +85,7 @@ public class UserDemote extends SubCommand { } boolean silent = args.remove("-s"); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, getPermission().get(), context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -132,7 +134,7 @@ public class UserDemote extends SubCommand { .action("demote", track.getName(), context) .build().submit(plugin, sender); - save(user, sender, plugin); + StorageAssistant.save(user, sender, plugin); plugin.getEventFactory().handleUserDemote(user, track, old, null, sender); return CommandResult.SUCCESS; } @@ -150,22 +152,22 @@ public class UserDemote extends SubCommand { user.getPrimaryGroup().setStoredValue(previousGroup.getName()); } - Message.USER_DEMOTE_SUCCESS.send(sender, user.getFriendlyName(), track.getName(), old, previousGroup.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.USER_DEMOTE_SUCCESS.send(sender, user.getFriendlyName(), track.getName(), old, previousGroup.getFriendlyName(), MessageUtils.contextSetToString(context)); if (!silent) { - Message.EMPTY.send(sender, CommandUtils.listToArrowSep(track.getGroups(), previousGroup.getName(), old, true)); + Message.EMPTY.send(sender, MessageUtils.listToArrowSep(track.getGroups(), previousGroup.getName(), old, true)); } ExtendedLogEntry.build().actor(sender).acted(user) .action("demote", track.getName(), context) .build().submit(plugin, sender); - save(user, sender, plugin); + StorageAssistant.save(user, sender, plugin); plugin.getEventFactory().handleUserDemote(user, track, old, previousGroup.getName(), sender); return CommandResult.SUCCESS; } @Override public List tabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return getTrackTabComplete(args, plugin); + return TabCompletions.getTrackTabComplete(args, plugin); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserInfo.java similarity index 83% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserInfo.java rename to common/src/main/java/me/lucko/luckperms/common/commands/user/UserInfo.java index 5e6f3645c..4977b3196 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserInfo.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.user; +package me.lucko.luckperms.common.commands.user; import com.google.common.collect.ListMultimap; @@ -31,17 +31,17 @@ import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.caching.MetaData; import me.lucko.luckperms.api.context.ContextSet; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +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.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.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.utils.DateUtil; import me.lucko.luckperms.common.utils.Predicates; @@ -51,7 +51,7 @@ import java.util.stream.Collectors; public class UserInfo extends SubCommand { public UserInfo(LocaleManager locale) { - super(CommandSpec.USER_INFO.spec(locale), "info", CommandPermission.USER_INFO, Predicates.alwaysFalse()); + super(CommandSpec.USER_INFO.localize(locale), "info", CommandPermission.USER_INFO, Predicates.alwaysFalse()); } @SuppressWarnings("unchecked") @@ -84,14 +84,14 @@ public class UserInfo extends SubCommand { if (!parents.isEmpty()) { Message.INFO_PARENT_HEADER.send(sender); for (Node node : parents) { - Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node)); + Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + MessageUtils.getAppendableNodeContextString(node)); } } if (!tempParents.isEmpty()) { Message.INFO_TEMP_PARENT_HEADER.send(sender); for (Node node : tempParents) { - Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + CommandUtils.getAppendableNodeContextString(node)); + Message.EMPTY.send(sender, "&f- &3> &f" + node.getGroupName() + MessageUtils.getAppendableNodeContextString(node)); Message.EMPTY.send(sender, "&f- &2- expires in " + DateUtil.formatDateDiff(node.getExpiryUnixTime())); } } @@ -105,7 +105,7 @@ public class UserInfo extends SubCommand { ContextSet contextSet = contexts.getContexts(); if (!contextSet.isEmpty()) { context = contextSet.toSet().stream() - .map(e -> CommandUtils.contextToString(e.getKey(), e.getValue())) + .map(e -> MessageUtils.contextToString(e.getKey(), e.getValue())) .collect(Collectors.joining(" ")); } @@ -120,12 +120,12 @@ public class UserInfo extends SubCommand { ListMultimap metaMap = data.getMetaMultimap(); if (!metaMap.isEmpty()) { meta = metaMap.entries().stream() - .map(e -> CommandUtils.contextToString(e.getKey(), e.getValue())) + .map(e -> MessageUtils.contextToString(e.getKey(), e.getValue())) .collect(Collectors.joining(" ")); } } - Message.USER_INFO_DATA.send(sender, CommandUtils.formatBoolean(contexts != null), context, prefix, suffix, meta); + Message.USER_INFO_DATA.send(sender, MessageUtils.formatBoolean(contexts != null), context, prefix, suffix, meta); return CommandResult.SUCCESS; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserMainCommand.java similarity index 85% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserMainCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/user/UserMainCommand.java index 0fcbe6ad9..a6953198a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserMainCommand.java @@ -23,28 +23,28 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.user; +package me.lucko.luckperms.common.commands.user; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; import com.google.common.collect.ImmutableList; -import me.lucko.luckperms.common.commands.abstraction.Command; -import me.lucko.luckperms.common.commands.abstraction.MainCommand; -import me.lucko.luckperms.common.commands.impl.generic.meta.CommandMeta; -import me.lucko.luckperms.common.commands.impl.generic.other.HolderClear; -import me.lucko.luckperms.common.commands.impl.generic.other.HolderEditor; -import me.lucko.luckperms.common.commands.impl.generic.other.HolderShowTracks; -import me.lucko.luckperms.common.commands.impl.generic.parent.CommandParent; -import me.lucko.luckperms.common.commands.impl.generic.permission.CommandPermission; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.abstraction.Command; +import me.lucko.luckperms.common.command.abstraction.MainCommand; +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; +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.CommandSpec; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.command.CommandSpec; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.references.UserIdentifier; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.DataConstraints; import me.lucko.luckperms.common.utils.Uuids; @@ -65,7 +65,7 @@ public class UserMainCommand extends MainCommand { .build(key -> new ReentrantLock()); public UserMainCommand(LocaleManager locale) { - super(CommandSpec.USER.spec(locale), "User", 2, ImmutableList.>builder() + super(CommandSpec.USER.localize(locale), "User", 2, ImmutableList.>builder() .add(new UserInfo(locale)) .add(new CommandPermission<>(locale, true)) .add(new CommandParent<>(locale, true)) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserPromote.java similarity index 83% rename from common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java rename to common/src/main/java/me/lucko/luckperms/common/commands/user/UserPromote.java index ecda5d85a..a0281042f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserPromote.java @@ -23,27 +23,29 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.impl.user; +package me.lucko.luckperms.common.commands.user; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; -import me.lucko.luckperms.common.commands.ArgumentPermissions; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.ArgumentPermissions; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +import me.lucko.luckperms.common.command.utils.MessageUtils; +import me.lucko.luckperms.common.command.utils.StorageAssistant; +import me.lucko.luckperms.common.command.utils.TabCompletions; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.Track; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.DataConstraints; import me.lucko.luckperms.common.utils.Predicates; @@ -53,7 +55,7 @@ import java.util.stream.Collectors; public class UserPromote extends SubCommand { public UserPromote(LocaleManager locale) { - super(CommandSpec.USER_PROMOTE.spec(locale), "promote", CommandPermission.USER_PROMOTE, Predicates.is(0)); + super(CommandSpec.USER_PROMOTE.localize(locale), "promote", CommandPermission.USER_PROMOTE, Predicates.is(0)); } @Override @@ -81,7 +83,7 @@ public class UserPromote extends SubCommand { } boolean silent = args.remove("-s"); - MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin); + MutableContextSet context = ArgumentParser.parseContext(1, args, plugin); if (ArgumentPermissions.checkContext(plugin, sender, getPermission().get(), context)) { Message.COMMAND_NO_PERMISSION.send(sender); @@ -113,13 +115,13 @@ public class UserPromote extends SubCommand { user.setPermission(NodeFactory.buildGroupNode(nextGroup.getId()).withExtraContext(context).build()); - Message.USER_TRACK_ADDED_TO_FIRST.send(sender, user.getFriendlyName(), nextGroup.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.USER_TRACK_ADDED_TO_FIRST.send(sender, user.getFriendlyName(), nextGroup.getFriendlyName(), MessageUtils.contextSetToString(context)); ExtendedLogEntry.build().actor(sender).acted(user) .action("promote", track.getName(), context) .build().submit(plugin, sender); - save(user, sender, plugin); + StorageAssistant.save(user, sender, plugin); plugin.getEventFactory().handleUserPromote(user, track, null, first, sender); return CommandResult.SUCCESS; } @@ -167,22 +169,22 @@ public class UserPromote extends SubCommand { user.getPrimaryGroup().setStoredValue(nextGroup.getName()); } - Message.USER_PROMOTE_SUCCESS.send(sender, user.getFriendlyName(), track.getName(), old, nextGroup.getFriendlyName(), CommandUtils.contextSetToString(context)); + Message.USER_PROMOTE_SUCCESS.send(sender, user.getFriendlyName(), track.getName(), old, nextGroup.getFriendlyName(), MessageUtils.contextSetToString(context)); if (!silent) { - Message.EMPTY.send(sender, CommandUtils.listToArrowSep(track.getGroups(), old, nextGroup.getName(), false)); + Message.EMPTY.send(sender, MessageUtils.listToArrowSep(track.getGroups(), old, nextGroup.getName(), false)); } ExtendedLogEntry.build().actor(sender).acted(user) .action("promote", track.getName(), context) .build().submit(plugin, sender); - save(user, sender, plugin); + StorageAssistant.save(user, sender, plugin); plugin.getEventFactory().handleUserPromote(user, track, old, nextGroup.getName(), sender); return CommandResult.SUCCESS; } @Override public List tabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return getTrackTabComplete(args, plugin); + return TabCompletions.getTrackTabComplete(args, plugin); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/utils/MetaComparator.java b/common/src/main/java/me/lucko/luckperms/common/commands/utils/MetaComparator.java deleted file mode 100644 index b3ca5b016..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/commands/utils/MetaComparator.java +++ /dev/null @@ -1,46 +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.commands.utils; - -import me.lucko.luckperms.api.LocalizedNode; -import me.lucko.luckperms.common.node.NodeWithContextComparator; - -import java.util.Comparator; -import java.util.Map; - -public class MetaComparator implements Comparator> { - public static final MetaComparator INSTANCE = new MetaComparator(); - - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - int result = Integer.compare(o1.getKey(), o2.getKey()); - if (result != 0) { - return result; - } - return NodeWithContextComparator.normal().compare(o1.getValue(), o2.getValue()); - } - -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java b/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java index 4f6df8f2f..b8eddff7f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java @@ -40,7 +40,6 @@ import me.lucko.luckperms.api.event.log.LogNotifyEvent; import me.lucko.luckperms.common.api.LuckPermsApiProvider; import me.lucko.luckperms.common.api.delegates.model.ApiPermissionHolder; import me.lucko.luckperms.common.api.delegates.model.ApiUser; -import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.event.impl.EventConfigReload; import me.lucko.luckperms.common.event.impl.EventGroupCacheLoad; import me.lucko.luckperms.common.event.impl.EventGroupCreate; @@ -80,6 +79,7 @@ import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import java.util.Collection; import java.util.List; diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNotify.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNotify.java index ee6ccb469..6ce1a7db9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNotify.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNotify.java @@ -28,9 +28,9 @@ package me.lucko.luckperms.common.event.impl; import me.lucko.luckperms.api.Entity; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.event.log.LogNotifyEvent; -import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.event.AbstractEvent; import me.lucko.luckperms.common.event.model.EntitySender; +import me.lucko.luckperms.common.sender.Sender; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/common/src/main/java/me/lucko/luckperms/common/event/model/EntitySender.java b/common/src/main/java/me/lucko/luckperms/common/event/model/EntitySender.java index 768072f72..3a90eb356 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/model/EntitySender.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/model/EntitySender.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.common.event.model; import me.lucko.luckperms.api.Entity; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.sender.Sender; import java.util.UUID; diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/CommandSpec.java b/common/src/main/java/me/lucko/luckperms/common/locale/CommandSpec.java deleted file mode 100644 index dde85bdc4..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/locale/CommandSpec.java +++ /dev/null @@ -1,665 +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.ImmutableList; - -import me.lucko.luckperms.common.commands.Arg; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; - -/** - * 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("User commands", "/%s user "), - GROUP("Group commands", "/%s group "), - TRACK("Track commands", "/%s track "), - LOG("Log commands", "/%s log"), - - SYNC("Sync changes with the storage", "/%s sync"), - INFO("Print general plugin info", "/%s info"), - EDITOR("Creates a new editor session", "/%s editor [type]", - Arg.list( - Arg.create("type", false, "the types to load into the editor. ('all', 'users' or 'groups')") - ) - ), - DEBUG("Produce debugging output", "/%s debug"), - VERBOSE("Manage verbose permission checking", "/%s verbose [filter]", - Arg.list( - Arg.create("on|record|off|paste", true, "whether to enable/disable logging, or to paste the logged output"), - Arg.create("filter", false, "the filter to match entries against") - ) - ), - TREE("Generate a tree view of permissions", "/%s tree [scope] [player]", - Arg.list( - Arg.create("scope", false, "the root of the tree. specify \".\" to include all permissions"), - Arg.create("player", false, "the name of an online player to check against") - ) - ), - SEARCH("Search for users/groups with a specific permission", "/%s search ", - Arg.list( - Arg.create("permission", true, "the permission to search for"), - Arg.create("page", false, "the page to view") - ) - ), - CHECK("Perform a standard permission check on an online player", "/%s check ", - Arg.list( - Arg.create("user", true, "the user to check"), - Arg.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("Import data from a file", "/%s import ", - Arg.list( - Arg.create("file", true, "the file to import from") - ) - ), - EXPORT("Export data to a file", "/%s export ", - Arg.list( - Arg.create("file", true, "the file to export to") - ) - ), - RELOAD_CONFIG("Reload some of the config options", "/%s reloadconfig"), - BULK_UPDATE("Execute bulk change queries on all data", "/%s bulkupdate", - Arg.list( - Arg.create("data type", true, "the type of data being changed. ('all', 'users' or 'groups')"), - Arg.create("action", true, "the action to perform on the data. ('update' or 'delete')"), - Arg.create("action field", false, "the field to act upon. only required for 'update'. ('permission', 'server' or 'world')"), - Arg.create("action value", false, "the value to replace with. only required for 'update'."), - Arg.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]", - Arg.list( - Arg.create("code", true, "the unique code for the data"), - Arg.create("target", false, "who to apply the data to") - ) - ), - - CREATE_GROUP("Create a new group", "/%s creategroup ", - Arg.list( - Arg.create("name", true, "the name of the group") - ) - ), - DELETE_GROUP("Delete a group", "/%s deletegroup ", - Arg.list( - Arg.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 ", - Arg.list( - Arg.create("name", true, "the name of the track") - ) - ), - DELETE_TRACK("Delete a track", "/%s deletetrack ", - Arg.list( - Arg.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", - Arg.list( - Arg.create("group", true, "the group to switch to") - ) - ), - USER_PROMOTE("Promotes the user up a track", - Arg.list( - Arg.create("track", true, "the track to promote the user up"), - Arg.create("context...", false, "the contexts to promote the user in") - ) - ), - USER_DEMOTE("Demotes the user down a track", - Arg.list( - Arg.create("track", true, "the track to demote the user down"), - Arg.create("context...", false, "the contexts to demote the user in") - ) - ), - USER_CLONE("Clone the user", - Arg.list( - Arg.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", - Arg.list( - Arg.create("page", false, "the page to view") - ) - ), - GROUP_SETWEIGHT("Set the groups weight", - Arg.list( - Arg.create("weight", true, "the weight to set") - ) - ), - GROUP_SET_DISPLAY_NAME("Set the groups display name", - Arg.list( - Arg.create("name", true, "the name to set") - ) - ), - GROUP_RENAME("Rename the group", - Arg.list( - Arg.create("name", true, "the new name") - ) - ), - GROUP_CLONE("Clone the group", - Arg.list( - Arg.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", - Arg.list( - Arg.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", - Arg.list( - Arg.create("page", false, "the page to view"), - Arg.create("sort mode", false, "how to sort the entries") - ) - ), - PERMISSION_SET("Sets a permission for the object", - Arg.list( - Arg.create("node", true, "the permission node to set"), - Arg.create("true|false", false, "the value of the node"), - Arg.create("context...", false, "the contexts to add the permission in") - ) - ), - PERMISSION_UNSET("Unsets a permission for the object", - Arg.list( - Arg.create("node", true, "the permission node to unset"), - Arg.create("context...", false, "the contexts to remove the permission in") - ) - ), - PERMISSION_SETTEMP("Sets a permission for the object temporarily", - Arg.list( - Arg.create("node", true, "the permission node to set"), - Arg.create("true|false", false, "the value of the node"), - Arg.create("duration", true, "the duration until the permission node expires"), - Arg.create("context...", false, "the contexts to add the permission in") - ) - ), - PERMISSION_UNSETTEMP("Unsets a temporary permission for the object", - Arg.list( - Arg.create("node", true, "the permission node to unset"), - Arg.create("context...", false, "the contexts to remove the permission in") - ) - ), - PERMISSION_CHECK("Checks to see if the object has a certain permission node", - Arg.list( - Arg.create("node", true, "the permission node to check for"), - Arg.create("context...", false, "the contexts to check in") - ) - ), - PERMISSION_CHECK_INHERITS("Checks to see if the object inherits a certain permission node", - Arg.list( - Arg.create("node", true, "the permission node to check for"), - Arg.create("context...", false, "the contexts to check in") - ) - ), - - PARENT_INFO("Lists the groups that this object inherits from", - Arg.list( - Arg.create("page", false, "the page to view"), - Arg.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", - Arg.list( - Arg.create("group", true, "the group to set to"), - Arg.create("context...", false, "the contexts to set the group in") - ) - ), - PARENT_ADD("Sets another group for the object to inherit permissions from", - Arg.list( - Arg.create("group", true, "the group to inherit from"), - Arg.create("context...", false, "the contexts to inherit the group in") - ) - ), - PARENT_REMOVE("Removes a previously set inheritance rule", - Arg.list( - Arg.create("group", true, "the group to remove"), - Arg.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", - Arg.list( - Arg.create("track", true, "the track to set on"), - Arg.create("group", true, "the group to set to, or a number relating to the position of the group on the given track"), - Arg.create("context...", false, "the contexts to set the group in") - ) - ), - PARENT_ADD_TEMP("Sets another group for the object to inherit permissions from temporarily", - Arg.list( - Arg.create("group", true, "the group to inherit from"), - Arg.create("duration", true, "the duration of the group membership"), - Arg.create("context...", false, "the contexts to inherit the group in") - ) - ), - PARENT_REMOVE_TEMP("Removes a previously set temporary inheritance rule", - Arg.list( - Arg.create("group", true, "the group to remove"), - Arg.create("context...", false, "the contexts to remove the group in") - ) - ), - PARENT_CLEAR("Clears all parents", - Arg.list( - Arg.create("context...", false, "the contexts to filter by") - ) - ), - PARENT_CLEAR_TRACK("Clears all parents on a given track", - Arg.list( - Arg.create("track", true, "the track to remove on"), - Arg.create("context...", false, "the contexts to filter by") - ) - ), - - META_INFO("Shows all chat meta"), - META_SET("Sets a meta value", - Arg.list( - Arg.create("key", true, "the key to set"), - Arg.create("value", true, "the value to set"), - Arg.create("context...", false, "the contexts to add the meta pair in") - ) - ), - META_UNSET("Unsets a meta value", - Arg.list( - Arg.create("key", true, "the key to unset"), - Arg.create("context...", false, "the contexts to remove the meta pair in") - ) - ), - META_SETTEMP("Sets a meta value temporarily", - Arg.list( - Arg.create("key", true, "the key to set"), - Arg.create("value", true, "the value to set"), - Arg.create("duration", true, "the duration until the meta value expires"), - Arg.create("context...", false, "the contexts to add the meta pair in") - ) - ), - META_UNSETTEMP("Unsets a temporary meta value", - Arg.list( - Arg.create("key", true, "the key to unset"), - Arg.create("context...", false, "the contexts to remove the meta pair in") - ) - ), - META_ADDPREFIX("Adds a prefix", - Arg.list( - Arg.create("priority", true, "the priority to add the prefix at"), - Arg.create("prefix", true, "the prefix string"), - Arg.create("context...", false, "the contexts to add the prefix in") - ) - ), - META_ADDSUFFIX("Adds a suffix", - Arg.list( - Arg.create("priority", true, "the priority to add the suffix at"), - Arg.create("suffix", true, "the suffix string"), - Arg.create("context...", false, "the contexts to add the suffix in") - ) - ), - META_REMOVEPREFIX("Removes a prefix", - Arg.list( - Arg.create("priority", true, "the priority to remove the prefix at"), - Arg.create("prefix", false, "the prefix string"), - Arg.create("context...", false, "the contexts to remove the prefix in") - ) - ), - META_REMOVESUFFIX("Removes a suffix", - Arg.list( - Arg.create("priority", true, "the priority to remove the suffix at"), - Arg.create("suffix", false, "the suffix string"), - Arg.create("context...", false, "the contexts to remove the suffix in") - ) - ), - META_ADDTEMP_PREFIX("Adds a prefix temporarily", - Arg.list( - Arg.create("priority", true, "the priority to add the prefix at"), - Arg.create("prefix", true, "the prefix string"), - Arg.create("duration", true, "the duration until the prefix expires"), - Arg.create("context...", false, "the contexts to add the prefix in") - ) - ), - META_ADDTEMP_SUFFIX("Adds a suffix temporarily", - Arg.list( - Arg.create("priority", true, "the priority to add the suffix at"), - Arg.create("suffix", true, "the suffix string"), - Arg.create("duration", true, "the duration until the suffix expires"), - Arg.create("context...", false, "the contexts to add the suffix in") - ) - ), - META_REMOVETEMP_PREFIX("Removes a temporary prefix", - Arg.list( - Arg.create("priority", true, "the priority to remove the prefix at"), - Arg.create("prefix", false, "the prefix string"), - Arg.create("context...", false, "the contexts to remove the prefix in") - ) - ), - META_REMOVETEMP_SUFFIX("Removes a temporary suffix", - Arg.list( - Arg.create("priority", true, "the priority to remove the suffix at"), - Arg.create("suffix", false, "the suffix string"), - Arg.create("context...", false, "the contexts to remove the suffix in") - ) - ), - META_CLEAR("Clears all meta", - Arg.list( - Arg.create("type", false, "the type of meta to remove"), - Arg.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", - Arg.list( - Arg.create("group", true, "the group to append") - ) - ), - TRACK_INSERT("Inserts a group at a given position along the track", - Arg.list( - Arg.create("group", true, "the group to insert"), - Arg.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", - Arg.list( - Arg.create("group", true, "the group to remove") - ) - ), - TRACK_CLEAR("Clears the groups on the track"), - TRACK_RENAME("Rename the track", - Arg.list( - Arg.create("name", true, "the new name") - ) - ), - TRACK_CLONE("Clone the track", - Arg.list( - Arg.create("name", true, "the name of the track to clone onto") - ) - ), - - LOG_RECENT("View recent actions", - Arg.list( - Arg.create("user", false, "the name/uuid of the user to filter by"), - Arg.create("page", false, "the page number to view") - ) - ), - LOG_SEARCH("Search the log for an entry", - Arg.list( - Arg.create("query", true, "the query to search by"), - Arg.create("page", false, "the page number to view") - ) - ), - LOG_NOTIFY("Toggle log notifications", - Arg.list( - Arg.create("on|off", false, "whether to toggle on or off") - ) - ), - LOG_USER_HISTORY("View a user's history", - Arg.list( - Arg.create("user", true, "the name/uuid of the user"), - Arg.create("page", false, "the page number to view") - ) - ), - LOG_GROUP_HISTORY("View an group's history", - Arg.list( - Arg.create("group", true, "the name of the group"), - Arg.create("page", false, "the page number to view") - ) - ), - LOG_TRACK_HISTORY("View a track's history", - Arg.list( - Arg.create("track", true, "the name of the track"), - Arg.create("page", false, "the page number to view") - ) - ), - - SPONGE("Edit extra Sponge data", "/%s sponge ", - Arg.list( - Arg.create("collection", true, "the collection to query"), - Arg.create("subject", true, "the subject to modify") - ) - ), - SPONGE_PERMISSION_INFO("Shows info about the subject's permissions", - Arg.list( - Arg.create("contexts...", false, "the contexts to filter by") - ) - ), - SPONGE_PERMISSION_SET("Sets a permission for the Subject", - Arg.list( - Arg.create("node", true, "the permission node to set"), - Arg.create("tristate", true, "the value to set the permission to"), - Arg.create("contexts...", false, "the contexts to set the permission in") - ) - ), - SPONGE_PERMISSION_CLEAR("Clears the Subjects permissions", - Arg.list( - Arg.create("contexts...", false, "the contexts to clear permissions in") - ) - ), - SPONGE_PARENT_INFO("Shows info about the subject's parents", - Arg.list( - Arg.create("contexts...", false, "the contexts to filter by") - ) - ), - SPONGE_PARENT_ADD("Adds a parent to the Subject", - Arg.list( - Arg.create("collection", true, "the subject collection where the parent Subject is"), - Arg.create("subject", true, "the name of the parent Subject"), - Arg.create("contexts...", false, "the contexts to add the parent in") - ) - ), - SPONGE_PARENT_REMOVE("Removes a parent from the Subject", - Arg.list( - Arg.create("collection", true, "the subject collection where the parent Subject is"), - Arg.create("subject", true, "the name of the parent Subject"), - Arg.create("contexts...", false, "the contexts to remove the parent in") - ) - ), - SPONGE_PARENT_CLEAR("Clears the Subjects parents", - Arg.list( - Arg.create("contexts...", false, "the contexts to clear parents in") - ) - ), - SPONGE_OPTION_INFO("Shows info about the subject's options", - Arg.list( - Arg.create("contexts...", false, "the contexts to filter by") - ) - ), - SPONGE_OPTION_SET("Sets an option for the Subject", - Arg.list( - Arg.create("key", true, "the key to set"), - Arg.create("value", true, "the value to set the key to"), - Arg.create("contexts...", false, "the contexts to set the option in") - ) - ), - SPONGE_OPTION_UNSET("Unsets an option for the Subject", - Arg.list( - Arg.create("key", true, "the key to unset"), - Arg.create("contexts...", false, "the contexts to unset the key in") - ) - ), - SPONGE_OPTION_CLEAR("Clears the Subjects options", - Arg.list( - Arg.create("contexts...", false, "the contexts to clear options in") - ) - ), - - MIGRATION_COMMAND("Migration command"), - MIGRATION_GROUPMANAGER("Migration command", - Arg.list( - Arg.create("migrate as global", true, "if world permissions should be ignored, and just migrated as global") - ) - ), - MIGRATION_POWERFULPERMS("Migration command", - Arg.list( - Arg.create("address", true, "the address of the PP database"), - Arg.create("database", true, "the name of the PP database"), - Arg.create("username", true, "the username to log into the DB"), - Arg.create("password", true, "the password to log into the DB"), - Arg.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); - } - - /** - * Creates a {@link LocalizedSpec} for the spec using the platforms locale manager. - * - * @param localeManager the locale manager to use for the spec - * @return a localized spec instance - */ - public LocalizedSpec spec(LocaleManager localeManager) { - return new SimpleLocalizedSpec(this, localeManager); - } - - private static final class SimpleLocalizedSpec implements LocalizedSpec { - private final LocaleManager localeManager; - private final CommandSpec spec; - - public SimpleLocalizedSpec(CommandSpec spec, LocaleManager localeManager) { - this.localeManager = localeManager; - this.spec = spec; - } - - @Override - public String description() { - CommandSpecData translation = this.localeManager.getTranslation(this.spec); - if (translation != null && translation.getDescription() != null) { - return translation.getDescription(); - } - - // fallback - return this.spec.description; - } - - @Override - public String usage() { - CommandSpecData translation = this.localeManager.getTranslation(this.spec); - if (translation != null && translation.getUsage() != null) { - return translation.getUsage(); - } - - // fallback - return this.spec.usage; - } - - @Override - public List args() { - CommandSpecData translation = this.localeManager.getTranslation(this.spec); - if (translation == null || translation.getArgs() == null) { - // fallback - return this.spec.args; - } - - List args = new ArrayList<>(this.spec.args); - ListIterator it = args.listIterator(); - while (it.hasNext()) { - Arg 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(Arg.create(next.getName(), next.isRequired(), s)); - } - } - - return ImmutableList.copyOf(args); - } - - @Override - public LocaleManager getLocaleManager() { - return this.localeManager; - } - } - - /** - * Prints this CommandSpec enum in a yml format, for reading by the {@link me.lucko.luckperms.common.locale.LocaleManager} - * @param args not needed - */ - 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 (Arg arg : spec.args) { - System.out.println(" \"" + arg.getName() + "\": \"" + arg.getDescription().replace("\"", "\\\"") + "\""); - } - } - } - } - -} 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 index f201b91cb..80aeff4c8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/LocaleManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/LocaleManager.java @@ -25,6 +25,9 @@ package me.lucko.luckperms.common.locale; +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 java.io.File; diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/SimpleLocaleManager.java b/common/src/main/java/me/lucko/luckperms/common/locale/SimpleLocaleManager.java index be0d22172..97a8ec6f0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/SimpleLocaleManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/SimpleLocaleManager.java @@ -27,6 +27,9 @@ 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; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/Arg.java b/common/src/main/java/me/lucko/luckperms/common/locale/command/Argument.java similarity index 84% rename from common/src/main/java/me/lucko/luckperms/common/commands/Arg.java rename to common/src/main/java/me/lucko/luckperms/common/locale/command/Argument.java index bdb1f2aff..d4d6962b4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/Arg.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/command/Argument.java @@ -23,16 +23,16 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands; +package me.lucko.luckperms.common.locale.command; import com.google.common.collect.ImmutableList; -public class Arg { - public static Arg create(String name, boolean required, String description) { - return new Arg(name, required, description); +public class Argument { + public static Argument create(String name, boolean required, String description) { + return new Argument(name, required, description); } - public static ImmutableList list(Arg... args) { + public static ImmutableList list(Argument... args) { return ImmutableList.copyOf(args); } @@ -40,7 +40,7 @@ public class Arg { private final boolean required; private final String description; - private Arg(String name, boolean required, String description) { + private Argument(String name, boolean required, String description) { this.name = name; this.required = required; this.description = description; 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 new file mode 100644 index 000000000..3cfa7522e --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpec.java @@ -0,0 +1,665 @@ +/* + * 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; + +/** + * 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("User commands", "/%s user "), + GROUP("Group commands", "/%s group "), + TRACK("Track commands", "/%s track "), + LOG("Log commands", "/%s log"), + + SYNC("Sync changes with the storage", "/%s sync"), + INFO("Print general plugin info", "/%s info"), + EDITOR("Creates a new editor session", "/%s editor [type]", + Argument.list( + Argument.create("type", false, "the types to load into the editor. ('all', 'users' or 'groups')") + ) + ), + DEBUG("Produce debugging output", "/%s debug"), + VERBOSE("Manage verbose permission checking", "/%s verbose [filter]", + Argument.list( + Argument.create("on|record|off|paste", true, "whether to enable/disable logging, or to paste the logged output"), + Argument.create("filter", false, "the filter to match entries against") + ) + ), + TREE("Generate a tree view of permissions", "/%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("Search for 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("Perform a standard permission check on 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("Import data from a file", "/%s import ", + Argument.list( + Argument.create("file", true, "the file to import from") + ) + ), + EXPORT("Export data to a file", "/%s export ", + Argument.list( + Argument.create("file", true, "the file to export to") + ) + ), + 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", true, "the track to promote the user up"), + Argument.create("context...", false, "the contexts to promote the user in") + ) + ), + USER_DEMOTE("Demotes the user down a track", + Argument.list( + Argument.create("track", true, "the track to demote the user down"), + Argument.create("context...", false, "the contexts to demote the user in") + ) + ), + 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") + ) + ), + 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("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("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") + ) + ), + + 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("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("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_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_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); + } + + /** + * 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 Localized(this, localeManager); + } + + private static final class Localized implements LocalizedCommandSpec { + private final LocaleManager localeManager; + private final CommandSpec spec; + + private Localized(CommandSpec spec, LocaleManager localeManager) { + this.localeManager = localeManager; + this.spec = spec; + } + + @Override + public String description() { + CommandSpecData translation = this.localeManager.getTranslation(this.spec); + if (translation != null && translation.getDescription() != null) { + return translation.getDescription(); + } + + // fallback + return this.spec.description; + } + + @Override + public String usage() { + CommandSpecData translation = this.localeManager.getTranslation(this.spec); + if (translation != null && translation.getUsage() != null) { + return translation.getUsage(); + } + + // fallback + return this.spec.usage; + } + + @Override + public List args() { + CommandSpecData translation = this.localeManager.getTranslation(this.spec); + if (translation == null || translation.getArgs() == null) { + // fallback + return this.spec.args; + } + + List args = new ArrayList<>(this.spec.args); + 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); + } + + @Override + public LocaleManager getLocaleManager() { + return this.localeManager; + } + } + + /** + * Prints this CommandSpec enum in a yml format, for reading by the {@link me.lucko.luckperms.common.locale.LocaleManager} + * @param args not needed + */ + 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/CommandSpecData.java b/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpecData.java similarity index 84% rename from common/src/main/java/me/lucko/luckperms/common/locale/CommandSpecData.java rename to common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpecData.java index 9f650c6c2..fc57333d7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/CommandSpecData.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/command/CommandSpecData.java @@ -23,12 +23,12 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.locale; +package me.lucko.luckperms.common.locale.command; import java.util.Map; import java.util.Objects; -import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * The localized data for a {@link CommandSpec}. @@ -38,23 +38,23 @@ public final class CommandSpecData { private final String usage; private final Map args; - public CommandSpecData(String description, String usage, Map args) { + public CommandSpecData(@Nullable String description, @Nullable String usage, @Nullable Map args) { this.description = description; this.usage = usage; this.args = args; } - @Nonnull + @Nullable public String getDescription() { return this.description; } - @Nonnull + @Nullable public String getUsage() { return this.usage; } - @Nonnull + @Nullable public Map getArgs() { return this.args; } @@ -65,9 +65,9 @@ public final class CommandSpecData { if (!(o instanceof CommandSpecData)) return false; final CommandSpecData that = (CommandSpecData) o; - return this.getDescription().equals(that.getDescription()) && - this.getUsage().equals(that.getUsage()) && - this.getArgs().equals(that.getArgs()); + return Objects.equals(this.getDescription(), that.getDescription()) && + Objects.equals(this.getUsage(), that.getUsage()) && + Objects.equals(this.getArgs(), that.getArgs()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/LocalizedSpec.java b/common/src/main/java/me/lucko/luckperms/common/locale/command/LocalizedCommandSpec.java similarity index 90% rename from common/src/main/java/me/lucko/luckperms/common/locale/LocalizedSpec.java rename to common/src/main/java/me/lucko/luckperms/common/locale/command/LocalizedCommandSpec.java index 97c023f27..440ac0405 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/LocalizedSpec.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/command/LocalizedCommandSpec.java @@ -23,16 +23,16 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.locale; +package me.lucko.luckperms.common.locale.command; -import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.locale.LocaleManager; import java.util.List; /** * Represents a localized instance of a {@link CommandSpec}. */ -public interface LocalizedSpec { +public interface LocalizedCommandSpec { /** * Gets the locale manager used to translate the {@link CommandSpec}. @@ -45,6 +45,6 @@ public interface LocalizedSpec { String usage(); - List args(); + List args(); } 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/Message.java similarity index 98% rename from common/src/main/java/me/lucko/luckperms/common/locale/Message.java rename to common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java index 99ebf8484..6aa711000 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java @@ -23,12 +23,15 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.locale; +package me.lucko.luckperms.common.locale.message; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; +import me.lucko.luckperms.common.command.utils.MessageUtils; +import me.lucko.luckperms.common.locale.LocaleManager; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.TextUtils; +import javax.annotation.Nullable; + /** * An enumeration of some of the messages used within the plugin. * @@ -456,7 +459,11 @@ public enum Message { return this.message; } - public String asString(LocaleManager localeManager, Object... objects) { + public String asString(Object... objects) { + return asString(null, objects); + } + + public String asString(@Nullable LocaleManager localeManager, Object... objects) { String prefix = null; if (localeManager != null) { prefix = localeManager.getTranslation(PREFIX); @@ -474,7 +481,7 @@ public enum Message { } s = format(s.replace("{PREFIX}", prefix).replace("\\n", "\n"), objects); - return CommandUtils.color(this.showPrefix ? prefix + s : s); + return MessageUtils.color(this.showPrefix ? prefix + s : s); } public void send(Sender sender, Object... objects) { @@ -482,7 +489,7 @@ public enum Message { } /** - * Prints this Message enum in a yml format, for reading by the {@link me.lucko.luckperms.common.locale.LocaleManager} + * Prints this Message enum in a yml format, for reading by the locale manager * @param args not needed */ public static void main(String[] args) { diff --git a/common/src/main/java/me/lucko/luckperms/common/logging/ProgressLogger.java b/common/src/main/java/me/lucko/luckperms/common/logging/ProgressLogger.java index 55123e2db..d31f229c6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/logging/ProgressLogger.java +++ b/common/src/main/java/me/lucko/luckperms/common/logging/ProgressLogger.java @@ -25,8 +25,8 @@ package me.lucko.luckperms.common.logging; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.sender.Sender; import java.util.HashSet; import java.util.Set; diff --git a/common/src/main/java/me/lucko/luckperms/common/logging/SenderLogger.java b/common/src/main/java/me/lucko/luckperms/common/logging/SenderLogger.java index 6c355f52f..1f75194f0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/logging/SenderLogger.java +++ b/common/src/main/java/me/lucko/luckperms/common/logging/SenderLogger.java @@ -25,11 +25,11 @@ package me.lucko.luckperms.common.logging; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; +import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import java.util.Objects; @@ -60,7 +60,7 @@ public class SenderLogger implements Logger { private void msg(Message message, String s) { String msg = message.asString(this.plugin.getLocaleManager(), s); if (this.plugin.getConfiguration() != null && !this.plugin.getConfiguration().get(ConfigKeys.USE_COLORED_LOGGER)) { - msg = CommandUtils.stripColor(msg); + msg = MessageUtils.stripColor(msg); } this.console.sendMessage(msg); } diff --git a/common/src/main/java/me/lucko/luckperms/common/messaging/message/LogMessageImpl.java b/common/src/main/java/me/lucko/luckperms/common/messaging/message/LogMessageImpl.java index ab1e3da9f..37be3215f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/messaging/message/LogMessageImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/messaging/message/LogMessageImpl.java @@ -111,7 +111,7 @@ public class LogMessageImpl extends AbstractMessage implements LogMessage { } private static LogMessageImpl decodeContent(JsonObject object) { - ExtendedLogEntry.ExtendedLogEntryBuilder builder = ExtendedLogEntry.build(); + ExtendedLogEntry.Builder builder = ExtendedLogEntry.build(); String id = object.get("id").getAsString(); if (id == null) { 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 3d6ee539e..ce022589e 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 @@ -33,8 +33,7 @@ import me.lucko.luckperms.common.buffers.BufferedRequest; import me.lucko.luckperms.common.buffers.UpdateTaskBuffer; import me.lucko.luckperms.common.caching.handlers.CachedStateManager; import me.lucko.luckperms.common.calculators.PlatformCalculatorFactory; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; +import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.config.AbstractConfiguration; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.config.LuckPermsConfiguration; @@ -50,6 +49,7 @@ import me.lucko.luckperms.common.logging.Logger; import me.lucko.luckperms.common.logging.SenderLogger; import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.messaging.MessagingFactory; +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; @@ -329,12 +329,12 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { } private void displayBanner(Sender sender) { - sender.sendMessage(CommandUtils.color("&b __ &3 __ ___ __ __ ")); - sender.sendMessage(CommandUtils.color("&b | | | / ` |__/ &3|__) |__ |__) |\\/| /__` ")); - sender.sendMessage(CommandUtils.color("&b |___ \\__/ \\__, | \\ &3| |___ | \\ | | .__/ ")); - sender.sendMessage(CommandUtils.color(" ")); - sender.sendMessage(CommandUtils.color("&2 Loading version &bv" + getBootstrap().getVersion() + "&2 on " + getBootstrap().getType().getFriendlyName() + " - " + getBootstrap().getServerBrand())); - sender.sendMessage(CommandUtils.color("&8 Running on server version " + getBootstrap().getServerVersion())); - sender.sendMessage(CommandUtils.color(" ")); + sender.sendMessage(MessageUtils.color("&b __ &3 __ ___ __ __ ")); + sender.sendMessage(MessageUtils.color("&b | | | / ` |__/ &3|__) |__ |__) |\\/| /__` ")); + sender.sendMessage(MessageUtils.color("&b |___ \\__/ \\__, | \\ &3| |___ | \\ | | .__/ ")); + sender.sendMessage(MessageUtils.color(" ")); + sender.sendMessage(MessageUtils.color("&2 Loading version &bv" + getBootstrap().getVersion() + "&2 on " + getBootstrap().getType().getFriendlyName() + " - " + getBootstrap().getServerBrand())); + sender.sendMessage(MessageUtils.color("&8 Running on server version " + getBootstrap().getServerVersion())); + sender.sendMessage(MessageUtils.color(" ")); } } 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 d955edd98..385b438c5 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 @@ -31,9 +31,8 @@ import me.lucko.luckperms.common.api.LuckPermsApiProvider; import me.lucko.luckperms.common.buffers.BufferedRequest; import me.lucko.luckperms.common.caching.handlers.CachedStateManager; import me.lucko.luckperms.common.calculators.CalculatorFactory; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.abstraction.Command; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.abstraction.Command; import me.lucko.luckperms.common.config.LuckPermsConfiguration; import me.lucko.luckperms.common.contexts.ContextManager; import me.lucko.luckperms.common.dependencies.DependencyManager; @@ -48,6 +47,7 @@ import me.lucko.luckperms.common.managers.user.UserManager; import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.Storage; import me.lucko.luckperms.common.storage.dao.file.FileWatcher; import me.lucko.luckperms.common.treeview.PermissionVault; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java b/common/src/main/java/me/lucko/luckperms/common/sender/AbstractSender.java similarity index 98% rename from common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java rename to common/src/main/java/me/lucko/luckperms/common/sender/AbstractSender.java index 17ac2d69a..72b06fd6d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/sender/AbstractSender.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/AbstractSender.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.sender; +package me.lucko.luckperms.common.sender; import com.google.common.base.Splitter; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/sender/DummySender.java b/common/src/main/java/me/lucko/luckperms/common/sender/DummySender.java similarity index 96% rename from common/src/main/java/me/lucko/luckperms/common/commands/sender/DummySender.java rename to common/src/main/java/me/lucko/luckperms/common/sender/DummySender.java index 0d384c3c4..e7f210503 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/sender/DummySender.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/DummySender.java @@ -23,10 +23,10 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.sender; +package me.lucko.luckperms.common.sender; import me.lucko.luckperms.api.Tristate; -import me.lucko.luckperms.common.commands.CommandManager; +import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.TextUtils; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/sender/Sender.java b/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java similarity index 96% rename from common/src/main/java/me/lucko/luckperms/common/commands/sender/Sender.java rename to common/src/main/java/me/lucko/luckperms/common/sender/Sender.java index bdbd63b7a..264877c0c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/sender/Sender.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java @@ -23,11 +23,11 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.sender; +package me.lucko.luckperms.common.sender; import me.lucko.luckperms.api.Tristate; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.contexts.ContextManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/sender/SenderFactory.java b/common/src/main/java/me/lucko/luckperms/common/sender/SenderFactory.java similarity index 97% rename from common/src/main/java/me/lucko/luckperms/common/commands/sender/SenderFactory.java rename to common/src/main/java/me/lucko/luckperms/common/sender/SenderFactory.java index 4f4b834cd..992047bc7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/sender/SenderFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/SenderFactory.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.sender; +package me.lucko.luckperms.common.sender; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/FileActionLogger.java b/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/FileActionLogger.java index f4fb86646..a8e90863a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/FileActionLogger.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/dao/file/FileActionLogger.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.common.storage.dao.file; import me.lucko.luckperms.api.LogEntry; -import me.lucko.luckperms.common.commands.CommandManager; +import me.lucko.luckperms.common.command.CommandManager; import java.io.File; import java.util.Date; diff --git a/common/src/main/java/me/lucko/luckperms/common/treeview/TreeView.java b/common/src/main/java/me/lucko/luckperms/common/treeview/TreeView.java index 0da1d37a4..389873a16 100644 --- a/common/src/main/java/me/lucko/luckperms/common/treeview/TreeView.java +++ b/common/src/main/java/me/lucko/luckperms/common/treeview/TreeView.java @@ -29,10 +29,10 @@ import com.google.common.base.Splitter; import com.google.gson.JsonObject; import me.lucko.luckperms.common.caching.type.PermissionCache; -import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.model.User; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.gson.JObject; -import me.lucko.luckperms.common.utils.web.StandardPastebin; +import me.lucko.luckperms.common.web.StandardPastebin; import java.text.SimpleDateFormat; import java.util.Date; diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/CollationKeyCache.java b/common/src/main/java/me/lucko/luckperms/common/utils/CollationKeyCache.java index 3d997a4bf..b3df1ae97 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/CollationKeyCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/CollationKeyCache.java @@ -45,7 +45,7 @@ public final class CollationKeyCache implements Comparator { } private static final LoadingCache CACHE = Caffeine.newBuilder() - .maximumSize(1000) + .maximumSize(5000) .expireAfterAccess(5, TimeUnit.MINUTES) .build(COLLATOR::getCollationKey); diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/SafeIteration.java b/common/src/main/java/me/lucko/luckperms/common/utils/Iterators.java similarity index 81% rename from common/src/main/java/me/lucko/luckperms/common/utils/SafeIteration.java rename to common/src/main/java/me/lucko/luckperms/common/utils/Iterators.java index 1a62f1137..d118b47fe 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/SafeIteration.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/Iterators.java @@ -25,10 +25,13 @@ package me.lucko.luckperms.common.utils; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import java.util.function.Consumer; import java.util.function.Function; -public final class SafeIteration { +public final class Iterators { public static void iterate(Iterable iterable, Consumer action) { for (I i : iterable) { @@ -70,6 +73,19 @@ public final class SafeIteration { } } - private SafeIteration() {} + public static List> divideIterable(Iterable source, int size) { + List> lists = new ArrayList<>(); + Iterator it = source.iterator(); + while (it.hasNext()) { + List subList = new ArrayList<>(); + for (int i = 0; it.hasNext() && i < size; i++) { + subList.add(it.next()); + } + lists.add(subList); + } + return lists; + } + + private Iterators() {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/Predicates.java b/common/src/main/java/me/lucko/luckperms/common/utils/Predicates.java index bf975fd2b..d679e3cc7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/Predicates.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/Predicates.java @@ -25,17 +25,26 @@ package me.lucko.luckperms.common.utils; -import java.util.Set; +import com.google.common.collect.Range; + import java.util.function.Predicate; -import java.util.stream.Collectors; -import java.util.stream.IntStream; /** * A collection of predicate utilities used mostly in command classes */ public final class Predicates { - private static final Predicate FALSE = o -> false; - private static final Predicate TRUE = o -> true; + private static final Predicate FALSE = new Predicate() { + @Override public boolean test(Object o) { return false; } + @Override public Predicate and(Predicate other) { return this; } + @Override public Predicate or(Predicate other) { return other; } + @Override public Predicate negate() { return TRUE; } + }; + private static final Predicate TRUE = new Predicate() { + @Override public boolean test(Object o) { return true; } + @Override public Predicate and(Predicate other) { return other; } + @Override public Predicate or(Predicate other) { return this; } + @Override public Predicate negate() { return FALSE; } + }; public static Predicate alwaysFalse() { //noinspection unchecked @@ -47,40 +56,23 @@ public final class Predicates { return TRUE; } - public static Predicate notInRange(Integer start, Integer end) { - return inverse(inRange(start, end)); + public static Predicate notInRange(int start, int end) { + Range range = Range.closed(start, end); + return value -> !range.contains(value); } - public static Predicate inRange(Integer start, Integer end) { - return isOneOf(IntStream.rangeClosed(start, end).boxed().collect(Collectors.toSet())); - } - - public static Predicate notOneOf(Set ts) { - return inverse(isOneOf(ts)); - } - - public static Predicate isOneOf(Set ta) { - return t -> { - for (T i : ta) { - if (i.equals(t)) { - return true; - } - } - return false; - }; + public static Predicate inRange(int start, int end) { + Range range = Range.closed(start, end); + return range::contains; } public static Predicate not(T t) { - return inverse(is(t)); + return obj -> !t.equals(obj); } public static Predicate is(T t) { return t::equals; } - public static Predicate inverse(Predicate t) { - return t2 -> !t.test(t2); - } - private Predicates() {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseHandler.java b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseHandler.java index 06b0ce02d..75cb44d0c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseHandler.java +++ b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseHandler.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.verbose; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.ContextSet; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.sender.Sender; import java.util.Map; import java.util.Queue; 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 f8c8c3c77..fad3c7de9 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,16 +28,16 @@ package me.lucko.luckperms.common.verbose; import com.google.gson.JsonObject; import me.lucko.luckperms.api.Tristate; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.utils.MessageUtils; +import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.common.utils.StackTracePrinter; import me.lucko.luckperms.common.utils.TextUtils; import me.lucko.luckperms.common.utils.gson.JArray; import me.lucko.luckperms.common.utils.gson.JObject; -import me.lucko.luckperms.common.utils.web.StandardPastebin; +import me.lucko.luckperms.common.web.StandardPastebin; import net.kyori.text.TextComponent; import net.kyori.text.event.HoverEvent; @@ -149,7 +149,7 @@ public class VerboseListener { // build the text List hover = new ArrayList<>(); hover.add("&bOrigin: &2" + data.getCheckOrigin().name()); - hover.add("&bContext: &r" + CommandUtils.contextSetToString(data.getCheckContext())); + hover.add("&bContext: &r" + MessageUtils.contextSetToString(data.getCheckContext())); hover.add("&bTrace: &r"); Consumer printer = StackTracePrinter.elementToString(str -> hover.add("&7" + str)); diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/web/HttpClient.java b/common/src/main/java/me/lucko/luckperms/common/web/HttpClient.java similarity index 98% rename from common/src/main/java/me/lucko/luckperms/common/utils/web/HttpClient.java rename to common/src/main/java/me/lucko/luckperms/common/web/HttpClient.java index a2ebbf29d..d0441509e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/web/HttpClient.java +++ b/common/src/main/java/me/lucko/luckperms/common/web/HttpClient.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.utils.web; +package me.lucko.luckperms.common.web; import okhttp3.Interceptor; import okhttp3.OkHttpClient; diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/web/Pastebin.java b/common/src/main/java/me/lucko/luckperms/common/web/Pastebin.java similarity index 98% rename from common/src/main/java/me/lucko/luckperms/common/utils/web/Pastebin.java rename to common/src/main/java/me/lucko/luckperms/common/web/Pastebin.java index 492985c9c..5b3515d1b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/web/Pastebin.java +++ b/common/src/main/java/me/lucko/luckperms/common/web/Pastebin.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.utils.web; +package me.lucko.luckperms.common.web; import com.google.gson.JsonElement; diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/web/StandardPastebin.java b/common/src/main/java/me/lucko/luckperms/common/web/StandardPastebin.java similarity index 99% rename from common/src/main/java/me/lucko/luckperms/common/utils/web/StandardPastebin.java rename to common/src/main/java/me/lucko/luckperms/common/web/StandardPastebin.java index 3f652a5d4..a686252ef 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/web/StandardPastebin.java +++ b/common/src/main/java/me/lucko/luckperms/common/web/StandardPastebin.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.utils.web; +package me.lucko.luckperms.common.web; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditor.java b/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java similarity index 97% rename from common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditor.java rename to common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java index e01220cea..e0bbaaaad 100644 --- a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditor.java +++ b/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.webeditor; +package me.lucko.luckperms.common.web; import com.google.common.base.Preconditions; import com.google.gson.Gson; @@ -32,19 +32,17 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.contexts.ContextSetJsonSerializer; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.NodeModel; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Uuids; import me.lucko.luckperms.common.utils.gson.JArray; import me.lucko.luckperms.common.utils.gson.JObject; -import me.lucko.luckperms.common.utils.web.HttpClient; -import me.lucko.luckperms.common.utils.web.StandardPastebin; import okhttp3.Request; import okhttp3.Response; diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java index 2ad693786..792450aee 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java @@ -28,8 +28,7 @@ package me.lucko.luckperms.nukkit; import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.LuckPermsApi; import me.lucko.luckperms.common.calculators.PlatformCalculatorFactory; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter; import me.lucko.luckperms.common.contexts.ContextManager; @@ -40,6 +39,7 @@ import me.lucko.luckperms.common.managers.user.StandardUserManager; import me.lucko.luckperms.common.messaging.MessagingFactory; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.tasks.CacheHousekeepingTask; import me.lucko.luckperms.common.tasks.ExpireTemporaryTask; import me.lucko.luckperms.nukkit.calculators.NukkitCalculatorFactory; diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitCommandExecutor.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitCommandExecutor.java index f592c9fe2..fbf3b99aa 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitCommandExecutor.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitCommandExecutor.java @@ -28,8 +28,8 @@ package me.lucko.luckperms.nukkit; import com.google.common.base.Joiner; import com.google.common.base.Splitter; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.sender.Sender; import cn.nukkit.command.Command; import cn.nukkit.command.CommandExecutor; diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSchedulerAdapter.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSchedulerAdapter.java index 5d8780d8e..a06cb1f77 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSchedulerAdapter.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSchedulerAdapter.java @@ -29,7 +29,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; import me.lucko.luckperms.common.plugin.SchedulerAdapter; import me.lucko.luckperms.common.plugin.SchedulerTask; -import me.lucko.luckperms.common.utils.SafeIteration; +import me.lucko.luckperms.common.utils.Iterators; import cn.nukkit.scheduler.ServerScheduler; import cn.nukkit.scheduler.TaskHandler; @@ -105,7 +105,7 @@ public class NukkitSchedulerAdapter implements SchedulerAdapter { @Override public void shutdown() { - SafeIteration.iterate(this.tasks, SchedulerTask::cancel); + Iterators.iterate(this.tasks, SchedulerTask::cancel); // wait for executor this.asyncFallback.shutdown(); 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 2b7ac4591..9fc06c170 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSenderFactory.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSenderFactory.java @@ -26,9 +26,9 @@ package me.lucko.luckperms.nukkit; import me.lucko.luckperms.api.Tristate; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.sender.SenderFactory; +import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.SenderFactory; import me.lucko.luckperms.common.utils.TextUtils; import net.kyori.text.Component; diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitConnectionListener.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitConnectionListener.java index 989a5c083..093af766a 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitConnectionListener.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitConnectionListener.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.nukkit.listeners; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.listener.AbstractConnectionListener; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.nukkit.LPNukkitPlugin; import me.lucko.luckperms.nukkit.model.permissible.LPPermissible; diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitPlatformListener.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitPlatformListener.java index d15e49bd5..e98b9713f 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitPlatformListener.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitPlatformListener.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.nukkit.listeners; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.nukkit.LPNukkitPlugin; import cn.nukkit.Player; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java index 94480df71..beec94289 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java @@ -28,17 +28,17 @@ package me.lucko.luckperms.sponge; import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.LuckPermsApi; import me.lucko.luckperms.common.calculators.PlatformCalculatorFactory; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.abstraction.Command; -import me.lucko.luckperms.common.commands.sender.DummySender; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.command.abstraction.Command; +import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.config.adapter.ConfigurationAdapter; import me.lucko.luckperms.common.contexts.ContextManager; import me.lucko.luckperms.common.managers.track.StandardTrackManager; import me.lucko.luckperms.common.messaging.MessagingFactory; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.plugin.AbstractLuckPermsPlugin; +import me.lucko.luckperms.common.sender.DummySender; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.tasks.CacheHousekeepingTask; import me.lucko.luckperms.common.tasks.ExpireTemporaryTask; import me.lucko.luckperms.sponge.calculators.SpongeCalculatorFactory; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeCommandExecutor.java b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeCommandExecutor.java index 40c7a026c..249b3b301 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeCommandExecutor.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeCommandExecutor.java @@ -27,8 +27,8 @@ package me.lucko.luckperms.sponge; import com.google.common.base.Splitter; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.sender.Sender; +import me.lucko.luckperms.common.command.CommandManager; +import me.lucko.luckperms.common.sender.Sender; import org.spongepowered.api.command.CommandCallable; import org.spongepowered.api.command.CommandResult; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSchedulerAdapter.java b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSchedulerAdapter.java index 204558786..219c7a1b9 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSchedulerAdapter.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSchedulerAdapter.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.sponge; import me.lucko.luckperms.common.plugin.SchedulerAdapter; import me.lucko.luckperms.common.plugin.SchedulerTask; -import me.lucko.luckperms.common.utils.SafeIteration; +import me.lucko.luckperms.common.utils.Iterators; import org.spongepowered.api.scheduler.Scheduler; import org.spongepowered.api.scheduler.SpongeExecutorService; @@ -127,7 +127,7 @@ public class SpongeSchedulerAdapter implements SchedulerAdapter { @Override public void shutdown() { - SafeIteration.iterate(this.tasks, SchedulerTask::cancel); + Iterators.iterate(this.tasks, SchedulerTask::cancel); } private static final class SpongeSchedulerTask implements SchedulerTask { 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 db553e8a8..7e2bbd4e1 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java @@ -26,9 +26,9 @@ package me.lucko.luckperms.sponge; import me.lucko.luckperms.api.Tristate; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.sender.SenderFactory; +import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.SenderFactory; import me.lucko.luckperms.sponge.service.CompatibilityUtil; import net.kyori.text.Component; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionClear.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionClear.java index da9b3d075..5ce24009f 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionClear.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/OptionClear.java @@ -26,15 +26,15 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -42,18 +42,18 @@ import java.util.List; public class OptionClear extends SubCommand { public OptionClear(LocaleManager locale) { - super(CommandSpec.SPONGE_OPTION_CLEAR.spec(locale), "clear", CommandPermission.SPONGE_OPTION_CLEAR, Predicates.alwaysFalse()); + super(CommandSpec.SPONGE_OPTION_CLEAR.localize(locale), "clear", CommandPermission.SPONGE_OPTION_CLEAR, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List args, String label) { - ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args); + ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args); if (contextSet.isEmpty()) { subjectData.clearOptions(); - CommandUtils.sendPluginMessage(sender, "&aCleared options matching contexts &bANY&a."); + MessageUtils.sendPluginMessage(sender, "&aCleared options matching contexts &bANY&a."); } else { subjectData.clearOptions(contextSet); - CommandUtils.sendPluginMessage(sender, "&aCleared options matching contexts &b" + SpongeCommandUtils.contextToString(contextSet)); + MessageUtils.sendPluginMessage(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 bde13b8fa..9f0204686 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 @@ -28,15 +28,15 @@ package me.lucko.luckperms.sponge.commands; import com.google.common.collect.ImmutableMap; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -45,32 +45,32 @@ import java.util.Map; public class OptionInfo extends SubCommand { public OptionInfo(LocaleManager locale) { - super(CommandSpec.SPONGE_OPTION_INFO.spec(locale), "info", CommandPermission.SPONGE_OPTION_INFO, Predicates.alwaysFalse()); + super(CommandSpec.SPONGE_OPTION_INFO.localize(locale), "info", CommandPermission.SPONGE_OPTION_INFO, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List args, String label) { - ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args); + ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args); if (contextSet.isEmpty()) { - CommandUtils.sendPluginMessage(sender, "&aShowing options matching contexts &bANY&a."); + MessageUtils.sendPluginMessage(sender, "&aShowing options matching contexts &bANY&a."); Map> options = subjectData.getAllOptions(); if (options.isEmpty()) { - CommandUtils.sendPluginMessage(sender, "That subject does not have any options defined."); + MessageUtils.sendPluginMessage(sender, "That subject does not have any options defined."); return CommandResult.SUCCESS; } for (Map.Entry> e : options.entrySet()) { - CommandUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.optionsToString(e.getValue())); + MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.optionsToString(e.getValue())); } } else { Map options = subjectData.getOptions(contextSet); if (options.isEmpty()) { - CommandUtils.sendPluginMessage(sender, "That subject does not have any options defined in those contexts."); + MessageUtils.sendPluginMessage(sender, "That subject does not have any options defined in those contexts."); return CommandResult.SUCCESS; } - CommandUtils.sendPluginMessage(sender, "&aShowing options matching contexts &b" + + MessageUtils.sendPluginMessage(sender, "&aShowing options matching contexts &b" + SpongeCommandUtils.contextToString(contextSet) + "&a.\n" + SpongeCommandUtils.optionsToString(options)); } 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 09237540c..39b71e45e 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 @@ -26,15 +26,15 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -42,19 +42,19 @@ import java.util.List; public class OptionSet extends SubCommand { public OptionSet(LocaleManager locale) { - super(CommandSpec.SPONGE_OPTION_SET.spec(locale), "set", CommandPermission.SPONGE_OPTION_SET, Predicates.inRange(0, 1)); + super(CommandSpec.SPONGE_OPTION_SET.localize(locale), "set", CommandPermission.SPONGE_OPTION_SET, Predicates.inRange(0, 1)); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List args, String label) { String key = args.get(0); String value = args.get(1); - ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(2, args); + ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args); if (subjectData.setOption(contextSet, key, value).join()) { - CommandUtils.sendPluginMessage(sender, "&aSet &f\"" + key + "&f\"&a to &f\"" + value + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet)); + MessageUtils.sendPluginMessage(sender, "&aSet &f\"" + key + "&f\"&a to &f\"" + value + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet)); } else { - CommandUtils.sendPluginMessage(sender, "Unable to set option. Does the Subject already have it set?"); + MessageUtils.sendPluginMessage(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 17a316819..131e3b378 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 @@ -26,15 +26,15 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -42,18 +42,18 @@ import java.util.List; public class OptionUnset extends SubCommand { public OptionUnset(LocaleManager locale) { - super(CommandSpec.SPONGE_OPTION_UNSET.spec(locale), "unset", CommandPermission.SPONGE_OPTION_UNSET, Predicates.is(0)); + super(CommandSpec.SPONGE_OPTION_UNSET.localize(locale), "unset", CommandPermission.SPONGE_OPTION_UNSET, Predicates.is(0)); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List args, String label) { String key = args.get(0); - ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(1, args); + ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(1, args); if (subjectData.unsetOption(contextSet, key).join()) { - CommandUtils.sendPluginMessage(sender, "&aUnset &f\"" + key + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet)); + MessageUtils.sendPluginMessage(sender, "&aUnset &f\"" + key + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet)); } else { - CommandUtils.sendPluginMessage(sender, "Unable to unset option. Are you sure the Subject has it set?"); + MessageUtils.sendPluginMessage(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 df24b7fe1..c43922d61 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 @@ -26,15 +26,15 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.LuckPermsService; import me.lucko.luckperms.sponge.service.model.LPSubject; @@ -47,32 +47,32 @@ import java.util.List; public class ParentAdd extends SubCommand { public ParentAdd(LocaleManager locale) { - super(CommandSpec.SPONGE_PARENT_ADD.spec(locale), "add", CommandPermission.SPONGE_PARENT_ADD, Predicates.inRange(0, 1)); + super(CommandSpec.SPONGE_PARENT_ADD.localize(locale), "add", CommandPermission.SPONGE_PARENT_ADD, Predicates.inRange(0, 1)); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List args, String label) { String collection = args.get(0); String name = args.get(1); - ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(2, args); + ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args); LuckPermsService service = Sponge.getServiceManager().provideUnchecked(LuckPermsService.class); if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(collection))) { - CommandUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't already exist."); + MessageUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't already exist."); } LPSubjectCollection c = service.getCollection(collection); if (!c.hasRegistered(name).join()) { - CommandUtils.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't already exist."); + MessageUtils.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't already exist."); } LPSubject subject = c.loadSubject(name).join(); if (subjectData.addParent(contextSet, subject.toReference()).join()) { - CommandUtils.sendPluginMessage(sender, "&aAdded parent &b" + subject.getParentCollection().getIdentifier() + + MessageUtils.sendPluginMessage(sender, "&aAdded parent &b" + subject.getParentCollection().getIdentifier() + "&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet)); } else { - CommandUtils.sendPluginMessage(sender, "Unable to add parent. Does the Subject already have it added?"); + MessageUtils.sendPluginMessage(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 b743f6f4f..9b4b1ebfd 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 @@ -26,15 +26,15 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -42,18 +42,18 @@ import java.util.List; public class ParentClear extends SubCommand { public ParentClear(LocaleManager locale) { - super(CommandSpec.SPONGE_PARENT_CLEAR.spec(locale), "clear", CommandPermission.SPONGE_PARENT_CLEAR, Predicates.alwaysFalse()); + super(CommandSpec.SPONGE_PARENT_CLEAR.localize(locale), "clear", CommandPermission.SPONGE_PARENT_CLEAR, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List args, String label) { - ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args); + ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args); if (contextSet.isEmpty()) { subjectData.clearParents(); - CommandUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &bANY&a."); + MessageUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &bANY&a."); } else { subjectData.clearParents(contextSet); - CommandUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &b" + SpongeCommandUtils.contextToString(contextSet)); + MessageUtils.sendPluginMessage(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 f77c57303..eec1246e0 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 @@ -28,15 +28,15 @@ package me.lucko.luckperms.sponge.commands; import com.google.common.collect.ImmutableList; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; import me.lucko.luckperms.sponge.service.model.LPSubjectReference; @@ -46,32 +46,32 @@ import java.util.Map; public class ParentInfo extends SubCommand { public ParentInfo(LocaleManager locale) { - super(CommandSpec.SPONGE_PARENT_INFO.spec(locale), "info", CommandPermission.SPONGE_PARENT_INFO, Predicates.alwaysFalse()); + super(CommandSpec.SPONGE_PARENT_INFO.localize(locale), "info", CommandPermission.SPONGE_PARENT_INFO, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List args, String label) { - ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args); + ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args); if (contextSet.isEmpty()) { - CommandUtils.sendPluginMessage(sender, "&aShowing parents matching contexts &bANY&a."); + MessageUtils.sendPluginMessage(sender, "&aShowing parents matching contexts &bANY&a."); Map> parents = subjectData.getAllParents(); if (parents.isEmpty()) { - CommandUtils.sendPluginMessage(sender, "That subject does not have any parents defined."); + MessageUtils.sendPluginMessage(sender, "That subject does not have any parents defined."); return CommandResult.SUCCESS; } for (Map.Entry> e : parents.entrySet()) { - CommandUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.parentsToString(e.getValue())); + MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.parentsToString(e.getValue())); } } else { List parents = subjectData.getParents(contextSet); if (parents.isEmpty()) { - CommandUtils.sendPluginMessage(sender, "That subject does not have any parents defined in those contexts."); + MessageUtils.sendPluginMessage(sender, "That subject does not have any parents defined in those contexts."); return CommandResult.SUCCESS; } - CommandUtils.sendPluginMessage(sender, "&aShowing parents matching contexts &b" + + MessageUtils.sendPluginMessage(sender, "&aShowing parents matching contexts &b" + SpongeCommandUtils.contextToString(contextSet) + "&a.\n" + SpongeCommandUtils.parentsToString(parents)); } 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 9a8be3a86..fd6b94084 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 @@ -26,15 +26,15 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.LuckPermsService; import me.lucko.luckperms.sponge.service.model.LPSubject; @@ -47,32 +47,32 @@ import java.util.List; public class ParentRemove extends SubCommand { public ParentRemove(LocaleManager locale) { - super(CommandSpec.SPONGE_PARENT_REMOVE.spec(locale), "remove", CommandPermission.SPONGE_PARENT_REMOVE, Predicates.inRange(0, 1)); + super(CommandSpec.SPONGE_PARENT_REMOVE.localize(locale), "remove", CommandPermission.SPONGE_PARENT_REMOVE, Predicates.inRange(0, 1)); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List args, String label) { String collection = args.get(0); String name = args.get(1); - ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(2, args); + ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args); LuckPermsService service = Sponge.getServiceManager().provideUnchecked(LuckPermsService.class); if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(collection))) { - CommandUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't exist."); + MessageUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't exist."); } LPSubjectCollection c = service.getCollection(collection); if (!c.hasRegistered(name).join()) { - CommandUtils.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't exist."); + MessageUtils.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't exist."); } LPSubject subject = c.loadSubject(name).join(); if (subjectData.removeParent(contextSet, subject.toReference()).join()) { - CommandUtils.sendPluginMessage(sender, "&aRemoved parent &b" + subject.getParentCollection().getIdentifier() + + MessageUtils.sendPluginMessage(sender, "&aRemoved parent &b" + subject.getParentCollection().getIdentifier() + "&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet)); } else { - CommandUtils.sendPluginMessage(sender, "Unable to remove parent. Are you sure the Subject has it added?"); + MessageUtils.sendPluginMessage(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 609ab71b9..26d5f62c5 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 @@ -26,15 +26,15 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -42,18 +42,18 @@ import java.util.List; public class PermissionClear extends SubCommand { public PermissionClear(LocaleManager locale) { - super(CommandSpec.SPONGE_PERMISSION_CLEAR.spec(locale), "clear", CommandPermission.SPONGE_PERMISSION_CLEAR, Predicates.alwaysFalse()); + super(CommandSpec.SPONGE_PERMISSION_CLEAR.localize(locale), "clear", CommandPermission.SPONGE_PERMISSION_CLEAR, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List args, String label) { - ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args); + ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args); if (contextSet.isEmpty()) { subjectData.clearPermissions(); - CommandUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &bANY&a."); + MessageUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &bANY&a."); } else { subjectData.clearPermissions(contextSet); - CommandUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &b" + SpongeCommandUtils.contextToString(contextSet)); + MessageUtils.sendPluginMessage(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 caae58536..0f04a6158 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 @@ -28,15 +28,15 @@ package me.lucko.luckperms.sponge.commands; import com.google.common.collect.ImmutableMap; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -45,32 +45,32 @@ import java.util.Map; public class PermissionInfo extends SubCommand { public PermissionInfo(LocaleManager locale) { - super(CommandSpec.SPONGE_PERMISSION_INFO.spec(locale), "info", CommandPermission.SPONGE_PERMISSION_INFO, Predicates.alwaysFalse()); + super(CommandSpec.SPONGE_PERMISSION_INFO.localize(locale), "info", CommandPermission.SPONGE_PERMISSION_INFO, Predicates.alwaysFalse()); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List args, String label) { - ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(0, args); + ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(0, args); if (contextSet.isEmpty()) { - CommandUtils.sendPluginMessage(sender, "&aShowing permissions matching contexts &bANY&a."); + MessageUtils.sendPluginMessage(sender, "&aShowing permissions matching contexts &bANY&a."); Map> permissions = subjectData.getAllPermissions(); if (permissions.isEmpty()) { - CommandUtils.sendPluginMessage(sender, "That subject does not have any permissions defined."); + MessageUtils.sendPluginMessage(sender, "That subject does not have any permissions defined."); return CommandResult.SUCCESS; } for (Map.Entry> e : permissions.entrySet()) { - CommandUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.nodesToString(e.getValue())); + MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.nodesToString(e.getValue())); } } else { Map permissions = subjectData.getPermissions(contextSet); if (permissions.isEmpty()) { - CommandUtils.sendPluginMessage(sender, "That subject does not have any permissions defined in those contexts."); + MessageUtils.sendPluginMessage(sender, "That subject does not have any permissions defined in those contexts."); return CommandResult.SUCCESS; } - CommandUtils.sendPluginMessage(sender, "&aShowing permissions matching contexts &b" + + MessageUtils.sendPluginMessage(sender, "&aShowing permissions matching contexts &b" + SpongeCommandUtils.contextToString(contextSet) + "&a.\n" + SpongeCommandUtils.nodesToString(permissions)); } 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 4aad7793b..8bfa98e05 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 @@ -27,16 +27,16 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.ImmutableContextSet; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandPermission; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandResult; +import me.lucko.luckperms.common.command.abstraction.CommandException; +import me.lucko.luckperms.common.command.abstraction.SubCommand; +import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +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.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.service.model.LPSubjectData; @@ -44,19 +44,19 @@ import java.util.List; public class PermissionSet extends SubCommand { public PermissionSet(LocaleManager locale) { - super(CommandSpec.SPONGE_PERMISSION_SET.spec(locale), "set", CommandPermission.SPONGE_PERMISSION_SET, Predicates.inRange(0, 1)); + super(CommandSpec.SPONGE_PERMISSION_SET.localize(locale), "set", CommandPermission.SPONGE_PERMISSION_SET, Predicates.inRange(0, 1)); } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List args, String label) throws CommandException { String node = args.get(0); Tristate tristate = SpongeCommandUtils.parseTristate(1, args); - ImmutableContextSet contextSet = ArgumentUtils.handleContextSponge(2, args); + ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args); if (subjectData.setPermission(contextSet, node, tristate).join()) { - CommandUtils.sendPluginMessage(sender, "&aSet &b" + node + "&a to &b" + tristate.toString().toLowerCase() + "&a in context " + SpongeCommandUtils.contextToString(contextSet)); + MessageUtils.sendPluginMessage(sender, "&aSet &b" + node + "&a to &b" + tristate.toString().toLowerCase() + "&a in context " + SpongeCommandUtils.contextToString(contextSet)); } else { - CommandUtils.sendPluginMessage(sender, "Unable to set permission. Does the Subject already have it set?"); + MessageUtils.sendPluginMessage(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 766449d48..937ae0aa3 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,8 +27,8 @@ package me.lucko.luckperms.sponge.commands; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.ContextSet; -import me.lucko.luckperms.common.commands.utils.ArgumentUtils; -import me.lucko.luckperms.common.commands.utils.CommandUtils; +import me.lucko.luckperms.common.command.utils.ArgumentParser; +import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.sponge.service.model.LPSubjectReference; import java.util.List; @@ -36,7 +36,7 @@ import java.util.Map; public final class SpongeCommandUtils { - public static Tristate parseTristate(int index, List args) throws ArgumentUtils.ArgumentException { + public static Tristate parseTristate(int index, List args) throws ArgumentParser.ArgumentException { String s = args.get(index).toLowerCase(); if (s.equals("1") || s.equals("true") || s.equals("t")) { return Tristate.TRUE; @@ -47,7 +47,7 @@ public final class SpongeCommandUtils { if (s.equals("-1") || s.equals("false") || s.equals("f")) { return Tristate.FALSE; } - throw new ArgumentUtils.DetailedUsageException(); + throw new ArgumentParser.DetailedUsageException(); } public static String nodesToString(Map nodes) { @@ -86,7 +86,7 @@ public final class SpongeCommandUtils { } public static String contextToString(ContextSet set) { - return CommandUtils.contextSetToString(set); + return MessageUtils.contextSetToString(set); } private SpongeCommandUtils() {} diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java index c3ae3470f..1a512c0f8 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/commands/SpongeMainCommand.java @@ -28,16 +28,16 @@ package me.lucko.luckperms.sponge.commands; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandManager; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.Command; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.commands.utils.CommandUtils; -import me.lucko.luckperms.common.locale.CommandSpec; +import me.lucko.luckperms.common.command.CommandManager; +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.utils.MessageUtils; import me.lucko.luckperms.common.locale.LocaleManager; -import me.lucko.luckperms.common.locale.Message; +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.utils.ImmutableCollectors; import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.sponge.LPSpongePlugin; @@ -61,7 +61,7 @@ public class SpongeMainCommand extends Command { private final Map>> subCommands; public SpongeMainCommand(LPSpongePlugin plugin) { - super(CommandSpec.SPONGE.spec(plugin.getLocaleManager()), "Sponge", null, Predicates.alwaysFalse()); + super(CommandSpec.SPONGE.localize(plugin.getLocaleManager()), "Sponge", null, Predicates.alwaysFalse()); LocaleManager locale = plugin.getLocaleManager(); @@ -96,8 +96,8 @@ public class SpongeMainCommand extends Command { LuckPermsService service = this.plugin.getService(); if (args.size() < 1) { - CommandUtils.sendPluginMessage(sender, "&aCurrent Subject Collections:\n" + - CommandUtils.toCommaSep(service.getLoadedCollections().keySet().stream() + MessageUtils.sendPluginMessage(sender, "&aCurrent Subject Collections:\n" + + MessageUtils.toCommaSep(service.getLoadedCollections().keySet().stream() .filter(s -> !s.equalsIgnoreCase("user") && !s.equalsIgnoreCase("group")) .sorted() .collect(Collectors.toList()) @@ -109,12 +109,12 @@ public class SpongeMainCommand extends Command { String subjectCollection = args.get(0); if (subjectCollection.equalsIgnoreCase("user") || subjectCollection.equalsIgnoreCase("group")) { - CommandUtils.sendPluginMessage(sender, "Please use the main LuckPerms commands to edit users and groups."); + MessageUtils.sendPluginMessage(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))) { - CommandUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + subjectCollection + "&c' doesn't already exist. Creating it now."); + MessageUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + subjectCollection + "&c' doesn't already exist. Creating it now."); } LPSubjectCollection collection = service.getCollection(subjectCollection); @@ -128,9 +128,9 @@ public class SpongeMainCommand extends Command { List extra = subjects.subList(50, subjects.size()); int overflow = extra.size(); extra.clear(); - CommandUtils.sendPluginMessage(sender, "&aCurrent Subjects:\n" + CommandUtils.toCommaSep(subjects) + "&b ... and &a" + overflow + " &bmore."); + MessageUtils.sendPluginMessage(sender, "&aCurrent Subjects:\n" + MessageUtils.toCommaSep(subjects) + "&b ... and &a" + overflow + " &bmore."); } else { - CommandUtils.sendPluginMessage(sender, "&aCurrent Subjects:\n" + CommandUtils.toCommaSep(subjects)); + MessageUtils.sendPluginMessage(sender, "&aCurrent Subjects:\n" + MessageUtils.toCommaSep(subjects)); } return CommandResult.SUCCESS; @@ -181,7 +181,7 @@ public class SpongeMainCommand extends Command { String subjectId = args.get(1); if (!collection.hasRegistered(subjectId).join()) { - CommandUtils.sendPluginMessage(sender, "Warning: Subject '&4" + subjectId + "&c' doesn't already exist. Creating it now."); + MessageUtils.sendPluginMessage(sender, "Warning: Subject '&4" + subjectId + "&c' doesn't already exist. Creating it now."); } LPSubject subject = collection.loadSubject(subjectId).join(); @@ -198,19 +198,19 @@ public class SpongeMainCommand extends Command { @Override public void sendUsage(Sender sender, String label) { - CommandUtils.sendPluginMessage(sender, "&3> &a" + String.format(getUsage(), label)); + MessageUtils.sendPluginMessage(sender, "&3> &a" + String.format(getUsage(), label)); } @Override public void sendDetailedUsage(Sender sender, String label) { - CommandUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s sponge [-transient]", label) + " ...)"); + MessageUtils.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s sponge [-transient]", label) + " ...)"); for (String s : Arrays.asList("Permission", "Parent", "Option")) { List subs = this.subCommands.get(s.toLowerCase()).stream() .filter(sub -> sub.isAuthorized(sender)) .collect(Collectors.toList()); if (!subs.isEmpty()) { - CommandUtils.sendPluginMessage(sender, "&3>> &b" + s); + MessageUtils.sendPluginMessage(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 38984e331..4589f91b5 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 @@ -27,7 +27,7 @@ package me.lucko.luckperms.sponge.listeners; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.listener.AbstractConnectionListener; -import me.lucko.luckperms.common.locale.Message; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.sponge.LPSpongePlugin; 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 15534a25f..a68f24805 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; +import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.sponge.LPSpongePlugin; import org.spongepowered.api.command.CommandSource;