diff --git a/bukkit/src/main/java/co/aikar/commands/BukkitCommandContexts.java b/bukkit/src/main/java/co/aikar/commands/BukkitCommandContexts.java index bd32ad44..c107f567 100644 --- a/bukkit/src/main/java/co/aikar/commands/BukkitCommandContexts.java +++ b/bukkit/src/main/java/co/aikar/commands/BukkitCommandContexts.java @@ -72,7 +72,7 @@ public class BukkitCommandContexts extends CommandContexts { + registerIssuerAwareContext(World.class, (c) -> { String firstArg = c.getFirstArg(); World world = firstArg != null ? Bukkit.getWorld(firstArg) : null; if (world != null) { @@ -86,8 +86,8 @@ public class BukkitCommandContexts extends CommandContexts { + registerIssuerAwareContext(CommandSender.class, BukkitCommandExecutionContext::getSender); + registerIssuerAwareContext(Player.class, (c) -> { Player player = c.getSender() instanceof Player ? (Player) c.getSender() : null; if (player == null && !c.hasAnnotation(Optional.class)) { throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); @@ -137,6 +137,7 @@ public class BukkitCommandContexts extends CommandContexts new CommandResultSupplier()); registerContext(OnlinePlayer.class, c -> getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.hasAnnotation(Optional.class))); + registerIssuerAwareContext(CommandSource.class, SpongeCommandExecutionContext::getSource); + registerIssuerAwareContext(Player.class, (c) -> { + Player player = c.getSource() instanceof Player ? (Player) c.getSource() : null; + if (player == null && !c.hasAnnotation(Optional.class)) { + throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false); + } + /*PlayerInventory inventory = player != null ? player.getInventory() : null; + if (inventory != null && c.hasFlag("itemheld") && !ACFBukkitUtil.isValidItem(inventory.getItem(inventory.getHeldItemSlot()))) { + throw new InvalidCommandArgument(MinecraftMessageKeys.YOU_MUST_BE_HOLDING_ITEM, false); + }*/ + return player; + }); }