Advertisement
Guest User

Untitled

a guest
Jul 14th, 2015
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Particle{ // Our Class
  2. public ArrayList<Entity> arraylist = new ArrayList<Entity>();
  3. Plugin plugin; // Creating a new Plugin Object
  4.  
  5. public Particles(Plugin plugin){ // Creating a method that passes through a Plugin Object
  6.  
  7. this.plugin = plugin; // Setting 'Plugin' to the Main class, to use instead of 'this.'
  8.  
  9. }
  10.  
  11. public void EntityParticles(Plugin plugin, Player player, Entity entity, EnumParticle enumparticle,
  12. int ParticleSize, int ParticleSpeed, int ParticleAmount){
  13. //Creating a Method with the required Objects.
  14.  
  15. arraylist.add(entity); //Adding in passed entity to arraylist
  16.  
  17. Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
  18. //Creating a constant repeating task ^^ We'll pass though the plugin object we made earlier
  19.  
  20. @Override
  21. public void run() {
  22. if(arraylist.contains(entity)){ //Checking if the arraylist contains the entity to make sure it wasn't removed
  23.  
  24. float x = (float) entity.getLocation().getX();//getting the entities X location and casting it as a float
  25. float y = (float) entity.getLocation().getY();//getting the entities Y location and casting it as a float
  26. float z = (float) entity.getLocation().getZ();//getting the entities Z location and casting it as a float
  27.  
  28. PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(
  29. enumparticle,true, x, y, z, ParticleSize, ParticleSize, ParticleSize, ParticleSize, ParticleAmount);
  30. //creating the particle with the information we got at the pos of the entity
  31.  
  32. ((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
  33. //Sending the player that was passed through the packet, casting it as CraftPlayer due to Player not having //the getHandle() Method to send packets.
  34.  
  35.  
  36. }
  37. }
  38. }, 0L, 0L); //This is the delay that will happen each time this runnable is repeated.
  39.  
  40. }
  41.  
  42. public void RemoveEntityParticles(Entity entity){
  43.  
  44. if(ent.contains(entity)){
  45.  
  46. ent.remove(entity);
  47.  
  48. }
  49.  
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement