Actually, be a bit more rigorous with the kill command.
@@ -16,8 +16,10 @@ import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.CommandElement;
+import org.spongepowered.api.data.DataTransactionResult;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.entity.Entity;
+import org.spongepowered.api.entity.living.Living;
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;
@@ -56,11 +58,16 @@ public class KillCommand extends AbstractCommand<CommandSource> {
if (gm != GameModes.SURVIVAL && gm != GameModes.NOT_SET) {
if (entities.size() == 1) {
throw ReturnMessageException.fromKey("command.kill.wronggm", pl.getName());
+ } else {
+ continue;
}
}
}
- x.offer(Keys.HEALTH, 0d);
+ DataTransactionResult dtr = x.offer(Keys.HEALTH, 0d);
+ if (!dtr.isSuccessful() && !(x instanceof Living)) {
+ x.remove();
+ }
entityKillCount++;
if (x instanceof Player) {
