Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Joshb.PvPKits.Events;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.List;
- import java.util.UUID;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.entity.ArmorStand;
- import org.bukkit.entity.Fireball;
- import org.bukkit.entity.Player;
- import org.bukkit.entity.TNTPrimed;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.EventPriority;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.inventory.InventoryAction;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- import org.bukkit.scheduler.BukkitRunnable;
- import org.bukkit.scheduler.BukkitTask;
- import org.bukkit.util.EulerAngle;
- import org.bukkit.util.Vector;
- import com.sk89q.worldguard.bukkit.WGBukkit;
- import com.sk89q.worldguard.protection.regions.ProtectedRegion;
- import me.Joshb.PvPKits.Core;
- import me.Joshb.PvPKits.Configs.Messages;
- import me.Joshb.PvPKits.Util.ActionBar;
- import me.Joshb.PvPKits.Util.CooldownManager;
- import me.Joshb.PvPKits.kits.Kits;
- import net.md_5.bungee.api.ChatColor;
- public class OnInteract implements Listener {
- String prefix = Messages.getInstance().getConfig().getString("Prefix").replaceAll("&", "§");
- public static ArrayList<UUID> firefly = new ArrayList<UUID>();
- public BukkitTask task;
- public static HashMap<UUID, BukkitTask> tasker = new HashMap<UUID, BukkitTask>();
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onInteract(PlayerInteractEvent e) {
- final Player p = e.getPlayer();
- for (ProtectedRegion r : WGBukkit.getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation())) {
- if (r.getId().contains("spawn")) {
- if (!p.getItemInHand().getType().equals(Material.MUSHROOM_STEM)
- || !p.getItemInHand().getType().equals(Material.AIR) || !p.getItemInHand().equals(null)) {
- e.setCancelled(true);
- p.sendMessage(prefix + ChatColor.RED + "You cannot use abilities or weapons in spawn.");
- return;
- }
- }
- }
- if (e.getAction().equals(InventoryAction.HOTBAR_SWAP)
- || e.getAction().equals(InventoryAction.SWAP_WITH_CURSOR)) {
- e.setCancelled(true);
- }
- if ((p.getItemInHand() != null) && (p.getItemInHand().equals(Kits.soup1()))
- && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
- || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
- if (p.getHealth() < p.getMaxHealth()) {
- // double conf =
- // Settings.getInstance().getConfig().getDouble("Game-Settings.Soup.Add-Hearts");
- double extra = p.getHealth() + 7.0 <= p.getMaxHealth() ? 7.0 : p.getMaxHealth() - p.getHealth();
- p.setHealth(p.getHealth() + extra);
- p.setItemInHand(new ItemStack(Material.AIR));
- ActionBar.sendActionbar(p, ChatColor.GREEN + "" + ChatColor.BOLD + "+3.5 hearts");
- e.setCancelled(true);
- // p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_BURP, 1.0F,
- // 1.0F);
- } else {
- p.sendMessage(prefix + msgs().getString("Soup-Full-Health").replaceAll("&", "§"));
- e.setCancelled(true);
- }
- } else if ((p.getItemInHand() != null) && (p.getItemInHand().equals(Kits.soup2()))
- && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
- || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
- if (p.getHealth() < p.getMaxHealth()) {
- // double conf =
- // Settings.getInstance().getConfig().getDouble("Game-Settings.Soup.Add-Hearts");
- double extra = p.getHealth() + 10.0 <= p.getMaxHealth() ? 10.0 : p.getMaxHealth() - p.getHealth();
- p.setHealth(p.getHealth() + extra);
- p.setItemInHand(new ItemStack(Material.AIR));
- ActionBar.sendActionbar(p, ChatColor.GREEN + "" + ChatColor.BOLD + "+5 hearts");
- e.setCancelled(true);
- // p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_BURP, 1.0F,
- // 1.0F);
- } else {
- p.sendMessage(prefix + msgs().getString("Soup-Full-Health").replaceAll("&", "§"));
- e.setCancelled(true);
- }
- } else if ((p.getItemInHand() != null) && (p.getItemInHand().equals(Kits.soup3()))
- && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
- || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
- if (p.getHealth() < p.getMaxHealth()) {
- p.setHealth(20.0);
- p.setItemInHand(new ItemStack(Material.AIR));
- ActionBar.sendActionbar(p, ChatColor.GREEN + "" + ChatColor.BOLD + "+full hearts");
- e.setCancelled(true);
- // p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_BURP, 1.0F,
- // 1.0F);
- } else {
- p.sendMessage(prefix + msgs().getString("Soup-Full-Health").replaceAll("&", "§"));
- e.setCancelled(true);
- }
- }
- if (Kits.getInstance().fireFlyEvent01.contains(p.getUniqueId())) {
- if (!p.getItemInHand().getType().equals(Material.FIRE_CHARGE)) {
- return;
- }
- if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
- || e.getAction().equals(Action.PHYSICAL)) {
- return;
- }
- if (CooldownManager.getManager().isInCooldown(p)) {
- e.setCancelled(true);
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- if (i > 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
- }
- if (i == 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
- }
- if (i == 0) {
- p.sendMessage(ChatColor.RED + "You cannot use till now");
- }
- return;
- }
- CooldownManager.getManager().create(p, 30);
- if (p.getItemInHand().getAmount() <= 1) {
- p.setItemInHand(null);
- } else {
- p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
- }
- p.launchProjectile(Fireball.class);
- new BukkitRunnable() {
- public void run() {
- if (!CooldownManager.getManager().isInCooldown(p)) {
- p.setLevel(0);
- p.setExp(0);
- this.cancel();
- return;
- }
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- p.setLevel(i);
- p.setExp(i / (float) 30);
- }
- }.runTaskTimer(Core.plugin, 0, 20);
- }
- if (Kits.getInstance().alchemistEvent01.contains(p.getUniqueId())) {
- if (!p.getItemInHand().getType().equals(Material.POTION)) {
- return;
- }
- if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
- || e.getAction().equals(Action.PHYSICAL)) {
- return;
- }
- CooldownManager.getManager().create(p, 15);
- p.getItemInHand().setAmount(0);
- new BukkitRunnable() {
- public void run() {
- if (!Kits.getInstance().alchemistEvent01.contains(p.getUniqueId())) {
- this.cancel();
- return;
- }
- if (!CooldownManager.getManager().isInCooldown(p)) {
- p.setLevel(0);
- p.setExp(0);
- Kits.getInstance().alchemistGivePotion(p);
- this.cancel();
- return;
- }
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- p.setLevel(i);
- p.setExp(i / (float) 15);
- }
- }.runTaskTimer(Core.plugin, 0, 20);
- }
- if (Kits.getInstance().assassinEvent01.contains(p.getUniqueId())) {
- if (!p.getItemInHand().getType().equals(Material.REDSTONE)) {
- return;
- }
- if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
- || e.getAction().equals(Action.PHYSICAL)) {
- return;
- }
- if (CooldownManager.getManager().isInCooldown(p)) {
- e.setCancelled(true);
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- if (i > 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
- }
- if (i == 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
- }
- if (i == 0) {
- p.sendMessage(ChatColor.RED + "You cannot use till now");
- }
- return;
- }
- CooldownManager.getManager().create(p, 20);
- p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20 * 5, 0), true);
- p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20 * 5, 2), true);
- new BukkitRunnable() {
- public void run() {
- p.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 20 * 5, 0), true);
- p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 5, 0), true);
- }
- }.runTaskLater(Core.plugin, 20 * 5);
- new BukkitRunnable() {
- public void run() {
- if (!CooldownManager.getManager().isInCooldown(p)) {
- p.setLevel(0);
- p.setExp(0);
- this.cancel();
- return;
- }
- if (!Kits.getInstance().assassinEvent01.contains(p.getUniqueId())) {
- this.cancel();
- return;
- }
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- p.setLevel(i);
- p.setExp(i / (float) 20);
- }
- }.runTaskTimer(Core.plugin, 0, 20);
- }
- if (Kits.getInstance().eagleEvent01.contains(p.getUniqueId())) {
- if (!p.getItemInHand().getType().equals(Material.QUARTZ)) {
- return;
- }
- if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
- || e.getAction().equals(Action.PHYSICAL)) {
- return;
- }
- if (CooldownManager.getManager().isInCooldown(p)) {
- e.setCancelled(true);
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- if (i > 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
- }
- if (i == 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
- }
- if (i == 0) {
- p.sendMessage(ChatColor.RED + "You cannot use till now");
- }
- return;
- }
- if (p.isOnGround()) {
- new BukkitRunnable() {
- int i = 2;
- public void run() {
- if (!Kits.getInstance().eagleEvent01.contains(p.getUniqueId())) {
- this.cancel();
- return;
- }
- p.setVelocity(p.getEyeLocation().getDirection().multiply(3.0));
- float x = 0.0F;
- while (x < 2.0F) {
- //ParticleEffect.EXPLOSION_LARGE.send(Bukkit.getOnlinePlayers(), p.getLocation().getX(),
- // p.getLocation().getY(), p.getLocation().getZ(), 0, 0, 0, 1, 1, 10);
- x = (float) (x + 0.2D);
- }
- i--;
- if (i == 0) {
- this.cancel();
- }
- }
- }.runTaskTimer(Core.plugin, 0, 10);
- CooldownManager.getManager().create(p, 15);
- new BukkitRunnable() {
- public void run() {
- if (!CooldownManager.getManager().isInCooldown(p)) {
- p.setLevel(0);
- p.setExp(0);
- this.cancel();
- return;
- }
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- p.setLevel(i);
- p.setExp(i / (float) 15);
- }
- }.runTaskTimer(Core.plugin, 0, 20);
- }
- }
- if (Kits.getInstance().iceKeeperEvent01.contains(p.getUniqueId())) {
- if (p.getItemInHand().getType().equals(Material.FIREWORK_STAR)) {
- if (e.getAction().equals(Action.PHYSICAL)) {
- return;
- }
- if (CooldownManager.getManager().isInCooldown(p)) {
- e.setCancelled(true);
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- if (i > 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
- }
- if (i == 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
- }
- if (i == 0) {
- p.sendMessage(ChatColor.RED + "You cannot use till now");
- }
- return;
- }
- if (p.isOnGround()) {
- final List<Location> circleblocks = new ArrayList<Location>();
- int cx = p.getLocation().getBlockX();
- int cy = p.getLocation().getBlockY();
- int cz = p.getLocation().getBlockZ();
- for (int x = cx - 5; x <= cx + 6; x++)
- for (int z = cz - 5; z <= cz + 6; z++)
- for (int y = (true ? cy - 5 : cy); y < (true ? cy + 5 : cy + 6); y++) {
- double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z)
- + (true ? (cy - y) * (cy - y) : 0);
- if (dist < 5 * 5 && !(true && dist < (5 - 1) * (5 - 1))) {
- Location l = new Location(p.getLocation().getWorld(), x, y + 0, z);
- circleblocks.add(l);
- }
- }
- for (Location loc : circleblocks) {
- if (loc.getBlock().getType().equals(Material.AIR)) {
- loc.getBlock().setType(Material.ICE);
- }
- }
- new BukkitRunnable() {
- public void run() {
- for (Location loc : circleblocks) {
- if (loc.getBlock().getType().equals(Material.ICE)) {
- loc.getBlock().setType(Material.AIR);
- }
- }
- }
- }.runTaskLater(Core.plugin, 20 * 5);
- CooldownManager.getManager().create(p, 30);
- new BukkitRunnable() {
- public void run() {
- if (!CooldownManager.getManager().isInCooldown(p)) {
- p.setLevel(0);
- p.setExp(0);
- this.cancel();
- return;
- }
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- p.setLevel(i);
- p.setExp(i / (float) 30);
- }
- }.runTaskTimer(Core.plugin, 0, 20);
- }
- }
- }
- if (Kits.getInstance().minotaurEvent.contains(p.getUniqueId())) {
- if (!p.getItemInHand().getType().equals(Material.COOKED_BEEF)) {
- return;
- }
- if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
- || e.getAction().equals(Action.PHYSICAL)) {
- return;
- }
- if (p.getHealth() < p.getMaxHealth()) {
- if (p.getItemInHand().getAmount() == 1) {
- p.setItemInHand(null);
- } else {
- p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
- }
- p.setHealth(p.getMaxHealth());
- } else {
- p.sendMessage(prefix + msgs().getString("Soup-Full-Health").replaceAll("&", "§"));
- }
- }
- if (Kits.getInstance().prospectorEvent.contains(p.getUniqueId())) {
- if (!p.getItemInHand().getType().equals(Material.TNT)) {
- return;
- }
- if (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)
- || e.getAction().equals(Action.PHYSICAL)) {
- return;
- }
- if (p.getItemInHand().getAmount() <= 1) {
- p.setItemInHand(null);
- } else {
- p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
- }
- TNTPrimed tnt = (TNTPrimed) p.getWorld().spawn(p.getLocation(), TNTPrimed.class);
- tnt.setFuseTicks(60);
- tnt.setVelocity(p.getLocation().getDirection().normalize().multiply(2));
- if (p.getItemInHand().getAmount() == 1) {
- new BukkitRunnable() {
- public void run() {
- if (!Kits.getInstance().prospectorEvent.contains(p.getUniqueId())) {
- this.cancel();
- return;
- }
- p.getInventory().addItem(new ItemStack(Material.TNT, 2));
- }
- }.runTaskLater(Core.plugin, 20 * 15);
- }
- }
- if (Kits.getInstance().pyromancerEvent.contains(p.getUniqueId())) {
- if (!p.getItemInHand().getType().equals(Material.INK_SAC)) {
- return;
- }
- if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
- || e.getAction().equals(Action.PHYSICAL)) {
- return;
- }
- if (CooldownManager.getManager().isInCooldown(p)) {
- e.setCancelled(true);
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- if (i > 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
- }
- if (i == 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
- }
- if (i == 0) {
- p.sendMessage(ChatColor.RED + "You cannot use till now");
- }
- return;
- }
- for (Player other : Bukkit.getOnlinePlayers()) {
- if (other.getWorld().equals(p.getWorld())) {
- if (other.getLocation().distance(p.getLocation()) <= 5) {
- if (!other.equals(p)) {
- other.setFireTicks(20 * 8);
- }
- }
- }
- }
- CooldownManager.getManager().create(p, 45);
- new BukkitRunnable() {
- public void run() {
- if (!CooldownManager.getManager().isInCooldown(p)) {
- p.setLevel(0);
- p.setExp(0);
- this.cancel();
- return;
- }
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- p.setLevel(i);
- p.setExp(i / (float) 45);
- }
- }.runTaskTimer(Core.plugin, 0, 20);
- }
- if (Kits.getInstance().executionerEvent.contains(p.getUniqueId())) {
- if (!p.getItemInHand().getType().equals(Material.DIAMOND_AXE)) {
- return;
- }
- final ItemStack i = p.getItemInHand();
- if (e.getAction().equals(Action.LEFT_CLICK_AIR) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)
- || e.getAction().equals(Action.PHYSICAL)) {
- return;
- }
- if (CooldownManager.getManager().isInCooldown(p)) {
- e.setCancelled(true);
- int cool = CooldownManager.getManager().getCooldown(p).timeLeft();
- if (cool > 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + cool + " more seconds!");
- }
- if (cool == 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + cool + " more second!");
- }
- if (cool == 0) {
- p.sendMessage(ChatColor.RED + "You cannot use till now");
- }
- return;
- }
- CooldownManager.getManager().create(p, 10);
- p.setItemInHand(null);
- Location ploc = p.getLocation().add(0, 0, 0);
- final ArmorStand as = (ArmorStand) ploc.getWorld().spawn(ploc, ArmorStand.class);
- as.setGravity(false);
- as.setCanPickupItems(false);
- as.setVisible(false);
- as.setArms(true);
- as.setItemInHand(i);
- EulerAngle rightArm = new EulerAngle(0F, 0F, degreesToRadians(270F));
- as.setRightArmPose(rightArm);
- final BukkitTask task1;
- final BukkitTask task2;
- task1 = new BukkitRunnable() {
- float start = 0;
- public void run() {
- EulerAngle pose = new EulerAngle(degreesToRadians(start), 0F, degreesToRadians(270F));
- as.setRightArmPose(pose);
- start = start + 10F;
- }
- }.runTaskTimer(Core.plugin, 0, 1);
- task2 = new BukkitRunnable() {
- float start = 0;
- Location loc = p.getLocation();
- public void run() {
- if (!Kits.getInstance().executionerEvent.contains(p.getUniqueId())) {
- task1.cancel();
- this.cancel();
- as.remove();
- }
- Vector dir = loc.getDirection();
- dir.normalize();
- dir.multiply(0.8);
- loc.add(dir);
- as.teleport(loc);
- if (!Kits.getInstance().executionerEvent.contains(p.getUniqueId())) {
- task1.cancel();
- this.cancel();
- as.remove();
- }
- if (!as.getLocation().add(0, 1, 0).getBlock().getType().equals(Material.AIR)) {
- task1.cancel();
- this.cancel();
- as.remove();
- p.getInventory().setItem(0, i);
- }
- for (Player players : Bukkit.getOnlinePlayers()) {
- if (players != p) {
- if (players.getWorld().equals(p.getWorld())) {
- if (as.getLocation().distance(players.getLocation()) <= 0.9) {
- task1.cancel();
- players.damage(16.0, p);
- this.cancel();
- as.remove();
- p.getInventory().setItem(0, i);
- }
- }
- }
- }
- }
- }.runTaskTimer(Core.plugin, 0, 1);
- new BukkitRunnable() {
- public void run() {
- if (p.getInventory().getItem(0) == null) {
- task1.cancel();
- task2.cancel();
- as.remove();
- p.getInventory().setItem(0, i);
- }
- }
- }.runTaskLater(Core.plugin, 20 * 10);
- new BukkitRunnable() {
- public void run() {
- if (!Kits.getInstance().executionerEvent.contains(p.getUniqueId())) {
- task1.cancel();
- task2.cancel();
- as.remove();
- }
- if (!CooldownManager.getManager().isInCooldown(p)) {
- p.setLevel(0);
- p.setExp(0);
- this.cancel();
- return;
- }
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- p.setLevel(i);
- p.setExp(i / (float) 10);
- }
- }.runTaskTimer(Core.plugin, 0, 20);
- }
- if (p.getItemInHand().getType().equals(Material.IRON_AXE) && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
- || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
- if (Kits.getInstance().thorEvent01.contains(p.getUniqueId())) {
- if (CooldownManager.getManager().isInCooldown(p)) {
- e.setCancelled(true);
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- if (i > 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
- }
- if (i == 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
- }
- if (i == 0) {
- p.sendMessage(ChatColor.RED + "You cannot use till now");
- }
- return;
- }
- Block b = p.getTargetBlock((HashSet<Material>) null, 100);
- Location loc = b.getLocation();
- for (ProtectedRegion r : WGBukkit.getRegionManager(p.getWorld())
- .getApplicableRegions(b.getLocation())) {
- if (r.getId().contains("spawn")) {
- p.sendMessage(prefix + ChatColor.RED + "Cannot use this aimed at spawn!");
- return;
- }
- }
- CooldownManager.getManager().create(p, 10);
- p.getWorld().strikeLightningEffect(loc);
- for (Player other : Bukkit.getOnlinePlayers()) {
- if (other.getWorld().equals(p.getWorld())) {
- if (other.getLocation().distance(loc) <= 6) {
- if (!other.equals(p)) {
- other.damage(6.0);
- }
- }
- }
- }
- new BukkitRunnable() {
- public void run() {
- if (!CooldownManager.getManager().isInCooldown(p)) {
- p.setLevel(0);
- p.setExp(0);
- this.cancel();
- return;
- }
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- p.setLevel(i);
- p.setExp(i / (float) 10);
- }
- }.runTaskTimer(Core.plugin, 0, 20);
- }
- } else if (p.getItemInHand().getType().equals(Material.GOLD_INGOT)
- && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
- || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
- if (Kits.getInstance().percyEvent02.contains(p.getUniqueId())) {
- if (CooldownManager.getManager().isInCooldown(p)) {
- e.setCancelled(true);
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- if (i > 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
- }
- if (i == 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
- }
- if (i == 0) {
- p.sendMessage(ChatColor.RED + "You cannot use till now");
- }
- return;
- }
- int newAmount = p.getItemInHand().getAmount() - 1;
- if (newAmount == 0) {
- p.setItemInHand(null);
- } else {
- p.getItemInHand().setAmount(newAmount);
- }
- p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 5, 0), true);
- p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20 * 5, 2), true);
- CooldownManager.getManager().create(p, 20);
- new BukkitRunnable() {
- public void run() {
- if (!CooldownManager.getManager().isInCooldown(p)) {
- p.setLevel(0);
- p.setExp(0);
- this.cancel();
- return;
- }
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- p.setLevel(i);
- p.setExp(i / (float) 20);
- }
- }.runTaskTimer(Core.plugin, 0, 20);
- }
- } else if (p.getItemInHand().getType().equals(Material.IRON_SWORD)
- && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
- || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
- if (Kits.getInstance().soldierEvent01.contains(p.getUniqueId())) {
- if (p.isOnGround()) {
- Vector v = new Vector(0, 0.8, 0);
- p.setVelocity(v);
- }
- }
- } else if (p.getItemInHand().getType().equals(Material.FEATHER)
- && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
- || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
- if (Kits.getInstance().gankEvent01.contains(p.getUniqueId())) {
- if (CooldownManager.getManager().isInCooldown(p)) {
- e.setCancelled(true);
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- if (i > 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more seconds!");
- }
- if (i == 1) {
- p.sendMessage(ChatColor.RED + "You cannot use this for " + i + " more second!");
- }
- if (i == 0) {
- p.sendMessage(ChatColor.RED + "You cannot use till now");
- }
- return;
- }
- int newAmount = p.getItemInHand().getAmount() - 1;
- if (newAmount == 0) {
- p.setItemInHand(null);
- } else {
- p.getItemInHand().setAmount(newAmount);
- }
- p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20 * 5, 3), true);
- CooldownManager.getManager().create(p, 20);
- new BukkitRunnable() {
- public void run() {
- if (!CooldownManager.getManager().isInCooldown(p)) {
- p.setLevel(0);
- p.setExp(0);
- this.cancel();
- return;
- }
- int i = CooldownManager.getManager().getCooldown(p).timeLeft();
- p.setLevel(i);
- p.setExp(i / (float) 20);
- }
- }.runTaskTimer(Core.plugin, 0, 20);
- }
- } else if (p.getItemInHand().getType().equals(Material.DIAMOND_SWORD)
- && ((e.getAction().equals(Action.RIGHT_CLICK_AIR))
- || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
- if (Kits.getInstance().knightEvent01.contains(p.getUniqueId())) {
- p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 0));
- new BukkitRunnable() {
- public void run() {
- if (!p.isBlocking()) {
- p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
- }
- }
- }.runTaskTimer(Core.plugin, 0, 5);
- }
- }
- }
- private static FileConfiguration msgs() {
- return Messages.getInstance().getConfig();
- }
- public List<Block> getBlocks(Location pos1, Location pos2) {
- if (pos1.getWorld() != pos2.getWorld())
- return null;
- World world = pos1.getWorld();
- List<Block> blocks = new ArrayList<>();
- int x1 = pos1.getBlockX();
- int y1 = pos1.getBlockY();
- int z1 = pos1.getBlockZ();
- int x2 = pos2.getBlockX();
- int y2 = pos2.getBlockY();
- int z2 = pos2.getBlockZ();
- int lowestX = Math.min(x1, x2);
- int lowestY = Math.min(y1, y2);
- int lowestZ = Math.min(z1, z2);
- int highestX = lowestX == x1 ? x2 : x1;
- int highestY = lowestX == y1 ? y2 : y1;
- int highestZ = lowestX == z1 ? z2 : z1;
- for (int x = lowestX; x <= highestX; x++)
- for (int y = lowestY; x <= highestY; y++)
- for (int z = lowestZ; x <= highestZ; z++)
- blocks.add(world.getBlockAt(x, y, z));
- return blocks;
- }
- public static float radiansToDegrees(float radians) {
- return (float) ((radians * 180) / Math.PI);
- }
- public static float degreesToRadians(float degrees) {
- return (float) ((degrees * Math.PI) / 180);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement