Effects

Discussion in 'Plugin Development' started by JordyPwner, Aug 22, 2014.

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

    JordyPwner

    is there a cloud effect> so i can finish my gun? Like:

    p.playEffect(s.getLocation(), Effect.CLOUD, 1);
     
  2. Offline

    ShadowLAX

    JordyPwner For particles you have to use the PacketPlayOutWorldParticles packet.
     
  3. Offline

    JordyPwner

  4. Offline

    ShadowLAX

    JordyPwner You can either write your own packet code (which in my opinion, is much easier to do if you know how to use packets), or you can use a Lib like ParticleEffect.
     
  5. Offline

    JordyPwner

    ShadowLAX im a noob at java ;3 but here is my class:
    Show Spoiler
    Code:java
    1. package me.jordypwner.guns;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Effect;
    5. import org.bukkit.Material;
    6. import org.bukkit.Sound;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.entity.Snowball;
    9. import org.bukkit.event.EventHandler;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.entity.ProjectileHitEvent;
    12. import org.bukkit.event.player.PlayerJoinEvent;
    13.  
    14. public class SnowballHit
    15. implements Listener
    16. {
    17. @EventHandler
    18. public void onPlayerJoin(PlayerJoinEvent e)
    19. {
    20.  
    21. }
    22.  
    23. @EventHandler
    24. public void onProjectileHit(ProjectileHitEvent e)
    25. {
    26. if ((e.getEntity() instanceof Snowball))
    27. {
    28. Snowball s = (Snowball)e.getEntity();
    29. if ((s.getShooter() instanceof Player))
    30. {
    31. Player p = (Player)s.getShooter();
    32. if (p.hasPermission("hub.hub"))
    33. {
    34. p.playSound(p.getLocation(), Sound.CHICKEN_EGG_POP, 2.0F, 2.0F);
    35. p.playEffect(s.getLocation(), Effect.SMOKE, 1);
    36. p.playEffect(s.getLocation(), Effect.ENDER_SIGNAL, 1);
    37. s.remove();
    38.  
    39. }else{
    40. p.sendMessage(ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "[" + ChatColor.YELLOW + "" + ChatColor.BOLD + "Aurum" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "]" + ChatColor.RED + "You must be a" + ChatColor.DARK_BLUE + "" + ChatColor.BOLD + " Donator" + ChatColor.RED + " or above to use the Bow!");
    41. p.sendMessage(ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "[" + ChatColor.YELLOW + "" + ChatColor.BOLD + "Aurum" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "]" + ChatColor.RED + "Purchase it at [url]http://aurumnetwork.enjin.com[/url]");
    42. return;
    43. }
    44. }
    45. }
    46. }
    47. }
     
  6. Offline

    Onlineids

    JordyPwner ParticleEffect class created by DarkBladee12
    Class (open)

    Code:java
    1. package me.online.SpideyMCHub;
    2.  
    3. import java.lang.reflect.Constructor;
    4. import java.lang.reflect.Field;
    5. import java.lang.reflect.Method;
    6. import java.util.ArrayList;
    7. import java.util.Arrays;
    8. import java.util.Collection;
    9. import java.util.HashMap;
    10. import java.util.List;
    11. import java.util.Map;
    12. import java.util.Map.Entry;
    13.  
    14. import me.online.SpideyMCHub.Reflection.PackageType;
    15. import me.online.SpideyMCHub.Reflection.PacketType;
    16. import me.online.SpideyMCHub.Reflection.SubPackageType;
    17.  
    18. import org.bukkit.Bukkit;
    19. import org.bukkit.Location;
    20. import org.bukkit.entity.Player;
    21.  
    22. /**
    23. * ParticleEffect Library v1.4
    24. *
    25. * This library was created by [USER=90640105]DarkBlade12[/USER] based on content related to particles of [USER=90705652]microgeek[/USER] (names and packet values), it allows you to display all Minecraft particle effects on a Bukkit server
    26. *
    27. * You are welcome to use it, modify it and redistribute it under the following conditions:
    28. * 1. Don't claim this class as your own
    29. * 2. Don't remove this text
    30. *
    31. * (Would be nice if you provide credit to me)
    32. *
    33. * @author DarkBlade12
    34. */
    35. public enum ParticleEffect {
    36. /**
    37. * @appearance Huge explosions
    38. * @displayed by TNT and creepers
    39. */
    40. HUGE_EXPLOSION("hugeexplosion"),
    41. /**
    42. * @appearance Smaller explosions
    43. * @displayed by TNT and creepers
    44. */
    45. LARGE_EXPLODE("largeexplode"),
    46. /**
    47. * @appearance Little white sparkling stars
    48. * @displayed by Fireworks
    49. */
    50. FIREWORKS_SPARK("fireworksSpark"),
    51. /**
    52. * @appearance Bubbles
    53. * @displayed in water
    54. */
    55. BUBBLE("bubble"),
    56. /**
    57. * @appearance Unknown
    58. */
    59. SUSPEND("suspend"),
    60. /**
    61. * @appearance Little gray dots
    62. * @displayed in the Void and water
    63. */
    64. DEPTH_SUSPEND("depthSuspend"),
    65. /**
    66. * @appearance Little gray dots
    67. * @displayed by Mycelium
    68. */
    69. TOWN_AURA("townaura"),
    70. /**
    71. * @appearance Light brown crosses
    72. * @displayed by critical hits
    73. */
    74. CRIT("crit"),
    75. /**
    76. * @appearance Cyan stars
    77. * @displayed by hits with an enchanted weapon
    78. */
    79. MAGIC_CRIT("magicCrit"),
    80. /**
    81. * @appearance Little black/gray clouds
    82. * @displayed by torches, primed TNT and end portals
    83. */
    84. SMOKE("smoke"),
    85. /**
    86. * @appearance Colored swirls
    87. * @displayed by potion effects
    88. */
    89. MOB_SPELL("mobSpell"),
    90. /**
    91. * @appearance Transparent colored swirls
    92. * @displayed by beacon effect
    93. */
    94. MOB_SPELL_AMBIENT("mobSpellAmbient"),
    95. /**
    96. * @appearance Colored swirls
    97. * @displayed by splash potions
    98. */
    99. SPELL("spell"),
    100. /**
    101. * @appearance Colored crosses
    102. * @displayed by instant splash potions (instant health/instant damage)
    103. */
    104. INSTANT_SPELL("instantSpell"),
    105. /**
    106. * @appearance Colored crosses
    107. * @displayed by witches
    108. */
    109. WITCH_MAGIC("witchMagic"),
    110. /**
    111. * @appearance Colored notes
    112. * @displayed by note blocks
    113. */
    114. NOTE("note"),
    115. /**
    116. * @appearance Little purple clouds
    117. * @displayed by nether portals, endermen, ender pearls, eyes of ender and ender chests
    118. */
    119. PORTAL("portal"),
    120. /**
    121. * @appearance: White letters
    122. * @displayed by enchantment tables that are near bookshelves
    123. */
    124. ENCHANTMENT_TABLE("enchantmenttable"),
    125. /**
    126. * @appearance White clouds
    127. */
    128. EXPLODE("explode"),
    129. /**
    130. * @appearance Little flames
    131. * @displayed by torches, furnaces, magma cubes and monster spawners
    132. */
    133. FLAME("flame"),
    134. /**
    135. * @appearance Little orange blobs
    136. * @displayed by lava
    137. */
    138. LAVA("lava"),
    139. /**
    140. * @appearance Gray transparent squares
    141. */
    142. FOOTSTEP("footstep"),
    143. /**
    144. * @appearance Blue drops
    145. * @displayed by water, rain and shaking wolves
    146. */
    147. SPLASH("splash"),
    148. /**
    149. * @appearance Blue droplets
    150. * @displayed on water when fishing
    151. */
    152. WAKE("wake"),
    153. /**
    154. * @appearance Black/Gray clouds
    155. * @displayed by fire, minecarts with furance and blazes
    156. */
    157. LARGE_SMOKE("largesmoke"),
    158. /**
    159. * @appearance Large white clouds
    160. * @displayed on mob death
    161. */
    162. CLOUD("cloud"),
    163. /**
    164. * @appearance Little colored clouds
    165. * @displayed by active redstone wires and redstone torches
    166. */
    167. RED_DUST("reddust"),
    168. /**
    169. * @appearance Little white parts
    170. * @displayed by cracking snowballs and eggs
    171. */
    172. SNOWBALL_POOF("snowballpoof"),
    173. /**
    174. * @appearance Blue drips
    175. * @displayed by blocks below a water source
    176. */
    177. DRIP_WATER("dripWater"),
    178. /**
    179. * @appearance Orange drips
    180. * @displayed by blocks below a lava source
    181. */
    182. DRIP_LAVA("dripLava"),
    183. /**
    184. * @appearance White clouds
    185. */
    186. SNOW_SHOVEL("snowshovel"),
    187. /**
    188. * @appearance Little green parts
    189. * @displayed by slimes
    190. */
    191. SLIME("slime"),
    192. /**
    193. * @appearance Red hearts
    194. * @displayed when breeding
    195. */
    196. HEART("heart"),
    197. /**
    198. * @appearance Dark gray cracked hearts
    199. * @displayed when attacking a villager in a village
    200. */
    201. ANGRY_VILLAGER("angryVillager"),
    202. /**
    203. * @appearance Green stars
    204. * @displayed by bone meal and when trading with a villager
    205. */
    206. HAPPY_VILLAGER("happyVillager");
    207.  
    208. private static final Map<String, ParticleEffect> NAME_MAP = new HashMap<String, ParticleEffect>();
    209. private static final double MAX_RANGE = 16;
    210. private static Constructor<?> packetPlayOutWorldParticles;
    211. private static Method getHandle;
    212. private static Field playerConnection;
    213. private static Method sendPacket;
    214. private final String name;
    215.  
    216. static {
    217. for (ParticleEffect p : values())
    218. NAME_MAP.put(p.name, p);
    219. try {
    220. packetPlayOutWorldParticles = Reflection.getConstructor(PacketType.PLAY_OUT_WORLD_PARTICLES.getPacket(), String.class, float.class, float.class, float.class, float.class, float.class,
    221. float.class, float.class, int.class);
    222. getHandle = Reflection.getMethod("CraftPlayer", SubPackageType.ENTITY, "getHandle");
    223. playerConnection = Reflection.getField("EntityPlayer", PackageType.MINECRAFT_SERVER, "playerConnection");
    224. sendPacket = Reflection.getMethod(playerConnection.getType(), "sendPacket", Reflection.getClass("Packet", PackageType.MINECRAFT_SERVER));
    225. } catch (Exception e) {
    226. e.printStackTrace();
    227. }
    228. }
    229.  
    230. /**
    231. * @param name Name of this particle effect
    232. */
    233. private ParticleEffect(String name) {
    234. this.name = name;
    235. }
    236.  
    237. /**
    238. * @return The name of this particle effect
    239. */
    240. public String getName() {
    241. return this.name;
    242. }
    243.  
    244. /**
    245. * Gets a particle effect from name
    246. *
    247. * @param name Name of the particle effect
    248. * @return The particle effect
    249. */
    250. public static ParticleEffect fromName(String name) {
    251. if (name != null)
    252. for (Entry<String, ParticleEffect> e : NAME_MAP.entrySet())
    253. if (e.getKey().equalsIgnoreCase(name))
    254. return e.getValue();
    255. return null;
    256. }
    257.  
    258. /**
    259. * Gets a list of players in a certain range
    260. *
    261. * @param center Center location
    262. * @param range Range
    263. * @return The list of players in the specified range
    264. */
    265. private static List<Player> getPlayers(Location center, double range) {
    266. List<Player> players = new ArrayList<Player>();
    267. String name = center.getWorld().getName();
    268. double squared = range * range;
    269. for (Player p : Bukkit.getOnlinePlayers())
    270. if (p.getWorld().getName().equals(name) && p.getLocation().distanceSquared(center) <= squared)
    271. players.add(p);
    272. return players;
    273. }
    274.  
    275. /**
    276. * Instantiates a new @PacketPlayOutWorldParticles object through reflection
    277. *
    278. * @param center Center location of the effect
    279. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    280. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    281. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    282. * @param speed Display speed of the particles
    283. * @param amount Amount of particles
    284. * @return The packet object
    285. * @throws #PacketInstantiationException if the amount is lower than 1 or if the @PacketPlayOutWorldParticles has changed its name or constructor parameters
    286. */
    287. private static Object instantiatePacket(String name, Location center, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
    288. if (amount < 1)
    289. throw new PacketInstantiationException("Amount cannot be lower than 1");
    290. try {
    291. return packetPlayOutWorldParticles.newInstance(name, (float) center.getX(), (float) center.getY(), (float) center.getZ(), offsetX, offsetY, offsetZ, speed, amount);
    292. } catch (Exception e) {
    293. throw new PacketInstantiationException("Packet instantiation failed", e);
    294. }
    295. }
    296.  
    297. /**
    298. * Instantiates a new @PacketPlayOutWorldParticles object through reflection especially for the "iconcrack" effect
    299. *
    300. * @param id Id of the icon
    301. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    302. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    303. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    304. * @param speed Display speed of the particles
    305. * @param amount Amount of particles
    306. * @return The packet object
    307. * @throws #PacketInstantiationException if the amount is lower than 1 or if the @PacketPlayOutWorldParticles has changed its name or constructor parameters
    308. * @see #instantiatePacket
    309. */
    310. private static Object instantiateIconCrackPacket(int id, Location center, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
    311. return instantiatePacket("iconcrack_" + id, center, offsetX, offsetY, offsetZ, speed, amount);
    312. }
    313.  
    314. /**
    315. * Instantiates a new @PacketPlayOutWorldParticles object through reflection especially for the "blockcrack" effect
    316. *
    317. * @param id Id of the block
    318. * @param data Data value
    319. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    320. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    321. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    322. * @param amount Amount of particles
    323. * @return The packet object
    324. * @throws #PacketInstantiationException if the amount is lower than 1 or if the @PacketPlayOutWorldParticles has changed its name or constructor parameters
    325. * @see #instantiatePacket
    326. */
    327. private static Object instantiateBlockCrackPacket(int id, byte data, Location center, float offsetX, float offsetY, float offsetZ, int amount) {
    328. return instantiatePacket("blockcrack_" + id + "_" + data, center, offsetX, offsetY, offsetZ, 0, amount);
    329. }
    330.  
    331. /**
    332. * Instantiates a new @PacketPlayOutWorldParticles object through reflection especially for the "blockdust" effect
    333. *
    334. * @param id Id of the block
    335. * @param data Data value
    336. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    337. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    338. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    339. * @param speed Display speed of the particles
    340. * @param amount Amount of particles
    341. * @return The packet object
    342. * @throws #PacketInstantiationException if the amount is lower than 1 or if the name or the constructor of @PacketPlayOutWorldParticles have changed
    343. * @see #instantiatePacket
    344. */
    345. private static Object instantiateBlockDustPacket(int id, byte data, Location center, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
    346. return instantiatePacket("blockdust_" + id + "_" + data, center, offsetX, offsetY, offsetZ, speed, amount);
    347. }
    348.  
    349. /**
    350. * Sends a packet through reflection to a player
    351. *
    352. * @param p Receiver of the packet
    353. * @param packet Packet that is sent
    354. * @throws #PacketSendingException if the packet is null or some methods which are accessed through reflection have changed
    355. */
    356. private static void sendPacket(Player p, Object packet) {
    357. try {
    358. sendPacket.invoke(playerConnection.get(getHandle.invoke(p)), packet);
    359. } catch (Exception e) {
    360. throw new PacketSendingException("Failed to send a packet to player '" + p.getName() + "'", e);
    361. }
    362. }
    363.  
    364. /**
    365. * Sends a packet through reflection to a collection of players
    366. *
    367. * @param players Receivers of the packet
    368. * @param packet Packet that is sent
    369. * @throws #PacketSendingException if the sending to a single player fails
    370. * @see #sendPacket
    371. */
    372. private static void sendPacket(Collection<Player> players, Object packet) {
    373. for (Player p : players)
    374. sendPacket(p, packet);
    375. }
    376.  
    377. /**
    378. * Displays a particle effect which is only visible for the specified players
    379. *
    380. * @param center Center location of the effect
    381. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    382. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    383. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    384. * @param speed Display speed of the particles
    385. * @param amount Amount of particles
    386. * @param players Receivers of the effect
    387. * @see #sendPacket
    388. * @see #instantiatePacket
    389. */
    390. public void display(Location center, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
    391. sendPacket(Arrays.asList(players), instantiatePacket(name, center, offsetX, offsetY, offsetZ, speed, amount));
    392. }
    393.  
    394. /**
    395. * Displays a particle effect which is only visible for all players within a certain range in the world of @param center
    396. *
    397. * @param center Center location of the effect
    398. * @param range Range of the visibility
    399. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    400. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    401. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    402. * @param speed Display speed of the particles
    403. * @param amount Amount of particles
    404. * @param players Receivers of the effect
    405. * @throws @IllegalArgumentException if the range is higher than 20
    406. * @see #sendPacket
    407. * @see #instantiatePacket
    408. */
    409. public void display(Location center, double range, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
    410. if (range > MAX_RANGE)
    411. throw new IllegalArgumentException("Range cannot exceed the maximum value of 16");
    412. sendPacket(getPlayers(center, range), instantiatePacket(name, center, offsetX, offsetY, offsetZ, speed, amount));
    413. }
    414.  
    415. /**
    416. * Displays a particle effect which is only visible for all players within a range of 20 in the world of @param center
    417. *
    418. * @param center Center location of the effect
    419. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    420. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    421. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    422. * @param speed Display speed of the particles
    423. * @param amount Amount of particles
    424. * @param players Receivers of the effect
    425. * @see #display(Location, double, float, float, float, float, int)
    426. */
    427. public void display(Location center, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
    428. display(center, MAX_RANGE, offsetX, offsetY, offsetZ, speed, amount);
    429. }
    430.  
    431. /**
    432. * Displays an icon crack (item break) particle effect which is only visible for the specified players
    433. *
    434. * @param center Center location of the effect
    435. * @param id Id of the icon
    436. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    437. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    438. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    439. * @param speed Display speed of the particles
    440. * @param amount Amount of particles
    441. * @param players Receivers of the effect
    442. * @see #sendPacket
    443. * @see #instantiateIconCrackPacket
    444. */
    445. public static void displayIconCrack(Location center, int id, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
    446. sendPacket(Arrays.asList(players), instantiateIconCrackPacket(id, center, offsetX, offsetY, offsetZ, speed, amount));
    447. }
    448.  
    449. /**
    450. * Displays an icon crack (item break) particle effect which is only visible for all players within a certain range in the world of @param center
    451. *
    452. * @param center Center location of the effect
    453. * @param range Range of the visibility
    454. * @param id Id of the icon
    455. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    456. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    457. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    458. * @param speed Display speed of the particles
    459. * @param amount Amount of particles
    460. * @throws @IllegalArgumentException if the range is higher than 20
    461. * @see #sendPacket
    462. * @see #instantiateIconCrackPacket
    463. */
    464. public static void displayIconCrack(Location center, double range, int id, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
    465. if (range > MAX_RANGE)
    466. throw new IllegalArgumentException("Range has to be lower/equal the maximum of 16");
    467. sendPacket(getPlayers(center, range), instantiateIconCrackPacket(id, center, offsetX, offsetY, offsetZ, speed, amount));
    468. }
    469.  
    470. /**
    471. * Displays an icon crack (item break) effect which is visible for all players whitin the maximum range of 20 blocks in the world of @param center
    472. *
    473. * @param center Center location of the effect
    474. * @param id Id of the icon
    475. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    476. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    477. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    478. * @param speed Display speed of the particles
    479. * @param amount Amount of particles
    480. * @see #displayIconCrack(Location, double, int, float, float, float, float, int)
    481. */
    482. public static void displayIconCrack(Location center, int id, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
    483. displayIconCrack(center, MAX_RANGE, id, offsetX, offsetY, offsetZ, speed, amount);
    484. }
    485.  
    486. /**
    487. * Displays a block crack (block break) particle effect which is only visible for the specified players
    488. *
    489. * @param center Center location of the effect
    490. * @param id Id of the block
    491. * @param data Data value
    492. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    493. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    494. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    495. * @param amount Amount of particles
    496. * @param players Receivers of the effect
    497. * @see #sendPacket
    498. * @see #instantiateBlockCrackPacket
    499. */
    500. public static void displayBlockCrack(Location center, int id, byte data, float offsetX, float offsetY, float offsetZ, int amount, Player... players) {
    501. sendPacket(Arrays.asList(players), instantiateBlockCrackPacket(id, data, center, offsetX, offsetY, offsetZ, amount));
    502. }
    503.  
    504. /**
    505. * Displays a block crack (block break) particle effect which is only visible for all players within a certain range in the world of @param center
    506. *
    507. * @param center Center location of the effect
    508. * @param range Range of the visibility
    509. * @param id Id of the block
    510. * @param data Data value
    511. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    512. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    513. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    514. * @param amount Amount of particles
    515. * @throws @IllegalArgumentException if the range is higher than 20
    516. * @see #sendPacket
    517. * @see #instantiateBlockCrackPacket
    518. */
    519. public static void displayBlockCrack(Location center, double range, int id, byte data, float offsetX, float offsetY, float offsetZ, int amount) {
    520. if (range > MAX_RANGE)
    521. throw new IllegalArgumentException("Range has to be lower/equal the maximum of 16");
    522. sendPacket(getPlayers(center, range), instantiateBlockCrackPacket(id, data, center, offsetX, offsetY, offsetZ, amount));
    523. }
    524.  
    525. /**
    526. * Displays a block crack (block break) effect which is visible for all players whitin the maximum range of 20 blocks in the world of @param center
    527. *
    528. * @param center Center location of the effect
    529. * @param id Id of the block
    530. * @param data Data value
    531. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    532. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    533. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    534. * @param amount Amount of particles
    535. * @see #displayBlockCrack(Location, double, int, byte, float, float, float, int)
    536. */
    537. public static void displayBlockCrack(Location center, int id, byte data, float offsetX, float offsetY, float offsetZ, int amount) {
    538. displayBlockCrack(center, MAX_RANGE, id, data, offsetX, offsetY, offsetZ, amount);
    539. }
    540.  
    541. /**
    542. * Displays a block dust particle effect which is only visible for the specified players
    543. *
    544. * @param center Center location of the effect
    545. * @param id Id of the block
    546. * @param data Data value
    547. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    548. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    549. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    550. * @param speed Display speed of the particles
    551. * @param amount Amount of particles
    552. * @param players Receivers of the effect
    553. * @see #sendPacket
    554. * @see #instantiateBlockDustPacket
    555. */
    556. public static void displayBlockDust(Location center, int id, byte data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
    557. sendPacket(Arrays.asList(players), instantiateBlockDustPacket(id, data, center, offsetX, offsetY, offsetZ, speed, amount));
    558. }
    559.  
    560. /**
    561. * Displays a block dust particle effect which is only visible for all players within a certain range in the world of @param center
    562. *
    563. * @param center Center location of the effect
    564. * @param range Range of the visibility
    565. * @param id Id of the block
    566. * @param data Data value
    567. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    568. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    569. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    570. * @param speed Display speed of the particles
    571. * @param amount Amount of particles
    572. * @throws @IllegalArgumentException if the range is higher than 20
    573. * @see #sendPacket
    574. * @see #instantiateBlockDustPacket
    575. */
    576. public static void displayBlockDust(Location center, double range, int id, byte data, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
    577. if (range > MAX_RANGE)
    578. throw new IllegalArgumentException("Range has to be lower/equal the maximum of 16");
    579. sendPacket(getPlayers(center, range), instantiateBlockDustPacket(id, data, center, offsetX, offsetY, offsetZ, speed, amount));
    580. }
    581.  
    582. /**
    583. * Displays a block dust effect which is visible for all players whitin the maximum range of 20 blocks in the world of @param center
    584. *
    585. * @param center Center location of the effect
    586. * @param id Id of the block
    587. * @param data Data value
    588. * @param offsetX Maximum distance particles can fly away from the center on the x-axis
    589. * @param offsetY Maximum distance particles can fly away from the center on the y-axis
    590. * @param offsetZ Maximum distance particles can fly away from the center on the z-axis
    591. * @param speed Display speed of the particles
    592. * @param amount Amount of particles
    593. * @see #displayBlockDust(Location, double, int, byte, float, float, float, float, int)
    594. */
    595. public static void displayBlockDust(Location center, int id, byte data, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
    596. displayBlockDust(center, MAX_RANGE, id, data, offsetX, offsetY, offsetZ, speed, amount);
    597. }
    598.  
    599. /**
    600. * Represents a runtime exception that can be thrown upon packet instantiation
    601. */
    602. private static final class PacketInstantiationException extends RuntimeException {
    603. private static final long serialVersionUID = 3203085387160737484L;
    604.  
    605. /**
    606. * @param message Message that will be logged
    607. */
    608. public PacketInstantiationException(String message) {
    609. super(message);
    610. }
    611.  
    612. /**
    613. * @param message Message that will be logged
    614. * @param cause Cause of the exception
    615. */
    616. public PacketInstantiationException(String message, Throwable cause) {
    617. super(message, cause);
    618. }
    619. }
    620.  
    621. /**
    622. * Represents a runtime exception that can be thrown upon packet sending
    623. */
    624. private static final class PacketSendingException extends RuntimeException {
    625. private static final long serialVersionUID = 3203085387160737484L;
    626.  
    627. /**
    628. * @param message Message that will be logged
    629. * @param cause Cause of the exception
    630. */
    631. public PacketSendingException(String message, Throwable cause) {
    632. super(message, cause);
    633. }
    634. }
    635. }

    Your probably looking for the Effect CLOUD so:
    ParticleEffect.CLOUD.display(loc, 0, 1, 0, 0, 2);
    That would probably do it
     
  7. Offline

    JordyPwner

    Onlineids nope got a error

    error:
    Show Spoiler
    [09:03:10 ERROR]: Could not pass event ProjectileHitEvent to Guns v1.0.0
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:320) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:486) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:471) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callProjectile
    HitEvent(CraftEventFactory.java:609) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b302
    0jnks]
    at net.minecraft.server.v1_7_R1.EntityProjectile.h(EntityProjectile.java
    :158) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.World.entityJoinedWorld(World.java:1348)
    [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.World.playerJoinedWorld(World.java:1329)
    [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.World.tickEntities(World.java:1217) [cra
    ftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.WorldServer.tickEntities(WorldServer.jav
    a:480) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    37) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused by: java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljav
    a/util/Collection;
    at me.jordypwner.guns.ParticleEffect.getPlayers(ParticleEffect.java:269)
    ~[?:?]
    at me.jordypwner.guns.ParticleEffect.display(ParticleEffect.java:412) ~[
    ?:?]
    at me.jordypwner.guns.ParticleEffect.display(ParticleEffect.java:428) ~[
    ?:?]
    at me.jordypwner.guns.SnowballHit.onProjectileHit(SnowballHit.java:37) ~
    [?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0
    _60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0
    _60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_60]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_60]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:318) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    ... 14 more


    My Class:

    Show Spoiler

    Code:java
    1. package me.jordypwner.guns;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Effect;
    5. import org.bukkit.Material;
    6. import org.bukkit.Sound;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.entity.Snowball;
    9. import org.bukkit.event.EventHandler;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.entity.ProjectileHitEvent;
    12. import org.bukkit.event.player.PlayerJoinEvent;
    13.  
    14. public class SnowballHit
    15. implements Listener
    16. {
    17. @EventHandler
    18. public void onPlayerJoin(PlayerJoinEvent e)
    19. {
    20.  
    21. }
    22.  
    23. @EventHandler
    24. public void onProjectileHit(ProjectileHitEvent e)
    25. {
    26. if ((e.getEntity() instanceof Snowball))
    27. {
    28. Snowball s = (Snowball)e.getEntity();
    29. if ((s.getShooter() instanceof Player))
    30. {
    31. Player p = (Player)s.getShooter();
    32. if (p.hasPermission("hub.hub"))
    33. {
    34. p.playSound(p.getLocation(), Sound.CHICKEN_EGG_POP, 2.0F, 2.0F);
    35. p.playEffect(s.getLocation(), Effect.SMOKE, 1);
    36. p.playEffect(s.getLocation(), Effect.ENDER_SIGNAL, 1);
    37. ParticleEffect.CLOUD.display(s.getLocation(), 0, 1, 0, 0, 2);
    38. s.remove();
    39.  
    40. }else{
    41. p.sendMessage(ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "[" + ChatColor.YELLOW + "" + ChatColor.BOLD + "Aurum" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "]" + ChatColor.RED + "You must be a" + ChatColor.DARK_BLUE + "" + ChatColor.BOLD + " Donator" + ChatColor.RED + " or above to use the Bow!");
    42. p.sendMessage(ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "[" + ChatColor.YELLOW + "" + ChatColor.BOLD + "Aurum" + ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "]" + ChatColor.RED + "Purchase it at [url]http://aurumnetwork.enjin.com[/url]");
    43. return;
    44. }
    45. }
    46. }
    47. }
    48. }
     
  8. Offline

    Onlineids

    JordyPwner What version of bukkit are you using?
     
  9. Offline

    JordyPwner

    Onlineids 1.7.2 and i tried 1.7.9 and 1.7.10
     
  10. Offline

    PePsiGam3r

    JordyPwner Let me see what you have typed in line 37 on your SnowballHit.java class.
     
  11. Offline

    JordyPwner

    PePsiGam3r

    ParticleEffect.CLOUD.display(p.getLocation(), 0, 1, 0, 0, 2);
     
  12. Offline

    PePsiGam3r

    Try to not set the float objects to ZERO then tell me what happen.
     
  13. Offline

    JordyPwner

    PePsiGam3r

    Show Spoiler
    [10:27:43 ERROR]: Could not pass event ProjectileHitEvent to Guns v1.0.0
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:320) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:486) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:471) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callProjectile
    HitEvent(CraftEventFactory.java:609) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b302
    0jnks]
    at net.minecraft.server.v1_7_R1.EntityProjectile.h(EntityProjectile.java
    :158) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.World.entityJoinedWorld(World.java:1348)
    [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.World.playerJoinedWorld(World.java:1329)
    [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.World.tickEntities(World.java:1217) [cra
    ftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.WorldServer.tickEntities(WorldServer.jav
    a:480) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    37) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused by: java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljav
    a/util/Collection;
    at me.jordypwner.guns.ParticleEffect.getPlayers(ParticleEffect.java:269)
    ~[?:?]
    at me.jordypwner.guns.ParticleEffect.display(ParticleEffect.java:412) ~[
    ?:?]
    at me.jordypwner.guns.ParticleEffect.display(ParticleEffect.java:428) ~[
    ?:?]
    at me.jordypwner.guns.SnowballHit.onProjectileHit(SnowballHit.java:37) ~
    [?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0
    _60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0
    _60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_60]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_60]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:318) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    ... 14 more


    class: http://pastebin.com/8gg6wBgJ
    line 37: ParticleEffect.CLOUD.display(p.getLocation(), 1, 1, 1, 1, 2);
     
  14. Offline

    ulsa

    NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()
    o.O well how can there not be a method Bukkit.getOnlinePlayers()
     
  15. Offline

    JordyPwner

  16. Offline

    Onlineids

    JordyPwner You probably have your imports screwed up
     
  17. Offline

    JordyPwner

  18. Offline

    ChipDev

    What? Its error has to do with the ProjectileHitEvent, not the lib.
    Onlineids Yes, :p
     
  19. ChipDev The issue is that there is no Bukkit.getOnlinePlayers() and that is only used in the lib therefor its a lib and also a Bukkit issue,
     
  20. Offline

    ChipDev

    I bet he did
    Player p = getServer().getOnlinePlayers()
    not
    Player[] p = getServer().getOnlinePlayers()
    Even if he did, Player[] would not be used...
    so he should of done
    for(Player p : getServer().getOnlinePlayers()) {}
     
  21. ChipDev No he did for(Player p : Bukkit.getOnlinePlayers(){} I have seen it.
     
  22. Offline

    ChipDev

    Oh..
     
  23. Offline

    fireblast709

    ulsa JordyPwner ChipDev bwfcwalshy stay up do date, lol. Somewhere around 1.7.10 Bukkit switched from a Player[] to a Collection<? extends Player>. Conclusion: your Bukkit depend / server are outdated compared to the lib you try to use.
     
  24. Offline

    ChipDev

    I'm ancient! AKA Im αρχαία!
     
  25. Offline

    JordyPwner

    fireblast709 maybe you should read better -.- i tried on: 1.7.2 1.7.9 AND 1.7.10 sjeez people should learn to read
     
  26. Offline

    fireblast709

    For a fact I do read. I read stacktraces. "Somewhere around 1.7.10" implies it could be any 1.7.10 release. The latest dev build uses Collection<? extends Player>, Mr. 'Do you even read'.
     
Thread Status:
Not open for further replies.

Share This Page