moizgamer23
📎 1 file 5,347 chars
📄
pasted-code-1789036927496.txt
txt 71 lines
▶
Act as an expert Senior Minecraft Plugin Developer specializing in Paper 1.21.11 (Java 21). 

Write a complete, single-file Java plugin (including plugin.yml) called "SeptiumSMP" targeting the Minecraft 1.21.11 API.

### COMMAND STRUCTURE HUB:
All functionality MUST be routed through the single root command `/septiumsmp` (aliases: `/ssmp`, `/septium`).

Commands Layout:
1. /septiumsmp register  -> Registers current player's IP address and locks it to their account.
2. /septiumsmp login  -> ONLY required if joining from a DIFFERENT IP or new location. If joining from the registered IP, auto-authenticate and skip login completely.
3. /septiumsmp start -> (Permission: septiumsmp.admin) Initializes the SMP session, playing a sound across the server, broadcasting a welcome title screen, and unfreezing world interaction.
4. /septiumsmp ipadmin unregister  -> (Permission: septiumsmp.admin) Removes an IP record.
5. /septiumsmp addpower   -> (Permission: septiumsmp.admin) Dynamically binds an ability to the held item via PersistentDataContainer (PDC).
6. /septiumsmp give  -> (Permission: septiumsmp.admin) Gives one of the 7 custom dual-ability items.
7. /septiumsmp help -> Displays formatted command menu.

---

### PLUGIN SPECIFICATIONS:

1. ONE-TIME IP REGISTER & AUTO-LOGIN SYSTEM:
- On Player Join (PlayerJoinEvent): Check player's IP address against stored records in `ip_data.yml`.
- IF NOT REGISTERED: Prompt the player to run `/septiumsmp register `. Freeze movement and interactions until registered.
- IF REGISTERED AND SAME IP: Automatically authenticate the player on join! No `/septiumsmp login` prompt needed. Send action-bar notification: "§a[SeptiumSMP] Auto-authenticated from home IP!"
- IF REGISTERED BUT DIFFERENT IP/LOCATION: Freeze the player (cancel PlayerMoveEvent, PlayerInteractEvent, BlockBreakEvent, BlockPlaceEvent, and CommandPreprocessEvent except for `/septiumsmp login`) and prompt: "§c[SeptiumSMP] IP Mismatch! Authenticate using /septiumsmp login ".

2. DYNAMIC PDC POWER BINDING ENGINE:
- Command `/septiumsmp addpower  ` attaches powers directly to ANY held item using Paper 1.21 PersistentDataContainer (`NamespacedKey`).
- Automatically appends/updates lore to reflect bound abilities (e.g., "§5✦ Imbued Power (Shift-Right): §dVOID_PULL").
- Uses `PlayerInteractEvent` with `player.isSneaking()` checks to trigger abilities cleanly on Shift + Left-Click or Shift + Right-Click.

3. 7 CUSTOM DUAL-POWER CRAZY ITEMS:
Every custom item MUST have TWO active abilities (Shift+Right AND Shift+Left):

1. "Void Singularity Blade" (`NETHERITE_SWORD`)
   - Shift + Right: [Void Pull] Pulls all entities within 12 blocks toward the caster with black portal particles and dragon sound.
   - Shift + Left: [Reality Tear] Instantly teleports the caster 8 blocks in their looking direction with ender shockwaves.

2. "Oblivion Core Mace" (`MACE`)
   - Shift + Right: [Orbital Laser] Strikes the target block up to 30 blocks away with a vertical beam of END_ROD particles, dealing 14 AOE damage and setting enemies on fire.
   - Shift + Left: [Seismic Slam] Launches the caster 15 blocks into the air with heavy explosion particles and grants 5 seconds of Slow Falling.

3. "Nebula Shadow Bow" (`BOW`)
   - Shift + Right: [Shadow Stealth] Grants Invisibility, Speed III, and Resistance II for 8 seconds with SOUL_FIRE_FLAME aura particles.
   - Shift + Left: [Arrow Rain] Spawns a barrage of 10 spectral arrows raining down from 15 blocks above the targeted location.

4. "Chronos Time Spear" (`TRIDENT`)
   - Shift + Right: [Time Freeze] Freezes all players/mobs within 10 blocks for 4 seconds (applies Slowness 255 and Blindness).
   - Shift + Left: [Recall] Teleports the player back to the location they were at 5 seconds prior.

5. "Infernal Sun Axe" (`NETHERITE_AXE`)
   - Shift + Right: [Flame Ring] Spawns an expanding ring of FLAME particles 6 blocks wide, pushing enemies back and igniting them.
   - Shift + Left: [Berserk Drain] Steals 3 hearts (6 HP) from the nearest enemy within 5 blocks to heal the caster.

6. "Phantom Winds Scythe" (`NETHERITE_HOE`)
   - Shift + Right: [Gale Push] Emits a gust of WIND_CHARGE particles that launches all nearby enemies 10 blocks back.
   - Shift + Left: [Elytra Flight] Grants a 5-second velocity forward/upward boost mimicking infinite glide flight without needing an Elytra equipped.

7. "Aegis Sanctum Shield" (`SHIELD`)
   - Shift + Right: [Absolute Fortress] Encloses the user in a SHULKER_BULLET particle dome, granting total invulnerability (Resistance 255) for 3 seconds.
   - Shift + Left: [Reflective Wave] Knocks back and damages all attackers within 4 blocks.

4. COOLDOWN SYSTEM & ACTION BAR FEEDBACK:
- 5-second per-player cooldown for item abilities.
- Display an action bar timer: "§cAbility on cooldown! X.Xs remaining".
- Play a BASS note block sound when denied, and distinct custom sound effects upon successful activation.

5. TECHNICAL REQUIREMENTS:
- Target Java 21 & Paper 1.21.11 API.
- Fully self-contained single-file plugin structure with a complete `plugin.yml`.
- Proper null checks, location tracking, and item metadata handling.
Kodari AI
KodariSep 10 at 10:48 am 2
SeptiumSMP
SeptiumSMP is a comprehensive Paper plugin for Minecraft 1.21.11 that implements a one-time IP registration and auto-login system, a dynamic PDC power binding engine for binding abilities to held items, seven custom dual-power items with unique Shift+Right and Shift+Left abilities, a 5-second per-player cooldown system with action bar feedback, and a command hub routed through /septiumsmp with admin subcommands for session management, IP administration, power binding, item granting, and help display.

I’ll create the self-contained Java plugin, its Paper descriptor, and the minimal Gradle build targeting Java 21/Paper 1.21.11.

Created the SeptiumSMP project with:

  • SeptiumSMP.java single-file plugin implementation

  • IP registration, password hashing, auto-login, and login locking

  • /septiumsmp command hub with aliases

  • PDC-based dynamic ability binding

  • Seven dual-ability custom items

  • Ability cooldowns and action-bar feedback

  • Session start/unfreeze functionality

  • plugin.yml

  • Java 21 Paper build configuration in build.gradle

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 1,291
src/main/java/com/septiumsmp/SeptiumSMP.java
package com.septiumsmp;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.SpectralArrow;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

public final class SeptiumSMP extends JavaPlugin implements Listener {

    private enum AuthState {
        UNREGISTERED,
        WAITING_LOGIN,
        AUTHENTICATED
    }

    private static final class LocationSnapshot {
        private final long time;
        private final Location location;

        private LocationSnapshot(long time, Location location) {
            this.time = time;
            this.location = location;
        }
    }

    private final Map<UUID, AuthState> authStates = new HashMap<>();
    private final Map<UUID, Long> cooldowns = new HashMap<>();
    private final Map<UUID, Deque<LocationSnapshot>> locationHistory = new HashMap<>();
    private final Set<UUID> fortressPlayers = new HashSet<>();
    private final Map<String, String[]> itemDefinitions = new HashMap<>();

    private File ipDataFile;
    private YamlConfiguration ipData;
    private NamespacedKey itemIdKey;
    private NamespacedKey rightPowerKey;
    private NamespacedKey leftPowerKey;
    private boolean sessionStarted;

    @Override
    public void onEnable() {
        itemIdKey = new NamespacedKey(this, "item_id");
        rightPowerKey = new NamespacedKey(this, "shift_right_power");
        leftPowerKey = new NamespacedKey(this, "shift_left_power");
        loadIpData();
        defineItems();

        getServer().getPluginManager().registerEvents(this, this);
        if (getCommand("septiumsmp") != null) {
            getCommand("septiumsmp").setExecutor(new RootCommand());
            getCommand("septiumsmp").setTabCompleter(new RootCommand());
        }

        for (Player player : Bukkit.getOnlinePlayers()) {
            initializePlayer(player);
        }
        Bukkit.getScheduler().runTaskTimer(this, this::recordLocations, 20L, 20L);
    }

    @Override
    public void onDisable() {
        saveIpData();
    }

    private void defineItems() {
        itemDefinitions.put("void_singularity_blade", new String[]{"NETHERITE_SWORD", "Void Singularity Blade", "VOID_PULL", "REALITY_TEAR"});
        itemDefinitions.put("oblivion_core_mace", new String[]{"MACE", "Oblivion Core Mace", "ORBITAL_LASER", "SEISMIC_SLAM"});
        itemDefinitions.put("nebula_shadow_bow", new String[]{"BOW", "Nebula Shadow Bow", "SHADOW_STEALTH", "ARROW_RAIN"});
        itemDefinitions.put("chronos_time_spear", new String[]{"TRIDENT", "Chronos Time Spear", "TIME_FREEZE", "RECALL"});
        itemDefinitions.put("infernal_sun_axe", new String[]{"NETHERITE_AXE", "Infernal Sun Axe", "FLAME_RING", "BERSERK_DRAIN"});
        itemDefinitions.put("phantom_winds_scythe", new String[]{"NETHERITE_HOE", "Phantom Winds Scythe", "GALE_PUSH", "ELYTRA_FLIGHT"});
        itemDefinitions.put("aegis_sanctum_shield", new String[]{"SHIELD", "Aegis Sanctum Shield", "ABSOLUTE_FORTRESS", "REFLECTIVE_WAVE"});
    }

    private void loadIpData() {
        if (!getDataFolder().exists() && !getDataFolder().mkdirs()) {
            getLogger().warning("Could not create the plugin data folder.");
        }
        ipDataFile = new File(getDataFolder(), "ip_data.yml");
        if (!ipDataFile.exists()) {
            try {
                if (!ipDataFile.createNewFile()) {
                    getLogger().warning("Could not create ip_data.yml.");
                }
            } catch (Exception exception) {
                getLogger().severe("Could not create ip_data.yml: " + exception.getMessage());
            }
        }
        ipData = YamlConfiguration.loadConfiguration(ipDataFile);
    }

    private void saveIpData() {
        if (ipData == null || ipDataFile == null) {
            return;
        }
        try {
            ipData.save(ipDataFile);
        } catch (Exception exception) {
            getLogger().severe("Could not save ip_data.yml: " + exception.getMessage());
        }
    }

    private void initializePlayer(Player player) {
        String path = "players." + player.getUniqueId();
        String storedIp = ipData.getString(path + ".ip");
        if (storedIp == null) {
            authStates.put(player.getUniqueId(), AuthState.UNREGISTERED);
            player.sendMessage("§e[SeptiumSMP] Register this IP with §f/septiumsmp register <password>§e.");
            return;
        }

        if (storedIp.equals(currentIp(player))) {
            authStates.put(player.getUniqueId(), AuthState.AUTHENTICATED);
            sendActionBar(player, "§a[SeptiumSMP] Auto-authenticated from home IP!");
        } else {
            authStates.put(player.getUniqueId(), AuthState.WAITING_LOGIN);
            player.sendMessage("§c[SeptiumSMP] IP Mismatch! Authenticate using /septiumsmp login <password>");
        }
    }

    private String currentIp(Player player) {
        if (player.getAddress() == null || player.getAddress().getAddress() == null) {
            return "unknown";
        }
        return player.getAddress().getAddress().getHostAddress();
    }

    private boolean isAuthenticated(Player player) {
        return authStates.getOrDefault(player.getUniqueId(), AuthState.UNREGISTERED) == AuthState.AUTHENTICATED;
    }

    private boolean isFrozen(Player player) {
        return !isAuthenticated(player) || !sessionStarted;
    }

    private void recordLocations() {
        long now = System.currentTimeMillis();
        for (Player player : Bukkit.getOnlinePlayers()) {
            Deque<LocationSnapshot> snapshots = locationHistory.computeIfAbsent(player.getUniqueId(), ignored -> new ArrayDeque<>());
            snapshots.addLast(new LocationSnapshot(now, player.getLocation().clone()));
            while (snapshots.size() > 12 || (!snapshots.isEmpty() && now - snapshots.peekFirst().time > 11000L)) {
                snapshots.removeFirst();
            }
        }
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        initializePlayer(event.getPlayer());