Marvel edit demo
📎 1 file 10,110 chars
📄
pasted-code-1792148154111.txt
txt 242 lines
▶
# BUILD A COMPLETE MINECRAFT PLUGIN — GOD SPEAR

Create a complete, functional Minecraft Java Edition server plugin named **GodSpear**, designed for **Minecraft Java Edition 26.2**.

This is a small, private SMP server with approximately six trusted players. The plugin must focus on a powerful progression-based Netherite Spear, not punishments or anti-cheat.

**IMPORTANT:** Build a real Java server plugin, not a website, mockup, datapack, Fabric mod, or demonstration. Provide a downloadable, compiled `GodSpear.jar` if compilation is supported, together with all source code and build files.

## 1. Minecraft Compatibility

- Target Minecraft Java Edition 26.2.
- Target the matching Paper server API, verifying the actual available version and dependencies.
- Use the correct Java toolchain required by the target server.
- Verify the real spear material, enchantment registry keys, and API methods for this version.
- Do not assume older Minecraft APIs work unchanged.
- If the requested server API or version cannot be verified, explain the limitation rather than claiming compatibility without testing.

## 2. Automatic God Spear Delivery

When a player joins for the first time, automatically give them one special Netherite Spear.

The spear must have:

- Display name: `§6§lGOD SPEAR`
- Density I
- Wind Burst I
- Lunge I
- Sharpness I
- Unbreaking I
- Mending I

Requirements:

- Use the actual spear item and supported enchantments for Minecraft 26.2.
- Give the spear a glowing visual effect.
- Add custom lore showing the player's current tier, total God Spear kills, and all enchantment levels.
- Do not give a duplicate every time a player relogs.
- Persist each player's progression independently.
- If a player loses the spear, an administrator must be able to restore it with its saved progression.

## 3. One Kill = Exactly One Tier Up

This is the core feature.

- Every valid kill made with the God Spear increases the killer's tier by exactly ONE.
- First valid kill = Tier 1.
- Second valid kill = Tier 2.
- Third valid kill = Tier 3.
- Fourth valid kill = Tier 4.
- Continue this pattern for every valid kill.
- Do not use kill thresholds such as 10, 25, 50, or 100.
- Do not require multiple kills to advance a tier.
- Do not skip tiers or award multiple tiers for one death.
- The tier number must equal the total number of valid God Spear kills.
- The tier and kill counter must be saved across relogs and server restarts.

Display a message after each kill, for example:

`§6§lGOD SPEAR §7» §aTier Up! §fYou reached Tier 5!`

Also display the new tier and enchantment levels in the item's lore.

## 4. Enchantment Progression

All six enchantments start at Level 1.

After every valid God Spear kill:

1. Increase the player's tier by exactly one.
2. Upgrade eligible enchantments according to the progression rules.
3. Update the spear's lore immediately.
4. Notify the player of the tier increase and any enchantment upgrades.
5. Save the progression persistently.

### Enchantment caps

| Enchantment | Starting level | Maximum level |
|---|---:|---:|
| Density | 1 | 79 |
| Wind Burst | 1 | 3 |
| Lunge | 1 | 79 |
| Sharpness | 1 | 79 |
| Unbreaking | 1 | 79 |
| Mending | 1 | 79 |

Rules:

- Ignore Minecraft's normal enchantment maximum levels where the API permits storing higher levels.
- Wind Burst must NEVER exceed Level 3.
- After Wind Burst reaches Level 3, it stays at Level 3 while the other eligible enchantments continue progressing.
- Every eligible enchantment must be able to reach Level 79 through continued progression.
- Do not instantly set every enchantment to Level 79 when a player reaches Tier 79.
- Upgrade each eligible enchantment gradually, and keep enchantment levels within their respective caps.
- Use a clear deterministic progression formula so the enchantment levels can be calculated from the tier.
- Ensure that the progression system eventually allows all five non-Wind-Burst enchantments to reach Level 79.
- Make sure the actual stored enchantment levels and displayed lore agree.
- If Minecraft stores a high enchantment level but the native game mechanics do not scale properly beyond vanilla limits, explain the limitation and implement the safest compatible approach.

## 5. Tier and Enchantment Synchronization

- Tier increases by one on each valid kill, even if some enchantments have already reached their maximum.
- Never stop tier progression just because an enchantment is capped.
- Keep tier, total kills, and enchantment levels synchronized.
- Store progression by player UUID, not player name.
- Do not lose progression if the spear is moved to another inventory slot.
- If the spear is temporarily missing, preserve the player's progress.
- Ensure a single death event cannot trigger multiple tier increases.

## 6. Private SMP — Absolutely No Automatic Bans

This is a private server for approximately six friends.

**The plugin must NEVER ban, temp-ban, kick, mute, jail, or punish a player for kills.**

Specifically:

- No automatic bans.
- No automatic kicks.
- No anti-boosting punishments.
- No suspicious-kill detection.
- No kill farming detection.
- No repeated-kill restrictions.
- No PvP kill cooldowns.
- No kill limits.
- No automatic punishment for killing the same friend repeatedly.
- No automatic punishment for voluntarily allowing a friend to get kills.
- No integration with anti-cheat punishment systems.
- Never execute ban, kick, or punishment commands.
- Never modify the server's ban lists.

Players may voluntarily fight or cooperate with friends for progression. Every otherwise valid kill made with the God Spear must count, including repeated kills of the same player.

Do not build any hidden punishment system.

## 7. Kill Detection

A valid kill must satisfy these requirements:

- The killer is a real player.
- The killer uses the identified God Spear to kill a player or a hostile mob.
- The kill is attributed to the spear correctly.
- A death event is counted only once.
- Environmental deaths, suicides, and deaths not attributable to the God Spear do not count.
- Repeated kills of the same player are allowed and count normally.
- Do not impose special restrictions on private-server PvP.

Use appropriate event handling for direct melee attacks and supported spear combat mechanics. Test the actual kill attribution behavior on the target Minecraft version.

## 8. Secure God Spear Identification

- Identify the item using persistent metadata and a unique plugin identifier.
- Never identify the God Spear by display name alone.
- Prevent ordinary renamed spears from gaining progression.
- Preserve player progression if the item is moved between slots.
- Do not accidentally grant tier progression twice for one kill.
- Provide a configurable death-drop policy.
- Preserve progression when the item is dropped, picked up, or restored.
- Prevent accidental duplicate rewards from repeated join events.

## 9. Commands

Implement the following commands:

`/godspear`
- Show the player's tier, total kills, and enchantment levels.

`/godspear stats `
- Show another player's God Spear progression.

`/godspear give `
- Give or restore the God Spear without resetting saved progression.

`/godspear setkills  `
- Set a player's kill counter for administration or testing, recalculating their tier and eligible enchantments consistently.

`/godspear reset `
- Reset the specified player's progression, with a confirmation step.

`/godspear reload`
- Reload the configuration.

Protect administrative commands with appropriate permissions. Regular players must not be able to alter other players' progression.

## 10. Configuration Files

Provide a `config.yml` containing configurable options for:

- Join delivery.
- Item display name and lore.
- Kill messages and tier-up messages.
- Death-drop behavior.
- Enchantment caps.
- Enchantment progression formula.
- First-join reward behavior.
- Administrative settings.

Default settings must follow all requirements in this prompt. Configuration options must not introduce automatic punishments.

## 11. Required Project Files

Provide all necessary files, including:

- Correct plugin descriptor for the chosen Paper API.
- `config.yml`.
- All Java source files.
- Gradle or Maven build configuration.
- README with installation and build instructions.
- Any other resources needed for a working plugin.

Do not provide pseudocode, missing classes, placeholder methods, or unfinished features.

## 12. Testing Requirements

Test or provide reproducible tests for:

1. A first-time player receives the correct spear.
2. Relogging does not grant duplicate spears.
3. A valid kill increases the tier by exactly one.
4. Killing the same friend repeatedly continues to increase the tier.
5. No ban, kick, mute, or punishment occurs.
6. Wind Burst never exceeds Level 3.
7. Other eligible enchantments can progress to Level 79.
8. Progression persists after server restart.
9. The spear can be restored without losing progression.
10. One death event cannot count twice.
11. The plugin builds against the actual target API.

Never claim a test passed unless it was actually executed.

## 13. Final Deliverables

Produce:

1. A working, compiled `GodSpear.jar`, if the environment supports building it.
2. The complete source project.
3. All configuration files.
4. Clear installation instructions for a compatible Minecraft 26.2 server.
5. Exact build instructions for Windows if compilation is unavailable.

Do not substitute a web application for the plugin. If you cannot compile the JAR, provide the complete source project and clearly explain how to build it.

**Priority order:** Correct Minecraft compatibility, one kill equals one tier, no automatic punishments, correct enchantment caps, persistent progression, and a genuinely functional plugin.
Kodari AI
KodariOct 16 at 11:05 am 1
GodSpearProgression
A progression-based Netherite Spear plugin for private SMP servers. First-join players receive a unique glowing God Spear with Density, Wind Burst, Lunge, Sharpness, Unbreaking, and Mending. Every valid kill with the spear increases the player's tier by exactly one, with enchantments upgrading deterministically from tier calculations. Wind Burst caps at Level 3 while other enchantments progress to Level 79. Progression persists per UUID across relogs and restarts, with admin commands for stats viewing, spear restoration, kill setting, reset, and config reload. No automatic punishments or kill restrictions exist—all kills count, including repeated friend kills. Configurable death-drop policy, join delivery, messages, and enchantment formulas via config.yml.

Created the GodSpear source project, including the Paper plugin descriptor, configuration, UUID-based progression storage, commands, first-join delivery, tagged spear items, and configurable death-drop handling. It contains no automatic punishments.

Compatibility is not verified for Minecraft 26.2. The project uses Paper API 1.21.4 and Java 21 as its compile baseline. The spear material and enchantments are resolved at runtime; the server must provide NETHERITE_SPEAR, Density, Wind Burst, and Lunge. Kill progression currently counts direct melee hits with the tagged spear in the main hand; projectile kills are not counted. No in-game tests have been run, and I can’t claim a compiled JAR.

To compile and download the JAR in Kodari, click Compile in the top bar (or ⋮ → Compile Project on phone), then click Compile in the window and Download after it succeeds.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
settings.gradle
Code
9 756
src/main/java/com/kodari/godspear/GodSpearPlugin.java
package com.kodari.godspear;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;

public final class GodSpearPlugin extends JavaPlugin implements CommandExecutor, Listener {
    private ProgressionStore progressionStore;
    private SpearItemFactory spearItemFactory;
    private final Map<String, UUID> pendingResets = new HashMap<>();

    @Override
    public void onEnable() {
        saveDefaultConfig();
        progressionStore = new ProgressionStore(this);
        spearItemFactory = new SpearItemFactory(this);
        getServer().getPluginManager().registerEvents(new GodSpearListener(this), this);
        getServer().getPluginManager().registerEvents(this, this);
        Objects.requireNonNull(getCommand("godspear"), "godspear command missing from plugin.yml").setExecutor(this);
    }

    public ProgressionStore getProgressionStore() {
        return progressionStore;
    }

    public SpearItemFactory getSpearItemFactory() {
        return spearItemFactory;
    }

    public void giveItem(Player player, ItemStack item) {
        Map<Integer, ItemStack> leftover = player.getInventory().addItem(item);
        for (ItemStack remaining : leftover.values()) {
            player.getWorld().dropItemNaturally(player.getLocation(), remaining);
        }
    }

    public void updatePlayerSpears(Player player, int kills) {
        for (ItemStack item : player.getInventory().getContents()) {
            if (spearItemFactory.isGodSpear(item)) {
                spearItemFactory.update(item, kills);
            }
        }
        for (ItemStack item : player.getEnderChest().getContents()) {
            if (spearItemFactory.isGodSpear(item)) {
                spearItemFactory.update(item, kills);
            }
        }
    }

    public void sendConfiguredMessage(CommandSender recipient, String path, Map<String, String> placeholders) {
        String message = getConfig().getString(path, "");
        if (message == null || message.isEmpty()) {
            return;
        }
        String prefix = getConfig().getString("messages.prefix", "");
        String result = (prefix == null ? "" : prefix) + message;
        for (Map.Entry<String, String> entry : placeholders.entrySet()) {
            result = result.replace("%" + entry.getKey() + "%", entry.getValue());
        }
        recipient.sendMessage(ChatColor.translateAlternateColorCodes('&', result));
    }

    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
        if (event.getWhoClicked() instanceof Player player) {
            Bukkit.getScheduler().runTask(this, () -> updatePlayerSpears(player, progressionStore.getKills(player.getUniqueId())));
        }
    }

    @EventHandler
    public void onInventoryDrag(InventoryDragEvent event) {
        if (event.getWhoClicked() instanceof Player player) {
            Bukkit.getScheduler().runTask(this, () -> updatePlayerSpears(player, progressionStore.getKills(player.getUniqueId())));
        }
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 0) {
            if (!(sender instanceof Player player)) {
                sendConfiguredMessage(sender, "messages.player-only", Map.of());
                return true;
            }
            sendStats(sender, player.getName(), player.getUniqueId());
            return true;
        }

        switch (args[0].toLowerCase(java.util.Locale.ROOT)) {
            case "stats" -> {
                if (args.length != 2) {
                    usage(sender);
                    return true;
                }
                OfflinePlayer target = findPlayer(args[1]);
                if (target == null) {
                    sendConfiguredMessage(sender, "messages.unknown-player", Map.of("player", args[1]));
                    return true;
                }
                sendStats(sender, target.getName() == null ? args[1] : target.getName(), target.getUniqueId());
            }
            case "give" -> {
                if (!requireAdmin(sender)) return true;
                if (args.length != 2) {
                    usage(sender);
                    return true;
                }
                Player target = Bukkit.getPlayerExact(args[1]);
                if (target == null) {
                    sendConfiguredMessage(sender, "messages.unknown-player", Map.of("player", args[1]));
                    return true;
                }
                if (hasSpear(target)) {
                    sendConfiguredMessage(sender, "messages.already-has-spear", Map.of("player", target.getName()));
                    return true;
                }
                ItemStack spear = spearItemFactory.create(progressionStore.getKills(target.getUniqueId()));
                if (spear == null) {
                    sendConfiguredMessage(sender, "messages.unsupported-item", Map.of());
                    return true;
                }
                giveItem(target, spear);
                sendConfiguredMessage(sender, "messages.given", Map.of("player", target.getName()));
            }
            case "setkills" -> {
                if (!requireAdmin(sender)) return true;
                if (args.length != 3) {
                    usage(sender);
                    return true;
                }
                OfflinePlayer target = findPlayer(args[1]);
                if (target == null) {
                    sendConfiguredMessage(sender, "messages.unknown-player", Map.of("player", args[1]));
                    return true;
                }
                int amount;
                try {
                    amount = Integer.parseInt(args[2]);
                    if (amount < 0) throw new NumberFormatException();
                } catch (NumberFormatException exception) {
                    sender.sendMessage(ChatColor.RED + "Amount must be a non-negative whole number.");
                    return true;
                }
                progressionStore.setKills(target.getUniqueId(), amount);
                Player online = target.getPlayer();
                if (online != null) updatePlayerSpears(online, amount);
                sendConfiguredMessage(sender, "messages.kills-set", Map.of("player", args[1], "kills", String.valueOf(amount)));
            }
            case "reset" -> handleReset(sender, args);
            case "reload" -> {
                if (!requireAdmin(sender)) return true;
                reloadConfig();
                sendConfiguredMessage(sender, "messages.reloaded", Map.of());
            }
            default -> usage(sender);
        }
        return true;
    }

    private void handleReset(CommandSender sender, String[] args) {
        if (!requireAdmin(sender)) return;
        String senderKey = sender instanceof Player player ? player.getUniqueId().toString() : "console";
        if (args.length == 2 && !args[1].equalsIgnoreCase("confirm")) {
            OfflinePlayer target = findPlayer(args[1]);
            if (target == null) {
                sendConfiguredMessage(sender, "messages.unknown-player", Map.of("player", args[1]));
                return;
            }
            pendingResets.put(senderKey, target.getUniqueId());
            sendConfiguredMessage(sender, "messages.reset-prompt", Map.of("player", args[1]));
            return;
        }

        if (args.length == 3 && args[1].equalsIgnoreCase("confirm")) {
            OfflinePlayer target = findPlayer(args[2]);
            UUID pending = pendingResets.get(senderKey);
            if (target == null) {
                sendConfiguredMessage(sender, "messages.unknown-player", Map.of("player", args[2]));
                return;
            }
            if (pending == null || !pending.equals(target.getUniqueId())) {
                sendConfiguredMessage(sender, "messages.reset-expired", Map.of());
                return;
            }
            pendingResets.remove(senderKey);
            progressionStore.reset(target.getUniqueId());