Solved Galaxy Armor Not Working!

Discussion in 'Spigot Plugin Development' started by CosmicFlameV2, May 30, 2016.

  1. Set durability to (short) 0
     
  2. ok ill try
     
  3. didnt go up it just stayed the same

    Code (Text):

    if(g1.getDurability() < (short) Material.getMaterial(298).getMaxDurability()){
                          g1.setDurability((short) Material.getMaterial(298).getMaxDurability());
                      }else if(g2.getDurability() < (short) Material.getMaterial(299).getMaxDurability()){
                          g2.setDurability((short) Material.getMaterial(299).getMaxDurability());
                      }else if(g3.getDurability() < (short) Material.getMaterial(300).getMaxDurability()){
                          g3.setDurability((short) Material.getMaterial(300).getMaxDurability());
                      }else if(g4.getDurability() < (short) Material.getMaterial(301).getMaxDurability()){
                          g1.setDurability((short) Material.getMaterial(301).getMaxDurability());
    [CODE/]

    Is that right?
     
  4. Did you even try to read
     
  5. srry xD
     
  6. Code (Text):

    if(g1.getDurability() < (short) Material.getMaterial(298).getMaxDurability()){
                          g1.setDurability((short) 0);
                      }else if(g2.getDurability() < (short) Material.getMaterial(299).getMaxDurability()){
                          g2.setDurability((short) 0);
                      }else if(g3.getDurability() < (short) Material.getMaterial(300).getMaxDurability()){
                          g3.setDurability((short) 0);
                      }else if(g4.getDurability() < (short) Material.getMaterial(301).getMaxDurability()){
                          g1.setDurability((short) 0);
     
    tried it but didnt work
     
  7. @CosmicFlameV2 Don't compare using ==, and you're only setting the durability for the items you just created, not the ones in the inventory
     
  8. should i use = ?
     
  9. = wont work ill do isSimilar()
     
  10. @CosmicFlameV2 usually when you want to compare values, you would use .equals(), but with ItemStacks I recommend .isSimilar() as it doesn't care about the amount.

    EDIT: O dank you beat me to it
     
  11. maxDurability = the least
     
  12. Code (Text):

    if(e.getPlayer().getInventory().getHelmet().isSimilar(g1) || e.getPlayer().getInventory().getChestplate().isSimilar(g2) ||
                          e.getPlayer().getInventory().getLeggings().isSimilar(g3) ||
                          e.getPlayer().getInventory().getBoots().isSimilar(g4)){
                      if(g1.getDurability() < (short) Material.getMaterial(298).getMaxDurability()){
                          g1.setDurability((short) 0);
                      }else if(g2.getDurability() < (short) Material.getMaterial(299).getMaxDurability()){
                          g2.setDurability((short) 0);
                      }else if(g3.getDurability() < (short) Material.getMaterial(300).getMaxDurability()){
                          g3.setDurability((short) 0);
                      }else if(g4.getDurability() < (short) Material.getMaterial(301).getMaxDurability()){
                          g4.setDurability((short) 0);
                  }
     
    ^^^^^^^^
     
  13. @CosmicFlameV2 you're still setting the durability for the items. Use the inventory's item like:
    Code (Java):
    e.getPlayer().getInventory().getHelmet().setDurability((short) 0);
     
  14. k
     
  15. ur method isnt working
    Code (Text):

        if(e.getPlayer().getInventory().getHelmet().isSimilar(g1) || e.getPlayer().getInventory().getChestplate().isSimilar(g2) ||
                          e.getPlayer().getInventory().getLeggings().isSimilar(g3) ||
                          e.getPlayer().getInventory().getBoots().isSimilar(g4)){
                      if(g1.getDurability() < (short) Material.getMaterial(298).getMaxDurability()){
                          e.getPlayer().getInventory().getHelmet().setDurability((short) 0);
                      }else if(g2.getDurability() < (short) Material.getMaterial(299).getMaxDurability()){
                          e.getPlayer().getInventory().getChestplate().setDurability((short) 0);
                      }else if(g3.getDurability() < (short) Material.getMaterial(300).getMaxDurability()){
                          e.getPlayer().getInventory().getLeggings().setDurability((short) 0);
                      }else if(g4.getDurability() < (short) Material.getMaterial(301).getMaxDurability()){
                          e.getPlayer().getInventory().getBoots().setDurability((short) 0);
                  }
     
     
  16. Explained:
    if (players helmet is similar to g1 OR chest is similar to g2 OR legs similar g3 OR boots similar g4 ) THEN

    * if ( g1 (NOT THE ITEM)'s durability is LESS than the max(which of it would be broken at)) then set the HELMETS durability to none. Basically, fix.
    Go on for g2, g3, g4 on chest, legs, boots.

    end
     
  17. Getting this error in the console im the best at reading errors sorry
    Code (Text):

    [20:04:19 ERROR]: Could not pass event PlayerInteractEvent to ScraftCore v2.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:228) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:195) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:191) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1200) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation.a(PacketPlayInArmAnimation.java:18) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation.a(PacketPlayInArmAnimation.java:1) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_73]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_73]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_73]
    Caused by: java.lang.NullPointerException
            at scraftcore.galaxyset.GalaxyArmor.onArmor(GalaxyArmor.java:33) ~[?:?]
            at sun.reflect.GeneratedMethodAccessor562.invoke(Unknown Source) ~[?:?]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_73]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_73]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot_latest.jar:git-Spigot-db6de12-18fbb24]
            ... 18 more