Alvin-LB / NameTagChanger

Library to be shaded into Bukkit Plugins to allow for modification of player name tags.
MIT License
31 stars 10 forks source link

package com.bringholm.nametagchanger does not exist #20

Open timbo2040 opened 1 year ago

timbo2040 commented 1 year ago

I am making it so you can do /namechange [current name] [new name] but I get the error: package com.bringholm.nametagchanger does not exist

here is my code (not sure if code brackets work in github but ill try anyway haha):


import com.bringholm.nametagchanger.NameTagChanger;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class nameset implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("This command can only be used by players.");
            return true;
        }

        if (args.length < 2) {
            sender.sendMessage("Usage: /setname [currentName] [newName]");
            return true;
        }

        Player p = (Player) sender;
        String currentName = args[0];
        String newName = args[1];

        // Check if the player's current name matches the provided currentName
        if (!p.getName().equalsIgnoreCase(currentName)) {
            sender.sendMessage("Your current name does not match the provided currentName.");
            return true;
        }

        // Apply the name change
        Player player = Bukkit.getPlayer(currentName);
        NameTagChanger.INSTANCE.changePlayerName(player, newName);

        sender.sendMessage("Name has been changed to: " + newName);

        return true;
    }
}

Not sure what's wrong here but help would be amazing.