Twligh
📎 1 file 9,157 chars
📄
pasted-code-1790734327271.txt
txt 222 lines
▶
# Build a Professional Minecraft Lifesteal Plugin

Act as a senior Minecraft Java plugin developer. Build a complete, production-ready **Lifesteal plugin** for Paper/Spigot servers.

The plugin must be modular, performance-efficient, secure, configurable, and compatible with modern Minecraft server versions. Use clean Java architecture, proper event handling, persistent storage, and well-organized code.

## 1. Core Lifesteal Mechanics

Implement the following features:

* When a player kills another player in an enabled Lifesteal world/group, the killer gains one heart and the victim loses one heart.
* Support configurable minimum and maximum hearts.
* Prevent players from exceeding the configured maximum hearts.
* When a player reaches the minimum heart limit, apply the configured zero-heart consequence, such as elimination, spectator mode, temporary ban, or another configurable action.
* Support configurable heart loss/gain amounts.
* Prevent heart changes from environmental deaths, suicide, or invalid kill situations unless explicitly enabled.
* Prevent farming through repeated kills, alternate accounts, or rapid repeated kills using configurable anti-abuse protection.
* Persist player heart data across reconnects, server restarts, and world changes.

## 2. Heart Items and Crafting

Implement a customizable heart item system:

* Players can obtain heart items through configured gameplay methods.
* Allow heart items to be crafted using configurable recipes.
* Allow players to consume/use heart items to gain hearts.
* Support configurable item material, display name, lore, model data, and crafting recipe.
* Prevent item duplication exploits.
* Ensure heart items only work in worlds/groups where the Lifesteal feature is enabled.
* Do not allow heart items to affect players in disabled worlds.

## 3. Strict World and Group System — Highest Priority

The plugin must use a strict **World → Group** configuration system.

The administrator will define world entries using placeholders such as:

* ``
* ``

Do not hardcode any world names or group names.

### Required behavior

* Every configured world belongs to its assigned Lifesteal group.
* Each group has its own independent Lifesteal settings.
* A world must only use the settings of the group assigned to it.
* If a world is not configured, Lifesteal must be disabled there by default.
* Never automatically enable Lifesteal in unknown or newly created worlds.
* Do not use a global default group to enable Lifesteal in every world.
* A configured disabled-world entry must always take precedence over group assignments.
* Group settings must not leak into other groups.
* Changing worlds must immediately apply the destination world's Lifesteal rules.

### Example behavior using placeholders

If ``, ``, and `` are assigned to ``, those worlds use `` settings.

If `` is assigned to ``, it uses only `` settings.

If `` is not configured, Lifesteal is completely disabled in that world.

The example names above are placeholders only. Do not create hardcoded configuration entries.

## 4. Complete World Isolation

World isolation is mandatory and must be enforced in the Java code—not just in the configuration file.

Check world eligibility before every Lifesteal-related action, including:

* Player kills and heart transfers
* Heart item usage
* Heart crafting
* Heart drops and pickups
* Zero-heart elimination
* Respawn handling
* Heart-related commands
* Admin commands that affect player hearts
* GUI interactions
* Rewards and statistics
* Any scheduled or delayed Lifesteal task

For player-versus-player interactions, validate the relevant players' worlds and group settings before changing hearts.

Do not allow a kill in one group to modify a player's hearts in another group unless an explicit cross-group feature is enabled.

Do not let disabled-world events trigger Lifesteal consequences.

## 5. Cross-World and Teleport Handling

Handle these situations safely:

* Player teleports between configured Lifesteal worlds.
* Player teleports from a Lifesteal world to a disabled world.
* Player dies in one world and respawns in another.
* Player disconnects during a death or elimination sequence.
* Player is moved by another plugin.
* A world is unloaded or removed.
* A configured world is temporarily unavailable during startup.

Always resolve the player's current world and group at the time of the action. Do not rely on stale cached world data.

## 6. Commands and Permissions

Implement a complete command system with tab completion and permission checks.

Include commands for:

* Checking a player's current hearts
* Viewing heart statistics
* Giving or removing hearts
* Setting a player's hearts
* Giving heart items
* Reviving or restoring an eliminated player, if enabled
* Reloading the plugin configuration
* Viewing the active Lifesteal group for the current world
* Checking whether Lifesteal is enabled in the current world

All commands that modify player data must validate the target player's world/group rules.

Admin commands may bypass normal gameplay restrictions only when explicitly configured to do so. Admin bypass must never accidentally enable Lifesteal mechanics in a disabled world.

Use clear permission nodes and informative messages.

## 7. GUI and User Experience

Create a polished, configurable GUI system for relevant Lifesteal features, such as:

* Player heart information
* Heart statistics
* Admin management tools
* Revive interface, if enabled

Support configurable titles, item icons, names, lore, and menu layout.

Prevent unauthorized players from using admin GUI actions. Validate the player's current world/group when a GUI action is clicked.

## 8. Storage and Data Safety

* Persist player heart data safely.
* Support SQLite as the default storage option.
* Avoid blocking the main server thread with database operations.
* Handle missing, corrupted, or outdated data gracefully.
* Include safe data migration when the plugin is updated.
* Do not reset player hearts when configuration is reloaded.
* Store player UUIDs rather than relying only on usernames.

## 9. Configuration Requirements

Do not provide a pre-filled YAML configuration with actual world names or group names.

Create a clear, documented configuration structure that supports:

* World-to-group assignments
* Disabled worlds
* Independent settings for each group
* Group-specific heart limits and mechanics
* Feature toggles
* Messages and item customization
* Commands and permissions
* Storage settings

Use `` and `` as explanatory placeholders in documentation and examples. The administrator will replace them with actual values.

Unknown worlds must remain disabled unless explicitly configured.

## 10. Code Architecture

Use separate classes/services for:

* Main plugin lifecycle
* Configuration management
* World and group resolution
* Lifesteal eligibility checks
* Heart management
* Kill and death handling
* Heart item and recipe handling
* Elimination and revive handling
* Commands and permissions
* GUI management
* Database/storage
* Messages and placeholders

Create one central service responsible for resolving world/group eligibility. Every listener, command, GUI, and scheduled task must use this service rather than implementing separate world checks.

Avoid duplicated logic and unsafe static state.

## 11. Testing Requirements

Include tests or a clear test plan covering:

1. Lifesteal works in a configured world.
2. Multiple worlds assigned to the same group use the same group settings.
3. Worlds assigned to different groups use independent settings.
4. Unconfigured worlds have Lifesteal disabled.
5. Disabled worlds remain disabled even if accidentally assigned to a group.
6. A kill in one group cannot unexpectedly modify another group's data.
7. Heart items cannot be used in disabled worlds.
8. Teleporting between worlds correctly updates eligibility.
9. Death and respawn do not bypass world restrictions.
10. Reloading configuration does not reset player data.
11. Repeated kills cannot be exploited to farm unlimited hearts.
12. Restarting the server preserves player heart data.

## 12. Final Deliverables

Provide:

* Complete Java source code
* Build files and dependency declarations
* Plugin metadata
* Documented configuration structure without hardcoded world/group names
* Permission documentation
* Command documentation
* Installation instructions
* Build instructions
* Test plan

Do not return pseudocode or incomplete placeholder methods. Implement the actual working plugin.

**Critical acceptance rule:** Lifesteal must work only in worlds explicitly configured and assigned to a group. It must not activate in any other world, regardless of global defaults, player teleportation, commands, GUI actions, death handling, or other plugins.
Kodari AI
KodariSep 30 at 2:17 am 2
WorldIsolatedLifesteal
A comprehensive Lifesteal plugin for Paper/Spigot with strict world-to-group isolation. Features configurable heart mechanics, heart items with crafting, elimination and revive systems, SQLite persistence, and a centralized eligibility service that enforces world/group rules across all listeners, commands, GUI actions, and scheduled tasks. Includes anti-abuse protections, tab-complete commands, permissions, and a documented configuration structure using placeholders. Unknown worlds remain disabled by default, and group settings never leak between worlds.

I’ll build the plugin around strict world-to-group resolution, per-group SQLite heart data, and shared eligibility checks.

  1. Create the Gradle project, metadata, and an empty-by-default documented configuration.

  2. Add storage, group resolution, heart mechanics, items, and world-safe listeners.

  3. Add player/admin commands, a heart-info GUI, and installation/test documentation.

Created the Lifesteal plugin project with strict world-to-group isolation, per-group heart limits and persistence, configurable heart items/recipes, elimination and revive handling, commands, a heart-info GUI, and an empty-by-default world/group configuration.

Included Gradle build files, plugin metadata, SQLite storage, permission and installation documentation, and a 12-case manual test plan. The project has not been compiled or run in a server environment.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
README.md
settings.gradle
TESTING.md
Code
18 1,327
src/main/java/com/kodari/lifesteal/LifestealPlugin.java
package com.kodari.lifesteal;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class LifestealPlugin extends JavaPlugin {
    private ConfigManager configManager;
    private WorldGroupService worldGroups;
    private SQLiteStorage storage;
    private HeartService heartService;
    private HeartItemManager heartItems;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        configManager = new ConfigManager(this);
        worldGroups = new WorldGroupService(configManager);
        storage = new SQLiteStorage(getDataFolder());
        try {
            storage.initialize().join();
        } catch (Exception exception) {
            getLogger().severe("Lifesteal storage failed to start: " + exception.getMessage());
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }

        heartService = new HeartService(this, storage, worldGroups);
        heartItems = new HeartItemManager(this);
        heartItems.registerRecipe();
        Bukkit.getPluginManager().registerEvents(new LifestealListener(this), this);
        LifestealCommand command = new LifestealCommand(this);
        getCommand("lifesteal").setExecutor(command);
        getCommand("lifesteal").setTabCompleter(command);
        getServer().getOnlinePlayers().forEach(heartService::loadForWorld);
    }

    @Override
    public void onDisable() {
        if (storage != null) {
            storage.close();
        }
    }

    public ConfigManager getConfigManager() {
        return configManager;
    }

    public WorldGroupService getWorldGroups() {
        return worldGroups;
    }

    public HeartService getHeartService() {
        return heartService;
    }

    public HeartItemManager getHeartItems() {
        return heartItems;
    }
}