Stef

make me a spawn for my new server like a spawn and make it really cool with a bot that when you click it, it opens the rtp menu and also there to be a kit and a pvp arena there and the server is called cozy smp

Kodari AI
KodariOct 27 at 9:33 am 1
CozySMPHub
A comprehensive spawn hub plugin for the Cozy SMP server featuring an interactive NPC bot that opens a random teleport (RTP) menu when clicked, a fully functional kit system with multiple starter loadouts, and a designated PvP arena area with safe teleportation. The plugin includes a visually impressive spawn design with custom structures, particle effects, and ambient lighting. Players can interact with the bot via proximity or click detection, access their chosen kit through a GUI menu, and teleport to the PvP arena where combat is enabled while the rest of the spawn remains peaceful. The plugin manages spawn protection, prevents griefing in the hub area, and provides clear visual markers for all zones. Includes configuration for arena boundaries, kit cooldowns, and RTP distance limits.
  1. Generate a cozy, lantern-lit spawn plaza and nearby enclosed PvP arena with an in-game setup command.

  2. Add a clickable guide villager with a menu for random teleport, the starter kit, and the arena.

  3. Create the plugin scaffold and default settings.

Created the Cozy SMP plugin. As an op, stand where you want the spawn and run /cozyspawn setup. It builds a lantern-lit plaza with a fountain and trees, an enclosed PvP arena nearby, sets the world spawn, and places a clickable guide villager. Setup replaces blocks in those build areas.

Right-click the guide for the hub menu: random teleport, starter kit, or arena. You can also use /cozyspawn menu, /cozyspawn kit, and /cozyspawn arena. RTP distance is configurable in config.yml.

This builds directly in the world; it isn’t a .schem file.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
4 382
src/main/java/com/cozy/smp/CozySMPPlugin.java
package com.cozy.smp;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;

public final class CozySMPPlugin extends JavaPlugin implements Listener, CommandExecutor {
    private static final String MENU_TITLE = ChatColor.DARK_GREEN + "Cozy SMP | Hub";
    private static final String GUIDE_TAG = "cozysmp-guide";

    @Override
    public void onEnable() {
        saveDefaultConfig();
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("cozyspawn").setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("This command can only be used in-game.");
            return true;
        }

        if (args.length == 0 || args[0].equalsIgnoreCase("menu")) {
            openHubMenu(player);
            return true;
        }

        switch (args[0].toLowerCase()) {
            case "setup" -> {
                if (!player.hasPermission("cozysmp.admin")) {
                    player.sendMessage(color("&cYou don't have permission to build the Cozy SMP spawn."));
                    return true;
                }
                buildHub(player.getLocation().getBlock().getLocation());
                player.sendMessage(color("&aCozy SMP spawn and PvP arena built. Your world spawn is now set here."));
            }
            case "kit" -> giveStarterKit(player);
            case "arena" -> teleportToArena(player);
            default -> player.sendMessage(color("&eUsage: /cozyspawn [setup|menu|kit|arena]"));
        }
        return true;
    }

    private void buildHub(Location hub) {
        World world = hub.getWorld();
        int x = hub.getBlockX();
        int y = hub.getBlockY();
        int z = hub.getBlockZ();

        for (int dx = -12; dx <= 12; dx++) {
            for (int dz = -12; dz <= 12; dz++) {
                boolean border = Math.abs(dx) == 12 || Math.abs(dz) == 12;
                String floor = border ? "SPRUCE_PLANKS"
                        : ((dx + dz) % 7 == 0 ? "MOSSY_STONE_BRICKS" : "STONE_BRICKS");
                setBlock(world, x + dx, y - 1, z + dz, floor);
            }
        }

        for (int pathX = 12; pathX <= 28; pathX++) {
            for (int pathZ = -1; pathZ <= 1; pathZ++) {
                setBlock(world, x + pathX, y - 1, z + pathZ, "COBBLESTONE");
            }
        }

        buildFountain(world, x, y, z + 6);
        buildLanternPost(world, x - 10, y, z - 10);
        buildLanternPost(world, x + 10, y, z - 10);
        buildLanternPost(world, x - 10, y, z + 10);
        buildLanternPost(world, x + 10, y, z + 10);
        buildTree(world, x - 17, y, z - 11);
        buildTree(world, x - 17, y, z + 11);
        buildTree(world, x + 17, y, z - 11);
        buildTree(world, x + 17, y, z + 11);

        Location arena = hub.clone().add(40, 0, 0);
        buildArena(arena);
        getConfig().set("hub.world", world.getName());
        getConfig().set("hub.x", x + 0.5);
        getConfig().set("hub.y", y);
        getConfig().set("hub.z", z + 0.5);
        getConfig().set("arena.world", world.getName());
        getConfig().set("arena.x", arena.getBlockX() + 0.5);
        getConfig().set("arena.y", arena.getBlockY());
        getConfig().set("arena.z", arena.getBlockZ() + 0.5);
        saveConfig();

        world.setSpawnLocation(x, y, z);
        removeOldGuides();
        Villager guide = world.spawn(new Location(world, x + 0.5, y, z - 7.5), Villager.class);
        guide.setAI(false);
        guide.setInvulnerable(true);
        guide.setPersistent(true);
        guide.setSilent(true);
        guide.setProfession(Villager.Profession.LIBRARIAN);
        guide.setCustomName(color("&a&lCozy Guide &7(Right-click)"));
        guide.setCustomNameVisible(true);
        guide.addScoreboardTag(GUIDE_TAG);
    }

    private void buildFountain(World world, int x, int y, int z) {
        for (int dx = -2; dx <= 2; dx++) {
            for (int dz = -2; dz <= 2; dz++) {
                if (Math.max(Math.abs(dx), Math.abs(dz)) == 2) {
                    setBlock(world, x + dx, y, z + dz, "STONE_BRICKS");
                } else {
                    setBlock(world, x + dx, y, z + dz, "WATER");
                }
            }
        }
        setBlock(world, x, y + 1, z, "SEA_LANTERN");
    }

    private void buildLanternPost(World world, int x, int y, int z) {
        for (int height = 0; height < 4; height++) {
            setBlock(world, x, y + height, z, "SPRUCE_FENCE");
        }
        setBlock(world, x, y + 4, z, "LANTERN");
    }

    private void buildTree(World world, int x, int y, int z) {
        setBlock(world, x, y - 1, z, "GRASS_BLOCK");
        for (int height = 0; height < 4; height++) {
            setBlock(world, x, y + height, z, "SPRUCE_LOG");
        }
        for (int dx = -2; dx <= 2; dx++) {
            for (int dz = -2; dz <= 2; dz++) {
                if (Math.abs(dx) + Math.abs(dz) <= 3) {
                    setBlock(world, x + dx, y + 2, z + dz, "OAK_LEAVES");
                    if (Math.abs(dx) + Math.abs(dz) <= 2) {
                        setBlock(world, x + dx, y + 3, z + dz, "OAK_LEAVES");
                    }
                }
            }
        }
        setBlock(world, x, y + 4, z, "OAK_LEAVES");
    }

    private void buildArena(Location center) {
        World world = center.getWorld();
        int x = center.getBlockX();
        int y = center.getBlockY();
        int z = center.getBlockZ();

        for (int dx = -12; dx <= 12; dx++) {
            for (int dz = -12; dz <= 12; dz++) {
                boolean edge = Math.abs(dx) == 12 || Math.abs(dz) == 12;
                String floor = edge ? "STONE_BRICKS"
                        : ((dx + dz) % 5 == 0 ? "MOSSY_STONE_BRICKS" : "POLISHED_ANDESITE");
                setBlock(world, x + dx, y - 1, z + dz, floor);

                if (edge && !(Math.abs(dx) == 12 && Math.abs(dz) <= 1)) {
                    setBlock(world, x + dx, y, z + dz, "STONE_BRICKS");
                    setBlock(world, x + dx, y + 1, z + dz, "STONE_BRICKS");
                    setBlock(world, x + dx, y + 2, z + dz, "SPRUCE_FENCE");
                }
            }
        }

        for (int dx : new int[]{-12, 12}) {
            for (int dz : new int[]{-12, 12}) {
                for (int height = 0; height <= 3; height++) {
                    setBlock(world, x + dx, y + height, z + dz, "SPRUCE_LOG");
                }
                setBlock(world, x + dx, y + 4, z + dz, "LANTERN");
            }
        }
    }

    private void setBlock(World world, int x, int y, int z, String materialName) {
        XMaterial.matchXMaterial(materialName)
                .map(XMaterial::parseMaterial)
                .ifPresent(material -> world.getBlockAt(x, y, z).setType(material, false));
    }

    private void removeOldGuides() {
        for (World world : Bukkit.getWorlds()) {
            for (Entity entity : world.getEntities()) {