Hanson Nugent

enchain smp

Kodari AI
KodariNov 4 at 9:26 pm 1
EnchainSMPCore
EnchainSMPCore is a comprehensive Minecraft plugin designed for the Enchain SMP server. It provides essential survival multiplayer management features including custom enchantment systems, player economy integration, land claiming protection, and advanced grief prevention. The plugin implements a robust permission-based command system, configurable GUI menus for shop and auction functionality, and automated event listeners for player interactions. It features database persistence for player data, customizable enchantment tiers with visual effects, and seamless integration with popular economy APIs. The core architecture utilizes modular service classes for maintainability, offering server administrators extensive configuration options through YAML files while delivering a polished, lag-optimized gameplay experience for the Enchain community.

I’ll create Enchain SMP as a Java server plugin with configurable join messages and /spawn / /setspawn commands. The spawn location will be saved in the plugin config.

Created Enchain SMP with configurable join messages, /spawn, and operator-only /setspawn. Spawn coordinates are saved in config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 150
src/main/java/net/enchain/smp/EnchainSMP.java
package net.enchain.smp;

import java.util.Objects;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class EnchainSMP extends JavaPlugin implements Listener, CommandExecutor {

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

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        String message = getConfig().getString("messages.join", "&aWelcome to Enchain SMP, &f%player%&a!");
        event.getPlayer().sendMessage(color(message.replace("%player%", event.getPlayer().getName())));
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage(message("messages.players-only"));
            return true;
        }

        if (command.getName().equalsIgnoreCase("setspawn")) {
            saveSpawn(player.getLocation());
            player.sendMessage(message("messages.spawn-set"));
            return true;
        }

        Location spawn = loadSpawn();
        if (spawn == null) {
            player.sendMessage(message("messages.spawn-not-set"));
            return true;
        }
        if (spawn.getWorld() == null) {
            player.sendMessage(message("messages.spawn-world-missing"));
            return true;
        }

        player.teleport(spawn);
        player.sendMessage(message("messages.spawn-teleported"));
        return true;
    }

    private void saveSpawn(Location location) {
        getConfig().set("spawn.world", location.getWorld().getName());
        getConfig().set("spawn.x", location.getX());
        getConfig().set("spawn.y", location.getY());
        getConfig().set("spawn.z", location.getZ());
        getConfig().set("spawn.yaw", location.getYaw());
        getConfig().set("spawn.pitch", location.getPitch());
        saveConfig();
    }

    private Location loadSpawn() {
        String worldName = getConfig().getString("spawn.world");
        if (worldName == null) {
            return null;
        }

        World world = Bukkit.getWorld(worldName);
        if (world == null) {
            return new Location(null, 0, 0, 0);
        }

        return new Location(
                world,
                getConfig().getDouble("spawn.x"),
                getConfig().getDouble("spawn.y"),
                getConfig().getDouble("spawn.z"),
                (float) getConfig().getDouble("spawn.yaw"),
                (float) getConfig().getDouble("spawn.pitch")
        );
    }

    private String message(String path) {
        return color(getConfig().getString(path, ""));
    }

    private String color(String text) {
        return ChatColor.translateAlternateColorCodes('&', text);
    }
}