Duy Luân Lê

Tạo cho tôi một plugin cho phép thế giới tạo ra farland như UNSTABLE SMP

Kodari AI
KodariOct 1 at 2:40 pm 1
FarlandWorldGenerator
Generates a unique Farland world for Minecraft servers, inspired by UNSTABLE SMP. The plugin creates a procedurally generated landscape featuring floating islands, crystal caverns, and ancient ruins. Players can explore diverse biomes including the Whispering Forest, the Crystal Desert, and the Abyssal Depths. The world generation system uses custom algorithms to place terrain features, spawn points, and resource deposits. Includes a command system for world regeneration, biome-specific mob spawning, and unique loot tables. Features dynamic weather patterns and day-night cycles that affect gameplay. The plugin integrates with existing world data while adding new generation layers for enhanced exploration and adventure.
  1. Tạo generator địa hình thường và vùng Farlands biến dạng theo cấu hình.

  2. Thêm lệnh /farlands create [world] để tạo thế giới dùng generator này.

  3. Thêm cấu hình và metadata/build files cho Paper 1.21.4.

Đã tạo plugin Farlands cho Paper 1.21.4. Lệnh /farlands create [world] tạo thế giới mới với địa hình biến dạng kiểu Farlands; mặc định tên là unstable_farlands. Vùng Farlands bắt đầu cách tâm thế giới 256 block theo cấu hình config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
6 214
src/main/java/com/kodari/farlands/FarlandsPlugin.java
package com.kodari.farlands;

import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Random;

public final class FarlandsPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        saveDefaultConfig();
        getLogger().info("Farlands is ready. Use /farlands create [world] to create a world.");
    }

    @Override
    public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
        return createGenerator();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length != 1 && args.length != 2 || !args[0].equalsIgnoreCase("create")) {
            sender.sendMessage("Usage: /farlands create [world]");
            return true;
        }

        String worldName = args.length == 2 ? args[1] : getConfig().getString("world-name", "unstable_farlands");
        if (worldName == null || worldName.isBlank()) {
            sender.sendMessage("World name cannot be empty.");
            return true;
        }
        if (Bukkit.getWorld(worldName) != null) {
            sender.sendMessage("That world is already loaded.");
            return true;
        }

        WorldCreator creator = new WorldCreator(worldName);
        creator.generator(createGenerator());
        World world = Bukkit.createWorld(creator);
        if (world == null) {
            sender.sendMessage("Could not create the Farlands world.");
            return true;
        }

        int spawnY = world.getHighestBlockYAt(0, 0) + 1;
        world.setSpawnLocation(0, spawnY, 0);
        sender.sendMessage("Created Farlands world: " + world.getName());
        return true;
    }

    private ChunkGenerator createGenerator() {
        return new FarlandsChunkGenerator(
                getConfig().getInt("terrain.base-height", 70),
                getConfig().getInt("terrain.roughness", 8),
                getConfig().getInt("terrain.water-level", 62),
                getConfig().getInt("farlands.start", 256),
                getConfig().getInt("farlands.strength", 42)
        );
    }
}