1

Please help with particles!

Ecliqse 7/1/19 9:13 am history
301
Hey, Im doing a tutorial for a discord server and messing with particles, and I changed to developing in 1.13.2, and I have a problemo. I have a runnable that is supposed to spawn particles in whatever like shape I want so I made it like a helix that goes higher all the time but unfortuaneytly its supposed to despawn the particles after about 30 seconds or so, but instead of despawning the particles, it also cancels the event whenever a player tries to trigger it again. How can I make it ONLY despawn the particles, instead of not let itself be triggered anymore? Heres my code:


package com.Zekeplayzz.Particles;














import org.bukkit.Bukkit;


import org.bukkit.Location;


import org.bukkit.Particle;


import org.bukkit.entity.Player;


import org.bukkit.event.EventHandler;


import org.bukkit.event.Listener;


import org.bukkit.event.player.PlayerToggleSneakEvent;


import org.bukkit.plugin.java.JavaPlugin;






public class Main extends JavaPlugin implements Listener {






private int counter;






public void onEnable() {


Bukkit.getPluginManager().registerEvents(this, this);


System.out.println("Working");






}






@EventHandler






public boolean onSneak(PlayerToggleSneakEvent e) {


Player player = e.getPlayer();










counter = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {


Location loc = player.getLocation();


double t = 0;


double r = 2;






public void run() {


t = t + Math.PI/16;


double x = r*Math.cos(t);


double y = 0.5*t;


double z = 4*Math.sin(t);


loc.add(x, y, z);


player.getWorld().spawnParticle(Particle.FLAME, loc, 0, 0, 0, 0, 1);


loc.subtract(x, y, z);


if (t > Math.PI*16) {





}










}










}, 2l, 0l);














return false;


}














}
Posted by
Ecliqse
Level 3 : Apprentice Network
2

  Have something to say?

JoinSign in

Welcome