0

"meta.set Unbreakable(true);" and in "Material.WOODEN AX" it gives this error, but I can't understand where the problem is. Note: If I give DIAMOND_SWORD instead of WOODEN_AXE it works.

package plugin.mypluginaxe;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.List;

public class mypluginaxe extends JavaPlugin implements CommandExecutor {
    @Override
    public void onEnable() {
        System.out.println("Plugin started.");

        this.getCommand("TAKEAXE").setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Player player = (Player) sender;
        ItemStack item = new ItemStack(Material.WOODEN_AXE);
        ItemMeta meta = item.getItemMeta();
        if (meta != null){
            meta.setDisplayName("TAKEAXE NAME");
            meta.setUnbreakable(true);

            item.setItemMeta(meta);
        }
        if (sender instanceof Player){
            player.getInventory().addItem(item);
            player.sendMessage("You take a AXE");
        }
        else{
            System.out.print("You can't this command.");
        }
        return true;
    }
}

I want it to give a wooden ax with an unbreakable spell, but as I said, it gives an error "cannot find the symbol" in 2 places I do not understand.

00prf00
  • 1
  • 1

0 Answers0