Solved Thanks<3

Discussion in 'Plugin Development' started by Ula492, Dec 7, 2014.

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

    Ula492

    Im making a plugin, its a gadget plugins and it I keep getting this error code in console and IDK why i've checked the codes 5 times and no erros

    Code:java
    1. [17:30:08 INFO]: [Hubtools] Loading Hubtools v1.0
    2. [17:30:08 INFO]: [Hubtools] Enabling Hubtools v1.0
    3. [17:30:08 INFO]: §6§l||========================================||
    4. [17:30:08 INFO]: §6§l||========================================||
    5. [17:30:08 INFO]: §6§l||========================================||
    6. [17:30:08 INFO]: ||§9HubTools On, HUB WORLD NAME IS null
    7. [17:30:08 INFO]: §6§l||========================================||
    8. [17:30:08 INFO]: §6§l||========================================||
    9. [17:30:08 INFO]: §6§l||========================================||
    10. [17:30:08 ERROR]: Error occurred while enabling Hubtools v1.0 (Is it up to date?)
    11. java.lang.IllegalArgumentException: Plugin already initialized!
    12. at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:122) ~[spigot.jar:git-Spigot-1643]
    13. at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[spigot.jar:git-Spigot-1643]
    14. at me.Ula492.HubTools.Gadgets.<init>(Gadgets.java:52) ~[?:?]
    15. at me.Ula492.HubTools.HubTools.onEnable(HubTools.java:66) ~[?:?]
    16. at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) ~[spigot.jar:git-Spigot-1643]
    17. at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) [spigot.jar:git-Spigot-1643]
    18. at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [spigot.jar:git-Spigot-1643]
    19. at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugin(CraftServer.java:476) [spigot.jar:git-Spigot-1643]
    20. at org.bukkit.craftbukkit.v1_7_R4.CraftServer.enablePlugins(CraftServer.java:394) [spigot.jar:git-Spigot-1643]
    21. at org.bukkit.craftbukkit.v1_7_R4.CraftServer.reload(CraftServer.java:866) [spigot.jar:git-Spigot-1643]
    22. at org.bukkit.Bukkit.reload(Bukkit.java:301) [spigot.jar:git-Spigot-1643]
    23. at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [spigot.jar:git-Spigot-1643]
    24. at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181) [spigot.jar:git-Spigot-1643]
    25. at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServer.java:767) [spigot.jar:git-Spigot-1643]
    26. at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchServerCommand(CraftServer.java:753) [spigot.jar:git-Spigot-1643]
    27. at net.minecraft.server.v1_7_R4.DedicatedServer.aB(DedicatedServer.java:326) [spigot.jar:git-Spigot-1643]
    28. at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:290) [spigot.jar:git-Spigot-1643]
    29. at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [spigot.jar:git-Spigot-1643]
    30. at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [spigot.jar:git-Spigot-1643]
    31. at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-Spigot-1643]
    32. Caused by: java.lang.IllegalStateException: Initial initialization
    33. at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:125) ~[spigot.jar:git-Spigot-1643]
    34. at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[spigot.jar:git-Spigot-1643]
    35. at me.Ula492.HubTools.HubTools.<init>(HubTools.java:21) ~[?:?]
    36. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_55]
    37. at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[?:1.7.0_55]
    38. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.7.0_55]
    39. at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[?:1.7.0_55]
    40. at java.lang.Class.newInstance(Class.java:374) ~[?:1.7.0_55]
    41. at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot.jar:git-Spigot-1643]
    42. at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[spigot.jar:git-Spigot-1643]
    43. at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:341) ~[spigot.jar:git-Spigot-1643]
    44. at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:263) ~[spigot.jar:git-Spigot-1643]
    45. at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugins(CraftServer.java:369) ~[spigot.jar:git-Spigot-1643]
    46. at org.bukkit.craftbukkit.v1_7_R4.CraftServer.reload(CraftServer.java:864) ~[spigot.jar:git-Spigot-1643]
    47. ... 10 more
    48.  
     
  2. Offline

    Darkpicasa

    Code? Line 66 of it, in your onEnable()?
     
    Ula492 likes this.
  3. Offline

    Ula492


    It still wont load my gadgets :/
     
  4. Offline

    Skionz

    Ula492 Post your entire class.
     
  5. Offline

    Ula492

    Menu Class for Gadgets:
    Code:java
    1. package me.Ula492.HubTools;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Material;
    8. import org.bukkit.enchantments.Enchantment;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.inventory.Inventory;
    12. import org.bukkit.inventory.ItemStack;
    13. import org.bukkit.inventory.meta.ItemMeta;
    14.  
    15. public class Menu implements Listener{
    16.  
    17. public static Inventory myInventory = Bukkit.createInventory(null, 54, "Gadgets");
    18. // The first parameter, is the inventory owner. I make it null to let everyone use it.
    19. //The second parameter, is the slots in a inventory. Must be a multiple of 9. Can be up to 54.
    20. //The third parameter, is the inventory name. This will accept chat colors.
    21.  
    22. static {
    23. createDisplay(Material.BED, 1, false, myInventory, 4, ChatColor.GRAY + "Close", "");
    24. createDisplay(Material.ENDER_PEARL, 1, true, myInventory, 19, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Ethereal Pearl", ChatColor.WHITE + "Take a ride through the skies with your very own Ethereal Pearl!");
    25. createDisplay(Material.FIREWORK, 1, false, myInventory, 20, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Fireworks", ChatColor.WHITE + "Need to celebrate?! Use some fireworks! Pew pew pew!");
    26. createDisplay(Material.TNT, 1, false, myInventory, 21, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate TNT", ChatColor.WHITE + "Blow some people up! KABOOM!");
    27. createDisplay(Material.MELON_BLOCK, 1, false, myInventory, 22, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Melon Launcher", ChatColor.WHITE + "Deliciously fun! Eat the melon slices for a temporary speed boost!");
    28. createDisplay(Material.TRIPWIRE_HOOK, 1, false, myInventory, 23, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Flesh Hook", ChatColor.WHITE + "Make new friends by throwing a hook into their face and pulling them towards you!");
    29. createDisplay(Material.GOLD_BARDING, 1, false, myInventory, 24, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Paintball Gun", ChatColor.WHITE + "PEW PEW PEW PEW!");
    30. createDisplay(Material.IRON_BARDING, 1, false, myInventory, 25, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Bat Blaster", ChatColor.WHITE + "Launch waves of annoying bats at people you don't like!");
    31. createDisplay(Material.YELLOW_FLOWER, 1, false, myInventory, 28, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Coin Party Bomb", ChatColor.WHITE + "It's party time! you will be everyones favourite player when you use one of these!");
    32. createDisplay(Material.INK_SACK, 1, false, myInventory, 49, ChatColor.GRAY + "Clear Gadget", "");
    33. //The first parameter, is the slot that is assigned to. Starts counting at 0
    34. }
    35.  
    36. public static void createDisplay(Material material, int amount, boolean isEnchanted, Inventory inv, int Slot, String name, String lore) {
    37. ItemStack item = new ItemStack(material);
    38. ItemMeta meta = item.getItemMeta();
    39. meta.setDisplayName(name);
    40. item.setAmount(amount);
    41. ArrayList<String> Lore = new ArrayList<String>();
    42. Lore.add(lore);
    43. meta.setLore(Lore);
    44. if(isEnchanted) {
    45. meta.addEnchant(Enchantment.OXYGEN, 1, true);
    46. } else {
    47. //Do Nothing
    48. }
    49. item.setItemMeta(meta);
    50.  
    51. inv.setItem(Slot, item);
    52.  
    53. }
    54.  
    55. public static void openInventory(Player player) {
    56. player.openInventory(myInventory);
    57. }
    58.  
    59. public static void getMenu() {
    60. return;
    61. }
    62. }



    Gadgets Class
    Code:java
    1. package me.Ula492.HubTools;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.List;
    5. import java.util.Random;
    6.  
    7. import org.bukkit.Bukkit;
    8. import org.bukkit.ChatColor;
    9. import org.bukkit.Color;
    10. import org.bukkit.FireworkEffect;
    11. import org.bukkit.FireworkEffect.Type;
    12. import org.bukkit.Location;
    13. import org.bukkit.Material;
    14. import org.bukkit.Server;
    15. import org.bukkit.Sound;
    16. import org.bukkit.command.Command;
    17. import org.bukkit.command.CommandSender;
    18. import org.bukkit.enchantments.Enchantment;
    19. import org.bukkit.entity.Bat;
    20. import org.bukkit.entity.Creature;
    21. import org.bukkit.entity.EnderPearl;
    22. import org.bukkit.entity.Entity;
    23. import org.bukkit.entity.EntityType;
    24. import org.bukkit.entity.Firework;
    25. import org.bukkit.entity.LivingEntity;
    26. import org.bukkit.entity.Player;
    27. import org.bukkit.entity.Snowball;
    28. import org.bukkit.entity.TNTPrimed;
    29. import org.bukkit.event.EventHandler;
    30. import org.bukkit.event.EventPriority;
    31. import org.bukkit.event.Listener;
    32. import org.bukkit.event.block.Action;
    33. import org.bukkit.event.entity.EntityDeathEvent;
    34. import org.bukkit.event.entity.ProjectileHitEvent;
    35. import org.bukkit.event.inventory.ClickType;
    36. import org.bukkit.event.inventory.InventoryAction;
    37. import org.bukkit.event.inventory.InventoryClickEvent;
    38. import org.bukkit.event.player.PlayerDropItemEvent;
    39. import org.bukkit.event.player.PlayerInteractEvent;
    40. import org.bukkit.event.player.PlayerJoinEvent;
    41. import org.bukkit.inventory.Inventory;
    42. import org.bukkit.inventory.ItemStack;
    43. import org.bukkit.inventory.meta.FireworkMeta;
    44. import org.bukkit.inventory.meta.ItemMeta;
    45. import org.bukkit.plugin.PluginManager;
    46. import org.bukkit.plugin.java.JavaPlugin;
    47. import org.bukkit.potion.PotionEffect;
    48. import org.bukkit.potion.PotionEffectType;
    49. import org.bukkit.scheduler.BukkitRunnable;
    50. import org.bukkit.util.Vector;
    51.  
    52. public class Gadgets extends JavaPlugin implements Listener {
    53.  
    54. Server server = getServer();
    55. PluginManager pm = server.getPluginManager();
    56. public static Gadgets instance = null;
    57.  
    58. public Gadgets getInstance() {
    59. return instance;
    60. }
    61.  
    62. private Menu menu;
    63.  
    64. public void onEnable() {
    65. pm.registerEvents(this, this);
    66. instance = this;
    67. }
    68.  
    69. public void onDisable() {
    70. //Nothing Here :P
    71. }
    72.  
    73. public static ItemStack createItem(Material material, int amount, boolean isEnchanted, String name, String lore) {
    74. ItemStack item = new ItemStack(material);
    75. ItemMeta meta = item.getItemMeta();
    76. meta.setDisplayName(name);
    77. item.setAmount(amount);
    78. ArrayList<String> Lore = new ArrayList<String>();
    79. Lore.add(lore);
    80. meta.setLore(Lore);
    81. if(isEnchanted) {
    82. meta.addEnchant(Enchantment.OXYGEN, 1, true);
    83. } else {
    84. //Do Nothing
    85. }
    86. item.setItemMeta(meta);
    87.  
    88. return item;
    89.  
    90. }
    91.  
    92. @EventHandler(priority=EventPriority.HIGHEST)
    93. public void onInventoryClick(InventoryClickEvent event) {
    94. Player player = (Player) event.getWhoClicked(); // The player that clicked the item
    95. InventoryAction action = event.getAction();
    96. ItemStack clicked = event.getCurrentItem(); // The item that was clicked
    97. Inventory inventory = event.getInventory(); // The inventory that was clicked in
    98. if(event.getSlot() == 8) {
    99. event.setCancelled(true);
    100. }
    101. if(event.getSlot() == 3) {
    102. if(clicked.getType() == Material.CHEST) {
    103. event.setCancelled(true);
    104. }
    105. }
    106. if (inventory.getName().equals(menu.myInventory.getName())) { // The inventory is our custom Inventory
    107. if(clicked.getType() != Material.AIR) {
    108. player.playSound(player.getLocation(), Sound.ORB_PICKUP, 10, 10);
    109. player.closeInventory();
    110. if(clicked.getType() == Material.ENDER_PEARL) {
    111. player.getInventory().setItem(4, createItem(Material.ENDER_PEARL, 1, true, ChatColor.GREEN + "" + ChatColor.BOLD + " Ethereal Pearl", ChatColor.WHITE + "Right-click me to activate"));
    112. }
    113. if(clicked.getType() == Material.FIREWORK) {
    114. player.getInventory().setItem(4, createItem(Material.FIREWORK, 1, false, ChatColor.GREEN + "" + ChatColor.BOLD + " Fireworks", ChatColor.WHITE + "Right-click me to activate"));
    115. }
    116. if(clicked.getType() == Material.TNT) {
    117. player.getInventory().setItem(4, createItem(Material.TNT, 1, false, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate TNT", ChatColor.WHITE + "Right-click me to activate"));
    118. }
    119. if(clicked.getType() == Material.MELON_BLOCK) {
    120. player.getInventory().setItem(4, createItem(Material.MELON_BLOCK, 1, false, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Melon Launcher", ChatColor.WHITE + "Right-click me to activate"));
    121. }
    122. if(clicked.getType() == Material.GOLD_BARDING) {
    123. player.getInventory().setItem(4, createItem(Material.GOLD_BARDING, 1, false, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Paintball Gun", ChatColor.WHITE + "Right-click me to activate"));
    124. }
    125. if(clicked.getType() == Material.TRIPWIRE_HOOK) {
    126. player.getInventory().setItem(4, createItem(Material.TRIPWIRE_HOOK, 1, false, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Flesh Hook", ChatColor.WHITE + "Right-click me to activate"));
    127. }
    128. if(clicked.getType() == Material.IRON_BARDING) {
    129. player.getInventory().setItem(4, createItem(Material.IRON_BARDING, 1, false, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Bat Blaster", ChatColor.WHITE + "Right-click me to activate"));
    130. }
    131. if(clicked.getType() == Material.YELLOW_FLOWER) {
    132. player.getInventory().setItem(4, createItem(Material.YELLOW_FLOWER, 1, false, ChatColor.GREEN + "" + ChatColor.BOLD + "Activate Coin Party Bomb", ChatColor.WHITE + "Right-click me to activate"));
    133. }
    134. if(clicked.getType() == Material.INK_SACK) {
    135. player.playSound(player.getLocation(), Sound.DIG_WOOD, 10, 10);
    136. player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "Gadget slot cleared!");
    137. player.getInventory().setItem(4, new ItemStack(Material.AIR));
    138. }
    139. event.setCancelled(true);
    140. } else {
    141. event.setCancelled(true);
    142. }
    143. }
    144. }
    145.  
    146. @EventHandler(priority = EventPriority.HIGHEST)
    147. public void onEntityLand(EntityDeathEvent event) {
    148. Entity entity = event.getEntity();
    149. EntityType type = event.getEntityType();
    150.  
    151. if(type == EntityType.ENDER_PEARL) {
    152. if(entity.getPassenger().getType() == EntityType.PLAYER) {
    153. Player player = (Player) entity.getPassenger();
    154. Firework fw = (Firework) player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREWORK);
    155. FireworkMeta fwm = fw.getFireworkMeta();
    156.  
    157. FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.PURPLE).withFade(Color.WHITE).with(Type.BURST).trail(false).build();
    158. fwm.addEffect(effect);
    159. fwm.setPower(1);
    160.  
    161. //Then apply this to our rocket
    162. fw.setFireworkMeta(fwm);
    163. player.getInventory().setItem(4, new ItemStack(Material.AIR));
    164. }
    165. }
    166. }
    167.  
    168. @EventHandler(priority = EventPriority.HIGHEST)
    169. public void onItemDrop(PlayerDropItemEvent event) {
    170. if(event.getItemDrop().getItemStack().getItemMeta().getDisplayName().contains("Activate")) {
    171. event.setCancelled(true);
    172. }
    173. if(event.getItemDrop().getItemStack().getItemMeta().getDisplayName().contains("Gadgets")) {
    174. event.setCancelled(true);
    175. }
    176. }
    177.  
    178. private Color getColor(int i) {
    179. Color c = null;
    180. if(i==1){
    181. c=Color.AQUA;
    182. }
    183. if(i==2){
    184. c=Color.BLACK;
    185. }
    186. if(i==3){
    187. c=Color.BLUE;
    188. }
    189. if(i==4){
    190. c=Color.FUCHSIA;
    191. }
    192. if(i==5){
    193. c=Color.GRAY;
    194. }
    195. if(i==6){
    196. c=Color.GREEN;
    197. }
    198. if(i==7){
    199. c=Color.LIME;
    200. }
    201. if(i==8){
    202. c=Color.MAROON;
    203. }
    204. if(i==9){
    205. c=Color.NAVY;
    206. }
    207. if(i==10){
    208. c=Color.OLIVE;
    209. }
    210. if(i==11){
    211. c=Color.ORANGE;
    212. }
    213. if(i==12){
    214. c=Color.PURPLE;
    215. }
    216. if(i==13){
    217. c=Color.RED;
    218. }
    219. if(i==14){
    220. c=Color.SILVER;
    221. }
    222. if(i==15){
    223. c=Color.TEAL;
    224. }
    225. if(i==16){
    226. c=Color.WHITE;
    227. }
    228. if(i==17){
    229. c=Color.YELLOW;
    230. }
    231.  
    232. return c;
    233. }
    234.  
    235. @EventHandler(priority = EventPriority.HIGHEST)
    236. public void onPlayerPlaceBlock(PlayerInteractEvent event) {
    237. final Player player = event.getPlayer();
    238. if(event.getItem().getType() == Material.CHEST) {
    239. if(event.getItem().getItemMeta().getDisplayName().contains("Gadgets")) {
    240. server.dispatchCommand(player, "gadget");
    241. event.setCancelled(true);
    242. }
    243. }
    244. if(event.getItem().getType() == Material.ENDER_PEARL) {
    245. player.playSound(player.getLocation(), Sound.FIREWORK_LAUNCH, 10, 10);
    246. EnderPearl enderpearl = player.launchProjectile(EnderPearl.class);
    247. enderpearl.setPassenger(player);
    248. event.setCancelled(true);
    249. event.getPlayer().getInventory().setItem(4, new ItemStack(Material.AIR));
    250. }
    251. if(event.getItem().getType() == Material.YELLOW_FLOWER) {
    252. player.playSound(player.getLocation(), Sound.ITEM_PICKUP, 10, 10);
    253. player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "This feature is in development. Please check back later.");
    254. event.setCancelled(true);
    255. event.getPlayer().getInventory().setItem(4, new ItemStack(Material.AIR));
    256. }
    257. if(event.getItem().getType() == Material.TNT) {
    258. final TNTPrimed tnt = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), TNTPrimed.class);
    259. player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "Explosion incoming!");
    260. player.playSound(player.getLocation(), Sound.FUSE, 10, 10);
    261. new BukkitRunnable() {
    262.  
    263. @Override
    264. public void run() {
    265. Location location = tnt.getLocation();
    266. player.playSound(player.getLocation(), Sound.EXPLODE, 10, 10);
    267. double radius = 5D;
    268. List<Entity> near = player.getNearbyEntities(10.0d, 10.0d, 10.0d);
    269. for(Entity e : near) {
    270. e.setVelocity(new Vector(0, 2, 0));
    271. }
    272. tnt.remove();
    273. }
    274.  
    275. }.runTaskLater(getInstance(), 60);
    276. event.setCancelled(true);
    277. event.getPlayer().getInventory().setItem(4, new ItemStack(Material.AIR));
    278. }
    279. if(event.getItem().getType() == Material.MELON_BLOCK) {
    280. player.playSound(player.getLocation(), Sound.LAVA_POP, 10, 10);
    281. player.getWorld().dropItemNaturally(player.getLocation().add(new Vector(0, 10, 0)), createItem(Material.MELON, 64, false, ChatColor.GREEN + "" + ChatColor.BOLD + "Super Melon", ChatColor.WHITE + "Eat them to get super speed!"));
    282. event.setCancelled(true);
    283. event.getPlayer().getInventory().setItem(4, new ItemStack(Material.AIR));
    284. }
    285. if(event.getItem().getType() == Material.MELON) {
    286. player.playSound(player.getLocation(), Sound.ORB_PICKUP, 10, 10);
    287. player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "* You feel different now...");
    288. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 150, 5));
    289. event.setCancelled(true);
    290. event.getPlayer().getInventory().remove(Material.MELON);
    291. }
    292. if(event.getItem().getType() == Material.GOLD_BARDING) {
    293. player.playSound(player.getLocation(), Sound.LAVA_POP, 10, 10);
    294. player.launchProjectile(Snowball.class);
    295. event.setCancelled(true);
    296. }
    297. if(event.getItem().getType() == Material.TRIPWIRE_HOOK) {
    298. player.playSound(player.getLocation(), Sound.ITEM_BREAK, 10, 10);
    299. player.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "Nearby entities have been hooked!");
    300. double radius = 5D;
    301. List<Entity> near = player.getNearbyEntities(10.0d, 10.0d, 10.0d);
    302. for(Entity e : near) {
    303. if(e.getType() == EntityType.PLAYER) {
    304. Player entity = (Player) e;
    305. player.playSound(player.getLocation(), Sound.LAVA_POP, 10, 10);
    306. entity.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "You have been hooked!");
    307. }
    308. e.setVelocity(new Vector(0, 3, 0));
    309. }
    310. event.setCancelled(true);
    311. event.getPlayer().getInventory().setItem(4, new ItemStack(Material.AIR));
    312. }
    313. if(event.getItem().getType() == Material.IRON_BARDING) {
    314. player.playSound(player.getLocation(), Sound.ITEM_BREAK, 10, 10);
    315. boolean done = false;
    316. if(done) {
    317. Bat bat = (Bat) player.getWorld().spawnEntity(player.getEyeLocation(), EntityType.BAT);
    318. Bat bat2 = (Bat) player.getWorld().spawnEntity(player.getEyeLocation(), EntityType.BAT);
    319. Bat bat3 = (Bat) player.getWorld().spawnEntity(player.getEyeLocation(), EntityType.BAT);
    320. Bat bat4 = (Bat) player.getWorld().spawnEntity(player.getEyeLocation(), EntityType.BAT);
    321. Bat bat5 = (Bat) player.getWorld().spawnEntity(player.getEyeLocation(), EntityType.BAT);
    322. Creature batc1 = (Creature) bat;
    323. Creature batc2 = (Creature) bat2;
    324. Creature batc3 = (Creature) bat3;
    325. Creature batc4 = (Creature) bat4;
    326. Creature batc5 = (Creature) bat5;
    327. double radius = 5D;
    328. List<Entity> near = player.getNearbyEntities(5.0d, 5.0d, 5.0d);
    329. for(Entity e : near) {
    330. batc1.setTarget((LivingEntity) e);
    331. batc2.setTarget((LivingEntity) e);
    332. batc3.setTarget((LivingEntity) e);
    333. batc4.setTarget((LivingEntity) e);
    334. batc5.setTarget((LivingEntity) e);
    335. }
    336. } else {
    337. player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "This feature is in development. Please check back later.");
    338. }
    339. event.setCancelled(true);
    340. }
    341. if(event.getItem().getType() == Material.FIREWORK) {
    342. //Spawn the Firework, get the FireworkMeta.
    343. Firework fw = (Firework) player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREWORK);
    344. FireworkMeta fwm = fw.getFireworkMeta();
    345.  
    346. //Our random generator
    347. Random r = new Random();
    348.  
    349. //Get the type
    350. int rt = r.nextInt(4) + 1;
    351. Type type = Type.BALL;
    352. if (rt == 1) type = Type.BALL;
    353. if (rt == 2) type = Type.BALL_LARGE;
    354. if (rt == 3) type = Type.BURST;
    355. if (rt == 4) type = Type.CREEPER;
    356. if (rt == 5) type = Type.STAR;
    357.  
    358. //Get our random colours
    359. int r1i = r.nextInt(17) + 1;
    360. int r2i = r.nextInt(17) + 1;
    361. Color c1 = getColor(r1i);
    362. Color c2 = getColor(r2i);
    363.  
    364. //Create our effect with this
    365. FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2).with(type).trail(r.nextBoolean()).build();
    366.  
    367. //Then apply the effect to the meta
    368. fwm.addEffect(effect);
    369.  
    370. //Generate some random power and set it
    371. int rp = r.nextInt(2) + 1;
    372. fwm.setPower(rp);
    373.  
    374. //Then apply this to our rocket
    375. fw.setFireworkMeta(fwm);
    376. event.setCancelled(true);
    377. }
    378. }
    379.  
    380. @EventHandler(priority = EventPriority.HIGHEST)
    381. public void onPlayerJoin(PlayerJoinEvent event) {
    382. event.getPlayer().getInventory().setItem(0, createItem(Material.CHEST, 1, false, ChatColor.AQUA + "" + ChatColor.BOLD + "Gadgets", ChatColor.WHITE + "Right-click me to open the gadgets menu"));
    383. }
    384.  
    385. @EventHandler(priority = EventPriority.HIGHEST)
    386. public void onEntityHit(ProjectileHitEvent event) {
    387. Entity entity = event.getEntity();
    388. EntityType type = event.getEntityType();
    389.  
    390. if(type == EntityType.BAT) {
    391. //Spawn the Firework, get the FireworkMeta.
    392. Firework fw = (Firework) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.FIREWORK);
    393. FireworkMeta fwm = fw.getFireworkMeta();
    394.  
    395. //Our random generator
    396. Random r = new Random();
    397.  
    398. //Get the type
    399. int rt = r.nextInt(4) + 1;
    400. Type type2 = Type.BALL;
    401. if (rt == 1) type2 = Type.BALL;
    402. if (rt == 2) type2 = Type.BALL_LARGE;
    403. if (rt == 3) type2 = Type.BURST;
    404. if (rt == 4) type2 = Type.CREEPER;
    405. if (rt == 5) type2 = Type.STAR;
    406.  
    407. //Get our random colours
    408. int r1i = r.nextInt(17) + 1;
    409. int r2i = r.nextInt(17) + 1;
    410. Color c1 = getColor(r1i);
    411. Color c2 = getColor(r2i);
    412.  
    413. //Create our effect with this
    414. FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2).with(type2).trail(r.nextBoolean()).build();
    415.  
    416. //Then apply the effect to the meta
    417. fwm.addEffect(effect);
    418.  
    419. //Generate some random power and set it
    420. int rp = r.nextInt(2) + 1;
    421. fwm.setPower(rp);
    422.  
    423. //Then apply this to our rocket
    424. fw.setFireworkMeta(fwm);
    425. double radius = 5D;
    426. List<Entity> near = entity.getNearbyEntities(3.0d, 3.0d, 3.0d);
    427. for(Entity e : near) {
    428. e.setVelocity(new Vector(0, 2, 0));
    429. }
    430. entity.remove();
    431. }
    432. if(type == EntityType.SNOWBALL) {
    433. //Spawn the Firework, get the FireworkMeta.
    434. Firework fw = (Firework) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.FIREWORK);
    435. FireworkMeta fwm = fw.getFireworkMeta();
    436.  
    437. //Our random generator
    438. Random r = new Random();
    439.  
    440. //Get the type
    441. int rt = r.nextInt(4) + 1;
    442. Type type2 = Type.BALL;
    443. if (rt == 1) type2 = Type.BALL;
    444. if (rt == 2) type2 = Type.BALL_LARGE;
    445. if (rt == 3) type2 = Type.BURST;
    446. if (rt == 4) type2 = Type.CREEPER;
    447. if (rt == 5) type2 = Type.STAR;
    448.  
    449. //Get our random colours
    450. int r1i = r.nextInt(17) + 1;
    451. int r2i = r.nextInt(17) + 1;
    452. Color c1 = getColor(r1i);
    453. Color c2 = getColor(r2i);
    454.  
    455. //Create our effect with this
    456. FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2).with(type2).trail(r.nextBoolean()).build();
    457.  
    458. //Then apply the effect to the meta
    459. fwm.addEffect(effect);
    460.  
    461. //Generate some random power and set it
    462. int rp = r.nextInt(2) + 1;
    463. fwm.setPower(rp);
    464.  
    465. //Then apply this to our rocket
    466. fw.setFireworkMeta(fwm);
    467. }
    468. }
    469.  
    470. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    471.  
    472. Player player = (Player) sender;
    473.  
    474. if(label.equalsIgnoreCase("gadget")) {
    475. if(player.hasPermission("HubTools.Gadget.Use")) {
    476. menu.openInventory(player);
    477. player.playSound(player.getLocation(), Sound.DOOR_OPEN, 10, 10);
    478. } else {
    479. player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "You don't have permission to do that.");
    480. player.playSound(player.getLocation(), Sound.FIZZ, 10, 10);
    481. }
    482. }
    483.  
    484. return false;
    485.  
    486. }
    487. }
    488.  
     
  6. Offline

    WesJD

    Ula492 You don't need to put else statements if they don't do anything. Same with onDisable.
     
  7. Offline

    Ula492

    My b I made the gadgets as a separate plugin and I just copied the class into the new plugin that im working on right now but the Gadgets thing still isnt working... I deleted the On enable and disble
     
  8. Offline

    WesJD

    Ula492 Doesn't seem that you were working on that plugin...

    all of your code is obviously copied...
     
  9. Offline

    Ula492

    Its copied of my Gadget plugin for my server...... want the video?
     
  10. Offline

    Skionz

  11. Offline

    Ula492

    .... Yes i used that code in a dif plugin..... I said it right up there I added some of my code to it aswell..................

    http://gyazo.com/6ddeb1d58b7963c8e704804f4fcc0c90

    http://gyazo.com/6ddeb1d58b7963c8e704804f4fcc0c90

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

    Skionz

    Ula492 Its a syntax error. Your IDE should tell you exactly what is wrong.
     
  13. Offline

    WesJD

    Ula492 If you didn't code it:

    1. You could easily be shut down for copyright if you don't have permission from the owner
    2. Don't come here, go to the creator
     
    Darkpicasa likes this.
  14. Offline

    Ula492

    *Blinks* I worked added stuff to that code..... I didnt just take the plugin...........
     
  15. Offline

    WesJD

    Ula492 Copyright still applies.
     
  16. Offline

    Skionz

  17. Offline

    Ula492

    idk what u want me to do then.... Sorry?
     
  18. Offline

    Skionz

    Ula492 He wants you to write your own code. I thought that was pretty self explanatory.
     
  19. Offline

    Ula492

    KK ill re do it then, dont see the problem but ok
     
Thread Status:
Not open for further replies.

Share This Page