Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Particle{ // Our Class
- public ArrayList<Entity> arraylist = new ArrayList<Entity>();
- Plugin plugin; // Creating a new Plugin Object
- public Particles(Plugin plugin){ // Creating a method that passes through a Plugin Object
- this.plugin = plugin; // Setting 'Plugin' to the Main class, to use instead of 'this.'
- }
- public void EntityParticles(Plugin plugin, Player player, Entity entity, EnumParticle enumparticle,
- int ParticleSize, int ParticleSpeed, int ParticleAmount){
- //Creating a Method with the required Objects.
- arraylist.add(entity); //Adding in passed entity to arraylist
- Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
- //Creating a constant repeating task ^^ We'll pass though the plugin object we made earlier
- @Override
- public void run() {
- if(arraylist.contains(entity)){ //Checking if the arraylist contains the entity to make sure it wasn't removed
- float x = (float) entity.getLocation().getX();//getting the entities X location and casting it as a float
- float y = (float) entity.getLocation().getY();//getting the entities Y location and casting it as a float
- float z = (float) entity.getLocation().getZ();//getting the entities Z location and casting it as a float
- PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(
- enumparticle,true, x, y, z, ParticleSize, ParticleSize, ParticleSize, ParticleSize, ParticleAmount);
- //creating the particle with the information we got at the pos of the entity
- ((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
- //Sending the player that was passed through the packet, casting it as CraftPlayer due to Player not having //the getHandle() Method to send packets.
- }
- }
- }, 0L, 0L); //This is the delay that will happen each time this runnable is repeated.
- }
- public void RemoveEntityParticles(Entity entity){
- if(ent.contains(entity)){
- ent.remove(entity);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement