From 111e495823d514ee2008f81e049329db43f0ab01 Mon Sep 17 00:00:00 2001 From: Leander <47365075+Le4nderS@users.noreply.github.com> Date: Tue, 21 Nov 2023 10:57:44 +0100 Subject: [PATCH] performance fix of height in actionbar, fix link-worlds feature, code cleanup --- README.md | 11 +- .../terraplusminus/Terraplusminus.java | 37 +- .../commands/OffsetCommand.java | 43 +- .../terraplusminus/commands/TpllCommand.java | 398 +++++++++--------- .../terraplusminus/commands/WhereCommand.java | 39 +- .../events/PlayerMoveEvent.java | 110 +++-- .../utils/ConfigurationHelper.java | 70 +-- .../terraplusminus/utils/LinkedWorld.java | 28 ++ src/main/resources/config.yml | 11 +- 9 files changed, 390 insertions(+), 357 deletions(-) create mode 100644 src/main/java/de/btegermany/terraplusminus/utils/LinkedWorld.java diff --git a/README.md b/README.md index 06642e6..d8d5b02 100644 --- a/README.md +++ b/README.md @@ -155,9 +155,12 @@ linked_worlds: method: 'SERVER' # 'SERVER' or 'MULTIVERSE' # if method = MULTIVERSE -> world_name, y-offset worlds: - - another_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section (-2032) - (-1) m a.s.l. it has a y-offset of -2032. - - current_world/server # do not change! e.g. this world/server has a datapack to extend height to 2032. it covers the height section 0 - 2032 m a.s.l. - - another_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section 2033 - 4064 m a.s.l. it has a y-offset of 2032 + - name: another_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section (-2032) - (-1) m a.s.l. it has a y-offset of -2032. + offset: 2032 + - name: current_world/server # do not change! e.g. this world/server has a datapack to extend height to 2032. it covers the height section 0 - 2032 m a.s.l. + offset: 0 + - name: another_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section 2033 - 4064 m a.s.l. it has a y-offset of 2032 + offset: -2032 # If disabled, tree generation is turned off. @@ -175,7 +178,7 @@ path_material: MOSS_BLOCK # ----------------------------------------------------- # NOTE: Do not change -config_version: 1.3 +config_version: 1.4 ``` # Dependencies diff --git a/src/main/java/de/btegermany/terraplusminus/Terraplusminus.java b/src/main/java/de/btegermany/terraplusminus/Terraplusminus.java index 573905d..35ff84d 100644 --- a/src/main/java/de/btegermany/terraplusminus/Terraplusminus.java +++ b/src/main/java/de/btegermany/terraplusminus/Terraplusminus.java @@ -10,6 +10,7 @@ import de.btegermany.terraplusminus.gen.RealWorldGenerator; import de.btegermany.terraplusminus.utils.ConfigurationHelper; import de.btegermany.terraplusminus.utils.FileBuilder; +import de.btegermany.terraplusminus.utils.LinkedWorld; import de.btegermany.terraplusminus.utils.PlayerHashMapManagement; import net.buildtheearth.terraminusminus.TerraConfig; import org.bukkit.Bukkit; @@ -20,6 +21,7 @@ import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.NotNull; import java.io.*; import java.util.logging.Level; @@ -44,7 +46,7 @@ public void onEnable() { // Config ------------------ this.saveDefaultConfig(); - this.config = getConfig(); + config = getConfig(); this.updateConfig(); // -------------------------- @@ -77,11 +79,7 @@ public void onEnable() { } // -------------------------- - if (Terraplusminus.config.getBoolean("reduced_console_messages")) { - TerraConfig.reducedConsoleMessages = true; // Disables console log of fetching data - } else { - TerraConfig.reducedConsoleMessages = false; - } + TerraConfig.reducedConsoleMessages = Terraplusminus.config.getBoolean("reduced_console_messages"); // Disables console log of fetching data // Registering commands getCommand("tpll").setExecutor(new TpllCommand()); @@ -117,22 +115,17 @@ public void onWorldInit(WorldInitEvent event) { @Override - public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { + public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id) { // Multiverse different y-offset support int yOffset = 0; if (Terraplusminus.config.getBoolean("linked_worlds.enabled") && Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE")) { - - String lastServerName = ConfigurationHelper.getLastServerName("world"); - String nextServerName = ConfigurationHelper.getNextServerName("world"); - try { - if (lastServerName != null && worldName.equalsIgnoreCase(lastServerName.split(",")[0])) { - yOffset = Integer.parseInt(lastServerName.split(",")[1].replace(" ", "")); - } else if (nextServerName != null && worldName.equalsIgnoreCase(nextServerName.split(",")[0])) { - yOffset = Integer.parseInt(nextServerName.split(",")[1].replace(" ", "")); + for (LinkedWorld world : ConfigurationHelper.getWorlds()) { + if (world.getWorldName().equalsIgnoreCase(worldName)) { + yOffset = world.getOffset(); } - } catch (Exception e) { - Bukkit.getLogger().log(Level.SEVERE, "[T+-] Could not parse y-offset from config"); } + } else { + yOffset = Terraplusminus.config.getInt("y_offset"); } return new RealWorldGenerator(yOffset); } @@ -240,7 +233,15 @@ private void updateConfig() { FileBuilder.addLineAfter("prefix:", "\n# If disabled, the plugin will log every fetched data to the console\n" + "reduced_console_messages: true"); - + FileBuilder.deleteLine("- another_world/server"); + FileBuilder.deleteLine("- current_world/server"); + FileBuilder.addLineAbove("# If disabled, tree generation is turned off.", + " - name: another_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section (-2032) - (-1) m a.s.l. it has a y-offset of -2032.\n" + + " offset: 2032\n" + + " - name: current_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section 0 - 2032 m a.s.l.\n" + + " offset: 0\n" + + " - name: another_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section 2033 - 4064 m a.s.l. it has a y-offset of 2032\n" + + " offset: -2032\n\n"); } } diff --git a/src/main/java/de/btegermany/terraplusminus/commands/OffsetCommand.java b/src/main/java/de/btegermany/terraplusminus/commands/OffsetCommand.java index 62b1b66..1e38049 100644 --- a/src/main/java/de/btegermany/terraplusminus/commands/OffsetCommand.java +++ b/src/main/java/de/btegermany/terraplusminus/commands/OffsetCommand.java @@ -11,34 +11,27 @@ public class OffsetCommand implements CommandExecutor { @Override public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) { - if (command.getName().equalsIgnoreCase("offset")) { - Player player = (Player) commandSender; - String worldName = player.getWorld().getName(); - if (player.hasPermission("t+-.offset")) { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Offsets:"); - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | X: §8" + Terraplusminus.config.getInt("terrain_offset.x")); - - if (!Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE") || !Terraplusminus.config.getBoolean("linked_worlds.enabled")) { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | Y: §8" + Terraplusminus.config.getInt("terrain_offset.y")); - } else { - if (Terraplusminus.config.getBoolean("linked_worlds.enabled") && Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE")) { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§9 World§7 | Y: §8" + Terraplusminus.config.getInt("terrain_offset.y")); - String lastServerName = ConfigurationHelper.getLastServerName("world"); - String nextServerName = ConfigurationHelper.getNextServerName("world"); - if (lastServerName != null) { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§9 " + lastServerName.split(",")[0] + "§7 | Y: §8" + Integer.parseInt(lastServerName.split(",")[1].replace(" ", ""))); - } else if (nextServerName != null) { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§9 " + nextServerName.split(",")[0] + "§7 | Y: §8" + Integer.parseInt(nextServerName.split(",")[1].replace(" ", ""))); - } - } - } + if (!command.getName().equalsIgnoreCase("offset")) { + return true; + } + Player player = (Player) commandSender; + if (player.hasPermission("t+-.offset")) { + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7No permission for /offset"); + return true; + } + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Offsets:"); + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | X: §8" + Terraplusminus.config.getInt("terrain_offset.x")); - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | Z: §8" + Terraplusminus.config.getInt("terrain_offset.z")); - } else { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7No permission for /offset"); - return true; + if (!Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE") || !Terraplusminus.config.getBoolean("linked_worlds.enabled")) { + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | Y: §8" + Terraplusminus.config.getInt("terrain_offset.y")); + } else { + if (Terraplusminus.config.getBoolean("linked_worlds.enabled") && Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE")) { + ConfigurationHelper.getWorlds().forEach(world -> player.sendMessage(Terraplusminus.config.getString("prefix") + "§9 " + world.getWorldName() + "§7 | Y: §8" + world.getOffset())); } } + + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7 | Z: §8" + Terraplusminus.config.getInt("terrain_offset.z")); + return true; } } diff --git a/src/main/java/de/btegermany/terraplusminus/commands/TpllCommand.java b/src/main/java/de/btegermany/terraplusminus/commands/TpllCommand.java index 48f0cbb..a6830c3 100644 --- a/src/main/java/de/btegermany/terraplusminus/commands/TpllCommand.java +++ b/src/main/java/de/btegermany/terraplusminus/commands/TpllCommand.java @@ -6,6 +6,7 @@ import de.btegermany.terraplusminus.data.TerraConnector; import de.btegermany.terraplusminus.gen.RealWorldGenerator; import de.btegermany.terraplusminus.utils.ConfigurationHelper; +import de.btegermany.terraplusminus.utils.LinkedWorld; import io.papermc.lib.PaperLib; import net.buildtheearth.terraminusminus.generator.EarthGeneratorSettings; import net.buildtheearth.terraminusminus.projection.GeographicProjection; @@ -20,254 +21,243 @@ import org.bukkit.generator.ChunkGenerator; import org.jetbrains.annotations.NotNull; -import java.util.logging.Level; +import java.util.List; import static org.bukkit.ChatColor.RED; public class TpllCommand implements CommandExecutor { + private final List linkedWorlds = ConfigurationHelper.getWorlds(); + @Override public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] args) { - if (command.getName().equalsIgnoreCase("tpll")) { - //If sender is not a player cancel the command. - if (!(commandSender instanceof Player)) { - commandSender.sendMessage("This command can only be used by players!"); - return true; - } - Player player = (Player) commandSender; + //If sender is not a player cancel the command. + if (!(commandSender instanceof Player)) { + commandSender.sendMessage("This command can only be used by players!"); + return true; + } + Player player = (Player) commandSender; + if (!command.getName().equalsIgnoreCase("tpll")) { + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Usage: /tpll "); + return true; + } + if (!player.hasPermission("t+-.tpll")) { + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7No permission for /tpll"); + return true; + } - // Entity selector - // detect if command starts with @ or with a player name + // Entity selector - if ((args[0].startsWith("@") || !isDouble(args[0].replace(",", ""))) && player.hasPermission("t+-.forcetpll")) { - if (args[0].equals("@a")) { - StringBuilder playerList = new StringBuilder(); - Terraplusminus.instance.getServer().getOnlinePlayers().forEach(p -> { - p.chat("/tpll " + String.join(" ", args).substring(2)); - if (Terraplusminus.instance.getServer().getOnlinePlayers().size() > 1) { - playerList.append(p.getName()).append(", "); - } else { - playerList.append(p.getName()).append(" "); - } - }); - // delete last comma if no player follows - if (playerList.length() > 0 && playerList.charAt(playerList.length() - 2) == ',') { - playerList.deleteCharAt(playerList.length() - 2); - } - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleported §9" + playerList + "§7to" + String.join(" ", args).substring(2)); - return true; - } else if (args[0].equals("@p")) { - // find nearest player but not the player itself - Player nearestPlayer = null; - double nearestDistance = Double.MAX_VALUE; - for (Player p : Terraplusminus.instance.getServer().getOnlinePlayers()) { - if (p.getLocation().distanceSquared(player.getLocation()) < nearestDistance && (!p.equals(player) || Terraplusminus.instance.getServer().getOnlinePlayers().size() == 1)) { - nearestPlayer = p; - nearestDistance = p.getLocation().distanceSquared(player.getLocation()); - } - } - if (nearestPlayer != null) { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleported §9" + nearestPlayer.getName() + " §7to" + String.join(" ", args).substring(2)); - nearestPlayer.chat("/tpll " + String.join(" ", args).substring(2)); + // detect if command starts with @ or with a player name + + if ((args[0].startsWith("@") || !isDouble(args[0].replace(",", ""))) && player.hasPermission("t+-.forcetpll")) { + if (args[0].equals("@a")) { + StringBuilder playerList = new StringBuilder(); + Terraplusminus.instance.getServer().getOnlinePlayers().forEach(p -> { + p.chat("/tpll " + String.join(" ", args).substring(2)); + if (Terraplusminus.instance.getServer().getOnlinePlayers().size() > 1) { + playerList.append(p.getName()).append(", "); + } else { + playerList.append(p.getName()).append(" "); } - return true; - } else { - Player target = null; - //check if target player is online - for (Player p : Terraplusminus.instance.getServer().getOnlinePlayers()) { - if (p.getName().equals(args[0])) { - target = p; - } + }); + // delete last comma if no player follows + if (playerList.length() > 0 && playerList.charAt(playerList.length() - 2) == ',') { + playerList.deleteCharAt(playerList.length() - 2); + } + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleported §9" + playerList + "§7to" + String.join(" ", args).substring(2)); + return true; + } else if (args[0].equals("@p")) { + // find nearest player but not the player itself + Player nearestPlayer = null; + double nearestDistance = Double.MAX_VALUE; + for (Player p : Terraplusminus.instance.getServer().getOnlinePlayers()) { + if (p.getLocation().distanceSquared(player.getLocation()) < nearestDistance && (!p.equals(player) || Terraplusminus.instance.getServer().getOnlinePlayers().size() == 1)) { + nearestPlayer = p; + nearestDistance = p.getLocation().distanceSquared(player.getLocation()); } - - if (target == null) { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§cNo player found with name §9" + args[0]); - return true; + } + if (nearestPlayer != null) { + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleported §9" + nearestPlayer.getName() + " §7to" + String.join(" ", args).substring(2)); + nearestPlayer.chat("/tpll " + String.join(" ", args).substring(2)); + } + return true; + } else { + Player target = null; + //check if target player is online + for (Player p : Terraplusminus.instance.getServer().getOnlinePlayers()) { + if (p.getName().equals(args[0])) { + target = p; } + } - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleported §9" + target.getName() + " §7to " + args[1] + " " + args[2]); - target.chat("/tpll " + String.join(" ", args).replace(target.getName(), "")); + if (target == null) { + player.sendMessage(Terraplusminus.config.getString("prefix") + "§cNo player found with name §9" + args[0]); return true; } - } - //Option to passthrough tpll to other bukkit plugins. - String passthroughTpll = Terraplusminus.config.getString("passthrough_tpll"); - if (!passthroughTpll.isEmpty()) { - //Check if any args are parsed. - if (args.length == 0) { - player.chat("/" + passthroughTpll + ":tpll"); - } else { - player.chat("/" + passthroughTpll + ":tpll " + String.join(" ", args)); - } + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleported §9" + target.getName() + " §7to " + args[1] + " " + args[2]); + target.chat("/tpll " + String.join(" ", args).replace(target.getName(), "")); return true; } + } - // - - if (args.length >= 2) { - if (player.hasPermission("t+-.tpll")) { - World tpWorld = player.getWorld(); - - - int yOffset = 0; - if (Terraplusminus.config.getBoolean("linked_worlds.enabled") && Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE")) { - String lastServerName = ConfigurationHelper.getLastServerName("world"); - String nextServerName = ConfigurationHelper.getNextServerName("world"); - try { - if (lastServerName != null && tpWorld.getName().equalsIgnoreCase(lastServerName.split(",")[0])) { - yOffset = Integer.parseInt(lastServerName.split(",")[1].replace(" ", "")); - } else if (nextServerName != null && tpWorld.getName().equalsIgnoreCase(nextServerName.split(",")[0])) { - yOffset = Integer.parseInt(nextServerName.split(",")[1].replace(" ", "")); - } - } catch (Exception e) { - Bukkit.getLogger().log(Level.SEVERE, "[T+-] Could not parse y-offset from config"); - } - } else { - yOffset = Terraplusminus.config.getInt("terrain_offset.y"); - } + //Option to passthrough tpll to other bukkit plugins. + String passthroughTpll = Terraplusminus.config.getString("passthrough_tpll"); + if (!passthroughTpll.isEmpty()) { + //Check if any args are parsed. + if (args.length == 0) { + player.chat("/" + passthroughTpll + ":tpll"); + } else { + player.chat("/" + passthroughTpll + ":tpll " + String.join(" ", args)); + } + return true; + } + // - + if (args.length >= 2) { - int xOffset = Terraplusminus.config.getInt("terrain_offset.x"); - int zOffset = Terraplusminus.config.getInt("terrain_offset.z"); - double minLat = Terraplusminus.config.getDouble("min_latitude"); - double maxLat = Terraplusminus.config.getDouble("max_latitude"); - double minLon = Terraplusminus.config.getDouble("min_longitude"); - double maxLon = Terraplusminus.config.getDouble("max_longitude"); + World tpWorld = player.getWorld(); - double[] coordinates = new double[2]; - coordinates[1] = Double.parseDouble(args[0].replace(",", "").replace("°", "")); - coordinates[0] = Double.parseDouble(args[1].replace("°", "")); + int xOffset = Terraplusminus.config.getInt("terrain_offset.x"); + int zOffset = Terraplusminus.config.getInt("terrain_offset.z"); + double minLat = Terraplusminus.config.getDouble("min_latitude"); + double maxLat = Terraplusminus.config.getDouble("max_latitude"); + double minLon = Terraplusminus.config.getDouble("min_longitude"); + double maxLon = Terraplusminus.config.getDouble("max_longitude"); - ChunkGenerator generator = player.getWorld().getGenerator(); - if (!(generator instanceof RealWorldGenerator)) { - commandSender.sendMessage(RED + "Must be in a Terra 1 to 1 world!"); - return true; - } - RealWorldGenerator terraGenerator = (RealWorldGenerator) generator; - EarthGeneratorSettings generatorSettings = terraGenerator.getSettings(); - GeographicProjection projection = generatorSettings.projection(); - // int yOffset = terraGenerator.getYOffset(); does not work anymore because i need the offsets for all worlds - - double[] mcCoordinates; - try { - mcCoordinates = projection.fromGeo(coordinates[0], coordinates[1]); - } catch (OutOfProjectionBoundsException e) { - commandSender.sendMessage(RED + "Location is not within projection bounds"); - return true; - } + double[] coordinates = new double[2]; + coordinates[1] = Double.parseDouble(args[0].replace(",", "").replace("°", "")); + coordinates[0] = Double.parseDouble(args[1].replace("°", "")); - if (minLat != 0 && maxLat != 0 && minLon != 0 && maxLon != 0 && !player.hasPermission("t+-.admin")) { - if (coordinates[1] < minLat || coordinates[0] < minLon || coordinates[1] > maxLat || coordinates[0] > maxLon) { - player.sendMessage(Terraplusminus.config.getString("prefix") + RED + "You cannot tpll to these coordinates, because this area is being worked on by another build team."); - return true; - } - } + ChunkGenerator generator = tpWorld.getGenerator(); + if (!(generator instanceof RealWorldGenerator)) { // after server reload the generator isnt instanceof RealWorldGenerator anymore + commandSender.sendMessage(Terraplusminus.config.getString("prefix") + RED + "The world generator must be set to Terraplusminus"); + return true; + } + RealWorldGenerator terraGenerator = (RealWorldGenerator) generator; + EarthGeneratorSettings generatorSettings = terraGenerator.getSettings(); + GeographicProjection projection = generatorSettings.projection(); + int yOffset = terraGenerator.getYOffset(); - TerraConnector terraConnector = new TerraConnector(); + double[] mcCoordinates; + try { + mcCoordinates = projection.fromGeo(coordinates[0], coordinates[1]); + } catch (OutOfProjectionBoundsException e) { + commandSender.sendMessage(RED + "Location is not within projection bounds"); + return true; + } - double height; - if (args.length >= 3) { - height = Double.parseDouble(args[2]) + yOffset; - } else { - height = terraConnector.getHeight((int) mcCoordinates[0], (int) mcCoordinates[1]).join() + yOffset; // 57 + (-2032) = -1975 - } - if (height > player.getWorld().getMaxHeight()) { - if (Terraplusminus.config.getBoolean("linked_worlds.enabled")) { - if (Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("SERVER")) { - //send player uuid and coordinates to bungee - - ByteArrayDataOutput out = ByteStreams.newDataOutput(); - out.writeUTF(player.getUniqueId().toString()); - if (ConfigurationHelper.getNextServerName("world") != null) { - out.writeUTF(ConfigurationHelper.getNextServerName("world")); - } else { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§cPlease contact server administrator. Your config is not set up correctly."); - return true; - } - out.writeUTF(coordinates[1] + ", " + coordinates[0]); - player.sendPluginMessage(Terraplusminus.instance, "bungeecord:terraplusminus", out.toByteArray()); - - player.sendMessage(Terraplusminus.config.getString("prefix") + "§cSending to another server..."); - return true; - } else if (Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE")) { - String[] nextServerName = ConfigurationHelper.getNextServerName(player.getWorld().getName()).split(","); - tpWorld = Bukkit.getWorld(nextServerName[0]); - height = height - yOffset + Integer.parseInt(nextServerName[1].replace(" ", "")); - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleporting to " + coordinates[1] + ", " + coordinates[0] + " on another server. This may take a bit..."); - //player.teleport(new Location(tpWorld, mcCoordinates[0] + xOffset, height, mcCoordinates[1] + zOffset, player.getLocation().getYaw(), player.getLocation().getPitch())); - PaperLib.teleportAsync(player, new Location(tpWorld, mcCoordinates[0] + xOffset, height, mcCoordinates[1] + zOffset, player.getLocation().getYaw(), player.getLocation().getPitch())); - return true; - } - } else { + if (minLat != 0 && maxLat != 0 && minLon != 0 && maxLon != 0 && !player.hasPermission("t+-.admin")) { + if (coordinates[1] < minLat || coordinates[0] < minLon || coordinates[1] > maxLat || coordinates[0] > maxLon) { + player.sendMessage(Terraplusminus.config.getString("prefix") + RED + "You cannot tpll to these coordinates, because this area is being worked on by another build team."); + return true; + } + } + + TerraConnector terraConnector = new TerraConnector(); + + double height; + if (args.length >= 3) { + height = Double.parseDouble(args[2]) + yOffset; + } else { + height = terraConnector.getHeight((int) mcCoordinates[0], (int) mcCoordinates[1]).join() + yOffset; // 57 + (-2032) = -1975 + } + if (height > player.getWorld().getMaxHeight()) { + if (Terraplusminus.config.getBoolean("linked_worlds.enabled")) { + if (Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("SERVER")) { + //send player uuid and coordinates to bungee + return sendPluginMessageToBungeeBridge(true, player, coordinates); + } else if (Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE")) { + LinkedWorld nextServer = ConfigurationHelper.getNextServerName(player.getWorld().getName()); + if (nextServer == null) { player.sendMessage(Terraplusminus.config.getString("prefix") + "§cYou cannot tpll to these coordinates, because the world is not high enough at the moment."); return true; } - } else if (height <= player.getWorld().getMinHeight()) { - if (Terraplusminus.config.getBoolean("linked_worlds.enabled")) { - if (Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("SERVER")) { - //send player uuid and coordinates to bungee - ByteArrayDataOutput out = ByteStreams.newDataOutput(); - out.writeUTF(player.getUniqueId().toString()); - if (ConfigurationHelper.getLastServerName("world") != null) { - out.writeUTF(ConfigurationHelper.getLastServerName("world")); - } else { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§cPlease contact server administrator. Your config is not set up correctly."); - return true; - } - out.writeUTF(coordinates[1] + ", " + coordinates[0]); - player.sendPluginMessage(Terraplusminus.instance, "bungeecord:terraplusminus", out.toByteArray()); - - player.sendMessage(Terraplusminus.config.getString("prefix") + "§cSending to another server..."); - return true; - } else if (Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE")) { - String[] lastServerName = ConfigurationHelper.getLastServerName(player.getWorld().getName()).split(","); - tpWorld = Bukkit.getWorld(lastServerName[0]); - height = height - yOffset + Integer.parseInt(lastServerName[1].replace(" ", "")); - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleporting to " + coordinates[1] + ", " + coordinates[0] + " on another server. This may take a bit..."); - //player.teleport(new Location(tpWorld, mcCoordinates[0] + xOffset, height, mcCoordinates[1] + zOffset, player.getLocation().getYaw(), player.getLocation().getPitch())); - PaperLib.teleportAsync(player, new Location(tpWorld, mcCoordinates[0] + xOffset, height, mcCoordinates[1] + zOffset, player.getLocation().getYaw(), player.getLocation().getPitch())); - return true; - } - } else { + tpWorld = Bukkit.getWorld(nextServer.getWorldName()); + height = height - yOffset + nextServer.getOffset(); + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleporting to " + coordinates[1] + ", " + coordinates[0] + " in another world. This may take a bit..."); + //player.teleport(new Location(tpWorld, mcCoordinates[0] + xOffset, height, mcCoordinates[1] + zOffset, player.getLocation().getYaw(), player.getLocation().getPitch())); + PaperLib.teleportAsync(player, new Location(tpWorld, mcCoordinates[0] + xOffset, height, mcCoordinates[1] + zOffset, player.getLocation().getYaw(), player.getLocation().getPitch())); + return true; + } + } else { + player.sendMessage(Terraplusminus.config.getString("prefix") + "§cYou cannot tpll to these coordinates, because the world is not high enough at the moment."); + return true; + } + } else if (height <= player.getWorld().getMinHeight()) { + if (Terraplusminus.config.getBoolean("linked_worlds.enabled")) { + if (Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("SERVER")) { + //send player uuid and coordinates to bungee + return sendPluginMessageToBungeeBridge(false, player, coordinates); + } else if (Terraplusminus.config.getString("linked_worlds.method").equalsIgnoreCase("MULTIVERSE")) { + LinkedWorld previousServer = ConfigurationHelper.getPreviousServerName(player.getWorld().getName()); + if (previousServer == null) { player.sendMessage(Terraplusminus.config.getString("prefix") + "§cYou cannot tpll to these coordinates, because the world is not low enough at the moment."); return true; } + tpWorld = Bukkit.getWorld(previousServer.getWorldName()); + height = height - yOffset + previousServer.getOffset(); + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleporting to " + coordinates[1] + ", " + coordinates[0] + " in another world. This may take a bit..."); + PaperLib.teleportAsync(player, new Location(tpWorld, mcCoordinates[0] + xOffset, height, mcCoordinates[1] + zOffset, player.getLocation().getYaw(), player.getLocation().getPitch())); + return true; } - Location location = new Location(tpWorld, mcCoordinates[0], height, mcCoordinates[1], player.getLocation().getYaw(), player.getLocation().getPitch()); - - if (PaperLib.isChunkGenerated(location)) { - if (args.length >= 3) { - location = new Location(tpWorld, mcCoordinates[0], height, mcCoordinates[1], player.getLocation().getYaw(), player.getLocation().getPitch()); - } else { - location = new Location(tpWorld, mcCoordinates[0], tpWorld.getHighestBlockYAt((int) mcCoordinates[0], (int) mcCoordinates[1]) + 1, mcCoordinates[1], player.getLocation().getYaw(), player.getLocation().getPitch()); - } - } else { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Location is generating. Please wait a moment..."); - } - PaperLib.teleportAsync(player, location); - - - if (args.length >= 3) { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleported to " + coordinates[1] + ", " + coordinates[0] + ", " + height + "."); - } else { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleported to " + coordinates[1] + ", " + coordinates[0] + "."); - } - - return true; } else { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7No permission for /tpll"); + player.sendMessage(Terraplusminus.config.getString("prefix") + "§cYou cannot tpll to these coordinates, because the world is not low enough at the moment."); return true; } + } + Location location = new Location(tpWorld, mcCoordinates[0], height, mcCoordinates[1], player.getLocation().getYaw(), player.getLocation().getPitch()); + + if (PaperLib.isChunkGenerated(location)) { + if (args.length >= 3) { + location = new Location(tpWorld, mcCoordinates[0], height, mcCoordinates[1], player.getLocation().getYaw(), player.getLocation().getPitch()); + } else { + location = new Location(tpWorld, mcCoordinates[0], tpWorld.getHighestBlockYAt((int) mcCoordinates[0], (int) mcCoordinates[1]) + 1, mcCoordinates[1], player.getLocation().getYaw(), player.getLocation().getPitch()); + } } else { - player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Usage: /tpll "); - return true; + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Location is generating. Please wait a moment..."); + } + PaperLib.teleportAsync(player, location); + + + if (args.length >= 3) { + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleported to " + coordinates[1] + ", " + coordinates[0] + ", " + height + "."); + } else { + player.sendMessage(Terraplusminus.config.getString("prefix") + "§7Teleported to " + coordinates[1] + ", " + coordinates[0] + "."); } + + return true; + } return true; } + private static boolean sendPluginMessageToBungeeBridge(boolean isNextServer, Player player, double[] coordinates) { + ByteArrayDataOutput out = ByteStreams.newDataOutput(); + out.writeUTF(player.getUniqueId().toString()); + LinkedWorld server; + if (isNextServer) { + server = ConfigurationHelper.getNextServerName(Bukkit.getServer().getName()); //TODO: Bukkit.getServer().getName() does not return the real name + } else { + server = ConfigurationHelper.getPreviousServerName(Bukkit.getServer().getName()); //TODO: Bukkit.getServer().getName() does not return the real name + } + + if (server != null) { + out.writeUTF(server.getWorldName() + ", " + server.getOffset()); + } else { + player.sendMessage(Terraplusminus.config.getString("prefix") + "§cPlease contact server administrator. Your config is not set up correctly."); + return true; + } + out.writeUTF(coordinates[1] + ", " + coordinates[0]); + player.sendPluginMessage(Terraplusminus.instance, "bungeecord:terraplusminus", out.toByteArray()); + + player.sendMessage(Terraplusminus.config.getString("prefix") + "§cSending to another server..."); + return true; + } + public boolean isDouble(String str) { try { Double.parseDouble(str); diff --git a/src/main/java/de/btegermany/terraplusminus/commands/WhereCommand.java b/src/main/java/de/btegermany/terraplusminus/commands/WhereCommand.java index 6b25cef..03b5f0f 100644 --- a/src/main/java/de/btegermany/terraplusminus/commands/WhereCommand.java +++ b/src/main/java/de/btegermany/terraplusminus/commands/WhereCommand.java @@ -25,29 +25,28 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command return true; } Player player = (Player) commandSender; - if (player.hasPermission("t+-.where")) { - int xOffset = Terraplusminus.config.getInt("terrain_offset.x"); - int zOffset = Terraplusminus.config.getInt("terrain_offset.z"); - - double[] mcCoordinates = new double[2]; - mcCoordinates[0] = player.getLocation().getX() - xOffset; - mcCoordinates[1] = player.getLocation().getZ() - zOffset; - System.out.println(mcCoordinates[0] + ", " + mcCoordinates[1]); - double[] coordinates = new double[0]; - try { - coordinates = bteGeneratorSettings.projection().toGeo(mcCoordinates[0], mcCoordinates[1]); - } catch (OutOfProjectionBoundsException e) { - e.printStackTrace(); - } - TextComponent message = new TextComponent(Terraplusminus.config.getString("prefix") + "§7Your coordinates are:"); - message.addExtra("\n§8" + coordinates[1] + ", " + coordinates[0] + "§7."); - message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://maps.google.com/maps?t=k&q=loc:" + coordinates[1] + "+" + coordinates[0])); - message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§7Click here to view in Google Maps.").create())); - player.spigot().sendMessage(message); - } else { + if (!player.hasPermission("t+-.where")) { player.sendMessage(Terraplusminus.config.getString("prefix") + "§7No permission for /where"); return true; } + int xOffset = Terraplusminus.config.getInt("terrain_offset.x"); + int zOffset = Terraplusminus.config.getInt("terrain_offset.z"); + + double[] mcCoordinates = new double[2]; + mcCoordinates[0] = player.getLocation().getX() - xOffset; + mcCoordinates[1] = player.getLocation().getZ() - zOffset; + System.out.println(mcCoordinates[0] + ", " + mcCoordinates[1]); + double[] coordinates = new double[0]; + try { + coordinates = bteGeneratorSettings.projection().toGeo(mcCoordinates[0], mcCoordinates[1]); + } catch (OutOfProjectionBoundsException e) { + e.printStackTrace(); + } + TextComponent message = new TextComponent(Terraplusminus.config.getString("prefix") + "§7Your coordinates are:"); + message.addExtra("\n§8" + coordinates[1] + ", " + coordinates[0] + "§7."); + message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://maps.google.com/maps?t=k&q=loc:" + coordinates[1] + "+" + coordinates[0])); + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§7Click here to view in Google Maps.").create())); + player.spigot().sendMessage(message); } return true; } diff --git a/src/main/java/de/btegermany/terraplusminus/events/PlayerMoveEvent.java b/src/main/java/de/btegermany/terraplusminus/events/PlayerMoveEvent.java index 9d9a5eb..8368eb6 100644 --- a/src/main/java/de/btegermany/terraplusminus/events/PlayerMoveEvent.java +++ b/src/main/java/de/btegermany/terraplusminus/events/PlayerMoveEvent.java @@ -2,6 +2,7 @@ import de.btegermany.terraplusminus.Terraplusminus; import de.btegermany.terraplusminus.utils.ConfigurationHelper; +import de.btegermany.terraplusminus.utils.LinkedWorld; import io.papermc.lib.PaperLib; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; @@ -16,23 +17,25 @@ import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; public class PlayerMoveEvent implements Listener { - BukkitRunnable runnable; - ArrayList taskIDs = new ArrayList<>(); - int yOffset; + private BukkitRunnable runnable; + private ArrayList taskIDs = new ArrayList<>(); + private int yOffset; final int yOffsetConfigEntry; - final int xOffset; - final int zOffset; - final boolean linkedWorldsEnabled; + private final int xOffset; + private final int zOffset; + private final boolean linkedWorldsEnabled; - final String linkedWorldsMethod; - Plugin plugin; - String lastServerName; - String nextServerName; + private final String linkedWorldsMethod; + private Plugin plugin; + private List worlds; + private HashMap worldHashMap; public PlayerMoveEvent(Plugin plugin) { this.plugin = plugin; @@ -41,48 +44,37 @@ public PlayerMoveEvent(Plugin plugin) { this.zOffset = Terraplusminus.config.getInt("terrain_offset.z"); this.linkedWorldsEnabled = Terraplusminus.config.getBoolean("linked_worlds.enabled"); this.linkedWorldsMethod = Terraplusminus.config.getString("linked_worlds.method"); - lastServerName = ConfigurationHelper.getLastServerName("world"); - nextServerName = ConfigurationHelper.getNextServerName("world"); + this.worlds = ConfigurationHelper.getWorlds(); + this.worldHashMap = new HashMap<>(); + if (this.linkedWorldsEnabled && this.linkedWorldsMethod.equalsIgnoreCase("MULTIVERSE")) { + for (LinkedWorld world : worlds) { + this.worldHashMap.put(world.getWorldName(), world.getOffset()); + } + } else { + for (World world : Bukkit.getWorlds()) { + this.worldHashMap.put(world.getName(), yOffsetConfigEntry); + } + } + this.startKeepActionBarAlive(); } @EventHandler void onPlayerMove(org.bukkit.event.player.PlayerMoveEvent event) { - Player p = event.getPlayer(); - // Multiverse support - if (this.linkedWorldsEnabled && this.linkedWorldsMethod.equalsIgnoreCase("MULTIVERSE")) { - if (lastServerName != null) { - if (p.getWorld().getName().equalsIgnoreCase(lastServerName.split(",")[0])) { - yOffset = Integer.parseInt(lastServerName.split(",")[1].replace(" ", "")); - } - } - if (nextServerName != null) { - if (p.getWorld().getName().equalsIgnoreCase(nextServerName.split(",")[0])) { - yOffset = Integer.parseInt(nextServerName.split(",")[1].replace(" ", "")); - } - } - if (p.getWorld().getName().equalsIgnoreCase("world")) { - yOffset = yOffsetConfigEntry; + setHeightInActionBar(event.getPlayer()); + } + + private void startKeepActionBarAlive() { + Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> { + for (Player p : Bukkit.getOnlinePlayers()) { + setHeightInActionBar(p); } - } else { - yOffset = yOffsetConfigEntry; - } + }, 0, 20); + } + + private void setHeightInActionBar(Player p) { if (p.getInventory().getItemInMainHand().getType() != Material.DEBUG_STICK) { - runnable = new BukkitRunnable() { - @Override - public void run() { - int height = p.getLocation().getBlockY() - yOffset; - p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("§l" + height + "m")); - } - }; - runnable.runTaskTimer(plugin, 0, 20); - if (!taskIDs.contains(runnable.getTaskId())) { - taskIDs.add(runnable.getTaskId()); - } - } else { - for (int id : taskIDs) { - Bukkit.getScheduler().cancelTask(id); - } - taskIDs.clear(); + int height = p.getLocation().getBlockY() - worldHashMap.get(p.getWorld().getName()); + p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("§l" + height + "m")); } } @@ -102,23 +94,25 @@ void onPlayerFall(org.bukkit.event.player.PlayerMoveEvent event) { public void run() { // Teleport player from world to world if (p.getLocation().getY() < 0) { - String[] lastServerName = ConfigurationHelper.getLastServerName(world.getName()).split(","); - if (lastServerName != null) { - World tpWorld = Bukkit.getWorld(lastServerName[0]); - Location newLocation = new Location(tpWorld, location.getX() + xOffset, tpWorld.getMaxHeight(), location.getZ() + zOffset, location.getYaw(), location.getPitch()); - PaperLib.teleportAsync(p, newLocation); - p.sendMessage(Terraplusminus.config.getString("prefix") + "§7You have been teleported to another world."); + LinkedWorld previousServer = ConfigurationHelper.getPreviousServerName(world.getName()); + if (previousServer != null) { + teleportPlayer(previousServer, location, p); } } else if (p.getLocation().getY() > world.getMaxHeight()) { - String[] nextServerName = ConfigurationHelper.getNextServerName(world.getName()).split(","); - if (nextServerName != null) { - World tpWorld = Bukkit.getWorld(nextServerName[0]); - Location newLocation = new Location(tpWorld, location.getX() + xOffset, tpWorld.getMinHeight(), location.getZ() + zOffset, location.getYaw(), location.getPitch()); - PaperLib.teleportAsync(p, newLocation); - p.sendMessage(Terraplusminus.config.getString("prefix") + "§7You have been teleported to another world."); + LinkedWorld nextServer = ConfigurationHelper.getNextServerName(world.getName()); + if (nextServer != null) { + teleportPlayer(nextServer, location, p); } } } }.runTaskLater(plugin, 60L); } + + private void teleportPlayer(LinkedWorld linkedWorld, Location location, Player p) { + World tpWorld = Bukkit.getWorld(linkedWorld.getWorldName()); + Location newLocation = new Location(tpWorld, location.getX() + xOffset, tpWorld.getMinHeight(), location.getZ() + zOffset, location.getYaw(), location.getPitch()); + PaperLib.teleportAsync(p, newLocation); + p.setFlying(true); + p.sendMessage(Terraplusminus.config.getString("prefix") + "§7You have been teleported to another world."); + } } diff --git a/src/main/java/de/btegermany/terraplusminus/utils/ConfigurationHelper.java b/src/main/java/de/btegermany/terraplusminus/utils/ConfigurationHelper.java index 3e8d298..015f40e 100644 --- a/src/main/java/de/btegermany/terraplusminus/utils/ConfigurationHelper.java +++ b/src/main/java/de/btegermany/terraplusminus/utils/ConfigurationHelper.java @@ -6,8 +6,11 @@ import org.jetbrains.annotations.NotNull; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; public final class ConfigurationHelper { + private static final List worlds = convertList(Terraplusminus.config.getMapList("linked_worlds.worlds")); /** * Returns a material from the configuration, @@ -34,40 +37,59 @@ private ConfigurationHelper() { throw new IllegalStateException(); } - private static List getList() { - return (List) Terraplusminus.config.getList("linked_worlds.worlds"); + public static List convertList(List> originalList) { + return originalList.stream() + .map(ConfigurationHelper::convertMapToLinkedWorld) + .filter(world -> !world.getWorldName().equalsIgnoreCase("another_world/server") || !world.getWorldName().equalsIgnoreCase("current_world/server")) + .collect(Collectors.toList()); } - public static String getNextServerName(String currentWorldName) { - List servers = getList(); - int index = servers.indexOf("current_world/server"); - String servername; - if (currentWorldName.equalsIgnoreCase("world")) { - servername = servers.get(index + 1); - } else { - return "world, 0"; + private static LinkedWorld convertMapToLinkedWorld(Map originalMap) { + String worldName = originalMap.get("name").toString(); + int offset = (Integer) originalMap.get("offset"); + return new LinkedWorld(worldName, offset); + } + + public static LinkedWorld getNextServerName(String currentWorldName) { + int currentIndex = -1; + + for (int i = 0; i < worlds.size(); i++) { + LinkedWorld world = worlds.get(i); + if (world.getWorldName().equalsIgnoreCase(currentWorldName)) { + currentIndex = i; + break; + } } - if (servername.equals("another_world/server")) { - return null; + + if (currentIndex >= 0 && currentIndex < worlds.size() - 1) { + return worlds.get(currentIndex + 1); } else { - return servername; + // Entweder wurde die Welt nicht gefunden oder sie ist die letzte Welt in der Liste + return null; } } - public static String getLastServerName(String currentWorldName) { - List servers = getList(); - int index = servers.indexOf("current_world/server"); - String servername; - if (currentWorldName.equalsIgnoreCase("world")) { - servername = servers.get(index - 1); - } else { - return "world, 0"; + public static LinkedWorld getPreviousServerName(String currentWorldName) { + int currentIndex = -1; + + for (int i = 0; i < worlds.size(); i++) { + LinkedWorld world = worlds.get(i); + if (world.getWorldName().equalsIgnoreCase(currentWorldName)) { + currentIndex = i; + break; + } } - if (servername.equals("another_world/server")) { - return null; + + if (currentIndex > 0) { + return worlds.get(currentIndex - 1); } else { - return servername; + // Entweder wurde die Welt nicht gefunden oder sie ist die erste Welt in der Liste + return null; } } + public static List getWorlds() { + return worlds; + } + } diff --git a/src/main/java/de/btegermany/terraplusminus/utils/LinkedWorld.java b/src/main/java/de/btegermany/terraplusminus/utils/LinkedWorld.java new file mode 100644 index 0000000..6d19e9b --- /dev/null +++ b/src/main/java/de/btegermany/terraplusminus/utils/LinkedWorld.java @@ -0,0 +1,28 @@ +package de.btegermany.terraplusminus.utils; + +public class LinkedWorld { + + private String worldName; + private int offset; + + public LinkedWorld(String worldName, int offset) { + this.worldName = worldName; + this.offset = offset; + } + + public String getWorldName() { + return worldName; + } + + public void setWorldName(String worldName) { + this.worldName = worldName; + } + + public int getOffset() { + return offset; + } + + public void setOffset(int offset) { + this.offset = offset; + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 47b5aa5..2f8e48c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -37,12 +37,15 @@ terrain_offset: # If the height limit in this world/server is not enough, other worlds/servers can be linked to generate higher or lower sections linked_worlds: enabled: false - method: 'SERVER' # 'SERVER' or 'MULTIVERSE' + method: 'MULTIVERSE' # 'SERVER' or 'MULTIVERSE' # if method = MULTIVERSE -> world_name, y-offset worlds: - - another_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section (-2032) - (-1) m a.s.l. it has a y-offset of -2032. - - current_world/server # do not change! e.g. this world/server has a datapack to extend height to 2032. it covers the height section 0 - 2032 m a.s.l. - - another_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section 2033 - 4064 m a.s.l. it has a y-offset of 2032 + - name: another_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section (-2032) - (-1) m a.s.l. it has a y-offset of -2032. + offset: 2032 + - name: current_world/server # do not change! e.g. this world/server has a datapack to extend height to 2032. it covers the height section 0 - 2032 m a.s.l. + offset: 0 + - name: another_world/server # e.g. this world/server has a datapack to extend height to 2032. it covers the height section 2033 - 4064 m a.s.l. it has a y-offset of 2032 + offset: -2032 # If disabled, tree generation is turned off.