KitPvP Balancer, Armor Not working?

Discussion in 'Plugin Development' started by B3N909, Oct 11, 2014.

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

    B3N909

    So I am trying to make a method that gets the amount of iron armor you are wearing and diamond, then multiplies the iron by x0.10 and the diamond by x0.13, then substracts those values from 1.00$ and returns it. But whenever I try to run it and we have armor on it only says you have "1" armor.

    Code:
    Code:java
    1. public double getPrice(Player p){
    2. double startprice = 1.00;
    3. int iron = 0;
    4. int diamond = 0;
    5. int finalprice = 0;
    6. if(p.getInventory().getArmorContents().length > 0) {
    7. /** Helmet **/
    8. if(p.getInventory().getHelmet() != null) {
    9. if(p.getInventory().getHelmet().getType().equals(Material.IRON_HELMET)) {
    10. iron = iron + 1;
    11. }else if(p.getInventory().getHelmet().getType().equals(Material.DIAMOND_HELMET)) {
    12. diamond = diamond + 1;
    13. }
    14. }
    15.  
    16. /** Chestplate **/
    17. if(p.getInventory().getChestplate() != null) {
    18. if(p.getInventory().getChestplate().equals(Material.IRON_CHESTPLATE)) {
    19. iron = iron + 1;
    20. }else if(p.getInventory().getChestplate().equals(Material.DIAMOND_CHESTPLATE)) {
    21. diamond = diamond + 1;
    22. }
    23. }
    24.  
    25. /** Leggings **/
    26. if(p.getInventory().getLeggings() != null) {
    27. if(p.getInventory().getChestplate().equals(Material.IRON_LEGGINGS)) {
    28. iron = iron + 1;
    29. }else if(p.getInventory().getChestplate().equals(Material.DIAMOND_LEGGINGS)) {
    30. diamond = diamond + 1;
    31. }
    32. }
    33.  
    34. /** Boots **/
    35. if(p.getInventory().getBoots() != null) {
    36. if(p.getInventory().getBoots().equals(Material.IRON_BOOTS)) {
    37. iron = iron + 1;
    38. }else if(p.getInventory().getBoots().equals(Material.DIAMOND_BOOTS)) {
    39. diamond = diamond + 1;
    40. }
    41. }
    42. p.sendMessage("" + iron);
    43. p.sendMessage("" + diamond);
    44. startprice = startprice-(0.10*iron)+(0.13*diamond);
    45. if(startprice > 0) {
    46. return startprice;
    47. }else {
    48. return 0;
    49. }
    50. }else {
    51. return 0;
    52. }
    53. }
     
  2. Offline

    CaptainUniverse

    B3N909 why are you doing
    I thought you were adding things
     
  3. Offline

    jpjunho

    B3N909
    On all checks, except the helmet one you're comparing the itemstack to a material
     
  4. Offline

    B3N909

    @CaptianUniverse , I add them then subtact to get a price that is balanced so pepole dont sit in diamond and never die. jpjunho , I added what you said with the getType() and it sorta works. If I wear nothing then it does not give me anything, BUT if I wear one or more it only says I have '1' on at all times? Thanks!
     
  5. Offline

    B3N909

    Bump. Still can't figure this out??
     
  6. Offline

    SuperOriginal

    Make sure you have .getType after every single armor piece, not just the head
     
  7. Offline

    B3N909

    I added that, and it still does not work. I think its something with the adding up the amount of armor you have on because it can find individual pieces.
     
Thread Status:
Not open for further replies.

Share This Page