FirecatHD's Question Thread

Discussion in 'Plugin Development' started by FirecatHD, Nov 15, 2013.

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

    FirecatHD

    I have so many small questions that i thought i could just make one thread for them all, if it's ok.
    So i will post here if it is just a small detail or something like that i cant figure out.

    Also if you wonder why i am asking so much, well i have only been coding for four days, so i am sorry for being so nooby.

    But i am eager to learn, and hope to get a little support :rolleyes:
    Also sorry for my bad english, i am from Norway...

    So this is my first question: I know this is a java error, but i cant figure it out.
    Source Code:
    Code:java
    1. package me.FirecatHD.TBS_PvP;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Color;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.enchantments.Enchantment;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.event.Listener;
    12. import org.bukkit.inventory.ItemStack;
    13. import org.bukkit.inventory.PlayerInventory;
    14. import org.bukkit.inventory.meta.ItemMeta;
    15. import org.bukkit.inventory.meta.LeatherArmorMeta;
    16. import org.bukkit.plugin.java.JavaPlugin;
    17. import org.bukkit.potion.PotionEffect;
    18. import org.bukkit.potion.PotionEffectType;
    19.  
    20. import com.rit.sucy.EnchantmentAPI;
    21.  
    22. public class Kits extends JavaPlugin implements Listener {
    23.  
    24. public void onEnable() {
    25. Bukkit.getServer().getPluginManager().registerEvents(new DeathListener(), this);
    26. }
    27.  
    28. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    29. if (!(sender instanceof Player)) {
    30. sender.sendMessage(ChatColor.RED + "Only players can get kits!");
    31. return true;
    32.  
    33. }
    34.  
    35. Player p = (Player) sender;
    36. PlayerInventory pi = p.getInventory();
    37.  
    38. if (cmd.getName().equalsIgnoreCase("basic")) {
    39.  
    40. pi.clear();
    41. pi.setArmorContents(null);
    42.  
    43. for(PotionEffect effect : p.getActivePotionEffects())
    44. {
    45. p.removePotionEffect(effect.getType());
    46. }
    47.  
    48. ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD,1);
    49. ItemMeta meta = Sword.getItemMeta();
    50. meta.setDisplayName(ChatColor.AQUA + "Basic Sword");
    51. Sword.setItemMeta(meta);
    52. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    53. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
    54. pi.addItem(Sword);
    55.  
    56. ItemStack Bow = new ItemStack(Material.BOW, 1);
    57. ItemMeta meta1 = Bow.getItemMeta();
    58. meta1.setDisplayName(ChatColor.GOLD + "Basic Bow");
    59. Bow.setItemMeta(meta1);
    60. Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    61. Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    62. Bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
    63. pi.addItem(Bow);
    64.  
    65. pi.setHelmet(new ItemStack(Material.IRON_HELMET));
    66. pi.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
    67. pi.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
    68. pi.setBoots(new ItemStack(Material.IRON_BOOTS));
    69.  
    70. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    71. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    72. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    73. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    74.  
    75. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    76. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    77. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    78. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    79.  
    80.  
    81. for(int i = 0; i < 15; i++) {
    82. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    83. }
    84. pi.addItem(new ItemStack(Material.ARROW , 1));
    85. for(int i = 0; i < 18; i++) {
    86. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    87. }
    88.  
    89. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.BLUE + "Basic! " + ChatColor.GRAY + "Its balanced, but yet strong!");
    90. return true;
    91. }
    92.  
    93. { //command
    94.  
    95. if (cmd.getName().equalsIgnoreCase("derpy")) {
    96.  
    97. pi.clear();
    98. pi.setArmorContents(null);
    99.  
    100. for(PotionEffect effect : p.getActivePotionEffects())
    101. {
    102. p.removePotionEffect(effect.getType());
    103. }
    104.  
    105. //Potion effects
    106.  
    107. p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000000, 0));
    108. p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1000000, 2));
    109. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 1));
    110. p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, 1));
    111.  
    112. //Enchantment's
    113.  
    114. ItemStack hay = new ItemStack(Material.WHEAT, 1);
    115. ItemMeta meta = hay.getItemMeta();
    116. meta.setDisplayName(ChatColor.YELLOW + "Hay");
    117. hay.setItemMeta(meta);;
    118. hay.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    119. hay.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 3);
    120. pi.addItem(hay);
    121.  
    122. ItemStack muffin = new ItemStack(Material.CAKE, 1);
    123. ItemMeta meta1 = muffin.getItemMeta();
    124. meta1.setDisplayName(ChatColor.LIGHT_PURPLE + "Muffin");
    125. muffin.setItemMeta(meta1);;
    126. muffin.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    127. EnchantmentAPI.getEnchantment("Dash").addToItem(muffin, 20);
    128. pi.addItem(muffin);
    129.  
    130. //Armour
    131.  
    132. pi.setHelmet(new ItemStack(Material.LEATHER_HELMET));
    133. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    134. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    135. pi.setBoots(new ItemStack(Material.LEATHER_BOOTS));
    136.  
    137. //Armour enchantments
    138.  
    139. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    140. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    141.  
    142. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    143. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    144. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    145. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    146.  
    147. //Leather armour colors
    148. ItemStack Helm = p.getInventory().getHelmet();
    149. LeatherArmorMeta im = (LeatherArmorMeta) Helm.getItemMeta();
    150. im.setColor(Color.fromRGB(255, 248, 148));
    151. Helm.setItemMeta(im);
    152.  
    153. ItemStack Chestplate = p.getInventory().getChestplate();
    154. Chestplate.getItemMeta();
    155. im.setColor(Color.fromRGB(175, 177, 250));
    156. Chestplate.setItemMeta(im);
    157.  
    158. ItemStack Leggings = p.getInventory().getLeggings();
    159. LeatherArmorMeta im1 = (LeatherArmorMeta) Leggings.getItemMeta();
    160. im1.setColor(Color.fromRGB(175, 177, 250));
    161. Leggings.setItemMeta(im1);
    162.  
    163. ItemStack Boots = p.getInventory().getBoots();
    164. Boots.getItemMeta();
    165. im1.setColor(Color.fromRGB(255, 248, 148));
    166. Boots.setItemMeta(im1);
    167.  
    168. //Items
    169.  
    170. for(int i = 0; i < 35; i++) {
    171. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    172. }
    173.  
    174. //On give message
    175.  
    176. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.LIGHT_PURPLE + "Derpy! " + ChatColor.YELLOW + "Your left eye rolls off in another direction while you prepare for battle!");
    177. return true;
    178. }
    179. }
    180.  
    181. { //command
    182.  
    183. if (cmd.getName().equalsIgnoreCase("pyro")) {
    184.  
    185. }
    186.  
    187. pi.clear();
    188. pi.setArmorContents(null);
    189.  
    190. for(PotionEffect effect : p.getActivePotionEffects())
    191. {
    192. p.removePotionEffect(effect.getType());
    193. }
    194.  
    195. //Potion effects
    196.  
    197. p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 1000000, 2));
    198.  
    199. //Enchantment's
    200.  
    201. ItemStack flamethrower = new ItemStack(Material.BOW, 1);
    202. ItemMeta meta = flamethrower.getItemMeta();
    203. meta.setDisplayName(ChatColor.RED + "Flamethrower");
    204. flamethrower.setItemMeta(meta);;
    205. flamethrower.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    206. flamethrower.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    207. flamethrower.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 3);
    208. pi.addItem(flamethrower);
    209.  
    210. //Armour
    211.  
    212. pi.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
    213. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    214. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    215. pi.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
    216.  
    217. //Armour enchantments
    218.  
    219. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    220. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    221. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    222. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    223.  
    224. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    225. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    226. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    227. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    228.  
    229. //Leather armour colors
    230.  
    231. ItemStack Chestplate = p.getInventory().getChestplate();
    232. LeatherArmorMeta im1 = (LeatherArmorMeta) Chestplate.getItemMeta();
    233. im1.setColor(Color.fromRGB(175, 0, 0));
    234. Chestplate.setItemMeta(im1);
    235.  
    236. ItemStack Leggings = p.getInventory().getLeggings();
    237. LeatherArmorMeta im11 = (LeatherArmorMeta) Leggings.getItemMeta();
    238. im11.setColor(Color.fromRGB(175, 0, 0));
    239. Leggings.setItemMeta(im11);
    240.  
    241. //Items
    242.  
    243. for(int i = 0; i < 16; i++) {
    244. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    245. }
    246. pi.addItem(new ItemStack(Material.ARROW , 1));
    247. for(int i = 0; i < 18; i++) {
    248. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    249. }
    250.  
    251. //On give message
    252.  
    253. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]" + ChatColor.GRAY + ":" + ChatColor.GREEN + "You equipped " + ChatColor.RED + "Pyro! " + ChatColor.GOLD + "Will we ever know what is behind the mask!?");
    254. return true;
    255.  
    256. {
    257.  
    258. {
    259.  
    260.  
    261. //command
    262.  
    263. if (cmd.getName().equalsIgnoreCase("basic")) {
    264.  
    265. }
    266. pi.clear();
    267. pi.setArmorContents(null);
    268.  
    269. for(PotionEffect effect : p.getActivePotionEffects())
    270. {
    271. p.removePotionEffect(effect.getType());
    272. }
    273.  
    274. ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD,1);
    275. ItemMeta meta1 = Sword.getItemMeta();
    276. meta1.setDisplayName(ChatColor.AQUA + "Basic Sword");
    277. Sword.setItemMeta(meta1);
    278. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    279. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
    280. pi.addItem(Sword);
    281.  
    282. ItemStack Bow = new ItemStack(Material.BOW, 1);
    283. ItemMeta eta = Bow.getItemMeta();
    284. eta.setDisplayName(ChatColor.GOLD + "Basic Bow");
    285. Bow.setItemMeta(eta);
    286. Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    287. Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    288. Bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
    289. pi.addItem(Bow);
    290.  
    291. pi.setHelmet(new ItemStack(Material.IRON_HELMET));
    292. pi.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
    293. pi.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
    294. pi.setBoots(new ItemStack(Material.IRON_BOOTS));
    295.  
    296. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    297. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    298. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    299. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    300.  
    301. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    302. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    303. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    304. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    305.  
    306.  
    307. for(int i = 0; i < 15; i++) {
    308. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    309. }
    310. pi.addItem(new ItemStack(Material.ARROW , 1));
    311. for(int i = 0; i < 18; i++) {
    312. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    313. }
    314.  
    315. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.BLUE + "Basic! " + ChatColor.GRAY + "Its balanced, but yet strong!");
    316. return true;
    317.  
    318. }
    319. }
    320. }
    321.  


    I have asked for help on this problem before, but not gotten to much out of it.
    It says on the last curly break that i have to set in one more to complete Classbody, but when i do the last part of the code gets unreachable :confused:

    I know Eclipse is kinda lying about placing the last curly break at the bottom, i am not sure though.
    However last time i managed to fix this, but i cant remember how i did it.
    So i need someone to explain the error, thats the best way for me to learn, so if i can get a little help that would be awesome!

    Thanks in advance.

    Tags: sgavster SkillSam L33m4n123 superjesse07
     
  2. Offline

    Mathias Eklund

    What's the error?
     
    FirecatHD likes this.
  3. Offline

    L33m4n123

    Uhm. After adding two closing brackets at the end the issue with the closing brackets seems to be fixed.. But why do you

    Code:java
    1. if(cmd.getName().equalsIgnoreCase("command1")) {
    2. //what ever command1 does
    3. }
    4. {
    5. if (cmd.getName().equalsIgnoreCase("command2")) {
    6. //what ever command 2 does
    7. }
    8. }


    Why are you opening the brackets before the if again? o.o it should be

    Code:java
    1. if(cmd.getName().equalsIgnoreCase("command1")) {
    2. //what ever command1 does
    3. } else if (cmd.getName().equalsIgnoreCase("command2")) {
    4. //what ever command 2 does
    5. }


    So take your time and redo the brackets^^
     
    FirecatHD likes this.
  4. Offline

    FirecatHD

    L33m4n123

    Ehh i dont know why i open the brackets, i get an error if i dont do it :eek:

    But when i place 2 breaks at the end, i get some errors too :'(
    Also why did you place a IF statement?
     
  5. Offline

    The_Doctor_123

    Err.. What?
     
  6. Offline

    FirecatHD

    @TheDoctor_123

    Ok here is the error:
    as it is now it says on the last bracket: Syntax error, insert "}" to complete ClassBody
     
  7. Offline

    The_Doctor_123

    FirecatHD
    You're probably missing braces or you're putting them in the wrong place. Thoroughly check your bodies.
     
  8. Offline

    FirecatHD

    The_Doctor_123

    This is what i have been doing the last hour, trust me. If you have Eclipse up now can u copy and paste the code and see if you can solve the error (just if you want) then tell me the problem? Sorry if this this sounds like i am commandanting you ...

    Thanks!
     
  9. Offline

    The_Doctor_123

    FirecatHD
    I'm on an iPad, so no. I'd try to read your code, but the indentation messed up when you edited the post. Possibly copy it again?
     
  10. Offline

    FirecatHD

    The_Doctor_123

    Ok.
    Code:
    Code:java
    1. package me.FirecatHD.TBS_PvP;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Color;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.enchantments.Enchantment;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.event.Listener;
    12. import org.bukkit.inventory.ItemStack;
    13. import org.bukkit.inventory.PlayerInventory;
    14. import org.bukkit.inventory.meta.ItemMeta;
    15. import org.bukkit.inventory.meta.LeatherArmorMeta;
    16. import org.bukkit.plugin.java.JavaPlugin;
    17. import org.bukkit.potion.PotionEffect;
    18. import org.bukkit.potion.PotionEffectType;
    19.  
    20. import com.rit.sucy.EnchantmentAPI;
    21.  
    22. public class Kits extends JavaPlugin implements Listener {
    23.  
    24. public void onEnable() {
    25. Bukkit.getServer().getPluginManager().registerEvents(new DeathListener(), this);
    26. }
    27.  
    28. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    29. if (!(sender instanceof Player)) {
    30. sender.sendMessage(ChatColor.RED + "Only players can get kits!");
    31. return true;
    32.  
    33. }
    34.  
    35. Player p = (Player) sender;
    36. PlayerInventory pi = p.getInventory();
    37.  
    38. if (cmd.getName().equalsIgnoreCase("basic")) {
    39.  
    40. pi.clear();
    41. pi.setArmorContents(null);
    42.  
    43. for(PotionEffect effect : p.getActivePotionEffects())
    44. {
    45. p.removePotionEffect(effect.getType());
    46. }
    47.  
    48. ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD,1);
    49. ItemMeta meta = Sword.getItemMeta();
    50. meta.setDisplayName(ChatColor.AQUA + "Basic Sword");
    51. Sword.setItemMeta(meta);
    52. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    53. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
    54. pi.addItem(Sword);
    55.  
    56. ItemStack Bow = new ItemStack(Material.BOW, 1);
    57. ItemMeta meta1 = Bow.getItemMeta();
    58. meta1.setDisplayName(ChatColor.GOLD + "Basic Bow");
    59. Bow.setItemMeta(meta1);
    60. Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    61. Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    62. Bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
    63. pi.addItem(Bow);
    64.  
    65. pi.setHelmet(new ItemStack(Material.IRON_HELMET));
    66. pi.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
    67. pi.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
    68. pi.setBoots(new ItemStack(Material.IRON_BOOTS));
    69.  
    70. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    71. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    72. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    73. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    74.  
    75. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    76. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    77. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    78. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    79.  
    80.  
    81. for(int i = 0; i < 15; i++) {
    82. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    83. }
    84. pi.addItem(new ItemStack(Material.ARROW , 1));
    85. for(int i = 0; i < 18; i++) {
    86. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    87. }
    88.  
    89. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.BLUE + "Basic! " + ChatColor.GRAY + "Its balanced, but yet strong!");
    90. return true;
    91. }
    92.  
    93. { //command
    94.  
    95. if (cmd.getName().equalsIgnoreCase("derpy")) {
    96.  
    97. pi.clear();
    98. pi.setArmorContents(null);
    99.  
    100. for(PotionEffect effect : p.getActivePotionEffects())
    101. {
    102. p.removePotionEffect(effect.getType());
    103. }
    104.  
    105. //Potion effects
    106.  
    107. p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000000, 0));
    108. p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1000000, 2));
    109. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 1));
    110. p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, 1));
    111.  
    112. //Enchantment's
    113.  
    114. ItemStack hay = new ItemStack(Material.WHEAT, 1);
    115. ItemMeta meta = hay.getItemMeta();
    116. meta.setDisplayName(ChatColor.YELLOW + "Hay");
    117. hay.setItemMeta(meta);;
    118. hay.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    119. hay.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 3);
    120. pi.addItem(hay);
    121.  
    122. ItemStack muffin = new ItemStack(Material.CAKE, 1);
    123. ItemMeta meta1 = muffin.getItemMeta();
    124. meta1.setDisplayName(ChatColor.LIGHT_PURPLE + "Muffin");
    125. muffin.setItemMeta(meta1);;
    126. muffin.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    127. EnchantmentAPI.getEnchantment("Dash").addToItem(muffin, 20);
    128. pi.addItem(muffin);
    129.  
    130. //Armour
    131.  
    132. pi.setHelmet(new ItemStack(Material.LEATHER_HELMET));
    133. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    134. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    135. pi.setBoots(new ItemStack(Material.LEATHER_BOOTS));
    136.  
    137. //Armour enchantments
    138.  
    139. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    140. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    141.  
    142. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    143. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    144. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    145. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    146.  
    147. //Leather armour colors
    148. ItemStack Helm = p.getInventory().getHelmet();
    149. LeatherArmorMeta im = (LeatherArmorMeta) Helm.getItemMeta();
    150. im.setColor(Color.fromRGB(255, 248, 148));
    151. Helm.setItemMeta(im);
    152.  
    153. ItemStack Chestplate = p.getInventory().getChestplate();
    154. Chestplate.getItemMeta();
    155. im.setColor(Color.fromRGB(175, 177, 250));
    156. Chestplate.setItemMeta(im);
    157.  
    158. ItemStack Leggings = p.getInventory().getLeggings();
    159. LeatherArmorMeta im1 = (LeatherArmorMeta) Leggings.getItemMeta();
    160. im1.setColor(Color.fromRGB(175, 177, 250));
    161. Leggings.setItemMeta(im1);
    162.  
    163. ItemStack Boots = p.getInventory().getBoots();
    164. Boots.getItemMeta();
    165. im1.setColor(Color.fromRGB(255, 248, 148));
    166. Boots.setItemMeta(im1);
    167.  
    168. //Items
    169.  
    170. for(int i = 0; i < 35; i++) {
    171. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    172. }
    173.  
    174. //On give message
    175.  
    176. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.LIGHT_PURPLE + "Derpy! " + ChatColor.YELLOW + "Your left eye rolls off in another direction while you prepare for battle!");
    177. return true;
    178. }
    179. }
    180.  
    181. { //command
    182.  
    183. if (cmd.getName().equalsIgnoreCase("pyro")) {
    184.  
    185. }
    186.  
    187. pi.clear();
    188. pi.setArmorContents(null);
    189.  
    190. for(PotionEffect effect : p.getActivePotionEffects())
    191. {
    192. p.removePotionEffect(effect.getType());
    193. }
    194.  
    195. //Potion effects
    196.  
    197. p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 1000000, 2));
    198.  
    199. //Enchantment's
    200.  
    201. ItemStack flamethrower = new ItemStack(Material.BOW, 1);
    202. ItemMeta meta = flamethrower.getItemMeta();
    203. meta.setDisplayName(ChatColor.RED + "Flamethrower");
    204. flamethrower.setItemMeta(meta);;
    205. flamethrower.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    206. flamethrower.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    207. flamethrower.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 3);
    208. pi.addItem(flamethrower);
    209.  
    210. //Armour
    211.  
    212. pi.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
    213. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    214. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    215. pi.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
    216.  
    217. //Armour enchantments
    218.  
    219. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    220. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    221. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    222. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    223.  
    224. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    225. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    226. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    227. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    228.  
    229. //Leather armour colors
    230.  
    231. ItemStack Chestplate = p.getInventory().getChestplate();
    232. LeatherArmorMeta im1 = (LeatherArmorMeta) Chestplate.getItemMeta();
    233. im1.setColor(Color.fromRGB(175, 0, 0));
    234. Chestplate.setItemMeta(im1);
    235.  
    236. ItemStack Leggings = p.getInventory().getLeggings();
    237. LeatherArmorMeta im11 = (LeatherArmorMeta) Leggings.getItemMeta();
    238. im11.setColor(Color.fromRGB(175, 0, 0));
    239. Leggings.setItemMeta(im11);
    240.  
    241. //Items
    242.  
    243. for(int i = 0; i < 16; i++) {
    244. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    245. }
    246. pi.addItem(new ItemStack(Material.ARROW , 1));
    247. for(int i = 0; i < 18; i++) {
    248. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    249. }
    250.  
    251. //On give message
    252.  
    253. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]" + ChatColor.GRAY + ":" + ChatColor.GREEN + "You equipped " + ChatColor.RED + "Pyro! " + ChatColor.GOLD + "Will we ever know what is behind the mask!?");
    254. return true;
    255. {
    256.  
    257.  
    258.  
    259. {
    260.  
    261.  
    262. //command
    263.  
    264. if (cmd.getName().equalsIgnoreCase("basic")) {
    265.  
    266. }
    267. pi.clear();
    268. pi.setArmorContents(null);
    269.  
    270. for(PotionEffect effect : p.getActivePotionEffects())
    271. {
    272. p.removePotionEffect(effect.getType());
    273. }
    274.  
    275. ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD,1);
    276. ItemMeta meta1 = Sword.getItemMeta();
    277. meta1.setDisplayName(ChatColor.AQUA + "Basic Sword");
    278. Sword.setItemMeta(meta1);
    279. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    280. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
    281. pi.addItem(Sword);
    282.  
    283. ItemStack Bow = new ItemStack(Material.BOW, 1);
    284. ItemMeta eta = Bow.getItemMeta();
    285. eta.setDisplayName(ChatColor.GOLD + "Basic Bow");
    286. Bow.setItemMeta(eta);
    287. Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    288. Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    289. Bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
    290. pi.addItem(Bow);
    291.  
    292. pi.setHelmet(new ItemStack(Material.IRON_HELMET));
    293. pi.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
    294. pi.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
    295. pi.setBoots(new ItemStack(Material.IRON_BOOTS));
    296.  
    297. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    298. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    299. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    300. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    301.  
    302. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    303. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    304. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    305. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    306.  
    307.  
    308. for(int i = 0; i < 15; i++) {
    309. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    310. }
    311. pi.addItem(new ItemStack(Material.ARROW , 1));
    312. for(int i = 0; i < 18; i++) {
    313. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    314. }
    315.  
    316. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.BLUE + "Basic! " + ChatColor.GRAY + "Its balanced, but yet strong!");
    317. return true;
    318.  
    319. }
    320. }
    321. }
    322. }
    323.  
     
  11. Offline

    sgavster

    FirecatHD
    Code:java
    1. flamethrower.setItemMeta(meta);;
    ???
    Code:java
    1. flamethrower.setItemMeta(meta);
     
    FirecatHD likes this.
  12. Offline

    The_Doctor_123

    FirecatHD
    When you have your editing cursor next to a brace, it will box it and the other one it is related to in gray. Check everything that way.
     
    FirecatHD likes this.
  13. Offline

    L33m4n123


    It might not be 100 % correct but not his issue. You can have something like this and it won't effect the program at all
    Code:java
    1.  
    2. @EventHandler
    3. public void eventMethod(someRandomEvent e) {
    4. ;;;;;;;;;
    5. Location loc = e.getPlayer().getLoc();
    6. }
     
  14. Offline

    FirecatHD

    The_Doctor_123

    So how do i see if it is not linked to an another break?

    The_Doctor_123 and L33m4n123

    i have checked every break now, and there dont seem to be any problems, however.
    On the last break it says: Syntax error, insert "}" to complete ClassBody
    And when i do that all this code:
    Code:java
    1. {
    2.  
    3. //command
    4.  
    5. if (cmd.getName().equalsIgnoreCase("basic")) {
    6.  
    7. }
    8. pi.clear();
    9. pi.setArmorContents(null);
    10.  
    11. for(PotionEffect effect : p.getActivePotionEffects())
    12. {
    13. p.removePotionEffect(effect.getType());
    14. }
    15.  
    16. ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD,1);
    17. ItemMeta meta1 = Sword.getItemMeta();
    18. meta1.setDisplayName(ChatColor.AQUA + "Basic Sword");
    19. Sword.setItemMeta(meta1);
    20. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    21. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
    22. pi.addItem(Sword);
    23.  
    24. ItemStack Bow = new ItemStack(Material.BOW, 1);
    25. ItemMeta eta = Bow.getItemMeta();
    26. eta.setDisplayName(ChatColor.GOLD + "Basic Bow");
    27. Bow.setItemMeta(eta);
    28. Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    29. Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    30. Bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
    31. pi.addItem(Bow);
    32.  
    33. pi.setHelmet(new ItemStack(Material.IRON_HELMET));
    34. pi.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
    35. pi.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
    36. pi.setBoots(new ItemStack(Material.IRON_BOOTS));
    37.  
    38. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    39. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    40. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    41. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    42.  
    43. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    44. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    45. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    46. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    47.  
    48.  
    49. for(int i = 0; i < 15; i++) {
    50. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    51. }
    52. pi.addItem(new ItemStack(Material.ARROW , 1));
    53. for(int i = 0; i < 18; i++) {
    54. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    55. }
    56.  
    57. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.BLUE + "Basic! " + ChatColor.GRAY + "Its balanced, but yet strong!");
    58. return true;
    59.  
    60. }


    becomes unreacable, so i am really stuck on this one :(

    Here is the code as it looks now:
    Code:java
    1. package me.FirecatHD.TBS_PvP;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Color;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.enchantments.Enchantment;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.event.Listener;
    12. import org.bukkit.inventory.ItemStack;
    13. import org.bukkit.inventory.PlayerInventory;
    14. import org.bukkit.inventory.meta.ItemMeta;
    15. import org.bukkit.inventory.meta.LeatherArmorMeta;
    16. import org.bukkit.plugin.java.JavaPlugin;
    17. import org.bukkit.potion.PotionEffect;
    18. import org.bukkit.potion.PotionEffectType;
    19.  
    20. import com.rit.sucy.EnchantmentAPI;
    21.  
    22. public class Kits extends JavaPlugin implements Listener {
    23.  
    24. public void onEnable() {
    25. Bukkit.getServer().getPluginManager().registerEvents(new DeathListener(), this);
    26. }
    27.  
    28. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    29. if (!(sender instanceof Player)) {
    30. sender.sendMessage(ChatColor.RED + "Only players can get kits!");
    31. return true;
    32.  
    33. }
    34.  
    35. Player p = (Player) sender;
    36. PlayerInventory pi = p.getInventory();
    37.  
    38. if (cmd.getName().equalsIgnoreCase("basic")) {
    39.  
    40. pi.clear();
    41. pi.setArmorContents(null);
    42.  
    43. for(PotionEffect effect : p.getActivePotionEffects())
    44. {
    45. p.removePotionEffect(effect.getType());
    46. }
    47.  
    48. ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD,1);
    49. ItemMeta meta = Sword.getItemMeta();
    50. meta.setDisplayName(ChatColor.AQUA + "Basic Sword");
    51. Sword.setItemMeta(meta);
    52. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    53. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
    54. pi.addItem(Sword);
    55.  
    56. ItemStack Bow = new ItemStack(Material.BOW, 1);
    57. ItemMeta meta1 = Bow.getItemMeta();
    58. meta1.setDisplayName(ChatColor.GOLD + "Basic Bow");
    59. Bow.setItemMeta(meta1);
    60. Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    61. Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    62. Bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
    63. pi.addItem(Bow);
    64.  
    65. pi.setHelmet(new ItemStack(Material.IRON_HELMET));
    66. pi.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
    67. pi.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
    68. pi.setBoots(new ItemStack(Material.IRON_BOOTS));
    69.  
    70. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    71. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    72. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    73. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    74.  
    75. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    76. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    77. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    78. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    79.  
    80.  
    81. for(int i = 0; i < 15; i++) {
    82. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    83. }
    84. pi.addItem(new ItemStack(Material.ARROW , 1));
    85. for(int i = 0; i < 18; i++) {
    86. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    87. }
    88.  
    89. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.BLUE + "Basic! " + ChatColor.GRAY + "Its balanced, but yet strong!");
    90. return true;
    91. }
    92. //command
    93.  
    94. if (cmd.getName().equalsIgnoreCase("derpy")) {
    95.  
    96. pi.clear();
    97. pi.setArmorContents(null);
    98.  
    99. for(PotionEffect effect : p.getActivePotionEffects())
    100. {
    101. p.removePotionEffect(effect.getType());
    102. }
    103.  
    104. //Potion effects
    105.  
    106. p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000000, 0));
    107. p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1000000, 2));
    108. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 1));
    109. p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, 1));
    110.  
    111. //Enchantment's
    112.  
    113. ItemStack hay = new ItemStack(Material.WHEAT, 1);
    114. ItemMeta meta = hay.getItemMeta();
    115. meta.setDisplayName(ChatColor.YELLOW + "Hay");
    116. hay.setItemMeta(meta);;
    117. hay.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    118. hay.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 3);
    119. pi.addItem(hay);
    120.  
    121. ItemStack muffin = new ItemStack(Material.CAKE, 1);
    122. ItemMeta meta1 = muffin.getItemMeta();
    123. meta1.setDisplayName(ChatColor.LIGHT_PURPLE + "Muffin");
    124. muffin.setItemMeta(meta1);;
    125. muffin.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    126. EnchantmentAPI.getEnchantment("Dash").addToItem(muffin, 20);
    127. pi.addItem(muffin);
    128.  
    129. //Armour
    130.  
    131. pi.setHelmet(new ItemStack(Material.LEATHER_HELMET));
    132. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    133. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    134. pi.setBoots(new ItemStack(Material.LEATHER_BOOTS));
    135.  
    136. //Armour enchantments
    137.  
    138. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    139. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    140.  
    141. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    142. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    143. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    144. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    145.  
    146. //Leather armour colors
    147. ItemStack Helm = p.getInventory().getHelmet();
    148. LeatherArmorMeta im = (LeatherArmorMeta) Helm.getItemMeta();
    149. im.setColor(Color.fromRGB(255, 248, 148));
    150. Helm.setItemMeta(im);
    151.  
    152. ItemStack Chestplate = p.getInventory().getChestplate();
    153. Chestplate.getItemMeta();
    154. im.setColor(Color.fromRGB(175, 177, 250));
    155. Chestplate.setItemMeta(im);
    156.  
    157. ItemStack Leggings = p.getInventory().getLeggings();
    158. LeatherArmorMeta im1 = (LeatherArmorMeta) Leggings.getItemMeta();
    159. im1.setColor(Color.fromRGB(175, 177, 250));
    160. Leggings.setItemMeta(im1);
    161.  
    162. ItemStack Boots = p.getInventory().getBoots();
    163. Boots.getItemMeta();
    164. im1.setColor(Color.fromRGB(255, 248, 148));
    165. Boots.setItemMeta(im1);
    166.  
    167. //Items
    168.  
    169. for(int i = 0; i < 35; i++) {
    170. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    171. }
    172.  
    173. //On give message
    174.  
    175. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.LIGHT_PURPLE + "Derpy! " + ChatColor.YELLOW + "Your left eye rolls off in another direction while you prepare for battle!");
    176. return true;
    177. }
    178. //command
    179.  
    180. if (cmd.getName().equalsIgnoreCase("pyro")) {
    181.  
    182. }
    183.  
    184. pi.clear();
    185. pi.setArmorContents(null);
    186.  
    187. for(PotionEffect effect : p.getActivePotionEffects())
    188. {
    189. p.removePotionEffect(effect.getType());
    190. }
    191.  
    192. //Potion effects
    193.  
    194. p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 1000000, 2));
    195.  
    196. //Enchantment's
    197.  
    198. ItemStack flamethrower = new ItemStack(Material.BOW, 1);
    199. ItemMeta meta = flamethrower.getItemMeta();
    200. meta.setDisplayName(ChatColor.RED + "Flamethrower");
    201. flamethrower.setItemMeta(meta);;
    202. flamethrower.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    203. flamethrower.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    204. flamethrower.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 3);
    205. pi.addItem(flamethrower);
    206.  
    207. //Armour
    208.  
    209. pi.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
    210. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    211. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    212. pi.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
    213.  
    214. //Armour enchantments
    215.  
    216. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    217. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    218. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    219. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    220.  
    221. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    222. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    223. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    224. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    225.  
    226. //Leather armour colors
    227.  
    228. ItemStack Chestplate = p.getInventory().getChestplate();
    229. LeatherArmorMeta im1 = (LeatherArmorMeta) Chestplate.getItemMeta();
    230. im1.setColor(Color.fromRGB(175, 0, 0));
    231. Chestplate.setItemMeta(im1);
    232.  
    233. ItemStack Leggings = p.getInventory().getLeggings();
    234. LeatherArmorMeta im11 = (LeatherArmorMeta) Leggings.getItemMeta();
    235. im11.setColor(Color.fromRGB(175, 0, 0));
    236. Leggings.setItemMeta(im11);
    237.  
    238. //Items
    239.  
    240. for(int i = 0; i < 16; i++) {
    241. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    242. }
    243. pi.addItem(new ItemStack(Material.ARROW , 1));
    244. for(int i = 0; i < 18; i++) {
    245. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    246. }
    247.  
    248. //On give message
    249.  
    250. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]" + ChatColor.GRAY + ":" + ChatColor.GREEN + "You equipped " + ChatColor.RED + "Pyro! " + ChatColor.GOLD + "Will we ever know what is behind the mask!?");
    251. return true;
    252. {
    253.  
    254. //command
    255.  
    256. if (cmd.getName().equalsIgnoreCase("basic")) {
    257.  
    258. }
    259. pi.clear();
    260. pi.setArmorContents(null);
    261.  
    262. for(PotionEffect effect : p.getActivePotionEffects())
    263. {
    264. p.removePotionEffect(effect.getType());
    265. }
    266.  
    267. ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD,1);
    268. ItemMeta meta1 = Sword.getItemMeta();
    269. meta1.setDisplayName(ChatColor.AQUA + "Basic Sword");
    270. Sword.setItemMeta(meta1);
    271. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    272. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
    273. pi.addItem(Sword);
    274.  
    275. ItemStack Bow = new ItemStack(Material.BOW, 1);
    276. ItemMeta eta = Bow.getItemMeta();
    277. eta.setDisplayName(ChatColor.GOLD + "Basic Bow");
    278. Bow.setItemMeta(eta);
    279. Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    280. Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    281. Bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
    282. pi.addItem(Bow);
    283.  
    284. pi.setHelmet(new ItemStack(Material.IRON_HELMET));
    285. pi.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
    286. pi.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
    287. pi.setBoots(new ItemStack(Material.IRON_BOOTS));
    288.  
    289. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    290. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    291. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    292. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    293.  
    294. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    295. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    296. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    297. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    298.  
    299.  
    300. for(int i = 0; i < 15; i++) {
    301. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    302. }
    303. pi.addItem(new ItemStack(Material.ARROW , 1));
    304. for(int i = 0; i < 18; i++) {
    305. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    306. }
    307.  
    308. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.BLUE + "Basic! " + ChatColor.GRAY + "Its balanced, but yet strong!");
    309. return true;
    310.  
    311. }
    312. }


    Thanks.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  15. Offline

    Chinwe

    Lines 252 - 258:
    Code:
    {
     
    //command
     
    if (cmd.getName().equalsIgnoreCase("basic")) {
     
    }
    You're randomly opening a bracket, and then closing the basic command bracket straight away :confused:
     
    FirecatHD, L33m4n123 and sgavster like this.
  16. Offline

    sgavster

    FirecatHD Okay, I need to teach you a bit about brackets hehe.
    So, lets say we have a basic project:
    Code:java
    1. public class Brackets {
    2.  
    3.  
    4. }


    so, now lets label them:
    Code:java
    1. public class Brackets {//b1
    2.  
    3.  
    4. }//b1


    So if we have a method:

    Code:java
    1. public class Brackets {//b1
    2.  
    3. public void myMethod() {//b2
    4.  
    5. }//b2
    6.  
    7. }//b1


    You need a beginning and an ending. See?
     
  17. Offline

    FirecatHD

    I encourage someone to copy and paste this code in eclipse and solve the error for me ..
    Because i have really tried everything i know, so i dont know what to do :(

    An maybe if you solve it, tell me HOW if you can.

    Thanks.
     
  18. Offline

    Chinwe

    K den, I replaced the random opening brackets, removed the insta command ending brackets, and formatted it all - you can use ctrl+shift+f in eclipse to format it to your liking if you prefer having opening braces on the same line as opposed to the next :)
    Voila (open)

    Code:
    package me.FirecatHD.TBS_PvP;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Color;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.inventory.meta.LeatherArmorMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
     
    public class Kits extends JavaPlugin implements Listener
    {
     
        public void onEnable()
        {
            Bukkit.getServer().getPluginManager().registerEvents(new DeathListener(), this);
        }
     
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
        {
            if (!(sender instanceof Player))
            {
                sender.sendMessage(ChatColor.RED + "Only players can get kits!");
                return true;
            }
     
            Player p = (Player) sender;
            PlayerInventory pi = p.getInventory();
     
            if (cmd.getName().equalsIgnoreCase("basic"))
            {
     
                pi.clear();
                pi.setArmorContents(null);
     
                for (PotionEffect effect : p.getActivePotionEffects())
                {
                    p.removePotionEffect(effect.getType());
                }
     
                ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD, 1);
                ItemMeta meta = Sword.getItemMeta();
                meta.setDisplayName(ChatColor.AQUA + "Basic Sword");
                Sword.setItemMeta(meta);
                Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
                pi.addItem(Sword);
     
                ItemStack Bow = new ItemStack(Material.BOW, 1);
                ItemMeta meta1 = Bow.getItemMeta();
                meta1.setDisplayName(ChatColor.GOLD + "Basic Bow");
                Bow.setItemMeta(meta1);
                Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
                Bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
                pi.addItem(Bow);
     
                pi.setHelmet(new ItemStack(Material.IRON_HELMET));
                pi.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
                pi.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
                pi.setBoots(new ItemStack(Material.IRON_BOOTS));
     
                pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
     
                pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
     
     
                for (int i = 0; i < 15; i++)
                {
                    pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
                }
                pi.addItem(new ItemStack(Material.ARROW, 1));
                for (int i = 0; i < 18; i++)
                {
                    pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
                }
     
                p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.BLUE + "Basic! " + ChatColor.GRAY + "Its balanced, but yet strong!");
                return true;
            }
            //command
     
            if (cmd.getName().equalsIgnoreCase("derpy"))
            {
     
                pi.clear();
                pi.setArmorContents(null);
     
                for (PotionEffect effect : p.getActivePotionEffects())
                {
                    p.removePotionEffect(effect.getType());
                }
     
                //Potion effects
     
                p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000000, 0));
                p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1000000, 2));
                p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 1));
                p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, 1));
     
                //Enchantment's
     
                ItemStack hay = new ItemStack(Material.WHEAT, 1);
                ItemMeta meta = hay.getItemMeta();
                meta.setDisplayName(ChatColor.YELLOW + "Hay");
                hay.setItemMeta(meta);
                ;
                hay.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                hay.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 3);
                pi.addItem(hay);
     
                ItemStack muffin = new ItemStack(Material.CAKE, 1);
                ItemMeta meta1 = muffin.getItemMeta();
                meta1.setDisplayName(ChatColor.LIGHT_PURPLE + "Muffin");
                muffin.setItemMeta(meta1);
                ;
                muffin.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                EnchantmentAPI.getEnchantment("Dash").addToItem(muffin, 20);
                pi.addItem(muffin);
     
                //Armour
     
                pi.setHelmet(new ItemStack(Material.LEATHER_HELMET));
                pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
                pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
                pi.setBoots(new ItemStack(Material.LEATHER_BOOTS));
     
                //Armour enchantments
     
                pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
     
                pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
     
                //Leather armour colors
                ItemStack Helm = p.getInventory().getHelmet();
                LeatherArmorMeta im = (LeatherArmorMeta) Helm.getItemMeta();
                im.setColor(Color.fromRGB(255, 248, 148));
                Helm.setItemMeta(im);
     
                ItemStack Chestplate = p.getInventory().getChestplate();
                Chestplate.getItemMeta();
                im.setColor(Color.fromRGB(175, 177, 250));
                Chestplate.setItemMeta(im);
     
                ItemStack Leggings = p.getInventory().getLeggings();
                LeatherArmorMeta im1 = (LeatherArmorMeta) Leggings.getItemMeta();
                im1.setColor(Color.fromRGB(175, 177, 250));
                Leggings.setItemMeta(im1);
     
                ItemStack Boots = p.getInventory().getBoots();
                Boots.getItemMeta();
                im1.setColor(Color.fromRGB(255, 248, 148));
                Boots.setItemMeta(im1);
     
                //Items
     
                for (int i = 0; i < 35; i++)
                {
                    pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
                }
     
                //On give message
     
                p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.LIGHT_PURPLE + "Derpy! " + ChatColor.YELLOW + "Your left eye rolls off in another direction while you prepare for battle!");
                return true;
            }
            //command
     
            if (cmd.getName().equalsIgnoreCase("pyro"))
            {
     
                pi.clear();
                pi.setArmorContents(null);
     
                for (PotionEffect effect : p.getActivePotionEffects())
                {
                    p.removePotionEffect(effect.getType());
                }
     
                //Potion effects
     
                p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 1000000, 2));
     
                //Enchantment's
     
                ItemStack flamethrower = new ItemStack(Material.BOW, 1);
                ItemMeta meta = flamethrower.getItemMeta();
                meta.setDisplayName(ChatColor.RED + "Flamethrower");
                flamethrower.setItemMeta(meta);
                ;
                flamethrower.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                flamethrower.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
                flamethrower.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 3);
                pi.addItem(flamethrower);
     
                //Armour
     
                pi.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
                pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
                pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
                pi.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
     
                //Armour enchantments
     
                pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
     
                pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
     
                //Leather armour colors
     
                ItemStack Chestplate = p.getInventory().getChestplate();
                LeatherArmorMeta im1 = (LeatherArmorMeta) Chestplate.getItemMeta();
                im1.setColor(Color.fromRGB(175, 0, 0));
                Chestplate.setItemMeta(im1);
     
                ItemStack Leggings = p.getInventory().getLeggings();
                LeatherArmorMeta im11 = (LeatherArmorMeta) Leggings.getItemMeta();
                im11.setColor(Color.fromRGB(175, 0, 0));
                Leggings.setItemMeta(im11);
     
                //Items
     
                for (int i = 0; i < 16; i++)
                {
                    pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
                }
                pi.addItem(new ItemStack(Material.ARROW, 1));
                for (int i = 0; i < 18; i++)
                {
                    pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
                }
     
                //On give message
     
                p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]" + ChatColor.GRAY + ":" + ChatColor.GREEN + "You equipped " + ChatColor.RED + "Pyro! " + ChatColor.GOLD + "Will we ever know what is behind the mask!?");
                return true;
            }
     
            //command
     
            if (cmd.getName().equalsIgnoreCase("basic"))
            {
     
                pi.clear();
                pi.setArmorContents(null);
     
                for (PotionEffect effect : p.getActivePotionEffects())
                {
                    p.removePotionEffect(effect.getType());
                }
     
                ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD, 1);
                ItemMeta meta1 = Sword.getItemMeta();
                meta1.setDisplayName(ChatColor.AQUA + "Basic Sword");
                Sword.setItemMeta(meta1);
                Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
                pi.addItem(Sword);
     
                ItemStack Bow = new ItemStack(Material.BOW, 1);
                ItemMeta eta = Bow.getItemMeta();
                eta.setDisplayName(ChatColor.GOLD + "Basic Bow");
                Bow.setItemMeta(eta);
                Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
                Bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
                pi.addItem(Bow);
     
                pi.setHelmet(new ItemStack(Material.IRON_HELMET));
                pi.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
                pi.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
                pi.setBoots(new ItemStack(Material.IRON_BOOTS));
     
                pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
     
                pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
                pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
     
     
                for (int i = 0; i < 15; i++)
                {
                    pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
                }
                pi.addItem(new ItemStack(Material.ARROW, 1));
                for (int i = 0; i < 18; i++)
                {
                    pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
                }
     
                p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "]: " + ChatColor.GREEN + "You equipped " + ChatColor.BLUE + "Basic! " + ChatColor.GRAY + "Its balanced, but yet strong!");
                return true;
     
            } // basic command end
            return true;
        } // onCommand end brace
    } // class end
     
    FirecatHD likes this.
  19. Offline

    FirecatHD

    Chinwe

    Omg, thanks man !!
    Can you explain exactly what i did wrong? And what you did to fix it :rolleyes:

    Thank you so much!
     
  20. Offline

    Chinwe

    No problem :)
    For a few commands, you closed the brackets straight away, ie:
    Code:
    if(cmd.getName().equalsIgnoreCase("basic")){ 
     
    }
    
    And then I think you used an opening bracket instead of a closing one somewhere :oops:
     
  21. Offline

    FirecatHD

    Thanks Chinwe

    Ok, now i have one question regarding Vault.
    I want to give player £50 for killing a player, but on "econ" it says "econ cannot be resolved"
    problem is that i dont know how to defing something in an eventhandler class :confused:

    I did get it to work in main class.

    Here is my code:
    Code:java
    1. package me.FirecatHD.TBS_PvP;
    2.  
    3. import net.milkbowl.vault.economy.EconomyResponse;
    4.  
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.Sound;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.event.EventHandler;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.event.entity.PlayerDeathEvent;
    11.  
    12. public class DeathListener implements Listener {
    13.  
    14. @EventHandler
    15. public void onDeath(PlayerDeathEvent e) {
    16. Player p = e.getEntity();
    17. if(p.getKiller() instanceof Player) {
    18. Player d = p.getKiller();
    19. {
    20. d.playSound(p.getKiller().getLocation(), Sound.EXPLODE, 5, 1);
    21. d.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "] " + ChatColor.GREEN + "You gor £50 for " + ChatColor.RED + "killing " + ChatColor.GRAY + (p.getName() + ChatColor.GREEN + "!"));
    22. d.getWorld().strikeLightning(p.getLocation());
    23. EconomyResponse r = econ.withdrawPlayer(p.getName(), 50);
    24. }
    25. }
    26. }
    27. }


    Thanks and i hope for help!

    Tags: sgavster Chinwe SkillSam L33m4n123

    Ohh an one quick question.
    How can you make a parent cmd like say i want the parent cmd for "basic" to be "kit" so players had to do /kit basic.

    And can such "parent" cmds have aliases?

    I can imagine they are made like other cmds but like:
    Code:java
    1. if (cmd.getName().equalsIgnoreCase("kit") string){

    Or something like that.

    Here is the whole class:
    Code:java
    1. package me.FirecatHD.TBS_PvP;
    2.  
    3. import net.milkbowl.vault.economy.Economy;
    4. import net.milkbowl.vault.economy.EconomyResponse;
    5.  
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.ChatColor;
    8. import org.bukkit.Color;
    9. import org.bukkit.Material;
    10. import org.bukkit.command.Command;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.enchantments.Enchantment;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.event.Listener;
    15. import org.bukkit.inventory.ItemStack;
    16. import org.bukkit.inventory.PlayerInventory;
    17. import org.bukkit.inventory.meta.ItemMeta;
    18. import org.bukkit.inventory.meta.LeatherArmorMeta;
    19. import org.bukkit.plugin.RegisteredServiceProvider;
    20. import org.bukkit.plugin.java.JavaPlugin;
    21. import org.bukkit.potion.PotionEffect;
    22. import org.bukkit.potion.PotionEffectType;
    23.  
    24. import com.rit.sucy.EnchantmentAPI;
    25.  
    26. public class Kits extends JavaPlugin implements Listener
    27. {
    28.  
    29. public void onEnable()
    30. {
    31. Bukkit.getServer().getPluginManager().registerEvents(new DeathListener(), this);
    32. }
    33.  
    34. public static Economy econ = null;
    35.  
    36. public void onEnable1() {
    37. if (!setupEconomy() ) {
    38. getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
    39. getServer().getPluginManager().disablePlugin(this);
    40. return;
    41. }
    42. }
    43.  
    44. private boolean setupEconomy() {
    45. if (getServer().getPluginManager().getPlugin("Vault") == null) {
    46. return false;
    47. }
    48. RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
    49. if (rsp == null) {
    50. return false;
    51. }
    52. econ = rsp.getProvider();
    53. return econ != null;
    54. }
    55.  
    56. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
    57. {
    58. if (!(sender instanceof Player))
    59. {
    60. sender.sendMessage(ChatColor.RED + "Only players can get kits!");
    61. return true;
    62. }
    63.  
    64. Player p = (Player) sender;
    65. PlayerInventory pi = p.getInventory();
    66.  
    67. if (cmd.getName().equalsIgnoreCase("basic")){
    68.  
    69. EconomyResponse r = econ.withdrawPlayer(p.getName(), 10);
    70. if (r.transactionSuccess()) {
    71.  
    72. pi.clear();
    73. pi.setArmorContents(null);
    74.  
    75. for (PotionEffect effect : p.getActivePotionEffects())
    76. {
    77. p.removePotionEffect(effect.getType());
    78. }
    79.  
    80. ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD, 1);
    81. ItemMeta meta = Sword.getItemMeta();
    82. meta.setDisplayName(ChatColor.AQUA + "Basic Sword");
    83. Sword.setItemMeta(meta);
    84. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    85. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
    86. pi.addItem(Sword);
    87.  
    88. ItemStack Bow = new ItemStack(Material.BOW, 1);
    89. ItemMeta meta1 = Bow.getItemMeta();
    90. meta1.setDisplayName(ChatColor.GOLD + "Basic Bow");
    91. Bow.setItemMeta(meta1);
    92. Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    93. Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    94. Bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
    95. pi.addItem(Bow);
    96.  
    97. pi.setHelmet(new ItemStack(Material.IRON_HELMET));
    98. pi.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
    99. pi.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
    100. pi.setBoots(new ItemStack(Material.IRON_BOOTS));
    101.  
    102. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    103. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    104. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    105. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    106.  
    107. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    108. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    109. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    110. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    111.  
    112.  
    113. for (int i = 0; i < 15; i++)
    114. {
    115. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    116. }
    117. pi.addItem(new ItemStack(Material.ARROW, 1));
    118. for (int i = 0; i < 18; i++)
    119. {
    120. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    121. }
    122.  
    123. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "] " + ChatColor.GREEN + "You equipped " + ChatColor.BLUE + "Basic! " + ChatColor.GRAY + "Its balanced, but yet strong!");
    124. return true;
    125. }
    126.  
    127. else {
    128. p.sendMessage(ChatColor.RED + "You dont have enought money! Go do some parkour =D.");
    129. return true;
    130. }
    131. }
    132. //command
    133.  
    134. if (cmd.getName().equalsIgnoreCase("derpy"))
    135. {
    136.  
    137. pi.clear();
    138. pi.setArmorContents(null);
    139.  
    140. for (PotionEffect effect : p.getActivePotionEffects())
    141. {
    142. p.removePotionEffect(effect.getType());
    143. }
    144.  
    145. //Potion effects
    146.  
    147. p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000000, 0));
    148. p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1000000, 2));
    149. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 1));
    150. p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, 1));
    151.  
    152. //Enchantment's
    153.  
    154. ItemStack hay = new ItemStack(Material.WHEAT, 1);
    155. ItemMeta meta = hay.getItemMeta();
    156. meta.setDisplayName(ChatColor.YELLOW + "Hay");
    157. hay.setItemMeta(meta);
    158. ;
    159. hay.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    160. hay.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 3);
    161. pi.addItem(hay);
    162.  
    163. ItemStack muffin = new ItemStack(Material.CAKE, 1);
    164. ItemMeta meta1 = muffin.getItemMeta();
    165. meta1.setDisplayName(ChatColor.LIGHT_PURPLE + "Muffin");
    166. muffin.setItemMeta(meta1);
    167. ;
    168. muffin.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    169. EnchantmentAPI.getEnchantment("Dash").addToItem(muffin, 20);
    170. pi.addItem(muffin);
    171.  
    172. //Armour
    173.  
    174. pi.setHelmet(new ItemStack(Material.LEATHER_HELMET));
    175. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    176. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    177. pi.setBoots(new ItemStack(Material.LEATHER_BOOTS));
    178.  
    179. //Armour enchantments
    180.  
    181. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    182. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    183.  
    184. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    185. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    186. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    187. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    188.  
    189. //Leather armour colors
    190. ItemStack Helm = p.getInventory().getHelmet();
    191. LeatherArmorMeta im = (LeatherArmorMeta) Helm.getItemMeta();
    192. im.setColor(Color.fromRGB(255, 248, 148));
    193. Helm.setItemMeta(im);
    194.  
    195. ItemStack Chestplate = p.getInventory().getChestplate();
    196. Chestplate.getItemMeta();
    197. im.setColor(Color.fromRGB(175, 177, 250));
    198. Chestplate.setItemMeta(im);
    199.  
    200. ItemStack Leggings = p.getInventory().getLeggings();
    201. LeatherArmorMeta im1 = (LeatherArmorMeta) Leggings.getItemMeta();
    202. im1.setColor(Color.fromRGB(175, 177, 250));
    203. Leggings.setItemMeta(im1);
    204.  
    205. ItemStack Boots = p.getInventory().getBoots();
    206. Boots.getItemMeta();
    207. im1.setColor(Color.fromRGB(255, 248, 148));
    208. Boots.setItemMeta(im1);
    209.  
    210. //Items
    211.  
    212. for (int i = 0; i < 35; i++)
    213. {
    214. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    215. }
    216.  
    217. //On give message
    218.  
    219. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "] " + ChatColor.GREEN + "You equipped " + ChatColor.LIGHT_PURPLE + "Derpy! " + ChatColor.YELLOW + "Your left eye rolls off in another direction while you prepare for battle!");
    220. return true;
    221. }
    222. //command
    223.  
    224. if (cmd.getName().equalsIgnoreCase("pyro"))
    225. {
    226.  
    227. pi.clear();
    228. pi.setArmorContents(null);
    229.  
    230. for (PotionEffect effect : p.getActivePotionEffects())
    231. {
    232. p.removePotionEffect(effect.getType());
    233. }
    234.  
    235. //Potion effects
    236.  
    237. p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 1000000, 2));
    238.  
    239. //Enchantment's
    240.  
    241. ItemStack flamethrower = new ItemStack(Material.BOW, 1);
    242. ItemMeta meta = flamethrower.getItemMeta();
    243. meta.setDisplayName(ChatColor.RED + "Flamethrower");
    244. flamethrower.setItemMeta(meta);
    245. ;
    246. flamethrower.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    247. flamethrower.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    248. flamethrower.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 3);
    249. pi.addItem(flamethrower);
    250.  
    251. //Armour
    252.  
    253. pi.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
    254. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    255. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    256. pi.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
    257.  
    258. //Armour enchantments
    259.  
    260. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    261. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    262. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    263. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    264.  
    265. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    266. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    267. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    268. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    269.  
    270. //Leather armour colors
    271.  
    272. ItemStack Chestplate = p.getInventory().getChestplate();
    273. LeatherArmorMeta im1 = (LeatherArmorMeta) Chestplate.getItemMeta();
    274. im1.setColor(Color.fromRGB(175, 0, 0));
    275. Chestplate.setItemMeta(im1);
    276.  
    277. ItemStack Leggings = p.getInventory().getLeggings();
    278. LeatherArmorMeta im11 = (LeatherArmorMeta) Leggings.getItemMeta();
    279. im11.setColor(Color.fromRGB(175, 0, 0));
    280. Leggings.setItemMeta(im11);
    281.  
    282. //Items
    283.  
    284. for (int i = 0; i < 16; i++)
    285. {
    286. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    287. }
    288. pi.addItem(new ItemStack(Material.ARROW, 1));
    289. for (int i = 0; i < 18; i++)
    290. {
    291. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    292. }
    293.  
    294. //On give message
    295.  
    296. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "] " + ChatColor.GREEN + "You equipped " + ChatColor.RED + "Pyro! " + ChatColor.GOLD + "Will we ever know what is behind the mask!?");
    297. return true;
    298. }
    299.  
    300. //command
    301.  
    302. if (cmd.getName().equalsIgnoreCase("diamondbullet"))
    303. {
    304.  
    305. pi.clear();
    306. pi.setArmorContents(null);
    307.  
    308. for (PotionEffect effect : p.getActivePotionEffects())
    309. {
    310. p.removePotionEffect(effect.getType());
    311. }
    312.  
    313. //Potion effects
    314.  
    315. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 0));
    316. p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 0));
    317.  
    318. //Enchantment's
    319.  
    320. ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD,1);
    321. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    322. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 3);
    323. pi.addItem(Sword);
    324.  
    325.  
    326. ItemStack Bow = new ItemStack(Material.BOW, 1);
    327. Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    328. Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    329. Bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 3);
    330. pi.addItem(Bow);
    331.  
    332. //Armour
    333.  
    334. pi.setHelmet(new ItemStack(Material.DIAMOND_HELMET));
    335. pi.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
    336. pi.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
    337. pi.setBoots(new ItemStack(Material.DIAMOND_BOOTS));
    338.  
    339. //Armour enchantments
    340.  
    341. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    342. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    343. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    344. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    345.  
    346. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    347. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    348. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    349. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    350.  
    351. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 1);
    352. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 1);
    353. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 1);
    354. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 1);
    355.  
    356. pi.getHelmet().addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 2);
    357. pi.getChestplate().addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 2);
    358. pi.getLeggings().addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 2);
    359. pi.getBoots().addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 2);
    360.  
    361. //Items
    362.  
    363. for(int i = 0; i < 4; i++) {
    364. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    365. }
    366. for(int i = 0; i < 3; i++) {
    367. pi.addItem(new ItemStack(Material.MILK_BUCKET, 1));
    368. }
    369. for(int i = 0; i < 8; i++) {
    370. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    371. }
    372. pi.addItem(new ItemStack(Material.ARROW , 1));
    373. for(int i = 0; i < 18; i++) {
    374. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP , 1));
    375. }
    376.  
    377. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "] " + ChatColor.GREEN + "You equipped " + ChatColor.GOLD + "Diamondbullet! " + ChatColor.BLUE + "Prepare for some epic PvP!");
    378.  
    379. return true;
    380.  
    381. }
    382.  
    383. //command
    384.  
    385. if (cmd.getName().equalsIgnoreCase("vampire"))
    386. {
    387.  
    388. pi.clear();
    389. pi.setArmorContents(null);
    390.  
    391. for (PotionEffect effect : p.getActivePotionEffects())
    392. {
    393. p.removePotionEffect(effect.getType());
    394. }
    395.  
    396. //Potion effects
    397.  
    398. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 2));
    399. p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 0));
    400.  
    401. //Enchantment's
    402.  
    403. ItemStack sword = new ItemStack(Material.GHAST_TEAR, 1);
    404. ItemMeta meta = sword.getItemMeta();
    405. meta.setDisplayName(ChatColor.LIGHT_PURPLE + "Vampire Tooth");
    406. sword.setItemMeta(meta);
    407. ;
    408. sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    409. sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 5);
    410. EnchantmentAPI.getEnchantment("lifesteal").addToItem(sword, 3);
    411. pi.addItem(sword);
    412.  
    413. //Armour
    414.  
    415. pi.setHelmet(new ItemStack(Material.LEATHER_HELMET));
    416. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    417. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    418. pi.setBoots(new ItemStack(Material.LEATHER_BOOTS));
    419.  
    420. //Armour enchantments
    421.  
    422. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    423. pi.getChestplate().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    424. pi.getLeggings().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    425. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    426.  
    427. //Leather armour colors
    428. ItemStack Helm = p.getInventory().getHelmet();
    429. LeatherArmorMeta im = (LeatherArmorMeta) Helm.getItemMeta();
    430. im.setColor(Color.fromRGB(255, 255, 255));
    431. Helm.setItemMeta(im);
    432.  
    433. ItemStack Chestplate = p.getInventory().getChestplate();
    434. Chestplate.getItemMeta();
    435. im.setColor(Color.fromRGB(175, 0, 0));
    436. Chestplate.setItemMeta(im);
    437.  
    438. ItemStack Leggings = p.getInventory().getLeggings();
    439. LeatherArmorMeta im1 = (LeatherArmorMeta) Leggings.getItemMeta();
    440. im1.setColor(Color.fromRGB(43, 36, 36));
    441. Leggings.setItemMeta(im1);
    442.  
    443. ItemStack Boots = p.getInventory().getBoots();
    444. Boots.getItemMeta();
    445. im1.setColor(Color.fromRGB(43, 36, 36));
    446. Boots.setItemMeta(im1);
    447.  
    448. //On give message
    449.  
    450. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED + "TBS PvP" + ChatColor.BLACK + "] " + ChatColor.GREEN + "You equipped " + ChatColor.BLACK + "Vampire! " + ChatColor.WHITE + "Drink others blood to heal yourself!");
    451.  
    452. return true;
    453.  
    454. } // basic command end
    455. return true;
    456. }
    457. }
    458.  


    Thanks.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  22. Offline

    Chinwe

    Where is 'econ' defined ? In your main class ? One way you could do it is:

    Code:
    // in main class
    private static Economy econ = whatever; // guessing its type is Economy
     
    public static Economy getEconomy()
    {
          return econ;
    }
     
    // in DeathListener
    Economy econ = MainClass.getEconomy();

    For subcommands, you only need to register the main "supercommand" ie 'kits'. Then you can check their arguments:

    Code:
    if (cmd.getName().equalsIgnoreCase("kits"))
    {
        if (args.length == 1)
        {
            if (args[0].equalsIgnoreCase("subcommand"))
            { ... }
           
            else if (args[0].equalsIgnorecase("anothersubcommand"))
            { ... }
     
     
        }
     
     
    }
     
  23. Offline

    FirecatHD

    Chinwe

    Sorry for noob question but where do i place this code:
    Code:java
    1. // in main class
    2. private static Economy econ = whatever; // guessing its type is Economy
    3.  
    4. public static Economy getEconomy()
    5. {
    6. return econ;
    7. }
    8.  
    9. // in DeathListener
    10. Economy econ = MainClass.getEconomy();


    ?

    ohh nevermind i think i figured it out

    Chinwe

    I messed up on the in main class part can u place it in there for me?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  24. Offline

    sgavster

    FirecatHD Don't double/tripple post. Edit your first post.
     
  25. Offline

    Chinwe

    Just put it in your main class, not inside any methods:

    Code:
    package blah blah;
     
    import blah blah;
     
    public class Kits
    {
        // can go here
       
        public void onEnable() { ... }
     
        // could go here 
     
     
     
    }
     
  26. Offline

    FirecatHD

    sgavster
    Ok, sorry i will do that nex time :oops:

    Chinwe
    When i put it there i have to rename the "econ" to "econ1" :confused:
    Also the MainClass.getEconomy (in DeathListener) wont work

    And where you say //Whatever, do i have to say getEconomy there? I get an error if i dont...

    And again i am sorry for asking so much :(
     
  27. Offline

    FirecatHD

    I am having problems with vault here...
    It comes up with a NPE and i dont know how to fix it.

    So can anyone see what i have done wrong?

    Code:
    Code:java
    1. package me.FirecatHD.TBS_PvP;
    2.  
    3. import net.milkbowl.vault.economy.Economy;
    4. import net.milkbowl.vault.economy.EconomyResponse;
    5.  
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.ChatColor;
    8. import org.bukkit.Color;
    9. import org.bukkit.Material;
    10. import org.bukkit.command.Command;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.enchantments.Enchantment;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.event.Listener;
    15. import org.bukkit.inventory.ItemStack;
    16. import org.bukkit.inventory.PlayerInventory;
    17. import org.bukkit.inventory.meta.ItemMeta;
    18. import org.bukkit.inventory.meta.LeatherArmorMeta;
    19. import org.bukkit.plugin.RegisteredServiceProvider;
    20. import org.bukkit.plugin.java.JavaPlugin;
    21. import org.bukkit.potion.PotionEffect;
    22. import org.bukkit.potion.PotionEffectType;
    23.  
    24. import com.rit.sucy.EnchantmentAPI;
    25.  
    26. public class Kits extends JavaPlugin implements Listener {
    27.  
    28. public void onEnable() {
    29. Bukkit.getServer().getPluginManager()
    30. .registerEvents(new DeathListener(), this);
    31. }
    32.  
    33. public static Economy econ = null;
    34.  
    35. public void onEnable1() {
    36. if (!setupEconomy() ) {
    37. getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
    38. getServer().getPluginManager().disablePlugin(this);
    39. return;
    40. }
    41. }
    42.  
    43. private boolean setupEconomy() {
    44. if (getServer().getPluginManager().getPlugin("Vault") == null) {
    45. return false;
    46. }
    47. RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
    48. if (rsp == null) {
    49. return false;
    50. }
    51. econ = rsp.getProvider();
    52. return econ != null;
    53. }
    54.  
    55. public boolean onCommand(CommandSender sender, Command cmd,
    56. String commandLabel, String[] args) {
    57. if (!(sender instanceof Player)) {
    58. sender.sendMessage(ChatColor.RED + "Only players can get kits!");
    59. return true;
    60. }
    61.  
    62. Player p = (Player) sender;
    63. PlayerInventory pi = p.getInventory();
    64.  
    65. if (cmd.getName().equalsIgnoreCase("tbspvp")) {
    66. if (args.length == 1) {
    67. if (args[0].equalsIgnoreCase("basic")) {
    68.  
    69. EconomyResponse r = econ.withdrawPlayer(getName(), 50);
    70. if (r.transactionSuccess()) {
    71.  
    72. pi.clear();
    73. pi.setArmorContents(null);
    74.  
    75. for (PotionEffect effect : p.getActivePotionEffects()) {
    76. p.removePotionEffect(effect.getType());
    77. }
    78.  
    79. ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD, 1);
    80. ItemMeta meta = Sword.getItemMeta();
    81. meta.setDisplayName(ChatColor.AQUA + "Basic Sword");
    82. Sword.setItemMeta(meta);
    83. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    84. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
    85. pi.addItem(Sword);
    86.  
    87. ItemStack Bow = new ItemStack(Material.BOW, 1);
    88. ItemMeta meta1 = Bow.getItemMeta();
    89. meta1.setDisplayName(ChatColor.GOLD + "Basic Bow");
    90. Bow.setItemMeta(meta1);
    91. Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    92. Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    93. Bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
    94. pi.addItem(Bow);
    95.  
    96. pi.setHelmet(new ItemStack(Material.IRON_HELMET));
    97. pi.setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
    98. pi.setLeggings(new ItemStack(Material.IRON_LEGGINGS));
    99. pi.setBoots(new ItemStack(Material.IRON_BOOTS));
    100.  
    101. pi.getHelmet().addUnsafeEnchantment(
    102. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    103. pi.getChestplate().addUnsafeEnchantment(
    104. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    105. pi.getLeggings().addUnsafeEnchantment(
    106. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    107. pi.getBoots().addUnsafeEnchantment(
    108. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    109.  
    110. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY,
    111. 1000);
    112. pi.getChestplate().addUnsafeEnchantment(
    113. Enchantment.DURABILITY, 1000);
    114. pi.getLeggings().addUnsafeEnchantment(
    115. Enchantment.DURABILITY, 1000);
    116. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY,
    117. 1000);
    118.  
    119. for (int i = 0; i < 15; i++) {
    120. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    121. }
    122. pi.addItem(new ItemStack(Material.ARROW, 1));
    123. for (int i = 0; i < 18; i++) {
    124. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    125. }
    126.  
    127. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED
    128. + "TBS PvP" + ChatColor.BLACK + "] "
    129. + ChatColor.GREEN + "You equipped "
    130. + ChatColor.BLUE + "Basic! " + ChatColor.GRAY
    131. + "Its balanced, but yet strong!");
    132. return true;
    133. }
    134. else
    135.  
    136. {
    137. p.sendMessage(ChatColor.RED + "You cannot get a kit at this time.");
    138. return true;
    139. }
    140. }
    141.  
    142. // command
    143.  
    144. if (args[0].equalsIgnoreCase("derpy")) {
    145.  
    146. pi.clear();
    147. pi.setArmorContents(null);
    148.  
    149. for (PotionEffect effect : p.getActivePotionEffects()) {
    150. p.removePotionEffect(effect.getType());
    151. }
    152.  
    153. // Potion effects
    154.  
    155. p.addPotionEffect(new PotionEffect(
    156. PotionEffectType.CONFUSION, 1000000, 0));
    157. p.addPotionEffect(new PotionEffect(
    158. PotionEffectType.INCREASE_DAMAGE, 1000000, 2));
    159. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
    160. 1000000, 1));
    161. p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,
    162. 1000000, 1));
    163.  
    164. // Enchantment's
    165.  
    166. ItemStack hay = new ItemStack(Material.WHEAT, 1);
    167. ItemMeta meta = hay.getItemMeta();
    168. meta.setDisplayName(ChatColor.YELLOW + "Hay");
    169. hay.setItemMeta(meta);
    170. ;
    171. hay.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    172. hay.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 3);
    173. pi.addItem(hay);
    174.  
    175. ItemStack muffin = new ItemStack(Material.CAKE, 1);
    176. ItemMeta meta1 = muffin.getItemMeta();
    177. meta1.setDisplayName(ChatColor.LIGHT_PURPLE + "Muffin");
    178. muffin.setItemMeta(meta1);
    179. ;
    180. muffin.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    181. EnchantmentAPI.getEnchantment("Dash").addToItem(muffin, 20);
    182. pi.addItem(muffin);
    183.  
    184. // Armour
    185.  
    186. pi.setHelmet(new ItemStack(Material.LEATHER_HELMET));
    187. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    188. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    189. pi.setBoots(new ItemStack(Material.LEATHER_BOOTS));
    190.  
    191. // Armour enchantments
    192.  
    193. pi.getChestplate().addUnsafeEnchantment(
    194. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    195. pi.getLeggings().addUnsafeEnchantment(
    196. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    197.  
    198. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY,
    199. 1000);
    200. pi.getChestplate().addUnsafeEnchantment(
    201. Enchantment.DURABILITY, 1000);
    202. pi.getLeggings().addUnsafeEnchantment(
    203. Enchantment.DURABILITY, 1000);
    204. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY,
    205. 1000);
    206.  
    207. // Leather armour colors
    208. ItemStack Helm = p.getInventory().getHelmet();
    209. LeatherArmorMeta im = (LeatherArmorMeta) Helm.getItemMeta();
    210. im.setColor(Color.fromRGB(255, 248, 148));
    211. Helm.setItemMeta(im);
    212.  
    213. ItemStack Chestplate = p.getInventory().getChestplate();
    214. Chestplate.getItemMeta();
    215. im.setColor(Color.fromRGB(175, 177, 250));
    216. Chestplate.setItemMeta(im);
    217.  
    218. ItemStack Leggings = p.getInventory().getLeggings();
    219. LeatherArmorMeta im1 = (LeatherArmorMeta) Leggings
    220. .getItemMeta();
    221. im1.setColor(Color.fromRGB(175, 177, 250));
    222. Leggings.setItemMeta(im1);
    223.  
    224. ItemStack Boots = p.getInventory().getBoots();
    225. Boots.getItemMeta();
    226. im1.setColor(Color.fromRGB(255, 248, 148));
    227. Boots.setItemMeta(im1);
    228.  
    229. // Items
    230.  
    231. for (int i = 0; i < 35; i++) {
    232. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    233. }
    234.  
    235. // On give message
    236.  
    237. p.sendMessage(ChatColor.BLACK
    238. + "["
    239. + ChatColor.DARK_RED
    240. + "TBS PvP"
    241. + ChatColor.BLACK
    242. + "] "
    243. + ChatColor.GREEN
    244. + "You equipped "
    245. + ChatColor.LIGHT_PURPLE
    246. + "Derpy! "
    247. + ChatColor.YELLOW
    248. + "Your left eye rolls off in another direction while you prepare for battle!");
    249. return true;
    250. }
    251. // command
    252.  
    253. if (args[0].equalsIgnoreCase("pyro")) {
    254.  
    255. pi.clear();
    256. pi.setArmorContents(null);
    257.  
    258. for (PotionEffect effect : p.getActivePotionEffects()) {
    259. p.removePotionEffect(effect.getType());
    260. }
    261.  
    262. // Potion effects
    263.  
    264. p.addPotionEffect(new PotionEffect(
    265. PotionEffectType.FIRE_RESISTANCE, 1000000, 2));
    266.  
    267. // Enchantment's
    268.  
    269. ItemStack flamethrower = new ItemStack(Material.BOW, 1);
    270. ItemMeta meta = flamethrower.getItemMeta();
    271. meta.setDisplayName(ChatColor.RED + "Flamethrower");
    272. flamethrower.setItemMeta(meta);
    273. ;
    274. flamethrower.addUnsafeEnchantment(Enchantment.DURABILITY,
    275. 1000);
    276. flamethrower.addUnsafeEnchantment(
    277. Enchantment.ARROW_INFINITE, 1000);
    278. flamethrower
    279. .addUnsafeEnchantment(Enchantment.ARROW_FIRE, 3);
    280. pi.addItem(flamethrower);
    281.  
    282. // Armour
    283.  
    284. pi.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
    285. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    286. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    287. pi.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
    288.  
    289. // Armour enchantments
    290.  
    291. pi.getHelmet().addUnsafeEnchantment(
    292. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    293. pi.getChestplate().addUnsafeEnchantment(
    294. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    295. pi.getLeggings().addUnsafeEnchantment(
    296. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    297. pi.getBoots().addUnsafeEnchantment(
    298. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    299.  
    300. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY,
    301. 1000);
    302. pi.getChestplate().addUnsafeEnchantment(
    303. Enchantment.DURABILITY, 1000);
    304. pi.getLeggings().addUnsafeEnchantment(
    305. Enchantment.DURABILITY, 1000);
    306. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY,
    307. 1000);
    308.  
    309. // Leather armour colors
    310.  
    311. ItemStack Chestplate = p.getInventory().getChestplate();
    312. LeatherArmorMeta im1 = (LeatherArmorMeta) Chestplate
    313. .getItemMeta();
    314. im1.setColor(Color.fromRGB(175, 0, 0));
    315. Chestplate.setItemMeta(im1);
    316.  
    317. ItemStack Leggings = p.getInventory().getLeggings();
    318. LeatherArmorMeta im11 = (LeatherArmorMeta) Leggings
    319. .getItemMeta();
    320. im11.setColor(Color.fromRGB(175, 0, 0));
    321. Leggings.setItemMeta(im11);
    322.  
    323. // Items
    324.  
    325. for (int i = 0; i < 16; i++) {
    326. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    327. }
    328. pi.addItem(new ItemStack(Material.ARROW, 1));
    329. for (int i = 0; i < 18; i++) {
    330. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    331. }
    332.  
    333. // On give message
    334.  
    335. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED
    336. + "TBS PvP" + ChatColor.BLACK + "] "
    337. + ChatColor.GREEN + "You equipped " + ChatColor.RED
    338. + "Pyro! " + ChatColor.GOLD
    339. + "Will we ever know what is behind the mask!?");
    340. return true;
    341. }
    342.  
    343. // command
    344.  
    345. if (args[0].equalsIgnoreCase("diamondbullet")) {
    346.  
    347. pi.clear();
    348. pi.setArmorContents(null);
    349.  
    350. for (PotionEffect effect : p.getActivePotionEffects()) {
    351. p.removePotionEffect(effect.getType());
    352. }
    353.  
    354. // Potion effects
    355.  
    356. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
    357. 1000000, 0));
    358. p.addPotionEffect(new PotionEffect(
    359. PotionEffectType.NIGHT_VISION, 1000000, 0));
    360.  
    361. // Enchantment's
    362.  
    363. ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD, 1);
    364. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    365. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 3);
    366. pi.addItem(Sword);
    367.  
    368. ItemStack Bow = new ItemStack(Material.BOW, 1);
    369. Bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    370. Bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    371. Bow.addUnsafeEnchantment(Enchantment.ARROW_KNOCKBACK, 3);
    372. pi.addItem(Bow);
    373.  
    374. // Armour
    375.  
    376. pi.setHelmet(new ItemStack(Material.DIAMOND_HELMET));
    377. pi.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
    378. pi.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
    379. pi.setBoots(new ItemStack(Material.DIAMOND_BOOTS));
    380.  
    381. // Armour enchantments
    382.  
    383. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY,
    384. 1000);
    385. pi.getChestplate().addUnsafeEnchantment(
    386. Enchantment.DURABILITY, 1000);
    387. pi.getLeggings().addUnsafeEnchantment(
    388. Enchantment.DURABILITY, 1000);
    389. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY,
    390. 1000);
    391.  
    392. pi.getHelmet().addUnsafeEnchantment(
    393. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    394. pi.getChestplate().addUnsafeEnchantment(
    395. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    396. pi.getLeggings().addUnsafeEnchantment(
    397. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    398. pi.getBoots().addUnsafeEnchantment(
    399. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    400.  
    401. pi.getHelmet().addUnsafeEnchantment(
    402. Enchantment.PROTECTION_FIRE, 1);
    403. pi.getChestplate().addUnsafeEnchantment(
    404. Enchantment.PROTECTION_FIRE, 1);
    405. pi.getLeggings().addUnsafeEnchantment(
    406. Enchantment.PROTECTION_FIRE, 1);
    407. pi.getBoots().addUnsafeEnchantment(
    408. Enchantment.PROTECTION_FIRE, 1);
    409.  
    410. pi.getHelmet().addUnsafeEnchantment(
    411. Enchantment.PROTECTION_EXPLOSIONS, 2);
    412. pi.getChestplate().addUnsafeEnchantment(
    413. Enchantment.PROTECTION_EXPLOSIONS, 2);
    414. pi.getLeggings().addUnsafeEnchantment(
    415. Enchantment.PROTECTION_EXPLOSIONS, 2);
    416. pi.getBoots().addUnsafeEnchantment(
    417. Enchantment.PROTECTION_EXPLOSIONS, 2);
    418.  
    419. // Items
    420.  
    421. for (int i = 0; i < 4; i++) {
    422. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    423. }
    424. for (int i = 0; i < 3; i++) {
    425. pi.addItem(new ItemStack(Material.MILK_BUCKET, 1));
    426. }
    427. for (int i = 0; i < 8; i++) {
    428. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    429. }
    430. pi.addItem(new ItemStack(Material.ARROW, 1));
    431. for (int i = 0; i < 18; i++) {
    432. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    433. }
    434.  
    435. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED
    436. + "TBS PvP" + ChatColor.BLACK + "] "
    437. + ChatColor.GREEN + "You equipped "
    438. + ChatColor.GOLD + "Diamondbullet! "
    439. + ChatColor.BLUE + "Prepare for some epic PvP!");
    440.  
    441. return true;
    442.  
    443. }
    444.  
    445. // command
    446.  
    447. if (args[0].equalsIgnoreCase("vampire")) {
    448.  
    449. pi.clear();
    450. pi.setArmorContents(null);
    451.  
    452. for (PotionEffect effect : p.getActivePotionEffects()) {
    453. p.removePotionEffect(effect.getType());
    454. }
    455.  
    456. // Potion effects
    457.  
    458. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
    459. 1000000, 2));
    460. p.addPotionEffect(new PotionEffect(
    461. PotionEffectType.NIGHT_VISION, 1000000, 0));
    462.  
    463. // Enchantment's
    464.  
    465. ItemStack sword = new ItemStack(Material.GHAST_TEAR, 1);
    466. ItemMeta meta = sword.getItemMeta();
    467. meta.setDisplayName(ChatColor.LIGHT_PURPLE
    468. + "Vampire Tooth");
    469. sword.setItemMeta(meta);
    470. ;
    471. sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    472. sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 5);
    473. EnchantmentAPI.getEnchantment("lifesteal").addToItem(sword,
    474. 10);
    475. pi.addItem(sword);
    476.  
    477. // Armour
    478.  
    479. pi.setHelmet(new ItemStack(Material.LEATHER_HELMET));
    480. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    481. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    482. pi.setBoots(new ItemStack(Material.LEATHER_BOOTS));
    483.  
    484. // Armour enchantments
    485.  
    486. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY,
    487. 1000);
    488. pi.getChestplate().addUnsafeEnchantment(
    489. Enchantment.DURABILITY, 1000);
    490. pi.getLeggings().addUnsafeEnchantment(
    491. Enchantment.DURABILITY, 1000);
    492. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY,
    493. 1000);
    494.  
    495. // Leather armour colors
    496. ItemStack Helm = p.getInventory().getHelmet();
    497. LeatherArmorMeta im = (LeatherArmorMeta) Helm.getItemMeta();
    498. im.setColor(Color.fromRGB(255, 255, 255));
    499. Helm.setItemMeta(im);
    500.  
    501. ItemStack Chestplate = p.getInventory().getChestplate();
    502. Chestplate.getItemMeta();
    503. im.setColor(Color.fromRGB(175, 0, 0));
    504. Chestplate.setItemMeta(im);
    505.  
    506. ItemStack Leggings = p.getInventory().getLeggings();
    507. LeatherArmorMeta im1 = (LeatherArmorMeta) Leggings
    508. .getItemMeta();
    509. im1.setColor(Color.fromRGB(43, 36, 36));
    510. Leggings.setItemMeta(im1);
    511.  
    512. ItemStack Boots = p.getInventory().getBoots();
    513. Boots.getItemMeta();
    514. im1.setColor(Color.fromRGB(43, 36, 36));
    515. Boots.setItemMeta(im1);
    516.  
    517. // On give message
    518.  
    519. p.sendMessage(ChatColor.BLACK + "[" + ChatColor.DARK_RED
    520. + "TBS PvP" + ChatColor.BLACK + "] "
    521. + ChatColor.GREEN + "You equipped "
    522. + ChatColor.BLACK + "Vampire! " + ChatColor.WHITE
    523. + "Drink others blood to heal yourself!");
    524.  
    525. return true;
    526.  
    527. }
    528.  
    529. if (args[0].equalsIgnoreCase("archer")) {
    530.  
    531. pi.clear();
    532. pi.setArmorContents(null);
    533.  
    534. for (PotionEffect effect : p.getActivePotionEffects()) {
    535. p.removePotionEffect(effect.getType());
    536. }
    537.  
    538. // Potion effects
    539.  
    540. p.addPotionEffect(new PotionEffect(
    541. PotionEffectType.NIGHT_VISION, 1000000, 0));
    542. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
    543. 1000000, 0));
    544. p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,
    545. 1000000, 0));
    546.  
    547. // Enchantment's
    548.  
    549. ItemStack bow = new ItemStack(Material.BOW, 1);
    550. ItemMeta meta = bow.getItemMeta();
    551. meta.setDisplayName(ChatColor.DARK_GREEN + "Trusty Bow");
    552. bow.setItemMeta(meta);
    553. ;
    554. bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    555. bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    556. bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 5);
    557. pi.addItem(bow);
    558.  
    559. // Armour
    560.  
    561. pi.setHelmet(new ItemStack(Material.LEATHER_HELMET));
    562. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    563. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    564. pi.setBoots(new ItemStack(Material.LEATHER_BOOTS));
    565.  
    566. // Armour enchantments
    567.  
    568. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY,
    569. 1000);
    570. pi.getChestplate().addUnsafeEnchantment(
    571. Enchantment.DURABILITY, 1000);
    572. pi.getLeggings().addUnsafeEnchantment(
    573. Enchantment.DURABILITY, 1000);
    574. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY,
    575. 1000);
    576.  
    577. // Leather armour colors
    578. ItemStack Helm = p.getInventory().getHelmet();
    579. LeatherArmorMeta im = (LeatherArmorMeta) Helm.getItemMeta();
    580. im.setColor(Color.fromRGB(34, 38, 38));
    581. Helm.setItemMeta(im);
    582.  
    583. ItemStack Chestplate = p.getInventory().getChestplate();
    584. Chestplate.getItemMeta();
    585. im.setColor(Color.fromRGB(0, 255, 0));
    586. Chestplate.setItemMeta(im);
    587.  
    588. ItemStack Leggings = p.getInventory().getLeggings();
    589. LeatherArmorMeta im1 = (LeatherArmorMeta) Leggings
    590. .getItemMeta();
    591. im1.setColor(Color.fromRGB(0, 255, 0));
    592. Leggings.setItemMeta(im1);
    593.  
    594. ItemStack Boots = p.getInventory().getBoots();
    595. Boots.getItemMeta();
    596. im1.setColor(Color.fromRGB(20, 145, 29));
    597. Boots.setItemMeta(im1);
    598.  
    599. // Items
    600.  
    601. for (int i = 0; i < 15; i++) {
    602. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    603. }
    604. pi.addItem(new ItemStack(Material.ARROW, 1));
    605. for (int i = 0; i < 18; i++) {
    606. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    607. }
    608.  
    609. // On give message
    610.  
    611. p.sendMessage(ChatColor.BLACK
    612. + "["
    613. + ChatColor.DARK_RED
    614. + "TBS PvP"
    615. + ChatColor.BLACK
    616. + "] "
    617. + ChatColor.GREEN
    618. + "You equipped "
    619. + ChatColor.GREEN
    620. + "Archer! "
    621. + ChatColor.DARK_GRAY
    622. + "With your good aim and bow, attack from far away!");
    623.  
    624. return true;
    625.  
    626. }
    627.  
    628. if (args[0].equalsIgnoreCase("swordsman")) {
    629.  
    630. pi.clear();
    631. pi.setArmorContents(null);
    632.  
    633. for (PotionEffect effect : p.getActivePotionEffects()) {
    634. p.removePotionEffect(effect.getType());
    635. }
    636.  
    637. // Potion effects
    638.  
    639. p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,
    640. 1000000, 0));
    641. p.addPotionEffect(new PotionEffect(
    642. PotionEffectType.BLINDNESS, 1000000, 0));
    643.  
    644. // Enchantment's
    645.  
    646. ItemStack Sword = new ItemStack(Material.IRON_SWORD, 1);
    647. ItemMeta meta = Sword.getItemMeta();
    648. meta.setDisplayName(ChatColor.DARK_GRAY + "Trusty Sword");
    649. Sword.setItemMeta(meta);
    650.  
    651. Sword.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    652. Sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 8);
    653. pi.addItem(Sword);
    654.  
    655. // Armour
    656.  
    657. pi.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
    658. pi.setChestplate(new ItemStack(
    659. Material.CHAINMAIL_CHESTPLATE));
    660. pi.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
    661. pi.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
    662.  
    663. // Armour enchantments
    664.  
    665. pi.getChestplate().addUnsafeEnchantment(
    666. Enchantment.PROTECTION_ENVIRONMENTAL, 3);
    667. pi.getLeggings().addUnsafeEnchantment(
    668. Enchantment.PROTECTION_ENVIRONMENTAL, 3);
    669. pi.getBoots().addUnsafeEnchantment(
    670. Enchantment.PROTECTION_ENVIRONMENTAL, 3);
    671. pi.getHelmet().addUnsafeEnchantment(
    672. Enchantment.PROTECTION_ENVIRONMENTAL, 3);
    673.  
    674. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY,
    675. 1000);
    676. pi.getChestplate().addUnsafeEnchantment(
    677. Enchantment.DURABILITY, 1000);
    678. pi.getLeggings().addUnsafeEnchantment(
    679. Enchantment.DURABILITY, 1000);
    680. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY,
    681. 1000);
    682.  
    683. // Items
    684.  
    685. for (int i = 0; i < 36; i++) {
    686. pi.addItem(new ItemStack(Material.MUSHROOM_SOUP, 1));
    687. }
    688.  
    689. // On give message
    690.  
    691. p.sendMessage(ChatColor.BLACK
    692. + "["
    693. + ChatColor.DARK_RED
    694. + "TBS PvP"
    695. + ChatColor.BLACK
    696. + "] "
    697. + ChatColor.GREEN
    698. + "You equipped "
    699. + ChatColor.DARK_AQUA
    700. + "Swordsman! "
    701. + ChatColor.DARK_GRAY
    702. + "You have heavy armour and poor sight, but a lot of strength!");
    703. return true;
    704. }
    705. // command
    706.  
    707. if (args[0].equalsIgnoreCase("m00n")) {
    708.  
    709. pi.clear();
    710. pi.setArmorContents(null);
    711.  
    712. for (PotionEffect effect : p.getActivePotionEffects()) {
    713. p.removePotionEffect(effect.getType());
    714. }
    715.  
    716. // Enchantment's
    717.  
    718. ItemStack bow = new ItemStack(Material.BOW, 1);
    719. ItemMeta meta = bow.getItemMeta();
    720. meta.setDisplayName(ChatColor.DARK_PURPLE + "Space Gun");
    721. bow.setItemMeta(meta);
    722. bow.addUnsafeEnchantment(Enchantment.DURABILITY, 1000);
    723. bow.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1000);
    724. bow.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1000);
    725. pi.addItem(bow);
    726.  
    727. ItemStack arrow = new ItemStack(Material.ARROW, 1);
    728. ItemMeta meta1 = arrow.getItemMeta();
    729. meta1.setDisplayName(ChatColor.DARK_GREEN + "Space Gun Ammo");
    730. arrow.setItemMeta(meta1);
    731. pi.addItem(arrow);
    732.  
    733. // Armour
    734.  
    735. pi.setHelmet(new ItemStack(Material.LEATHER_HELMET));
    736. pi.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    737. pi.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    738. pi.setBoots(new ItemStack(Material.LEATHER_BOOTS));
    739.  
    740. // Armour enchantments
    741.  
    742. pi.getHelmet().addUnsafeEnchantment(Enchantment.DURABILITY,
    743. 1000);
    744. pi.getChestplate().addUnsafeEnchantment(
    745. Enchantment.DURABILITY, 1000);
    746. pi.getLeggings().addUnsafeEnchantment(
    747. Enchantment.DURABILITY, 1000);
    748. pi.getBoots().addUnsafeEnchantment(Enchantment.DURABILITY,
    749. 1000);
    750.  
    751. // Leather armour colors
    752. ItemStack Helm = p.getInventory().getHelmet();
    753. LeatherArmorMeta im = (LeatherArmorMeta) Helm.getItemMeta();
    754. im.setColor(Color.fromRGB(0, 0, 0));
    755. Helm.setItemMeta(im);
    756.  
    757. ItemStack Chestplate = p.getInventory().getChestplate();
    758. Chestplate.getItemMeta();
    759. im.setColor(Color.fromRGB(255, 255, 255));
    760. Chestplate.setItemMeta(im);
    761.  
    762. ItemStack Leggings = p.getInventory().getLeggings();
    763. Leggings.getItemMeta();
    764. im.setColor(Color.fromRGB(255, 255, 255));
    765. Leggings.setItemMeta(im);
    766.  
    767. ItemStack Boots = p.getInventory().getBoots();
    768. Boots.getItemMeta();
    769. im.setColor(Color.fromRGB(194, 194, 194));
    770. Boots.setItemMeta(im);
    771.  
    772. // On give message
    773.  
    774. p.sendMessage(ChatColor.BLACK
    775. + "["
    776. + ChatColor.DARK_RED
    777. + "TBS PvP"
    778. + ChatColor.BLACK
    779. + "] "
    780. + ChatColor.GREEN
    781. + "You equipped "
    782. + ChatColor.BLUE
    783. + "M00n! "
    784. + ChatColor.RED
    785. + "ManOnTheM00ns likes to spawn in items in PvP, so i had to make a kit... "
    786. + ChatColor.YELLOW + "-FirecatHD");
    787. return true;
    788. }
    789.  
    790. }
    791. }
    792.  
    793. return true;
    794. }
    795. }
    796.  


    Thanks.

    Tags: sgavster L33m4n123 SkillSam Chinwe

    SkillSam
    I don know what i am supposed to put there, can you tell me?
    Ohh and the to onEnable() metohods is because i have a @EventHandeler class that had to be registrered.
    Also if you see some VERY unefficient code, tell me ;)

    Thanks.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  28. Offline

    L33m4n123

    Put the code of the onEnables both into ONE onEnable() Method. No need to make it two even though you are registering Events from different classes

    Oh and mind telling me where the NPE is? Never worked with Vault and do not want to work through all of your code just to see where the NPE might be
     
  29. Offline

    FirecatHD

    L33m4n123
    Ok i put both onEnable methods in one, and now it acually works!
    Thanks man!!
     
  30. Offline

    FirecatHD

    Ok, i have a question here:
    I want the exploding snowball eventhandeler ONLY to work if the player types /kit fragger i guess it is an if statement, but i am not sure how to do it, or if it is even possible.

    I hope someone understand what i mean.

    The Listener:
    Code:java
    1. package me.FirecatHD.TBS_PvP;
    2.  
    3. import java.util.List;
    4.  
    5. import org.bukkit.entity.LivingEntity;
    6. import org.bukkit.entity.Projectile;
    7. import org.bukkit.entity.Snowball;
    8. import org.bukkit.event.EventHandler;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.event.entity.ProjectileHitEvent;
    11.  
    12. public class BombListener implements Listener {
    13.  
    14. @EventHandler
    15. public void onProjectileHit(ProjectileHitEvent e) {
    16. Projectile p = e.getEntity();
    17. if (!(p instanceof Snowball)) return;
    18. if(!p.getWorld().getName().equals("Arenas")) return;
    19. Snowball s = (Snowball) p;
    20. s.getWorld().createExplosion(s.getLocation(), 0); {
    21.  
    22. List<org.bukkit.entity.Entity> nearbyEntities = s.getNearbyEntities(2, 2, 2);
    23. for (int i = 0; i < nearbyEntities.size(); i++) {
    24. if (nearbyEntities.get(i) instanceof LivingEntity) {
    25. LivingEntity living = (LivingEntity) nearbyEntities.get(i);
    26. living.damage(8D);
    27. }
    28. }
    29. }
    30. }
    31. }
    32.  


    Tags: L33m4n123 sgavster SkillSam Chinwe (If you want me to stop tagging YOU, tell me.)

    Thanks !
     
Thread Status:
Not open for further replies.

Share This Page