Advertisement
Guest User

Rede_Galak_Trevas_Win_Animation

a guest
Feb 28th, 2020
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.25 KB | None | 0 0
  1.     public static List<Player> animation = new ArrayList<>();
  2.    
  3.     public static String candle = "http://textures.minecraft.net/texture/f79c7a2c7350b0f361502c0e06dab0fd2c0859e237df544d20cd3447b0c75fcf";
  4.     public static String skull = "http://textures.minecraft.net/texture/660932b2c224b7c2163cbac05f286a06e6922527b03667c4e96f728e5c4ffb66";
  5.    
  6.     public static ItemStack getSkull(String url) {
  7.         ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
  8.         if (url == null || url.isEmpty()) return skull;
  9.        
  10.         SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
  11.         GameProfile profile = new GameProfile(UUID.randomUUID(), null);
  12.         byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
  13.         profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
  14.         Field profileField = null;
  15.    
  16.         try {
  17.             profileField = skullMeta.getClass().getDeclaredField("profile");
  18.         }catch (NoSuchFieldException | SecurityException e) {
  19.             e.printStackTrace();
  20.         }
  21.    
  22.         profileField.setAccessible(true);
  23.    
  24.         try {
  25.             profileField.set(skullMeta, profile);
  26.         }catch (IllegalArgumentException | IllegalAccessException e) {
  27.             e.printStackTrace();
  28.         }
  29.    
  30.         skull.setItemMeta(skullMeta);
  31.         return skull;
  32.     }
  33.    
  34.     public static void iniciar(Player jogador) {
  35.         World w = jogador.getLocation().getWorld();
  36.        
  37.         animation.add(jogador);
  38.        
  39.         w.strikeLightning(jogador.getLocation().clone().add(0, 0.5, 0));
  40.        
  41.         int points = 8;
  42.         for (int i = 0; i < 360; i += 360/points) {
  43.             double angle = (i * Math.PI / 180);
  44.             double bx = 4 * Math.cos(angle);
  45.             double bz = 4 * Math.sin(angle);
  46.             double x = 0 * Math.cos(angle);
  47.             double z = 0 * Math.sin(angle);
  48.             Location bases = jogador.getLocation().clone().add(bx, 0, bz);
  49.             Location candles = jogador.getLocation().clone().add(x, 0.8, z);
  50.             ArmorStand as = (ArmorStand) w.spawnEntity(candles, EntityType.ARMOR_STAND);
  51.             as.setMetadata("candle", new FixedMetadataValue(Main.plugin, new Object()));
  52.             ParticleEffect.LAVA.display(as.getEyeLocation(), 0, 0, 0, 5, 0, 15);
  53.             as.setCustomNameVisible(false);
  54.             as.setGravity(false);
  55.             as.setVisible(false);
  56.             as.setHelmet(getSkull(candle));
  57.             as.getWorld().playSound(as.getEyeLocation(), Sound.LAVA_POP, 6F, 5F);
  58.             new BukkitRunnable() {
  59.                 public void run() {
  60.                     as.teleport(bases);
  61.                    
  62.                 }
  63.             }.runTaskLaterAsynchronously(Main.plugin, 2 * 20L);
  64.         }
  65.        
  66.         int fires = new BukkitRunnable() {
  67.             public void run() {
  68.                 for (Entity entities : w.getEntities()) {
  69.                     if (entities instanceof ArmorStand) {
  70.                         ArmorStand candles = (ArmorStand) entities;
  71.                         Location l = candles.getEyeLocation();
  72.                         ParticleEffect.FLAME.display(l.add(0.0D, 0.4D, 0.0D), 15, 0, 0, 0, 0, 10);
  73.                         ParticleEffect.SMOKE_NORMAL.display(l.add(0.0D, 0.4D, 0.0D), 15, 0, 0, 0, 0, 10);
  74.                     }
  75.                 }
  76.             }
  77.         }.runTaskTimerAsynchronously(Main.plugin, 0L, 20L).getTaskId();
  78.        
  79.         int yaws = new BukkitRunnable() {
  80.             float yaw = 0.0F;
  81.             public void run() {
  82.                 for (Entity entities : w.getEntities()) {
  83.                     if (entities instanceof ArmorStand) {
  84.                         ArmorStand candles = (ArmorStand) entities;
  85.                         if (candles.hasMetadata("candle")) {
  86.                             Location l = candles.getLocation();
  87.                             l.setYaw(l.getYaw() + yaw);
  88.                             candles.teleport(l);
  89.                         }
  90.                     }
  91.                 }
  92.                 yaw += 0.2F;
  93.             }
  94.         }.runTaskTimerAsynchronously(Main.plugin, 1L, 1L).getTaskId();
  95.        
  96.         jogador.getEquipment().setArmorContents(null);
  97.         jogador.getEquipment().setHelmet(getSkull(skull));
  98.        
  99.         ItemStack c = Item.addItem(Material.LEATHER_CHESTPLATE, 1);
  100.         LeatherArmorMeta lam = (LeatherArmorMeta) c.getItemMeta();
  101.         lam.setColor(Color.BLACK);
  102.         c.setItemMeta(lam);
  103.         jogador.getEquipment().setChestplate(c);
  104.        
  105.         int particulas = new BukkitRunnable() {
  106.             float i = 0.0F;
  107.             public void run() {
  108.                 for (int k = 0; k < 1; k++) {
  109.                     Location local = jogador.getLocation();
  110.                     double x = Math.sin(this.i * 3.7F);
  111.                     double y = Math.cos(this.i * 3.7F);
  112.                     double z = this.i * 0.4F;
  113.                     Vector v = new Vector(x, z, y);
  114.                     local.add(v);
  115.                     ParticleEffect.CRIT.display(local.add(0, 0, 0), 0, 0, 0, 10, 0, 25.0D);
  116.                 }
  117.                 this.i += 0.1F;
  118.                 if (this.i > 5.0F) {
  119.                     this.i = 0.0F;
  120.                 }
  121.             }
  122.         }.runTaskTimerAsynchronously(Main.plugin, 1L, 1L).getTaskId();
  123.        
  124.         new BukkitRunnable() {
  125.             public void run() {
  126.                 Bukkit.getScheduler().cancelTask(yaws);
  127.                 Bukkit.getScheduler().cancelTask(fires);
  128.                 Bukkit.getScheduler().cancelTask(particulas);
  129.                 for (Entity entities : w.getEntities()) {
  130.                     if (entities instanceof ArmorStand) {
  131.                         ArmorStand candles = (ArmorStand) entities;
  132.                         if (candles.hasMetadata("candle")) {
  133.                             ParticleEffect.SMOKE_LARGE.display(candles.getEyeLocation(), 0, 0, 0, 5, 0, 15);
  134.                             candles.getWorld().playSound(candles.getEyeLocation(), Sound.CHICKEN_EGG_POP, 3F, 2F);
  135.                             candles.remove();
  136.                         }
  137.                         jogador.getEquipment().setArmorContents(null);
  138.                         animation.remove(jogador);
  139.                     }
  140.                 }
  141.             }
  142.         }.runTaskLaterAsynchronously(Main.plugin, 5 * 20L);
  143.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement