Untitled

 avatar
unknown
plain_text
a year ago
1.5 kB
16
Indexable
    public boolean loadChunk(Player player) {
        if (modifyFile.contains("Players." + player.getName())) {
            String path = "Players." + player.getName();
            String worldName = modifyFile.getString("Players." + player.getName() + ".world");
            World world = Bukkit.getWorld(worldName);
            double cSize = modifyFile.getDouble(path + ".borderSize");
            int locx = modifyFile.getInt(path + ".x");
            int locy = modifyFile.getInt(path + ".y");
            int locz = modifyFile.getInt(path + ".z");

            Location location = new Location(world, locx, locy, locz);

            try {
                player.teleport(location);

                Bukkit.getLogger().info("World: " + (world != null ? world.getName() : "null"));
                Bukkit.getLogger().info("Location: " + location);
                Bukkit.getLogger().info("Border size: " + cSize);

                worldBorderApi.setBorder(player, cSize, location);
                player.sendMessage(ChatColor.GREEN + "Chunk loaded");
                return true;
            } catch (Exception e) {
                player.sendMessage(ChatColor.RED + "Failed to load chunk");
                e.printStackTrace();
                return false;
            }

        } else {
            player.sendMessage(ChatColor.RED + "You don't have a chunk, create one with /c create");
            return false;
        }
    }
Editor is loading...
Leave a Comment