Give player a custom Item

Discussion in 'Plugin Development' started by Nico8k, Aug 30, 2021.

  1. Offline

    Nico8k

    Hello there!
    I created a weapon with special abilities, but my problem is that i can't give it to the player, because it's created in an enum.

    The code from the enum:

    public enum Waffen {

    Pistole(Material.DIAMOND_AXE, "Pistole",4, Sound.ENTITY_DRAGON_FIREBALL_EXPLODE);Material material;String display; int damage;Sound sound;Waffen(Material material, String display, int damage, Sound sound){
    this.material = material; this.display = display; this.damage = damage; this.sound = sound;}



    public Material getMaterial(){
    return this.material;}

    public String getDisplay(){
    return this.display;}

    public int getDamage(){
    return this.damage;}

    public Sound getSound(){
    return this.sound;}

    }

    And I want to add it to the players inventory with player.getInventory().addItem(Waffen.Pistole), but that doesnt work. I also can't do Waffen waffen = new Waffen, becuase its an enum.
    Any help is apprechiated!
     
  2. Online

    timtower Administrator Administrator Moderator

    @Nico8k Might want to make a function: getItemStack(), then you can add that.
     

Share This Page