Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/SerenityJS/serenity into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
PMK744 committed Sep 19, 2024
2 parents ffe4efc + 80681cf commit 5a83a4e
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions packages/world/src/commands/admin/kill.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import { CommandPermissionLevel } from "@serenityjs/protocol";
import { CommandPermissionLevel, Gamemode } from "@serenityjs/protocol";

import { TargetEnum } from "../enums";
import { Player } from "../../player";

import type { World } from "../../world";
import type { Entity } from "../../entity";

/**
* When executing /kill on a player, if the player
* has one of these gamemodes, the player will be ignored.
*/
const IGNORED_GAMEMODES = new Set([
Gamemode.Creative,
Gamemode.CreativeSpectator,
Gamemode.Spectator
]);

const register = (world: World) => {
// Register the kill command
world.commands.register(
Expand All @@ -31,7 +42,14 @@ const register = (world: World) => {
throw new Error("No targets matched the selector.");

// Loop through all the targets
for (const target of targets) target.kill();
for (const target of targets) {
if (
target instanceof Player &&
IGNORED_GAMEMODES.has(target.gamemode)
)
continue;
target.kill();
}
}
);
},
Expand Down

0 comments on commit 5a83a4e

Please sign in to comment.