Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. package me.RDev.ParticlesEffects;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.entity.Player;
  8.  
  9. import me.RDev.CosmeticsTreasure;
  10. import me.RDev.PlayerSettings;
  11. import me.RDev.TreasureChest.GadgetsType;
  12. import me.RDev.nmsClasses.Effects.ParticleEffect;
  13. import me.RDev.nmsClasses.Effects.ParticleEffect.ParticleType;
  14.  
  15. public class FrostLord {
  16.  
  17. final public static HashMap<Player, Integer> countdown = new HashMap<Player, Integer>();
  18.  
  19. public static GadgetsType playfrostlord(final Player p) {
  20. int r = Bukkit.getScheduler()
  21. .runTaskTimer(
  22. CosmeticsTreasure.getPlugin(),
  23. new Runnable() {
  24.  
  25. double t = 0;
  26. double pi = Math.PI;
  27. public void run(){
  28. if(!p.isOnline()) cancel(p);
  29. t += pi / 13;
  30. Location loc = p.getLocation();
  31. for(double phi = 0; phi <= 2 * pi; phi += pi / 3){
  32. double x = 0.2 * (4 * pi - t) * Math.cos(t + phi);
  33. double y = 0.2 * t;
  34. double z = 0.2 * (4 * pi - t) * Math.sin(t + phi);
  35. loc.add(x,y,z);
  36. new ParticleEffect(ParticleType.SNOW_SHOVEL,loc, 0.0f, 1, 0.0f);
  37. loc.subtract(x,y,z);
  38.  
  39.  
  40. if(t >= 4 * pi){
  41. t = 0; phi = 0;
  42. loc.add(x,y,z);
  43. new ParticleEffect(ParticleType.SNOW_SHOVEL,loc, 1, 60, 0.1f);
  44. loc.subtract(x,y,z);
  45. }
  46. }
  47. }
  48. }, 0, 1).getTaskId();
  49. countdown.put(p, r);
  50. PlayerSettings.getPlayersParticlesEffects().put(p.getName(), GadgetsType.FrostLord);
  51. return GadgetsType.FrostLord;
  52. }
  53.  
  54. public static void cancel(Player p)
  55. {
  56. if (countdown.containsKey(p))
  57. {
  58. Bukkit.getServer().getScheduler().cancelTask(((Integer)countdown.get(p)).intValue());
  59. countdown.remove(p);
  60. PlayerSettings.getPlayersParticlesEffects().put(p.getName(), null);
  61. }
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement