From 15d594528ea20ce321731362f0a1786b841f4776 Mon Sep 17 00:00:00 2001 From: Martin <Martin.Olischlaeger@icloud.com> Date: Sun, 30 Apr 2023 15:06:08 +0200 Subject: [PATCH] removing gamemode creative option --- .../worldmuseum/commands/GamemodeCommand.java | 27 ++++++++++++++++--- .../worldmuseum/commands/TeleportCommand.java | 1 + 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/mhsl/craftattack/worldmuseum/commands/GamemodeCommand.java b/src/main/java/eu/mhsl/craftattack/worldmuseum/commands/GamemodeCommand.java index 5ec66c9..0030908 100644 --- a/src/main/java/eu/mhsl/craftattack/worldmuseum/commands/GamemodeCommand.java +++ b/src/main/java/eu/mhsl/craftattack/worldmuseum/commands/GamemodeCommand.java @@ -8,10 +8,29 @@ import net.minestom.server.entity.Player; public class GamemodeCommand extends Command { public GamemodeCommand() { - super("gamemode", "gm"); - addSyntax((sender, context) -> ((Player) sender).setGameMode( - context.get("target")), - ArgumentType.Enum("target", GameMode.class).setFormat(ArgumentEnum.Format.LOWER_CASED) + super("gamemode"); + addSyntax( + (sender, context) -> { + ((Player) sender).setGameMode(((PlayerGameModes) context.get("target")).getGameMode()); + ((Player) sender).setAllowFlying(true); + }, ArgumentType.Enum("target", PlayerGameModes.class).setFormat(ArgumentEnum.Format.LOWER_CASED) ); } + + public enum PlayerGameModes { + SURVIVAL(GameMode.SURVIVAL), + SPECTATOR(GameMode.SPECTATOR), + ADVENTURE(GameMode.ADVENTURE); + + final GameMode gameMode; + PlayerGameModes(GameMode gameMode) { + this.gameMode = gameMode; + } + + public GameMode getGameMode() { + return gameMode; + } + } } + + diff --git a/src/main/java/eu/mhsl/craftattack/worldmuseum/commands/TeleportCommand.java b/src/main/java/eu/mhsl/craftattack/worldmuseum/commands/TeleportCommand.java index baf023f..300f2e6 100644 --- a/src/main/java/eu/mhsl/craftattack/worldmuseum/commands/TeleportCommand.java +++ b/src/main/java/eu/mhsl/craftattack/worldmuseum/commands/TeleportCommand.java @@ -21,5 +21,6 @@ public class TeleportCommand extends Command { else p.teleport(targetPlayer.getPosition()); }), playerArgument); + } }