Solved I don't even...

Discussion in 'Plugin Development' started by ItsOneAndTwo, Jan 24, 2014.

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

    ItsOneAndTwo

    Ok so i have this plugin I made.
    Here's the code:
    Code:java
    1. if(args.length == 2) {
    2. if(player.getItemInHand().getType() == Material.BOW) {
    3. ItemStack hand = player.getItemInHand();
    4. ItemMeta meta = hand.getItemMeta();
    5.  
    6. if(args[1].equalsIgnoreCase("Lightning")) {
    7. lore.add("§7Strike a lightning bolt");
    8. meta.setLore(lore);
    9. meta.setDisplayName("Bow - Lightning");
    10. hand.setItemMeta(meta);
    11. lore.clear();
    12. sender.sendMessage("§aEnjoy your Lightning bow!");
    13. }
    14.  
    15. if(args[1].equalsIgnoreCase("Fireball")) {
    16. lore.add("§7Shoot a fireball");
    17. meta.setLore(lore);
    18. meta.setDisplayName("Bow - Fireball");
    19. hand.setItemMeta(meta);
    20. lore.clear();
    21. sender.sendMessage("§aEnjoy your Fireball bow!");
    22. }
    23.  
    24. if(args[1].equalsIgnoreCase("Witherskull")) {
    25. lore.add("§7Shoot a witherskull");
    26. meta.setLore(lore);
    27. meta.setDisplayName("Bow - Witherskull");
    28. hand.setItemMeta(meta);
    29. lore.clear();
    30. sender.sendMessage("§aEnjoy your Witherskull bow!");
    31. }
    32.  
    33. if(args[1].equalsIgnoreCase("Explosion")) {
    34. lore.add("§7Create an explosion");
    35. meta.setLore(lore);
    36. meta.setDisplayName("Bow - Explosion");
    37. hand.setItemMeta(meta);
    38. lore.clear();
    39. sender.sendMessage("§aEnjoy your Explosion bow!");
    40. }
    41.  
    42. if(args[1].equalsIgnoreCase("Teleport")) {
    43. lore.add("§7Teleport to the arrow's landing point");
    44. meta.setLore(lore);
    45. meta.setDisplayName("Bow - Teleport");
    46. hand.setItemMeta(meta);
    47. lore.clear();
    48. sender.sendMessage("§aEnjoy your Teleport bow!");
    49. }
    50.  
    51. if(args[1].equalsIgnoreCase("Bat")) {
    52. lore.add("§7Spawn a Bat");
    53. meta.setLore(lore);
    54. meta.setDisplayName("Bow - Bat");
    55. hand.setItemMeta(meta);
    56. lore.clear();
    57. sender.sendMessage("§aEnjoy your Bat bow!");
    58. }
    59.  
    60. if(args[1].equalsIgnoreCase("Blaze")) {
    61. lore.add("§7Spawn a Blaze");
    62. meta.setLore(lore);
    63. meta.setDisplayName("Bow - Blaze");
    64. hand.setItemMeta(meta);
    65. lore.clear();
    66. sender.sendMessage("§aEnjoy your Blaze bow!");
    67. }
    68.  
    69. if(args[1].equalsIgnoreCase("Cavespider")) {
    70. lore.add("§7Spawn a Cavespider");
    71. meta.setLore(lore);
    72. meta.setDisplayName("Bow - Cavespider");
    73. hand.setItemMeta(meta);
    74. lore.clear();
    75. sender.sendMessage("§aEnjoy your Cavespider bow!");
    76. }
    77.  
    78. if(args[1].equalsIgnoreCase("Chicken")) {
    79. lore.add("§7Spawn a Chicken");
    80. meta.setLore(lore);
    81. meta.setDisplayName("Bow - Chicken");
    82. hand.setItemMeta(meta);
    83. lore.clear();
    84. sender.sendMessage("§aEnjoy your Chicken bow!");
    85. }
    86.  
    87. if(args[1].equalsIgnoreCase("Cow")) {
    88. lore.add("§7Spawn a Cow");
    89. meta.setLore(lore);
    90. meta.setDisplayName("Bow - Cow");
    91. hand.setItemMeta(meta);
    92. lore.clear();
    93. sender.sendMessage("§aEnjoy your Cow bow!");
    94. }
    95.  
    96. if(args[1].equalsIgnoreCase("Creeper")) {
    97. lore.add("§7Spawn a Creeper");
    98. meta.setLore(lore);
    99. meta.setDisplayName("Bow - Creeper");
    100. hand.setItemMeta(meta);
    101. lore.clear();
    102. sender.sendMessage("§aEnjoy your Creeper bow!");
    103. }
    104.  
    105. if(args[1].equalsIgnoreCase("Enderdragon")) {
    106. lore.add("§7Spawn an Enderdragon");
    107. meta.setLore(lore);
    108. meta.setDisplayName("Bow - Enderdragon");
    109. hand.setItemMeta(meta);
    110. lore.clear();
    111. sender.sendMessage("§aEnjoy your Enderdragon bow!");
    112. }
    113.  
    114. if(args[1].equalsIgnoreCase("Enderman")) {
    115. lore.add("§7Spawn an Enderman");
    116. meta.setLore(lore);
    117. meta.setDisplayName("Bow - Enderman");
    118. hand.setItemMeta(meta);
    119. lore.clear();
    120. sender.sendMessage("§aEnjoy your Enderman bow!");
    121. }
    122.  
    123. if(args[1].equalsIgnoreCase("Ghast")) {
    124. lore.add("§7Spawn a Ghast");
    125. meta.setLore(lore);
    126. meta.setDisplayName("Bow - Ghast");
    127. hand.setItemMeta(meta);
    128. lore.clear();
    129. sender.sendMessage("§aEnjoy your Ghast bow!");
    130. }
    131.  
    132. if(args[1].equalsIgnoreCase("Giant")) {
    133. lore.add("§7Spawn a Giant");
    134. meta.setLore(lore);
    135. meta.setDisplayName("Bow - Giant");
    136. hand.setItemMeta(meta);
    137. lore.clear();
    138. sender.sendMessage("§aEnjoy your Giant bow!");
    139. }
    140. } else {
    141. sender.sendMessage("§4Please equip a bow first!");
    142. }
    143. }


    Everything works up to Creeper, after that the aguments will no longer work.
    If i were to type /cmd set Creeper, then everything works as it should.
    Now if i were to type /cmd set Enderdragon, it will do nothing.
    Is there a limit to how much IF statements I can use or what?
     
  2. Offline

    Monkey_Swag

    You have to add else's in your code

    if(cmd.getName().equalsIgnoreCase("one")) {
    p.sendMessage("one");
    } else if(cmd.getName().equalsIgnoreCase("two")) {
    p.sendMessage("two");
    } else if(cmd.getName().equalsIgnoreCase("three")){
    p.sendMessage("three");
    }

    So on and so fourth
     
  3. Offline

    fireblast709

    ItsOneAndTwo the code looks fine, and it -should- work fine. Maybe something else causes the problem, so try to debug it.

    Monkey_Swag elses are optional, and wouldn't cause functionality problems in this case (or Java would have to break)
     
  4. Offline

    ItsOneAndTwo

    Monkey_Swag
    fireblast709
    I've tried with else's and without, every single argument up to creeper works fine, if i go past creeper it wont work.
    No errors in console.
     
  5. Offline

    Maurdekye

    Comment out the creeper section. Is it still bugged after that point?
    Edit: also, what's your stacktrace?
     
  6. Offline

    ItsOneAndTwo

    Maurdekye
    Thanks dude, it worked even after I wrote creeper part again, I just have no idea what happaned, I triple checked the code also..
     
  7. Offline

    Garris0n

    This is marked as solved, is it solved or...?
     
Thread Status:
Not open for further replies.

Share This Page