Advertisement
Joshb_

Untitled

Oct 22nd, 2021
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.63 KB | None | 0 0
  1. package me.Joshb.PvPKits.Events;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.HashSet;
  6. import java.util.List;
  7. import java.util.UUID;
  8.  
  9. import org.bukkit.Bukkit;
  10. import org.bukkit.Location;
  11. import org.bukkit.Material;
  12. import org.bukkit.World;
  13. import org.bukkit.block.Block;
  14. import org.bukkit.configuration.file.FileConfiguration;
  15. import org.bukkit.entity.ArmorStand;
  16. import org.bukkit.entity.Fireball;
  17. import org.bukkit.entity.Player;
  18. import org.bukkit.entity.TNTPrimed;
  19. import org.bukkit.event.EventHandler;
  20. import org.bukkit.event.EventPriority;
  21. import org.bukkit.event.Listener;
  22. import org.bukkit.event.block.Action;
  23. import org.bukkit.event.inventory.InventoryAction;
  24. import org.bukkit.event.player.PlayerInteractEvent;
  25. import org.bukkit.inventory.ItemStack;
  26. import org.bukkit.potion.PotionEffect;
  27. import org.bukkit.potion.PotionEffectType;
  28. import org.bukkit.scheduler.BukkitRunnable;
  29. import org.bukkit.scheduler.BukkitTask;
  30. import org.bukkit.util.EulerAngle;
  31. import org.bukkit.util.Vector;
  32.  
  33. import com.sk89q.worldguard.bukkit.WGBukkit;
  34. import com.sk89q.worldguard.protection.regions.ProtectedRegion;
  35.  
  36. import me.Joshb.PvPKits.Core;
  37. import me.Joshb.PvPKits.Configs.Messages;
  38. import me.Joshb.PvPKits.Util.ActionBar;
  39. import me.Joshb.PvPKits.Util.CooldownManager;
  40. import me.Joshb.PvPKits.kits.Kits;
  41. import net.md_5.bungee.api.ChatColor;
  42.  
  43. public class OnInteract implements Listener {
  44.  
  45. String prefix = Messages.getInstance().getConfig().getString("Prefix").replaceAll("&", "§");
  46.  
  47. public static ArrayList<UUID> firefly = new ArrayList<UUID>();
  48. public BukkitTask task;
  49. public static HashMap<UUID, BukkitTask> tasker = new HashMap<UUID, BukkitTask>();
  50.  
  51. @EventHandler(priority = EventPriority.HIGHEST)
  52. public void onInteract(PlayerInteractEvent e) {
  53. final Player p = e.getPlayer();
  54.  
  55. for (ProtectedRegion r : WGBukkit.getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation())) {
  56. if (r.getId().contains("spawn")) {
  57. if (!p.getItemInHand().getType().equals(Material.MUSHROOM_STEM)
  58. || !p.getItemInHand().getType().equals(Material.AIR) || !p.getItemInHand().equals(null)) {
  59. e.setCancelled(true);
  60. p.sendMessage(prefix + ChatColor.RED + "You cannot use abilities or weapons in spawn.");
  61. return;
  62. }
  63. }
  64. }
  65.  
  66. if (e.getAction().equals(InventoryAction.HOTBAR_SWAP)
  67. || e.getAction().equals(InventoryAction.SWAP_WITH_CURSOR)) {
  68. e.setCancelled(true);
  69. }
  70.  
  71. if ((p.getItemInHand() != null) && (p.getItemInHand().equals(Kits.soup1()))
  72. && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
  73. || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
  74. if (p.getHealth() < p.getMaxHealth()) {
  75. // double conf =
  76. // Settings.getInstance().getConfig().getDouble("Game-Settings.Soup.Add-Hearts");
  77. double extra = p.getHealth() + 7.0 <= p.getMaxHealth() ? 7.0 : p.getMaxHealth() - p.getHealth();
  78. p.setHealth(p.getHealth() + extra);
  79. p.setItemInHand(new ItemStack(Material.AIR));
  80. ActionBar.sendActionbar(p, ChatColor.GREEN + "" + ChatColor.BOLD + "+3.5 hearts");
  81. e.setCancelled(true);
  82. // p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_BURP, 1.0F,
  83. // 1.0F);
  84. } else {
  85. p.sendMessage(prefix + msgs().getString("Soup-Full-Health").replaceAll("&", "§"));
  86. e.setCancelled(true);
  87. }
  88. } else if ((p.getItemInHand() != null) && (p.getItemInHand().equals(Kits.soup2()))
  89. && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
  90. || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
  91. if (p.getHealth() < p.getMaxHealth()) {
  92. // double conf =
  93. // Settings.getInstance().getConfig().getDouble("Game-Settings.Soup.Add-Hearts");
  94. double extra = p.getHealth() + 10.0 <= p.getMaxHealth() ? 10.0 : p.getMaxHealth() - p.getHealth();
  95. p.setHealth(p.getHealth() + extra);
  96. p.setItemInHand(new ItemStack(Material.AIR));
  97. ActionBar.sendActionbar(p, ChatColor.GREEN + "" + ChatColor.BOLD + "+5 hearts");
  98. e.setCancelled(true);
  99. // p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_BURP, 1.0F,
  100. // 1.0F);
  101. } else {
  102. p.sendMessage(prefix + msgs().getString("Soup-Full-Health").replaceAll("&", "§"));
  103. e.setCancelled(true);
  104. }
  105. } else if ((p.getItemInHand() != null) && (p.getItemInHand().equals(Kits.soup3()))
  106. && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
  107. || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
  108. if (p.getHealth() < p.getMaxHealth()) {
  109. p.setHealth(20.0);
  110. p.setItemInHand(new ItemStack(Material.AIR));
  111. ActionBar.sendActionbar(p, ChatColor.GREEN + "" + ChatColor.BOLD + "+full hearts");
  112. e.setCancelled(true);
  113. // p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_BURP, 1.0F,
  114. // 1.0F);
  115. } else {
  116. p.sendMessage(prefix + msgs().getString("Soup-Full-Health").replaceAll("&", "§"));
  117. e.setCancelled(true);
  118. }
  119. }
  120.  
  121. if (Kits.getInstance().fireFlyEvent01.contains(p.getUniqueId())) {
  122. if (!p.getItemInHand().getType().equals(Material.FIRE_CHARGE)) {
  123. return;
  124. }
  125. if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
  126. || e.getAction().equals(Action.PHYSICAL)) {
  127. return;
  128. }
  129.  
  130. if (CooldownManager.getManager().isInCooldown(p)) {
  131. e.setCancelled(true);
  132. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  133. if (i > 1) {
  134. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
  135. }
  136. if (i == 1) {
  137. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
  138. }
  139. if (i == 0) {
  140. p.sendMessage(ChatColor.RED + "You cannot use till now");
  141. }
  142. return;
  143. }
  144.  
  145. CooldownManager.getManager().create(p, 30);
  146.  
  147. if (p.getItemInHand().getAmount() <= 1) {
  148. p.setItemInHand(null);
  149. } else {
  150. p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
  151. }
  152.  
  153. p.launchProjectile(Fireball.class);
  154.  
  155. new BukkitRunnable() {
  156.  
  157. public void run() {
  158. if (!CooldownManager.getManager().isInCooldown(p)) {
  159. p.setLevel(0);
  160. p.setExp(0);
  161. this.cancel();
  162. return;
  163. }
  164. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  165. p.setLevel(i);
  166. p.setExp(i / (float) 30);
  167. }
  168. }.runTaskTimer(Core.plugin, 0, 20);
  169. }
  170.  
  171. if (Kits.getInstance().alchemistEvent01.contains(p.getUniqueId())) {
  172. if (!p.getItemInHand().getType().equals(Material.POTION)) {
  173. return;
  174. }
  175. if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
  176. || e.getAction().equals(Action.PHYSICAL)) {
  177. return;
  178. }
  179.  
  180. CooldownManager.getManager().create(p, 15);
  181. p.getItemInHand().setAmount(0);
  182. new BukkitRunnable() {
  183.  
  184. public void run() {
  185. if (!Kits.getInstance().alchemistEvent01.contains(p.getUniqueId())) {
  186. this.cancel();
  187. return;
  188. }
  189. if (!CooldownManager.getManager().isInCooldown(p)) {
  190. p.setLevel(0);
  191. p.setExp(0);
  192. Kits.getInstance().alchemistGivePotion(p);
  193. this.cancel();
  194. return;
  195. }
  196. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  197. p.setLevel(i);
  198. p.setExp(i / (float) 15);
  199. }
  200. }.runTaskTimer(Core.plugin, 0, 20);
  201. }
  202.  
  203. if (Kits.getInstance().assassinEvent01.contains(p.getUniqueId())) {
  204. if (!p.getItemInHand().getType().equals(Material.REDSTONE)) {
  205. return;
  206. }
  207.  
  208. if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
  209. || e.getAction().equals(Action.PHYSICAL)) {
  210. return;
  211. }
  212.  
  213. if (CooldownManager.getManager().isInCooldown(p)) {
  214. e.setCancelled(true);
  215. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  216. if (i > 1) {
  217. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
  218. }
  219. if (i == 1) {
  220. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
  221. }
  222. if (i == 0) {
  223. p.sendMessage(ChatColor.RED + "You cannot use till now");
  224. }
  225. return;
  226. }
  227.  
  228. CooldownManager.getManager().create(p, 20);
  229. p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20 * 5, 0), true);
  230. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20 * 5, 2), true);
  231. new BukkitRunnable() {
  232. public void run() {
  233. p.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 20 * 5, 0), true);
  234. p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 5, 0), true);
  235. }
  236. }.runTaskLater(Core.plugin, 20 * 5);
  237.  
  238. new BukkitRunnable() {
  239. public void run() {
  240. if (!CooldownManager.getManager().isInCooldown(p)) {
  241. p.setLevel(0);
  242. p.setExp(0);
  243. this.cancel();
  244. return;
  245. }
  246. if (!Kits.getInstance().assassinEvent01.contains(p.getUniqueId())) {
  247. this.cancel();
  248. return;
  249. }
  250. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  251. p.setLevel(i);
  252. p.setExp(i / (float) 20);
  253. }
  254. }.runTaskTimer(Core.plugin, 0, 20);
  255. }
  256.  
  257. if (Kits.getInstance().eagleEvent01.contains(p.getUniqueId())) {
  258. if (!p.getItemInHand().getType().equals(Material.QUARTZ)) {
  259. return;
  260. }
  261.  
  262. if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
  263. || e.getAction().equals(Action.PHYSICAL)) {
  264. return;
  265. }
  266.  
  267. if (CooldownManager.getManager().isInCooldown(p)) {
  268. e.setCancelled(true);
  269. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  270. if (i > 1) {
  271. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
  272. }
  273. if (i == 1) {
  274. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
  275. }
  276. if (i == 0) {
  277. p.sendMessage(ChatColor.RED + "You cannot use till now");
  278. }
  279. return;
  280. }
  281. if (p.isOnGround()) {
  282. new BukkitRunnable() {
  283. int i = 2;
  284.  
  285. public void run() {
  286. if (!Kits.getInstance().eagleEvent01.contains(p.getUniqueId())) {
  287. this.cancel();
  288. return;
  289. }
  290. p.setVelocity(p.getEyeLocation().getDirection().multiply(3.0));
  291. float x = 0.0F;
  292. while (x < 2.0F) {
  293. //ParticleEffect.EXPLOSION_LARGE.send(Bukkit.getOnlinePlayers(), p.getLocation().getX(),
  294. // p.getLocation().getY(), p.getLocation().getZ(), 0, 0, 0, 1, 1, 10);
  295. x = (float) (x + 0.2D);
  296. }
  297.  
  298. i--;
  299. if (i == 0) {
  300. this.cancel();
  301. }
  302. }
  303. }.runTaskTimer(Core.plugin, 0, 10);
  304. CooldownManager.getManager().create(p, 15);
  305. new BukkitRunnable() {
  306. public void run() {
  307. if (!CooldownManager.getManager().isInCooldown(p)) {
  308. p.setLevel(0);
  309. p.setExp(0);
  310. this.cancel();
  311. return;
  312. }
  313. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  314. p.setLevel(i);
  315. p.setExp(i / (float) 15);
  316. }
  317. }.runTaskTimer(Core.plugin, 0, 20);
  318. }
  319. }
  320.  
  321. if (Kits.getInstance().iceKeeperEvent01.contains(p.getUniqueId())) {
  322. if (p.getItemInHand().getType().equals(Material.FIREWORK_STAR)) {
  323. if (e.getAction().equals(Action.PHYSICAL)) {
  324. return;
  325. }
  326. if (CooldownManager.getManager().isInCooldown(p)) {
  327. e.setCancelled(true);
  328. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  329. if (i > 1) {
  330. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
  331. }
  332. if (i == 1) {
  333. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
  334. }
  335. if (i == 0) {
  336. p.sendMessage(ChatColor.RED + "You cannot use till now");
  337. }
  338. return;
  339. }
  340. if (p.isOnGround()) {
  341. final List<Location> circleblocks = new ArrayList<Location>();
  342. int cx = p.getLocation().getBlockX();
  343. int cy = p.getLocation().getBlockY();
  344. int cz = p.getLocation().getBlockZ();
  345. for (int x = cx - 5; x <= cx + 6; x++)
  346. for (int z = cz - 5; z <= cz + 6; z++)
  347. for (int y = (true ? cy - 5 : cy); y < (true ? cy + 5 : cy + 6); y++) {
  348. double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z)
  349. + (true ? (cy - y) * (cy - y) : 0);
  350. if (dist < 5 * 5 && !(true && dist < (5 - 1) * (5 - 1))) {
  351. Location l = new Location(p.getLocation().getWorld(), x, y + 0, z);
  352. circleblocks.add(l);
  353. }
  354. }
  355.  
  356. for (Location loc : circleblocks) {
  357. if (loc.getBlock().getType().equals(Material.AIR)) {
  358. loc.getBlock().setType(Material.ICE);
  359. }
  360. }
  361.  
  362. new BukkitRunnable() {
  363. public void run() {
  364. for (Location loc : circleblocks) {
  365. if (loc.getBlock().getType().equals(Material.ICE)) {
  366. loc.getBlock().setType(Material.AIR);
  367. }
  368. }
  369. }
  370. }.runTaskLater(Core.plugin, 20 * 5);
  371.  
  372. CooldownManager.getManager().create(p, 30);
  373. new BukkitRunnable() {
  374. public void run() {
  375. if (!CooldownManager.getManager().isInCooldown(p)) {
  376. p.setLevel(0);
  377. p.setExp(0);
  378. this.cancel();
  379. return;
  380. }
  381. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  382. p.setLevel(i);
  383. p.setExp(i / (float) 30);
  384. }
  385. }.runTaskTimer(Core.plugin, 0, 20);
  386. }
  387.  
  388. }
  389. }
  390.  
  391. if (Kits.getInstance().minotaurEvent.contains(p.getUniqueId())) {
  392. if (!p.getItemInHand().getType().equals(Material.COOKED_BEEF)) {
  393. return;
  394. }
  395. if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
  396. || e.getAction().equals(Action.PHYSICAL)) {
  397. return;
  398. }
  399. if (p.getHealth() < p.getMaxHealth()) {
  400. if (p.getItemInHand().getAmount() == 1) {
  401. p.setItemInHand(null);
  402. } else {
  403. p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
  404. }
  405. p.setHealth(p.getMaxHealth());
  406. } else {
  407. p.sendMessage(prefix + msgs().getString("Soup-Full-Health").replaceAll("&", "§"));
  408. }
  409. }
  410. if (Kits.getInstance().prospectorEvent.contains(p.getUniqueId())) {
  411. if (!p.getItemInHand().getType().equals(Material.TNT)) {
  412. return;
  413. }
  414. if (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)
  415. || e.getAction().equals(Action.PHYSICAL)) {
  416. return;
  417. }
  418.  
  419. if (p.getItemInHand().getAmount() <= 1) {
  420. p.setItemInHand(null);
  421. } else {
  422. p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
  423. }
  424.  
  425. TNTPrimed tnt = (TNTPrimed) p.getWorld().spawn(p.getLocation(), TNTPrimed.class);
  426. tnt.setFuseTicks(60);
  427. tnt.setVelocity(p.getLocation().getDirection().normalize().multiply(2));
  428.  
  429. if (p.getItemInHand().getAmount() == 1) {
  430. new BukkitRunnable() {
  431. public void run() {
  432. if (!Kits.getInstance().prospectorEvent.contains(p.getUniqueId())) {
  433. this.cancel();
  434. return;
  435. }
  436. p.getInventory().addItem(new ItemStack(Material.TNT, 2));
  437. }
  438. }.runTaskLater(Core.plugin, 20 * 15);
  439. }
  440. }
  441.  
  442. if (Kits.getInstance().pyromancerEvent.contains(p.getUniqueId())) {
  443. if (!p.getItemInHand().getType().equals(Material.INK_SAC)) {
  444. return;
  445. }
  446. if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
  447. || e.getAction().equals(Action.PHYSICAL)) {
  448. return;
  449. }
  450.  
  451. if (CooldownManager.getManager().isInCooldown(p)) {
  452. e.setCancelled(true);
  453. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  454. if (i > 1) {
  455. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
  456. }
  457. if (i == 1) {
  458. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
  459. }
  460. if (i == 0) {
  461. p.sendMessage(ChatColor.RED + "You cannot use till now");
  462. }
  463. return;
  464. }
  465. for (Player other : Bukkit.getOnlinePlayers()) {
  466. if (other.getWorld().equals(p.getWorld())) {
  467. if (other.getLocation().distance(p.getLocation()) <= 5) {
  468. if (!other.equals(p)) {
  469. other.setFireTicks(20 * 8);
  470. }
  471. }
  472. }
  473. }
  474. CooldownManager.getManager().create(p, 45);
  475. new BukkitRunnable() {
  476. public void run() {
  477. if (!CooldownManager.getManager().isInCooldown(p)) {
  478. p.setLevel(0);
  479. p.setExp(0);
  480. this.cancel();
  481. return;
  482. }
  483. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  484. p.setLevel(i);
  485. p.setExp(i / (float) 45);
  486. }
  487. }.runTaskTimer(Core.plugin, 0, 20);
  488.  
  489. }
  490.  
  491. if (Kits.getInstance().executionerEvent.contains(p.getUniqueId())) {
  492. if (!p.getItemInHand().getType().equals(Material.DIAMOND_AXE)) {
  493. return;
  494. }
  495.  
  496. final ItemStack i = p.getItemInHand();
  497.  
  498. if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
  499. || e.getAction().equals(Action.PHYSICAL)) {
  500. return;
  501. }
  502.  
  503. if (CooldownManager.getManager().isInCooldown(p)) {
  504. e.setCancelled(true);
  505. int cool = CooldownManager.getManager().getCooldown(p).timeLeft();
  506. if (cool > 1) {
  507. p.sendMessage(ChatColor.RED + "You cannot use this for " + cool + " more seconds!");
  508. }
  509. if (cool == 1) {
  510. p.sendMessage(ChatColor.RED + "You cannot use this for " + cool + " more second!");
  511. }
  512. if (cool == 0) {
  513. p.sendMessage(ChatColor.RED + "You cannot use till now");
  514. }
  515. return;
  516. }
  517. CooldownManager.getManager().create(p, 10);
  518.  
  519. p.setItemInHand(null);
  520.  
  521. Location ploc = p.getLocation().add(0, 0, 0);
  522.  
  523. final ArmorStand as = (ArmorStand) ploc.getWorld().spawn(ploc, ArmorStand.class);
  524.  
  525. as.setGravity(false);
  526. as.setCanPickupItems(false);
  527. as.setVisible(false);
  528. as.setArms(true);
  529.  
  530. as.setItemInHand(i);
  531.  
  532. EulerAngle rightArm = new EulerAngle(0F, 0F, degreesToRadians(270F));
  533. as.setRightArmPose(rightArm);
  534.  
  535. final BukkitTask task1;
  536. final BukkitTask task2;
  537.  
  538. task1 = new BukkitRunnable() {
  539. float start = 0;
  540.  
  541. public void run() {
  542. EulerAngle pose = new EulerAngle(degreesToRadians(start), 0F, degreesToRadians(270F));
  543. as.setRightArmPose(pose);
  544. start = start + 10F;
  545. }
  546. }.runTaskTimer(Core.plugin, 0, 1);
  547.  
  548. task2 = new BukkitRunnable() {
  549. float start = 0;
  550. Location loc = p.getLocation();
  551.  
  552. public void run() {
  553. if (!Kits.getInstance().executionerEvent.contains(p.getUniqueId())) {
  554. task1.cancel();
  555. this.cancel();
  556. as.remove();
  557. }
  558. Vector dir = loc.getDirection();
  559. dir.normalize();
  560. dir.multiply(0.8);
  561. loc.add(dir);
  562. as.teleport(loc);
  563. if (!Kits.getInstance().executionerEvent.contains(p.getUniqueId())) {
  564. task1.cancel();
  565. this.cancel();
  566. as.remove();
  567. }
  568. if (!as.getLocation().add(0, 1, 0).getBlock().getType().equals(Material.AIR)) {
  569. task1.cancel();
  570. this.cancel();
  571. as.remove();
  572. p.getInventory().setItem(0, i);
  573. }
  574. for (Player players : Bukkit.getOnlinePlayers()) {
  575. if (players != p) {
  576. if (players.getWorld().equals(p.getWorld())) {
  577. if (as.getLocation().distance(players.getLocation()) <= 0.9) {
  578. task1.cancel();
  579. players.damage(16.0, p);
  580. this.cancel();
  581. as.remove();
  582. p.getInventory().setItem(0, i);
  583. }
  584. }
  585. }
  586. }
  587. }
  588. }.runTaskTimer(Core.plugin, 0, 1);
  589.  
  590. new BukkitRunnable() {
  591. public void run() {
  592. if (p.getInventory().getItem(0) == null) {
  593. task1.cancel();
  594. task2.cancel();
  595. as.remove();
  596. p.getInventory().setItem(0, i);
  597. }
  598. }
  599. }.runTaskLater(Core.plugin, 20 * 10);
  600.  
  601. new BukkitRunnable() {
  602.  
  603. public void run() {
  604. if (!Kits.getInstance().executionerEvent.contains(p.getUniqueId())) {
  605. task1.cancel();
  606. task2.cancel();
  607. as.remove();
  608. }
  609. if (!CooldownManager.getManager().isInCooldown(p)) {
  610. p.setLevel(0);
  611. p.setExp(0);
  612. this.cancel();
  613. return;
  614. }
  615. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  616. p.setLevel(i);
  617. p.setExp(i / (float) 10);
  618. }
  619. }.runTaskTimer(Core.plugin, 0, 20);
  620. }
  621.  
  622. if (p.getItemInHand().getType().equals(Material.IRON_AXE) && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
  623. || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
  624. if (Kits.getInstance().thorEvent01.contains(p.getUniqueId())) {
  625. if (CooldownManager.getManager().isInCooldown(p)) {
  626. e.setCancelled(true);
  627. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  628. if (i > 1) {
  629. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
  630. }
  631. if (i == 1) {
  632. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
  633. }
  634. if (i == 0) {
  635. p.sendMessage(ChatColor.RED + "You cannot use till now");
  636. }
  637. return;
  638. }
  639. Block b = p.getTargetBlock((HashSet<Material>) null, 100);
  640. Location loc = b.getLocation();
  641.  
  642. for (ProtectedRegion r : WGBukkit.getRegionManager(p.getWorld())
  643. .getApplicableRegions(b.getLocation())) {
  644. if (r.getId().contains("spawn")) {
  645. p.sendMessage(prefix + ChatColor.RED + "Cannot use this aimed at spawn!");
  646. return;
  647. }
  648. }
  649. CooldownManager.getManager().create(p, 10);
  650. p.getWorld().strikeLightningEffect(loc);
  651. for (Player other : Bukkit.getOnlinePlayers()) {
  652. if (other.getWorld().equals(p.getWorld())) {
  653. if (other.getLocation().distance(loc) <= 6) {
  654. if (!other.equals(p)) {
  655. other.damage(6.0);
  656. }
  657. }
  658. }
  659. }
  660.  
  661. new BukkitRunnable() {
  662.  
  663. public void run() {
  664. if (!CooldownManager.getManager().isInCooldown(p)) {
  665. p.setLevel(0);
  666. p.setExp(0);
  667. this.cancel();
  668. return;
  669. }
  670. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  671. p.setLevel(i);
  672. p.setExp(i / (float) 10);
  673. }
  674. }.runTaskTimer(Core.plugin, 0, 20);
  675.  
  676. }
  677. } else if (p.getItemInHand().getType().equals(Material.GOLD_INGOT)
  678. && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
  679. || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
  680. if (Kits.getInstance().percyEvent02.contains(p.getUniqueId())) {
  681. if (CooldownManager.getManager().isInCooldown(p)) {
  682. e.setCancelled(true);
  683. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  684. if (i > 1) {
  685. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
  686. }
  687. if (i == 1) {
  688. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
  689. }
  690. if (i == 0) {
  691. p.sendMessage(ChatColor.RED + "You cannot use till now");
  692. }
  693. return;
  694. }
  695. int newAmount = p.getItemInHand().getAmount() - 1;
  696. if (newAmount == 0) {
  697. p.setItemInHand(null);
  698. } else {
  699. p.getItemInHand().setAmount(newAmount);
  700. }
  701. p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 5, 0), true);
  702. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20 * 5, 2), true);
  703. CooldownManager.getManager().create(p, 20);
  704. new BukkitRunnable() {
  705. public void run() {
  706. if (!CooldownManager.getManager().isInCooldown(p)) {
  707. p.setLevel(0);
  708. p.setExp(0);
  709. this.cancel();
  710. return;
  711. }
  712. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  713. p.setLevel(i);
  714. p.setExp(i / (float) 20);
  715. }
  716. }.runTaskTimer(Core.plugin, 0, 20);
  717. }
  718. } else if (p.getItemInHand().getType().equals(Material.IRON_SWORD)
  719. && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
  720. || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
  721. if (Kits.getInstance().soldierEvent01.contains(p.getUniqueId())) {
  722. if (p.isOnGround()) {
  723. Vector v = new Vector(0, 0.8, 0);
  724. p.setVelocity(v);
  725. }
  726. }
  727. } else if (p.getItemInHand().getType().equals(Material.FEATHER)
  728. && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
  729. || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
  730. if (Kits.getInstance().gankEvent01.contains(p.getUniqueId())) {
  731. if (CooldownManager.getManager().isInCooldown(p)) {
  732. e.setCancelled(true);
  733. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  734. if (i > 1) {
  735. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
  736. }
  737. if (i == 1) {
  738. p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
  739. }
  740. if (i == 0) {
  741. p.sendMessage(ChatColor.RED + "You cannot use till now");
  742. }
  743. return;
  744. }
  745. int newAmount = p.getItemInHand().getAmount() - 1;
  746. if (newAmount == 0) {
  747. p.setItemInHand(null);
  748. } else {
  749. p.getItemInHand().setAmount(newAmount);
  750. }
  751. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20 * 5, 3), true);
  752. CooldownManager.getManager().create(p, 20);
  753. new BukkitRunnable() {
  754.  
  755. public void run() {
  756. if (!CooldownManager.getManager().isInCooldown(p)) {
  757. p.setLevel(0);
  758. p.setExp(0);
  759. this.cancel();
  760. return;
  761. }
  762. int i = CooldownManager.getManager().getCooldown(p).timeLeft();
  763. p.setLevel(i);
  764. p.setExp(i / (float) 20);
  765. }
  766. }.runTaskTimer(Core.plugin, 0, 20);
  767. }
  768. } else if (p.getItemInHand().getType().equals(Material.DIAMOND_SWORD)
  769. && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
  770. || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
  771. if (Kits.getInstance().knightEvent01.contains(p.getUniqueId())) {
  772. p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 0));
  773. new BukkitRunnable() {
  774. public void run() {
  775. if (!p.isBlocking()) {
  776. p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
  777. }
  778. }
  779. }.runTaskTimer(Core.plugin, 0, 5);
  780. }
  781. }
  782. }
  783.  
  784. private static FileConfiguration msgs() {
  785. return Messages.getInstance().getConfig();
  786. }
  787.  
  788. public List<Block> getBlocks(Location pos1, Location pos2) {
  789. if (pos1.getWorld() != pos2.getWorld())
  790. return null;
  791. World world = pos1.getWorld();
  792. List<Block> blocks = new ArrayList<>();
  793. int x1 = pos1.getBlockX();
  794. int y1 = pos1.getBlockY();
  795. int z1 = pos1.getBlockZ();
  796.  
  797. int x2 = pos2.getBlockX();
  798. int y2 = pos2.getBlockY();
  799. int z2 = pos2.getBlockZ();
  800.  
  801. int lowestX = Math.min(x1, x2);
  802. int lowestY = Math.min(y1, y2);
  803. int lowestZ = Math.min(z1, z2);
  804.  
  805. int highestX = lowestX == x1 ? x2 : x1;
  806. int highestY = lowestX == y1 ? y2 : y1;
  807. int highestZ = lowestX == z1 ? z2 : z1;
  808.  
  809. for (int x = lowestX; x <= highestX; x++)
  810. for (int y = lowestY; x <= highestY; y++)
  811. for (int z = lowestZ; x <= highestZ; z++)
  812. blocks.add(world.getBlockAt(x, y, z));
  813. return blocks;
  814. }
  815.  
  816. public static float radiansToDegrees(float radians) {
  817. return (float) ((radians * 180) / Math.PI);
  818. }
  819.  
  820. public static float degreesToRadians(float degrees) {
  821. return (float) ((degrees * Math.PI) / 180);
  822. }
  823.  
  824. }
  825.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement