From 5fe9085483c5a35cbc1e093936cb914d534f73f6 Mon Sep 17 00:00:00 2001 From: William Date: Mon, 11 Jul 2022 18:50:06 +0100 Subject: [PATCH 1/4] Re-order commands --- .../william278/husksync/command/BukkitCommandType.java | 4 ++-- bukkit/src/main/resources/plugin.yml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bukkit/src/main/java/net/william278/husksync/command/BukkitCommandType.java b/bukkit/src/main/java/net/william278/husksync/command/BukkitCommandType.java index 1162c50d..d9187e6b 100644 --- a/bukkit/src/main/java/net/william278/husksync/command/BukkitCommandType.java +++ b/bukkit/src/main/java/net/william278/husksync/command/BukkitCommandType.java @@ -9,9 +9,9 @@ import org.jetbrains.annotations.NotNull; public enum BukkitCommandType { HUSKSYNC_COMMAND(new HuskSyncCommand(BukkitHuskSync.getInstance())), + USERDATA_COMMAND(new UserDataCommand(BukkitHuskSync.getInstance())), INVENTORY_COMMAND(new InventoryCommand(BukkitHuskSync.getInstance())), - ENDER_CHEST_COMMAND(new EnderChestCommand(BukkitHuskSync.getInstance())), - USERDATA_COMMAND(new UserDataCommand(BukkitHuskSync.getInstance())); + ENDER_CHEST_COMMAND(new EnderChestCommand(BukkitHuskSync.getInstance())); public final CommandBase commandBase; diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 460cd820..500ead20 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -16,12 +16,12 @@ commands: husksync: usage: '/husksync ' description: 'Manage the HuskSync plugin' + userdata: + usage: '/userdata [version_uuid]' + description: 'View, manage & restore player userdata' inventory: usage: '/inventory [version_uuid]' description: 'View & edit a player''s inventory' enderchest: usage: '/enderchest [version_uuid]' - description: 'View & edit a player''s Ender Chest' - userdata: - usage: '/userdata [version_uuid]' - description: 'View, manage & restore player userdata' \ No newline at end of file + description: 'View & edit a player''s Ender Chest' \ No newline at end of file From 5d584581f0c20dfc74a93ae602a18b3123e3d00f Mon Sep 17 00:00:00 2001 From: William Date: Mon, 11 Jul 2022 18:51:19 +0100 Subject: [PATCH 2/4] Add pin to usage --- bukkit/src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 500ead20..bc54a3fa 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -17,7 +17,7 @@ commands: usage: '/husksync ' description: 'Manage the HuskSync plugin' userdata: - usage: '/userdata [version_uuid]' + usage: '/userdata [version_uuid]' description: 'View, manage & restore player userdata' inventory: usage: '/inventory [version_uuid]' From 8f396273c7a292322756fc22b8af83acc2ec4e58 Mon Sep 17 00:00:00 2001 From: William Date: Mon, 11 Jul 2022 18:57:43 +0100 Subject: [PATCH 3/4] Respect userdata.manage permission node --- .../husksync/command/UserDataCommand.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/src/main/java/net/william278/husksync/command/UserDataCommand.java b/common/src/main/java/net/william278/husksync/command/UserDataCommand.java index 50229276..e2726adb 100644 --- a/common/src/main/java/net/william278/husksync/command/UserDataCommand.java +++ b/common/src/main/java/net/william278/husksync/command/UserDataCommand.java @@ -69,6 +69,10 @@ public class UserDataCommand extends CommandBase implements TabCompletable { } } case "list" -> { + if (!player.hasPermission(Permission.COMMAND_USER_DATA_MANAGE.node)) { + plugin.getLocales().getLocale("error_no_permission").ifPresent(player::sendMessage); + return; + } if (args.length < 2) { plugin.getLocales().getLocale("error_invalid_syntax", "/userdata list ") @@ -90,6 +94,10 @@ public class UserDataCommand extends CommandBase implements TabCompletable { .ifPresent(player::sendMessage)))); } case "delete" -> { + if (!player.hasPermission(Permission.COMMAND_USER_DATA_MANAGE.node)) { + plugin.getLocales().getLocale("error_no_permission").ifPresent(player::sendMessage); + return; + } // Delete user data by specified UUID if (args.length < 3) { plugin.getLocales().getLocale("error_invalid_syntax", @@ -124,6 +132,10 @@ public class UserDataCommand extends CommandBase implements TabCompletable { } } case "restore" -> { + if (!player.hasPermission(Permission.COMMAND_USER_DATA_MANAGE.node)) { + plugin.getLocales().getLocale("error_no_permission").ifPresent(player::sendMessage); + return; + } // Get user data by specified uuid and username if (args.length < 3) { plugin.getLocales().getLocale("error_invalid_syntax", @@ -161,6 +173,10 @@ public class UserDataCommand extends CommandBase implements TabCompletable { } } case "pin" -> { + if (!player.hasPermission(Permission.COMMAND_USER_DATA_MANAGE.node)) { + plugin.getLocales().getLocale("error_no_permission").ifPresent(player::sendMessage); + return; + } if (args.length < 3) { plugin.getLocales().getLocale("error_invalid_syntax", "/userdata pin ") From feb6280fd2686c318560ae9e5f3371ed9377ae2f Mon Sep 17 00:00:00 2001 From: William Date: Mon, 11 Jul 2022 18:58:14 +0100 Subject: [PATCH 4/4] Re-arrange permissions --- .../husksync/command/Permission.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/common/src/main/java/net/william278/husksync/command/Permission.java b/common/src/main/java/net/william278/husksync/command/Permission.java index 34fe8055..4e7dba78 100644 --- a/common/src/main/java/net/william278/husksync/command/Permission.java +++ b/common/src/main/java/net/william278/husksync/command/Permission.java @@ -28,6 +28,19 @@ public enum Permission { */ COMMAND_HUSKSYNC_UPDATE("husksync.command.husksync.update", DefaultAccess.OPERATORS), + /* + * /userdata command permissions + */ + + /** + * Lets the user view user data {@code /userdata view/list (player) (version_uuid)} + */ + COMMAND_USER_DATA("husksync.command.userdata", DefaultAccess.OPERATORS), + /** + * Lets the user restore and delete user data {@code /userdata restore/delete (player) (version_uuid)} + */ + COMMAND_USER_DATA_MANAGE("husksync.command.userdata.manage", DefaultAccess.OPERATORS), + /* * /inventory command permissions */ @@ -52,20 +65,7 @@ public enum Permission { /** * Lets the user edit the contents of offline players' ender chests */ - COMMAND_ENDER_CHEST_EDIT("husksync.command.enderchest.edit", DefaultAccess.OPERATORS), - - /* - * /userdata command permissions - */ - - /** - * Lets the user view user data {@code /userdata view/list (player) (version_uuid)} - */ - COMMAND_USER_DATA("husksync.command.userdata", DefaultAccess.OPERATORS), - /** - * Lets the user restore and delete user data {@code /userdata restore/delete (player) (version_uuid)} - */ - COMMAND_USER_DATA_MANAGE("husksync.command.userdata.manage", DefaultAccess.OPERATORS); + COMMAND_ENDER_CHEST_EDIT("husksync.command.enderchest.edit", DefaultAccess.OPERATORS); public final String node;