s1nco_stan

Add these things bro

📎 1 file 5,434 chars
📄
lostsmp-diff-instructions.md
md 109 lines
▶
# Task: Reproduce a code change in the LostSMP Bukkit/Paper plugin

I have the Java source for this plugin. Please make the following changes so it matches the "after" version of the plugin:

## 1. Delete the admin panel system
Delete the class `LostAdminPanel` entirely, including its nested classes:
- `LostAdminPanel.Panel`
- `LostAdminPanel.EditSession`
- `LostAdminPanel.MessageEdit`

This class implemented a multi-page in-game GUI ("Lost SMP | Admin") with pages for
Bounty, Ritual, Rewards, Items, Messages, Effects, Settings, Players, Debug, Reload,
and Save, including sub-menus for editing kill/survive reward items, reward commands,
effect pools/durations, bounty duration, and bounty target selection.

## 2. Update `LostSMPPlugin`
Remove the `adminPanel` field (type `LostAdminPanel`) and its `getAdminPanel()` getter
method, since the class no longer exists.

## 3. Update `LostCommand`
Find the branch that checks the `lost.admin` permission and currently calls something
like `plugin.getAdminPanel().open(player)`. Replace it with inline code that builds and
opens a single flat inventory menu instead of delegating to the old panel class. The
inventory should be:
- Title: `"LostSMP Admin"`
- Built via `Bukkit.createInventory(...)`
- Populated with these items (material → display name), in this order:
  1. `COMPASS` — "Bounty status"
  2. `NETHER_STAR` — "Start random bounty"
  3. `BARRIER` — "Stop bounty"
  4. `CLOCK` — "Expire bounty"
  5. `PAPER` — "Rewards"
  6. `BEDROCK` — "Ritual status"
  7. `REDSTONE` — "Reset rituals"
  8. `BOOK` — "Debug"
  9. `EMERALD` — "Reload config"
- Open it for the player with `player.openInventory(inventory)`

No editing sub-menus, item pickers, or message editors — just this one flat menu of
top-level actions. Clicking these items should call the same underlying manager methods
the old panel used (bounty start/stop/expire via `BountyManager`, ritual reset via
`RitualManager`, reward viewing via `RewardManager`, config reload via the plugin's
reload method, etc.) — wire up a simple `InventoryClickEvent` handler for this new menu
if one doesn't already exist.

## 4. Update `RewardManager`
Remove the `listRedeemed(UUID)` method. Nothing else in this class changes.

## Not changed (leave alone)
`BountyManager`, `GameListener`, `MessageUtil`, `PlayerData`, `RitualManager` (and its
`Ritual` inner class), `TimeUtil`, the bundled XSeries library, `config.yml`, and
`plugin.yml` are all identical between versions — do not modify them (except for the
new feature below, which only adds to `config.yml` and to `BountyManager`/`LostCommand`
as described).

---

# Additional new feature: periodic bounty-target coordinates in chat

This is a separate, additive feature — do not change any existing bounty logic
(bossbar, glow effect, rewards, bounty code, kill/survive rewards, ritual system,
hearts system, or any other existing command). Only add the following.

## 1. New command: `/lost cords time `
- Lets an admin set the interval for the coordinates announcement.
- Accepts a number plus a unit suffix: `s` (seconds), `m` (minutes), `h` (hours),
  `d` (days). Examples: `5m`, `30s`, `1h`, `1d`.
- Parse the value+unit and store it as a duration (e.g. convert to seconds/ticks
  internally).
- Persist it to `config.yml` as a new key:
  ```yaml
  bounty_cords_interval: 5m   # default value, changed via /lost cords time
  ```
- Add this permission-gated the same way other admin subcommands are (reuse the
  existing admin permission check pattern in `LostCommand`, e.g. `lost.admin`).

## 2. Timing behavior
- When a bounty starts, do **not** announce coordinates immediately.
- The first coordinates announcement should fire exactly one configured interval
  after the bounty started (e.g. if the interval is `5m`, the first announcement is
  5 minutes after bounty start).
- After that, repeat every interval for as long as the bounty is active (e.g. 5m,
  10m, 15m, 20m, ...).
- The moment the bounty ends — target killed, or bounty duration expires — stop the
  periodic announcements immediately. No further announcement should fire after the
  bounty has ended, even if a scheduled tick lines up.
- Implementation approach: schedule a repeating Bukkit task (e.g.
  `BukkitScheduler.runTaskTimer`) keyed to the configured interval when a bounty
  starts, and cancel that task as soon as the bounty ends (on kill and on
  expire/duration-complete — check both code paths in `BountyManager`).

## 3. Chat message content
- Include the bounty target's current coordinates (X, Y, Z) and current world name,
  shown as "Overworld", "Nether", or "End" (map the Bukkit world environment to
  these labels).
- Always read the target's **live** location at the moment each announcement fires
  (not the location at bounty start), so if the target changes world mid-bounty
  (e.g. Overworld → Nether), the next announcement reflects the new world and
  coordinates.
- Follow the plugin's existing chat message style/prefix (via `MessageUtil`) rather
  than inventing a new format. Example of the info to include:
  `"[Lost] Bounty Target Location: X: 120, Y: 65, Z: -340 | World: Nether"`

## Scope reminder
Only add: the new `/lost cords time` subcommand, the new `bounty_cords_interval`
config key, and the scheduled/cancelled announcement task tied to bounty
start/end in `BountyManager`. Everything else in the plugin must remain exactly as
it is.
Kodari AI
KodariSep 26 at 4:44 am 2
  1. Remove the admin panel and replace it with the requested flat menu; remove RewardManager.listRedeemed.

  2. Add /lost cords time and persist its interval in config.

  3. Schedule live-coordinate announcements for an active bounty and cancel them on every end path.

  1. The flat admin menu is in place. This source tree had no separate LostAdminPanel, adminPanel getter/field, or listRedeemed method to remove.

  2. I’ll add the interval subcommand and config default, then wire its scheduler into bounty start/end.

  • Replaced the existing 27-slot admin panel with the requested 9-slot menu and wired its buttons to the existing commands. This source tree had no separate LostAdminPanel, adminPanel field/getter, or listRedeemed method to remove.

  • Added admin-only /lost cords time <value><unit> with s, m, h, and d support, plus the bounty_cords_interval: 5m default.

  • Added recurring live target-coordinate announcements with Overworld/Nether/End labels. The task is cancelled when a bounty is stopped, expires, or ends on target death.

s1nco_stan

Done?

Kodari AI
KodariSep 26 at 5:04 am 1

Yes. The flat admin menu, /lost cords time <value><unit>, config default, and recurring live-coordinate announcements with cancellation on bounty end are in place. The project didn’t contain a separate LostAdminPanel class or listRedeemed method to remove.

s1nco_stan

I’ll add the interval subcommand and config default, then wire its scheduler into bounty start/end.?

Kodari AI
KodariSep 26 at 5:12 am 1

Yes—that was an intermediate progress note. The changes were completed afterward: the interval command and config default were added, and bounty announcements are scheduled and cancelled when the bounty ends.

s1nco_stan

Can you let bedrock block show a I'm

Kodari AI
KodariSep 26 at 5:12 am 1

The generation was stopped before any content could be produced.

s1nco_stan

Can you let bedrock block a timer of 3p after placing if nothing is going with it it will despawn automatically with timer show up t

Kodari AI
KodariSep 26 at 5:13 am 1

The ritual bedrock currently has no expiry unless a ritual starts. Did you mean it should disappear 3 minutes after placement if no ritual begins, and should the countdown appear in the action bar for the placer?

s1nco_stan

Yes but 30 second which can be change from config

Kodari AI
KodariSep 26 at 5:16 am 1
  1. Trace where ritual bedrock is placed and when a ritual begins.

  2. Add a configurable 30-second idle timeout, countdown display, and automatic cleanup if no ritual starts.

  3. Cancel the timeout when the ritual begins and add the config default.

Added a 30-second default timeout for placed ritual bedrock, configurable with ritual.bedrock-timeout in config.yml. The placer sees the countdown in their action bar, and the bedrock despawns if no ritual starts; starting a ritual cancels the timer.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
CONFIG_GUIDE.md
FEATURES.md
IMPLEMENTATION_GUIDE.md
pom.xml
README.md
Code
17 2,458
src/main/java/com/kodari/lostsmp/LostSMPPlugin.java
package com.kodari.lostsmp;

import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public final class LostSMPPlugin extends JavaPlugin {
    private NamespacedKey itemTypeKey;
    private NamespacedKey headOwnerKey;
    private NamespacedKey rewardIdKey;
    private PlayerData playerData;
    private RitualManager ritualManager;
    private BountyManager bountyManager;
    private RewardManager rewardManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        itemTypeKey = new NamespacedKey(this, "item_type");
        headOwnerKey = new NamespacedKey(this, "head_owner");
        rewardIdKey = new NamespacedKey(this, "reward_id");
        playerData = new PlayerData(this);
        rewardManager = new RewardManager(this);
        ritualManager = new RitualManager(this);
        bountyManager = new BountyManager(this);
        Bukkit.getPluginManager().registerEvents(new GameListener(this), this);
        LostCommand command = new LostCommand(this);
        Bukkit.getPluginManager().registerEvents(command, this);
        getCommand("lost").setExecutor(command);
        getCommand("lost").setTabCompleter(command);
        registerRecipe();
        bountyManager.startClock();
        for (org.bukkit.entity.Player online : Bukkit.getOnlinePlayers()) rewardManager.restoreEffects(online);
    }

    @Override
    public void onDisable() {
        if (bountyManager != null) bountyManager.stopClock();
        if (ritualManager != null) ritualManager.stopAll();
    }

    public NamespacedKey getItemTypeKey() { return itemTypeKey; }
    public NamespacedKey getHeadOwnerKey() { return headOwnerKey; }
    public NamespacedKey getRewardIdKey() { return rewardIdKey; }
    public PlayerData getPlayerData() { return playerData; }
    public RitualManager getRitualManager() { return ritualManager; }
    public BountyManager getBountyManager() { return bountyManager; }
    public RewardManager getRewardManager() { return rewardManager; }

    public ItemStack createReviveToken() {
        ItemStack item = XMaterial.matchXMaterial("BEDROCK").map(XMaterial::parseItem).orElse(null);
        return tagItem(item, "ritual_bedrock", "&5Ritual Bedrock");
    }

    public ItemStack createDeadPlayerHead(java.util.UUID owner) {
        ItemStack item = XMaterial.matchXMaterial("PLAYER_HEAD").map(XMaterial::parseItem).orElse(null);
        if (item == null) return null;
        ItemMeta meta = item.getItemMeta();
        if (meta instanceof org.bukkit.inventory.meta.SkullMeta skullMeta) {
            skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(owner));
            skullMeta.getPersistentDataContainer().set(headOwnerKey, PersistentDataType.STRING, owner.toString());
            skullMeta.setDisplayName(ChatColor.RED + getPlayerData().getName(owner) + "'s Head");
            item.setItemMeta(skullMeta);
        }
        return item;
    }

    public ItemStack createHeartItem() {
        ItemStack item = XMaterial.matchXMaterial("RED_DYE").map(XMaterial::parseItem).orElse(null);
        return tagItem(item, "heart", "&cLost Heart");
    }

    public boolean isTagged(ItemStack item, String type) {
        if (item == null || !item.hasItemMeta()) return false;
        return type.equals(item.getItemMeta().getPersistentDataContainer().get(itemTypeKey, PersistentDataType.STRING));
    }

    public java.util.UUID getHeadOwner(ItemStack item) {
        if (item == null || !item.hasItemMeta()) return null;
        String value = item.getItemMeta().getPersistentDataContainer().get(headOwnerKey, PersistentDataType.STRING);
        if (value == null) return null;
        try {
            return java.util.UUID.fromString(value);
        } catch (IllegalArgumentException ignored) {
            return null;
        }
    }

    public void reloadPlugin() {
        reloadConfig();
        registerRecipe();
        bountyManager.configReloaded();
        ritualManager.durationChanged();
    }

    public void registerRecipe() {
        NamespacedKey key = new NamespacedKey(this, "revive_token");
        Bukkit.removeRecipe(key);
        ItemStack result = createReviveToken();
        if (result == null) {
            getLogger().severe("Could not create the configured ritual bedrock item.");
            return;
        }
        ShapedRecipe recipe = new ShapedRecipe(key, result);
        List<String> shape = new ArrayList<>();
        Map<Character, Material> ingredients = new LinkedHashMap<>();
        String[] rows = {"rowOne", "rowTwo", "rowThree"};
        char ingredient = 'A';
        for (String rowName : rows) {
            List<String> row = getConfig().getStringList("revive_token_recipe." + rowName);
            if (row.size() != 3) {
                getLogger().severe("Invalid revive token recipe: revive_token_recipe." + rowName
                        + " must contain exactly 3 materials; recipe was not registered.");
                return;
            }
            StringBuilder shapeRow = new StringBuilder();
            for (String materialName : row) {
                String normalized = materialName == null ? "AIR" : materialName.trim().toUpperCase(java.util.Locale.ROOT);
                if (normalized.equals("AIR")) {
                    shapeRow.append(' ');
                    continue;
                }
                Material material = XMaterial.matchXMaterial(normalized)
                        .map(XMaterial::parseMaterial).orElse(null);
                if (material == null || material.isAir()) {
                    getLogger().severe("Invalid material in revive token recipe: " + materialName
                            + "; recipe was not registered.");
                    return;
                }
                ingredients.put(ingredient, material);
                shapeRow.append(ingredient++);
            }
            shape.add(shapeRow.toString());
        }
        try {
            recipe.shape(shape.toArray(new String[0]));
            for (Map.Entry<Character, Material> entry : ingredients.entrySet()) {
                recipe.setIngredient(entry.getKey(), entry.getValue());
            }
            Bukkit.addRecipe(recipe);
        } catch (IllegalArgumentException exception) {
            getLogger().severe("Invalid revive token recipe shape or ingredients; recipe was not registered: "
                    + exception.getMessage());
        }
    }

    private ItemStack tagItem(ItemStack item, String type, String displayName) {
        if (item == null) return null;
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayName));
        meta.getPersistentDataContainer().set(itemTypeKey, PersistentDataType.STRING, type);
        item.setItemMeta(meta);
        return item;
    }
}