Skip to content

Commit

Permalink
Player#kill() method
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSlimeDiamond committed Mar 1, 2024
1 parent 3fa4581 commit b086d38
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/src/main/java/org/galliumpowered/world/entity/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ default void setPrefix(String prefix) throws SQLException {
*/
void setGamemode(Gamemode gamemode);

/**
* Kill the player
*/
void kill();

/**
* Gets the player's current {@link World}
* @return Player world
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public void setGamemode(Gamemode gamemode) {
serverPlayer.setGameMode(GameType.byId(gamemode.getId()));
}

@Override
public void kill() {
serverPlayer.kill();
}

@Override
public World getWorld() {
return new WorldImpl(serverPlayer.level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.galliumpowered.Gallium;
import org.galliumpowered.annotation.Args;
import org.galliumpowered.annotation.Command;
import org.galliumpowered.chat.Colors;
import org.galliumpowered.command.CommandContext;
import org.galliumpowered.command.args.ArgumentType;

Expand Down Expand Up @@ -79,4 +80,12 @@ public void test8Command(CommandContext ctx) {
console.sendMessage("You cannot use this command as the console!");
});
}

@Command(aliases = "suicide", description = "it's a way out")
public void suicideCommand(CommandContext ctx) {
ctx.ifPlayer(player -> {
player.kill();
Gallium.getServer().sendMsgToAll(Component.text(player.getPrefix() + player.getName() + Colors.GREEN + " took the easy way out."));
});
}
}

0 comments on commit b086d38

Please sign in to comment.