Advertisement
SrinjoySS01

Untitled

Feb 21st, 2021
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.69 KB | None | 0 0
  1. package me.ryan.TNTEveryMinUHC.commands;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.World;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandExecutor;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.EntityType;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.scheduler.BukkitScheduler;
  13. import org.bukkit.Location;
  14. import org.bukkit.Material;
  15. import org.bukkit.Sound;
  16. import org.bukkit.WorldBorder;
  17.  
  18. import me.ryan.TNTEveryMinUHC.Main;
  19. import net.md_5.bungee.api.ChatColor;
  20.  
  21. public class startUHC implements CommandExecutor{
  22.    
  23.     private Main plugin;
  24.     int task1;
  25.    
  26.     public startUHC(Main plugin) {
  27.         this.plugin = plugin;
  28.         plugin.getCommand("startUHC").setExecutor(this);
  29.     }
  30.    
  31.     @Override
  32.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  33.         Player p = (Player) sender;
  34.         Location l = p.getLocation();
  35.         World w = p.getWorld();
  36.         int randomX = new Random(100).nextInt();
  37.         int randomZ = new Random(100).nextInt();
  38.         Location loc = null;
  39.         BukkitScheduler sched = p.getServer().getScheduler();
  40.        
  41.         for(int y = 30; y < 100; y++) {
  42.             loc = new Location(w, randomX, y, randomZ);
  43.             if (loc.getBlock() == null && loc.add(0,1,0).getBlock() == null) {
  44.                 p.teleport(loc);
  45.             } else {
  46.                 if (loc.getBlock().getType() == Material.AIR && loc.add(0,1,0).getBlock().getType() == Material.AIR) {
  47.                     p.teleport(loc);
  48.                 }
  49.             }
  50.         }
  51.        
  52.         p.getServer().broadcastMessage("UHC starting in...");
  53.         task1 = sched.scheduleSyncRepeatingTask(this.plugin, new Runnable() {
  54.            
  55.             int num = 10;
  56.            
  57.             @Override
  58.             public void run() {            
  59.                 if(num == 0) {
  60.                     p.getServer().broadcastMessage(ChatColor.GREEN + "GOOO!!!");
  61.                     p.playSound(l, Sound.BLOCK_BELL_RESONATE, 2.0F, 1.0F);
  62.                     Bukkit.getScheduler().cancelTask(task1);
  63.                 }else {
  64.                     p.getServer().broadcastMessage(Integer.toString(num--));
  65.                 }
  66.             }  
  67.         }, 20L, 20L);
  68.        
  69.         sched.scheduleSyncRepeatingTask(this.plugin, new Runnable() {
  70.            
  71.             int num = 1;
  72.            
  73.             @Override
  74.             public void run() {
  75.                 if(num == 0) {
  76.                     w.setPVP(true);
  77.                     p.sendTitle("PVP has been enabled!!!" + ChatColor.GREEN, null, 1, 20, 1);
  78.                     p.playSound(l, Sound.ENTITY_ENDER_DRAGON_DEATH, 2.0F, 1.0F);
  79.                 } else {
  80.                     w.setPVP(false);
  81.                 }
  82.             }
  83.            
  84.         },12220L,12000L);
  85.        
  86.        
  87.         sched.scheduleSyncRepeatingTask(this.plugin, new Runnable() {
  88.            
  89.             @Override
  90.             public void run() {
  91.                 int borderSize;
  92.                 borderSize = (int) 1200.0;
  93.                
  94.                 WorldBorder border = w.getWorldBorder();
  95.                
  96.                 w.spawnEntity(l, EntityType.PRIMED_TNT);
  97.                 border.setSize(borderSize - 20);
  98.                
  99.             }
  100.         }, 820L, 600L);
  101.        
  102.         return false;
  103.     }
  104.  
  105. }
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement