Plugin problem

Discussion in 'Plugin Development' started by blackshade, Jan 19, 2011.

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

    blackshade

    Hi I made a little plugin for bukkit (my first one).
    But on the part that the plugin should remove 1 item from a stack it goes wrong. well actually it works only you don't see it. lets say i have 32 dirt, the plgin should remove 1. Afterwarts I still see 32 but I have actually 31, when I reconnect tot he server you will see the 31, but not the instance that plugin have done the job.

    I tried just A plugin who removes an item n right click (with the same part of the code I used for the real plugin) and that worked fine...)

    I will attach the whole .java files to this post. I have tried almost anything and I can't find it. Maybe you guys can

    regards,
    Blackshade
     

    Attached Files:

  2. Offline

    Archelaus

    Could you just post your part that remove the blocks? I can't download anything right now.
     
  3. Offline

    apexearth

    I'm placing my bets on it being a problem with Bukkit. It's probably because Bukkit isn't finished yet. This is not the first time I've read about someone having this issue.
     
  4. Offline

    blackshade

    This is the particular code that will delete 1 item.
    It works fine alone but in a plugin i wrote it acts really strange like I have posted before.

    Maybe it is a problem in bukkit, but why would the same code works fine normal but when I use it in the loop for the plugin it bugs...

    Code:
                        if(check == true) {
                                for(int i=0;i<costs.length;i++) {
                                    int itemidx = inv.first(Integer.parseInt(costs[i]));
                                    int aantal = inv.getItem(itemidx).getAmount();
                                    ItemStack item = new ItemStack(3,aantal-1);
                                    inv.setItem(itemidx, item);
                                    player.sendMessage("old amount:"+aantal);
                                }
                                event.getItemInHand().setDamage((byte) 0x01);
                                player.sendMessage("Item "+inHand+" is now repaired");
    
                            } else {
    
                                player.sendMessage(plugin.toolsMessage);
                            }
    costs[ ] is an array with the costs for the product in it.
     
  5. Offline

    blackshade

    Somebody an idea what is wrong with my code?

    I found the cause of my problem.
    The inventory needs to update it self after the plugin has done its work... One problem, there is nothing in bukkit that can do that (yet).
    So I think i need to wait a little longer. till they make an iventory update function in it.

    I found this when i used the plugin and placed a blok of the same item, the inventory refreshed it self doing that en tada!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 6, 2016
Thread Status:
Not open for further replies.

Share This Page