Updated and broke

Discussion in 'Plugin Development' started by chunkaymonkay, Jun 25, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    chunkaymonkay

    hey bukkit people I made a plugin and decided to update it right.. and it all worked before and I updated one thing and it all broke here is the pastebin


    http://pastebin.com/UGqmfSbH
     
  2. Offline

    Zombie_Striker

    25.06 22:04:12 [Server] INFO java.lang.NullPointerException
    25.06 22:04:12 [Server] INFO at me.eric.ItemMechanics.Attributes.<init>(Attributes.java:269) ~[?:?]


    Something is null it the Attributes class at line 269. Please, try to fix your problem by making figuring out what object is null, and initializing the variable. If the problem persists, post the class.
     
  3. Offline

    chunkaymonkay

    @Zombie_Striker

    this is my code at like 269

    // Load NBT
    if(nmsStack.getTag() == null) {
    nmsStack.setTag(parent = new NBTTagCompound());
    } else {
    parent = nmsStack.getTag();
    }
     
  4. Offline

    Zombie_Striker

  5. Offline

    chunkaymonkay

    Last edited: Jun 27, 2016
  6. Offline

    chunkaymonkay

    I cant figure this out , I'm stumped , can anyone help me?
     
  7. Code:
    [LIST=1]
    [*]public Attributes(ItemStack stack)
    [*]    {
    [*]        // Create a CraftItemStack (under the hood)
    [*]        this.nmsStack = CraftItemStack.asNMSCopy(stack);
    [*]       
    [*]        // Load NBT
    [*]        if (nmsStack.getTag() != null)
    [*]        {
    [*]            nmsStack.getTag();
    [*]        }
    [*]        else
    [*]        {
    [*]            parent = nmsStack.getTag();
    [*]        }
    [*]       
    [*]        // Load attribute list
    [*]        if (parent.hasKey("AttributeModifiers"))
    [*]        {
    [*]            attributes = parent.getList("AttributeModifiers", 0);
    [*]        }
    [*]        else
    [*]        {
    [*]            attributes = new NBTTagList();
    [*]            parent.set("AttributeModifiers", attributes);
    [*]        }
    [*]    }
    Your if statement does this

    if tag is not null
    Get tag and do nothing with it
    If it is null
    Make parent null

    You don't set parent if it isn't null and you make parent null if it is null.
    [/LIST]
     
    mine-care likes this.
  8. Offline

    chunkaymonkay

    @bwfcwalshy I posted the wrong code this is what it actually is

    Code:
        // This may be modified
        public net.minecraft.server.v1_8_R2.ItemStack nmsStack;
     
        private NBTTagCompound parent;
        private NBTTagList attributes;
     
        public Attributes(ItemStack stack)
        {
            // Create a CraftItemStack (under the hood)
            this.nmsStack = CraftItemStack.asNMSCopy(stack);
         
            // Load NBT
            if (nmsStack.getTag() == null)
            {
                nmsStack.setTag(parent = new NBTTagCompound());
            }
            else
            {
                parent = nmsStack.getTag();
            }
         
            // Load attribute list
            if (parent.hasKey("AttributeModifiers"))
            {
                attributes = parent.getList("AttributeModifiers", 0);
            }
            else
            {
                attributes = new NBTTagList();
                parent.set("AttributeModifiers", attributes);
            }
        }
        
     
    Last edited: Jun 28, 2016
  9. Offline

    chunkaymonkay

    Anyone? help please
     
Thread Status:
Not open for further replies.

Share This Page