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.

[1.21.5] V1.3.3

Fix bug #21

MrSnowy c55096d6 f4832476

+202 -40
+1
.envrc
··· 1 + use flake
+2
.gitignore
··· 23 23 replay_*.log 24 24 *.hprof 25 25 *.jfr 26 + 27 + .direnv
+5
CHANGELOG.md
··· 4 4 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), 5 5 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 6 7 + ### [1.3.3] 8 + - Fixed commands not registering when running `/reload`. 9 + - Cleaned up commands code a bit. 10 + - Finally added a nix development flake. 11 + 7 12 ### [1.3.2] 8 13 - Added Traditional Chinese (Hong Kong) translations. (Thanks to [Dicecan](https://github.com/Dicecan) 9 14 - Updated Traditional Chinese (Taiwan) and Simplified Chinese translations. (Thanks to [Dicecan](https://github.com/Dicecan))
+18 -7
README.md
··· 33 33 <br> 34 34 35 35 ### TODO: 36 - 37 36 #### Planned commands: 38 37 - [ ] `/wild` - Teleports you to a random location in the Overworld 39 38 - [x] `/worldspawn` - Teleports you to the worldspawn ··· 57 56 - [x] Add Quilt support and NeoForge 58 57 59 58 60 - #### Want to help? 61 - 59 + ### Want to help? 62 60 1. You can create a translation file so other people can use the mod in their native language: [translations.md](./common/src/main/resources/assets/teleport_commands/lang/translations.md) 63 61 64 62 65 - #### How to build 66 - w.i.p. 67 - just use correto21 and an intellij idea, then just run the build option that should appear. That's what I do :3 63 + ### How to build 64 + #### Getting the correct environment 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 + 67 + On any other linux distro, just install the jetbrains jdk, or try openjdk21. 68 + 69 + On windows probably go to the openjdk website and install the 21 version? idk goodluck. 70 + 71 + #### Building 72 + Then on linux just do `./gradlew build` and to make it in a single mod jar `./gradlew mergeJars`. 68 73 74 + Or on windows, just do `.\gradlew.bat build` and `.\gradlew.bat mergeJars`. 75 + Note that this isn't tested for windows, but I think that is how it works. 69 76 70 - #### Notes 77 + #### Getting the jars 78 + Then you can find your jars in `fabric/build/libs/` (for fabric), `neoforge/build/libs/` (for neoforge) or `merged/build/libs/` (if you made the merged jar file). 71 79 80 + If you have any issues just make an issue or contact me on Discord `@mrsnowy_` 81 + 82 + ### Notes 72 83 Colors: 73 84 - Green = When something succeeds and an action will happen 74 85 - Aqua = When something needs attention
+1 -1
common/src/main/java/dev/mrsnowy/teleport_commands/Constants.java
··· 6 6 public class Constants { 7 7 public static final String MOD_ID = "teleport_commands"; 8 8 public static final String MOD_NAME = "Teleport Commands"; 9 - public static final String VERSION = "1.3.2"; 9 + public static final String VERSION = "1.3.3"; 10 10 11 11 public static final Logger LOGGER = LoggerFactory.getLogger(MOD_NAME); 12 12 }
+10 -7
common/src/main/java/dev/mrsnowy/teleport_commands/TeleportCommands.java
··· 1 1 package dev.mrsnowy.teleport_commands; 2 2 3 3 import com.google.gson.*; 4 + import com.mojang.brigadier.CommandDispatcher; 4 5 import dev.mrsnowy.teleport_commands.storage.StorageManager; 5 6 import dev.mrsnowy.teleport_commands.commands.*; 6 7 import dev.mrsnowy.teleport_commands.storage.DeathLocationStorage; 8 + import net.minecraft.commands.CommandSourceStack; 7 9 import net.minecraft.commands.Commands; 8 10 import net.minecraft.server.MinecraftServer; 9 11 import net.minecraft.server.level.ServerPlayer; ··· 37 39 StorageManager.STORAGE = storageValidator(); // Initialize the storage file 38 40 DeathLocationStorage.clearDeathLocations(); // Clear data of death locations. 39 41 40 - // initialize commands, also allows me to easily disable any when there is a config 41 - Commands commandManager = server.getCommands(); 42 - back.register(commandManager); 43 - home.register(commandManager); 44 - tpa.register(commandManager); 45 - warp.register(commandManager); 46 - worldspawn.register(commandManager); 47 42 } 48 43 44 + // initialize commands, also allows me to easily disable any when there is a config 45 + public static void registerCommands(CommandDispatcher<CommandSourceStack> dispatcher) { 46 + back.register(dispatcher); 47 + home.register(dispatcher); 48 + tpa.register(dispatcher); 49 + warp.register(dispatcher); 50 + worldspawn.register(dispatcher); 51 + } 49 52 50 53 // Runs when the playerDeath mixin calls it, updates the /back command position 51 54 public static void onPlayerDeath(ServerPlayer player) {
+4 -2
common/src/main/java/dev/mrsnowy/teleport_commands/commands/back.java
··· 1 1 package dev.mrsnowy.teleport_commands.commands; 2 2 3 + import com.mojang.brigadier.CommandDispatcher; 3 4 import com.mojang.brigadier.arguments.BoolArgumentType; 4 5 import dev.mrsnowy.teleport_commands.Constants; 5 6 ··· 9 10 import dev.mrsnowy.teleport_commands.common.DeathLocation; 10 11 import dev.mrsnowy.teleport_commands.utils.tools; 11 12 import net.minecraft.ChatFormatting; 13 + import net.minecraft.commands.CommandSourceStack; 12 14 import net.minecraft.commands.Commands; 13 15 import net.minecraft.core.BlockPos; 14 16 import net.minecraft.network.chat.ClickEvent; ··· 22 24 23 25 public class back { 24 26 25 - public static void register(Commands commandManager) { 27 + public static void register(CommandDispatcher<CommandSourceStack> commandDispatcher) { 26 28 27 - commandManager.getDispatcher().register(Commands.literal("back") 29 + commandDispatcher.register(Commands.literal("back") 28 30 .requires(source -> source.getPlayer() != null) 29 31 .executes(context -> { 30 32 final ServerPlayer player = context.getSource().getPlayerOrException();
+9 -7
common/src/main/java/dev/mrsnowy/teleport_commands/commands/home.java
··· 1 1 package dev.mrsnowy.teleport_commands.commands; 2 2 3 + import com.mojang.brigadier.CommandDispatcher; 3 4 import com.mojang.brigadier.arguments.StringArgumentType; 4 5 import dev.mrsnowy.teleport_commands.Constants; 5 6 import dev.mrsnowy.teleport_commands.storage.StorageManager; ··· 12 13 13 14 import dev.mrsnowy.teleport_commands.utils.tools; 14 15 import net.minecraft.ChatFormatting; 16 + import net.minecraft.commands.CommandSourceStack; 15 17 import net.minecraft.commands.Commands; 16 18 import net.minecraft.core.BlockPos; 17 19 import net.minecraft.network.chat.ClickEvent; ··· 28 30 import static dev.mrsnowy.teleport_commands.utils.tools.Teleporter; 29 31 30 32 public class home { 31 - public static void register(Commands commandManager) { 33 + public static void register(CommandDispatcher<CommandSourceStack> commandDispatcher) { 32 34 33 - commandManager.getDispatcher().register(Commands.literal("sethome") 35 + commandDispatcher.register(Commands.literal("sethome") 34 36 .requires(source -> source.getPlayer() != null) 35 37 .then(argument("name", StringArgumentType.string()) 36 38 .executes(context -> { ··· 49 51 }))); 50 52 51 53 52 - commandManager.getDispatcher().register(Commands.literal("home") 54 + commandDispatcher.register(Commands.literal("home") 53 55 .requires(source -> source.getPlayer() != null) 54 56 .executes(context -> { 55 57 final ServerPlayer player = context.getSource().getPlayerOrException(); ··· 82 84 return 0; 83 85 }))); 84 86 85 - commandManager.getDispatcher().register(Commands.literal("delhome") 87 + commandDispatcher.register(Commands.literal("delhome") 86 88 .requires(source -> source.getPlayer() != null) 87 89 .then(argument("name", StringArgumentType.string()) 88 90 .suggests(new HomeSuggestionProvider()) ··· 102 104 return 0; 103 105 }))); 104 106 105 - commandManager.getDispatcher().register(Commands.literal("renamehome") 107 + commandDispatcher.register(Commands.literal("renamehome") 106 108 .requires(source -> source.getPlayer() != null) 107 109 .then(argument("name", StringArgumentType.string()) 108 110 .suggests(new HomeSuggestionProvider()) ··· 125 127 })))); 126 128 127 129 128 - commandManager.getDispatcher().register(Commands.literal("defaulthome") 130 + commandDispatcher.register(Commands.literal("defaulthome") 129 131 .requires(source -> source.getPlayer() != null) 130 132 .then(argument("name", StringArgumentType.string()).suggests(new HomeSuggestionProvider()) 131 133 .executes(context -> { ··· 143 145 return 0; 144 146 }))); 145 147 146 - commandManager.getDispatcher().register(Commands.literal("homes") 148 + commandDispatcher.register(Commands.literal("homes") 147 149 .requires(source -> source.getPlayer() != null) 148 150 .executes(context -> { 149 151 final ServerPlayer player = context.getSource().getPlayerOrException();
+7 -5
common/src/main/java/dev/mrsnowy/teleport_commands/commands/tpa.java
··· 2 2 3 3 import java.util.*; 4 4 5 + import com.mojang.brigadier.CommandDispatcher; 5 6 import dev.mrsnowy.teleport_commands.Constants; 6 7 import dev.mrsnowy.teleport_commands.suggestions.tpaSuggestionProvider; 7 8 8 9 import net.minecraft.ChatFormatting; 10 + import net.minecraft.commands.CommandSourceStack; 9 11 import net.minecraft.commands.Commands; 10 12 import net.minecraft.commands.arguments.EntityArgument; 11 13 import net.minecraft.core.BlockPos; ··· 33 35 } 34 36 } 35 37 36 - public static void register(Commands commandManager) { 38 + public static void register(CommandDispatcher<CommandSourceStack> commandDispatcher) { 37 39 38 - commandManager.getDispatcher().register(Commands.literal("tpa") 40 + commandDispatcher.register(Commands.literal("tpa") 39 41 .requires(source -> source.getPlayer() != null) 40 42 .then(Commands.argument("player", EntityArgument.player()) 41 43 .executes(context -> { ··· 54 56 return 0; 55 57 }))); 56 58 57 - commandManager.getDispatcher().register(Commands.literal("tpahere") 59 + commandDispatcher.register(Commands.literal("tpahere") 58 60 .requires(source -> source.getPlayer() != null) 59 61 .then(Commands.argument("player", EntityArgument.player()) 60 62 .executes(context -> { ··· 71 73 return 0; 72 74 }))); 73 75 74 - commandManager.getDispatcher().register(Commands.literal("tpaaccept") 76 + commandDispatcher.register(Commands.literal("tpaaccept") 75 77 .requires(source -> source.getPlayer() != null) 76 78 .then(Commands.argument("player", EntityArgument.player()).suggests(new tpaSuggestionProvider()) 77 79 .executes(context -> { ··· 89 91 return 0; 90 92 }))); 91 93 92 - commandManager.getDispatcher().register(Commands.literal("tpadeny") 94 + commandDispatcher.register(Commands.literal("tpadeny") 93 95 .requires(source -> source.getPlayer() != null) 94 96 .then(Commands.argument("player", EntityArgument.player()).suggests(new tpaSuggestionProvider()) 95 97 .executes(context -> {
+8 -6
common/src/main/java/dev/mrsnowy/teleport_commands/commands/warp.java
··· 1 1 package dev.mrsnowy.teleport_commands.commands; 2 2 3 + import com.mojang.brigadier.CommandDispatcher; 3 4 import com.mojang.brigadier.arguments.StringArgumentType; 4 5 import dev.mrsnowy.teleport_commands.Constants; 5 6 import dev.mrsnowy.teleport_commands.common.NamedLocation; 6 7 import dev.mrsnowy.teleport_commands.suggestions.WarpSuggestionProvider; 7 8 import dev.mrsnowy.teleport_commands.utils.tools; 8 9 import net.minecraft.ChatFormatting; 10 + import net.minecraft.commands.CommandSourceStack; 9 11 import net.minecraft.commands.Commands; 10 12 import net.minecraft.core.BlockPos; 11 13 import net.minecraft.network.chat.ClickEvent; ··· 25 27 import static net.minecraft.commands.Commands.argument; 26 28 27 29 public class warp { 28 - public static void register(Commands commandManager) { 30 + public static void register(CommandDispatcher<CommandSourceStack> commandDispatcher) { 29 31 30 - commandManager.getDispatcher().register(Commands.literal("setwarp") 32 + commandDispatcher.register(Commands.literal("setwarp") 31 33 .requires(source -> 32 34 source.getPlayer() != null && 33 35 source.hasPermission(4) ··· 48 50 return 0; 49 51 }))); 50 52 51 - commandManager.getDispatcher().register(Commands.literal("warp") 53 + commandDispatcher.register(Commands.literal("warp") 52 54 .requires(source -> source.getPlayer() != null) 53 55 .then(argument("name", StringArgumentType.string()) 54 56 .suggests(new WarpSuggestionProvider()) ··· 67 69 return 0; 68 70 }))); 69 71 70 - commandManager.getDispatcher().register(Commands.literal("delwarp") 72 + commandDispatcher.register(Commands.literal("delwarp") 71 73 .requires(source -> 72 74 source.getPlayer() != null && 73 75 source.hasPermission(4) ··· 88 90 return 0; 89 91 }))); 90 92 91 - commandManager.getDispatcher().register(Commands.literal("renamewarp") 93 + commandDispatcher.register(Commands.literal("renamewarp") 92 94 .requires(source -> 93 95 source.getPlayer() != null && 94 96 source.hasPermission(4) ··· 111 113 return 0; 112 114 })))); 113 115 114 - commandManager.getDispatcher().register(Commands.literal("warps") 116 + commandDispatcher.register(Commands.literal("warps") 115 117 .requires(source -> source.getPlayer() != null) 116 118 .executes(context -> { 117 119 final ServerPlayer player = context.getSource().getPlayerOrException();
+4 -2
common/src/main/java/dev/mrsnowy/teleport_commands/commands/worldspawn.java
··· 1 1 package dev.mrsnowy.teleport_commands.commands; 2 2 3 + import com.mojang.brigadier.CommandDispatcher; 3 4 import com.mojang.brigadier.arguments.BoolArgumentType; 4 5 import dev.mrsnowy.teleport_commands.Constants; 5 6 import dev.mrsnowy.teleport_commands.TeleportCommands; 6 7 import net.minecraft.ChatFormatting; 8 + import net.minecraft.commands.CommandSourceStack; 7 9 import net.minecraft.commands.Commands; 8 10 import net.minecraft.core.BlockPos; 9 11 import net.minecraft.network.chat.ClickEvent; ··· 22 24 23 25 public class worldspawn { 24 26 25 - public static void register(Commands commandManager) { 26 - commandManager.getDispatcher().register(Commands.literal("worldspawn") 27 + public static void register(CommandDispatcher<CommandSourceStack> commandDispatcher) { 28 + commandDispatcher.register(Commands.literal("worldspawn") 27 29 .requires(source -> source.getPlayer() != null) 28 30 .executes(context -> { 29 31 final ServerPlayer player = context.getSource().getPlayerOrException();
+25
common/src/main/java/dev/mrsnowy/teleport_commands/mixin/CommandsMixin.java
··· 1 + package dev.mrsnowy.teleport_commands.mixin; 2 + 3 + import com.mojang.brigadier.CommandDispatcher; 4 + import dev.mrsnowy.teleport_commands.TeleportCommands; 5 + import dev.mrsnowy.teleport_commands.commands.*; 6 + import net.minecraft.commands.CommandBuildContext; 7 + import net.minecraft.commands.CommandSourceStack; 8 + import net.minecraft.commands.Commands; 9 + import org.spongepowered.asm.mixin.Mixin; 10 + import org.spongepowered.asm.mixin.injection.At; 11 + import org.spongepowered.asm.mixin.injection.Inject; 12 + import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 + 14 + @Mixin(Commands.class) 15 + public class CommandsMixin { 16 + 17 + @Inject(method = "<init>", at = @At("RETURN")) 18 + private void RegisterTeleportCommands(Commands.CommandSelection selection, CommandBuildContext context, CallbackInfo info) { 19 + 20 + Commands self = (Commands) (Object) this; 21 + CommandDispatcher<CommandSourceStack> dispatcher = self.getDispatcher(); 22 + 23 + TeleportCommands.registerCommands(dispatcher); 24 + } 25 + }
+1 -1
common/src/main/java/dev/mrsnowy/teleport_commands/mixin/PlayerDeathMixin.java
··· 11 11 public class PlayerDeathMixin { 12 12 13 13 @Inject(method = "die", at = @At("HEAD")) 14 - private void notifyDeath(CallbackInfo ci) { 14 + private void notifyDeath(CallbackInfo info) { 15 15 16 16 TeleportCommands.onPlayerDeath((ServerPlayer) (Object) this); 17 17 }
+2 -1
common/src/main/resources/teleport_commands.mixins.json
··· 6 6 "compatibilityLevel": "JAVA_${java_version}", 7 7 "mixins": [ 8 8 "ServerStartMixin", 9 - "PlayerDeathMixin" 9 + "PlayerDeathMixin", 10 + "CommandsMixin" 10 11 ], 11 12 "client": [], 12 13 "server": [],
+27
flake.lock
··· 1 + { 2 + "nodes": { 3 + "nixpkgs": { 4 + "locked": { 5 + "lastModified": 1756125398, 6 + "narHash": "sha256-XexyKZpf46cMiO5Vbj+dWSAXOnr285GHsMch8FBoHbc=", 7 + "owner": "nixos", 8 + "repo": "nixpkgs", 9 + "rev": "3b9f00d7a7bf68acd4c4abb9d43695afb04e03a5", 10 + "type": "github" 11 + }, 12 + "original": { 13 + "owner": "nixos", 14 + "ref": "nixos-unstable", 15 + "repo": "nixpkgs", 16 + "type": "github" 17 + } 18 + }, 19 + "root": { 20 + "inputs": { 21 + "nixpkgs": "nixpkgs" 22 + } 23 + } 24 + }, 25 + "root": "root", 26 + "version": 7 27 + }
+74
flake.nix
··· 1 + { 2 + description = "Flake for developing snowstorm!"; 3 + 4 + inputs = { 5 + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 6 + }; 7 + 8 + outputs = 9 + { 10 + nixpkgs, 11 + ... 12 + }: 13 + let 14 + system = "x86_64-linux"; 15 + pkgs = import nixpkgs { 16 + inherit system; 17 + }; 18 + project = "TeleportCommands"; 19 + in 20 + { 21 + devShells."${system}" = { 22 + default = pkgs.mkShell { 23 + packages = with pkgs; [ 24 + jetbrains.jdk-no-jcef # Jetbrains jdk 25 + flite # Make mc not complain 26 + 27 + # Took these from https://github.com/NixOS/nixpkgs/blob/nixos-25.05/pkgs/by-name/pr/prismlauncher/package.nix#L123 28 + # Thanks nixos packagers <3! 29 + xorg.xrandr 30 + 31 + glfw3-minecraft 32 + openal 33 + 34 + alsa-lib 35 + libjack2 36 + libpulseaudio 37 + pipewire 38 + 39 + libGL 40 + libx11 41 + xorg.libXcursor 42 + xorg.libXext 43 + xorg.libXrandr 44 + xorg.libXxf86vm 45 + ]; 46 + 47 + LD_LIBRARY_PATH = 48 + with pkgs; 49 + lib.makeLibraryPath [ 50 + flite # Make mc not complain 51 + 52 + glfw3-minecraft 53 + openal 54 + 55 + alsa-lib 56 + libjack2 57 + libpulseaudio 58 + pipewire 59 + 60 + libGL 61 + libx11 62 + xorg.libXcursor 63 + xorg.libXext 64 + xorg.libXrandr 65 + xorg.libXxf86vm 66 + ]; 67 + 68 + shellHook = '' 69 + echo -e "\n\x1b[36;1m📦 Welcome to the default flake for \x1b[32;1m${project}\x1b[0m\x1b[36m!\x1b[0m" 70 + ''; 71 + }; 72 + }; 73 + }; 74 + }
+1 -1
gradle.properties
··· 2 2 # Every field you add must be added to the root build.gradle expandProps map. 3 3 4 4 # Project 5 - version=1.3.2 5 + version=1.3.3 6 6 group=dev.mrsnowy.teleport_commands 7 7 java_version=21 8 8
+3
justfile
··· 1 + 2 + ide: 3 + idea-ultimate ./