sunchl

A paper, 1.21.11 server plugin.

Make it so players that aren't OP can rename an item only once, and never again.

If the item has been renamed once by someone else, you still can't rename it. The item is stuck with the name it has been put first.

Kodari AI
KodariJun 24 at 8:18 pm 15

I’ll create a plugin that prevents items from being renamed more than once by non-OP players.

RenameOnce
Prevents items from being renamed more than once. When a non-OP player renames an item in an anvil, it becomes permanently locked and cannot be renamed again by anyone except OP players. Uses PersistentDataContainer to track renamed items. Configurable messages notify players when rename attempts are blocked.

Plugin created. Non-OP players can rename items once in an anvil, then the item is permanently locked. OP players bypass the restriction via the renameonce.bypass permission. Items are tracked using PersistentDataContainer, so the restriction persists across server restarts.

sunchl

can you make it so it gives the warnings only once..

Kodari AI
KodariJun 25 at 12:06 am 8

Done. Players will now only see the warning once per session when they try to rename an already-renamed item.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
5 150
src/main/java/me/renameonce/RenameOnce.java
package me.renameonce;

import me.renameonce.listeners.AnvilListener;
import org.bukkit.NamespacedKey;
import org.bukkit.plugin.java.JavaPlugin;

public class RenameOnce extends JavaPlugin {
    
    private NamespacedKey renamedKey;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        renamedKey = new NamespacedKey(this, "renamed");
        
        getServer().getPluginManager().registerEvents(new AnvilListener(this), this);
        
        getLogger().info("RenameOnce has been enabled!");
    }
    
    @Override
    public void onDisable() {
        getLogger().info("RenameOnce has been disabled!");
    }
    
    public NamespacedKey getRenamedKey() {
        return renamedKey;
    }
}