Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.unionmc.pt;
- import java.util.ArrayList;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.DyeColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerMoveEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.plugin.java.JavaPlugin;
- public class MainPT extends JavaPlugin implements Listener
- {
- public ArrayList<Location> spawnlocations = new ArrayList<Location>();
- public boolean hasrun = false;
- public void onEnable ()
- {
- getLogger().info("ParkourTeleport has been enabled.");
- Bukkit.getServer().getPluginManager().registerEvents(this, this);
- startTasks();
- saveDefaultConfig();
- starttime = getConfig().getInt("countdown");
- }
- public void onDisable ()
- {
- getLogger().info("ParkourTeleport has been disabled.");
- }
- /**TIMER CODE BEGINS HERE! TIMER CODE BEGINS HERE! TIMER CODE BEGINS HERE! TIMER CODE BEGINS HERE!**/
- int starttime, staskID, ataskID;
- boolean docountdown;
- private void startTasks()
- {
- staskID = getServer().getScheduler().scheduleSyncRepeatingTask(this, new sTask(this), 20, 20);
- }
- private class sTask implements Runnable
- {
- MainPT instance;
- public sTask(MainPT instance)
- {
- this.instance = instance;
- }
- @Override
- public void run(){
- if(getServer().getOnlinePlayers().size() >= getConfig().getInt("players"))
- {
- if(starttime == getConfig().getInt("countdown"))
- {
- docountdown = true;
- starttime--;
- ataskID = getServer().getScheduler().scheduleSyncRepeatingTask(instance, new Runnable()
- {
- @Override
- public void run() {
- if(!hasrun)
- {
- getServer().broadcastMessage(ChatColor.GREEN + "Mini-game will start in 30 seconds!");
- hasrun = true;
- }
- getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("countdownmessage").replaceAll("%time%", starttime + "")));
- }
- }, getConfig().getInt("broadcastseconds")*20, getConfig().getInt("broadcastseconds")*20);
- }
- else
- {
- starttime--;
- }
- }
- else
- {
- if(starttime < getConfig().getInt("countdown"))
- {
- starttime = 30;
- docountdown = false;
- getServer().getScheduler().cancelTask(ataskID);
- getServer().broadcastMessage(ChatColor.RED + "Mini-game has been postponed.");
- getLogger().info("Start time was less than countdown in config.");
- }
- }
- if(starttime == 0)
- {
- getServer().dispatchCommand(getServer().getConsoleSender(), getConfig().getString("command"));
- getServer().getScheduler().cancelTask(ataskID);
- }
- }
- }
- /**TIMER CODE ENDS HERE! TIMER CODE ENDS HERE! TIMER CODE ENDS HERE! TIMER CODE ENDS HERE!**/
- public double random = (Math.random() * 100);
- public World world = Bukkit.getServer().getWorld("parkour");
- public Location spawn1 = new Location(world, 7, 65, -82);
- public Location spawn2 = new Location(world, 22, 65, -169);
- public Location spawn3 = new Location(world, 6, 65, -116);
- public Location spawn4 = new Location(world, 13, 66, -99);
- public Location spawn5 = new Location(world, -2, 65, -135);
- public Location spawn6 = new Location(world, 22, 65, -169);
- public Location spawn7 = new Location(world, -2, 65, -160);
- public Location spawn8 = new Location(world, 22, 65, -176);
- public Location spawn9 = new Location(world, 7, 65, -194);
- public Location spawn10 = new Location(world, -10, 65, -202);
- public Location spawn11 = new Location(world, 7, 65, -245);
- public Location spawn12 = new Location(world, 14, 65, -202);
- public Location spawn13 = new Location(world, 22, 65, -236);
- public Location spawn14 = new Location(world, 13, 73, -270);
- public Location spawn15 = new Location(world, -12, 65, -271);
- public Location spawn16 = new Location(world, 22, 65, -169);
- public Location regspawn = new Location(world, 3, 64, -3);
- public void addSpawnLocations ()
- {
- spawnlocations.add(spawn1);
- spawnlocations.add(spawn2);
- spawnlocations.add(spawn3);
- spawnlocations.add(spawn4);
- spawnlocations.add(spawn5);
- spawnlocations.add(spawn6);
- spawnlocations.add(spawn7);
- spawnlocations.add(spawn8);
- spawnlocations.add(spawn9);
- spawnlocations.add(spawn10);
- spawnlocations.add(spawn11);
- spawnlocations.add(spawn12);
- spawnlocations.add(spawn13);
- spawnlocations.add(spawn14);
- spawnlocations.add(spawn15);
- spawnlocations.add(spawn16);
- addSpawnLocations();
- }
- @SuppressWarnings("deprecation")
- public ItemStack greenblock = new ItemStack(Material.STAINED_CLAY, 1, DyeColor.LIME.getData());
- @SuppressWarnings("deprecation")
- public ItemStack yellowblock = new ItemStack(Material.STAINED_CLAY, 1, DyeColor.YELLOW.getData());
- @SuppressWarnings("deprecation")
- public ItemStack redblock = new ItemStack(Material.STAINED_CLAY, 1, DyeColor.RED.getData());
- @EventHandler
- public void playerMove(PlayerMoveEvent e)
- {
- Location loc = e.getPlayer().getLocation().subtract(0, 1, 0);
- if (!hasrun && e.getPlayer().getWorld() == world) //THIS IF STATEMENT IS NOT FINISHED, WE ONLY WANT THIS TO HAPPEN WHEN THE GAME BEGINS ON THE TIMER! NEED YOUR HELP THERE AARON!
- {
- if (random <= 6.25)
- {
- e.getPlayer().teleport(spawn1);
- }
- if (random <= 12.5 && random > 6.25)
- {
- e.getPlayer().teleport(spawn2);
- }
- if (random <= 18.75 && random > 12.5)
- {
- e.getPlayer().teleport(spawn3);
- }
- if (random <= 25 && random > 18.75)
- {
- e.getPlayer().teleport(spawn4);
- }
- if (random <= 31.25 && random > 25)
- {
- e.getPlayer().teleport(spawn5);
- }
- if (random <= 37.5 && random > 31.25)
- {
- e.getPlayer().teleport(spawn6);
- }
- if (random <= 43.75 && random > 37.5)
- {
- e.getPlayer().teleport(spawn7);
- }
- if (random <= 50 && random > 43.75)
- {
- e.getPlayer().teleport(spawn8);
- }
- if (random <= 56.25 && random > 50)
- {
- e.getPlayer().teleport(spawn9);
- }
- if (random <= 62.5 && random > 56.25)
- {
- e.getPlayer().teleport(spawn10);
- }
- if (random <= 68.75 && random > 62.5)
- {
- e.getPlayer().teleport(spawn11);
- }
- if (random <= 75 && random > 68.75)
- {
- e.getPlayer().teleport(spawn12);
- }
- if (random <= 81.25 && random > 75)
- {
- e.getPlayer().teleport(spawn13);
- }
- if (random <= 87.5 && random > 81.25)
- {
- e.getPlayer().teleport(spawn14);
- }
- if (random <= 93.75 && random > 87.5)
- {
- e.getPlayer().teleport(spawn15);
- }
- if (random <= 100 && random > 93.75)
- {
- e.getPlayer().teleport(spawn16);
- }
- }
- if (e.getPlayer().teleport(spawn1) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn1);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn1);
- }
- }
- if (e.getPlayer().teleport(spawn2) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn2);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn2);
- }
- }
- if (e.getPlayer().teleport(spawn3) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn3);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn3);
- }
- }
- if (e.getPlayer().teleport(spawn4) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn4);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn4);
- }
- }
- if (e.getPlayer().teleport(spawn5) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn5);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn5);
- }
- }
- if (e.getPlayer().teleport(spawn6) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn6);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn6);
- }
- }
- if (e.getPlayer().teleport(spawn7) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn7);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn7);
- }
- }
- if (e.getPlayer().teleport(spawn8) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn8);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn8);
- }
- }
- if (e.getPlayer().teleport(spawn9) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn9);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn9);
- }
- }
- if (e.getPlayer().teleport(spawn10) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn10);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn10);
- }
- }
- if (e.getPlayer().teleport(spawn11) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn11);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn11);
- }
- }
- if (e.getPlayer().teleport(spawn12) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn12);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn12);
- }
- }
- if (e.getPlayer().teleport(spawn13) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn13);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn13);
- }
- }
- if (e.getPlayer().teleport(spawn14) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn14);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn14);
- }
- }
- if (e.getPlayer().teleport(spawn15) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn15);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn15);
- }
- }
- if (e.getPlayer().teleport(spawn16) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
- {
- if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
- {
- e.getPlayer().teleport(spawn16);
- }
- else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- spawnlocations.remove(spawn16);
- }
- }
- if(spawnlocations.isEmpty()) {
- String p = e.getPlayer().getDisplayName();
- e.getPlayer().teleport(regspawn);
- e.getPlayer().sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_RED + ChatColor.BOLD + "Union " + ChatColor.RED + ChatColor.BOLD + "MC" + ChatColor.DARK_GRAY + "] §4» §fGame over. " + ChatColor.GOLD + p + "§fhas won!");
- if (e.getPlayer().teleport(regspawn))
- {
- addSpawnLocations();
- e.getPlayer().setExp(0F);
- }
- }
- if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement