diff --git a/server/src/main/java/org/allaymc/server/command/defaults/DifficultyCommand.java b/server/src/main/java/org/allaymc/server/command/defaults/DifficultyCommand.java index 5c5aa0d4c..a6b4c1a1c 100644 --- a/server/src/main/java/org/allaymc/server/command/defaults/DifficultyCommand.java +++ b/server/src/main/java/org/allaymc/server/command/defaults/DifficultyCommand.java @@ -16,11 +16,11 @@ public DifficultyCommand() { @Override public void prepareCommandTree(CommandTree tree) { - tree.getRoot().difficulty("difficulty").exec((context, player) -> { + tree.getRoot().difficulty("difficulty").exec((context, entity) -> { Difficulty difficulty = context.getResult(0); - player.getWorld().getWorldData().setDifficulty(difficulty); + entity.getWorld().getWorldData().setDifficulty(difficulty); context.addOutput(TrKeys.M_COMMANDS_DIFFICULTY_SUCCESS, difficulty); return context.success(); - }, SenderType.PLAYER); + }, SenderType.ENTITY); } } diff --git a/server/src/main/java/org/allaymc/server/command/defaults/GCCommand.java b/server/src/main/java/org/allaymc/server/command/defaults/GCCommand.java index 1c2ddee76..6574a9d4d 100644 --- a/server/src/main/java/org/allaymc/server/command/defaults/GCCommand.java +++ b/server/src/main/java/org/allaymc/server/command/defaults/GCCommand.java @@ -23,7 +23,7 @@ public void prepareCommandTree(CommandTree tree) { var memory = getCurrentMemoryUsage(); System.gc(); var freedMemory = memory - getCurrentMemoryUsage(); - context.getSender().sendText("Memory freed: " + TextFormat.GREEN + freedMemory + " MB"); + context.getSender().sendTr(TrKeys.A_COMMAND_GC_COMPLETED, freedMemory); return context.success(); }); } diff --git a/server/src/main/java/org/allaymc/server/command/defaults/MeCommand.java b/server/src/main/java/org/allaymc/server/command/defaults/MeCommand.java index 1990547ee..e4436baab 100644 --- a/server/src/main/java/org/allaymc/server/command/defaults/MeCommand.java +++ b/server/src/main/java/org/allaymc/server/command/defaults/MeCommand.java @@ -19,7 +19,8 @@ public MeCommand() { @Override public void prepareCommandTree(CommandTree tree) { tree.getRoot() - .msg("message") + .msg("message", "") + .optional() .exec(context -> { Server.getInstance().broadcastTr( TrKeys.M_CHAT_TYPE_EMOTE, diff --git a/server/src/main/java/org/allaymc/server/command/defaults/SetBlockCommand.java b/server/src/main/java/org/allaymc/server/command/defaults/SetBlockCommand.java index 4a0cf58b6..e48b9d5cc 100644 --- a/server/src/main/java/org/allaymc/server/command/defaults/SetBlockCommand.java +++ b/server/src/main/java/org/allaymc/server/command/defaults/SetBlockCommand.java @@ -25,7 +25,7 @@ public void prepareCommandTree(CommandTree tree) { .blockType("blockType") .blockPropertyValues("blockPropertyValues") .optional() - .exec((context, player) -> { + .exec((context, entity) -> { Vector3f pos = context.getResult(0); BlockType blockType = context.getResult(1); List> blockPropertyValues = context.getResult(2); @@ -35,9 +35,9 @@ public void prepareCommandTree(CommandTree tree) { context.addError("%" + TrKeys.M_COMMANDS_BLOCKSTATE_INVALIDSTATE, blockType.getIdentifier() + blockPropertyValues.toString()); return context.fail(); } - player.getDimension().setBlockState(pos, blockState); + entity.getDimension().setBlockState(pos, blockState); context.addOutput(TrKeys.M_COMMANDS_SETBLOCK_SUCCESS); return context.success(); - }, SenderType.PLAYER); + }, SenderType.ENTITY); } } diff --git a/server/src/main/java/org/allaymc/server/command/defaults/TpsCommand.java b/server/src/main/java/org/allaymc/server/command/defaults/TpsCommand.java index 0332d41c7..28e0fef04 100644 --- a/server/src/main/java/org/allaymc/server/command/defaults/TpsCommand.java +++ b/server/src/main/java/org/allaymc/server/command/defaults/TpsCommand.java @@ -20,15 +20,15 @@ public void prepareCommandTree(CommandTree tree) { tree.getRoot() .key("tps") .optional() - .exec((context, player) -> { - player.sendText(TextFormat.GREEN + "TPS: " + player.getLocation().dimension().getWorld().getTPS()); + .exec(context -> { + context.getSender().sendText(TextFormat.GREEN + "TPS: " + context.getSender().getCmdExecuteLocation().dimension().getWorld().getTPS()); return context.success(); - }, SenderType.PLAYER) + }) .root() .key("mspt") - .exec((context, player) -> { - player.sendText(TextFormat.GREEN + "MSPT: " + player.getLocation().dimension().getWorld().getMSPT()); + .exec(context -> { + context.getSender().sendText(TextFormat.GREEN + "MSPT: " + context.getSender().getCmdExecuteLocation().dimension().getWorld().getMSPT()); return context.success(); - }, SenderType.PLAYER); + }); } } diff --git a/server/src/main/java/org/allaymc/server/command/defaults/WeatherCommand.java b/server/src/main/java/org/allaymc/server/command/defaults/WeatherCommand.java index 71e8ad3be..05f9d7ea0 100644 --- a/server/src/main/java/org/allaymc/server/command/defaults/WeatherCommand.java +++ b/server/src/main/java/org/allaymc/server/command/defaults/WeatherCommand.java @@ -19,12 +19,12 @@ public WeatherCommand() { public void prepareCommandTree(CommandTree tree) { tree.getRoot() .enums("weather", Weather.class) - .exec((context, player) -> { + .exec(context -> { Weather weather = Weather.valueOf(((String)context.getResult(0)).toUpperCase()); if (weather == Weather.CLEAR) { - player.getWorld().clearWeather(); + context.getSender().getCmdExecuteLocation().dimension().getWorld().clearWeather(); } else { - player.getWorld().addWeather(weather); + context.getSender().getCmdExecuteLocation().dimension().getWorld().addWeather(weather); } context.addOutput(switch (weather) { case CLEAR -> TrKeys.M_COMMANDS_WEATHER_CLEAR; @@ -32,21 +32,21 @@ public void prepareCommandTree(CommandTree tree) { case THUNDER -> TrKeys.M_COMMANDS_WEATHER_THUNDER; }); return context.success(); - }, SenderType.PLAYER) + }) .root() .key("query") - .exec((context, player) -> { - var weathers = player.getWorld().getWeathers(); + .exec(context -> { + var weathers = context.getSender().getCmdExecuteLocation().dimension().getWorld().getWeathers(); if (weathers.contains(Weather.CLEAR)) { - player.sendTr(TrKeys.M_COMMANDS_WEATHER_QUERY, "clear"); + context.getSender().sendTr(TrKeys.M_COMMANDS_WEATHER_QUERY, "clear"); return context.success(); } if (weathers.contains(Weather.THUNDER)) { - player.sendTr(TrKeys.M_COMMANDS_WEATHER_QUERY, "rain and thunder"); + context.getSender().sendTr(TrKeys.M_COMMANDS_WEATHER_QUERY, "rain and thunder"); return context.success(); } - player.sendTr(TrKeys.M_COMMANDS_WEATHER_QUERY, "rain"); + context.getSender().sendTr(TrKeys.M_COMMANDS_WEATHER_QUERY, "rain"); return context.success(); - }, SenderType.PLAYER); + }); } } diff --git a/server/src/main/java/org/allaymc/server/command/defaults/WorldCommand.java b/server/src/main/java/org/allaymc/server/command/defaults/WorldCommand.java index 396fad187..55de767cb 100644 --- a/server/src/main/java/org/allaymc/server/command/defaults/WorldCommand.java +++ b/server/src/main/java/org/allaymc/server/command/defaults/WorldCommand.java @@ -44,7 +44,7 @@ public void prepareCommandTree(CommandTree tree) { .str("world") .intNum("dimId") .optional() - .exec((context, player) -> { + .exec((context, entity) -> { String worldName = context.getResult(1); int dimId = context.getResult(2); var world = Server.getInstance().getWorldPool().getWorld(worldName); @@ -59,9 +59,9 @@ public void prepareCommandTree(CommandTree tree) { return context.fail(); } - player.teleport(new Location3f(0, 64, 0, dim)); + entity.teleport(new Location3f(0, 64, 0, dim)); context.addOutput(TrKeys.A_COMMAND_WORLD_SUCCESS, worldName, dimId); return context.success(); - }, SenderType.PLAYER); + }, SenderType.ENTITY); } }