Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1. package spiel;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import org.bukkit.Location;
  6. import org.bukkit.Material;
  7. import org.bukkit.Sound;
  8. import org.bukkit.block.Block;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.potion.PotionEffect;
  11. import org.bukkit.potion.PotionEffectType;
  12. import org.bukkit.scheduler.BukkitRunnable;
  13. import org.bukkit.util.Vector;
  14.  
  15. import SpigotComplements.Particle;
  16. import crazy.Crazy;
  17. import gameverlauf.Gameverlauf;
  18. import lobby.VoteGUI;
  19. import net.minecraft.server.v1_12_R1.EnumParticle;
  20.  
  21. public class Ultimate {
  22.  
  23. public static void manageUltimateBar(Location loc) {
  24. createBar(loc, 10);
  25. }
  26.  
  27. private static void createBar(final Location loc, final int currentBarLevel) {
  28. if(currentBarLevel > 10 || currentBarLevel<1) return;
  29. final ArrayList<Block> blocks = createBlocks(loc, currentBarLevel);
  30. BukkitRunnable bukRun = new BukkitRunnable() {
  31. @Override
  32. public void run() {
  33. for(Block block:blocks) {
  34. block.setType(Material.AIR);
  35. }
  36. blocks.clear();
  37.  
  38. if(currentBarLevel==1) {
  39. for(Player p : Gameverlauf.ingame) {
  40. p.playSound(loc, Sound.ENTITY_ENDERDRAGON_GROWL, 3f, 1f);
  41. p.sendMessage("§6§lULTIMATE!");
  42. p.teleport(new Location(loc.getWorld(), loc.getBlockX(), loc.getY()+12, loc.getBlockZ()));
  43. p.setVelocity(new Vector(0,10,0));
  44. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 300, 5));
  45. p.sendMessage("§7>>> §6§lULTIMATIVE BESCHLEUNIGUNG");
  46. p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 300, 5));
  47. p.sendMessage("§7>>> §6§lULTIMATIVE STÄRKE");
  48.  
  49. }
  50. for (Integer spawn=0; spawn < VoteGUI.WINNER.getSpawns().size(); spawn++) {
  51. for(int i = 0; i<=60; i++) {
  52. Particle particle = new Particle(EnumParticle.VILLAGER_HAPPY, VoteGUI.WINNER.getSpawns().get(spawn).clone().add(0,i,0), true, 0.1f, 0.1f, 0.1f, 1, 4);
  53. particle.sendAll();
  54. }
  55. }
  56. manageUltimateBar(loc);
  57. } else {
  58. createBar(loc, currentBarLevel-1);
  59. }
  60. cancel();
  61. }
  62. };
  63. bukRun.runTaskLater(Crazy.plugin, 20l*12);
  64. }
  65.  
  66. @SuppressWarnings("deprecation")
  67. private static ArrayList<Block> createBlocks(Location loc, Integer currentBarLevel) {
  68. int byteInt = currentBarLevel < 2 ? 14 : (currentBarLevel < 4 ? 1 : (currentBarLevel < 6 ? 4 : 13));
  69. ArrayList<Block> blocks = new ArrayList<>();
  70. for (Integer i = 0; i < 10; i++) {
  71. final Block block = loc.getWorld()
  72. .getBlockAt(new Location(loc.getWorld(), loc.getX(), loc.getY() + i, loc.getZ()));
  73. if (i < currentBarLevel) {
  74. block.setType(Material.STAINED_CLAY);
  75. blocks.add(block);
  76. } else {
  77. block.setType(Material.AIR);
  78. }
  79. }
  80.  
  81. for (Integer i = 0; i < 10; i++) {
  82. final Block glass = loc.getWorld()
  83. .getBlockAt(new Location(loc.getWorld(), loc.getX() + 1, loc.getY() + i, loc.getZ()));
  84. glass.setType(Material.STAINED_GLASS);
  85.  
  86. final Block glass2 = loc.getWorld()
  87. .getBlockAt(new Location(loc.getWorld(), loc.getX() - 1, loc.getY() + i, loc.getZ()));
  88. glass2.setType(Material.STAINED_GLASS);
  89.  
  90. final Block glass3 = loc.getWorld()
  91. .getBlockAt(new Location(loc.getWorld(), loc.getX(), loc.getY() + i, loc.getZ() + 1));
  92. glass3.setType(Material.STAINED_GLASS);
  93.  
  94. final Block glass4 = loc.getWorld()
  95. .getBlockAt(new Location(loc.getWorld(), loc.getX(), loc.getY() + i, loc.getZ() - 1));
  96. glass4.setType(Material.STAINED_GLASS);
  97.  
  98. blocks.add(glass);
  99. blocks.add(glass2);
  100. blocks.add(glass3);
  101. blocks.add(glass4);
  102. }
  103. for(int i = 0; i < 1; i++) {
  104. final Block edge = loc.getWorld().getBlockAt(new Location(loc.getWorld(), loc.getX(), loc.getY() + (11*i)-1, loc.getZ()));
  105. edge.setType(Material.STAINED_GLASS);
  106. blocks.add(edge);
  107. }
  108.  
  109. for (Block block : blocks) {
  110. block.setData((byte) byteInt);
  111. }
  112. return blocks;
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement