Advertisement
Guest User

Untitled

a guest
Mar 7th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.38 KB | None | 0 0
  1. package me.AJ_HD.Koth;
  2.  
  3. import java.text.SimpleDateFormat;
  4. import java.util.ArrayList;
  5. import java.util.Collections;
  6. import java.util.Date;
  7. import java.util.Random;
  8. import java.util.TimeZone;
  9. import org.bukkit.Bukkit;
  10. import org.bukkit.ChatColor;
  11. import org.bukkit.Location;
  12. import org.bukkit.Material;
  13. import org.bukkit.block.Block;
  14. import org.bukkit.block.Chest;
  15. import org.bukkit.command.Command;
  16. import org.bukkit.command.CommandSender;
  17. import org.bukkit.configuration.ConfigurationSection;
  18. import org.bukkit.configuration.file.FileConfiguration;
  19. import org.bukkit.enchantments.Enchantment;
  20. import org.bukkit.entity.Player;
  21. import org.bukkit.event.EventHandler;
  22. import org.bukkit.event.Listener;
  23. import org.bukkit.event.block.Action;
  24. import org.bukkit.event.inventory.InventoryClickEvent;
  25. import org.bukkit.event.player.PlayerInteractEvent;
  26. import org.bukkit.event.player.PlayerMoveEvent;
  27. import org.bukkit.event.player.PlayerQuitEvent;
  28. import org.bukkit.inventory.Inventory;
  29. import org.bukkit.inventory.ItemStack;
  30. import org.bukkit.inventory.meta.ItemMeta;
  31. import org.bukkit.plugin.Plugin;
  32. import org.bukkit.plugin.java.JavaPlugin;
  33. import com.sk89q.worldedit.bukkit.WorldEditPlugin;
  34. import com.sk89q.worldedit.bukkit.selections.Selection;
  35. /* 29: */
  36. /* 9: */
  37. /* 15: */
  38. /* 16: */
  39. /* 23: */
  40. /* 38: */
  41. /* 40: */
  42. /* 41: */
  43. /* 42: */public class Koth
  44. /* 43: */extends JavaPlugin
  45. /* 44: */implements Listener
  46. /* 45: */{
  47. /* 46: 47 */boolean claim = false;
  48. /* 47: 47 */boolean cl = false;
  49. /* 48: 47 */boolean st = false;
  50. /* 49: 47 */boolean hill = false;
  51. /* 50: 48 */boolean koth = false;
  52. /* 51: 49 */ArrayList<Player> inHill = new ArrayList<Player>();
  53. /* 52: 50 */ArrayList<Player> b = new ArrayList<Player>();
  54. /* 53: 51 */ArrayList<Player> control = new ArrayList<Player>();
  55. /* 54: 52 */ArrayList<ItemStack> item = new ArrayList<ItemStack>();
  56. /* 55: 53 */ArrayList<String> a = new ArrayList<String>();
  57. /* 56: 54 */ArrayList<String> k = new ArrayList<String>();
  58. /* 57: 56 */int controltime = 60;
  59. /* 58: 65 */int yMore = 0;
  60. /* 59: 65 */int yLess = 0;
  61. /* 60: 65 */int zLess = 0;
  62. /* 61: 65 */int zMore = 0;
  63. /* 62: 65 */int xLess = 0;
  64. /* 63: 65 */int xMore = 0;
  65. /* 64: */String lastControl;
  66. /* 65: */int time;
  67. /* 66: */int finish;
  68. /* 67: */String winner;
  69. /* 68: */int c;
  70. /* 69: */Koth ko;
  71. /* 70: */FileConfiguration cfg;
  72. /* 71: */String name;
  73. /* 72: */Chest chest;
  74.  
  75. /* 73: */
  76. /* 74: */public void onEnable()
  77. /* 75: */{
  78. /* 76: 69 */this.ko = this;
  79. /* 77: 70 */Bukkit.getPluginManager().registerEvents(this, this);
  80. /* 78: 71 */getConfig().addDefault("AutoStartEnabled",
  81. Boolean.valueOf(false));
  82. /* 79: 72 */getConfig().addDefault("FirstStartTime", "10:00");
  83. /* 80: 73 */getConfig().addDefault("SecondStartTime", "22:00");
  84. /* 81: 74 */final ConfigurationSection section = getConfig()
  85. .getConfigurationSection("Koth");
  86. /* 82: 75 */Bukkit.getServer().getScheduler()
  87. .scheduleSyncRepeatingTask(this, new Runnable()
  88. /* 83: */{
  89. /* 84: */public void run()
  90. /* 85: */{
  91. /* 86: 79 */if (Koth.this.finish == 1)
  92. /* 87: */{
  93. /* 88: 80 */Block b = Bukkit.getWorld("world")
  94. .getBlockAt(
  95. Koth.this.ko.getConfig().getInt(
  96. "Koth." + Koth.this.name
  97. + ".chestX"),
  98. Koth.this.ko.getConfig().getInt(
  99. "Koth." + Koth.this.name
  100. + ".chestY"),
  101. Koth.this.ko.getConfig().getInt(
  102. "Koth." + Koth.this.name
  103. + ".chestZ"));
  104. /* 89: 81 */b.setType(Material.AIR);
  105. /* 90: 82 */Koth.this.name = "";
  106. /* 91: 83 */Koth.this.finish = 0;
  107. /* 92: */}
  108. /* 93: 85 */if (Koth.this.getConfig()
  109. .getConfigurationSection("Koth") == null) {
  110. /* 94: 86 */return;
  111. /* 95: */}
  112. /* 96: 88 */for (String key : section.getValues(false)
  113. .keySet()) {
  114. /* 97: 89 */Koth.this.k.add(key);
  115. /* 98: */}
  116. /* 99: 91 */if (Koth.this.ko.getConfig().getBoolean(
  117. "AutoStartEnable"))
  118. /* 100: */{
  119. /* 101: 92 */SimpleDateFormat dateFormat = new SimpleDateFormat(
  120. "HH:mm");
  121. /* 102: 93 */dateFormat.setTimeZone(TimeZone
  122. .getTimeZone("GMT"));
  123. /* 103: 94 */if ((dateFormat.format(new Date())
  124. .equals("10:00"))
  125. || (dateFormat.format(new Date())
  126. .equals("22:24")))
  127. /* 104: */{
  128. /* 105: 95 */Collections.shuffle(Koth.this.k);
  129. /* 106: 96 */Koth.this.name = ((String) Koth.this.k
  130. .get(0));
  131. /* 107: 97 */Bukkit
  132. .broadcastMessage(ChatColor.GOLD
  133. + "["
  134. + ChatColor.YELLOW
  135. + "HCFKoth"
  136. + ChatColor.GOLD
  137. + "]"
  138. + ChatColor.GREEN
  139. + " A koth is about to begin! The map coordinates will be released in a moment!");
  140. /* 108: 98 */Bukkit
  141. .getServer()
  142. .getScheduler()
  143. .scheduleSyncDelayedTask(Koth.this.ko,
  144. new Runnable()
  145. /* 109: */{
  146. /* 110: */public void run()
  147. /* 111: */{
  148. /* 112:102 */Bukkit
  149. .broadcastMessage(ChatColor.GOLD
  150. + "["
  151. + ChatColor.YELLOW
  152. + "HCFKoth"
  153. + ChatColor.GOLD
  154. + "]"
  155. + ChatColor.GREEN
  156. + " The koth has begun");
  157. /* 113:103 */Bukkit
  158. .broadcastMessage(ChatColor.GOLD
  159. + "["
  160. + ChatColor.YELLOW
  161. + "HCFKoth"
  162. + ChatColor.GOLD
  163. + "]"
  164. + ChatColor.GREEN
  165. + " The koth map is "
  166. + ChatColor.GRAY
  167. + Koth.this.name);
  168. /* 114:104 */Bukkit
  169. .broadcastMessage(ChatColor.GOLD
  170. + "["
  171. + ChatColor.YELLOW
  172. + "HCFKoth"
  173. + ChatColor.GOLD
  174. + "]"
  175. + ChatColor.GREEN
  176. + " The coordinates are "
  177. + ChatColor.YELLOW
  178. + "x"
  179. + Koth.this.ko
  180. .getConfig()
  181. .getString(
  182. new StringBuilder(
  183. "Koth.")
  184. .append(Koth.this.name)
  185. .append(".xMore")
  186. .toString())
  187. + " z"
  188. + Koth.this.ko
  189. .getConfig()
  190. .getString(
  191. new StringBuilder(
  192. "Koth.")
  193. .append(Koth.this.name)
  194. .append(".zMore")
  195. .toString()));
  196. /* 115:105 */Koth.this.koth = true;
  197. /* 116: */}
  198. /* 117:109 */
  199. }, 100L);
  200. /* 118:110 */Koth.this.c = Bukkit
  201. .getServer()
  202. .getScheduler()
  203. .scheduleSyncRepeatingTask(
  204. Koth.this.ko, new Runnable()
  205. /* 119: */{
  206. /* 120: */public void run()
  207. /* 121: */{
  208. /* 122:113 */Bukkit
  209. .broadcastMessage(ChatColor.GOLD
  210. + "["
  211. + ChatColor.YELLOW
  212. + "HCFKoth"
  213. + ChatColor.GOLD
  214. + "]"
  215. + ChatColor.GOLD
  216. + " The "
  217. + ChatColor.GRAY
  218. + Koth.this.name
  219. + ChatColor.GOLD
  220. + " coordinates are "
  221. + ChatColor.YELLOW
  222. + "x"
  223. + Koth.this.ko
  224. .getConfig()
  225. .getString(
  226. new StringBuilder(
  227. "Koth.")
  228. .append(Koth.this.name)
  229. .append(".xMore")
  230. .toString())
  231. + " z"
  232. + Koth.this.ko
  233. .getConfig()
  234. .getString(
  235. new StringBuilder(
  236. "Koth.")
  237. .append(Koth.this.name)
  238. .append(".zMore")
  239. .toString()));
  240. /* 123: */}
  241. /* 124:116 */
  242. }, 4800L, 7200L);
  243. /* 125: */}
  244. /* 126: */}
  245. /* 127: */}
  246. /* 128:122 */
  247. }, 0L, 1000L);
  248. /* 129:123 */getConfig().options().copyDefaults(true);
  249. /* 130:124 */saveConfig();
  250. /* 131: */}
  251.  
  252. /* 132: */
  253. /* 133: */public void onDisable() {
  254. }
  255.  
  256. /* 134: */
  257. /* 135: */public WorldEditPlugin getWE()
  258. /* 136: */{
  259. /* 137:133 */Plugin p = Bukkit.getServer().getPluginManager()
  260. .getPlugin("WorldEdit");
  261. /* 138:135 */if ((p instanceof WorldEditPlugin)) {
  262. /* 139:136 */return (WorldEditPlugin) p;
  263. /* 140: */}
  264. /* 141:138 */return null;
  265. /* 142: */}
  266.  
  267. /* 143: */
  268. /* 144: */public boolean onCommand(CommandSender sender, Command command,
  269. String label, String[] args)
  270. /* 145: */{
  271. /* 146:145 */if ((sender instanceof Player))
  272. /* 147: */{
  273. /* 148:146 */Player player = (Player) sender;
  274. /* 149:147 */if (command.getName().equalsIgnoreCase("koth")) {
  275. player.sendMessage(ChatColor.GREEN + "If you need help do");
  276. player.sendMessage(ChatColor.GREEN + "/koth help");
  277. /* 150:148 */if (args.length == 1)
  278. /* 151: */{
  279. if (args[0].equalsIgnoreCase("help"))
  280. player.sendMessage(ChatColor.GOLD + "=-"
  281. + ChatColor.AQUA + "Koth" + ChatColor.GOLD
  282. + "-=");
  283. player.sendMessage(ChatColor.DARK_RED + "/koth start");
  284. player.sendMessage(ChatColor.DARK_RED + "/koth stop");
  285. player.sendMessage(ChatColor.DARK_RED + "/koth add"
  286. + ChatColor.RED
  287. + " Select with World Edit the Koth");
  288. player.sendMessage(ChatColor.DARK_RED + "/koth loot");
  289. player.sendMessage(ChatColor.DARK_RED
  290. + "/koth setchest"
  291. + ChatColor.RED
  292. + " Select the chest with World Edit it will be put in");
  293. player.sendMessage(ChatColor.YELLOW + "Made by AJ_HD <3");
  294. if (args[0].equalsIgnoreCase("start"))
  295. {
  296. if (player.isOp())
  297. /* 155: */{
  298. /* 156:151 */this.winner = "";
  299. /* 157:152 */Inventory i = Bukkit.createInventory(
  300. null, 27, "Koth Modes");
  301. /* 158:153 */ConfigurationSection section = getConfig()
  302. .getConfigurationSection("Koth");
  303. /* 159:154 */int iii = 0;
  304. /* 160:155 */for (String key : section.getValues(
  305. false).keySet())
  306. /* 161: */{
  307. /* 162:156 */ItemStack g1 = new ItemStack(
  308. Material.DIAMOND_SWORD);
  309. /* 163:157 */ItemMeta ii = g1.getItemMeta();
  310. /* 164:158 */ii.setDisplayName(key);
  311. /* 165:159 */g1.setItemMeta(ii);
  312. /* 166:160 */i.setItem(iii, g1);
  313. /* 167:161 */iii++;
  314. /* 168: */}
  315. /* 169:163 */player.openInventory(i);
  316. /* 170: */}
  317. /* 171: */}
  318. /* 172:166 */else if (args[0].equalsIgnoreCase("loot"))
  319. /* 173: */{
  320. /* 174:167 */Inventory in = Bukkit.createInventory(
  321. null, 27, "Koth Loot");
  322. /* 175: */
  323. /* 176:169 */ItemStack h = new ItemStack(
  324. Material.DIAMOND_HELMET);
  325. /* 177:170 */h.addEnchantment(
  326. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
  327. /* 178: */
  328. /* 179:172 */ItemStack c = new ItemStack(
  329. Material.DIAMOND_CHESTPLATE);
  330. c.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
  331. ItemStack l = new ItemStack(
  332. Material.DIAMOND_LEGGINGS);
  333. l.addEnchantment(
  334. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
  335. ItemStack b = new ItemStack(
  336. Material.DIAMOND_BOOTS);b.addEnchantment(
  337. Enchantment.PROTECTION_ENVIRONMENTAL, 1);
  338. ItemStack s = new ItemStack(
  339. Material.DIAMOND_SWORD);
  340. s.addEnchantment(Enchantment.DAMAGE_ALL, 2);
  341. ItemStack e = new ItemStack(
  342. Material.ENDER_PEARL, 16);
  343. ItemStack g = new ItemStack(
  344. Material.GOLDEN_APPLE, 1, (short) 1);
  345. in.setItem(0, h);
  346. in.setItem(1, c);
  347. in.setItem(2, l);
  348. in.setItem(3, b);
  349. in.setItem(4, s);
  350. in.setItem(5, e);
  351. in.setItem(6, g);
  352. player.openInventory(in);
  353. /* 206: */}
  354. /* 207:199 */else if ((args[0].equalsIgnoreCase("stop")) &&
  355. /* 208:200 */(player.isOp()))
  356. /* 209: */{
  357. /* 210:201 */player.sendMessage(ChatColor.GOLD + "["
  358. + ChatColor.YELLOW + "HCFKoth" + ChatColor.GOLD
  359. + "]" + ChatColor.GOLD
  360. + " Koth has been stopped");
  361. /* 211:202 */this.koth = false;
  362. /* 212:203 */this.inHill.clear();
  363. /* 213:204 */this.control.clear();
  364. /* 214:205 */this.controltime = 6;
  365. /* 215:206 */getServer().getScheduler().cancelTask(
  366. this.c);
  367. /* 216:207 */this.st = false;
  368. /* 217: */
  369. /* 218:209 */this.k.clear();
  370. /* 219: */}
  371. /* 220: */}
  372. /* 221:212 */else if (args.length == 2) {
  373. /* 222:213 */if (args[0].equalsIgnoreCase("add"))
  374. /* 223: */{
  375. /* 224:214 */if (player.isOp())
  376. /* 225: */{
  377. /* 226:215 */Selection s = getWE().getSelection(
  378. player);
  379. /* 227:216 */if (s == null)
  380. /* 228: */{
  381. /* 229:217 */player.sendMessage(ChatColor.RED
  382. + "Make a selection first");
  383. /* 230:218 */return true;
  384. /* 231: */}
  385. /* 232:220 */player.sendMessage(ChatColor.GOLD
  386. + "[" + ChatColor.YELLOW + "HCFKoth"
  387. + ChatColor.GOLD + "]" + ChatColor.GOLD
  388. + " Koth added");
  389. /* 233:221 */String name = args[1];
  390. /* 234:222 */int xMore = s.getMinimumPoint()
  391. .getBlockX();
  392. /* 235:223 */int zMore = s.getMinimumPoint()
  393. .getBlockZ();
  394. /* 236:224 */int yMore = s.getMinimumPoint()
  395. .getBlockY();
  396. /* 237:225 */int xLess = s.getMaximumPoint()
  397. .getBlockX();
  398. /* 238:226 */int zLess = s.getMaximumPoint()
  399. .getBlockZ();
  400. /* 239:227 */int yLess = s.getMaximumPoint()
  401. .getBlockY();
  402. /* 240:228 */getConfig().set(
  403. "Koth." + name + ".xMore",
  404. Integer.valueOf(xMore));
  405. /* 241:229 */getConfig().set(
  406. "Koth." + name + ".xLess",
  407. Integer.valueOf(xLess));
  408. /* 242:230 */getConfig().set(
  409. "Koth." + name + ".zMore",
  410. Integer.valueOf(zMore));
  411. /* 243:231 */getConfig().set(
  412. "Koth." + name + ".zLess",
  413. Integer.valueOf(zLess));
  414. /* 244:232 */getConfig().set(
  415. "Koth." + name + ".yMore",
  416. Integer.valueOf(yMore));
  417. /* 245:233 */getConfig().set(
  418. "Koth." + name + ".yLess",
  419. Integer.valueOf(yLess));
  420. /* 246:234 */saveConfig();
  421. /* 247: */}
  422. /* 248: */}
  423. if ((args[0].equalsIgnoreCase("chest")) &&
  424. (player.isOp()))
  425. {
  426. Selection s = getWE().getSelection(player);
  427. if (s == null)
  428. {
  429. player.sendMessage(ChatColor.RED + "Make a selection first");
  430. return true;
  431. }
  432. player.sendMessage(ChatColor.GOLD + "[" + ChatColor.YELLOW + "HCFKoth" + ChatColor.GOLD + "]" + ChatColor.GOLD + " Koth chest added");
  433. String name = args[1];
  434. int x = s.getMinimumPoint().getBlockX();
  435. int z = s.getMinimumPoint().getBlockZ();
  436. int y = s.getMinimumPoint().getBlockY();
  437. getConfig().set("Koth." + name + ".xChest", Integer.valueOf(x));
  438. getConfig().set("Koth." + name + ".zChest", Integer.valueOf(z));
  439. getConfig().set("Koth." + name + ".yChest", Integer.valueOf(y));
  440. saveConfig();
  441. }
  442. }
  443. }
  444. }
  445. return false;
  446. /* 272: */}
  447.  
  448. /* 273: */
  449. /* 274: */@EventHandler
  450. /* 275: */ public void q(PlayerMoveEvent event)
  451. /* 276: */ {
  452. /* 277:267 */ Player player = event.getPlayer();
  453. /* 278:268 */ Location loc = player.getLocation();
  454. /* 279:269 */ double x = loc.getBlockX();
  455. /* 280:270 */ double z = loc.getBlockZ();
  456. /* 281:271 */ if (this.koth) {
  457. /* 282:273 */ if ((x > getConfig().getDouble("Koth." + this.name + ".xMore")) && (x < getConfig().getDouble("Koth." + this.name + ".xLess")) && (z < getConfig().getDouble("Koth." + this.name + ".zLess")) && (z > getConfig().getDouble("Koth." + this.name + ".zMore")) && (loc.getBlockY() > getConfig().getDouble("Koth." + this.name + ".yMore")) && (loc.getBlockY() < getConfig().getDouble("Koth." + this.name + ".yLess")))
  458. /* 283: */ {
  459. /* 284:274 */ if (!this.inHill.contains(player))
  460. /* 285: */ {
  461. /* 286:275 */ this.inHill.add(player);
  462. /* 287:276 */ player.sendMessage(ChatColor.GOLD + "[" + ChatColor.YELLOW + "HCFKoth" + ChatColor.GOLD + "] " + ChatColor.GOLD + "Entering" + ChatColor.YELLOW + " cap zone");
  463. /* 288: */ }
  464. /* 289:278 */ if (this.control.isEmpty())
  465. /* 290: */ {
  466. /* 291: */ Player p;
  467. /* 293:280 */ if (this.inHill.size() == 1)
  468. /* 294: */ {
  469. p = player;
  470. }
  471. else
  472. {
  473. Collections.shuffle(this.inHill);
  474. p = (Player)this.inHill.get(0);
  475. }
  476. this.control.add(p);
  477. this.lastControl = p.getName();
  478. this.time = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable()
  479. {
  480. public void run()
  481. {
  482. if ((Koth.this.controltime % 30 == 0) && (Koth.this.controltime > 0))
  483. {
  484. int minutes = Koth.this.controltime % 3600 / 60;
  485. int seconds = Koth.this.controltime % 60;
  486. String t = String.format("%02d:%02d", new Object[] { Integer.valueOf(minutes), Integer.valueOf(seconds) });
  487.  
  488. Bukkit.broadcastMessage(ChatColor.GOLD + "[" + ChatColor.YELLOW + "HCFKoth" + ChatColor.GOLD + "] " + ChatColor.GREEN + Koth.this.name + ChatColor.GOLD + " is being controlled by " + ChatColor.GREEN + p.getName() + ChatColor.GREEN + " (" + ChatColor.WHITE + t + ChatColor.WHITE + ")");
  489. }
  490. if (Koth.this.controltime == 0)
  491. {
  492. Bukkit.broadcastMessage(ChatColor.GOLD + "[" + ChatColor.YELLOW + "HCFKoth" + ChatColor.GOLD + "]" + ChatColor.YELLOW + " " + ChatColor.RED + p.getName() + ChatColor.YELLOW + " has won the Koth.");
  493. Koth.this.getServer().getScheduler().cancelTask(Koth.this.time);
  494. Koth.this.koth = false;
  495. Koth.this.inHill.clear();
  496. Koth.this.control.clear();
  497. Koth.this.controltime = 60;
  498.  
  499. Koth.this.st = false;
  500. Koth.this.k.clear();
  501. Koth.this.winner = p.getName();
  502. Koth.this.getServer().getScheduler().cancelTask(Koth.this.c);
  503. Block b = Bukkit.getWorld(p.getWorld().getName()).getBlockAt(Koth.this.ko.getConfig().getInt("Koth." + Koth.this.name + ".xChest"), Koth.this.ko.getConfig().getInt("Koth." + Koth.this.name + ".yChest"), Koth.this.ko.getConfig().getInt("Koth." + Koth.this.name + ".zChest"));
  504. b.setType(Material.CHEST);
  505. Koth.this.chest = ((Chest)b.getState());
  506.  
  507. Koth.this.winner = p.getName();
  508. if ((b.getState() instanceof Chest))
  509. {
  510.  
  511. ArrayList<ItemStack> toAdd = new ArrayList<ItemStack>();
  512. int percentage = new Random().nextInt(100);
  513. int addUntilPercentage = 0;
  514. ItemStack g = new ItemStack(Material.GOLD_BLOCK, 32 );
  515. ItemStack d = new ItemStack(Material.DIAMOND_BLOCK, 32);
  516. addUntilPercentage += 30;
  517. if(addUntilPercentage >= percentage) {toAdd.add(g); toAdd.add(d);}
  518. else{
  519. ItemStack e = new ItemStack(Material.GOLDEN_APPLE, 2);
  520. ItemStack ds1 = new ItemStack(Material.DIAMOND_SWORD);
  521. ds1.addEnchantment(Enchantment.KNOCKBACK, 1);
  522. addUntilPercentage += 25;
  523. if(addUntilPercentage >= percentage) {toAdd.add(e); toAdd.add(ds1);}
  524. else{
  525. ItemStack w = new ItemStack(Material.ENDER_PEARL, 64);
  526. ItemStack p = new ItemStack(Material.SULPHUR, 64);
  527. addUntilPercentage += 15;
  528. if(addUntilPercentage >= percentage) {toAdd.add(w); toAdd.add(p);}
  529. else{
  530. ItemStack s = new ItemStack(Material.SLIME_BALL, 64);
  531. ItemStack dp1 = new ItemStack(Material.DIAMOND_PICKAXE);
  532. dp1.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
  533. dp1.addEnchantment(Enchantment.DIG_SPEED, 4);
  534. addUntilPercentage += 15;
  535. if(addUntilPercentage >= percentage) {toAdd.add(s); toAdd.add(dp1);}
  536. else{
  537. ItemStack b1 = new ItemStack(Material.BEACON, 1);
  538. ItemStack ds2 = new ItemStack(Material.DIAMOND_SWORD);
  539. ds2.addEnchantment(Enchantment.LOOT_BONUS_MOBS, 3);
  540. ds2.addEnchantment(Enchantment.DAMAGE_ALL, 1);
  541. addUntilPercentage += 15;
  542. if(addUntilPercentage >= percentage) {toAdd.add(b1); toAdd.add(ds2);}
  543.  
  544. }
  545. }
  546. }
  547. int index = 0;
  548. for(ItemStack add : toAdd){
  549. Koth.this.chest.getInventory().setItem(index, add);
  550. index++;
  551. }
  552. }
  553. }
  554. }
  555. Koth.this.controltime -= 1;
  556. Koth.this.finish = 1;
  557.  
  558.  
  559.  
  560.  
  561. }
  562. }, 0L, 20L);
  563. }
  564. }
  565.  
  566. else if (this.inHill.contains(player))
  567. {
  568. this.inHill.remove(player);
  569. if (this.control.contains(player))
  570. {
  571. getServer().getScheduler().cancelTask(this.time);
  572. this.controltime = 60;
  573. this.control.remove(player);
  574. }
  575. player.sendMessage(ChatColor.GOLD + "[" + ChatColor.YELLOW + "HCFKoth" + ChatColor.GOLD + "] " + ChatColor.GOLD + "Leaving" + ChatColor.YELLOW + " cap zone");
  576. }
  577. }
  578. }
  579.  
  580. @EventHandler
  581. public void InventoryClick(InventoryClickEvent event) {
  582. if (event.getInventory().getName().equalsIgnoreCase("Koth Loot")) {
  583. event.setCancelled(true);
  584. } else if (event.getInventory().getName()
  585. .equalsIgnoreCase("Koth Modes")) {
  586. Player player = (Player) event.getWhoClicked();
  587. ItemStack clicked = event.getCurrentItem();
  588. if (clicked.getType() == Material.DIAMOND_SWORD) {
  589. ItemMeta i = clicked.getItemMeta();
  590. final String n = i.getDisplayName();
  591. event.setCancelled(true);
  592. Bukkit.broadcastMessage(ChatColor.GOLD
  593. + "["
  594. + ChatColor.YELLOW
  595. + "HCFKoth"
  596. + ChatColor.GOLD
  597. + "]"
  598. + ChatColor.GREEN
  599. + " A koth is about to begin! The map coordinates will be shown shortly!");
  600. Bukkit.getServer().getScheduler()
  601. .scheduleSyncDelayedTask(this, new Runnable() {
  602. public void run() {
  603. Koth.this.name = n;
  604. Bukkit
  605. .broadcastMessage(ChatColor.GOLD + "["
  606. + ChatColor.YELLOW + "HCFKoth"
  607. + ChatColor.GOLD + "]"
  608. + ChatColor.GREEN
  609. + " The koth has begun");
  610. Bukkit
  611. .broadcastMessage(ChatColor.GOLD + "["
  612. + ChatColor.YELLOW + "HCFKoth"
  613. + ChatColor.GOLD + "]"
  614. + ChatColor.GREEN
  615. + " The koth map is "
  616. + ChatColor.GRAY
  617. + Koth.this.name);
  618. Bukkit
  619. .broadcastMessage(ChatColor.GOLD
  620. + "["
  621. + ChatColor.YELLOW
  622. + "HCFKoth"
  623. + ChatColor.GOLD
  624. + "]"
  625. + ChatColor.GREEN
  626. + " The coordinates are "
  627. + ChatColor.YELLOW
  628. + "x"
  629. + Koth.this.ko
  630. .getConfig()
  631. .getString(
  632. new StringBuilder(
  633. "Koth.")
  634. .append(Koth.this.name)
  635. .append(".xMore")
  636. .toString())
  637. + " z"
  638. + Koth.this.ko
  639. .getConfig()
  640. .getString(
  641. new StringBuilder(
  642. "Koth.")
  643. .append(Koth.this.name)
  644. .append(".zMore")
  645. .toString()));
  646. Koth.this.koth = true;
  647. }
  648.  
  649. }, 100L);
  650. this.c = Bukkit.getServer().getScheduler()
  651. .scheduleSyncRepeatingTask(this, new Runnable()
  652. {
  653. public void run() {
  654. Bukkit.broadcastMessage(ChatColor.GOLD
  655. + "["
  656. + ChatColor.YELLOW
  657. + "HCFKoth"
  658. + ChatColor.GOLD
  659. + "]"
  660. + ChatColor.GOLD
  661. + " The "
  662. + ChatColor.GRAY
  663. + Koth.this.name
  664. + ChatColor.GOLD
  665. + " coordinates are "
  666. + ChatColor.YELLOW
  667. + "x"
  668. + Koth.this.ko.getConfig().getString(
  669. new StringBuilder("Koth.")
  670. .append(Koth.this.name)
  671. .append(".xMore")
  672. .toString())
  673. + " z"
  674. + Koth.this.ko.getConfig().getString(
  675. new StringBuilder("Koth.")
  676. .append(Koth.this.name)
  677. .append(".zMore")
  678. .toString()));
  679. }
  680. }, 4800L, 7200L);
  681. player.closeInventory();
  682. }
  683. }
  684. }
  685.  
  686. @EventHandler
  687. public void q(PlayerInteractEvent event)
  688. {
  689. if ((event.getAction() == Action.RIGHT_CLICK_BLOCK) &&
  690. (event.getClickedBlock().getType() == Material.CHEST))
  691. {
  692. Block b = event.getClickedBlock();
  693. if ((b.getLocation().getBlockX() == -543)
  694. && (b.getLocation().getBlockY() == 67)
  695. && (b.getLocation().getBlockZ() == 1840) &&
  696. (event.getPlayer().getName() != this.winner))
  697. {
  698. event.getPlayer().sendMessage(
  699. ChatColor.GRAY + "[" + ChatColor.AQUA + "KOTH"
  700. + ChatColor.GRAY + "]" + ChatColor.RED
  701. + " Only the Koth winner can open this chest");
  702. event.setCancelled(true);
  703. }
  704. }
  705. }
  706.  
  707.  
  708. @EventHandler
  709. public void p(PlayerQuitEvent event)
  710. {
  711. final Player player = event.getPlayer();
  712. if (this.koth) {
  713. Bukkit.getServer().getScheduler()
  714. .scheduleSyncDelayedTask(this, new Runnable() {
  715. public void run() {
  716. if (Koth.this.inHill.contains(player)) {
  717. Koth.this.inHill.remove(player);
  718. }
  719. if (Koth.this.control.contains(player)) {
  720. Koth.this.getServer().getScheduler()
  721. .cancelTask(Koth.this.time);
  722. Koth.this.control.remove(player);
  723. Koth.this.controltime = 60;
  724. }
  725. }
  726. }, 20L);
  727. }
  728. }
  729. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement