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.

should be stabel-ish [1.10.0-beta]

check the changelog.md for the changes :3!

+768 -164
+4 -5
.github/workflows/build.yml
··· 11 11 strategy: 12 12 matrix: 13 13 # Use these Java versions 14 - java: [ 15 - 17, # Currently min for minecraft 16 - ] 14 + java: 15 + - 17 # Currently min for minecraft 17 16 runs-on: ubuntu-22.04 18 17 steps: 19 18 - name: checkout repository ··· 28 27 - name: make gradle wrapper executable 29 28 run: chmod +x ./gradlew 30 29 - name: build 31 - run: ./gradlew build 30 + run: ./gradlew shadowJar 32 31 - name: capture build artifacts 33 - if: ${{ matrix.java == '17' }} # Only upload artifacts built from latest java 32 + # if: ${{ matrix.java == '17' }} # Only upload artifacts built from latest java 34 33 uses: actions/upload-artifact@v4 35 34 with: 36 35 name: Artifacts
+16 -4
CHANGELOG.md
··· 8 8 ### [Unreleased] 9 9 10 10 #### Added 11 - - Added completely server-side translation system (UNLIKE MOJANG'S SYSTEM WHICH IS CLIENT SIDE) 11 + - Added a completely server-side translation system (UNLIKE MOJANG'S SYSTEM WHICH IS CLIENT SIDE) 12 + - Added a Json Storage cleaner, which automatically cleans and updates any values 13 + - Added a safety check with /back that automatically chooses a nearby safe location 12 14 - Added quilt support 13 - - Added CHANGELOG.md 15 + - Added a CHANGELOG.md 16 + - Added Tpa Accept/Deny Suggestions 17 + - Added Dutch translations 18 + - Added Hungarian translations (Thanks to [Martin Morningstar](https://github.com/RMI637)) 19 + 14 20 15 21 #### Changed 22 + - Limited the requests a player can do to the same player to 1 16 23 - Improved command messages and colors 17 - - improved performance by changing the death event to be player specific (not all entities) 18 - - Replaced all loader specific events with Mixins 24 + - Fixed Tpa Accept/Deny messages going to the wrong person 25 + - Fixed /back saying "Already back" when on the same death location in another dimension 26 + - Fixed /back giving an error when the player didn't have a deathLocation, instead of the appropriate message 27 + - Improved performance by changing the death event to be player specific (not all entities) 28 + - Replaced all loader specific api events with Mixins 29 + - Edited /back to have a DisableSafety option: `/back [<Disable Safety>]` 19 30 20 31 #### Removed 21 32 - Removed Sources and Javadoc files to improve build speed 22 33 - Removed Fabric API dependency 34 + - Removed pretty json printing (to save storage) 23 35 24 36 25 37 ### [v1.0.5]
+14 -12
README.md
··· 1 1 # Teleport Commands <img src="https://raw.githubusercontent.com/MrSn0wy/TeleportCommands/main/common/src/main/resources/teleport_commands.png" alt="Teleport Commands Logo" width="30"/> 2 2 3 - 4 3 A Minecraft server-side mod that adds various teleportation related commands, like /home /tpa and /back 5 4 6 - ### This mod is still in beta, if there are any problems then let me know! 5 + Here is the [Changelog](CHANGELOG.md) 7 6 8 7 #### Currently available commands: 9 8 10 - - `/back` - Teleports you to the location where you last died 9 + - `/back [<Disable Safety>]` - Teleports you to the location where you last died, if given true it will not do safety checks 11 10 <br> 12 11 13 12 - `/sethome <name>` - Creates a new home ··· 33 32 - [ ] `/spawn <dimension>` - Teleports you to your spawnpoint in a dimension, defaults to your current dimension 34 33 35 34 #### Improvements: 36 - - [ ] Modify /back to check if the location is safe and automatically choose a nearby location that is safe 37 35 - [ ] Create a config to add any delays and disable commands, also add commands for operators in game 38 36 - [ ] Add a perm system 39 - - [ ] Limit tpa requests for a player 37 + - [x] Json Storage automatic updater & cleaner 38 + - [x] Modify /back to check if the location is safe and automatically choose a nearby location that is safe 39 + - [x] Limit tpa requests for a player 40 40 - [x] Add translation system 41 41 - [x] Improve responses for commands 42 42 - [x] Add Quilt support and NeoForge ··· 44 44 45 45 ### Want to help? 46 46 47 - #### You can create a Translation file so other people can use the mod in their native language 48 - 1. Clone the repository 49 - 2. Go to `common/src/main/resources/assets/teleport_commands/lang/` 50 - 3. Go [here](https://minecraft.wiki/w/Language) and pick the in-game locale code for the language you want to translate 51 - 4. Copy `en_us.toml` and paste it in a new file called `[in-game locale code here].toml` 52 - 5. Translate the file 53 - 6. Submit a pull request with your translation :D! 47 + 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) 48 + 49 + #### Notes 50 + 51 + Colors: 52 + - Green = When something succeeds and an action will happen 53 + - Aqua = When something needs attention 54 + - White = When something is done 55 + - Red = When something fails
+2
build.gradle
··· 1 1 plugins { 2 2 // Required for NeoGradle 3 3 id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7" 4 + // Required to bundle the toml library 5 + id 'com.github.johnrengelman.shadow' version '8.1.1' 4 6 }
+9 -1
buildSrc/src/main/groovy/multiloader-common.gradle
··· 1 1 plugins { 2 2 id 'java-library' 3 + id 'com.github.johnrengelman.shadow' 3 4 } 4 5 5 6 base { ··· 37 38 // } 38 39 } 39 40 40 - jar { 41 + shadowJar { 41 42 from(rootProject.file("LICENSE")) { 42 43 rename { "${it}_${mod_name}" } 43 44 } ··· 53 54 'Built-On-Minecraft' : minecraft_version 54 55 ]) 55 56 } 57 + 58 + dependencies { 59 + include(dependency('org.tomlj:tomlj:1.1.1')) 60 + relocate 'org.tomlj', "dev.mrsnowy.tomlj_${mod_id}" 61 + } 62 + 63 + exclude('mappings/**') 56 64 } 57 65 58 66 processResources {
+142 -6
common/src/main/java/dev/mrsnowy/teleport_commands/TeleportCommands.java
··· 1 1 package dev.mrsnowy.teleport_commands; 2 2 3 + import com.google.gson.*; 3 4 import dev.mrsnowy.teleport_commands.storage.StorageManager; 4 5 import dev.mrsnowy.teleport_commands.commands.*; 5 6 import net.minecraft.commands.Commands; ··· 8 9 import net.minecraft.world.level.storage.LevelResource; 9 10 import org.slf4j.Logger; 10 11 import org.slf4j.LoggerFactory; 12 + 13 + import java.io.FileReader; 14 + import java.io.IOException; 15 + import java.nio.file.Files; 11 16 import java.nio.file.Path; 12 17 import java.nio.file.Paths; 13 - import java.util.Objects; 18 + import java.nio.file.StandardOpenOption; 14 19 15 20 import static dev.mrsnowy.teleport_commands.utils.tools.DeathLocationUpdater; 16 21 17 22 public class TeleportCommands { 18 - 19 23 public static final String MOD_ID = "teleport_commands"; 20 24 public static final String MOD_NAME = "Teleport Commands"; 21 25 public static final Logger LOGGER = LoggerFactory.getLogger(MOD_NAME); 22 26 public static String MOD_LOADER; 23 27 public static Path SAVE_DIR; 24 28 public static Path CONFIG_DIR; 25 - public static MinecraftServer Server; 29 + // public static MinecraftServer Server; 30 + 26 31 32 + // Gets ran when the server starts 27 33 public static void initializeMod(MinecraftServer server) { 28 34 // initialize da variables 29 35 LOGGER.info("Initializing Teleport Commands! Hello {}!", MOD_LOADER); ··· 33 39 // Construct the game directory path 34 40 CONFIG_DIR = Paths.get(System.getProperty("user.dir")).resolve("config"); 35 41 36 - Server = server; 42 + // Server = server; 43 + 44 + cleanStorage(); 37 45 38 46 // initialize commands, also allows me to easily disable any when there is a config 39 47 Commands commandManager = server.getCommands(); 40 48 back.register(commandManager); 41 49 home.register(commandManager); 42 50 tpa.register(commandManager); 43 - 44 - StorageManager.StorageInit(); 45 51 } 46 52 47 53 public static void onPlayerDeath(ServerPlayer player) { ··· 50 56 DeathLocationUpdater(player.position(), player.serverLevel(), player.getStringUUID()); 51 57 52 58 } catch (Exception e) { 59 + LOGGER.error(e.toString()); 60 + } 61 + } 62 + 63 + // cleans and updates Storage to the newest "version" 64 + private static void cleanStorage() { 65 + LOGGER.info("Cleaning and updating Storage!"); 66 + try { 67 + StorageManager.StorageInit(); 68 + FileReader reader = new FileReader(StorageManager.STORAGE_FILE.toString()); 69 + JsonElement jsonElement = JsonParser.parseReader(reader); 70 + 71 + boolean done = false; 72 + 73 + if (jsonElement.isJsonObject()) { 74 + JsonObject mainJsonObject = jsonElement.getAsJsonObject(); 75 + 76 + // get the Players list 77 + if (mainJsonObject.has("Players") && mainJsonObject.get("Players").isJsonArray()) { 78 + 79 + JsonArray newPlayersArray = new JsonArray(); 80 + 81 + // players 82 + for (JsonElement playerElement : mainJsonObject.get("Players").getAsJsonArray()) { 83 + System.out.println("Element: " + playerElement); 84 + 85 + // player 86 + if (playerElement.isJsonObject()) { 87 + 88 + JsonObject player = playerElement.getAsJsonObject(); 89 + boolean hasInformation = false; 90 + 91 + String UUID = player.has("Player_UUID") 92 + ? player.get("Player_UUID").getAsString() : (player.has("UUID") 93 + ? player.get("UUID").getAsString() : null); 94 + 95 + String DefaultHome = player.has("DefaultHome") 96 + ? player.get("DefaultHome").getAsString() : ""; 97 + 98 + 99 + // Clean death location after server restart 100 + JsonObject deathLocation = new JsonObject(); 101 + 102 + deathLocation.addProperty("x", 0); 103 + deathLocation.addProperty("y", 0); 104 + deathLocation.addProperty("z", 0); 105 + deathLocation.addProperty("world", ""); 106 + 107 + 108 + JsonArray homes = new JsonArray(); 109 + 110 + if (player.has("Homes") && player.get("Homes").isJsonArray() ) { 111 + JsonArray tempHomes = player.get("Homes").getAsJsonArray(); 112 + boolean defaultFound = false; 113 + 114 + 115 + for (JsonElement homeElement : tempHomes) { 116 + if (homeElement.isJsonObject()) { 117 + JsonObject home = homeElement.getAsJsonObject(); 118 + 119 + String homeName = home.has("name") 120 + ? home.get("name").getAsString() : ""; 121 + 122 + Double homeX = home.has("x") 123 + ? home.get("x").getAsDouble() : null; 124 + 125 + Double homeY = home.has("y") 126 + ? home.get("y").getAsDouble() : null; 127 + 128 + Double homeZ = home.has("z") 129 + ? home.get("z").getAsDouble() : null; 130 + 131 + String homeWorld = home.has("world") 132 + ? home.get("world").getAsString() : ""; 133 + 134 + 135 + // check if it is valid 136 + if (!homeName.isBlank() && !homeWorld.isBlank() && homeX != null && homeY != null && homeZ != null) { 137 + 138 + // check if it is the default home 139 + if (!DefaultHome.isBlank() && homeName.equals(DefaultHome)) { 140 + defaultFound = true; 141 + } 142 + 143 + JsonObject newHome = new JsonObject(); 144 + 145 + newHome.addProperty("name", homeName); 146 + newHome.addProperty("x", homeX); 147 + newHome.addProperty("y", homeY); 148 + newHome.addProperty("z", homeZ); 149 + newHome.addProperty("world", homeWorld); 150 + 151 + homes.add(newHome); 152 + hasInformation = true; 153 + } 154 + } 155 + } 156 + 157 + // clean DefaultHome if there is no home with the name 158 + if (!defaultFound) { 159 + DefaultHome = ""; 160 + } 161 + } 162 + 163 + // if it isn't empty it gets added to the newPlayersArray 164 + if ((UUID != null && !UUID.isBlank()) && hasInformation) { 165 + 166 + JsonObject newPlayer = new JsonObject(); 167 + 168 + newPlayer.addProperty("UUID", UUID); 169 + newPlayer.addProperty("DefaultHome", DefaultHome); 170 + newPlayer.add("deathLocation", deathLocation); 171 + newPlayer.add("Homes", homes); 172 + 173 + newPlayersArray.add(newPlayer); 174 + } 175 + } 176 + } 177 + 178 + // save the cleaned and updated file 179 + mainJsonObject.remove("Players"); 180 + mainJsonObject.add("Players", newPlayersArray); 181 + 182 + Gson gson = new GsonBuilder().create(); 183 + byte[] json = gson.toJson(mainJsonObject).getBytes(); 184 + Files.write(StorageManager.STORAGE_FILE, json, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); 185 + } 186 + } 187 + 188 + } catch (IOException e) { 53 189 LOGGER.error(e.toString()); 54 190 } 55 191 }
+176 -29
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.arguments.BoolArgumentType; 4 + import com.mojang.datafixers.util.Pair; 3 5 import dev.mrsnowy.teleport_commands.TeleportCommands; 4 6 import dev.mrsnowy.teleport_commands.storage.StorageManager; 5 - import java.util.Objects; 7 + 8 + import java.util.*; 9 + 10 + import dev.mrsnowy.teleport_commands.suggestions.HomeSuggestionProvider; 6 11 import net.minecraft.ChatFormatting; 7 12 import net.minecraft.commands.Commands; 13 + import net.minecraft.core.BlockPos; 14 + import net.minecraft.network.chat.ClickEvent; 8 15 import net.minecraft.network.chat.Component; 9 16 import net.minecraft.server.level.ServerLevel; 10 17 import net.minecraft.server.level.ServerPlayer; 11 18 import net.minecraft.world.phys.Vec3; 19 + import org.tomlj.Toml; 20 + 21 + import javax.swing.text.html.Option; 12 22 13 23 import static dev.mrsnowy.teleport_commands.storage.StorageManager.GetPlayerStorage; 14 - import static dev.mrsnowy.teleport_commands.utils.tools.Teleporter; 15 - import static dev.mrsnowy.teleport_commands.utils.tools.getTranslatedText; 24 + import static dev.mrsnowy.teleport_commands.utils.tools.*; 25 + import static net.minecraft.commands.Commands.argument; 16 26 17 27 public class back { 18 28 ··· 22 32 ServerPlayer player = context.getSource().getPlayerOrException(); 23 33 24 34 try { 25 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.teleport", player), true); 26 - ToDeathLocation(player); 35 + ToDeathLocation(player, false); 36 + 27 37 } catch (Exception e) { 28 38 TeleportCommands.LOGGER.error(String.valueOf(e)); 29 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 39 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 30 40 return 1; 31 41 } 32 42 return 0; 33 - })); 43 + }) 44 + .then(argument("Disable Safety", BoolArgumentType.bool()).executes(context -> { 45 + final boolean safety = BoolArgumentType.getBool(context, "Disable Safety"); 46 + ServerPlayer player = context.getSource().getPlayerOrException(); 34 47 35 - commandManager.getDispatcher().register(Commands.literal("lang").executes(context -> { 48 + try { 49 + ToDeathLocation(player, safety); 50 + 51 + } catch (Exception e) { 52 + TeleportCommands.LOGGER.error(String.valueOf(e)); 53 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 54 + return 1; 55 + } 56 + return 0; 57 + })) 58 + ); 59 + 60 + commandManager.getDispatcher().register(Commands.literal("test").executes(context -> { 36 61 ServerPlayer player = context.getSource().getPlayerOrException(); 37 62 38 - try { 39 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", player), true); 40 - } catch (Exception e) { 41 - TeleportCommands.LOGGER.error(String.valueOf(e)); 42 - // player.displayClientMessage(Component.translatable("commands.teleport_commands.back.error").withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 43 - return 1; 44 - } 63 + 64 + player.displayClientMessage(Component.literal("Yellow").withStyle(ChatFormatting.YELLOW, ChatFormatting.BOLD), true); 65 + TeleportCommands.LOGGER.info("Yellow info"); 66 + TeleportCommands.LOGGER.warn("Yellow warn"); 67 + TeleportCommands.LOGGER.error("Yellow error"); 68 + TeleportCommands.LOGGER.error(String.valueOf(Toml.parse("commands.teleport_commands.back.go = \"Going Back\""))); 69 + Toml.parse("commands.teleport_commands.back.go = \"Going Back\""); 45 70 return 0; 46 71 })); 47 72 } 48 73 49 74 50 75 51 - private static void ToDeathLocation(ServerPlayer player) throws Exception { 76 + private static void ToDeathLocation(ServerPlayer player, boolean safetyDisabled) throws Exception { 52 77 StorageManager.StorageClass.Player playerStorage = GetPlayerStorage(player.getStringUUID()).playerStorage; 53 78 54 - Vec3 pos = new Vec3(playerStorage.deathLocation.x, playerStorage.deathLocation.y, playerStorage.deathLocation.z); 79 + // todo : fix 80 + 81 + if (playerStorage.deathLocation == null) { 82 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.noLocation", player).withStyle(ChatFormatting.RED), true); 83 + } else { 84 + final Vec3 pos = new Vec3(playerStorage.deathLocation.x, playerStorage.deathLocation.y, playerStorage.deathLocation.z); 85 + 86 + boolean found = false; 87 + for (ServerLevel currentWorld : Objects.requireNonNull(player.getServer()).getAllLevels()) { 88 + 89 + if (Objects.equals(currentWorld.dimension().location().toString(), playerStorage.deathLocation.world)) { 90 + 91 + int playerX = (int) pos.x; 92 + int playerY = (int) pos.y; 93 + int playerZ = (int) pos.z; 94 + 95 + // check if the death location isn't safe and that safety isn't enabled 96 + if (!safetyDisabled) { 97 + Pair<Integer, Optional<Vec3>> silly = teleportSafetyChecker(playerX, playerY, playerZ, currentWorld, player); 98 + 99 + 100 + switch (silly.getFirst()) { 101 + case 0: // safe! 102 + if (silly.getSecond().isPresent()) { 103 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.go", player), true); 104 + Teleporter(player, currentWorld, silly.getSecond().get()); 105 + } else { 106 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); 107 + } 108 + 109 + break; 110 + case 1: // same 111 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.same", player).withStyle(ChatFormatting.AQUA), true); 112 + break; 113 + case 2: // no safe location 114 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.forceTeleport", player) 115 + .withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD) 116 + .withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/back true"))) 117 + ,false); 118 + break; 119 + } 120 + 121 + // if (!safetyDisabled && isBlockPosUnsafe(new BlockPos(playerX, playerY, playerZ), currentWorld)) { 122 + // int row = 1; 123 + // int rows = 3; 124 + // boolean safeLocationFound = false; 125 + // 126 + // // find a safe location in an x row radius 127 + // whileLoop: 128 + // while (row <= rows) { 129 + //// TeleportCommands.LOGGER.info("currently doing row " + row + " of " + rows); //debug 130 + // 131 + // for (int z = -row; z <= row; z++) { 132 + // for (int x = -row; x <= row; x++) { 133 + // for (int y = -row; y <= row; y++ ) { 134 + // 135 + // if ((x == -row || x == row) || (z == -row || z == row) || (y == -row || y == row)) { 136 + // if (!isBlockPosUnsafe(new BlockPos(playerX + x, playerY + y, playerZ + z), currentWorld)) { 137 + // 138 + // Vec3 PlayerToTeleport = new Vec3(playerX + x + 0.5, playerY + y, playerZ + z + 0.5); 139 + // 140 + // if (!player.getPosition(0).equals(PlayerToTeleport) || player.level() != currentWorld) { 141 + // 142 + // Teleporter(player, currentWorld, PlayerToTeleport); 143 + // } else { 144 + // 145 + // } 146 + // 147 + // safeLocationFound = true; 148 + // break whileLoop; 149 + // } 150 + // } 151 + // } 152 + // } 153 + // } 154 + // 155 + // row++; 156 + // } 157 + // 158 + // if (!safeLocationFound) { 159 + // player.displayClientMessage( 160 + // getTranslatedText("commands.teleport_commands.back.noSafeLocation", player) 161 + // .withStyle(ChatFormatting.RED, ChatFormatting.BOLD) 162 + // , false); 163 + // 164 + // player.displayClientMessage( 165 + // getTranslatedText("commands.teleport_commands.back.safetyIsForLosers", player).withStyle(ChatFormatting.AQUA) 166 + // .append("\n") 167 + // .append( 168 + // getTranslatedText("commands.teleport_commands.back.forceTeleport", player) 169 + // .withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD) 170 + // .withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/back true"))) 171 + // ) 172 + // ,false); 173 + // } 55 174 56 - boolean found = false; 57 - for (ServerLevel currentWorld : Objects.requireNonNull(player.getServer()).getAllLevels()) { 58 - if (Objects.equals(currentWorld.dimension().location().toString(), playerStorage.deathLocation.world)) { 59 - if (!player.getPosition(0).equals(pos)) { 60 - Teleporter(player, currentWorld, pos); 61 - } else { 62 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.same", player).withStyle(ChatFormatting.AQUA), true); 175 + } else { 176 + if (!player.getPosition(0).equals(pos) || player.level() != currentWorld) { 177 + 178 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.go", player), true); 179 + Teleporter(player, currentWorld, new Vec3(playerX + 0.5, playerY, playerZ + 0.5)); 180 + 181 + } else { 182 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.same", player).withStyle(ChatFormatting.AQUA), true); 183 + } 184 + } 185 + 186 + 187 + found = true; 188 + break; 63 189 } 64 - found = true; 65 - break; 66 190 } 67 - } 68 191 69 - if (!found) { 70 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.noLocation", player).withStyle(ChatFormatting.RED), true); 192 + if (!found) { 193 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.noLocation", player).withStyle(ChatFormatting.RED), true); 194 + } 71 195 } 72 196 } 197 + 198 + // private static boolean isBlockPosUnsafe(BlockPos bottomPlayer, ServerLevel world) { 199 + // // bottomPlayer is presumed to be the bottom of the player character 200 + // 201 + // BlockPos belowPlayer = new BlockPos(bottomPlayer.getX(), bottomPlayer.getY() -1, bottomPlayer.getZ()); // below the player 202 + // String belowPlayerId = world.getBlockState(belowPlayer).getBlock().getDescriptionId(); // below the player 203 + // 204 + // String BottomPlayerId = world.getBlockState(bottomPlayer).getBlock().getDescriptionId(); // bottom of player 205 + // 206 + // BlockPos TopPlayer = new BlockPos(bottomPlayer.getX(), bottomPlayer.getY() + 1, bottomPlayer.getZ()); // top of player 207 + // String TopPlayerId = world.getBlockState(TopPlayer).getBlock().getDescriptionId(); // top of player 208 + // 209 + // 210 + // // check if the death location isn't safe 211 + // if ( 212 + // (belowPlayerId.equals("block.minecraft.water") || !world.getBlockState(belowPlayer).getCollisionShape(world, belowPlayer).isEmpty()) // check if the player is gonna fall on teleport 213 + // && (world.getBlockState(bottomPlayer).getCollisionShape(world, bottomPlayer).isEmpty() && !unsafeCollisionFreeBlocks.contains(BottomPlayerId)) // check if it is a collision free block, that isnt dangerous 214 + // && (!unsafeCollisionFreeBlocks.contains(TopPlayerId)) // check if it is a dangerous collision free block, if it is solid then the player crawls 215 + // ){ 216 + // return false; // it's safe 217 + // } 218 + // return true; // it's not safe! 219 + // } 73 220 }
+34 -25
common/src/main/java/dev/mrsnowy/teleport_commands/commands/home.java
··· 3 3 import com.mojang.brigadier.arguments.StringArgumentType; 4 4 import dev.mrsnowy.teleport_commands.TeleportCommands; 5 5 import dev.mrsnowy.teleport_commands.storage.StorageManager; 6 - import dev.mrsnowy.teleport_commands.suggestions.HomesuggestionProvider; 6 + import dev.mrsnowy.teleport_commands.suggestions.HomeSuggestionProvider; 7 7 import java.util.Objects; 8 8 import net.minecraft.ChatFormatting; 9 9 import net.minecraft.commands.Commands; ··· 29 29 ServerPlayer player = context.getSource().getPlayerOrException(); 30 30 31 31 try { 32 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.set", player), true); 33 32 SetHome(player, name); 34 33 35 34 } catch (Exception e) { ··· 46 45 ServerPlayer player = context.getSource().getPlayerOrException(); 47 46 48 47 try { 49 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.go", player), true); 50 48 GoHome(player, ""); 51 49 52 50 } catch (Exception e) { ··· 56 54 } 57 55 return 0; 58 56 }) 59 - .then(argument("name", StringArgumentType.string()).suggests(new HomesuggestionProvider()) 57 + .then(argument("name", StringArgumentType.string()).suggests(new HomeSuggestionProvider()) 60 58 .executes(context -> { 61 59 final String name = StringArgumentType.getString(context, "name"); 62 60 ServerPlayer player = context.getSource().getPlayerOrException(); 63 61 64 62 try { 65 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.go", player), true); 66 63 GoHome(player, name); 67 64 68 65 } catch (Exception e) { ··· 74 71 }))); 75 72 76 73 commandManager.getDispatcher().register(Commands.literal("delhome") 77 - .then(argument("name", StringArgumentType.string()).suggests(new HomesuggestionProvider()) 74 + .then(argument("name", StringArgumentType.string()).suggests(new HomeSuggestionProvider()) 78 75 .executes(context -> { 79 76 final String name = StringArgumentType.getString(context, "name"); 80 - ServerPlayer player = context.getSource().getPlayerOrException();; 77 + ServerPlayer player = context.getSource().getPlayerOrException(); 81 78 82 79 try { 83 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.delete", player), true); 84 80 DeleteHome(player, name); 85 81 86 82 } catch (Exception e) { ··· 92 88 }))); 93 89 94 90 commandManager.getDispatcher().register(Commands.literal("renamehome") 95 - .then(argument("name", StringArgumentType.string()).suggests(new HomesuggestionProvider()) 91 + .then(argument("name", StringArgumentType.string()).suggests(new HomeSuggestionProvider()) 96 92 .then(argument("newName", StringArgumentType.string()) 97 93 .executes(context -> { 98 94 final String name = StringArgumentType.getString(context, "name"); ··· 100 96 ServerPlayer player = context.getSource().getPlayerOrException(); 101 97 102 98 try { 103 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.rename", player), true); 104 99 RenameHome(player, name, newName); 100 + 105 101 } catch (Exception e) { 106 102 TeleportCommands.LOGGER.error(String.valueOf(e)); 107 103 player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.renameError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); ··· 112 108 113 109 114 110 commandManager.getDispatcher().register(Commands.literal("defaulthome") 115 - .then(argument("name", StringArgumentType.string()).suggests(new HomesuggestionProvider()) 111 + .then(argument("name", StringArgumentType.string()).suggests(new HomeSuggestionProvider()) 116 112 .executes(context -> { 117 113 final String name = StringArgumentType.getString(context, "name"); 118 114 ServerPlayer player = context.getSource().getPlayerOrException(); 119 115 120 116 try { 121 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.default", player), true); 122 117 SetDefaultHome(player, name); 118 + 123 119 } catch (Exception e) { 124 120 TeleportCommands.LOGGER.error(String.valueOf(e)); 125 121 player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.defaultError", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); ··· 134 130 135 131 try { 136 132 PrintHomes(player); 133 + 137 134 } catch (Exception e) { 138 135 TeleportCommands.LOGGER.error(String.valueOf(e)); 139 136 player.displayClientMessage(getTranslatedText("commands.teleport_commands.homes.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); ··· 150 147 Vec3 pos = player.position(); 151 148 ServerLevel world = player.serverLevel(); 152 149 153 - StorageManager.PlayerStorageResult storages = GetPlayerStorage(player.getStringUUID()); 150 + StorageManager.PlayerStorageClass storages = GetPlayerStorage(player.getStringUUID()); 154 151 StorageManager.StorageClass storage = storages.storage; 155 152 StorageManager.StorageClass.Player playerStorage = storages.playerStorage; 156 153 ··· 181 178 } 182 179 183 180 StorageSaver(storage); 181 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.set", player), true); 184 182 } else { 185 183 player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.exists", player).withStyle(ChatFormatting.RED), true); 186 184 } ··· 215 213 foundWorld = true; 216 214 217 215 if (!player.getPosition(0).equals(coords)) { 216 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.go", player), true); 218 217 Teleporter(player, currentWorld, new Vec3(currentHome.x, currentHome.y, currentHome.z)); 219 218 } else { 220 219 player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.goSame", player).withStyle(ChatFormatting.AQUA), true); ··· 232 231 233 232 private static void DeleteHome(ServerPlayer player, String homeName) throws Exception { 234 233 homeName = homeName.toLowerCase(); 235 - StorageManager.PlayerStorageResult storages = GetPlayerStorage(player.getStringUUID()); 234 + StorageManager.PlayerStorageClass storages = GetPlayerStorage(player.getStringUUID()); 236 235 StorageManager.StorageClass storage = storages.storage; 237 236 StorageManager.StorageClass.Player playerStorage = storages.playerStorage; 238 237 ··· 249 248 if (Objects.nonNull(homeToDelete)) { 250 249 playerStorage.Homes.remove(homeToDelete); 251 250 StorageSaver(storage); 251 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.delete", player), true); 252 252 } else { 253 253 player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); 254 254 } ··· 258 258 homeName = homeName.toLowerCase(); 259 259 newHomeName = newHomeName.toLowerCase(); 260 260 261 - StorageManager.PlayerStorageResult storages = GetPlayerStorage(player.getStringUUID()); 261 + StorageManager.PlayerStorageClass storages = GetPlayerStorage(player.getStringUUID()); 262 262 StorageManager.StorageClass storage = storages.storage; 263 263 StorageManager.StorageClass.Player playerStorage = storages.playerStorage; 264 264 ··· 283 283 } 284 284 285 285 if (Objects.nonNull(homeToRename)) { 286 - // if the current home is the default home, then change it in the config 286 + // if the current home is the default home, then change to the new name in the config 287 287 if (Objects.equals(playerStorage.DefaultHome, homeToRename.name)) { 288 288 playerStorage.DefaultHome = newHomeName; 289 289 } 290 290 291 291 homeToRename.name = newHomeName; 292 292 StorageSaver(storage); 293 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.rename", player), true); 293 294 } else { 294 295 player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); 295 296 } ··· 301 302 302 303 private static void SetDefaultHome(ServerPlayer player, String homeName) throws Exception { 303 304 homeName = homeName.toLowerCase(); 304 - StorageManager.PlayerStorageResult storages = GetPlayerStorage(player.getStringUUID()); 305 + StorageManager.PlayerStorageClass storages = GetPlayerStorage(player.getStringUUID()); 305 306 StorageManager.StorageClass storage = storages.storage; 306 307 StorageManager.StorageClass.Player playerStorage = storages.playerStorage; 307 308 ··· 316 317 } 317 318 318 319 if (homeExists) { 319 - if (Objects.equals(playerStorage.DefaultHome, homeName)) { 320 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.defaultSame", player).withStyle(ChatFormatting.AQUA), true); 320 + if (!Objects.equals(playerStorage.DefaultHome, homeName)) { 321 321 322 - } else { 323 322 playerStorage.DefaultHome = homeName; 324 323 StorageSaver(storage); 324 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.default", player), true); 325 + 326 + } else { 327 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.defaultSame", player).withStyle(ChatFormatting.AQUA), true); 325 328 } 329 + 326 330 } else { 327 331 player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); 328 332 } ··· 334 338 335 339 for (StorageManager.StorageClass.Player.Home currenthome : playerStorage.Homes) { 336 340 if (!anyHomes) { 337 - player.displayClientMessage(getTranslatedText("commands.teleport_commands.homes.homes", player).withStyle(ChatFormatting.YELLOW, ChatFormatting.BOLD), false); 341 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.homes.homes", player).withStyle(ChatFormatting.YELLOW, ChatFormatting.BOLD) 342 + .append("\n"), false); 338 343 anyHomes = true; 339 344 } 340 345 341 346 String name = String.format(" - %s", currenthome.name); 342 347 343 348 344 - String coords = String.format(" [X%.1f Y%.1f Z%.1f]", currenthome.x, currenthome.y, currenthome.z); 349 + String coords = String.format("[X%.1f Y%.1f Z%.1f]", currenthome.x, currenthome.y, currenthome.z); 345 350 String dimension = String.format(" [%s]", currenthome.world); 346 351 347 352 if (Objects.equals(currenthome.name, playerStorage.DefaultHome)) { 348 353 player.displayClientMessage(Component.literal(name).withStyle(ChatFormatting.AQUA) 354 + .append(" ") 349 355 .append(getTranslatedText("commands.teleport_commands.homes.default", player).withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD)), 350 356 false 351 357 ); ··· 354 360 } 355 361 356 362 357 - player.displayClientMessage(Component.literal(" |").withStyle(ChatFormatting.AQUA) 363 + player.displayClientMessage(Component.literal(" | ").withStyle(ChatFormatting.AQUA) 358 364 .append(Component.literal(coords).withStyle(ChatFormatting.LIGHT_PURPLE).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, String.format("X%.2f Y%.2f Z%.2f", currenthome.x, currenthome.y, currenthome.z))))) 359 365 .append(Component.literal(dimension).withStyle(ChatFormatting.DARK_PURPLE).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, currenthome.world)))), 360 366 false 361 367 ); 362 368 363 - player.displayClientMessage(Component.literal(" |").withStyle(ChatFormatting.AQUA) 369 + player.displayClientMessage(Component.literal(" | ").withStyle(ChatFormatting.AQUA) 364 370 .append(getTranslatedText("commands.teleport_commands.homes.tp", player).withStyle(ChatFormatting.GREEN).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/home %s", currenthome.name))))) 371 + .append(" ") 365 372 .append(getTranslatedText("commands.teleport_commands.homes.rename", player).withStyle(ChatFormatting.BLUE).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.format("/renamehome %s ", currenthome.name))))) 366 - .append(getTranslatedText("commands.teleport_commands.homes.delete", player).withStyle(ChatFormatting.RED).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.format("/delhome %s", currenthome.name))))), 373 + .append(" ") 374 + .append(getTranslatedText("commands.teleport_commands.homes.delete", player).withStyle(ChatFormatting.RED).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.format("/delhome %s", currenthome.name))))) 375 + .append("\n"), 367 376 false 368 377 ); 369 378 }
+40 -28
common/src/main/java/dev/mrsnowy/teleport_commands/commands/tpa.java
··· 1 1 package dev.mrsnowy.teleport_commands.commands; 2 2 3 - import dev.mrsnowy.teleport_commands.TeleportCommands; 4 3 import java.util.*; 4 + 5 + import dev.mrsnowy.teleport_commands.suggestions.tpaSuggestionProvider; 6 + 5 7 import net.minecraft.ChatFormatting; 6 8 import net.minecraft.commands.Commands; 7 9 import net.minecraft.commands.arguments.EntityArgument; 8 10 import net.minecraft.network.chat.ClickEvent; 9 11 import net.minecraft.network.chat.Component; 10 - import net.minecraft.network.chat.MutableComponent; 11 12 import net.minecraft.server.level.ServerPlayer; 12 13 13 14 import static dev.mrsnowy.teleport_commands.utils.tools.Teleporter; ··· 15 16 16 17 public class tpa { 17 18 18 - private static final ArrayList<tpaArrayClass> tpaList = new ArrayList<>(); 19 + public static final ArrayList<tpaArrayClass> tpaList = new ArrayList<>(); 19 20 20 - private static class tpaArrayClass { 21 - private String InitPlayer; 22 - private String RecPlayer; 23 - private boolean here; 21 + public static class tpaArrayClass { 22 + public String InitPlayer; 23 + public String RecPlayer; 24 + boolean here; 24 25 } 25 26 26 27 public static void register(Commands commandManager) { ··· 47 48 }))); 48 49 49 50 commandManager.getDispatcher().register(Commands.literal("tpaaccept") 50 - .then(Commands.argument("player", EntityArgument.player()) 51 + .then(Commands.argument("player", EntityArgument.player()).suggests(new tpaSuggestionProvider()) 51 52 .executes(context -> { 52 53 final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); 53 54 ServerPlayer player = context.getSource().getPlayerOrException(); ··· 57 58 }))); 58 59 59 60 commandManager.getDispatcher().register(Commands.literal("tpadeny") 60 - .then(Commands.argument("player", EntityArgument.player()) 61 + .then(Commands.argument("player", EntityArgument.player()).suggests(new tpaSuggestionProvider()) 61 62 .executes(context -> { 62 63 final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); 63 64 ServerPlayer player = context.getSource().getPlayerOrException(); ··· 70 71 71 72 72 73 private static void tpaCommandHandler(ServerPlayer FromPlayer, ServerPlayer ToPlayer, boolean here) throws NullPointerException { 74 + long playerTpaList = tpa.tpaList.stream() 75 + .filter(tpa -> Objects.equals(FromPlayer.getStringUUID(), tpa.InitPlayer)) 76 + .filter(tpa -> Objects.equals(ToPlayer.getStringUUID(), tpa.RecPlayer)) 77 + .count(); 78 + 73 79 74 80 if (FromPlayer == ToPlayer) { 75 81 FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA),true); 76 82 83 + } else if (playerTpaList >= 1) { 84 + FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.alreadySent", FromPlayer, Component.literal(Objects.requireNonNull(ToPlayer.getName().tryCollapseToString())).withStyle(ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA) 85 + ,true 86 + ); 87 + 77 88 } else { 78 89 String hereText = here ? "Here" : ""; 79 - MutableComponent ReceivedFromMessage = getTranslatedText("commands.teleport_commands.tpa.received", ToPlayer, hereText); 80 - MutableComponent SentToMessage = getTranslatedText("commands.teleport_commands.tpa.sent", FromPlayer, hereText); 81 90 82 91 // Store da request 83 92 tpaArrayClass tpaRequest = new tpaArrayClass(); ··· 89 98 String ReceivedFromPlayer = Objects.requireNonNull(FromPlayer.getName().tryCollapseToString()); 90 99 String SentToPlayer = Objects.requireNonNull(ToPlayer.getName().tryCollapseToString()); 91 100 92 - FromPlayer.displayClientMessage(SentToMessage 93 - .append(Component.literal(SentToPlayer).withStyle(ChatFormatting.BOLD)) 101 + FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.sent", FromPlayer, Component.literal(hereText), Component.literal(SentToPlayer).withStyle(ChatFormatting.BOLD)) 94 102 // .append(Text.literal("\n[Cancel]").formatted(Formatting.BLUE, Formatting.BOLD)) 95 103 ,true 96 104 ); 97 105 98 - ToPlayer.displayClientMessage(ReceivedFromMessage.withStyle(ChatFormatting.AQUA) 99 - .append(Component.literal(ReceivedFromPlayer).withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD)) 106 + ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.received", ToPlayer, Component.literal(hereText), Component.literal(ReceivedFromPlayer).withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA) 107 + .append("\n") 100 108 .append(getTranslatedText("commands.teleport_commands.tpa.accept", ToPlayer).withStyle(ChatFormatting.GREEN, ChatFormatting.BOLD).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/tpaaccept %s", ReceivedFromPlayer))))) 101 109 .append(getTranslatedText("commands.teleport_commands.tpa.deny", ToPlayer).withStyle(ChatFormatting.RED, ChatFormatting.BOLD).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/tpadeny %s", ReceivedFromPlayer))))), 102 110 false ··· 109 117 public void run() { 110 118 boolean successful = tpaList.remove(tpaRequest); 111 119 if (successful) { 112 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.expired", FromPlayer, hereText).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); 120 + FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.expired", FromPlayer, Component.literal(hereText)).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); 121 + ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.expired", ToPlayer, Component.literal(hereText)).withStyle(ChatFormatting.WHITE),true); 113 122 } 123 + // else { 124 + // TeleportCommands.LOGGER.error("Error removing tpaRequest from tpaList!"); 125 + // } 126 + // else not needed since it may be cancelled 114 127 } 115 - }, 30 * 1000 128 + }, 30 * 1000 // 30 seconds 116 129 ); 117 130 } 118 131 } ··· 120 133 private static void tpaAccept(ServerPlayer FromPlayer, ServerPlayer ToPlayer) { 121 134 if (FromPlayer == ToPlayer) { 122 135 FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA),true); 136 + 123 137 } else { 124 138 Optional<tpaArrayClass> tpaStorage = tpaList.stream() 125 139 .filter(tpa -> Objects.equals(ToPlayer.getStringUUID(), tpa.InitPlayer)) ··· 127 141 .findFirst(); 128 142 129 143 if (tpaStorage.isPresent()) { 130 - if (tpaStorage.get().here) { 131 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.common.teleport", FromPlayer).withStyle(ChatFormatting.AQUA),true); 132 - ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", ToPlayer).withStyle(ChatFormatting.GREEN),true); 133 144 145 + if (tpaStorage.get().here) { 134 146 Teleporter(FromPlayer, ToPlayer.serverLevel(), ToPlayer.position()); 135 - } else { 136 - ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.common.teleport", ToPlayer).withStyle(ChatFormatting.AQUA),true); 137 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", FromPlayer).withStyle(ChatFormatting.GREEN),true); 138 147 148 + } else { 139 149 Teleporter(ToPlayer, FromPlayer.serverLevel(), FromPlayer.position()); 140 150 } 151 + 152 + FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", FromPlayer).withStyle(ChatFormatting.WHITE),true); 153 + ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", ToPlayer).withStyle(ChatFormatting.GREEN),true); 141 154 142 155 tpaList.remove(tpaStorage.get()); 143 156 } else { ··· 149 162 private static void tpaDeny(ServerPlayer FromPlayer, ServerPlayer ToPlayer) { 150 163 if (FromPlayer == ToPlayer) { 151 164 FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA),true); 165 + 152 166 } else { 153 167 Optional<tpaArrayClass> tpaStorage = tpaList.stream() 154 168 .filter(tpa -> Objects.equals(ToPlayer.getStringUUID(), tpa.InitPlayer)) ··· 158 172 if (tpaStorage.isPresent()) { 159 173 tpaList.remove(tpaStorage.get()); 160 174 161 - if (tpaStorage.get().here) { 162 - ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.denied", ToPlayer).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); 163 - } else { 164 - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.denied", FromPlayer).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); 165 - } 175 + ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.denied", ToPlayer).withStyle(ChatFormatting.RED, ChatFormatting.BOLD),true); 176 + FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.denied", FromPlayer).withStyle(ChatFormatting.WHITE),true); 177 + 166 178 } else { 167 179 FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.notFound", FromPlayer).withStyle(ChatFormatting.RED),true); 168 180 }
+14 -14
common/src/main/java/dev/mrsnowy/teleport_commands/storage/StorageManager.java
··· 48 48 StorageClass storage = StorageRetriever(); 49 49 // Optional<StorageClass.Player> playerStorage = GetPlayerStorage(UUID, storage); 50 50 Optional<StorageClass.Player> playerStorage = storage.Players.stream() 51 - .filter(player -> Objects.equals(UUID, player.Player_UUID)) 51 + .filter(player -> Objects.equals(UUID, player.UUID)) 52 52 .findFirst(); 53 53 54 54 if (playerStorage.isEmpty()) { 55 55 StorageClass.Player newPlayer = new StorageClass.Player(); 56 56 57 - newPlayer.Player_UUID = UUID; 57 + newPlayer.UUID = UUID; 58 58 newPlayer.DefaultHome = ""; 59 59 newPlayer.deathLocation = new StorageClass.Player.Location(); 60 60 newPlayer.deathLocation.x = new StorageClass.Player.Location().x; ··· 75 75 } 76 76 77 77 public static void StorageSaver(StorageClass storage) throws Exception { 78 - Gson gson = new GsonBuilder().setPrettyPrinting().create(); 78 + Gson gson = new GsonBuilder().create(); 79 79 byte[] json = gson.toJson(storage).getBytes(); 80 80 Files.write(STORAGE_FILE, json, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); 81 81 } ··· 86 86 StorageInit(); 87 87 } 88 88 String jsonContent = Files.readString(STORAGE_FILE); 89 - Gson gson = new GsonBuilder().setPrettyPrinting().create(); 89 + Gson gson = new GsonBuilder().create(); 90 90 return gson.fromJson(jsonContent, StorageClass.class); 91 91 } 92 92 93 - public static PlayerStorageResult GetPlayerStorage(String UUID) throws Exception { 93 + public static PlayerStorageClass GetPlayerStorage(String UUID) throws Exception { 94 94 StorageClass storage = StorageRetriever(); 95 95 96 96 Optional<StorageClass.Player> playerStorage = storage.Players.stream() 97 - .filter(player -> Objects.equals(UUID, player.Player_UUID)) 97 + .filter(player -> Objects.equals(UUID, player.UUID)) 98 98 .findFirst(); 99 99 100 100 if (playerStorage.isEmpty()) { ··· 103 103 storage = StorageRetriever(); 104 104 105 105 playerStorage = storage.Players.stream() 106 - .filter(player -> Objects.equals(UUID, player.Player_UUID)) 106 + .filter(player -> Objects.equals(UUID, player.UUID)) 107 107 .findFirst(); 108 108 109 109 if (playerStorage.isEmpty()) { ··· 111 111 } 112 112 } 113 113 114 - return new PlayerStorageResult(storage, playerStorage.get()); 114 + return new PlayerStorageClass(storage, playerStorage.get()); 115 115 } 116 116 117 - public static class PlayerStorageResult { 117 + public static class PlayerStorageClass { 118 118 public StorageClass storage; 119 119 public StorageClass.Player playerStorage; 120 120 121 - public PlayerStorageResult(StorageClass storage, StorageClass.Player playerStorage) { 121 + public PlayerStorageClass(StorageClass storage, StorageClass.Player playerStorage) { 122 122 this.storage = storage; 123 123 this.playerStorage = playerStorage; 124 124 } ··· 128 128 public List<Player> Players; 129 129 130 130 public static class Player { 131 - public String Player_UUID; 131 + public String UUID; 132 132 public String DefaultHome; 133 133 public Location deathLocation; 134 134 public List<Home> Homes; 135 135 136 136 public static class Location { 137 - public double x; 138 - public double y; 139 - public double z; 137 + public int x; 138 + public int y; 139 + public int z; 140 140 public String world; 141 141 } 142 142
+2 -2
common/src/main/java/dev/mrsnowy/teleport_commands/suggestions/HomesuggestionProvider.java common/src/main/java/dev/mrsnowy/teleport_commands/suggestions/HomeSuggestionProvider.java
··· 13 13 14 14 import static dev.mrsnowy.teleport_commands.storage.StorageManager.GetPlayerStorage; 15 15 16 - public class HomesuggestionProvider implements SuggestionProvider<CommandSourceStack> { 16 + public class HomeSuggestionProvider implements SuggestionProvider<CommandSourceStack> { 17 17 @Override 18 18 public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandSourceStack> context, SuggestionsBuilder builder) { 19 19 try { 20 - ServerPlayer player = Objects.requireNonNull(context.getSource().getPlayer()); 20 + ServerPlayer player = context.getSource().getPlayerOrException(); 21 21 StorageManager.StorageClass.Player playerStorage = GetPlayerStorage(player.getStringUUID()).playerStorage; 22 22 23 23 for (StorageManager.StorageClass.Player.Home currenthome : playerStorage.Homes) {
+43
common/src/main/java/dev/mrsnowy/teleport_commands/suggestions/tpaSuggestionProvider.java
··· 1 + package dev.mrsnowy.teleport_commands.suggestions; 2 + 3 + import com.mojang.brigadier.context.CommandContext; 4 + import com.mojang.brigadier.suggestion.SuggestionProvider; 5 + import com.mojang.brigadier.suggestion.Suggestions; 6 + import com.mojang.brigadier.suggestion.SuggestionsBuilder; 7 + import dev.mrsnowy.teleport_commands.TeleportCommands; 8 + import dev.mrsnowy.teleport_commands.commands.tpa; 9 + 10 + import net.minecraft.commands.CommandSourceStack; 11 + import net.minecraft.server.level.ServerPlayer; 12 + 13 + import java.util.*; 14 + import java.util.concurrent.CompletableFuture; 15 + 16 + 17 + public class tpaSuggestionProvider implements SuggestionProvider<CommandSourceStack> { 18 + @Override 19 + public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandSourceStack> context, SuggestionsBuilder builder) { 20 + try { 21 + ServerPlayer player = context.getSource().getPlayerOrException(); 22 + 23 + List<tpa.tpaArrayClass> playerTpaList = tpa.tpaList.stream() 24 + .filter(tpa -> Objects.equals(player.getStringUUID(), tpa.RecPlayer)) 25 + .toList(); 26 + 27 + for (tpa.tpaArrayClass tpaEntry : playerTpaList) { 28 + 29 + Optional<String> recPlayerName = Optional.ofNullable(context.getSource().getServer().getPlayerList().getPlayer(UUID.fromString(tpaEntry.InitPlayer)).getName().tryCollapseToString()); 30 + 31 + if (recPlayerName.isPresent()) { 32 + builder.suggest(recPlayerName.get()); 33 + } 34 + } 35 + 36 + // Build and return the suggestions 37 + return builder.buildFuture(); 38 + } catch (Exception e) { 39 + TeleportCommands.LOGGER.error("Error getting suggestions!"); 40 + return null; 41 + } 42 + } 43 + }
+126 -16
common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java
··· 1 1 package dev.mrsnowy.teleport_commands.utils; 2 2 3 + import com.mojang.datafixers.util.Pair; 3 4 import dev.mrsnowy.teleport_commands.TeleportCommands; 4 5 import dev.mrsnowy.teleport_commands.storage.StorageManager; 5 6 6 7 import java.io.*; 7 8 import java.util.*; 9 + import java.util.regex.Matcher; 10 + import java.util.regex.Pattern; 8 11 12 + import net.minecraft.ChatFormatting; 13 + import net.minecraft.core.BlockPos; 9 14 import net.minecraft.core.particles.ParticleTypes; 10 15 import net.minecraft.network.chat.Component; 11 16 import net.minecraft.network.chat.MutableComponent; ··· 24 29 25 30 public class tools { 26 31 32 + private static final Set<String> unsafeCollisionFreeBlocks = Set.of("block.minecraft.lava", "block.minecraft.flowing_lava", "block.minecraft.end_portal", "block.minecraft.end_gateway","block.minecraft.fire", "block.minecraft.soul_fire", "block.minecraft.powder_snow", "block.minecraft.nether_portal"); 33 + 27 34 public static void Teleporter(ServerPlayer player, ServerLevel world, Vec3 coords) { 28 35 world.sendParticles(ParticleTypes.SNOWFLAKE, player.getX(), player.getY() + 1, player.getZ(), 20, 0.0D, 0.0D, 0.0D, 0.01); 29 36 world.sendParticles(ParticleTypes.WHITE_SMOKE, player.getX(), player.getY(), player.getZ(), 15, 0.0D, 1.0D, 0.0D, 0.03); ··· 50 57 world.sendParticles(ParticleTypes.SNOWFLAKE, player.getX(), player.getY() , player.getZ(), 20, 0.0D, 1.0D, 0.0D, 0.01); 51 58 world.sendParticles(ParticleTypes.WHITE_SMOKE, player.getX(), player.getY(), player.getZ(), 15, 0.0D, 0.0D, 0.0D, 0.03); 52 59 } 53 - }, 100 // hopefully good, 2 ticks 60 + }, 100 // hopefully good, ~ 2 ticks 54 61 ); 55 62 } 56 63 57 64 58 65 public static void DeathLocationUpdater(Vec3 pos, ServerLevel world, String UUID) throws Exception { 59 - StorageManager.PlayerStorageResult storages = GetPlayerStorage(UUID); 66 + StorageManager.PlayerStorageClass storages = GetPlayerStorage(UUID); 60 67 61 68 StorageManager.StorageClass storage = storages.storage; 62 69 StorageManager.StorageClass.Player playerStorage = storages.playerStorage; 63 70 64 - playerStorage.deathLocation.x = Double.parseDouble(String.format("%.1f", pos.x())); 65 - playerStorage.deathLocation.y = Double.parseDouble(String.format("%.1f", pos.y())); 66 - playerStorage.deathLocation.z = Double.parseDouble(String.format("%.1f", pos.z())); 71 + // to ensure compatibility with older versions we cast it to double 72 + playerStorage.deathLocation.x = (int) Math.round(pos.x()); 73 + playerStorage.deathLocation.y = (int) Math.round(pos.y()); 74 + playerStorage.deathLocation.z = (int) Math.round(pos.z()); 75 + 67 76 playerStorage.deathLocation.world = world.dimension().location().toString(); 68 77 69 78 StorageSaver(storage); 70 79 } 71 80 81 + 82 + public static Pair<Integer, Optional<Vec3>> teleportSafetyChecker(int playerX, int playerY, int playerZ, ServerLevel world, ServerPlayer player) { 83 + int row = 1; 84 + int rows = 3; 85 + 86 + // find a safe location in an x row radius 87 + if (isBlockPosUnsafe(new BlockPos(playerX, playerY, playerZ), world)) { 88 + 89 + while (row <= rows) { 90 + // TeleportCommands.LOGGER.info("currently doing row " + row + " of " + rows); //debug 91 + 92 + for (int z = -row; z <= row; z++) { 93 + for (int x = -row; x <= row; x++) { 94 + for (int y = -row; y <= row; y++) { 95 + 96 + if ((x == -row || x == row) || (z == -row || z == row) || (y == -row || y == row)) { 97 + if (!isBlockPosUnsafe(new BlockPos(playerX + x, playerY + y, playerZ + z), world)) { 98 + 99 + Vec3 toTeleportTo = new Vec3(playerX + x + 0.5, playerY + y, playerZ + z + 0.5); 100 + 101 + if (!player.getPosition(0).equals(toTeleportTo) || player.level() != world) { 102 + return new Pair<>(0, Optional.of(toTeleportTo)); // safe! 103 + 104 + } else { 105 + return new Pair<>(1, Optional.empty()); // same 106 + } 107 + } 108 + } 109 + } 110 + } 111 + } 112 + 113 + row++; 114 + } 115 + 116 + // no safe location 117 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.noSafeLocation", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), false); 118 + player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.safetyIsForLosers", player).withStyle(ChatFormatting.AQUA), false); 119 + 120 + return new Pair<>(2, Optional.empty()); // no safe location 121 + } else { 122 + return new Pair<>(0, Optional.of(new Vec3(playerX + 0.5, playerY, playerZ + 0.5))); // safe! 123 + } 124 + } 125 + 126 + 127 + 72 128 // Gets the translated text for each player based on their language, this is fully server side and actually works (UNLIKE MOJANG'S TRANSLATED KEY'S WHICH ARE CLIENT SIDE) 73 - public static MutableComponent getTranslatedText(String key, ServerPlayer player, Object... args) { 129 + public static MutableComponent getTranslatedText(String key, ServerPlayer player, MutableComponent... args) { 74 130 String language = player.clientInformation().language(); 131 + String regex = "%(\\d+)%"; 132 + Pattern pattern = Pattern.compile(regex); 75 133 134 + // the try catch stuff is so wacky, but it works fine and I don't need to check everything 76 135 try { 77 136 String filePath = String.format("/assets/%s/lang/%s.toml", MOD_ID, language); 78 137 InputStream stream = TeleportCommands.class.getResourceAsStream(filePath); 79 138 80 - assert stream != null; 81 - TomlParseResult toml = Toml.parse(stream); 139 + TomlParseResult toml = Toml.parse(Objects.requireNonNull(stream)); 82 140 String translation = toml.getString(key); 83 141 84 - assert translation != null; 85 - return Component.literal(String.format(translation, args)); 142 + Matcher matcher = pattern.matcher(Objects.requireNonNull(translation)); 86 143 87 - } catch (Exception ignored) { 144 + MutableComponent component = Component.literal(""); 145 + int lastIndex = 0; 146 + 147 + while (matcher.find()) { 148 + component.append(Component.literal(translation.substring(lastIndex, matcher.start()))); 149 + 150 + int index = Integer.parseInt(matcher.group(1)); 151 + component.append(args[index]); 152 + 153 + lastIndex = matcher.end(); 154 + } 155 + component.append(translation.substring(lastIndex)); 156 + 157 + return component; 158 + 159 + } catch (Exception e) { 160 + TeleportCommands.LOGGER.error(e.toString()); 88 161 try { 89 162 if (!Objects.equals(language, "en_us")) { 90 - TeleportCommands.LOGGER.warn("Key \"{}\" not found in the language: {}, falling back to default (en_us)", key, language); 163 + // TeleportCommands.LOGGER.warn("Key \"{}\" not found in the language: {}, falling back to default (en_us)", key, language); 91 164 92 165 String filePath = String.format("/assets/%s/lang/en_us.toml", MOD_ID); 93 166 InputStream stream = TeleportCommands.class.getResourceAsStream(filePath); 94 167 95 - assert stream != null; 96 - TomlParseResult toml = Toml.parse(stream); 168 + TomlParseResult toml = Toml.parse(Objects.requireNonNull(stream)); 97 169 String translation = toml.getString(key); 98 170 99 - assert translation != null; 100 - return Component.literal(String.format(translation, args)); 171 + Matcher matcher = pattern.matcher(Objects.requireNonNull(translation)); 172 + 173 + MutableComponent component = Component.literal(""); 174 + int lastIndex = 0; 175 + 176 + while (matcher.find()) { 177 + component.append(Component.literal(translation.substring(lastIndex, matcher.start()))); 178 + 179 + int index = Integer.parseInt(matcher.group(1)); 180 + component.append(args[index]); 181 + 182 + lastIndex = matcher.end(); 183 + } 184 + component.append(translation.substring(lastIndex)); 185 + 186 + return component; 101 187 } 102 188 } catch (Exception ignored1) {} 103 189 TeleportCommands.LOGGER.error("Key \"{}\" not found in the default language (en_us), sending raw key as fallback.", key); 104 190 return Component.literal(key); 105 191 } 192 + } 193 + 194 + 195 + private static boolean isBlockPosUnsafe(BlockPos bottomPlayer, ServerLevel world) { 196 + // bottomPlayer is presumed to be the bottom of the player character 197 + 198 + BlockPos belowPlayer = new BlockPos(bottomPlayer.getX(), bottomPlayer.getY() -1, bottomPlayer.getZ()); // below the player 199 + String belowPlayerId = world.getBlockState(belowPlayer).getBlock().getDescriptionId(); // below the player 200 + 201 + String BottomPlayerId = world.getBlockState(bottomPlayer).getBlock().getDescriptionId(); // bottom of player 202 + 203 + BlockPos TopPlayer = new BlockPos(bottomPlayer.getX(), bottomPlayer.getY() + 1, bottomPlayer.getZ()); // top of player 204 + String TopPlayerId = world.getBlockState(TopPlayer).getBlock().getDescriptionId(); // top of player 205 + 206 + 207 + // check if the death location isn't safe 208 + if ( 209 + (belowPlayerId.equals("block.minecraft.water") || !world.getBlockState(belowPlayer).getCollisionShape(world, belowPlayer).isEmpty()) // check if the player is going to fall on teleport 210 + && (world.getBlockState(bottomPlayer).getCollisionShape(world, bottomPlayer).isEmpty() && !unsafeCollisionFreeBlocks.contains(BottomPlayerId)) // check if it is a collision free block, that isn't dangerous 211 + && (!unsafeCollisionFreeBlocks.contains(TopPlayerId)) // check if it is a dangerous collision free block, if it is solid then the player crawls 212 + ){ 213 + return false; // it's safe 214 + } 215 + return true; // it's not safe! 106 216 } 107 217 }
+18 -13
common/src/main/resources/assets/teleport_commands/lang/en_us.toml
··· 1 - #back 2 - commands.teleport_commands.back.error = "Error Teleporting!" 1 + # back 2 + commands.teleport_commands.back.go = "Going Back" 3 3 commands.teleport_commands.back.same = "Already Back" 4 4 commands.teleport_commands.back.noLocation = "No Location Found!" 5 5 6 - #home 6 + # home 7 7 commands.teleport_commands.home.set = "Home Set" 8 8 commands.teleport_commands.home.setError = "Error Setting Home!" 9 9 commands.teleport_commands.home.go = "Going Home" ··· 23 23 24 24 # homes 25 25 commands.teleport_commands.homes.error = "Error Getting Homes!" 26 - commands.teleport_commands.homes.homes = "Homes: \n" 27 - commands.teleport_commands.homes.default = " (Default)" 28 - commands.teleport_commands.homes.tp = " [Tp]" 29 - commands.teleport_commands.homes.rename = " [Rename]" 30 - commands.teleport_commands.homes.delete = " [Delete]\n" 26 + commands.teleport_commands.homes.homes = "Homes:" 27 + commands.teleport_commands.homes.default = "(Default)" 28 + commands.teleport_commands.homes.tp = "[Tp]" 29 + commands.teleport_commands.homes.rename = "[Rename]" 30 + commands.teleport_commands.homes.delete = "[Delete]" 31 31 32 32 # tpa 33 33 commands.teleport_commands.tpa.self = "Well, that was easy" 34 - commands.teleport_commands.tpa.received = "Tpa%s Request Received From " 35 - commands.teleport_commands.tpa.sent = "Tpa%s Request Sent to " 36 - commands.teleport_commands.tpa.accept = "\n[Accept]" 34 + commands.teleport_commands.tpa.alreadySent = "A request has already been sent to %0%" 35 + commands.teleport_commands.tpa.received = "Tpa%0% Request Received From %1%" 36 + commands.teleport_commands.tpa.sent = "Tpa%0% Request Sent to %1%" 37 + commands.teleport_commands.tpa.accept = "[Accept]" 37 38 commands.teleport_commands.tpa.deny = " [Deny]" 38 - commands.teleport_commands.tpa.expired = "Tpa%s Request Expired" 39 + commands.teleport_commands.tpa.expired = "Tpa%0% Request Expired" 39 40 commands.teleport_commands.tpa.notFound = "No Requests found!" 40 41 commands.teleport_commands.tpa.accepted = "Request Accepted" 41 42 commands.teleport_commands.tpa.denied = "Request Denied" 42 43 43 44 # common 44 - commands.teleport_commands.common.teleport = "Teleporting" 45 + commands.teleport_commands.common.teleport = "Teleporting" 46 + commands.teleport_commands.common.error = "Error Teleporting!" 47 + commands.teleport_commands.common.noSafeLocation = "No Safe Location Found!" 48 + commands.teleport_commands.common.safetyIsForLosers = "Teleport anyways? (Warning, you might die!)" 49 + commands.teleport_commands.common.forceTeleport = "[Force Teleport]"
+50
common/src/main/resources/assets/teleport_commands/lang/hu_hu.toml
··· 1 + # back 2 + commands.teleport_commands.back.go = "Indulás vissza" 3 + commands.teleport_commands.back.same = "Vissza" 4 + commands.teleport_commands.back.noLocation = "Nem található a koordináta" 5 + 6 + # home 7 + commands.teleport_commands.home.set = "Otthon beállítása" 8 + commands.teleport_commands.home.setError = "Hiba történt az otthon beállításával!" 9 + commands.teleport_commands.home.go = "Indulás haza!" 10 + commands.teleport_commands.home.goError = "Hiba történt az otthonnal!" 11 + commands.teleport_commands.home.goSame = "Otthon, édes otthon" 12 + commands.teleport_commands.home.delete = "Otthon törölve" 13 + commands.teleport_commands.home.deleteError = "Hiba történt az otthon rökésével!" 14 + commands.teleport_commands.home.rename = "Otthon átnevezve" 15 + commands.teleport_commands.home.renameError = "Hiba történt az otthon átnevezésével!" 16 + commands.teleport_commands.home.renameExists = "A név már létezik!" 17 + commands.teleport_commands.home.default = "Alap otthon beállítva" 18 + commands.teleport_commands.home.defaultError = "Hiba történt az alap otthon beállításával!" 19 + commands.teleport_commands.home.defaultSame = "Már alap ez az otthon!" 20 + commands.teleport_commands.home.notFound = "Otthon nem találva!" 21 + commands.teleport_commands.home.exists = "Az otthon már létezik!" 22 + commands.teleport_commands.home.homeless = "Nincs otthonod!" 23 + 24 + # homes 25 + commands.teleport_commands.homes.error = "Hiba történt az otthonok megtalálásával!" 26 + commands.teleport_commands.homes.homes = "Otthonol:" 27 + commands.teleport_commands.homes.default = "(Alap)" 28 + commands.teleport_commands.homes.tp = "[Tp]" 29 + commands.teleport_commands.homes.rename = "[Átnevezés]" 30 + commands.teleport_commands.homes.delete = "[Törlés]" 31 + 32 + # tpa 33 + commands.teleport_commands.tpa.self = "Hát ez gyors volt" 34 + commands.teleport_commands.tpa.alreadySent = "Egy kérés már el lett küldve %0%-nek" 35 + commands.teleport_commands.tpa.received = "Tpa%0% kérés megkapva %1%-től" 36 + commands.teleport_commands.tpa.sent = "tpa%0% kérés elküldve %1%-nek" 37 + commands.teleport_commands.tpa.accept = "[Elfogadás]" 38 + commands.teleport_commands.tpa.deny = " [Elutasítás]" 39 + commands.teleport_commands.tpa.expired = "Tpa%0% kérés lejárt" 40 + commands.teleport_commands.tpa.notFound = "Semmi kérésed sincsen!" 41 + commands.teleport_commands.tpa.accepted = "Elfogadva" 42 + commands.teleport_commands.tpa.denied = "Elutasítva" 43 + 44 + # common 45 + commands.teleport_commands.common.teleport = "Utazás" 46 + commands.teleport_commands.common.error = "Hiba történt a teleportálással!" 47 + 48 + commands.teleport_commands.common.noSafeLocation = "No Safe Location Found!" 49 + commands.teleport_commands.common.safetyIsForLosers = "Teleport anyways? (Warning, you might die!)" 50 + commands.teleport_commands.common.forceTeleport = "[Force Teleport]"
+49
common/src/main/resources/assets/teleport_commands/lang/nl_nl.toml
··· 1 + # back 2 + commands.teleport_commands.back.go = "Terug gaan" 3 + commands.teleport_commands.back.same = "Al Terug" 4 + commands.teleport_commands.back.noLocation = "Geen Locatie Gevonden!" 5 + 6 + # home 7 + commands.teleport_commands.home.set = "Huis Ingesteld" 8 + commands.teleport_commands.home.setError = "Probleem Met Het Huis Instellen!" 9 + commands.teleport_commands.home.go = "Naar Huis" 10 + commands.teleport_commands.home.goError = "Probleem Met Naar Huis Gaan!" 11 + commands.teleport_commands.home.goSame = "Al Thuis" 12 + commands.teleport_commands.home.delete = "Huis Verwijderd" 13 + commands.teleport_commands.home.deleteError = "Probleem Met Het Verwijderen Van Het Huis!" 14 + commands.teleport_commands.home.rename = "Huis Hernoemd" 15 + commands.teleport_commands.home.renameError = "Probleem Met Het Huis Hernamen!" 16 + commands.teleport_commands.home.renameExists = "Die Naam Bestaat Al!" 17 + commands.teleport_commands.home.default = "Standaard Huis Ingesteld" 18 + commands.teleport_commands.home.defaultError = "Probleem Tijdens Het Wijzigen Van Het Standaard Huis!" 19 + commands.teleport_commands.home.defaultSame = "Huis is al als standaard ingesteld!" 20 + commands.teleport_commands.home.notFound = "Huis Niet Gevonden!" 21 + commands.teleport_commands.home.exists = "Dat huis bestaad Al!" 22 + commands.teleport_commands.home.homeless = "Je Hebt Geen Huizen!" 23 + 24 + # homes 25 + commands.teleport_commands.homes.error = "Probleem Bij Het Ophalen Van De Huizen!" 26 + commands.teleport_commands.homes.homes = "Huizen:" 27 + commands.teleport_commands.homes.default = "(Standaard)" 28 + commands.teleport_commands.homes.tp = "[Tp]" 29 + commands.teleport_commands.homes.rename = "[Naam Wijzigen]" 30 + commands.teleport_commands.homes.delete = "[Verwijderen]" 31 + 32 + # tpa 33 + commands.teleport_commands.tpa.self = "Welp, Dat Was Makkelijk" 34 + commands.teleport_commands.tpa.alreadySent = "Er is al een verzoek verzonden naar %0%" 35 + commands.teleport_commands.tpa.received = "Tpa%0% Verzoek Ontvangen Van %1%" 36 + commands.teleport_commands.tpa.sent = "Tpa%0% Verzoek Verzonden Naar %1%" 37 + commands.teleport_commands.tpa.accept = "[Accepteren]" 38 + commands.teleport_commands.tpa.deny = " [Weigeren]" 39 + commands.teleport_commands.tpa.expired = "Tpa%0% Verzoek Verlopen" 40 + commands.teleport_commands.tpa.notFound = "Geen Verzoeken Gevonden!" 41 + commands.teleport_commands.tpa.accepted = "Verzoek Geaccepteerd" 42 + commands.teleport_commands.tpa.denied = "Verzoek Geweigerd" 43 + 44 + # common 45 + commands.teleport_commands.common.teleport = "Teleporteren" 46 + commands.teleport_commands.common.error = "Probleem tijdens het Teleporteren!" 47 + commands.teleport_commands.common.noSafeLocation = "Geen veilige locatie gevonden!" 48 + commands.teleport_commands.common.safetyIsForLosers = "Toch teleporteren? (Waarschuwing, je kan dood gaan!)" 49 + commands.teleport_commands.common.forceTeleport = "[Geforceerd Teleporteren]"
+26
common/src/main/resources/assets/teleport_commands/lang/translations.md
··· 1 + ### Translations 2 + Heya! here is some information about how you can make a translation or modify an existing translation! 3 + 4 + I also want to thank everyone who made a translation for this mod! This makes the mod more accessible for everyone. 5 + 6 + Things to know: 7 + - The "%number%" are placeholders, The number indicates what it needs to be replaced with. 8 + - funny things are allowed, as long as they don't make the mod less accessible or cluttered! 9 + 10 + #### Want to make a translation? 11 + 1. Make a fork of the mod 12 + 2. Go [here](https://minecraft.wiki/w/Language) and pick the in-game locale code for the language you want to translate 13 + 3. Copy `en_us.toml` and paste it in a new file called `[in-game locale code here].toml` 14 + 4. Translate the values (everything between " ") in the file 15 + 5. Submit a pull request with your translation :D! 16 + 17 + #### Want to improve an existing translation? 18 + 1. Make a fork of the mod 19 + 2. Modify the existing translation in the mod 20 + 3. Submit a pull request with your changes :D! 21 + 22 + 23 + #### Credits 24 + - English (en_us): [Mr. Snowy](https://github.com/MrSn0wy) 25 + - Dutch (nl_nl): [Mr. Snowy](https://github.com/MrSn0wy) 26 + - Hungarian (hu_hu): [Martin Morningstar](https://github.com/RMI637)
+1 -3
fabric/build.gradle
··· 7 7 minecraft "com.mojang:minecraft:${minecraft_version}" 8 8 mappings loom.layered() { 9 9 officialMojangMappings() 10 - parchment("org.parchmentmc.data:parchment-${parchment_mappings}@zip") 10 + // parchment("org.parchmentmc.data:parchment-${parchment_mappings}@zip") 11 11 } 12 12 modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" 13 13 // modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api}" 14 - 15 - implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1' 16 14 } 17 15 18 16 loom {
+2 -2
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.0.5 5 + version=1.1.0-beta 6 6 group=dev.mrsnowy.teleport_commands 7 7 java_version=17 8 8 ··· 33 33 neoforge_loader_version_range=[2,) 34 34 35 35 # Gradle 36 - org.gradle.jvmargs=-Xmx3G 36 + org.gradle.jvmargs=-Xmx4G 37 37 org.gradle.daemon=false
-4
settings.gradle
··· 17 17 name = 'Sponge Snapshots' 18 18 url = uri("https://repo.spongepowered.org/repository/maven-public") 19 19 } 20 - maven { 21 - name = 'ParchmentMC' 22 - url = 'https://maven.parchmentmc.org' 23 - } 24 20 } 25 21 } 26 22