From 68f0177eb5ef7dddd1295c1a07d4c1df5495fd2e Mon Sep 17 00:00:00 2001 From: MrSnowy Date: Sat, 25 Apr 2026 18:16:08 +0200 Subject: [PATCH] Update to Minecraft Version 26.1 (using #30 thanks to Wjiangzhi!) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 江芷酱紫 --- .gitattributes | 5 +- .github/workflows/build.yml | 2 +- README.md | 4 +- common/build.gradle | 12 +++- .../teleport_commands/TeleportCommands.java | 2 +- .../teleport_commands/commands/back.java | 16 ++--- .../teleport_commands/commands/home.java | 67 +++++++++---------- .../teleport_commands/commands/main.java | 14 ++-- .../teleport_commands/commands/tpa.java | 40 +++++------ .../teleport_commands/commands/warp.java | 63 ++++++++--------- .../commands/worldspawn.java | 18 +++-- .../common/DeathLocation.java | 2 +- .../common/NamedLocation.java | 2 +- .../teleport_commands/utils/tools.java | 4 +- fabric/build.gradle | 13 ++-- flake.lock | 6 +- flake.nix | 3 +- gradle.properties | 22 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- justfile | 2 +- neoforge/build.gradle | 12 +++- quilt/build.gradle | 6 +- settings.gradle | 40 ++--------- 23 files changed, 161 insertions(+), 196 deletions(-) diff --git a/.gitattributes b/.gitattributes index 097f9f9..f1e482a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,12 @@ # # https://help.github.com/articles/dealing-with-line-endings/ -# + +* text=auto + # Linux start script should use lf /gradlew text eol=lf # These are Windows script files and should use crlf *.bat text eol=crlf + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2dc6468..e7e8f96 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: java: - - 21 # Currently min for minecraft + - 25 # Currently min for minecraft runs-on: ubuntu-latest steps: - name: checkout repository diff --git a/README.md b/README.md index c251d75..aa87faf 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,9 @@ Here is the [Changelog](https://github.com/MrSn0wy/TeleportCommands/blob/main/CH #### Getting the correct environment If you are on nixos you can simply go into the folder of where you cloned the repo, and run `nix develop .`. This will give you the environment I use (apart from the IDE) :3. -On any other linux distro, just install the jetbrains jdk, or try openjdk21. +On any other linux distro try openjdk25. -On windows probably go to the openjdk website and install the 21 version? idk goodluck. +On windows probably go to the openjdk website and install the 25 version? idk goodluck. #### Building Then on linux just do `./gradlew build` and to make it in a single mod jar `./gradlew mergeJars`. diff --git a/common/build.gradle b/common/build.gradle index e47427c..ca3cb04 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -3,13 +3,23 @@ plugins { id 'net.neoforged.moddev' } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(25) + } +} + neoForge { - neoFormVersion = neo_form_version // Automatically enable AccessTransformers if the file exists def at = file('src/main/resources/META-INF/accesstransformer.cfg') if (at.exists()) { accessTransformers.from(at.absolutePath) } + enable { + version = neoforge_version + neoFormVersion = neo_form_version + disableRecompilation = true + } parchment { minecraftVersion = parchment_minecraft mappingsVersion = parchment_version diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/TeleportCommands.java b/common/src/main/java/dev/mrsnowy/teleport_commands/TeleportCommands.java index 8dfd2e4..1f734e1 100644 --- a/common/src/main/java/dev/mrsnowy/teleport_commands/TeleportCommands.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/TeleportCommands.java @@ -53,7 +53,7 @@ public class TeleportCommands { // Runs when the playerDeath mixin calls it, updates the /back command position public static void onPlayerDeath(ServerPlayer player) { BlockPos pos = new BlockPos(player.getBlockX(), player.getBlockY(), player.getBlockZ()); - String world = player.serverLevel().dimension().location().toString(); + String world = player.level().dimension().identifier().toString(); String uuid = player.getStringUUID(); DeathLocationStorage.setDeathLocation(uuid, pos, world); diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/back.java b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/back.java index 74c3fae..222b941 100644 --- a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/back.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/back.java @@ -27,7 +27,6 @@ public class back { public static void register(CommandDispatcher commandDispatcher) { commandDispatcher.register(Commands.literal("back") - .requires(source -> source.getPlayer() != null) .executes(context -> { final ServerPlayer player = context.getSource().getPlayerOrException(); @@ -36,13 +35,12 @@ public class back { } catch (Exception e) { Constants.LOGGER.error("Error while going back! => ", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; }) .then(argument("Disable Safety", BoolArgumentType.bool()) - .requires(source -> source.getPlayer() != null) .executes(context -> { final boolean safety = BoolArgumentType.getBool(context, "Disable Safety"); final ServerPlayer player = context.getSource().getPlayerOrException(); @@ -52,7 +50,7 @@ public class back { } catch (Exception e) { Constants.LOGGER.error("Error while going back! => ", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; @@ -70,7 +68,7 @@ public class back { .orElse(null); if (deathLocation == null) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.noLocation", player).withStyle(ChatFormatting.RED), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.noLocation", player).withStyle(ChatFormatting.RED), true); return; } @@ -83,7 +81,7 @@ public class back { deathLocation.getWorldString(), tools.getWorldIds()); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) .withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return; @@ -98,7 +96,7 @@ public class back { // Check if there is a safe BlockPos if (safeBlockPos.isEmpty()) { // asks the player if they want to teleport anyway - player.displayClientMessage( + player.sendSystemMessage( Component.empty() .append(getTranslatedText("commands.teleport_commands.common.noSafeLocation", player) .withStyle(ChatFormatting.RED, ChatFormatting.BOLD) @@ -125,13 +123,13 @@ public class back { // check if the player is already at this location (in the same world) if (player.blockPosition().equals(teleportBlockPos) && player.level() == deathLocationWorld) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.same", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.back.same", player).withStyle(ChatFormatting.AQUA), true); } else { // teleport the player! Vec3 teleportPos = new Vec3(teleportBlockPos.getX() + 0.5, teleportBlockPos.getY(), teleportBlockPos.getZ() + 0.5); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.go", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.back.go", player), true); tools.Teleporter(player, deathLocationWorld, teleportPos); } } diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/home.java b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/home.java index 267c5f5..c735e34 100644 --- a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/home.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/home.java @@ -33,7 +33,6 @@ public class home { public static void register(CommandDispatcher commandDispatcher) { commandDispatcher.register(Commands.literal("sethome") - .requires(source -> source.getPlayer() != null) .then(argument("name", StringArgumentType.string()) .executes(context -> { final String name = StringArgumentType.getString(context, "name"); @@ -44,7 +43,7 @@ public class home { } catch (Exception e) { Constants.LOGGER.error("Error while setting a home! => ", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; @@ -52,7 +51,6 @@ public class home { commandDispatcher.register(Commands.literal("home") - .requires(source -> source.getPlayer() != null) .executes(context -> { final ServerPlayer player = context.getSource().getPlayerOrException(); @@ -61,14 +59,13 @@ public class home { } catch (Exception e) { Constants.LOGGER.error("Error while going home! => ", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; }) .then(argument("name", StringArgumentType.string()) .suggests(new HomeSuggestionProvider()) - .requires(source -> source.getPlayer() != null) .executes(context -> { final String name = StringArgumentType.getString(context, "name"); final ServerPlayer player = context.getSource().getPlayerOrException(); @@ -78,14 +75,13 @@ public class home { } catch (Exception e) { Constants.LOGGER.error("Error while going to a specific home! => ", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; }))); commandDispatcher.register(Commands.literal("delhome") - .requires(source -> source.getPlayer() != null) .then(argument("name", StringArgumentType.string()) .suggests(new HomeSuggestionProvider()) .executes(context -> { @@ -97,7 +93,7 @@ public class home { } catch (Exception e) { Constants.LOGGER.error("Error while deleting a home! => ", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.deleteError", player) + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.deleteError", player) .withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } @@ -105,7 +101,6 @@ public class home { }))); commandDispatcher.register(Commands.literal("renamehome") - .requires(source -> source.getPlayer() != null) .then(argument("name", StringArgumentType.string()) .suggests(new HomeSuggestionProvider()) .then(argument("newName", StringArgumentType.string()) @@ -119,7 +114,7 @@ public class home { } catch (Exception e) { Constants.LOGGER.error("Error while renaming a home! => ", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.renameError", player) + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.renameError", player) .withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } @@ -128,7 +123,6 @@ public class home { commandDispatcher.register(Commands.literal("defaulthome") - .requires(source -> source.getPlayer() != null) .then(argument("name", StringArgumentType.string()).suggests(new HomeSuggestionProvider()) .executes(context -> { final String name = StringArgumentType.getString(context, "name"); @@ -139,14 +133,13 @@ public class home { } catch (Exception e) { Constants.LOGGER.error("Error while setting the default home! => ", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.defaultError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.defaultError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; }))); commandDispatcher.register(Commands.literal("homes") - .requires(source -> source.getPlayer() != null) .executes(context -> { final ServerPlayer player = context.getSource().getPlayerOrException(); @@ -155,7 +148,7 @@ public class home { } catch (Exception e) { Constants.LOGGER.error("Error while printing the homes! => ", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.homes.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.homes.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; @@ -169,7 +162,7 @@ public class home { private static void SetHome(ServerPlayer player, String homeName) throws Exception { homeName = homeName.toLowerCase(); BlockPos blockPos = player.blockPosition(); - String worldString = player.serverLevel().dimension().location().toString(); + String worldString = player.level().dimension().identifier().toString(); // Gets the player's storage and creates it if it doesn't exist Player playerStorage = StorageManager.STORAGE.addPlayer(player.getStringUUID()); @@ -182,7 +175,7 @@ public class home { if (homeExists) { // Display error message that the home already exists - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.exists", player).withStyle(ChatFormatting.RED), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.exists", player).withStyle(ChatFormatting.RED), true); } else { // Set it as the default if there are no other homes @@ -191,7 +184,7 @@ public class home { } // Display message that the home has been set - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.set", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.set", player), true); } } @@ -202,7 +195,7 @@ public class home { // Get player storage Optional optionalPlayerStorage = STORAGE.getPlayer(player.getStringUUID()); if (optionalPlayerStorage.isEmpty()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); return; } @@ -214,7 +207,7 @@ public class home { if (defaultHome.isEmpty()) { // No default home set! - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.defaultNone", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.defaultNone", player).withStyle(ChatFormatting.AQUA), true); return; } else { @@ -225,7 +218,7 @@ public class home { // Get the home (if it exists) Optional optionalHome = playerStorage.getHome(homeName); if (optionalHome.isEmpty()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.AQUA), true); return; } @@ -241,7 +234,7 @@ public class home { home.getWorldString(), tools.getWorldIds()); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) .withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return; @@ -253,13 +246,13 @@ public class home { // Check if the player is already at this location (in the same world) if (player.blockPosition().equals(teleportBlockPos) && player.level() == homeWorld) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.goSame", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.goSame", player).withStyle(ChatFormatting.AQUA), true); } else { // Teleport the player! Vec3 teleportPos = new Vec3(teleportBlockPos.getX() + 0.5, teleportBlockPos.getY(), teleportBlockPos.getZ() + 0.5); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.go", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.go", player), true); Teleporter(player, homeWorld, teleportPos); } } @@ -270,7 +263,7 @@ public class home { // Gets player storage Optional optionalPlayerStorage = STORAGE.getPlayer(player.getStringUUID()); if (optionalPlayerStorage.isEmpty()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); return; } @@ -279,7 +272,7 @@ public class home { // Get the home from the player Optional optionalHome = playerStorage.getHome(homeName); if (optionalHome.isEmpty()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); return; } @@ -293,7 +286,7 @@ public class home { // todo! maybe ask the player if they want to set a new default home? :3 } - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.delete", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.delete", player), true); } private static void RenameHome(ServerPlayer player, String homeName, String newHomeName) throws Exception { @@ -303,7 +296,7 @@ public class home { // Gets player storage Optional optionalPlayerStorage = STORAGE.getPlayer(player.getStringUUID()); if (optionalPlayerStorage.isEmpty()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); return; } @@ -311,14 +304,14 @@ public class home { // Check if there already is a home with the new name if (playerStorage.getHome(newHomeName).isPresent()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.nameExists", player).withStyle(ChatFormatting.RED), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.nameExists", player).withStyle(ChatFormatting.RED), true); return; } // Get the home that needs to be renamed Optional optionalHome = playerStorage.getHome(homeName); if (optionalHome.isEmpty()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); return; } @@ -330,7 +323,7 @@ public class home { playerStorage.setDefaultHome(newHomeName); } - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.rename", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.rename", player), true); } private static void SetDefaultHome(ServerPlayer player, String homeName) throws Exception { @@ -339,7 +332,7 @@ public class home { // Gets player storage Optional optionalPlayerStorage = STORAGE.getPlayer(player.getStringUUID()); if (optionalPlayerStorage.isEmpty()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); return; } @@ -347,26 +340,26 @@ public class home { // Check if the new default home exists if ( playerStorage.getHome(homeName).isEmpty() ) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); return; } // Check if the home is already the default if (playerStorage.getDefaultHome().equals(homeName)) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.defaultSame", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.defaultSame", player).withStyle(ChatFormatting.AQUA), true); return; } // set the new default playerStorage.setDefaultHome(homeName); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.default", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.default", player), true); } private static void PrintHomes(ServerPlayer player) throws Exception { // Gets player storage, if no storage then the player is homeless! Optional optionalPlayerStorage = STORAGE.getPlayer(player.getStringUUID()); if (optionalPlayerStorage.isEmpty()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); return; } @@ -376,7 +369,7 @@ public class home { // Check if there are any homes lol if (homes.isEmpty()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); return; } @@ -513,6 +506,6 @@ public class home { } // send the message - player.displayClientMessage(message, false); + player.sendSystemMessage(message, false); } } \ No newline at end of file diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/main.java b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/main.java index 952618f..52de689 100644 --- a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/main.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/main.java @@ -26,7 +26,6 @@ // // commandManager.getDispatcher().register(Commands.literal("teleportcommands") // .then(Commands.literal("help") -// .requires(source -> source.getPlayer() != null) // .executes(context -> { // final ServerPlayer player = context.getSource().getPlayerOrException(); // @@ -35,13 +34,12 @@ // // } catch (Exception e) { // TeleportCommands.LOGGER.error("Error while going back! => ", e); -// player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); +// player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); // return 1; // } // return 0; // })) // .then(argument("Disable Safety", BoolArgumentType.bool()) -// .requires(source -> source.getPlayer() != null) // .executes(context -> { // final boolean safety = BoolArgumentType.getBool(context, "Disable Safety"); // final ServerPlayer player = context.getSource().getPlayerOrException(); @@ -51,7 +49,7 @@ // // } catch (Exception e) { // TeleportCommands.LOGGER.error("Error while going back! => ", e); -// player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); +// player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); // return 1; // } // return 0; @@ -66,11 +64,11 @@ // // Gets the DeathLocation of the player and teleports the player to it // private static void printCommands(ServerPlayer player) throws Exception { // -// player.displayClientMessage(Component.literal("Thank you for using Teleport Commands (V)!").withStyle(ChatFormatting.AQUA), false); -// player.displayClientMessage(Component.literal("Teleport Commands is a server-side mod that adds various teleportation related commands").withStyle(ChatFormatting.AQUA), false); +// player.sendSystemMessage(Component.literal("Thank you for using Teleport Commands (V)!").withStyle(ChatFormatting.AQUA), false); +// player.sendSystemMessage(Component.literal("Teleport Commands is a server-side mod that adds various teleportation related commands").withStyle(ChatFormatting.AQUA), false); // -// player.displayClientMessage(Component.literal("----").withStyle(ChatFormatting.AQUA), false); +// player.sendSystemMessage(Component.literal("----").withStyle(ChatFormatting.AQUA), false); // -// player.displayClientMessage(Component.literal("Usage:").withStyle(ChatFormatting.AQUA), false); +// player.sendSystemMessage(Component.literal("Usage:").withStyle(ChatFormatting.AQUA), false); // } //} diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/tpa.java b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/tpa.java index f35ff4d..620c529 100644 --- a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/tpa.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/tpa.java @@ -38,7 +38,6 @@ public class tpa { public static void register(CommandDispatcher commandDispatcher) { commandDispatcher.register(Commands.literal("tpa") - .requires(source -> source.getPlayer() != null) .then(Commands.argument("player", EntityArgument.player()) .executes(context -> { final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); @@ -57,7 +56,6 @@ public class tpa { }))); commandDispatcher.register(Commands.literal("tpahere") - .requires(source -> source.getPlayer() != null) .then(Commands.argument("player", EntityArgument.player()) .executes(context -> { final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); @@ -74,7 +72,6 @@ public class tpa { }))); commandDispatcher.register(Commands.literal("tpaaccept") - .requires(source -> source.getPlayer() != null) .then(Commands.argument("player", EntityArgument.player()).suggests(new tpaSuggestionProvider()) .executes(context -> { final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); @@ -92,7 +89,6 @@ public class tpa { }))); commandDispatcher.register(Commands.literal("tpadeny") - .requires(source -> source.getPlayer() != null) .then(Commands.argument("player", EntityArgument.player()).suggests(new tpaSuggestionProvider()) .executes(context -> { final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); @@ -103,7 +99,7 @@ public class tpa { } catch (Exception e) { Constants.LOGGER.error("Error while denying a tpa(here) request! => ", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } @@ -119,10 +115,10 @@ public class tpa { .count(); if (FromPlayer == ToPlayer) { - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA), true); + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA), true); } else if (playerTpaList >= 1) { - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.alreadySent", FromPlayer, Component.literal(Objects.requireNonNull(ToPlayer.getName().getString(), "ToPlayer name cannot be null")).withStyle(ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA) + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.alreadySent", FromPlayer, Component.literal(Objects.requireNonNull(ToPlayer.getName().getString(), "ToPlayer name cannot be null")).withStyle(ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA) , true ); @@ -135,12 +131,12 @@ public class tpa { String ReceivedFromPlayer = Objects.requireNonNull(FromPlayer.getName().getString(), "FromPlayer name cannot be null"); String SentToPlayer = Objects.requireNonNull(ToPlayer.getName().getString(), "ToPlayer name cannot be null"); - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.sent", FromPlayer, Component.literal(hereText), Component.literal(SentToPlayer).withStyle(ChatFormatting.BOLD)) + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.sent", FromPlayer, Component.literal(hereText), Component.literal(SentToPlayer).withStyle(ChatFormatting.BOLD)) // .append(Text.literal("\n[Cancel]").formatted(Formatting.BLUE, Formatting.BOLD)) ,true ); - ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.received", ToPlayer, Component.literal(hereText), Component.literal(ReceivedFromPlayer).withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA) + ToPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.received", ToPlayer, Component.literal(hereText), Component.literal(ReceivedFromPlayer).withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA) .append("\n") .append(getTranslatedText("commands.teleport_commands.tpa.accept", ToPlayer) .withStyle(ChatFormatting.GREEN, ChatFormatting.BOLD) @@ -173,8 +169,8 @@ public class tpa { public void run() { boolean successful = tpaList.remove(tpaRequest); if (successful) { - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.expired", FromPlayer, Component.literal(hereText)).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); - ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.expired", ToPlayer, Component.literal(hereText)).withStyle(ChatFormatting.WHITE),true); + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.expired", FromPlayer, Component.literal(hereText)).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); + ToPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.expired", ToPlayer, Component.literal(hereText)).withStyle(ChatFormatting.WHITE),true); } // else not needed since it may be denied/cancelled } @@ -185,7 +181,7 @@ public class tpa { private static void tpaAccept(ServerPlayer FromPlayer, ServerPlayer ToPlayer) { if (FromPlayer == ToPlayer) { - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA), true); + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA), true); return; } @@ -200,32 +196,32 @@ public class tpa { ServerPlayer destinationPlayer = tpaStorage.get().here ? ToPlayer : FromPlayer; ServerPlayer toSentPlayer = tpaStorage.get().here ? FromPlayer : ToPlayer; - Optional teleportData = getSafeBlockPos(destinationPlayer.blockPosition(), destinationPlayer.serverLevel()); + Optional teleportData = getSafeBlockPos(destinationPlayer.blockPosition(), destinationPlayer.level()); if (teleportData.isPresent()) { BlockPos safeBlockPos = teleportData.get(); Vec3 teleportPos = new Vec3(safeBlockPos.getX() + 0.5, safeBlockPos.getY(), safeBlockPos.getZ() + 0.5); - Teleporter(toSentPlayer, destinationPlayer.serverLevel(), teleportPos); + Teleporter(toSentPlayer, destinationPlayer.level(), teleportPos); } else { // if no safe location then just teleport to the player - Teleporter(toSentPlayer, destinationPlayer.serverLevel(), destinationPlayer.position()); + Teleporter(toSentPlayer, destinationPlayer.level(), destinationPlayer.position()); } // if the player teleported then these messages get sent && the request gets removed - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", FromPlayer).withStyle(ChatFormatting.WHITE),true); - ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", ToPlayer).withStyle(ChatFormatting.GREEN),true); + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", FromPlayer).withStyle(ChatFormatting.WHITE),true); + ToPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", ToPlayer).withStyle(ChatFormatting.GREEN),true); tpaList.remove(tpaStorage.get()); } else { // No request found - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.notFound", FromPlayer).withStyle(ChatFormatting.RED),true); + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.notFound", FromPlayer).withStyle(ChatFormatting.RED),true); } } private static void tpaDeny(ServerPlayer FromPlayer, ServerPlayer ToPlayer) { if (FromPlayer == ToPlayer) { - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA),true); + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA),true); } else { Optional tpaStorage = tpaList.stream() @@ -236,11 +232,11 @@ public class tpa { if (tpaStorage.isPresent()) { tpaList.remove(tpaStorage.get()); - ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.denied", ToPlayer).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.denied", FromPlayer).withStyle(ChatFormatting.WHITE),true); + ToPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.denied", ToPlayer).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.denied", FromPlayer).withStyle(ChatFormatting.WHITE),true); } else { - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.notFound", FromPlayer).withStyle(ChatFormatting.RED),true); + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.notFound", FromPlayer).withStyle(ChatFormatting.RED),true); } } } diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/warp.java b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/warp.java index 9789be8..722cc25 100644 --- a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/warp.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/warp.java @@ -16,6 +16,8 @@ import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.permissions.Permission; +import net.minecraft.server.permissions.PermissionLevel; import net.minecraft.world.phys.Vec3; import java.util.List; @@ -30,10 +32,7 @@ public class warp { public static void register(CommandDispatcher commandDispatcher) { commandDispatcher.register(Commands.literal("setwarp") - .requires(source -> - source.getPlayer() != null && - source.hasPermission(4) - ) + .requires(source -> source.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.OWNERS))) .then(argument("name", StringArgumentType.string()) .executes(context -> { final String name = StringArgumentType.getString(context, "name"); @@ -44,14 +43,13 @@ public class warp { } catch (Exception e) { Constants.LOGGER.error("Error while setting the warp!", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; }))); commandDispatcher.register(Commands.literal("warp") - .requires(source -> source.getPlayer() != null) .then(argument("name", StringArgumentType.string()) .suggests(new WarpSuggestionProvider()) .executes(context -> { @@ -63,17 +61,14 @@ public class warp { } catch (Exception e) { Constants.LOGGER.error("Error while going to the warp!",e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; }))); commandDispatcher.register(Commands.literal("delwarp") - .requires(source -> - source.getPlayer() != null && - source.hasPermission(4) - ) + .requires(source -> source.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.OWNERS))) .then(argument("name", StringArgumentType.string()).suggests(new WarpSuggestionProvider()) .executes(context -> { final String name = StringArgumentType.getString(context, "name"); @@ -84,17 +79,14 @@ public class warp { } catch (Exception e) { Constants.LOGGER.error("Error while deleting to the warp!", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.deleteError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.deleteError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; }))); commandDispatcher.register(Commands.literal("renamewarp") - .requires(source -> - source.getPlayer() != null && - source.hasPermission(4) - ) + .requires(source -> source.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.OWNERS))) .then(argument("name", StringArgumentType.string()).suggests(new WarpSuggestionProvider()) .then(argument("newName", StringArgumentType.string()) .executes(context -> { @@ -107,14 +99,13 @@ public class warp { } catch (Exception e) { Constants.LOGGER.error("Error while renaming the warp!", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.renameError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.renameError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; })))); commandDispatcher.register(Commands.literal("warps") - .requires(source -> source.getPlayer() != null) .executes(context -> { final ServerPlayer player = context.getSource().getPlayerOrException(); @@ -123,7 +114,7 @@ public class warp { } catch (Exception e) { Constants.LOGGER.error("Error while printing warps!", e); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warps.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warps.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; @@ -136,7 +127,7 @@ public class warp { warpName = warpName.toLowerCase(); BlockPos blockPos = new BlockPos(player.getBlockX(), player.getBlockY(), player.getBlockZ()); - String worldString = player.serverLevel().dimension().location().toString(); + String worldString = player.level().dimension().identifier().toString(); // Create the NamedLocation NamedLocation warp = new NamedLocation(warpName, blockPos, worldString); @@ -146,21 +137,21 @@ public class warp { if (warpExists) { // Display error message that the warp already exists - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.exists", player).withStyle(ChatFormatting.RED), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.exists", player).withStyle(ChatFormatting.RED), true); } else { // Display message that the home as been set - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.set", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.set", player), true); } } - private static void GoToWarp(ServerPlayer player, String warpName) throws Exception { + private static void GoToWarp(ServerPlayer player, String warpName) { warpName = warpName.toLowerCase(); // Gets warp Optional optionalWarp = STORAGE.getWarp(warpName); if (optionalWarp.isEmpty()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); return; } @@ -176,7 +167,7 @@ public class warp { warp.getWorldString(), tools.getWorldIds()); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) .withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return; @@ -188,13 +179,13 @@ public class warp { // Check if the player is already at this location (in the same world) if (player.blockPosition().equals(teleportBlockPos) && player.level() == warpWorld) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.goSame", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.goSame", player).withStyle(ChatFormatting.AQUA), true); } else { // Teleport the player! Vec3 teleportPos = new Vec3(teleportBlockPos.getX() + 0.5, teleportBlockPos.getY(), teleportBlockPos.getZ() + 0.5); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.go", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.go", player), true); Teleporter(player, warpWorld, teleportPos); } } @@ -209,11 +200,11 @@ public class warp { // Delete the warp STORAGE.removeWarp(optionalWarp.get()); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.delete", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.delete", player), true); } else { // the warp is not found - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); } } @@ -223,7 +214,7 @@ public class warp { // check if there is no existing warp with the new name if (STORAGE.getWarp(newWarpName).isPresent()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.nameExists", player).withStyle(ChatFormatting.RED), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.nameExists", player).withStyle(ChatFormatting.RED), true); return; } @@ -234,21 +225,21 @@ public class warp { // set the new name warpToRename.get().setName(newWarpName); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.rename", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.rename", player), true); } else { // the warp is not found - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); } } - private static void PrintWarps(ServerPlayer player) throws Exception { + private static void PrintWarps(ServerPlayer player) { // Get warps List warps = STORAGE.getWarps(); // Check if there are any warps lol if (warps.isEmpty()) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.homeless", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.homeless", player).withStyle(ChatFormatting.AQUA), true); return; } @@ -265,7 +256,7 @@ public class warp { String coords = String.format("[X%d Y%d Z%d]", currentWarp.getX(), currentWarp.getY(), currentWarp.getZ()); String dimension = String.format(" [%s]", currentWarp.getWorldString()); - boolean canModify = player.hasPermissions(4); + boolean canModify = player.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.OWNERS)); // linebreak message.append("\n"); @@ -364,6 +355,6 @@ public class warp { } // send the message - player.displayClientMessage(message, false); + player.sendSystemMessage(message, false); } } diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/worldspawn.java b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/worldspawn.java index 7e5577a..77982fb 100644 --- a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/worldspawn.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/worldspawn.java @@ -26,7 +26,6 @@ public class worldspawn { public static void register(CommandDispatcher commandDispatcher) { commandDispatcher.register(Commands.literal("worldspawn") - .requires(source -> source.getPlayer() != null) .executes(context -> { final ServerPlayer player = context.getSource().getPlayerOrException(); @@ -35,13 +34,12 @@ public class worldspawn { } catch (Exception error) { Constants.LOGGER.error("Error while going to the worldspawn! => ", error); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; }) .then(argument("Disable Safety", BoolArgumentType.bool()) - .requires(source -> source.getPlayer() != null) .executes(context -> { final boolean safety = BoolArgumentType.getBool(context, "Disable Safety"); final ServerPlayer player = context.getSource().getPlayerOrException(); @@ -51,7 +49,7 @@ public class worldspawn { } catch (Exception error) { Constants.LOGGER.error("Error while going to the worldspawn! => ", error); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); return 1; } return 0; @@ -63,7 +61,7 @@ public class worldspawn { private static void toWorldSpawn(ServerPlayer player, boolean safetyDisabled) throws NullPointerException { // todo! make the dimension customizable ServerLevel world = TeleportCommands.SERVER.getLevel(OVERWORLD); - BlockPos worldSpawn = Objects.requireNonNull(world,"Overworld cannot be null!").getSharedSpawnPos(); + BlockPos worldSpawn = Objects.requireNonNull(world,"Overworld cannot be null!").getLevelData().getRespawnData().pos(); if (!safetyDisabled) { Optional teleportData = getSafeBlockPos(worldSpawn, world); @@ -74,17 +72,17 @@ public class worldspawn { // check if the player is already at this location if (player.blockPosition().equals(safeBlockPos) && player.level() == world) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.same", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.worldspawn.same", player).withStyle(ChatFormatting.AQUA), true); } else { Vec3 teleportPos = new Vec3(safeBlockPos.getX() + 0.5, safeBlockPos.getY(), safeBlockPos.getZ() + 0.5); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.go", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.worldspawn.go", player), true); Teleporter(player, world, teleportPos); } } else { - player.displayClientMessage( + player.sendSystemMessage( Component.empty() .append(getTranslatedText("commands.teleport_commands.common.noSafeLocation", player) .withStyle(ChatFormatting.RED, ChatFormatting.BOLD) @@ -108,10 +106,10 @@ public class worldspawn { if (player.blockPosition().equals(worldSpawn) && player.level() == world) { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.same", player).withStyle(ChatFormatting.AQUA), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.worldspawn.same", player).withStyle(ChatFormatting.AQUA), true); } else { - player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.go", player), true); + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.worldspawn.go", player), true); Teleporter(player, world, new Vec3(worldSpawn.getX() + 0.5, worldSpawn.getY(), worldSpawn.getZ() + 0.5)); } } diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/common/DeathLocation.java b/common/src/main/java/dev/mrsnowy/teleport_commands/common/DeathLocation.java index 9f45e6a..d4f383e 100644 --- a/common/src/main/java/dev/mrsnowy/teleport_commands/common/DeathLocation.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/common/DeathLocation.java @@ -32,7 +32,7 @@ public class DeathLocation { // function to quickly filter the worlds and get the ServerLevel for the string public Optional getWorld() { return StreamSupport.stream( TeleportCommands.SERVER.getAllLevels().spliterator(), false ) // woa, this looks silly - .filter(level -> Objects.equals( level.dimension().location().toString(), this.world )) + .filter(level -> Objects.equals( level.dimension().identifier().toString(), this.world )) .findFirst(); } diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/common/NamedLocation.java b/common/src/main/java/dev/mrsnowy/teleport_commands/common/NamedLocation.java index 9af35ab..7183a73 100644 --- a/common/src/main/java/dev/mrsnowy/teleport_commands/common/NamedLocation.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/common/NamedLocation.java @@ -54,7 +54,7 @@ public class NamedLocation { // function to quickly filter the worlds and get the ServerLevel for the string public Optional getWorld() { return StreamSupport.stream( TeleportCommands.SERVER.getAllLevels().spliterator(), false ) // woa, this looks silly - .filter(level -> Objects.equals( level.dimension().location().toString(), this.world )) + .filter(level -> Objects.equals( level.dimension().identifier().toString(), this.world )) .findFirst(); } diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java b/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java index 38854c0..ef242f7 100644 --- a/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java @@ -124,7 +124,7 @@ public class tools { // Constants.LOGGER.info("{} : {} : {}", pack.packId(), pack.location(), pack.getClass()); // }); -// player.displayClientMessage(Component.literal(.toString()), false); +// player.sendSystemMessage(Component.literal(.toString()), false); // the try catch stuff is so wacky, but it works fine and I don't need to check everything try { @@ -195,7 +195,7 @@ public class tools { // Gets the ids of all the worlds public static List getWorldIds() { return StreamSupport.stream(TeleportCommands.SERVER.getAllLevels().spliterator(), false) - .map(level -> level.dimension().location().toString()) + .map(level -> level.dimension().identifier().toString()) .toList(); } diff --git a/fabric/build.gradle b/fabric/build.gradle index 547985f..bc0cbc9 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,15 +1,12 @@ plugins { id 'multiloader-loader' + id "net.fabricmc.fabric-loom" id 'fabric-loom' } dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" - mappings loom.layered() { - officialMojangMappings() - parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip") - } - modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" + implementation "net.fabricmc:fabric-loader:${fabric_loader_version}" // modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api}" } @@ -18,9 +15,6 @@ loom { if (aw.exists()) { accessWidenerPath.set(aw) } - mixin { - defaultRefmapName.set("${mod_id}.refmap.json") - } runs { client { client() @@ -37,7 +31,8 @@ loom { } } +/* Update to 26.1 no needed // Fix for fabric - makes it so it uses the archive name I specify tasks.named("remapJar") { archiveFileName.set("${mod_id}-${project.name}-${minecraft_version}-v${version}.jar") -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/flake.lock b/flake.lock index c4feea0..839eaed 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1756125398, - "narHash": "sha256-XexyKZpf46cMiO5Vbj+dWSAXOnr285GHsMch8FBoHbc=", + "lastModified": 1776877367, + "narHash": "sha256-EHq1/OX139R1RvBzOJ0aMRT3xnWyqtHBRUBuO1gFzjI=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3b9f00d7a7bf68acd4c4abb9d43695afb04e03a5", + "rev": "0726a0ecb6d4e08f6adced58726b95db924cef57", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index ea84758..e651de8 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,8 @@ devShells."${system}" = { default = pkgs.mkShell { packages = with pkgs; [ - jetbrains.jdk-no-jcef # Jetbrains jdk + jdk25_headless + # jetbrains.jdk-no-jcef # Jetbrains jdk (doesn't support java 25 yet) flite # Make mc not complain # Took these from https://github.com/NixOS/nixpkgs/blob/nixos-25.05/pkgs/by-name/pr/prismlauncher/package.nix#L123 diff --git a/gradle.properties b/gradle.properties index ff7372d..8a798f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,28 +4,30 @@ # Project version=1.3.4 group=dev.mrsnowy.teleport_commands -java_version=21 +java_version=25 # Common -minecraft_version=1.21.5 +minecraft_version=26.1 mod_name=Teleport Commands mod_author=Mr. Snowy mod_id=teleport_commands license=MIT credits=Mr. Snowy description=A server-side mod that adds various teleportation related commands. -minecraft_version_range=[1.21.5, 1.22] +minecraft_version_range=[26.1] # see https://projects.neoforged.net/neoforged/neoform for new versions -neo_form_version=1.21.5-20250325.162830 +neo_form_version=26.1-1 # see https://parchmentmc.org/docs/getting-started#choose-a-version for new versions -parchment_minecraft=1.21.5 -parchment_version=2025.04.19 +# TODO Update 26.1 +parchment_minecraft=1.21.11 +# There is no new version for now +parchment_version=2025.12.20 # see https://fabricmc.net/develop/ for new versions -fabric_loader_version=0.16.14 -fabric_loom=1.10-SNAPSHOT +fabric_loader_version=0.18.5 +fabric_loom=1.15-SNAPSHOT # Quilt (Currently disabled since fabric port works better) #quilt_loader_version=0.25.0 @@ -34,10 +36,10 @@ fabric_loom=1.10-SNAPSHOT # NeoForge # see https://projects.neoforged.net/neoforged/neoforge for new versions -neoforge_version=21.5.65-beta +neoforge_version=26.1.0.8-beta neoforge_loader_version_range=[4,) # see https://projects.neoforged.net/neoforged/moddevgradle for new versions -neoforge_moddevgradle=2.0.87 +neoforge_moddevgradle=2.0.141 # Gradle org.gradle.jvmargs=-Xmx6G diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cea7a79..dbc3ce4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/justfile b/justfile index fc07239..60e828b 100644 --- a/justfile +++ b/justfile @@ -1,3 +1,3 @@ ide: - nohup idea-ultimate ./ >/dev/null 2>&1 & + nohup idea ./ >/dev/null 2>&1 & diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 71154f0..1dea13b 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -3,8 +3,18 @@ plugins { id 'net.neoforged.moddev' } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(25) + } +} + neoForge { - version = neoforge_version + enable { + version = neoforge_version + disableRecompilation = true + } + // Automatically enable neoforge AccessTransformers if the file exists def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg') if (at.exists()) { diff --git a/quilt/build.gradle b/quilt/build.gradle index 62ed5ca..45a0def 100644 --- a/quilt/build.gradle +++ b/quilt/build.gradle @@ -5,9 +5,9 @@ plugins { dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" - mappings loom.layered() { - officialMojangMappings() - } +// mappings loom.layered() { +// officialMojangMappings() +// } modImplementation "org.quiltmc:quilt-loader:${quilt_loader_version}" modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${quilt_fabric_api}" } diff --git a/settings.gradle b/settings.gradle index 5df84b2..9ea8f4d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,45 +2,15 @@ pluginManagement { repositories { gradlePluginPortal() mavenCentral() - exclusiveContent { - forRepository { - maven { - name = 'Fabric' - url = uri('https://maven.fabricmc.net') - } - } - filter { - includeGroup('net.fabricmc') - includeGroup('fabric-loom') - } - } - exclusiveContent { - forRepository { - maven { - name = 'Sponge' - url = uri('https://repo.spongepowered.org/repository/maven-public') - } - } - filter { - includeGroupAndSubgroups("org.spongepowered") - } - } - exclusiveContent { - forRepository { - maven { - name = 'Forge' - url = uri('https://maven.minecraftforge.net') - } - } - filter { - includeGroupAndSubgroups('net.minecraftforge') - } - } + maven { url = uri("https://maven.fabricmc.net/") } // Fabric官方仓库直接加,不用exclusiveContent + maven { url = uri("https://repo.spongepowered.org/repository/maven-public") } +// maven { url = uri("https://maven.minecraftforge.net") } + maven { url = 'https://maven.neoforged.net/releases' } } } plugins { - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' + id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0' } // This should match the folder name of the project, or else IDEA may complain (see https://youtrack.jetbrains.com/issue/IDEA-317606) -- 2.51.2