Merge branch 'master' into futuriumnetwork_master

feat/data-edit-commands
William 2 years ago
commit 0520cc6ad0

@ -9,9 +9,9 @@ import org.jetbrains.annotations.NotNull;
public enum BukkitCommandType { public enum BukkitCommandType {
HUSKSYNC_COMMAND(new HuskSyncCommand(BukkitHuskSync.getInstance())), HUSKSYNC_COMMAND(new HuskSyncCommand(BukkitHuskSync.getInstance())),
USERDATA_COMMAND(new UserDataCommand(BukkitHuskSync.getInstance())),
INVENTORY_COMMAND(new InventoryCommand(BukkitHuskSync.getInstance())), INVENTORY_COMMAND(new InventoryCommand(BukkitHuskSync.getInstance())),
ENDER_CHEST_COMMAND(new EnderChestCommand(BukkitHuskSync.getInstance())), ENDER_CHEST_COMMAND(new EnderChestCommand(BukkitHuskSync.getInstance()));
USERDATA_COMMAND(new UserDataCommand(BukkitHuskSync.getInstance()));
public final CommandBase commandBase; public final CommandBase commandBase;

@ -16,12 +16,12 @@ commands:
husksync: husksync:
usage: '/husksync <update/info/reload/migrate>' usage: '/husksync <update/info/reload/migrate>'
description: 'Manage the HuskSync plugin' description: 'Manage the HuskSync plugin'
userdata:
usage: '/userdata <view/list/delete/restore/pin> <username> [version_uuid]'
description: 'View, manage & restore player userdata'
inventory: inventory:
usage: '/inventory <username> [version_uuid]' usage: '/inventory <username> [version_uuid]'
description: 'View & edit a player''s inventory' description: 'View & edit a player''s inventory'
enderchest: enderchest:
usage: '/enderchest <username> [version_uuid]' usage: '/enderchest <username> [version_uuid]'
description: 'View & edit a player''s Ender Chest' description: 'View & edit a player''s Ender Chest'
userdata:
usage: '/userdata <view/list/delete/restore> <username> [version_uuid]'
description: 'View, manage & restore player userdata'

@ -28,6 +28,19 @@ public enum Permission {
*/ */
COMMAND_HUSKSYNC_UPDATE("husksync.command.husksync.update", DefaultAccess.OPERATORS), 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 * /inventory command permissions
*/ */
@ -52,20 +65,7 @@ public enum Permission {
/** /**
* Lets the user edit the contents of offline players' ender chests * Lets the user edit the contents of offline players' ender chests
*/ */
COMMAND_ENDER_CHEST_EDIT("husksync.command.enderchest.edit", DefaultAccess.OPERATORS), 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);
public final String node; public final String node;

@ -69,6 +69,10 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
} }
} }
case "list" -> { 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) { if (args.length < 2) {
plugin.getLocales().getLocale("error_invalid_syntax", plugin.getLocales().getLocale("error_invalid_syntax",
"/userdata list <username>") "/userdata list <username>")
@ -90,6 +94,10 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
.ifPresent(player::sendMessage)))); .ifPresent(player::sendMessage))));
} }
case "delete" -> { 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 // Delete user data by specified UUID
if (args.length < 3) { if (args.length < 3) {
plugin.getLocales().getLocale("error_invalid_syntax", plugin.getLocales().getLocale("error_invalid_syntax",
@ -124,6 +132,10 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
} }
} }
case "restore" -> { 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 // Get user data by specified uuid and username
if (args.length < 3) { if (args.length < 3) {
plugin.getLocales().getLocale("error_invalid_syntax", plugin.getLocales().getLocale("error_invalid_syntax",
@ -161,6 +173,10 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
} }
} }
case "pin" -> { 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) { if (args.length < 3) {
plugin.getLocales().getLocale("error_invalid_syntax", plugin.getLocales().getLocale("error_invalid_syntax",
"/userdata pin <username> <version_uuid>") "/userdata pin <username> <version_uuid>")

Loading…
Cancel
Save