Fix breaking /kill if a player in creative is captured.
@@ -22,6 +22,7 @@ import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.living.player.gamemode.GameMode;
import org.spongepowered.api.entity.living.player.gamemode.GameModes;
import org.spongepowered.api.text.Text;
+import org.spongepowered.api.util.annotation.NonnullByDefault;
import java.util.Collection;
@@ -29,6 +30,7 @@ import java.util.Collection;
@RegisterCommand("kill")
@EssentialsEquivalent(value = { "kill", "remove", "butcher", "killall", "mobkill" },
isExact = false, notes = "Nucleus supports killing entities using the Minecraft selectors.")
+@NonnullByDefault
public class KillCommand extends AbstractCommand<CommandSource> {
private final String key = "subject";
@@ -52,9 +54,11 @@ public class KillCommand extends AbstractCommand<CommandSource> {
Player pl = (Player)x;
GameMode gm = pl.gameMode().getDirect().orElseGet(() -> pl.gameMode().getDefault());
if (gm != GameModes.SURVIVAL && gm != GameModes.NOT_SET) {
+ if (entities.size() == 1) {
throw ReturnMessageException.fromKey("command.kill.wronggm", pl.getName());
}
}
+ }
x.offer(Keys.HEALTH, 0d);
entityKillCount++;
