Solved Weird inventory bug?

Discussion in 'Plugin Development' started by soulofw0lf, Jul 7, 2013.

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

    soulofw0lf

    So i've got a really weird inventory bug where payers are getting their gear from their classes right up until they try to use it and then it just dissapears, armor seems to be working fine but sword and things just dissappear.
    classItemList is a Mapped list of ItemStacks generated onEnable from config, as i said they are getting the items correctly, lore name's and everything, they just dissapear as soon as they're used. Any thoughts?

    Code:java
    1. for (ItemStack iS : classItemList.get(pClass)){
    2. if (iS.getType().equals(Material.LEATHER_HELMET) || iS.getType().equals(Material.CHAINMAIL_HELMET) || iS.getType().equals(Material.IRON_HELMET) || iS.getType().equals(Material.GOLD_HELMET) || iS.getType().equals(Material.DIAMOND_HELMET)){
    3. p.getInventory().setHelmet(iS);
    4. continue;
    5. }
    6. if (iS.getType().equals(Material.LEATHER_CHESTPLATE) || iS.getType().equals(Material.CHAINMAIL_CHESTPLATE) || iS.getType().equals(Material.IRON_CHESTPLATE) || iS.getType().equals(Material.GOLD_CHESTPLATE) || iS.getType().equals(Material.DIAMOND_CHESTPLATE)){
    7. p.getInventory().setChestplate(iS);
    8. continue;
    9. }
    10. if (iS.getType().equals(Material.LEATHER_LEGGINGS) || iS.getType().equals(Material.CHAINMAIL_LEGGINGS) || iS.getType().equals(Material.IRON_LEGGINGS) || iS.getType().equals(Material.GOLD_LEGGINGS) || iS.getType().equals(Material.DIAMOND_LEGGINGS)){
    11. p.getInventory().setLeggings(iS);
    12. continue;
    13. }
    14. if (iS.getType().equals(Material.LEATHER_BOOTS) || iS.getType().equals(Material.CHAINMAIL_BOOTS) || iS.getType().equals(Material.IRON_BOOTS) || iS.getType().equals(Material.GOLD_BOOTS) || iS.getType().equals(Material.DIAMOND_BOOTS)){
    15. p.getInventory().setBoots(iS);
    16. continue;
    17. }
    18. p.getInventory().addItem(iS);


    update here's the whole equipment handler part of the code, it's called on respawn and on enter game. both have the same bug where the items disappear right after you use them.

    Code:java
    1. public class EquipmentHandler {
    2. public static void equipmentProcessor(Player p){
    3. String player = p.getName();
    4. p.getInventory().setArmorContents(null);
    5. String pClass = KeyStone.playerClasses.get(player);
    6. for (ItemStack iS : KeyStone.classItemList.get(pClass)){
    7. if (iS == null || iS.getType().equals(Material.AIR)){
    8. continue;
    9. }
    10. if (iS.getType().toString().indexOf("HELMET") != -1){
    11. p.getInventory().setHelmet(iS);
    12. continue;
    13. }
    14. if (iS.getType().toString().indexOf("CHESTPLATE") != -1){
    15. p.getInventory().setChestplate(iS);
    16. continue;
    17. }
    18. if (iS.getType().toString().indexOf("LEGGINGS") != -1){
    19. p.getInventory().setLeggings(iS);
    20. continue;
    21. }
    22. if (iS.getType().toString().indexOf("BOOTS") != -1){
    23. p.getInventory().setBoots(iS);
    24. continue;
    25. }
    26. p.getInventory().addItem(iS);
    27.  
    28. }
    29. final Player pl = p;
    30. new BukkitRunnable(){
    31. @Override
    32. public void run(){
    33. pl.updateInventory();
    34. }
    35. }.runTaskLater(KeyStone.plugin, 10);
    36. }
    37. }


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

Share This Page