From b79784849765494006b815fa7916ad7dcb7d37c2 Mon Sep 17 00:00:00 2001 From: Alexander01998 Date: Tue, 6 Aug 2019 20:54:28 +0200 Subject: [PATCH] Add GmCmd --- .../java/net/wurstclient/command/CmdList.java | 3 +- .../java/net/wurstclient/commands/GmCmd.java | 54 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/main/java/net/wurstclient/commands/GmCmd.java diff --git a/src/main/java/net/wurstclient/command/CmdList.java b/src/main/java/net/wurstclient/command/CmdList.java index 027ed5fe..e19803d0 100644 --- a/src/main/java/net/wurstclient/command/CmdList.java +++ b/src/main/java/net/wurstclient/command/CmdList.java @@ -17,6 +17,7 @@ import net.wurstclient.commands.AnnoyCmd; import net.wurstclient.commands.AuthorCmd; import net.wurstclient.commands.BindsCmd; import net.wurstclient.commands.ClearCmd; +import net.wurstclient.commands.GmCmd; import net.wurstclient.commands.HelpCmd; import net.wurstclient.commands.SayCmd; @@ -39,7 +40,7 @@ public final class CmdList // public final GetPosCmd getPosCmd = new GetPosCmd(); // public final GhostHandCmd ghostHandCmd = new GhostHandCmd(); // public final GiveCmd giveCmd = new GiveCmd(); - // public final GmCmd gmCmd = new GmCmd(); + public final GmCmd gmCmd = new GmCmd(); // public final GoToCmd goToCmd = new GoToCmd(); public final HelpCmd helpCmd = new HelpCmd(); // public final InvseeCmd invseeCmd = new InvseeCmd(); diff --git a/src/main/java/net/wurstclient/commands/GmCmd.java b/src/main/java/net/wurstclient/commands/GmCmd.java new file mode 100644 index 00000000..1e2bef74 --- /dev/null +++ b/src/main/java/net/wurstclient/commands/GmCmd.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2014 - 2019 | Wurst-Imperium | All rights reserved. + * + * This source code is subject to the terms of the GNU General Public + * License, version 3. If a copy of the GPL was not distributed with this + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt + */ +package net.wurstclient.commands; + +import net.wurstclient.command.CmdException; +import net.wurstclient.command.CmdSyntaxError; +import net.wurstclient.command.Command; + +public final class GmCmd extends Command +{ + public GmCmd() + { + super("gm", "Shortcut for /gamemode.", ".gm "); + } + + @Override + public void call(String[] args) throws CmdException + { + if(args.length < 1) + throw new CmdSyntaxError(); + + String args2 = String.join(" ", args); + switch(args2) + { + case "s": + case "0": + args2 = "survival"; + break; + + case "c": + case "1": + args2 = "creative"; + break; + + case "a": + case "2": + args2 = "adventure"; + break; + + case "sp": + case "3": + args2 = "spectator"; + break; + } + + String message = "/gamemode " + args2; + MC.player.sendChatMessage(message); + } +}