1313import org .mvplugins .multiverse .external .acf .commands .annotation .CommandCompletion ;
1414import org .mvplugins .multiverse .external .acf .commands .annotation .CommandPermission ;
1515import org .mvplugins .multiverse .external .acf .commands .annotation .Description ;
16+ import org .mvplugins .multiverse .external .acf .commands .annotation .Flags ;
1617import org .mvplugins .multiverse .external .acf .commands .annotation .Subcommand ;
1718import org .mvplugins .multiverse .external .acf .commands .annotation .Syntax ;
1819import org .mvplugins .multiverse .external .jakarta .inject .Inject ;
@@ -48,32 +49,25 @@ final class InventoryModifyCommand extends InventoriesCommand {
4849 @ Description ("Modify a player's inventory in a specific world." )
4950 void onInventoryModifyCommand (
5051 @ NotNull MVCommandIssuer issuer ,
52+
53+ // to make sure the command is only run by players
54+ @ Flags ("resolve=issuerOnly" )
55+ @ NotNull Player player ,
56+
5157 @ Syntax ("<player>" )
5258 @ Description ("Online or offline player" )
5359 OfflinePlayer targetPlayer ,
5460
5561 @ Syntax ("<world>" )
5662 @ Description ("The world the player's inventory is in" )
57- MultiverseWorld [] worlds
63+ MultiverseWorld world
5864 ) {
59- if (!(issuer .getIssuer () instanceof Player viewer )) {
60- issuer .sendError (ChatColor .RED + "Only players can modify inventories." );
61- return ;
62- }
63- if (worlds == null || worlds .length == 0 || worlds [0 ] == null ) {
64- issuer .sendError (ChatColor .RED + "You must specify a valid world." );
65- return ;
66- }
67- if (targetPlayer == null || targetPlayer .getName () == null ) {
68- issuer .sendError (ChatColor .RED + "You must specify a valid player." );
69- return ;
70- }
71- if (viewer .getUniqueId ().equals (targetPlayer .getUniqueId ())) {
65+ if (player .getUniqueId ().equals (targetPlayer .getUniqueId ())) {
7266 issuer .sendError (ChatColor .RED + "You cannot modify your own inventory using this command. Use your regular inventory." );
7367 return ;
7468 }
7569
76- String worldName = worlds [ 0 ] .getName ();
70+ String worldName = world .getName ();
7771 // Asynchronously load data using InventoryDataProvider
7872 issuer .sendInfo (ChatColor .YELLOW + "Loading inventory data for " + targetPlayer .getName () + "..." );
7973
@@ -137,7 +131,7 @@ void onInventoryModifyCommand(
137131 inv .setItem (i , inventoryGUIHelper .createFillerItemForSlot (i ));
138132 }
139133
140- viewer .openInventory (inv );
134+ player .openInventory (inv );
141135 issuer .sendInfo (ChatColor .GREEN + "Opened editable inventory for " + targetPlayer .getName () + " in world " + worldName + ". Changes will save on close." );
142136 }); // End of Bukkit.getScheduler().runTask()
143137 })
@@ -150,4 +144,3 @@ void onInventoryModifyCommand(
150144 });
151145 }
152146}
153-
0 commit comments