diff --git a/bukkit/src/main/java/co/aikar/commands/BukkitCommandContexts.java b/bukkit/src/main/java/co/aikar/commands/BukkitCommandContexts.java index 8fad9902..05a5b157 100644 --- a/bukkit/src/main/java/co/aikar/commands/BukkitCommandContexts.java +++ b/bukkit/src/main/java/co/aikar/commands/BukkitCommandContexts.java @@ -34,7 +34,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.inventory.PlayerInventory; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Contract; import java.util.HashSet; import java.util.Set; @@ -51,10 +51,10 @@ public class BukkitCommandContexts extends CommandContexts getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.isOptional())); + registerContext(OnlinePlayer.class, c -> getOnlinePlayer(c.getIssuer(), c.popFirstArg(), false)); registerContext(co.aikar.commands.contexts.OnlinePlayer.class, c -> { - OnlinePlayer onlinePlayer = getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.isOptional()); - return onlinePlayer != null ? new co.aikar.commands.contexts.OnlinePlayer(onlinePlayer.getPlayer()) : null; + OnlinePlayer onlinePlayer = getOnlinePlayer(c.getIssuer(), c.popFirstArg(), false); + return new co.aikar.commands.contexts.OnlinePlayer(onlinePlayer.getPlayer()); }); registerContext(OnlinePlayer[].class, (c) -> { BukkitCommandIssuer issuer = c.getIssuer(); @@ -125,8 +125,8 @@ public class BukkitCommandContexts extends CommandContexts { @@ -249,7 +249,7 @@ public class BukkitCommandContexts extends CommandContexts !null") OnlinePlayer getOnlinePlayer(BukkitCommandIssuer issuer, String lookup, boolean allowMissing) throws InvalidCommandArgument { Player player = ACFBukkitUtil.findPlayerSmart(issuer, lookup); //noinspection Duplicates diff --git a/sponge/src/main/java/co/aikar/commands/SpongeCommandContexts.java b/sponge/src/main/java/co/aikar/commands/SpongeCommandContexts.java index a02ae2b4..3ee2b35a 100644 --- a/sponge/src/main/java/co/aikar/commands/SpongeCommandContexts.java +++ b/sponge/src/main/java/co/aikar/commands/SpongeCommandContexts.java @@ -25,7 +25,7 @@ package co.aikar.commands; import co.aikar.commands.contexts.CommandResultSupplier; import co.aikar.commands.sponge.contexts.OnlinePlayer; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Contract; import org.spongepowered.api.Sponge; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.entity.living.player.Player; @@ -49,10 +49,10 @@ public class SpongeCommandContexts extends CommandContexts new CommandResultSupplier()); - registerContext(OnlinePlayer.class, c -> getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.isOptional())); + registerContext(OnlinePlayer.class, c -> getOnlinePlayer(c.getIssuer(), c.popFirstArg(), false)); registerContext(co.aikar.commands.contexts.OnlinePlayer.class, c -> { - OnlinePlayer onlinePlayer = getOnlinePlayer(c.getIssuer(), c.popFirstArg(), c.isOptional()); - return onlinePlayer != null ? new co.aikar.commands.contexts.OnlinePlayer(onlinePlayer.getPlayer()) : null; + OnlinePlayer onlinePlayer = getOnlinePlayer(c.getIssuer(), c.popFirstArg(), false); + return new co.aikar.commands.contexts.OnlinePlayer(onlinePlayer.getPlayer()); }); registerContext(User.class, c -> { String name = c.popFirstArg(); @@ -164,7 +164,7 @@ public class SpongeCommandContexts extends CommandContexts !null") OnlinePlayer getOnlinePlayer(SpongeCommandIssuer issuer, String lookup, boolean allowMissing) throws InvalidCommandArgument { Player player = ACFSpongeUtil.findPlayerSmart(issuer, lookup); if (player == null) { diff --git a/velocity/src/main/java/co/aikar/commands/VelocityCommandContexts.java b/velocity/src/main/java/co/aikar/commands/VelocityCommandContexts.java index 628f0a44..883d15c1 100644 --- a/velocity/src/main/java/co/aikar/commands/VelocityCommandContexts.java +++ b/velocity/src/main/java/co/aikar/commands/VelocityCommandContexts.java @@ -32,7 +32,6 @@ import net.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.text.format.TextFormat; import net.kyori.adventure.text.format.TextColor; -import org.jetbrains.annotations.Nullable; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -44,7 +43,7 @@ public class VelocityCommandContexts extends CommandContexts getOnlinePlayer(server, c)); registerContext(co.aikar.commands.contexts.OnlinePlayer.class, c -> { OnlinePlayer onlinePlayer = getOnlinePlayer(server, c); - return onlinePlayer != null ? new co.aikar.commands.contexts.OnlinePlayer(onlinePlayer.getPlayer()) : null; + return new co.aikar.commands.contexts.OnlinePlayer(onlinePlayer.getPlayer()); }); registerIssuerAwareContext(CommandSource.class, VelocityCommandExecutionContext::getSender); registerIssuerAwareContext(Player.class, (c) -> { @@ -79,13 +78,9 @@ public class VelocityCommandContexts extends CommandContexts