CHEST SHOP AND ANY SHOP SYSTEM SUPER BUG!

Discussion in 'Bukkit Help' started by SniperElite, Jan 16, 2013.

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

    SniperElite

    LOOK!!
    If you rename the diamond or any item and sell!
    Is impossible to sell and you ll earn infinite money!
    FIX THIS UNTIL IT EXPLODE!!!!!!!!!\
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     
  2. Offline

    caseif

    Dammit, you're right. I guess I'll need to fix my plugin then...
    Also, lay off the caps.
     
  3. Offline

    ZeusAllMighty11

    "fix this until it explode"


    ... I have no words for this.



    But if this is a true bug I'll fix this too for my server, thanks?
     
  4. Offline

    Rprrr

    Although I think this is the wrong section to post this in..
    you were right.

    I just tried this on my server and the diamond didn't get removed from my inventory when I sold it. But I did get money.

    So I'm gonna close my admin shop right away. :l
     
  5. Offline

    SniperElite

    Last edited by a moderator: May 30, 2016
  6. Offline

    fireblast709

    funny how noone notices that this is the wrong section
     
  7. Offline

    caseif

    Then again, it could be seen as smart to post it here, as this is where plugin devs are most likely to notice it. But yes, it is technically in the wrong section.
     
  8. Offline

    Craftiii4

    Sorry.... I had to :3
     
  9. Offline

    alkarin

    I disagree.. I just tried this on my Shop plugin BattleShops, item is removed just fine.

    So whatever shop system you are using is bugged.
     
  10. Offline

    caseif

    The bug is caused by the shop plugin using Inventory.removeItem(), which uses an ItemStack or ItemStack[] as an argument. Because Minecraft doesn't consider an unnamed diamond and a named diamond to be equivlant ItemStacks, it doesn't remove them. However, the plugin still gives money because it checks to see if an inventory contains a certain Material, which is unaffected by ItemMeta. I wrote a method for my plugin to get around this bug, so I'll post it for any devs who see this in the future.
    Code:java
    1. public void removeFromInv(Inventory inv, Material mat, int amount){
    2. if(inv.contains(mat)){
    3. int remaining = amount;
    4. ItemStack[] contents = inv.getContents();
    5. for (ItemStack is : contents){
    6. if (is != null){
    7. if (is.getType() == mat){
    8. if(is.getAmount() > remaining){
    9. is.setAmount(is.getAmount() - remaining);
    10. remaining = 0;
    11. }
    12. else if(is.getAmount() <= remaining){
    13. if (remaining > 0){
    14. remaining -= is.getAmount();
    15. is.setType(Material.AIR);
    16. }
    17. }
    18. }
    19. }
    20. }
    21. inv.setContents(contents);
    22. }
    23. }
    24.  
    25. @SuppressWarnings("deprecation")
    26. public void removeFromPlayerInv(Inventory inv, Material mat, int amount, Player p){
    27. removeFromInv(inv, mat, amount);
    28. p.updateInventory();
    29. }

    The former is used for non-player inventories (chests, furnaces, etc.), while the latter is used for player inventories. These methods assume that you've already checked that the inventory contains enough of the material.
     
  11. Offline

    alkarin

    That must be why, I've almost always used a custom method to remove items from an inventory, so that would explain why it didnt affect BattleShops.

    Glad you put up the code for other shop systems, crashing economies is always bad.
     
  12. Offline

    SniperElite

    OTHER PLUING WITH LOGING
    OTHER BOMB!!
    If you enter on the server whith . /nameofadm,
    you dont need login, u can make a new acount and u ll have admin grulp.
    TESTED WITH
    XAULT
    and
    PEX
    ADD SKYPE I HAVE SOME PROJECTS
    josegerdes

    Not pluing, BUG!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  13. Offline

    fireblast709

    SniperElite please stop with the allcaps -_-... Also Bukkit does not support cracked servers, so there is no reason why someone could bypass naming and suddenly get admin
     
  14. Offline

    Butkicker12

    SniperElite Locked and moved to Bukkit Help forum as this seems to be a plugin issue, doesn't fit in the plugin development forum.. Also it's high recommend you don't run your server in offline mode, you won't get support.
     
Thread Status:
Not open for further replies.

Share This Page