Advertisement
Guest User

Untitled

a guest
May 29th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.69 KB | None | 0 0
  1. package net.unionmc.pt;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.DyeColor;
  8. import org.bukkit.Location;
  9. import org.bukkit.Material;
  10. import org.bukkit.World;
  11. import org.bukkit.event.EventHandler;
  12. import org.bukkit.event.Listener;
  13. import org.bukkit.event.player.PlayerMoveEvent;
  14. import org.bukkit.inventory.ItemStack;
  15. import org.bukkit.plugin.java.JavaPlugin;
  16.  
  17. public class MainPT extends JavaPlugin implements Listener
  18. {
  19.  
  20.  
  21.  
  22. public ArrayList<Location> spawnlocations = new ArrayList<Location>();
  23.  
  24. public boolean hasrun = false;
  25.  
  26.  
  27. public void onEnable ()
  28. {
  29.  
  30. getLogger().info("ParkourTeleport has been enabled.");
  31. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  32.  
  33. startTasks();
  34. saveDefaultConfig();
  35. starttime = getConfig().getInt("countdown");
  36. }
  37.  
  38. public void onDisable ()
  39. {
  40. getLogger().info("ParkourTeleport has been disabled.");
  41. }
  42.  
  43.  
  44. /**TIMER CODE BEGINS HERE! TIMER CODE BEGINS HERE! TIMER CODE BEGINS HERE! TIMER CODE BEGINS HERE!**/
  45. int starttime, staskID, ataskID;
  46. boolean docountdown;
  47.  
  48.  
  49. private void startTasks()
  50. {
  51. staskID = getServer().getScheduler().scheduleSyncRepeatingTask(this, new sTask(this), 20, 20);
  52. }
  53.  
  54. private class sTask implements Runnable
  55. {
  56. MainPT instance;
  57.  
  58. public sTask(MainPT instance)
  59. {
  60. this.instance = instance;
  61. }
  62.  
  63. @Override
  64. public void run(){
  65. if(getServer().getOnlinePlayers().size() >= getConfig().getInt("players"))
  66. {
  67. if(starttime == getConfig().getInt("countdown"))
  68. {
  69. docountdown = true;
  70. starttime--;
  71. ataskID = getServer().getScheduler().scheduleSyncRepeatingTask(instance, new Runnable()
  72. {
  73.  
  74.  
  75. @Override
  76. public void run() {
  77. if(!hasrun)
  78. {
  79. getServer().broadcastMessage(ChatColor.GREEN + "Mini-game will start in 30 seconds!");
  80. hasrun = true;
  81. }
  82. getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("countdownmessage").replaceAll("%time%", starttime + "")));
  83. }
  84. }, getConfig().getInt("broadcastseconds")*20, getConfig().getInt("broadcastseconds")*20);
  85. }
  86. else
  87. {
  88. starttime--;
  89. }
  90. }
  91. else
  92. {
  93. if(starttime < getConfig().getInt("countdown"))
  94. {
  95. starttime = 30;
  96. docountdown = false;
  97. getServer().getScheduler().cancelTask(ataskID);
  98. getServer().broadcastMessage(ChatColor.RED + "Mini-game has been postponed.");
  99. getLogger().info("Start time was less than countdown in config.");
  100. }
  101. }
  102. if(starttime == 0)
  103. {
  104. getServer().dispatchCommand(getServer().getConsoleSender(), getConfig().getString("command"));
  105. getServer().getScheduler().cancelTask(ataskID);
  106. }
  107. }
  108. }
  109.  
  110. /**TIMER CODE ENDS HERE! TIMER CODE ENDS HERE! TIMER CODE ENDS HERE! TIMER CODE ENDS HERE!**/
  111.  
  112.  
  113.  
  114.  
  115. public double random = (Math.random() * 100);
  116.  
  117.  
  118. public World world = Bukkit.getServer().getWorld("parkour");
  119. public Location spawn1 = new Location(world, 7, 65, -82);
  120. public Location spawn2 = new Location(world, 22, 65, -169);
  121. public Location spawn3 = new Location(world, 6, 65, -116);
  122. public Location spawn4 = new Location(world, 13, 66, -99);
  123. public Location spawn5 = new Location(world, -2, 65, -135);
  124. public Location spawn6 = new Location(world, 22, 65, -169);
  125. public Location spawn7 = new Location(world, -2, 65, -160);
  126. public Location spawn8 = new Location(world, 22, 65, -176);
  127. public Location spawn9 = new Location(world, 7, 65, -194);
  128. public Location spawn10 = new Location(world, -10, 65, -202);
  129. public Location spawn11 = new Location(world, 7, 65, -245);
  130. public Location spawn12 = new Location(world, 14, 65, -202);
  131. public Location spawn13 = new Location(world, 22, 65, -236);
  132. public Location spawn14 = new Location(world, 13, 73, -270);
  133. public Location spawn15 = new Location(world, -12, 65, -271);
  134. public Location spawn16 = new Location(world, 22, 65, -169);
  135.  
  136. public Location regspawn = new Location(world, 3, 64, -3);
  137.  
  138. public void addSpawnLocations ()
  139.  
  140. {
  141.  
  142. spawnlocations.add(spawn1);
  143. spawnlocations.add(spawn2);
  144. spawnlocations.add(spawn3);
  145. spawnlocations.add(spawn4);
  146. spawnlocations.add(spawn5);
  147. spawnlocations.add(spawn6);
  148. spawnlocations.add(spawn7);
  149. spawnlocations.add(spawn8);
  150. spawnlocations.add(spawn9);
  151. spawnlocations.add(spawn10);
  152. spawnlocations.add(spawn11);
  153. spawnlocations.add(spawn12);
  154. spawnlocations.add(spawn13);
  155. spawnlocations.add(spawn14);
  156. spawnlocations.add(spawn15);
  157. spawnlocations.add(spawn16);
  158.  
  159. addSpawnLocations();
  160. }
  161.  
  162.  
  163.  
  164. @SuppressWarnings("deprecation")
  165. public ItemStack greenblock = new ItemStack(Material.STAINED_CLAY, 1, DyeColor.LIME.getData());
  166. @SuppressWarnings("deprecation")
  167. public ItemStack yellowblock = new ItemStack(Material.STAINED_CLAY, 1, DyeColor.YELLOW.getData());
  168. @SuppressWarnings("deprecation")
  169. public ItemStack redblock = new ItemStack(Material.STAINED_CLAY, 1, DyeColor.RED.getData());
  170.  
  171.  
  172. @EventHandler
  173. public void playerMove(PlayerMoveEvent e)
  174. {
  175.  
  176.  
  177. Location loc = e.getPlayer().getLocation().subtract(0, 1, 0);
  178.  
  179. 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!
  180. {
  181.  
  182. if (random <= 6.25)
  183. {
  184. e.getPlayer().teleport(spawn1);
  185. }
  186.  
  187. if (random <= 12.5 && random > 6.25)
  188. {
  189. e.getPlayer().teleport(spawn2);
  190. }
  191.  
  192. if (random <= 18.75 && random > 12.5)
  193. {
  194. e.getPlayer().teleport(spawn3);
  195. }
  196.  
  197. if (random <= 25 && random > 18.75)
  198. {
  199. e.getPlayer().teleport(spawn4);
  200. }
  201.  
  202. if (random <= 31.25 && random > 25)
  203. {
  204. e.getPlayer().teleport(spawn5);
  205. }
  206.  
  207.  
  208. if (random <= 37.5 && random > 31.25)
  209. {
  210. e.getPlayer().teleport(spawn6);
  211. }
  212.  
  213.  
  214. if (random <= 43.75 && random > 37.5)
  215. {
  216. e.getPlayer().teleport(spawn7);
  217. }
  218.  
  219. if (random <= 50 && random > 43.75)
  220. {
  221. e.getPlayer().teleport(spawn8);
  222. }
  223.  
  224. if (random <= 56.25 && random > 50)
  225. {
  226. e.getPlayer().teleport(spawn9);
  227. }
  228.  
  229. if (random <= 62.5 && random > 56.25)
  230. {
  231. e.getPlayer().teleport(spawn10);
  232. }
  233.  
  234. if (random <= 68.75 && random > 62.5)
  235. {
  236. e.getPlayer().teleport(spawn11);
  237. }
  238.  
  239. if (random <= 75 && random > 68.75)
  240. {
  241. e.getPlayer().teleport(spawn12);
  242. }
  243.  
  244. if (random <= 81.25 && random > 75)
  245. {
  246. e.getPlayer().teleport(spawn13);
  247. }
  248.  
  249. if (random <= 87.5 && random > 81.25)
  250. {
  251. e.getPlayer().teleport(spawn14);
  252. }
  253.  
  254. if (random <= 93.75 && random > 87.5)
  255. {
  256. e.getPlayer().teleport(spawn15);
  257. }
  258.  
  259. if (random <= 100 && random > 93.75)
  260. {
  261. e.getPlayer().teleport(spawn16);
  262.  
  263. }
  264. }
  265.  
  266. if (e.getPlayer().teleport(spawn1) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  267. {
  268. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  269. {
  270. e.getPlayer().teleport(spawn1);
  271. }
  272.  
  273. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  274. {
  275. spawnlocations.remove(spawn1);
  276. }
  277.  
  278. }
  279.  
  280. if (e.getPlayer().teleport(spawn2) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  281. {
  282. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  283. {
  284. e.getPlayer().teleport(spawn2);
  285. }
  286.  
  287. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  288. {
  289. spawnlocations.remove(spawn2);
  290. }
  291.  
  292. }
  293.  
  294. if (e.getPlayer().teleport(spawn3) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  295. {
  296. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  297. {
  298. e.getPlayer().teleport(spawn3);
  299. }
  300.  
  301. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  302. {
  303. spawnlocations.remove(spawn3);
  304. }
  305.  
  306. }
  307.  
  308. if (e.getPlayer().teleport(spawn4) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  309. {
  310. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  311. {
  312. e.getPlayer().teleport(spawn4);
  313. }
  314.  
  315. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  316. {
  317. spawnlocations.remove(spawn4);
  318. }
  319.  
  320. }
  321.  
  322. if (e.getPlayer().teleport(spawn5) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  323. {
  324. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  325. {
  326. e.getPlayer().teleport(spawn5);
  327. }
  328.  
  329. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  330. {
  331. spawnlocations.remove(spawn5);
  332. }
  333.  
  334. }
  335.  
  336. if (e.getPlayer().teleport(spawn6) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  337. {
  338. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  339. {
  340. e.getPlayer().teleport(spawn6);
  341. }
  342.  
  343. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  344. {
  345. spawnlocations.remove(spawn6);
  346. }
  347.  
  348. }
  349.  
  350. if (e.getPlayer().teleport(spawn7) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  351. {
  352. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  353. {
  354. e.getPlayer().teleport(spawn7);
  355. }
  356.  
  357. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  358. {
  359. spawnlocations.remove(spawn7);
  360. }
  361.  
  362. }
  363.  
  364. if (e.getPlayer().teleport(spawn8) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  365. {
  366. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  367. {
  368. e.getPlayer().teleport(spawn8);
  369. }
  370.  
  371. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  372. {
  373. spawnlocations.remove(spawn8);
  374. }
  375.  
  376. }
  377.  
  378. if (e.getPlayer().teleport(spawn9) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  379. {
  380. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  381. {
  382. e.getPlayer().teleport(spawn9);
  383. }
  384.  
  385. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  386. {
  387. spawnlocations.remove(spawn9);
  388. }
  389.  
  390. }
  391.  
  392. if (e.getPlayer().teleport(spawn10) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  393. {
  394. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  395. {
  396. e.getPlayer().teleport(spawn10);
  397. }
  398.  
  399. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  400. {
  401. spawnlocations.remove(spawn10);
  402. }
  403.  
  404. }
  405.  
  406. if (e.getPlayer().teleport(spawn11) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  407. {
  408. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  409. {
  410. e.getPlayer().teleport(spawn11);
  411. }
  412.  
  413. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  414. {
  415. spawnlocations.remove(spawn11);
  416. }
  417.  
  418. }
  419.  
  420. if (e.getPlayer().teleport(spawn12) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  421. {
  422. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  423. {
  424. e.getPlayer().teleport(spawn12);
  425. }
  426.  
  427. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  428. {
  429. spawnlocations.remove(spawn12);
  430. }
  431.  
  432. }
  433.  
  434. if (e.getPlayer().teleport(spawn13) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  435. {
  436. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  437. {
  438. e.getPlayer().teleport(spawn13);
  439. }
  440.  
  441. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  442. {
  443. spawnlocations.remove(spawn13);
  444. }
  445.  
  446. }
  447.  
  448. if (e.getPlayer().teleport(spawn14) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  449. {
  450. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  451. {
  452. e.getPlayer().teleport(spawn14);
  453. }
  454.  
  455. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  456. {
  457. spawnlocations.remove(spawn14);
  458. }
  459.  
  460. }
  461.  
  462. if (e.getPlayer().teleport(spawn15) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  463. {
  464.  
  465.  
  466. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  467. {
  468. e.getPlayer().teleport(spawn15);
  469. }
  470.  
  471. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  472. {
  473. spawnlocations.remove(spawn15);
  474. }
  475.  
  476. }
  477.  
  478. if (e.getPlayer().teleport(spawn16) && e.getPlayer().getWorld().getBlockAt(loc) == yellowblock )
  479. {
  480. if (e.getPlayer().getWorld().getBlockAt(loc) == redblock)
  481. {
  482. e.getPlayer().teleport(spawn16);
  483. }
  484.  
  485. else if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  486. {
  487. spawnlocations.remove(spawn16);
  488. }
  489.  
  490. }
  491.  
  492.  
  493.  
  494. if(spawnlocations.isEmpty()) {
  495.  
  496. String p = e.getPlayer().getDisplayName();
  497. e.getPlayer().teleport(regspawn);
  498. 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!");
  499.  
  500. if (e.getPlayer().teleport(regspawn))
  501. {
  502. addSpawnLocations();
  503. e.getPlayer().setExp(0F);
  504. }
  505.  
  506. }
  507.  
  508. if (e.getPlayer().getWorld().getBlockAt(loc) == greenblock)
  509. {
  510.  
  511. }
  512.  
  513.  
  514. }
  515. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement