Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.ryan.TNTEveryMinUHC.commands;
- import java.util.Random;
- import org.bukkit.Bukkit;
- import org.bukkit.World;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.EntityType;
- import org.bukkit.entity.Player;
- import org.bukkit.scheduler.BukkitScheduler;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.Sound;
- import org.bukkit.WorldBorder;
- import me.ryan.TNTEveryMinUHC.Main;
- import net.md_5.bungee.api.ChatColor;
- public class startUHC implements CommandExecutor{
- private Main plugin;
- int task1;
- public startUHC(Main plugin) {
- this.plugin = plugin;
- plugin.getCommand("startUHC").setExecutor(this);
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- Player p = (Player) sender;
- Location l = p.getLocation();
- World w = p.getWorld();
- int randomX = new Random(100).nextInt();
- int randomZ = new Random(100).nextInt();
- Location loc = null;
- BukkitScheduler sched = p.getServer().getScheduler();
- for(int y = 30; y < 100; y++) {
- loc = new Location(w, randomX, y, randomZ);
- if (loc.getBlock() == null && loc.add(0,1,0).getBlock() == null) {
- p.teleport(loc);
- } else {
- if (loc.getBlock().getType() == Material.AIR && loc.add(0,1,0).getBlock().getType() == Material.AIR) {
- p.teleport(loc);
- }
- }
- }
- p.getServer().broadcastMessage("UHC starting in...");
- task1 = sched.scheduleSyncRepeatingTask(this.plugin, new Runnable() {
- int num = 10;
- @Override
- public void run() {
- if(num == 0) {
- p.getServer().broadcastMessage(ChatColor.GREEN + "GOOO!!!");
- p.playSound(l, Sound.BLOCK_BELL_RESONATE, 2.0F, 1.0F);
- Bukkit.getScheduler().cancelTask(task1);
- }else {
- p.getServer().broadcastMessage(Integer.toString(num--));
- }
- }
- }, 20L, 20L);
- sched.scheduleSyncRepeatingTask(this.plugin, new Runnable() {
- int num = 1;
- @Override
- public void run() {
- if(num == 0) {
- w.setPVP(true);
- p.sendTitle("PVP has been enabled!!!" + ChatColor.GREEN, null, 1, 20, 1);
- p.playSound(l, Sound.ENTITY_ENDER_DRAGON_DEATH, 2.0F, 1.0F);
- } else {
- w.setPVP(false);
- }
- }
- },12220L,12000L);
- sched.scheduleSyncRepeatingTask(this.plugin, new Runnable() {
- @Override
- public void run() {
- int borderSize;
- borderSize = (int) 1200.0;
- WorldBorder border = w.getWorldBorder();
- w.spawnEntity(l, EntityType.PRIMED_TNT);
- border.setSize(borderSize - 20);
- }
- }, 820L, 600L);
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement