diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,12 +24,10 @@ uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} distribution: temurin - - name: make gradle wrapper executable - run: chmod +x ./gradlew + cache: 'gradle' - name: build - run: ./gradlew shadowJar + run: chmod +x ./gradlew && ./gradlew build - name: capture build artifacts -# if: ${{ matrix.java == '17' }} # Only upload artifacts built from latest java uses: actions/upload-artifact@v4 with: name: Artifacts diff --git a/CHANGELOG.md b/CHANGELOG.md --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,30 +5,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -### [Unreleased] - -### [Planned for 1.2.0] - -- Add a Config System -- Add `/spawn` -- Add `/wild` -- Add `/worldspawn` - - -### [v1.1.0-beta] +### [v1.1.0] #### Added - Added a completely server-side translation system (UNLIKE MOJANG'S SYSTEM WHICH IS CLIENT SIDE) - Added a Json Storage cleaner, which automatically cleans and updates any values -- Added a safety check with /back that automatically chooses a nearby safe location +- Added a safety check with `/back` and `/tpa[here]` that automatically chooses a nearby safe location - Added quilt support - Added a CHANGELOG.md - Added Tpa Accept/Deny Suggestions - Added Dutch translations - Added Hungarian translations (Thanks to [Martin Morningstar](https://github.com/RMI637)) - #### Changed - Limited the requests a player can do to the same player to 1 - Improved command messages and colors @@ -38,12 +27,18 @@ - Fixed /back giving an error when the player didn't have a deathLocation, instead of the appropriate message - Improved performance by changing the death event to be player specific (not all entities) - Replaced all loader specific api events with Mixins - Edited /back to have a DisableSafety option: `/back []` +- Improved /back and /home `Already there` detection #### Removed - Removed Sources and Javadoc files to improve build speed - Removed Fabric API dependency - Removed pretty json printing (to save storage) +#### Breaking changes (non-backwards compatible) +- Replaced `Player_UUID` in the storage json to `UUID` +- Changed Death location coords in the storage json from `double` to `int` +- Changed Home coords in the storage json from `double` to `int` +- ### [v1.0.5] diff --git a/build.gradle b/build.gradle --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,4 @@ plugins { // Required for NeoGradle id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7" - // Required to bundle the toml library - id 'com.github.johnrengelman.shadow' version '8.1.1' } \ No newline at end of file diff --git a/buildSrc/src/main/groovy/multiloader-common.gradle b/buildSrc/src/main/groovy/multiloader-common.gradle --- a/buildSrc/src/main/groovy/multiloader-common.gradle +++ b/buildSrc/src/main/groovy/multiloader-common.gradle @@ -1,6 +1,5 @@ plugins { id 'java-library' - id 'com.github.johnrengelman.shadow' } base { @@ -23,7 +22,6 @@ } dependencies { implementation 'org.jetbrains:annotations:24.1.0' - implementation 'org.tomlj:tomlj:1.1.1' } // Declare capabilities on the outgoing configurations. @@ -38,7 +36,8 @@ // suppressPomMetadataWarningsFor(variant) // } } -shadowJar { + +jar { from(rootProject.file("LICENSE")) { rename { "${it}_${mod_name}" } } @@ -54,13 +53,6 @@ 'Implementation-Vendor' : mod_author, 'Built-On-Minecraft' : minecraft_version ]) } - - dependencies { - include(dependency('org.tomlj:tomlj:1.1.1')) - relocate 'org.tomlj', "dev.mrsnowy.tomlj_${mod_id}" - } - - exclude('mappings/**') } processResources { @@ -69,15 +61,14 @@ "version": version, "group": project.group, //Else we target the task's group. "minecraft_version": minecraft_version, "minecraft_version_range": minecraft_version_range, - "parchment_mappings": parchment_mappings, // "fabric_api": fabric_api, "fabric_loader_version": fabric_loader_version, "fabric_loom": fabric_loom, "neoforge_version": neoforge_version, "neoforge_loader_version_range": neoforge_loader_version_range, - "quilt_loader_version": quilt_loader_version, - "quilt_fabric_api": quilt_fabric_api, - "quilt_loom": quilt_loom, +// "quilt_loader_version": quilt_loader_version, +// "quilt_fabric_api": quilt_fabric_api, +// "quilt_loom": quilt_loom, "mod_name": mod_name, "mod_author": mod_author, "mod_id": mod_id, diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/TeleportCommands.java b/common/src/main/java/dev/mrsnowy/teleport_commands/TeleportCommands.java --- a/common/src/main/java/dev/mrsnowy/teleport_commands/TeleportCommands.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/TeleportCommands.java @@ -4,6 +4,7 @@ import com.google.gson.*; import dev.mrsnowy.teleport_commands.storage.StorageManager; import dev.mrsnowy.teleport_commands.commands.*; import net.minecraft.commands.Commands; +import net.minecraft.core.BlockPos; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.storage.LevelResource; @@ -26,7 +27,6 @@ public static final Logger LOGGER = LoggerFactory.getLogger(MOD_NAME); public static String MOD_LOADER; public static Path SAVE_DIR; public static Path CONFIG_DIR; -// public static MinecraftServer Server; // Gets ran when the server starts @@ -39,8 +39,6 @@ // Construct the game directory path CONFIG_DIR = Paths.get(System.getProperty("user.dir")).resolve("config"); -// Server = server; - cleanStorage(); // initialize commands, also allows me to easily disable any when there is a config @@ -53,7 +51,7 @@ public static void onPlayerDeath(ServerPlayer player) { try { // update /back command position - DeathLocationUpdater(player.position(), player.serverLevel(), player.getStringUUID()); + DeathLocationUpdater(new BlockPos(player.getBlockX(), player.getBlockY(), player.getBlockZ()), player.serverLevel(), player.getStringUUID()); } catch (Exception e) { LOGGER.error(e.toString()); @@ -65,10 +63,11 @@ private static void cleanStorage() { LOGGER.info("Cleaning and updating Storage!"); try { StorageManager.StorageInit(); + long startFileSize = Files.size(StorageManager.STORAGE_FILE); + FileReader reader = new FileReader(StorageManager.STORAGE_FILE.toString()); JsonElement jsonElement = JsonParser.parseReader(reader); - boolean done = false; if (jsonElement.isJsonObject()) { JsonObject mainJsonObject = jsonElement.getAsJsonObject(); @@ -80,7 +79,6 @@ JsonArray newPlayersArray = new JsonArray(); // players for (JsonElement playerElement : mainJsonObject.get("Players").getAsJsonArray()) { - System.out.println("Element: " + playerElement); // player if (playerElement.isJsonObject()) { @@ -109,7 +107,7 @@ JsonArray homes = new JsonArray(); if (player.has("Homes") && player.get("Homes").isJsonArray() ) { JsonArray tempHomes = player.get("Homes").getAsJsonArray(); - boolean defaultFound = false; + boolean defaultHomeFound = false; for (JsonElement homeElement : tempHomes) { @@ -119,25 +117,25 @@ String homeName = home.has("name") ? home.get("name").getAsString() : ""; - Double homeX = home.has("x") - ? home.get("x").getAsDouble() : null; + // upgrade doubles to int + Integer homeX = home.has("x") && home.get("x").isJsonPrimitive() && home.get("x").getAsJsonPrimitive().isNumber() + ? (int) Math.floor(home.get("x").getAsDouble()) : null; - Double homeY = home.has("y") - ? home.get("y").getAsDouble() : null; + Integer homeY = home.has("y") && home.get("y").isJsonPrimitive() && home.get("y").getAsJsonPrimitive().isNumber() + ? (int) Math.floor(home.get("y").getAsDouble()) : null; - Double homeZ = home.has("z") - ? home.get("z").getAsDouble() : null; + Integer homeZ = home.has("z") && home.get("z").isJsonPrimitive() && home.get("z").getAsJsonPrimitive().isNumber() + ? (int) Math.floor(home.get("z").getAsDouble()) : null; String homeWorld = home.has("world") ? home.get("world").getAsString() : ""; - // check if it is valid if (!homeName.isBlank() && !homeWorld.isBlank() && homeX != null && homeY != null && homeZ != null) { // check if it is the default home if (!DefaultHome.isBlank() && homeName.equals(DefaultHome)) { - defaultFound = true; + defaultHomeFound = true; } JsonObject newHome = new JsonObject(); @@ -155,7 +153,7 @@ } } // clean DefaultHome if there is no home with the name - if (!defaultFound) { + if (!defaultHomeFound) { DefaultHome = ""; } } @@ -182,6 +180,10 @@ Gson gson = new GsonBuilder().create(); byte[] json = gson.toJson(mainJsonObject).getBytes(); Files.write(StorageManager.STORAGE_FILE, json, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); + + long endFileSize = Files.size(StorageManager.STORAGE_FILE); + + LOGGER.info("Success! Cleaned: " + Math.round((startFileSize - endFileSize)) + "B"); } } diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/back.java b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/back.java --- a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/back.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/back.java @@ -7,18 +7,13 @@ import dev.mrsnowy.teleport_commands.storage.StorageManager; import java.util.*; -import dev.mrsnowy.teleport_commands.suggestions.HomeSuggestionProvider; import net.minecraft.ChatFormatting; import net.minecraft.commands.Commands; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.ClickEvent; -import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.phys.Vec3; -import org.tomlj.Toml; - -import javax.swing.text.html.Option; import static dev.mrsnowy.teleport_commands.storage.StorageManager.GetPlayerStorage; import static dev.mrsnowy.teleport_commands.utils.tools.*; @@ -29,7 +24,7 @@ public static void register(Commands commandManager) { commandManager.getDispatcher().register(Commands.literal("back").executes(context -> { - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); try { ToDeathLocation(player, false); @@ -43,7 +38,7 @@ return 0; }) .then(argument("Disable Safety", BoolArgumentType.bool()).executes(context -> { final boolean safety = BoolArgumentType.getBool(context, "Disable Safety"); - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); try { ToDeathLocation(player, safety); @@ -56,21 +51,7 @@ } return 0; })) ); - - commandManager.getDispatcher().register(Commands.literal("test").executes(context -> { - ServerPlayer player = context.getSource().getPlayerOrException(); - - - player.displayClientMessage(Component.literal("Yellow").withStyle(ChatFormatting.YELLOW, ChatFormatting.BOLD), true); - TeleportCommands.LOGGER.info("Yellow info"); - TeleportCommands.LOGGER.warn("Yellow warn"); - TeleportCommands.LOGGER.error("Yellow error"); - TeleportCommands.LOGGER.error(String.valueOf(Toml.parse("commands.teleport_commands.back.go = \"Going Back\""))); - Toml.parse("commands.teleport_commands.back.go = \"Going Back\""); - return 0; - })); } - private static void ToDeathLocation(ServerPlayer player, boolean safetyDisabled) throws Exception { @@ -81,27 +62,23 @@ if (playerStorage.deathLocation == null) { player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.noLocation", player).withStyle(ChatFormatting.RED), true); } else { - final Vec3 pos = new Vec3(playerStorage.deathLocation.x, playerStorage.deathLocation.y, playerStorage.deathLocation.z); + final BlockPos pos = new BlockPos(playerStorage.deathLocation.x, playerStorage.deathLocation.y, playerStorage.deathLocation.z); boolean found = false; for (ServerLevel currentWorld : Objects.requireNonNull(player.getServer()).getAllLevels()) { if (Objects.equals(currentWorld.dimension().location().toString(), playerStorage.deathLocation.world)) { - int playerX = (int) pos.x; - int playerY = (int) pos.y; - int playerZ = (int) pos.z; - // check if the death location isn't safe and that safety isn't enabled if (!safetyDisabled) { - Pair> silly = teleportSafetyChecker(playerX, playerY, playerZ, currentWorld, player); + Pair> teleportData = teleportSafetyChecker(pos.getX(), pos.getY(), pos.getZ(), currentWorld, player); - switch (silly.getFirst()) { + switch (teleportData.getFirst()) { case 0: // safe! - if (silly.getSecond().isPresent()) { + if (teleportData.getSecond().isPresent()) { player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.go", player), true); - Teleporter(player, currentWorld, silly.getSecond().get()); + Teleporter(player, currentWorld, teleportData.getSecond().get()); } else { player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); } @@ -111,72 +88,20 @@ case 1: // same player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.same", player).withStyle(ChatFormatting.AQUA), true); break; case 2: // no safe location - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.forceTeleport", player) - .withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD) - .withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/back true"))) - ,false); + + player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.noSafeLocation", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), false); + player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.safetyIsForLosers", player).withStyle(ChatFormatting.AQUA), false); + player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.forceTeleport", player).withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD) + .withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/back true"))),false); break; } -// if (!safetyDisabled && isBlockPosUnsafe(new BlockPos(playerX, playerY, playerZ), currentWorld)) { -// int row = 1; -// int rows = 3; -// boolean safeLocationFound = false; -// -// // find a safe location in an x row radius -// whileLoop: -// while (row <= rows) { -//// TeleportCommands.LOGGER.info("currently doing row " + row + " of " + rows); //debug -// -// for (int z = -row; z <= row; z++) { -// for (int x = -row; x <= row; x++) { -// for (int y = -row; y <= row; y++ ) { -// -// if ((x == -row || x == row) || (z == -row || z == row) || (y == -row || y == row)) { -// if (!isBlockPosUnsafe(new BlockPos(playerX + x, playerY + y, playerZ + z), currentWorld)) { -// -// Vec3 PlayerToTeleport = new Vec3(playerX + x + 0.5, playerY + y, playerZ + z + 0.5); -// -// if (!player.getPosition(0).equals(PlayerToTeleport) || player.level() != currentWorld) { -// -// Teleporter(player, currentWorld, PlayerToTeleport); -// } else { -// -// } -// -// safeLocationFound = true; -// break whileLoop; -// } -// } -// } -// } -// } -// -// row++; -// } -// -// if (!safeLocationFound) { -// player.displayClientMessage( -// getTranslatedText("commands.teleport_commands.back.noSafeLocation", player) -// .withStyle(ChatFormatting.RED, ChatFormatting.BOLD) -// , false); -// -// player.displayClientMessage( -// getTranslatedText("commands.teleport_commands.back.safetyIsForLosers", player).withStyle(ChatFormatting.AQUA) -// .append("\n") -// .append( -// getTranslatedText("commands.teleport_commands.back.forceTeleport", player) -// .withStyle(ChatFormatting.AQUA, ChatFormatting.BOLD) -// .withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/back true"))) -// ) -// ,false); -// } - } else { - if (!player.getPosition(0).equals(pos) || player.level() != currentWorld) { + BlockPos playerBlockPos = new BlockPos(player.getBlockX(), player.getBlockY(), player.getBlockZ()); + if (!playerBlockPos.equals(pos) || player.level() != currentWorld) { player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.go", player), true); - Teleporter(player, currentWorld, new Vec3(playerX + 0.5, playerY, playerZ + 0.5)); + Teleporter(player, currentWorld, new Vec3(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5)); } else { player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.same", player).withStyle(ChatFormatting.AQUA), true); @@ -194,27 +119,4 @@ player.displayClientMessage(getTranslatedText("commands.teleport_commands.back.noLocation", player).withStyle(ChatFormatting.RED), true); } } } - -// private static boolean isBlockPosUnsafe(BlockPos bottomPlayer, ServerLevel world) { -// // bottomPlayer is presumed to be the bottom of the player character -// -// BlockPos belowPlayer = new BlockPos(bottomPlayer.getX(), bottomPlayer.getY() -1, bottomPlayer.getZ()); // below the player -// String belowPlayerId = world.getBlockState(belowPlayer).getBlock().getDescriptionId(); // below the player -// -// String BottomPlayerId = world.getBlockState(bottomPlayer).getBlock().getDescriptionId(); // bottom of player -// -// BlockPos TopPlayer = new BlockPos(bottomPlayer.getX(), bottomPlayer.getY() + 1, bottomPlayer.getZ()); // top of player -// String TopPlayerId = world.getBlockState(TopPlayer).getBlock().getDescriptionId(); // top of player -// -// -// // check if the death location isn't safe -// if ( -// (belowPlayerId.equals("block.minecraft.water") || !world.getBlockState(belowPlayer).getCollisionShape(world, belowPlayer).isEmpty()) // check if the player is gonna fall on teleport -// && (world.getBlockState(bottomPlayer).getCollisionShape(world, bottomPlayer).isEmpty() && !unsafeCollisionFreeBlocks.contains(BottomPlayerId)) // check if it is a collision free block, that isnt dangerous -// && (!unsafeCollisionFreeBlocks.contains(TopPlayerId)) // check if it is a dangerous collision free block, if it is solid then the player crawls -// ){ -// return false; // it's safe -// } -// return true; // it's not safe! -// } } diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/home.java b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/home.java --- a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/home.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/home.java @@ -7,6 +7,7 @@ import dev.mrsnowy.teleport_commands.suggestions.HomeSuggestionProvider; import java.util.Objects; import net.minecraft.ChatFormatting; import net.minecraft.commands.Commands; +import net.minecraft.core.BlockPos; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; @@ -26,7 +27,7 @@ commandManager.getDispatcher().register(Commands.literal("sethome") .then(argument("name", StringArgumentType.string()) .executes(context -> { final String name = StringArgumentType.getString(context, "name"); - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); try { SetHome(player, name); @@ -42,7 +43,7 @@ commandManager.getDispatcher().register(Commands.literal("home") .executes(context -> { - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); try { GoHome(player, ""); @@ -57,7 +58,7 @@ }) .then(argument("name", StringArgumentType.string()).suggests(new HomeSuggestionProvider()) .executes(context -> { final String name = StringArgumentType.getString(context, "name"); - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); try { GoHome(player, name); @@ -74,7 +75,7 @@ commandManager.getDispatcher().register(Commands.literal("delhome") .then(argument("name", StringArgumentType.string()).suggests(new HomeSuggestionProvider()) .executes(context -> { final String name = StringArgumentType.getString(context, "name"); - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); try { DeleteHome(player, name); @@ -93,7 +94,7 @@ .then(argument("newName", StringArgumentType.string()) .executes(context -> { final String name = StringArgumentType.getString(context, "name"); final String newName = StringArgumentType.getString(context, "newName"); - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); try { RenameHome(player, name, newName); @@ -111,7 +112,7 @@ commandManager.getDispatcher().register(Commands.literal("defaulthome") .then(argument("name", StringArgumentType.string()).suggests(new HomeSuggestionProvider()) .executes(context -> { final String name = StringArgumentType.getString(context, "name"); - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); try { SetDefaultHome(player, name); @@ -126,7 +127,7 @@ }))); commandManager.getDispatcher().register(Commands.literal("homes") .executes(context -> { - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); try { PrintHomes(player); @@ -144,7 +145,7 @@ private static void SetHome(ServerPlayer player, String homeName) throws Exception { homeName = homeName.toLowerCase(); - Vec3 pos = player.position(); + BlockPos blockPos = new BlockPos(player.getBlockX(), player.getBlockY(), player.getBlockZ()); ServerLevel world = player.serverLevel(); StorageManager.PlayerStorageClass storages = GetPlayerStorage(player.getStringUUID()); @@ -166,9 +167,9 @@ // Create a new Home StorageManager.StorageClass.Player.Home homeLocation = new StorageManager.StorageClass.Player.Home(); homeLocation.name = homeName; - homeLocation.x = Double.parseDouble(String.format("%.1f", pos.x())); - homeLocation.y = Double.parseDouble(String.format("%.1f", pos.y())); - homeLocation.z = Double.parseDouble(String.format("%.1f", pos.z())); + homeLocation.x = blockPos.getX(); + homeLocation.y = blockPos.getY(); + homeLocation.z = blockPos.getZ(); homeLocation.world = world.dimension().location().toString(); playerStorage.Homes.add(homeLocation); @@ -198,23 +199,23 @@ homeName = playerStorage.DefaultHome; } } - boolean foundHome = false; boolean foundWorld = false; // find correct home for (StorageManager.StorageClass.Player.Home currentHome : playerStorage.Homes) { if (Objects.equals(currentHome.name, homeName)){ - foundHome = true; // find correct world for (ServerLevel currentWorld : Objects.requireNonNull(player.getServer()).getAllLevels()) { if (Objects.equals(currentWorld.dimension().location().toString(), currentHome.world)) { - Vec3 coords = new Vec3(currentHome.x, currentHome.y, currentHome.z); foundWorld = true; - if (!player.getPosition(0).equals(coords)) { + BlockPos coords = new BlockPos(currentHome.x, currentHome.y, currentHome.z); + BlockPos playerBlockPos = new BlockPos(player.getBlockX(), player.getBlockY(), player.getBlockZ()); + + if (!playerBlockPos.equals(coords)) { player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.go", player), true); - Teleporter(player, currentWorld, new Vec3(currentHome.x, currentHome.y, currentHome.z)); + Teleporter(player, currentWorld, new Vec3(currentHome.x + 0.5, currentHome.y, currentHome.z + 0.5)); } else { player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.goSame", player).withStyle(ChatFormatting.AQUA), true); } @@ -224,7 +225,7 @@ } } } - if (!foundHome || !foundWorld) { + if (!foundWorld) { player.displayClientMessage(getTranslatedText("commands.teleport_commands.home.notFound", player).withStyle(ChatFormatting.RED), true); } } @@ -346,7 +347,7 @@ String name = String.format(" - %s", currenthome.name); - String coords = String.format("[X%.1f Y%.1f Z%.1f]", currenthome.x, currenthome.y, currenthome.z); + String coords = String.format("[X%d Y%d Z%d]", currenthome.x, currenthome.y, currenthome.z); String dimension = String.format(" [%s]", currenthome.world); if (Objects.equals(currenthome.name, playerStorage.DefaultHome)) { @@ -361,7 +362,7 @@ } player.displayClientMessage(Component.literal(" | ").withStyle(ChatFormatting.AQUA) - .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))))) + .append(Component.literal(coords).withStyle(ChatFormatting.LIGHT_PURPLE).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, String.format("X%d Y%d Z%d", currenthome.x, currenthome.y, currenthome.z))))) .append(Component.literal(dimension).withStyle(ChatFormatting.DARK_PURPLE).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, currenthome.world)))), false ); diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/tpa.java b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/tpa.java --- a/common/src/main/java/dev/mrsnowy/teleport_commands/commands/tpa.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/commands/tpa.java @@ -2,6 +2,7 @@ package dev.mrsnowy.teleport_commands.commands; import java.util.*; +import com.mojang.datafixers.util.Pair; import dev.mrsnowy.teleport_commands.suggestions.tpaSuggestionProvider; import net.minecraft.ChatFormatting; @@ -10,9 +11,9 @@ import net.minecraft.commands.arguments.EntityArgument; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.phys.Vec3; -import static dev.mrsnowy.teleport_commands.utils.tools.Teleporter; -import static dev.mrsnowy.teleport_commands.utils.tools.getTranslatedText; +import static dev.mrsnowy.teleport_commands.utils.tools.*; public class tpa { @@ -30,7 +31,7 @@ commandManager.getDispatcher().register(Commands.literal("tpa") .then(Commands.argument("player", EntityArgument.player()) .executes(context -> { final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); tpaCommandHandler(player, TargetPlayer, false); return 0; @@ -40,7 +41,7 @@ commandManager.getDispatcher().register(Commands.literal("tpahere") .then(Commands.argument("player", EntityArgument.player()) .executes(context -> { final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); tpaCommandHandler(player, TargetPlayer, true); @@ -51,7 +52,7 @@ commandManager.getDispatcher().register(Commands.literal("tpaaccept") .then(Commands.argument("player", EntityArgument.player()).suggests(new tpaSuggestionProvider()) .executes(context -> { final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); tpaAccept(player, TargetPlayer); return 0; @@ -61,7 +62,7 @@ commandManager.getDispatcher().register(Commands.literal("tpadeny") .then(Commands.argument("player", EntityArgument.player()).suggests(new tpaSuggestionProvider()) .executes(context -> { final ServerPlayer TargetPlayer = EntityArgument.getPlayer(context, "player"); - ServerPlayer player = context.getSource().getPlayerOrException(); + final ServerPlayer player = context.getSource().getPlayerOrException(); tpaDeny(player, TargetPlayer); return 0; @@ -81,7 +82,7 @@ if (FromPlayer == ToPlayer) { FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.self", FromPlayer).withStyle(ChatFormatting.AQUA),true); } else if (playerTpaList >= 1) { - FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.alreadySent", FromPlayer, Component.literal(Objects.requireNonNull(ToPlayer.getName().tryCollapseToString())).withStyle(ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA) + FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.alreadySent", FromPlayer, Component.literal(Objects.requireNonNull(ToPlayer.getName().getString())).withStyle(ChatFormatting.BOLD)).withStyle(ChatFormatting.AQUA) ,true ); @@ -95,8 +96,8 @@ tpaRequest.RecPlayer = ToPlayer.getStringUUID(); tpaRequest.here = here; tpaList.add(tpaRequest); - String ReceivedFromPlayer = Objects.requireNonNull(FromPlayer.getName().tryCollapseToString()); - String SentToPlayer = Objects.requireNonNull(ToPlayer.getName().tryCollapseToString()); + String ReceivedFromPlayer = Objects.requireNonNull(FromPlayer.getName().getString()); + String SentToPlayer = Objects.requireNonNull(ToPlayer.getName().getString()); FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.sent", FromPlayer, Component.literal(hereText), Component.literal(SentToPlayer).withStyle(ChatFormatting.BOLD)) // .append(Text.literal("\n[Cancel]").formatted(Formatting.BLUE, Formatting.BOLD)) @@ -123,7 +124,7 @@ } // else { // TeleportCommands.LOGGER.error("Error removing tpaRequest from tpaList!"); // } - // else not needed since it may be cancelled + // else not needed since it may be denied/cancelled } }, 30 * 1000 // 30 seconds ); @@ -140,19 +141,36 @@ .filter(tpa -> Objects.equals(ToPlayer.getStringUUID(), tpa.InitPlayer)) .filter(tpa -> Objects.equals(FromPlayer.getStringUUID(), tpa.RecPlayer)) .findFirst(); + // Check if there is a request if (tpaStorage.isPresent()) { - if (tpaStorage.get().here) { - Teleporter(FromPlayer, ToPlayer.serverLevel(), ToPlayer.position()); + ServerPlayer destinationPlayer = tpaStorage.get().here ? ToPlayer : FromPlayer; + ServerPlayer toSentPlayer = tpaStorage.get().here ? FromPlayer : ToPlayer; - } else { - Teleporter(ToPlayer, FromPlayer.serverLevel(), FromPlayer.position()); + Pair> teleportData = teleportSafetyChecker(destinationPlayer.getBlockX(), destinationPlayer.getBlockY(), destinationPlayer.getBlockZ(), destinationPlayer.serverLevel(), toSentPlayer); + + switch (teleportData.getFirst()) { + case 1: // same (let it fall through) + case 0: // safe! + if (teleportData.getSecond().isPresent() ) { + + Teleporter(toSentPlayer, destinationPlayer.serverLevel(), teleportData.getSecond().get()); + break; + } else { + toSentPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.common.error", toSentPlayer).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), true); + return; // exit + } + case 2: // if no safe location then just teleport to the player + Teleporter(toSentPlayer, destinationPlayer.serverLevel(), destinationPlayer.position()); + break; } + // if the player teleported then these messages get sent && the request gets removed FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", FromPlayer).withStyle(ChatFormatting.WHITE),true); ToPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.accepted", ToPlayer).withStyle(ChatFormatting.GREEN),true); + tpaList.remove(tpaStorage.get()); - tpaList.remove(tpaStorage.get()); + // No request found } else { FromPlayer.displayClientMessage(getTranslatedText("commands.teleport_commands.tpa.notFound", FromPlayer).withStyle(ChatFormatting.RED),true); } diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/mixin/PlayerDeathMixin.java b/common/src/main/java/dev/mrsnowy/teleport_commands/mixin/PlayerDeathMixin.java --- a/common/src/main/java/dev/mrsnowy/teleport_commands/mixin/PlayerDeathMixin.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/mixin/PlayerDeathMixin.java @@ -15,4 +15,4 @@ private void notifyDeath(CallbackInfo ci) { TeleportCommands.onPlayerDeath((ServerPlayer) (Object) this); } -} +} \ No newline at end of file diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/mixin/ServerStartMixin.java b/common/src/main/java/dev/mrsnowy/teleport_commands/mixin/ServerStartMixin.java --- a/common/src/main/java/dev/mrsnowy/teleport_commands/mixin/ServerStartMixin.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/mixin/ServerStartMixin.java @@ -15,5 +15,4 @@ private void runServer(CallbackInfo info) { TeleportCommands.initializeMod((MinecraftServer) (Object) this); } -} - +} \ No newline at end of file diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/storage/StorageManager.java b/common/src/main/java/dev/mrsnowy/teleport_commands/storage/StorageManager.java --- a/common/src/main/java/dev/mrsnowy/teleport_commands/storage/StorageManager.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/storage/StorageManager.java @@ -142,9 +142,9 @@ } public static class Home { public String name; - public double x; - public double y; - public double z; + public int x; + public int y; + public int z; public String world; } } diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/suggestions/HomeSuggestionProvider.java b/common/src/main/java/dev/mrsnowy/teleport_commands/suggestions/HomeSuggestionProvider.java --- a/common/src/main/java/dev/mrsnowy/teleport_commands/suggestions/HomeSuggestionProvider.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/suggestions/HomeSuggestionProvider.java @@ -6,7 +6,6 @@ import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; import dev.mrsnowy.teleport_commands.TeleportCommands; import dev.mrsnowy.teleport_commands.storage.StorageManager; -import java.util.Objects; import java.util.concurrent.CompletableFuture; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.level.ServerPlayer; diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/suggestions/tpaSuggestionProvider.java b/common/src/main/java/dev/mrsnowy/teleport_commands/suggestions/tpaSuggestionProvider.java --- a/common/src/main/java/dev/mrsnowy/teleport_commands/suggestions/tpaSuggestionProvider.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/suggestions/tpaSuggestionProvider.java @@ -26,7 +26,7 @@ .toList(); for (tpa.tpaArrayClass tpaEntry : playerTpaList) { - Optional recPlayerName = Optional.ofNullable(context.getSource().getServer().getPlayerList().getPlayer(UUID.fromString(tpaEntry.InitPlayer)).getName().tryCollapseToString()); + Optional recPlayerName = Optional.ofNullable(context.getSource().getServer().getPlayerList().getPlayer(UUID.fromString(tpaEntry.InitPlayer)).getName().getString()); if (recPlayerName.isPresent()) { builder.suggest(recPlayerName.get()); diff --git a/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java b/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java --- a/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java +++ b/common/src/main/java/dev/mrsnowy/teleport_commands/utils/tools.java @@ -1,15 +1,16 @@ package dev.mrsnowy.teleport_commands.utils; +import com.google.gson.*; import com.mojang.datafixers.util.Pair; import dev.mrsnowy.teleport_commands.TeleportCommands; import dev.mrsnowy.teleport_commands.storage.StorageManager; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.chat.Component; @@ -19,8 +20,6 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.world.phys.Vec3; -import org.tomlj.Toml; -import org.tomlj.TomlParseResult; import static dev.mrsnowy.teleport_commands.TeleportCommands.MOD_ID; import static dev.mrsnowy.teleport_commands.storage.StorageManager.GetPlayerStorage; @@ -32,12 +31,14 @@ private static final Set 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"); public static void Teleporter(ServerPlayer player, ServerLevel world, Vec3 coords) { + // before teleportation effects world.sendParticles(ParticleTypes.SNOWFLAKE, player.getX(), player.getY() + 1, player.getZ(), 20, 0.0D, 0.0D, 0.0D, 0.01); world.sendParticles(ParticleTypes.WHITE_SMOKE, player.getX(), player.getY(), player.getZ(), 15, 0.0D, 1.0D, 0.0D, 0.03); world.playSound(null, player.blockPosition(), SoundEvent.createVariableRangeEvent(ENDERMAN_TELEPORT.getLocation()), SoundSource.PLAYERS, 0.4f, 1.0f); var flying = player.getAbilities().flying; + // teleport! player.teleportTo(world, coords.x, coords.y, coords.z, player.getYRot(), player.getXRot()); // Restore flying when teleporting dimensions @@ -50,6 +51,7 @@ world.playSound(null, player.blockPosition(), SoundEvent.createVariableRangeEvent(ENDERMAN_TELEPORT.getLocation()), SoundSource.PLAYERS, 0.4f, 1.0f); Timer timer = new Timer(); + // delay visual effects so the player can see it when switching dimensions timer.schedule( new TimerTask() { @Override @@ -62,17 +64,15 @@ ); } - public static void DeathLocationUpdater(Vec3 pos, ServerLevel world, String UUID) throws Exception { + public static void DeathLocationUpdater(BlockPos pos, ServerLevel world, String UUID) throws Exception { StorageManager.PlayerStorageClass storages = GetPlayerStorage(UUID); StorageManager.StorageClass storage = storages.storage; StorageManager.StorageClass.Player playerStorage = storages.playerStorage; - // to ensure compatibility with older versions we cast it to double - playerStorage.deathLocation.x = (int) Math.round(pos.x()); - playerStorage.deathLocation.y = (int) Math.round(pos.y()); - playerStorage.deathLocation.z = (int) Math.round(pos.z()); - + playerStorage.deathLocation.x = pos.getX(); + playerStorage.deathLocation.y = pos.getY(); + playerStorage.deathLocation.z = pos.getZ(); playerStorage.deathLocation.world = world.dimension().location().toString(); StorageSaver(storage); @@ -82,9 +82,12 @@ public static Pair> teleportSafetyChecker(int playerX, int playerY, int playerZ, ServerLevel world, ServerPlayer player) { int row = 1; int rows = 3; + + BlockPos playerBlockPos = new BlockPos(player.getBlockX(), player.getBlockY(), player.getBlockZ()); + BlockPos blockPos = new BlockPos(playerX, playerY, playerZ); // find a safe location in an x row radius - if (isBlockPosUnsafe(new BlockPos(playerX, playerY, playerZ), world)) { + if (isBlockPosUnsafe(blockPos, world)) { while (row <= rows) { // TeleportCommands.LOGGER.info("currently doing row " + row + " of " + rows); //debug @@ -93,16 +96,18 @@ for (int z = -row; z <= row; z++) { for (int x = -row; x <= row; x++) { for (int y = -row; y <= row; y++) { + // checks if we are on the outer layer of the row, not on the inside if ((x == -row || x == row) || (z == -row || z == row) || (y == -row || y == row)) { - if (!isBlockPosUnsafe(new BlockPos(playerX + x, playerY + y, playerZ + z), world)) { - Vec3 toTeleportTo = new Vec3(playerX + x + 0.5, playerY + y, playerZ + z + 0.5); + BlockPos newSafePos = new BlockPos(playerX + x, playerY + y, playerZ + z); - if (!player.getPosition(0).equals(toTeleportTo) || player.level() != world) { - return new Pair<>(0, Optional.of(toTeleportTo)); // safe! + if (!isBlockPosUnsafe(newSafePos, world)) { + + if (!playerBlockPos.equals(newSafePos) || player.level() != world) { + return new Pair<>(0, Optional.of(new Vec3(newSafePos.getX() + 0.5, newSafePos.getY(), newSafePos.getZ() + 0.5))); // safe! } else { - return new Pair<>(1, Optional.empty()); // same + return new Pair<>(1, Optional.of(new Vec3(newSafePos.getX() + 0.5, newSafePos.getY(), newSafePos.getZ() + 0.5))); // same } } } @@ -112,20 +117,21 @@ } row++; } - // no safe location - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.noSafeLocation", player).withStyle(ChatFormatting.RED, ChatFormatting.BOLD), false); - player.displayClientMessage(getTranslatedText("commands.teleport_commands.common.safetyIsForLosers", player).withStyle(ChatFormatting.AQUA), false); + return new Pair<>(2, Optional.empty()); // no safe location - return new Pair<>(2, Optional.empty()); // no safe location + // check if the location is the same + } else if (!playerBlockPos.equals(blockPos) || player.level() != world) { + return new Pair<>(0, Optional.of(new Vec3(playerX + 0.5, playerY, playerZ + 0.5))); // good and safe! + } else { - return new Pair<>(0, Optional.of(new Vec3(playerX + 0.5, playerY, playerZ + 0.5))); // safe! + return new Pair<>(1, Optional.of(new Vec3(playerX + 0.5, playerY, playerZ + 0.5))); // same } } - // 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) + // 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) (I'm not mad, I swear) public static MutableComponent getTranslatedText(String key, ServerPlayer player, MutableComponent... args) { String language = player.clientInformation().language(); String regex = "%(\\d+)%"; @@ -133,12 +139,15 @@ Pattern pattern = Pattern.compile(regex); // the try catch stuff is so wacky, but it works fine and I don't need to check everything try { - String filePath = String.format("/assets/%s/lang/%s.toml", MOD_ID, language); + String filePath = String.format("/assets/%s/lang/%s.json", MOD_ID, language); InputStream stream = TeleportCommands.class.getResourceAsStream(filePath); - TomlParseResult toml = Toml.parse(Objects.requireNonNull(stream)); - String translation = toml.getString(key); + Reader reader = new InputStreamReader(Objects.requireNonNull(stream), StandardCharsets.UTF_8); + JsonElement json = JsonParser.parseReader(reader); + String translation = json.getAsJsonObject().get(key).getAsString(); + + // Adds the optional MutableComponents in the correct places Matcher matcher = pattern.matcher(Objects.requireNonNull(translation)); MutableComponent component = Component.literal(""); @@ -162,11 +171,13 @@ try { if (!Objects.equals(language, "en_us")) { // TeleportCommands.LOGGER.warn("Key \"{}\" not found in the language: {}, falling back to default (en_us)", key, language); - String filePath = String.format("/assets/%s/lang/en_us.toml", MOD_ID); + String filePath = String.format("/assets/%s/lang/en_us.json", MOD_ID); InputStream stream = TeleportCommands.class.getResourceAsStream(filePath); - TomlParseResult toml = Toml.parse(Objects.requireNonNull(stream)); - String translation = toml.getString(key); + Reader reader = new InputStreamReader(Objects.requireNonNull(stream), StandardCharsets.UTF_8); + JsonElement json = JsonParser.parseReader(reader); + String translation = json.getAsJsonObject().get(key).getAsString(); + Matcher matcher = pattern.matcher(Objects.requireNonNull(translation)); diff --git a/common/src/main/resources/assets/teleport_commands/lang/en_us.json b/common/src/main/resources/assets/teleport_commands/lang/en_us.json new file mode 100644 --- /dev/null +++ b/common/src/main/resources/assets/teleport_commands/lang/en_us.json @@ -0,0 +1,46 @@ +{ + "commands.teleport_commands.back.go": "Going Back", + "commands.teleport_commands.back.same": "Already Back", + "commands.teleport_commands.back.noLocation": "No Location Found!", + + "commands.teleport_commands.home.set": "Home Set", + "commands.teleport_commands.home.setError": "Error Setting Home!", + "commands.teleport_commands.home.go": "Going Home", + "commands.teleport_commands.home.goError": "Error Going Home!", + "commands.teleport_commands.home.goSame": "Already Home", + "commands.teleport_commands.home.delete": "Home Deleted", + "commands.teleport_commands.home.deleteError": "Error Deleting Home!", + "commands.teleport_commands.home.rename": "Home Renamed", + "commands.teleport_commands.home.renameError": "Error Renaming Home!", + "commands.teleport_commands.home.renameExists": "That Name Already Exists!", + "commands.teleport_commands.home.default": "Default Home Set", + "commands.teleport_commands.home.defaultError": "Error Changing Default Home!", + "commands.teleport_commands.home.defaultSame": "Home is already set as default!", + "commands.teleport_commands.home.notFound": "Home Not Found!", + "commands.teleport_commands.home.exists": "Home Already Exists!", + "commands.teleport_commands.home.homeless": "You Have No Homes!", + + "commands.teleport_commands.homes.error": "Error Getting Homes!", + "commands.teleport_commands.homes.homes": "Homes:", + "commands.teleport_commands.homes.default": "(Default)", + "commands.teleport_commands.homes.tp": "[Tp]", + "commands.teleport_commands.homes.rename": "[Rename]", + "commands.teleport_commands.homes.delete": "[Delete]", + + "commands.teleport_commands.tpa.self": "Well, that was easy", + "commands.teleport_commands.tpa.alreadySent": "A request has already been sent to %0%", + "commands.teleport_commands.tpa.received": "Tpa%0% Request Received From %1%", + "commands.teleport_commands.tpa.sent": "Tpa%0% Request Sent to %1%", + "commands.teleport_commands.tpa.accept": "[Accept]", + "commands.teleport_commands.tpa.deny": " [Deny]", + "commands.teleport_commands.tpa.expired": "Tpa%0% Request Expired", + "commands.teleport_commands.tpa.notFound": "No Requests found!", + "commands.teleport_commands.tpa.accepted": "Request Accepted", + "commands.teleport_commands.tpa.denied": "Request Denied", + + "commands.teleport_commands.common.teleport": "Teleporting", + "commands.teleport_commands.common.error": "Error Teleporting!", + "commands.teleport_commands.common.noSafeLocation": "No Safe Location Found!", + "commands.teleport_commands.common.safetyIsForLosers": "Teleport anyways? (Warning, you might die!)", + "commands.teleport_commands.common.forceTeleport": "[Force Teleport]" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/teleport_commands/lang/en_us.toml b/common/src/main/resources/assets/teleport_commands/lang/en_us.toml deleted file mode 100644 --- a/common/src/main/resources/assets/teleport_commands/lang/en_us.toml +++ /dev/null @@ -1,49 +0,0 @@ -# back -commands.teleport_commands.back.go = "Going Back" -commands.teleport_commands.back.same = "Already Back" -commands.teleport_commands.back.noLocation = "No Location Found!" - -# home -commands.teleport_commands.home.set = "Home Set" -commands.teleport_commands.home.setError = "Error Setting Home!" -commands.teleport_commands.home.go = "Going Home" -commands.teleport_commands.home.goError = "Error Going Home!" -commands.teleport_commands.home.goSame = "Already Home" -commands.teleport_commands.home.delete = "Home Deleted" -commands.teleport_commands.home.deleteError = "Error Deleting Home!" -commands.teleport_commands.home.rename = "Home Renamed" -commands.teleport_commands.home.renameError = "Error Renaming Home!" -commands.teleport_commands.home.renameExists = "That Name Already Exists!" -commands.teleport_commands.home.default = "Default Home Set" -commands.teleport_commands.home.defaultError = "Error Changing Default Home!" -commands.teleport_commands.home.defaultSame = "Home is already set as default!" -commands.teleport_commands.home.notFound = "Home Not Found!" -commands.teleport_commands.home.exists = "Home Already Exists!" -commands.teleport_commands.home.homeless = "You Have No Homes!" - -# homes -commands.teleport_commands.homes.error = "Error Getting Homes!" -commands.teleport_commands.homes.homes = "Homes:" -commands.teleport_commands.homes.default = "(Default)" -commands.teleport_commands.homes.tp = "[Tp]" -commands.teleport_commands.homes.rename = "[Rename]" -commands.teleport_commands.homes.delete = "[Delete]" - -# tpa -commands.teleport_commands.tpa.self = "Well, that was easy" -commands.teleport_commands.tpa.alreadySent = "A request has already been sent to %0%" -commands.teleport_commands.tpa.received = "Tpa%0% Request Received From %1%" -commands.teleport_commands.tpa.sent = "Tpa%0% Request Sent to %1%" -commands.teleport_commands.tpa.accept = "[Accept]" -commands.teleport_commands.tpa.deny = " [Deny]" -commands.teleport_commands.tpa.expired = "Tpa%0% Request Expired" -commands.teleport_commands.tpa.notFound = "No Requests found!" -commands.teleport_commands.tpa.accepted = "Request Accepted" -commands.teleport_commands.tpa.denied = "Request Denied" - -# common -commands.teleport_commands.common.teleport = "Teleporting" -commands.teleport_commands.common.error = "Error Teleporting!" -commands.teleport_commands.common.noSafeLocation = "No Safe Location Found!" -commands.teleport_commands.common.safetyIsForLosers = "Teleport anyways? (Warning, you might die!)" -commands.teleport_commands.common.forceTeleport = "[Force Teleport]" \ No newline at end of file diff --git a/common/src/main/resources/assets/teleport_commands/lang/hu_hu.json b/common/src/main/resources/assets/teleport_commands/lang/hu_hu.json new file mode 100644 --- /dev/null +++ b/common/src/main/resources/assets/teleport_commands/lang/hu_hu.json @@ -0,0 +1,46 @@ +{ + "commands.teleport_commands.back.go": "Indulás vissza", + "commands.teleport_commands.back.same": "Vissza", + "commands.teleport_commands.back.noLocation": "Nem található a koordináta", + + "commands.teleport_commands.home.set": "Otthon beállítása", + "commands.teleport_commands.home.setError": "Hiba történt az otthon beállításával!", + "commands.teleport_commands.home.go": "Indulás haza!", + "commands.teleport_commands.home.goError": "Hiba történt az otthonnal!", + "commands.teleport_commands.home.goSame": "Otthon, édes otthon", + "commands.teleport_commands.home.delete": "Otthon törölve", + "commands.teleport_commands.home.deleteError": "Hiba történt az otthon rökésével!", + "commands.teleport_commands.home.rename": "Otthon átnevezve", + "commands.teleport_commands.home.renameError": "Hiba történt az otthon átnevezésével!", + "commands.teleport_commands.home.renameExists": "A név már létezik!", + "commands.teleport_commands.home.default": "Alap otthon beállítva", + "commands.teleport_commands.home.defaultError": "Hiba történt az alap otthon beállításával!", + "commands.teleport_commands.home.defaultSame": "Már alap ez az otthon!", + "commands.teleport_commands.home.notFound": "Otthon nem találva!", + "commands.teleport_commands.home.exists": "Az otthon már létezik!", + "commands.teleport_commands.home.homeless": "Nincs otthonod!", + + "commands.teleport_commands.homes.error": "Hiba történt az otthonok megtalálásával!", + "commands.teleport_commands.homes.homes": "Otthonol:", + "commands.teleport_commands.homes.default": "(Alap)", + "commands.teleport_commands.homes.tp": "[Tp]", + "commands.teleport_commands.homes.rename": "[Átnevezés]", + "commands.teleport_commands.homes.delete": "[Törlés]", + + "commands.teleport_commands.tpa.self": "Hát ez gyors volt", + "commands.teleport_commands.tpa.alreadySent": "Egy kérés már el lett küldve %0%-nek", + "commands.teleport_commands.tpa.received": "Tpa%0% kérés megkapva %1%-től", + "commands.teleport_commands.tpa.sent": "tpa%0% kérés elküldve %1%-nek", + "commands.teleport_commands.tpa.accept": "[Elfogadás]", + "commands.teleport_commands.tpa.deny": " [Elutasítás]", + "commands.teleport_commands.tpa.expired": "Tpa%0% kérés lejárt", + "commands.teleport_commands.tpa.notFound": "Semmi kérésed sincsen!", + "commands.teleport_commands.tpa.accepted": "Elfogadva", + "commands.teleport_commands.tpa.denied": "Elutasítva", + + "commands.teleport_commands.common.teleport": "Utazás", + "commands.teleport_commands.common.error": "Hiba történt a teleportálással!", + "commands.teleport_commands.common.noSafeLocation": "Nem találtunk biztonságos helyet!", + "commands.teleport_commands.common.safetyIsForLosers": "Biztos teleportálsz?", + "commands.teleport_commands.common.forceTeleport": "[Teleportálás mindenképp]" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/teleport_commands/lang/hu_hu.toml b/common/src/main/resources/assets/teleport_commands/lang/hu_hu.toml deleted file mode 100644 --- a/common/src/main/resources/assets/teleport_commands/lang/hu_hu.toml +++ /dev/null @@ -1,50 +0,0 @@ -# back -commands.teleport_commands.back.go = "Indulás vissza" -commands.teleport_commands.back.same = "Vissza" -commands.teleport_commands.back.noLocation = "Nem található a koordináta" - -# home -commands.teleport_commands.home.set = "Otthon beállítása" -commands.teleport_commands.home.setError = "Hiba történt az otthon beállításával!" -commands.teleport_commands.home.go = "Indulás haza!" -commands.teleport_commands.home.goError = "Hiba történt az otthonnal!" -commands.teleport_commands.home.goSame = "Otthon, édes otthon" -commands.teleport_commands.home.delete = "Otthon törölve" -commands.teleport_commands.home.deleteError = "Hiba történt az otthon rökésével!" -commands.teleport_commands.home.rename = "Otthon átnevezve" -commands.teleport_commands.home.renameError = "Hiba történt az otthon átnevezésével!" -commands.teleport_commands.home.renameExists = "A név már létezik!" -commands.teleport_commands.home.default = "Alap otthon beállítva" -commands.teleport_commands.home.defaultError = "Hiba történt az alap otthon beállításával!" -commands.teleport_commands.home.defaultSame = "Már alap ez az otthon!" -commands.teleport_commands.home.notFound = "Otthon nem találva!" -commands.teleport_commands.home.exists = "Az otthon már létezik!" -commands.teleport_commands.home.homeless = "Nincs otthonod!" - -# homes -commands.teleport_commands.homes.error = "Hiba történt az otthonok megtalálásával!" -commands.teleport_commands.homes.homes = "Otthonol:" -commands.teleport_commands.homes.default = "(Alap)" -commands.teleport_commands.homes.tp = "[Tp]" -commands.teleport_commands.homes.rename = "[Átnevezés]" -commands.teleport_commands.homes.delete = "[Törlés]" - -# tpa -commands.teleport_commands.tpa.self = "Hát ez gyors volt" -commands.teleport_commands.tpa.alreadySent = "Egy kérés már el lett küldve %0%-nek" -commands.teleport_commands.tpa.received = "Tpa%0% kérés megkapva %1%-től" -commands.teleport_commands.tpa.sent = "tpa%0% kérés elküldve %1%-nek" -commands.teleport_commands.tpa.accept = "[Elfogadás]" -commands.teleport_commands.tpa.deny = " [Elutasítás]" -commands.teleport_commands.tpa.expired = "Tpa%0% kérés lejárt" -commands.teleport_commands.tpa.notFound = "Semmi kérésed sincsen!" -commands.teleport_commands.tpa.accepted = "Elfogadva" -commands.teleport_commands.tpa.denied = "Elutasítva" - -# common -commands.teleport_commands.common.teleport = "Utazás" -commands.teleport_commands.common.error = "Hiba történt a teleportálással!" - -commands.teleport_commands.common.noSafeLocation = "No Safe Location Found!" -commands.teleport_commands.common.safetyIsForLosers = "Teleport anyways? (Warning, you might die!)" -commands.teleport_commands.common.forceTeleport = "[Force Teleport]" \ No newline at end of file diff --git a/common/src/main/resources/assets/teleport_commands/lang/nl_nl.json b/common/src/main/resources/assets/teleport_commands/lang/nl_nl.json new file mode 100644 --- /dev/null +++ b/common/src/main/resources/assets/teleport_commands/lang/nl_nl.json @@ -0,0 +1,46 @@ +{ + "commands.teleport_commands.back.go": "Terug gaan", + "commands.teleport_commands.back.same": "Al Terug", + "commands.teleport_commands.back.noLocation": "Geen Locatie Gevonden!", + + "commands.teleport_commands.home.set": "Huis Ingesteld", + "commands.teleport_commands.home.setError": "Probleem Met Het Huis Instellen!", + "commands.teleport_commands.home.go": "Naar Huis", + "commands.teleport_commands.home.goError": "Probleem Met Naar Huis Gaan!", + "commands.teleport_commands.home.goSame": "Al Thuis", + "commands.teleport_commands.home.delete": "Huis Verwijderd", + "commands.teleport_commands.home.deleteError": "Probleem Met Het Verwijderen Van Het Huis!", + "commands.teleport_commands.home.rename": "Huis Hernoemd", + "commands.teleport_commands.home.renameError": "Probleem Met Het Huis Hernamen!", + "commands.teleport_commands.home.renameExists": "Die Naam Bestaat Al!", + "commands.teleport_commands.home.default": "Standaard Huis Ingesteld", + "commands.teleport_commands.home.defaultError": "Probleem Tijdens Het Wijzigen Van Het Standaard Huis!", + "commands.teleport_commands.home.defaultSame": "Huis is al als standaard ingesteld!", + "commands.teleport_commands.home.notFound": "Huis Niet Gevonden!", + "commands.teleport_commands.home.exists": "Dat huis bestaad Al!", + "commands.teleport_commands.home.homeless": "Je Hebt Geen Huizen!", + + "commands.teleport_commands.homes.error": "Probleem Bij Het Ophalen Van De Huizen!", + "commands.teleport_commands.homes.homes": "Huizen:", + "commands.teleport_commands.homes.default": "(Standaard)", + "commands.teleport_commands.homes.tp": "[Tp]", + "commands.teleport_commands.homes.rename ": "[Naam Wijzigen]", + "commands.teleport_commands.homes.delete": "[Verwijderen]", + + "commands.teleport_commands.tpa.self": "Welp, Dat Was Makkelijk", + "commands.teleport_commands.tpa.alreadySent": "Er is al een verzoek verzonden naar %0%", + "commands.teleport_commands.tpa.received": "Tpa%0% Verzoek Ontvangen Van %1%", + "commands.teleport_commands.tpa.sent": "Tpa%0% Verzoek Verzonden Naar %1%", + "commands.teleport_commands.tpa.accept": "[Accepteren]", + "commands.teleport_commands.tpa.deny": " [Weigeren]", + "commands.teleport_commands.tpa.expired": "Tpa%0% Verzoek Verlopen", + "commands.teleport_commands.tpa.notFound": "Geen Verzoeken Gevonden!", + "commands.teleport_commands.tpa.accepted": "Verzoek Geaccepteerd", + "commands.teleport_commands.tpa.denied": "Verzoek Geweigerd", + + "commands.teleport_commands.common.teleport": "Teleporteren", + "commands.teleport_commands.common.error": "Probleem tijdens het Teleporteren!", + "commands.teleport_commands.common.noSafeLocation": "Geen veilige locatie gevonden!", + "commands.teleport_commands.common.safetyIsForLosers": "Toch teleporteren? (Waarschuwing, je kan dood gaan!)", + "commands.teleport_commands.common.forceTeleport": "[Geforceerd Teleporteren]" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/teleport_commands/lang/nl_nl.toml b/common/src/main/resources/assets/teleport_commands/lang/nl_nl.toml deleted file mode 100644 --- a/common/src/main/resources/assets/teleport_commands/lang/nl_nl.toml +++ /dev/null @@ -1,49 +0,0 @@ -# back -commands.teleport_commands.back.go = "Terug gaan" -commands.teleport_commands.back.same = "Al Terug" -commands.teleport_commands.back.noLocation = "Geen Locatie Gevonden!" - -# home -commands.teleport_commands.home.set = "Huis Ingesteld" -commands.teleport_commands.home.setError = "Probleem Met Het Huis Instellen!" -commands.teleport_commands.home.go = "Naar Huis" -commands.teleport_commands.home.goError = "Probleem Met Naar Huis Gaan!" -commands.teleport_commands.home.goSame = "Al Thuis" -commands.teleport_commands.home.delete = "Huis Verwijderd" -commands.teleport_commands.home.deleteError = "Probleem Met Het Verwijderen Van Het Huis!" -commands.teleport_commands.home.rename = "Huis Hernoemd" -commands.teleport_commands.home.renameError = "Probleem Met Het Huis Hernamen!" -commands.teleport_commands.home.renameExists = "Die Naam Bestaat Al!" -commands.teleport_commands.home.default = "Standaard Huis Ingesteld" -commands.teleport_commands.home.defaultError = "Probleem Tijdens Het Wijzigen Van Het Standaard Huis!" -commands.teleport_commands.home.defaultSame = "Huis is al als standaard ingesteld!" -commands.teleport_commands.home.notFound = "Huis Niet Gevonden!" -commands.teleport_commands.home.exists = "Dat huis bestaad Al!" -commands.teleport_commands.home.homeless = "Je Hebt Geen Huizen!" - -# homes -commands.teleport_commands.homes.error = "Probleem Bij Het Ophalen Van De Huizen!" -commands.teleport_commands.homes.homes = "Huizen:" -commands.teleport_commands.homes.default = "(Standaard)" -commands.teleport_commands.homes.tp = "[Tp]" -commands.teleport_commands.homes.rename = "[Naam Wijzigen]" -commands.teleport_commands.homes.delete = "[Verwijderen]" - -# tpa -commands.teleport_commands.tpa.self = "Welp, Dat Was Makkelijk" -commands.teleport_commands.tpa.alreadySent = "Er is al een verzoek verzonden naar %0%" -commands.teleport_commands.tpa.received = "Tpa%0% Verzoek Ontvangen Van %1%" -commands.teleport_commands.tpa.sent = "Tpa%0% Verzoek Verzonden Naar %1%" -commands.teleport_commands.tpa.accept = "[Accepteren]" -commands.teleport_commands.tpa.deny = " [Weigeren]" -commands.teleport_commands.tpa.expired = "Tpa%0% Verzoek Verlopen" -commands.teleport_commands.tpa.notFound = "Geen Verzoeken Gevonden!" -commands.teleport_commands.tpa.accepted = "Verzoek Geaccepteerd" -commands.teleport_commands.tpa.denied = "Verzoek Geweigerd" - -# common -commands.teleport_commands.common.teleport = "Teleporteren" -commands.teleport_commands.common.error = "Probleem tijdens het Teleporteren!" -commands.teleport_commands.common.noSafeLocation = "Geen veilige locatie gevonden!" -commands.teleport_commands.common.safetyIsForLosers = "Toch teleporteren? (Waarschuwing, je kan dood gaan!)" -commands.teleport_commands.common.forceTeleport = "[Geforceerd Teleporteren]" \ No newline at end of file diff --git a/common/src/main/resources/assets/teleport_commands/lang/translations.md b/common/src/main/resources/assets/teleport_commands/lang/translations.md --- a/common/src/main/resources/assets/teleport_commands/lang/translations.md +++ b/common/src/main/resources/assets/teleport_commands/lang/translations.md @@ -10,8 +10,8 @@ #### Want to make a translation? 1. Make a fork of the mod 2. Go [here](https://minecraft.wiki/w/Language) and pick the in-game locale code for the language you want to translate -3. Copy `en_us.toml` and paste it in a new file called `[in-game locale code here].toml` -4. Translate the values (everything between " ") in the file +3. Copy `en_us.json` and paste it in a new file called `[in-game locale code here].json` +4. Translate the values in the file 5. Submit a pull request with your translation :D! #### Want to improve an existing translation? diff --git a/fabric/build.gradle b/fabric/build.gradle --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -7,7 +7,6 @@ dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" mappings loom.layered() { officialMojangMappings() -// parchment("org.parchmentmc.data:parchment-${parchment_mappings}@zip") } modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" // modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api}" diff --git a/gradle.properties b/gradle.properties --- a/gradle.properties +++ b/gradle.properties @@ -2,30 +2,29 @@ # Important Notes: # Every field you add must be added to the root build.gradle expandProps map. # Project -version=1.1.0-beta +version=1.1.0 group=dev.mrsnowy.teleport_commands java_version=17 # Common minecraft_version=1.20.4 -parchment_mappings=1.20.4:2024.04.14 mod_name=Teleport Commands mod_author=Mr. Snowy mod_id=teleport_commands license=MIT credits=Mr. Snowy description=A server-side mod that adds various teleportation related commands. -minecraft_version_range=[1.20.4, 1.21) +minecraft_version_range=[1.20.4, 1.21] # Fabric fabric_loader_version=0.15.7 #fabric_api=0.97.0+1.20.4 fabric_loom=1.6-SNAPSHOT -# Quilt -quilt_loader_version=0.25.0 -quilt_fabric_api=9.0.0-alpha.8+0.97.0-1.20.4 -quilt_loom=1.6.7 +# Quilt (Currently disabled since fabric port works better) +#quilt_loader_version=0.25.0 +#quilt_fabric_api=9.0.0-alpha.8+0.97.0-1.20.4 +#quilt_loom=1.6.7 # NeoForge diff --git a/quilt/build.gradle b/quilt/build.gradle --- a/quilt/build.gradle +++ b/quilt/build.gradle @@ -7,7 +7,6 @@ dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" mappings loom.layered() { officialMojangMappings() -// parchment("org.parchmentmc.data:parchment-${parchment_mappings}@zip") } modImplementation "org.quiltmc:quilt-loader:${quilt_loader_version}" modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${quilt_fabric_api}" diff --git a/settings.gradle b/settings.gradle --- a/settings.gradle +++ b/settings.gradle @@ -7,7 +7,7 @@ url = uri("https://maven.fabricmc.net") } maven { name = 'Quilt' - url = 'https://maven.quiltmc.org/repository/release' + url = uri("https://maven.quiltmc.org/repository/release") } maven { name = 'NeoForge' @@ -29,5 +29,4 @@ rootProject.name = "Teleport Commands" include("common") include("fabric") include("neoforge") -include("quilt") - +//include("quilt") // disabled since the fabric port works better then the native quilt port \ No newline at end of file