Advertisement
Guest User

I dont know why my plugin wont work

a guest
Oct 18th, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.79 KB | None | 0 0
  1. package me.kitpvp.main;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.Material;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.enchantments.Enchantment;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.inventory.ItemStack;
  10. import org.bukkit.inventory.meta.ItemMeta;
  11. import org.bukkit.plugin.PluginManager;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13.  
  14. import me.kitpvp.listeners.PlayerListeners;
  15.  
  16. public class main extends JavaPlugin{
  17.  
  18. private static main instance;
  19.  
  20. public void log(String string) {
  21. System.out.println(string);
  22. }
  23.  
  24. public static main getInstance(){
  25. return instance;
  26. }
  27.  
  28. public void registerListeners(){
  29. PluginManager pm = getServer().getPluginManager();
  30. pm.registerEvents(new PlayerListeners(this), this);
  31. }
  32.  
  33. public void registerCommands(){
  34. //not using this yet
  35. }
  36.  
  37. //when the plugin is enabled
  38. @Override
  39. public void onEnable(){
  40. getLogger().info("has been enabled successfully!");
  41. instance = this;
  42. registerListeners();
  43. registerCommands();
  44. }
  45.  
  46. //when the plugin is disabled
  47. @Override
  48. public void onDisable(){
  49. getLogger().info("has been disabled successfully!");
  50. instance = null;
  51. }
  52.  
  53. //commands
  54.  
  55. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  56.  
  57. //kit pvp command
  58. if (cmd.getName().equalsIgnoreCase("kit pvp") && sender instanceof Player) {
  59. if(!sender.hasPermission("kit.pvp")) {
  60. return true;
  61. }
  62. Player p = (Player) sender;
  63. p.getInventory();
  64. ItemStack pvpsword = new ItemStack(Material.IRON_SWORD);
  65. ItemMeta m = pvpsword.getItemMeta();
  66. m.setDisplayName("" + ChatColor.GRAY + ChatColor.BOLD + "KitPvpSword");
  67. pvpsword.setItemMeta(m);
  68. pvpsword.addEnchantment(Enchantment.DURABILITY, 1);
  69. pvpsword.addEnchantment(Enchantment.DAMAGE_ALL, 2);
  70. p.getInventory().addItem(pvpsword);
  71. ItemStack pvpbow = new ItemStack(Material.BOW);
  72. ItemMeta m1 = pvpbow.getItemMeta();
  73. m1.setDisplayName("" + ChatColor.GRAY + ChatColor.BOLD + "KitPvpBow");
  74. pvpbow.setItemMeta(m1);
  75. pvpbow.addEnchantment(Enchantment.DURABILITY, 1);
  76. pvpbow.addEnchantment(Enchantment.ARROW_DAMAGE, 1);
  77. ItemStack pvphelmet = new ItemStack(Material.IRON_HELMET);
  78. ItemMeta m2 = pvphelmet.getItemMeta();
  79. m2.setDisplayName("" + ChatColor.GRAY + ChatColor.BOLD + "KitPvpHelmet");
  80. pvphelmet.setItemMeta(m2);
  81. pvphelmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
  82. pvphelmet.addEnchantment(Enchantment.DURABILITY, 1);
  83. ItemStack pvpchestplate = new ItemStack(Material.IRON_CHESTPLATE);
  84. ItemMeta m3 = pvpchestplate.getItemMeta();
  85. m3.setDisplayName("" + ChatColor.GRAY + ChatColor.BOLD + "KitPvpChestplate");
  86. pvpchestplate.setItemMeta(m3);
  87. pvpchestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
  88. pvpchestplate.addEnchantment(Enchantment.DURABILITY, 1);
  89. ItemStack pvpleggings = new ItemStack(Material.IRON_LEGGINGS);
  90. ItemMeta m4 = pvpleggings.getItemMeta();
  91. m4.setDisplayName("" + ChatColor.GRAY + ChatColor.BOLD + "KitPvpLeggings");
  92. pvpleggings.setItemMeta(m4);
  93. pvpleggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
  94. pvpleggings.addEnchantment(Enchantment.DURABILITY, 1);
  95. ItemStack pvpboots = new ItemStack(Material.IRON_BOOTS);
  96. ItemMeta m5 = pvpboots.getItemMeta();
  97. m5.setDisplayName("" + ChatColor.GRAY + ChatColor.BOLD + "KitPvpBoots");
  98. pvpboots.setItemMeta(m5);
  99. pvpboots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
  100. pvpboots.addEnchantment(Enchantment.DURABILITY, 1);
  101. p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 10));
  102. p.getInventory().addItem(pvphelmet);
  103. p.getInventory().addItem(pvpchestplate);
  104. p.getInventory().addItem(pvpleggings);
  105. p.getInventory().addItem(pvpboots);
  106. p.getInventory().addItem(new ItemStack(Material.ARROW, 32));
  107. p.sendMessage("" + ChatColor.AQUA + "You have recieved the kit" + ChatColor.BOLD + ChatColor.GREEN + "pvp");
  108. return true;
  109. }
  110. //end of kit pvp command
  111.  
  112. //kit vip command
  113.  
  114. if (cmd.getName().equalsIgnoreCase("kit vip") && sender instanceof Player) {
  115. if(!sender.hasPermission("kit.vip")) {
  116. sender.sendMessage(ChatColor.RED + "You do not have permission to use this command!");
  117. return true;
  118. }
  119. Player p = (Player) sender;
  120. p.getInventory();
  121. ItemStack vipsword = new ItemStack(Material.IRON_SWORD);
  122. ItemMeta m = vipsword.getItemMeta();
  123. m.setDisplayName("" + ChatColor.AQUA + ChatColor.BOLD + "KitVipSword");
  124. vipsword.setItemMeta(m);
  125. vipsword.addEnchantment(Enchantment.DURABILITY, 2);
  126. vipsword.addEnchantment(Enchantment.DAMAGE_ALL, 3);
  127. p.getInventory().addItem(vipsword);
  128. ItemStack vipbow = new ItemStack(Material.BOW);
  129. ItemMeta m1 = vipbow.getItemMeta();
  130. m1.setDisplayName("" + ChatColor.AQUA + ChatColor.BOLD + "KitVipBow");
  131. vipbow.setItemMeta(m1);
  132. vipbow.addEnchantment(Enchantment.DURABILITY, 2);
  133. vipbow.addEnchantment(Enchantment.ARROW_DAMAGE, 2);
  134. ItemStack viphelmet = new ItemStack(Material.IRON_HELMET);
  135. ItemMeta m2 = viphelmet.getItemMeta();
  136. m2.setDisplayName("" + ChatColor.AQUA + ChatColor.BOLD + "KitVipHelmet");
  137. viphelmet.setItemMeta(m2);
  138. viphelmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
  139. viphelmet.addEnchantment(Enchantment.DURABILITY, 2);
  140. ItemStack vipchestplate = new ItemStack(Material.IRON_CHESTPLATE);
  141. ItemMeta m3 = vipchestplate.getItemMeta();
  142. m3.setDisplayName("" + ChatColor.AQUA + ChatColor.BOLD + "KitVipChestplate");
  143. vipchestplate.setItemMeta(m3);
  144. vipchestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
  145. vipchestplate.addEnchantment(Enchantment.DURABILITY, 2);
  146. ItemStack vipleggings = new ItemStack(Material.IRON_LEGGINGS);
  147. ItemMeta m4 = vipleggings.getItemMeta();
  148. m4.setDisplayName("" + ChatColor.AQUA + ChatColor.BOLD + "KitVipLeggings");
  149. vipleggings.setItemMeta(m4);
  150. vipleggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
  151. vipchestplate.addEnchantment(Enchantment.DURABILITY, 2);
  152. ItemStack vipboots = new ItemStack(Material.IRON_BOOTS);
  153. ItemMeta m5 = vipboots.getItemMeta();
  154. m5.setDisplayName("" + ChatColor.AQUA + ChatColor.BOLD + "KitVipBoots");
  155. vipboots.setItemMeta(m5);
  156. vipboots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
  157. vipboots.addEnchantment(Enchantment.DURABILITY, 2);
  158. p.getInventory().addItem(new ItemStack(Material.GOLDEN_APPLE, 10));
  159. p.getInventory().addItem(viphelmet);
  160. p.getInventory().addItem(vipchestplate);
  161. p.getInventory().addItem(vipleggings);
  162. p.getInventory().addItem(vipboots);
  163. p.getInventory().addItem(new ItemStack(Material.ARROW, 32));
  164. p.getInventory().addItem(new ItemStack(Material.ENCHANTED_GOLDEN_APPLE, 1));
  165. p.sendMessage("" + ChatColor.AQUA + "You have recieved the kit" + ChatColor.BOLD + ChatColor.GOLD + "Vip");
  166. return true;
  167. }
  168.  
  169. return false;
  170. }
  171.  
  172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement