Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ua.coolboy.skullfinder;
- import org.bukkit.Bukkit;
- import org.bukkit.Color;
- import org.bukkit.FireworkEffect;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.Particle;
- import org.bukkit.Sound;
- import org.bukkit.World;
- import org.bukkit.block.Skull;
- import org.bukkit.entity.ArmorStand;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.SkullMeta;
- import org.bukkit.scheduler.BukkitRunnable;
- public class StandFlyRunnable extends BukkitRunnable {
- ArmorStand stand;
- Skull skull;
- World world;
- public StandFlyRunnable(ArmorStand stand, Skull skull) {
- this.stand = stand;
- this.skull = skull;
- this.world = stand.getWorld();
- }
- @Override
- public void run() {
- stand.setGravity(false);
- stand.setMarker(false);
- stand.setInvulnerable(true);
- stand.setVisible(false);
- stand.setCustomNameVisible(false);
- stand.setCustomName("Flying Skull");
- double start = stand.getHeadPose().getY();
- int skip = 0;
- synchronized (this) {
- for (int i = 0; i < 1000; i++) {
- Location location = stand.getLocation();
- location.add(0, 0.006, 0);
- stand.teleport(location);
- double rad = Math.pow((float)i / 400, 2) * Math.PI;
- stand.setHeadPose(stand.getHeadPose().setY(start + rad));
- skip++;
- if(skip % 4 == 0) {
- world.spawnParticle(Particle.REDSTONE, stand.getEyeLocation().subtract(0, 0.5, 0), 0, Float.MIN_VALUE, 1, 0.5, 1);
- }
- if (skip == 15) {
- world.playSound(stand.getLocation(), Sound.BLOCK_NOTE_HARP, 0.5F, 0);
- }
- if (skip >= 40) {
- world.playSound(stand.getLocation(), Sound.BLOCK_NOTE_HARP, 0.5F, 1);
- skip = 0;
- }
- try {
- this.wait(5);
- } catch (InterruptedException ex) {
- Bukkit.getLogger().warning("Oops! Something went wrong during stand fly!");
- stand.remove();
- this.cancel();
- break;
- }
- }
- stand.remove();
- new BukkitRunnable() {
- @Override
- public void run() {
- FireworkUtil.custom(stand.getEyeLocation(), 1, true, Color.BLUE, Color.RED, Color.SILVER, FireworkEffect.Type.BURST, true);
- }
- }.runTask(SkullFinder.getInstance());
- }
- this.cancel();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement