From b142be953f63127d9c7f7c4f48185d43877ac63a Mon Sep 17 00:00:00 2001 From: memetrollsXD Date: Wed, 20 Apr 2022 09:00:50 +0200 Subject: [PATCH] Fix merge conflict --- .../grasscutter/commands/PlayerCommands.java | 85 +++++++++++++------ 1 file changed, 59 insertions(+), 26 deletions(-) diff --git a/src/main/java/emu/grasscutter/commands/PlayerCommands.java b/src/main/java/emu/grasscutter/commands/PlayerCommands.java index 2c0827b82..ea2cbfbd6 100644 --- a/src/main/java/emu/grasscutter/commands/PlayerCommands.java +++ b/src/main/java/emu/grasscutter/commands/PlayerCommands.java @@ -32,8 +32,8 @@ import java.util.List; * A container for player-related commands. */ public final class PlayerCommands { - @Command(label = "give", aliases = { "g", "item", - "giveitem" }, usage = "Usage: give [player] [amount]") + @Command(label = "give", aliases = {"g", "item", "giveitem"}, + usage = "give [player] [amount]", description = "Gives an item to you or the specified player", permission = "player.give") public static class GiveCommand implements CommandHandler { @Override @@ -158,9 +158,9 @@ public final class PlayerCommands { } } } - - @Command(label = "drop", aliases = { "d", - "dropitem" }, usage = "Usage: drop [amount]", execution = Command.Execution.PLAYER) + @Command(label = "drop", aliases = {"d", "dropitem"}, + usage = "drop [amount]", + execution = Command.Execution.PLAYER, description = "Drops an item near you", permission = "server.drop") public static class DropCommand implements CommandHandler { @Override @@ -201,8 +201,8 @@ public final class PlayerCommands { } } - @Command(label = "givechar", aliases = { - "givec" }, usage = "Usage: givechar [level|avatarId] [level]") + @Command(label = "givechar", aliases = { "givec" }, usage = "givechar [level]", + description = "Gives the player a specified character", permission = "player.givechar") public static class GiveCharCommand implements CommandHandler { @Override public void execute(GenshinPlayer player, List args) { @@ -328,7 +328,8 @@ public final class PlayerCommands { } } - @Command(label = "spawn", execution = Command.Execution.PLAYER, usage = "Usage: spawn [level] [amount]") + @Command(label = "spawn", execution = Command.Execution.PLAYER, + usage = "spawn [level] [amount]", description = "Spawns an entity near you", permission = "server.spawn") public static class SpawnCommand implements CommandHandler { @Override @@ -365,8 +366,9 @@ public final class PlayerCommands { } } } - - @Command(label = "killall", usage = "Usage: killall [playerUid] [sceneId]") + + @Command(label = "killall", + usage = "killall [playerUid] [sceneId]", description = "Kill all entities", permission = "server.killall") public static class KillAllCommand implements CommandHandler { @Override @@ -411,8 +413,9 @@ public final class PlayerCommands { } } - @Command(label = "resetconst", aliases = { - "resetconstellation" }, usage = "Usage: resetconst [all]", execution = Command.Execution.PLAYER) + @Command(label = "resetconst", aliases = {"resetconstellation"}, + usage = "resetconst [all]", execution = Command.Execution.PLAYER, permission = "player.resetconstellation", + description = "Resets the constellation level on your current active character, will need to relog after using the command to see any changes.") public static class ResetConstellationCommand implements CommandHandler { @Override @@ -440,8 +443,9 @@ public final class PlayerCommands { avatar.save(); } } - - @Command(label = "godmode", usage = "Usage: godmode", execution = Command.Execution.PLAYER) + + @Command(label = "godmode", + usage = "godmode", execution = Command.Execution.PLAYER, description = "Prevents you from taking damage", permission = "player.godmode") public static class GodModeCommand implements CommandHandler { @Override @@ -451,8 +455,9 @@ public final class PlayerCommands { } } - @Command(label = "sethealth", aliases = { - "sethp" }, usage = "Usage: sethealth ", execution = Command.Execution.PLAYER) + @Command(label = "sethealth", aliases = {"sethp"}, + usage = "sethealth ", execution = Command.Execution.PLAYER, description = "Sets your health to the specified value", + permission = "player.sethealth") public static class SetHealthCommand implements CommandHandler { @Override @@ -478,8 +483,9 @@ public final class PlayerCommands { } } - @Command(label = "setworldlevel", aliases = { - "setworldlvl" }, usage = "Usage: setworldlevel ", execution = Command.Execution.PLAYER) + @Command(label = "setworldlevel", aliases = {"setworldlvl"}, usage = "setworldlevel ", + description = "Sets your world level (Relog to see proper effects)", permission = "player.setworldlevel", + execution = Command.Execution.PLAYER) public static class SetWorldLevelCommand implements CommandHandler { @Override public void execute(GenshinPlayer player, List args) { @@ -501,9 +507,10 @@ public final class PlayerCommands { } } } - - @Command(label = "clearartifacts", aliases = { - "clearart" }, usage = "Usage: clearartifacts", execution = Command.Execution.PLAYER) + + @Command(label = "clearartifacts", aliases = {"clearart"}, + usage = "clearartifacts", execution = Command.Execution.PLAYER, permission = "player.clearartifacts", + description = "Deletes all unequipped and unlocked level 0 artifacts, including yellow rarity ones from your inventory") public static class ClearArtifactsCommand implements CommandHandler { @Override public void execute(GenshinPlayer player, List args) { @@ -516,8 +523,8 @@ public final class PlayerCommands { } } - @Command(label = "changescene", aliases = { - "scene" }, usage = "Usage: changescene ", execution = Command.Execution.PLAYER) + @Command(label = "changescene", aliases = {"scene"}, + usage = "changescene ", description = "Changes your scene", permission = "player.changescene", execution = Command.Execution.PLAYER) public static class ChangeSceneCommand implements CommandHandler { @Override public void execute(GenshinPlayer player, List args) { @@ -540,12 +547,38 @@ public final class PlayerCommands { } } - @Command(label = "restart", usage = "Usage: restart - Restarts the current session", execution = Command.Execution.PLAYER) - public static class RestartCommand implements CommandHandler { + @Command(label = "sendservermessage", aliases = {"sendservmsg"}, + usage = "sendservermessage ", description = "Sends a message to a player as the server", + execution = Command.Execution.PLAYER, permission = "server.sendmessage") + public static class SendServerMessageCommand implements CommandHandler { + @Override + public void execute(GenshinPlayer player, List args) { + if(args.size() < 2) { + CommandHandler.sendMessage(null, "Usage: sendmessage "); return; + } + try { + int target = Integer.parseInt(args.get(0)); + String message = String.join(" ", args.subList(1, args.size())); + + GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); + if(targetPlayer == null) { + CommandHandler.sendMessage(null, "Player not found."); return; + } + + targetPlayer.dropMessage(message); + CommandHandler.sendMessage(null, "Message sent."); + } catch (NumberFormatException ignored) { + CommandHandler.sendMessage(null, "Invalid player ID."); + } + } + } + + @Command(label = "restart", usage = "Usage: restart", description = "Restarts the current session", execution = Command.Execution.PLAYER, permission = "player.restart") + public static class RestartCommand implements CommandHandler { @Override public void execute(GenshinPlayer player, List args) { player.getSession().close(); } } -} +} \ No newline at end of file