A Minecraft server-side mod that adds various teleportation related commands
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update to Minecraft Version 26.1 (using #30 thanks to Wjiangzhi!)

Co-authored-by: 江芷酱紫 <wanjiangzhi@outlook.com>

+161 -196
+4 -1
.gitattributes
··· 1 1 # 2 2 # https://help.github.com/articles/dealing-with-line-endings/ 3 - # 3 + 4 + * text=auto 5 + 4 6 # Linux start script should use lf 5 7 /gradlew text eol=lf 6 8 7 9 # These are Windows script files and should use crlf 8 10 *.bat text eol=crlf 9 11 12 +
+1 -1
.github/workflows/build.yml
··· 11 11 strategy: 12 12 matrix: 13 13 java: 14 - - 21 # Currently min for minecraft 14 + - 25 # Currently min for minecraft 15 15 runs-on: ubuntu-latest 16 16 steps: 17 17 - name: checkout repository
+2 -2
README.md
··· 64 64 #### Getting the correct environment 65 65 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. 66 66 67 - On any other linux distro, just install the jetbrains jdk, or try openjdk21. 67 + On any other linux distro try openjdk25. 68 68 69 - On windows probably go to the openjdk website and install the 21 version? idk goodluck. 69 + On windows probably go to the openjdk website and install the 25 version? idk goodluck. 70 70 71 71 #### Building 72 72 Then on linux just do `./gradlew build` and to make it in a single mod jar `./gradlew mergeJars`.
+11 -1
common/build.gradle
··· 3 3 id 'net.neoforged.moddev' 4 4 } 5 5 6 + java { 7 + toolchain { 8 + languageVersion = JavaLanguageVersion.of(25) 9 + } 10 + } 11 + 6 12 neoForge { 7 - neoFormVersion = neo_form_version 8 13 // Automatically enable AccessTransformers if the file exists 9 14 def at = file('src/main/resources/META-INF/accesstransformer.cfg') 10 15 if (at.exists()) { 11 16 accessTransformers.from(at.absolutePath) 17 + } 18 + enable { 19 + version = neoforge_version 20 + neoFormVersion = neo_form_version 21 + disableRecompilation = true 12 22 } 13 23 parchment { 14 24 minecraftVersion = parchment_minecraft
+1 -1
common/src/main/java/dev/mrsnowy/teleport_commands/TeleportCommands.java
··· 53 53 // Runs when the playerDeath mixin calls it, updates the /back command position 54 54 public static void onPlayerDeath(ServerPlayer player) { 55 55 BlockPos pos = new BlockPos(player.getBlockX(), player.getBlockY(), player.getBlockZ()); 56 - String world = player.serverLevel().dimension().location().toString(); 56 + String world = player.level().dimension().identifier().toString(); 57 57 String uuid = player.getStringUUID(); 58 58 59 59 DeathLocationStorage.setDeathLocation(uuid, pos, world);
+7 -9
common/src/main/java/dev/mrsnowy/teleport_commands/commands/back.java
··· 27 27 public static void register(CommandDispatcher<CommandSourceStack> commandDispatcher) { 28 28 29 29 commandDispatcher.register(Commands.literal("back") 30 - .requires(source -> source.getPlayer() != null) 31 30 .executes(context -> { 32 31 final ServerPlayer player = context.getSource().getPlayerOrException(); 33 32 ··· 36 35 37 36 } catch (Exception e) { 38 37 Constants.LOGGER.error("Error while going back! => ", e); 39 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 38 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 40 39 return 1; 41 40 } 42 41 return 0; 43 42 }) 44 43 .then(argument("Disable Safety", BoolArgumentType.bool()) 45 - .requires(source -> source.getPlayer() != null) 46 44 .executes(context -> { 47 45 final boolean safety = BoolArgumentType.getBool(context, "Disable Safety"); 48 46 final ServerPlayer player = context.getSource().getPlayerOrException(); ··· 52 50 53 51 } catch (Exception e) { 54 52 Constants.LOGGER.error("Error while going back! => ", e); 55 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 53 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 56 54 return 1; 57 55 } 58 56 return 0; ··· 70 68 .orElse(null); 71 69 72 70 if (deathLocation == null) { 73 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.noLocation", player).withStyle(ChatFormatting.RED), true); 71 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.noLocation", player).withStyle(ChatFormatting.RED), true); 74 72 return; 75 73 } 76 74 ··· 83 81 deathLocation.getWorldString(), 84 82 tools.getWorldIds()); 85 83 86 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) 84 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) 87 85 .withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 88 86 89 87 return; ··· 98 96 // Check if there is a safe BlockPos 99 97 if (safeBlockPos.isEmpty()) { 100 98 // asks the player if they want to teleport anyway 101 - player.displayClientMessage( 99 + player.sendSystemMessage( 102 100 Component.empty() 103 101 .append(getTranslatedText("commands.teleport_commands.common.noSafeLocation", player) 104 102 .withStyle(ChatFormatting.RED, ChatFormatting.BOLD) ··· 125 123 126 124 // check if the player is already at this location (in the same world) 127 125 if (player.blockPosition().equals(teleportBlockPos) && player.level() == deathLocationWorld) { 128 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.same", player).withStyle(ChatFormatting.AQUA), true); 126 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.back.same", player).withStyle(ChatFormatting.AQUA), true); 129 127 130 128 } else { 131 129 // teleport the player! 132 130 Vec3 teleportPos = new Vec3(teleportBlockPos.getX() + 0.5, teleportBlockPos.getY(), teleportBlockPos.getZ() + 0.5); 133 131 134 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.go", player), true); 132 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.back.go", player), true); 135 133 tools.Teleporter(player, deathLocationWorld, teleportPos); 136 134 } 137 135 }
+30 -37
common/src/main/java/dev/mrsnowy/teleport_commands/commands/home.java
··· 33 33 public static void register(CommandDispatcher<CommandSourceStack> commandDispatcher) { 34 34 35 35 commandDispatcher.register(Commands.literal("sethome") 36 - .requires(source -> source.getPlayer() != null) 37 36 .then(argument("name", StringArgumentType.string()) 38 37 .executes(context -> { 39 38 final String name = StringArgumentType.getString(context, "name"); ··· 44 43 45 44 } catch (Exception e) { 46 45 Constants.LOGGER.error("Error while setting a home! => ", e); 47 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 46 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 48 47 return 1; 49 48 } 50 49 return 0; ··· 52 51 53 52 54 53 commandDispatcher.register(Commands.literal("home") 55 - .requires(source -> source.getPlayer() != null) 56 54 .executes(context -> { 57 55 final ServerPlayer player = context.getSource().getPlayerOrException(); 58 56 ··· 61 59 62 60 } catch (Exception e) { 63 61 Constants.LOGGER.error("Error while going home! => ", e); 64 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 62 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 65 63 return 1; 66 64 } 67 65 return 0; 68 66 }) 69 67 .then(argument("name", StringArgumentType.string()) 70 68 .suggests(new HomeSuggestionProvider()) 71 - .requires(source -> source.getPlayer() != null) 72 69 .executes(context -> { 73 70 final String name = StringArgumentType.getString(context, "name"); 74 71 final ServerPlayer player = context.getSource().getPlayerOrException(); ··· 78 75 79 76 } catch (Exception e) { 80 77 Constants.LOGGER.error("Error while going to a specific home! => ", e); 81 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 78 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 82 79 return 1; 83 80 } 84 81 return 0; 85 82 }))); 86 83 87 84 commandDispatcher.register(Commands.literal("delhome") 88 - .requires(source -> source.getPlayer() != null) 89 85 .then(argument("name", StringArgumentType.string()) 90 86 .suggests(new HomeSuggestionProvider()) 91 87 .executes(context -> { ··· 97 93 98 94 } catch (Exception e) { 99 95 Constants.LOGGER.error("Error while deleting a home! => ", e); 100 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.deleteError", player) 96 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.deleteError", player) 101 97 .withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 102 98 return 1; 103 99 } ··· 105 101 }))); 106 102 107 103 commandDispatcher.register(Commands.literal("renamehome") 108 - .requires(source -> source.getPlayer() != null) 109 104 .then(argument("name", StringArgumentType.string()) 110 105 .suggests(new HomeSuggestionProvider()) 111 106 .then(argument("newName", StringArgumentType.string()) ··· 119 114 120 115 } catch (Exception e) { 121 116 Constants.LOGGER.error("Error while renaming a home! => ", e); 122 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.renameError", player) 117 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.renameError", player) 123 118 .withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 124 119 return 1; 125 120 } ··· 128 123 129 124 130 125 commandDispatcher.register(Commands.literal("defaulthome") 131 - .requires(source -> source.getPlayer() != null) 132 126 .then(argument("name", StringArgumentType.string()).suggests(new HomeSuggestionProvider()) 133 127 .executes(context -> { 134 128 final String name = StringArgumentType.getString(context, "name"); ··· 139 133 140 134 } catch (Exception e) { 141 135 Constants.LOGGER.error("Error while setting the default home! => ", e); 142 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.defaultError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 136 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.defaultError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 143 137 return 1; 144 138 } 145 139 return 0; 146 140 }))); 147 141 148 142 commandDispatcher.register(Commands.literal("homes") 149 - .requires(source -> source.getPlayer() != null) 150 143 .executes(context -> { 151 144 final ServerPlayer player = context.getSource().getPlayerOrException(); 152 145 ··· 155 148 156 149 } catch (Exception e) { 157 150 Constants.LOGGER.error("Error while printing the homes! => ", e); 158 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.homes.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 151 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.homes.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 159 152 return 1; 160 153 } 161 154 return 0; ··· 169 162 private static void SetHome(ServerPlayer player, String homeName) throws Exception { 170 163 homeName = homeName.toLowerCase(); 171 164 BlockPos blockPos = player.blockPosition(); 172 - String worldString = player.serverLevel().dimension().location().toString(); 165 + String worldString = player.level().dimension().identifier().toString(); 173 166 174 167 // Gets the player's storage and creates it if it doesn't exist 175 168 Player playerStorage = StorageManager.STORAGE.addPlayer(player.getStringUUID()); ··· 182 175 183 176 if (homeExists) { 184 177 // Display error message that the home already exists 185 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.exists", player).withStyle(ChatFormatting.RED), true); 178 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.exists", player).withStyle(ChatFormatting.RED), true); 186 179 187 180 } else { 188 181 // Set it as the default if there are no other homes ··· 191 184 } 192 185 193 186 // Display message that the home has been set 194 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.set", player), true); 187 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.set", player), true); 195 188 } 196 189 } 197 190 ··· 202 195 // Get player storage 203 196 Optional<Player> optionalPlayerStorage = STORAGE.getPlayer(player.getStringUUID()); 204 197 if (optionalPlayerStorage.isEmpty()) { 205 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 198 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 206 199 return; 207 200 } 208 201 ··· 214 207 215 208 if (defaultHome.isEmpty()) { 216 209 // No default home set! 217 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.defaultNone", player).withStyle(ChatFormatting.AQUA), true); 210 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.defaultNone", player).withStyle(ChatFormatting.AQUA), true); 218 211 219 212 return; 220 213 } else { ··· 225 218 // Get the home (if it exists) 226 219 Optional<NamedLocation> optionalHome = playerStorage.getHome(homeName); 227 220 if (optionalHome.isEmpty()) { 228 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.AQUA), true); 221 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.AQUA), true); 229 222 return; 230 223 } 231 224 ··· 241 234 home.getWorldString(), 242 235 tools.getWorldIds()); 243 236 244 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) 237 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) 245 238 .withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 246 239 247 240 return; ··· 253 246 254 247 // Check if the player is already at this location (in the same world) 255 248 if (player.blockPosition().equals(teleportBlockPos) && player.level() == homeWorld) { 256 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.goSame", player).withStyle(ChatFormatting.AQUA), true); 249 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.goSame", player).withStyle(ChatFormatting.AQUA), true); 257 250 258 251 } else { 259 252 // Teleport the player! 260 253 Vec3 teleportPos = new Vec3(teleportBlockPos.getX() + 0.5, teleportBlockPos.getY(), teleportBlockPos.getZ() + 0.5); 261 254 262 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.go", player), true); 255 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.go", player), true); 263 256 Teleporter(player, homeWorld, teleportPos); 264 257 } 265 258 } ··· 270 263 // Gets player storage 271 264 Optional<Player> optionalPlayerStorage = STORAGE.getPlayer(player.getStringUUID()); 272 265 if (optionalPlayerStorage.isEmpty()) { 273 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 266 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 274 267 return; 275 268 } 276 269 ··· 279 272 // Get the home from the player 280 273 Optional<NamedLocation> optionalHome = playerStorage.getHome(homeName); 281 274 if (optionalHome.isEmpty()) { 282 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); 275 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); 283 276 return; 284 277 } 285 278 ··· 293 286 // todo! maybe ask the player if they want to set a new default home? :3 294 287 } 295 288 296 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.delete", player), true); 289 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.delete", player), true); 297 290 } 298 291 299 292 private static void RenameHome(ServerPlayer player, String homeName, String newHomeName) throws Exception { ··· 303 296 // Gets player storage 304 297 Optional<Player> optionalPlayerStorage = STORAGE.getPlayer(player.getStringUUID()); 305 298 if (optionalPlayerStorage.isEmpty()) { 306 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 299 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 307 300 return; 308 301 } 309 302 ··· 311 304 312 305 // Check if there already is a home with the new name 313 306 if (playerStorage.getHome(newHomeName).isPresent()) { 314 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.nameExists", player).withStyle(ChatFormatting.RED), true); 307 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.nameExists", player).withStyle(ChatFormatting.RED), true); 315 308 return; 316 309 } 317 310 318 311 // Get the home that needs to be renamed 319 312 Optional<NamedLocation> optionalHome = playerStorage.getHome(homeName); 320 313 if (optionalHome.isEmpty()) { 321 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); 314 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); 322 315 return; 323 316 } 324 317 ··· 330 323 playerStorage.setDefaultHome(newHomeName); 331 324 } 332 325 333 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.rename", player), true); 326 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.rename", player), true); 334 327 } 335 328 336 329 private static void SetDefaultHome(ServerPlayer player, String homeName) throws Exception { ··· 339 332 // Gets player storage 340 333 Optional<Player> optionalPlayerStorage = STORAGE.getPlayer(player.getStringUUID()); 341 334 if (optionalPlayerStorage.isEmpty()) { 342 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 335 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 343 336 return; 344 337 } 345 338 ··· 347 340 348 341 // Check if the new default home exists 349 342 if ( playerStorage.getHome(homeName).isEmpty() ) { 350 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); 343 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); 351 344 return; 352 345 } 353 346 354 347 // Check if the home is already the default 355 348 if (playerStorage.getDefaultHome().equals(homeName)) { 356 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.defaultSame", player).withStyle(ChatFormatting.AQUA), true); 349 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.defaultSame", player).withStyle(ChatFormatting.AQUA), true); 357 350 return; 358 351 } 359 352 360 353 // set the new default 361 354 playerStorage.setDefaultHome(homeName); 362 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.default", player), true); 355 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.default", player), true); 363 356 } 364 357 365 358 private static void PrintHomes(ServerPlayer player) throws Exception { 366 359 // Gets player storage, if no storage then the player is homeless! 367 360 Optional<Player> optionalPlayerStorage = STORAGE.getPlayer(player.getStringUUID()); 368 361 if (optionalPlayerStorage.isEmpty()) { 369 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 362 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 370 363 return; 371 364 } 372 365 ··· 376 369 377 370 // Check if there are any homes lol 378 371 if (homes.isEmpty()) { 379 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 372 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.homeless", player).withStyle(ChatFormatting.AQUA), true); 380 373 return; 381 374 } 382 375 ··· 513 506 } 514 507 515 508 // send the message 516 - player.displayClientMessage(message, false); 509 + player.sendSystemMessage(message, false); 517 510 } 518 511 }
+6 -8
common/src/main/java/dev/mrsnowy/teleport_commands/commands/main.java
··· 26 26 // 27 27 // commandManager.getDispatcher().register(Commands.literal("teleportcommands") 28 28 // .then(Commands.literal("help") 29 - // .requires(source -> source.getPlayer() != null) 30 29 // .executes(context -> { 31 30 // final ServerPlayer player = context.getSource().getPlayerOrException(); 32 31 // ··· 35 34 // 36 35 // } catch (Exception e) { 37 36 // TeleportCommands.LOGGER.error("Error while going back! => ", e); 38 - // player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 37 + // player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 39 38 // return 1; 40 39 // } 41 40 // return 0; 42 41 // })) 43 42 // .then(argument("Disable Safety", BoolArgumentType.bool()) 44 - // .requires(source -> source.getPlayer() != null) 45 43 // .executes(context -> { 46 44 // final boolean safety = BoolArgumentType.getBool(context, "Disable Safety"); 47 45 // final ServerPlayer player = context.getSource().getPlayerOrException(); ··· 51 49 // 52 50 // } catch (Exception e) { 53 51 // TeleportCommands.LOGGER.error("Error while going back! => ", e); 54 - // player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 52 + // player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 55 53 // return 1; 56 54 // } 57 55 // return 0; ··· 66 64 // // Gets the DeathLocation of the player and teleports the player to it 67 65 // private static void printCommands(ServerPlayer player) throws Exception { 68 66 // 69 - // player.displayClientMessage(Component.literal("Thank you for using Teleport Commands (V)!").withStyle(ChatFormatting.AQUA), false); 70 - // player.displayClientMessage(Component.literal("Teleport Commands is a server-side mod that adds various teleportation related commands").withStyle(ChatFormatting.AQUA), false); 67 + // player.sendSystemMessage(Component.literal("Thank you for using Teleport Commands (V)!").withStyle(ChatFormatting.AQUA), false); 68 + // player.sendSystemMessage(Component.literal("Teleport Commands is a server-side mod that adds various teleportation related commands").withStyle(ChatFormatting.AQUA), false); 71 69 // 72 - // player.displayClientMessage(Component.literal("----").withStyle(ChatFormatting.AQUA), false); 70 + // player.sendSystemMessage(Component.literal("----").withStyle(ChatFormatting.AQUA), false); 73 71 // 74 - // player.displayClientMessage(Component.literal("Usage:").withStyle(ChatFormatting.AQUA), false); 72 + // player.sendSystemMessage(Component.literal("Usage:").withStyle(ChatFormatting.AQUA), false); 75 73 // } 76 74 //}
+18 -22
common/src/main/java/dev/mrsnowy/teleport_commands/commands/tpa.java
··· 38 38 public static void register(CommandDispatcher<CommandSourceStack> commandDispatcher) { 39 39 40 40 commandDispatcher.register(Commands.literal("tpa") 41 - .requires(source -> source.getPlayer() != null) 42 41 .then(Commands.argument("player", EntityArgument.player()) 43 42 .executes(context -> { 44 43 final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); ··· 57 56 }))); 58 57 59 58 commandDispatcher.register(Commands.literal("tpahere") 60 - .requires(source -> source.getPlayer() != null) 61 59 .then(Commands.argument("player", EntityArgument.player()) 62 60 .executes(context -> { 63 61 final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); ··· 74 72 }))); 75 73 76 74 commandDispatcher.register(Commands.literal("tpaaccept") 77 - .requires(source -> source.getPlayer() != null) 78 75 .then(Commands.argument("player", EntityArgument.player()).suggests(new tpaSuggestionProvider()) 79 76 .executes(context -> { 80 77 final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); ··· 92 89 }))); 93 90 94 91 commandDispatcher.register(Commands.literal("tpadeny") 95 - .requires(source -> source.getPlayer() != null) 96 92 .then(Commands.argument("player", EntityArgument.player()).suggests(new tpaSuggestionProvider()) 97 93 .executes(context -> { 98 94 final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); ··· 103 99 104 100 } catch (Exception e) { 105 101 Constants.LOGGER.error("Error while denying a tpa(here) request! => ", e); 106 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 102 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.home.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 107 103 return 1; 108 104 } 109 105 ··· 119 115 .count(); 120 116 121 117 if (FromPlayer == ToPlayer) { 122 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA), true); 118 + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA), true); 123 119 124 120 } else if (playerTpaList >= 1) { 125 - 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) 121 + 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) 126 122 , true 127 123 ); 128 124 ··· 135 131 String ReceivedFromPlayer = Objects.requireNonNull(FromPlayer.getName().getString(), "FromPlayer name cannot be null"); 136 132 String SentToPlayer = Objects.requireNonNull(ToPlayer.getName().getString(), "ToPlayer name cannot be null"); 137 133 138 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.sent", FromPlayer, Component.literal(hereText), Component.literal(SentToPlayer).withStyle(ChatFormatting.BOLD)) 134 + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.sent", FromPlayer, Component.literal(hereText), Component.literal(SentToPlayer).withStyle(ChatFormatting.BOLD)) 139 135 // .append(Text.literal("\n[Cancel]").formatted(Formatting.BLUE, Formatting.BOLD)) 140 136 ,true 141 137 ); 142 138 143 - ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.received", ToPlayer, Component.literal(hereText), Component.literal(ReceivedFromPlayer).withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA) 139 + ToPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.received", ToPlayer, Component.literal(hereText), Component.literal(ReceivedFromPlayer).withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA) 144 140 .append("\n") 145 141 .append(getTranslatedText("commands.teleport_commands.tpa.accept", ToPlayer) 146 142 .withStyle(ChatFormatting.GREEN, ChatFormatting.BOLD) ··· 173 169 public void run() { 174 170 boolean successful = tpaList.remove(tpaRequest); 175 171 if (successful) { 176 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.expired", FromPlayer, Component.literal(hereText)).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); 177 - ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.expired", ToPlayer, Component.literal(hereText)).withStyle(ChatFormatting.WHITE),true); 172 + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.expired", FromPlayer, Component.literal(hereText)).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); 173 + ToPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.expired", ToPlayer, Component.literal(hereText)).withStyle(ChatFormatting.WHITE),true); 178 174 } 179 175 // else not needed since it may be denied/cancelled 180 176 } ··· 185 181 186 182 private static void tpaAccept(ServerPlayer FromPlayer, ServerPlayer ToPlayer) { 187 183 if (FromPlayer == ToPlayer) { 188 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA), true); 184 + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA), true); 189 185 return; 190 186 } 191 187 ··· 200 196 ServerPlayer destinationPlayer = tpaStorage.get().here ? ToPlayer : FromPlayer; 201 197 ServerPlayer toSentPlayer = tpaStorage.get().here ? FromPlayer : ToPlayer; 202 198 203 - Optional<BlockPos> teleportData = getSafeBlockPos(destinationPlayer.blockPosition(), destinationPlayer.serverLevel()); 199 + Optional<BlockPos> teleportData = getSafeBlockPos(destinationPlayer.blockPosition(), destinationPlayer.level()); 204 200 205 201 if (teleportData.isPresent()) { 206 202 BlockPos safeBlockPos = teleportData.get(); 207 203 Vec3 teleportPos = new Vec3(safeBlockPos.getX() + 0.5, safeBlockPos.getY(), safeBlockPos.getZ() + 0.5); 208 204 209 - Teleporter(toSentPlayer, destinationPlayer.serverLevel(), teleportPos); 205 + Teleporter(toSentPlayer, destinationPlayer.level(), teleportPos); 210 206 } else { 211 207 // if no safe location then just teleport to the player 212 - Teleporter(toSentPlayer, destinationPlayer.serverLevel(), destinationPlayer.position()); 208 + Teleporter(toSentPlayer, destinationPlayer.level(), destinationPlayer.position()); 213 209 } 214 210 215 211 // if the player teleported then these messages get sent && the request gets removed 216 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", FromPlayer).withStyle(ChatFormatting.WHITE),true); 217 - ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", ToPlayer).withStyle(ChatFormatting.GREEN),true); 212 + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", FromPlayer).withStyle(ChatFormatting.WHITE),true); 213 + ToPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", ToPlayer).withStyle(ChatFormatting.GREEN),true); 218 214 tpaList.remove(tpaStorage.get()); 219 215 220 216 } else { 221 217 // No request found 222 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.notFound", FromPlayer).withStyle(ChatFormatting.RED),true); 218 + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.notFound", FromPlayer).withStyle(ChatFormatting.RED),true); 223 219 } 224 220 } 225 221 226 222 private static void tpaDeny(ServerPlayer FromPlayer, ServerPlayer ToPlayer) { 227 223 if (FromPlayer == ToPlayer) { 228 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA),true); 224 + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA),true); 229 225 230 226 } else { 231 227 Optional<tpaArrayClass> tpaStorage = tpaList.stream() ··· 236 232 if (tpaStorage.isPresent()) { 237 233 tpaList.remove(tpaStorage.get()); 238 234 239 - ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.denied", ToPlayer).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); 240 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.denied", FromPlayer).withStyle(ChatFormatting.WHITE),true); 235 + ToPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.denied", ToPlayer).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); 236 + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.denied", FromPlayer).withStyle(ChatFormatting.WHITE),true); 241 237 242 238 } else { 243 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.notFound", FromPlayer).withStyle(ChatFormatting.RED),true); 239 + FromPlayer.sendSystemMessage(getTranslatedText("commands.teleport_commands.tpa.notFound", FromPlayer).withStyle(ChatFormatting.RED),true); 244 240 } 245 241 } 246 242 }
+27 -36
common/src/main/java/dev/mrsnowy/teleport_commands/commands/warp.java
··· 16 16 import net.minecraft.network.chat.MutableComponent; 17 17 import net.minecraft.server.level.ServerLevel; 18 18 import net.minecraft.server.level.ServerPlayer; 19 + import net.minecraft.server.permissions.Permission; 20 + import net.minecraft.server.permissions.PermissionLevel; 19 21 import net.minecraft.world.phys.Vec3; 20 22 21 23 import java.util.List; ··· 30 32 public static void register(CommandDispatcher<CommandSourceStack> commandDispatcher) { 31 33 32 34 commandDispatcher.register(Commands.literal("setwarp") 33 - .requires(source -> 34 - source.getPlayer() != null && 35 - source.hasPermission(4) 36 - ) 35 + .requires(source -> source.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.OWNERS))) 37 36 .then(argument("name", StringArgumentType.string()) 38 37 .executes(context -> { 39 38 final String name = StringArgumentType.getString(context, "name"); ··· 44 43 45 44 } catch (Exception e) { 46 45 Constants.LOGGER.error("Error while setting the warp!", e); 47 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 46 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.setError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 48 47 return 1; 49 48 } 50 49 return 0; 51 50 }))); 52 51 53 52 commandDispatcher.register(Commands.literal("warp") 54 - .requires(source -> source.getPlayer() != null) 55 53 .then(argument("name", StringArgumentType.string()) 56 54 .suggests(new WarpSuggestionProvider()) 57 55 .executes(context -> { ··· 63 61 64 62 } catch (Exception e) { 65 63 Constants.LOGGER.error("Error while going to the warp!",e); 66 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 64 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.goError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 67 65 return 1; 68 66 } 69 67 return 0; 70 68 }))); 71 69 72 70 commandDispatcher.register(Commands.literal("delwarp") 73 - .requires(source -> 74 - source.getPlayer() != null && 75 - source.hasPermission(4) 76 - ) 71 + .requires(source -> source.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.OWNERS))) 77 72 .then(argument("name", StringArgumentType.string()).suggests(new WarpSuggestionProvider()) 78 73 .executes(context -> { 79 74 final String name = StringArgumentType.getString(context, "name"); ··· 84 79 85 80 } catch (Exception e) { 86 81 Constants.LOGGER.error("Error while deleting to the warp!", e); 87 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.deleteError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 82 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.deleteError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 88 83 return 1; 89 84 } 90 85 return 0; 91 86 }))); 92 87 93 88 commandDispatcher.register(Commands.literal("renamewarp") 94 - .requires(source -> 95 - source.getPlayer() != null && 96 - source.hasPermission(4) 97 - ) 89 + .requires(source -> source.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.OWNERS))) 98 90 .then(argument("name", StringArgumentType.string()).suggests(new WarpSuggestionProvider()) 99 91 .then(argument("newName", StringArgumentType.string()) 100 92 .executes(context -> { ··· 107 99 108 100 } catch (Exception e) { 109 101 Constants.LOGGER.error("Error while renaming the warp!", e); 110 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.renameError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 102 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.renameError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 111 103 return 1; 112 104 } 113 105 return 0; 114 106 })))); 115 107 116 108 commandDispatcher.register(Commands.literal("warps") 117 - .requires(source -> source.getPlayer() != null) 118 109 .executes(context -> { 119 110 final ServerPlayer player = context.getSource().getPlayerOrException(); 120 111 ··· 123 114 124 115 } catch (Exception e) { 125 116 Constants.LOGGER.error("Error while printing warps!", e); 126 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warps.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 117 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warps.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 127 118 return 1; 128 119 } 129 120 return 0; ··· 136 127 warpName = warpName.toLowerCase(); 137 128 138 129 BlockPos blockPos = new BlockPos(player.getBlockX(), player.getBlockY(), player.getBlockZ()); 139 - String worldString = player.serverLevel().dimension().location().toString(); 130 + String worldString = player.level().dimension().identifier().toString(); 140 131 141 132 // Create the NamedLocation 142 133 NamedLocation warp = new NamedLocation(warpName, blockPos, worldString); ··· 146 137 147 138 if (warpExists) { 148 139 // Display error message that the warp already exists 149 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.exists", player).withStyle(ChatFormatting.RED), true); 140 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.exists", player).withStyle(ChatFormatting.RED), true); 150 141 151 142 } else { 152 143 // Display message that the home as been set 153 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.set", player), true); 144 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.set", player), true); 154 145 } 155 146 } 156 147 157 - private static void GoToWarp(ServerPlayer player, String warpName) throws Exception { 148 + private static void GoToWarp(ServerPlayer player, String warpName) { 158 149 warpName = warpName.toLowerCase(); 159 150 160 151 // Gets warp 161 152 Optional<NamedLocation> optionalWarp = STORAGE.getWarp(warpName); 162 153 if (optionalWarp.isEmpty()) { 163 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); 154 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); 164 155 return; 165 156 } 166 157 ··· 176 167 warp.getWorldString(), 177 168 tools.getWorldIds()); 178 169 179 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) 170 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.worldNotFound", player) 180 171 .withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 181 172 182 173 return; ··· 188 179 189 180 // Check if the player is already at this location (in the same world) 190 181 if (player.blockPosition().equals(teleportBlockPos) && player.level() == warpWorld) { 191 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.goSame", player).withStyle(ChatFormatting.AQUA), true); 182 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.goSame", player).withStyle(ChatFormatting.AQUA), true); 192 183 193 184 } else { 194 185 // Teleport the player! 195 186 Vec3 teleportPos = new Vec3(teleportBlockPos.getX() + 0.5, teleportBlockPos.getY(), teleportBlockPos.getZ() + 0.5); 196 187 197 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.go", player), true); 188 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.go", player), true); 198 189 Teleporter(player, warpWorld, teleportPos); 199 190 } 200 191 } ··· 209 200 // Delete the warp 210 201 STORAGE.removeWarp(optionalWarp.get()); 211 202 212 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.delete", player), true); 203 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.delete", player), true); 213 204 214 205 } else { 215 206 // the warp is not found 216 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); 207 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); 217 208 } 218 209 } 219 210 ··· 223 214 224 215 // check if there is no existing warp with the new name 225 216 if (STORAGE.getWarp(newWarpName).isPresent()) { 226 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.nameExists", player).withStyle(ChatFormatting.RED), true); 217 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.nameExists", player).withStyle(ChatFormatting.RED), true); 227 218 return; 228 219 } 229 220 ··· 234 225 235 226 // set the new name 236 227 warpToRename.get().setName(newWarpName); 237 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.rename", player), true); 228 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.rename", player), true); 238 229 239 230 } else { 240 231 // the warp is not found 241 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); 232 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.notFound", player).withStyle(ChatFormatting.RED), true); 242 233 } 243 234 } 244 235 245 - private static void PrintWarps(ServerPlayer player) throws Exception { 236 + private static void PrintWarps(ServerPlayer player) { 246 237 // Get warps 247 238 List<NamedLocation> warps = STORAGE.getWarps(); 248 239 249 240 // Check if there are any warps lol 250 241 if (warps.isEmpty()) { 251 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.warp.homeless", player).withStyle(ChatFormatting.AQUA), true); 242 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.warp.homeless", player).withStyle(ChatFormatting.AQUA), true); 252 243 return; 253 244 } 254 245 ··· 265 256 String coords = String.format("[X%d Y%d Z%d]", currentWarp.getX(), currentWarp.getY(), currentWarp.getZ()); 266 257 String dimension = String.format(" [%s]", currentWarp.getWorldString()); 267 258 268 - boolean canModify = player.hasPermissions(4); 259 + boolean canModify = player.permissions().hasPermission(new Permission.HasCommandLevel(PermissionLevel.OWNERS)); 269 260 270 261 // linebreak 271 262 message.append("\n"); ··· 364 355 } 365 356 366 357 // send the message 367 - player.displayClientMessage(message, false); 358 + player.sendSystemMessage(message, false); 368 359 } 369 360 }
+8 -10
common/src/main/java/dev/mrsnowy/teleport_commands/commands/worldspawn.java
··· 26 26 27 27 public static void register(CommandDispatcher<CommandSourceStack> commandDispatcher) { 28 28 commandDispatcher.register(Commands.literal("worldspawn") 29 - .requires(source -> source.getPlayer() != null) 30 29 .executes(context -> { 31 30 final ServerPlayer player = context.getSource().getPlayerOrException(); 32 31 ··· 35 34 36 35 } catch (Exception error) { 37 36 Constants.LOGGER.error("Error while going to the worldspawn! => ", error); 38 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 37 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 39 38 return 1; 40 39 } 41 40 return 0; 42 41 }) 43 42 .then(argument("Disable Safety", BoolArgumentType.bool()) 44 - .requires(source -> source.getPlayer() != null) 45 43 .executes(context -> { 46 44 final boolean safety = BoolArgumentType.getBool(context, "Disable Safety"); 47 45 final ServerPlayer player = context.getSource().getPlayerOrException(); ··· 51 49 52 50 } catch (Exception error) { 53 51 Constants.LOGGER.error("Error while going to the worldspawn! => ", error); 54 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 52 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 55 53 return 1; 56 54 } 57 55 return 0; ··· 63 61 private static void toWorldSpawn(ServerPlayer player, boolean safetyDisabled) throws NullPointerException { 64 62 // todo! make the dimension customizable 65 63 ServerLevel world = TeleportCommands.SERVER.getLevel(OVERWORLD); 66 - BlockPos worldSpawn = Objects.requireNonNull(world,"Overworld cannot be null!").getSharedSpawnPos(); 64 + BlockPos worldSpawn = Objects.requireNonNull(world,"Overworld cannot be null!").getLevelData().getRespawnData().pos(); 67 65 68 66 if (!safetyDisabled) { 69 67 Optional<BlockPos> teleportData = getSafeBlockPos(worldSpawn, world); ··· 74 72 // check if the player is already at this location 75 73 if (player.blockPosition().equals(safeBlockPos) && player.level() == world) { 76 74 77 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.same", player).withStyle(ChatFormatting.AQUA), true); 75 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.worldspawn.same", player).withStyle(ChatFormatting.AQUA), true); 78 76 } else { 79 77 Vec3 teleportPos = new Vec3(safeBlockPos.getX() + 0.5, safeBlockPos.getY(), safeBlockPos.getZ() + 0.5); 80 78 81 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.go", player), true); 79 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.worldspawn.go", player), true); 82 80 Teleporter(player, world, teleportPos); 83 81 } 84 82 85 83 } else { 86 84 87 - player.displayClientMessage( 85 + player.sendSystemMessage( 88 86 Component.empty() 89 87 .append(getTranslatedText("commands.teleport_commands.common.noSafeLocation", player) 90 88 .withStyle(ChatFormatting.RED, ChatFormatting.BOLD) ··· 108 106 109 107 if (player.blockPosition().equals(worldSpawn) && player.level() == world) { 110 108 111 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.same", player).withStyle(ChatFormatting.AQUA), true); 109 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.worldspawn.same", player).withStyle(ChatFormatting.AQUA), true); 112 110 } else { 113 111 114 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.worldspawn.go", player), true); 112 + player.sendSystemMessage(getTranslatedText("commands.teleport_commands.worldspawn.go", player), true); 115 113 Teleporter(player, world, new Vec3(worldSpawn.getX() + 0.5, worldSpawn.getY(), worldSpawn.getZ() + 0.5)); 116 114 } 117 115 }
+1 -1
common/src/main/java/dev/mrsnowy/teleport_commands/common/DeathLocation.java
··· 32 32 // function to quickly filter the worlds and get the ServerLevel for the string 33 33 public Optional<ServerLevel> getWorld() { 34 34 return StreamSupport.stream( TeleportCommands.SERVER.getAllLevels().spliterator(), false ) // woa, this looks silly 35 - .filter(level -> Objects.equals( level.dimension().location().toString(), this.world )) 35 + .filter(level -> Objects.equals( level.dimension().identifier().toString(), this.world )) 36 36 .findFirst(); 37 37 } 38 38
+1 -1
common/src/main/java/dev/mrsnowy/teleport_commands/common/NamedLocation.java
··· 54 54 // function to quickly filter the worlds and get the ServerLevel for the string 55 55 public Optional<ServerLevel> getWorld() { 56 56 return StreamSupport.stream( TeleportCommands.SERVER.getAllLevels().spliterator(), false ) // woa, this looks silly 57 - .filter(level -> Objects.equals( level.dimension().location().toString(), this.world )) 57 + .filter(level -> Objects.equals( level.dimension().identifier().toString(), this.world )) 58 58 .findFirst(); 59 59 } 60 60
+2 -2
common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java
··· 124 124 // Constants.LOGGER.info("{} : {} : {}", pack.packId(), pack.location(), pack.getClass()); 125 125 // }); 126 126 127 - // player.displayClientMessage(Component.literal(.toString()), false); 127 + // player.sendSystemMessage(Component.literal(.toString()), false); 128 128 129 129 // the try catch stuff is so wacky, but it works fine and I don't need to check everything 130 130 try { ··· 195 195 // Gets the ids of all the worlds 196 196 public static List<String> getWorldIds() { 197 197 return StreamSupport.stream(TeleportCommands.SERVER.getAllLevels().spliterator(), false) 198 - .map(level -> level.dimension().location().toString()) 198 + .map(level -> level.dimension().identifier().toString()) 199 199 .toList(); 200 200 } 201 201
+4 -9
fabric/build.gradle
··· 1 1 plugins { 2 2 id 'multiloader-loader' 3 + id "net.fabricmc.fabric-loom" 3 4 id 'fabric-loom' 4 5 } 5 6 6 7 dependencies { 7 8 minecraft "com.mojang:minecraft:${minecraft_version}" 8 - mappings loom.layered() { 9 - officialMojangMappings() 10 - parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip") 11 - } 12 - modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" 9 + implementation "net.fabricmc:fabric-loader:${fabric_loader_version}" 13 10 // modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api}" 14 11 } 15 12 ··· 18 15 if (aw.exists()) { 19 16 accessWidenerPath.set(aw) 20 17 } 21 - mixin { 22 - defaultRefmapName.set("${mod_id}.refmap.json") 23 - } 24 18 runs { 25 19 client { 26 20 client() ··· 37 31 } 38 32 } 39 33 34 + /* Update to 26.1 no needed 40 35 // Fix for fabric - makes it so it uses the archive name I specify 41 36 tasks.named("remapJar") { 42 37 archiveFileName.set("${mod_id}-${project.name}-${minecraft_version}-v${version}.jar") 43 - } 38 + }*/
+3 -3
flake.lock
··· 2 2 "nodes": { 3 3 "nixpkgs": { 4 4 "locked": { 5 - "lastModified": 1756125398, 6 - "narHash": "sha256-XexyKZpf46cMiO5Vbj+dWSAXOnr285GHsMch8FBoHbc=", 5 + "lastModified": 1776877367, 6 + "narHash": "sha256-EHq1/OX139R1RvBzOJ0aMRT3xnWyqtHBRUBuO1gFzjI=", 7 7 "owner": "nixos", 8 8 "repo": "nixpkgs", 9 - "rev": "3b9f00d7a7bf68acd4c4abb9d43695afb04e03a5", 9 + "rev": "0726a0ecb6d4e08f6adced58726b95db924cef57", 10 10 "type": "github" 11 11 }, 12 12 "original": {
+2 -1
flake.nix
··· 21 21 devShells."${system}" = { 22 22 default = pkgs.mkShell { 23 23 packages = with pkgs; [ 24 - jetbrains.jdk-no-jcef # Jetbrains jdk 24 + jdk25_headless 25 + # jetbrains.jdk-no-jcef # Jetbrains jdk (doesn't support java 25 yet) 25 26 flite # Make mc not complain 26 27 27 28 # Took these from https://github.com/NixOS/nixpkgs/blob/nixos-25.05/pkgs/by-name/pr/prismlauncher/package.nix#L123
+12 -10
gradle.properties
··· 4 4 # Project 5 5 version=1.3.4 6 6 group=dev.mrsnowy.teleport_commands 7 - java_version=21 7 + java_version=25 8 8 9 9 # Common 10 - minecraft_version=1.21.5 10 + minecraft_version=26.1 11 11 mod_name=Teleport Commands 12 12 mod_author=Mr. Snowy 13 13 mod_id=teleport_commands 14 14 license=MIT 15 15 credits=Mr. Snowy 16 16 description=A server-side mod that adds various teleportation related commands. 17 - minecraft_version_range=[1.21.5, 1.22] 17 + minecraft_version_range=[26.1] 18 18 19 19 # see https://projects.neoforged.net/neoforged/neoform for new versions 20 - neo_form_version=1.21.5-20250325.162830 20 + neo_form_version=26.1-1 21 21 22 22 # see https://parchmentmc.org/docs/getting-started#choose-a-version for new versions 23 - parchment_minecraft=1.21.5 24 - parchment_version=2025.04.19 23 + # TODO Update 26.1 24 + parchment_minecraft=1.21.11 25 + # There is no new version for now 26 + parchment_version=2025.12.20 25 27 26 28 # see https://fabricmc.net/develop/ for new versions 27 - fabric_loader_version=0.16.14 28 - fabric_loom=1.10-SNAPSHOT 29 + fabric_loader_version=0.18.5 30 + fabric_loom=1.15-SNAPSHOT 29 31 30 32 # Quilt (Currently disabled since fabric port works better) 31 33 #quilt_loader_version=0.25.0 ··· 34 36 35 37 # NeoForge 36 38 # see https://projects.neoforged.net/neoforged/neoforge for new versions 37 - neoforge_version=21.5.65-beta 39 + neoforge_version=26.1.0.8-beta 38 40 neoforge_loader_version_range=[4,) 39 41 # see https://projects.neoforged.net/neoforged/moddevgradle for new versions 40 - neoforge_moddevgradle=2.0.87 42 + neoforge_moddevgradle=2.0.141 41 43 42 44 # Gradle 43 45 org.gradle.jvmargs=-Xmx6G
+1 -1
gradle/wrapper/gradle-wrapper.properties
··· 1 1 distributionBase=GRADLE_USER_HOME 2 2 distributionPath=wrapper/dists 3 - distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip 3 + distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip 4 4 networkTimeout=10000 5 5 validateDistributionUrl=true 6 6 zipStoreBase=GRADLE_USER_HOME
+1 -1
justfile
··· 1 1 2 2 ide: 3 - nohup idea-ultimate ./ >/dev/null 2>&1 & 3 + nohup idea ./ >/dev/null 2>&1 &
+11 -1
neoforge/build.gradle
··· 3 3 id 'net.neoforged.moddev' 4 4 } 5 5 6 + java { 7 + toolchain { 8 + languageVersion = JavaLanguageVersion.of(25) 9 + } 10 + } 11 + 6 12 neoForge { 7 - version = neoforge_version 13 + enable { 14 + version = neoforge_version 15 + disableRecompilation = true 16 + } 17 + 8 18 // Automatically enable neoforge AccessTransformers if the file exists 9 19 def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg') 10 20 if (at.exists()) {
+3 -3
quilt/build.gradle
··· 5 5 6 6 dependencies { 7 7 minecraft "com.mojang:minecraft:${minecraft_version}" 8 - mappings loom.layered() { 9 - officialMojangMappings() 10 - } 8 + // mappings loom.layered() { 9 + // officialMojangMappings() 10 + // } 11 11 modImplementation "org.quiltmc:quilt-loader:${quilt_loader_version}" 12 12 modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${quilt_fabric_api}" 13 13 }
+5 -35
settings.gradle
··· 2 2 repositories { 3 3 gradlePluginPortal() 4 4 mavenCentral() 5 - exclusiveContent { 6 - forRepository { 7 - maven { 8 - name = 'Fabric' 9 - url = uri('https://maven.fabricmc.net') 10 - } 11 - } 12 - filter { 13 - includeGroup('net.fabricmc') 14 - includeGroup('fabric-loom') 15 - } 16 - } 17 - exclusiveContent { 18 - forRepository { 19 - maven { 20 - name = 'Sponge' 21 - url = uri('https://repo.spongepowered.org/repository/maven-public') 22 - } 23 - } 24 - filter { 25 - includeGroupAndSubgroups("org.spongepowered") 26 - } 27 - } 28 - exclusiveContent { 29 - forRepository { 30 - maven { 31 - name = 'Forge' 32 - url = uri('https://maven.minecraftforge.net') 33 - } 34 - } 35 - filter { 36 - includeGroupAndSubgroups('net.minecraftforge') 37 - } 38 - } 5 + maven { url = uri("https://maven.fabricmc.net/") } // Fabric官方仓库直接加,不用exclusiveContent 6 + maven { url = uri("https://repo.spongepowered.org/repository/maven-public") } 7 + // maven { url = uri("https://maven.minecraftforge.net") } 8 + maven { url = 'https://maven.neoforged.net/releases' } 39 9 } 40 10 } 41 11 42 12 plugins { 43 - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' 13 + id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0' 44 14 } 45 15 46 16 // This should match the folder name of the project, or else IDEA may complain (see https://youtrack.jetbrains.com/issue/IDEA-317606)