Advertisement
Lisenochek

Untitled

Nov 5th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. private void blockMode(Player player) {
  2.  
  3. List<Drop> dropList = new ArrayList<>();
  4.  
  5. for (Drop drop : DropConfig.getConfig().getDrops()) for (int chance = 0; chance < drop.getChance(); chance++) dropList.add(drop);
  6.  
  7. Collections.shuffle(dropList);
  8. titleHologram.clearLines();
  9.  
  10. new BukkitRunnable() {
  11.  
  12. int ticks = 0;
  13. boolean isOpened = false;
  14.  
  15. @Override
  16. public void run() {
  17.  
  18. ticks++;
  19.  
  20. if (!isOpened) {
  21. double radius = 5 / (double) ticks * 20;
  22.  
  23. Bukkit.broadcastMessage(String.valueOf(radius));
  24.  
  25. if (ticks % 4 == 0) location.getWorld().playSound(location, Sound.BLOCK_NOTE_GUITAR, 1, (float) radius);
  26.  
  27. double increment = (2 * Math.PI) / 25;
  28.  
  29. for (int i = 0; i < 25; i++) {
  30. double angle = i * increment;
  31. double x = radius * Math.cos(angle);
  32. double z = radius * Math.sin(angle);
  33. Utils.playEffect(location.clone().add(x + 0.5D, 0.5D, z + 0.5D), false, false, 0, 0, 0, 0, EnumWrappers.Particle.FLAME, Material.AIR, 1);
  34. }
  35. }
  36.  
  37. if (ticks % (Config.ROLL_TIME.getInteger() * 20) == 0) {
  38.  
  39. Drop drop = dropList.get(Utils.getRandom().nextInt(dropList.size()));
  40.  
  41. for (Player players : Bukkit.getOnlinePlayers()) player.sendMessage(Utils.getPrefix() + Utils.stripColor(drop.getWinMessage().replace("%player%", player.getName())));
  42. titleHologram.appendTextLine(Utils.stripColor(drop.getDisplayItem().getItemMeta().getDisplayName())).getParent().appendItemLine(drop.getDisplayItem());
  43. location.getWorld().playSound(location, Sound.ENTITY_GENERIC_EXPLODE, 1, 1.5f);
  44. isOpened = true;
  45. return;
  46. }
  47.  
  48. if (ticks % ((Config.ROLL_TIME.getInteger() * 20) + 100) != 0) return;
  49.  
  50. isUsed = false;
  51. titleHologram.clearLines();
  52. titleHologram = HologramsAPI.createHologram(Main.plugin, location.clone().add(0.5D, 2, 0.5D)).appendTextLine(Utils.stripColor(Config.MESSAGE_HOLO_CASE_NAME.getString())).getParent().appendTextLine(Utils.stripColor(Config.MESSAGE_HOLO_HELP.getString())).getParent();
  53. cancel();
  54. }
  55. }.runTaskTimer(Main.plugin, 1, 1);
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement