Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.AopAndDie.PhoenixCore;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.concurrent.ThreadLocalRandom;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.Sound;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.EntityDamageByEntityEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- import org.bukkit.scheduler.BukkitRunnable;
- import org.bukkit.scheduler.BukkitTask;
- import com.massivecraft.factions.FPlayer;
- import com.massivecraft.factions.FPlayers;
- import com.massivecraft.factions.struct.Relation;
- import me.AopAndDie.PhoenixCore.NaturesWrathTask;
- public class SoulEnchants implements Listener {
- public SoulEnchants(JavaPlugin plugin) {
- this.plugin = plugin;
- }
- private final JavaPlugin plugin;
- private Main main;
- static String Translate(String text) {
- return ChatColor.translateAlternateColorCodes('&', text);
- }
- @EventHandler
- public void damageInTerritory(EntityDamageByEntityEvent e) { //Damage in territory
- if (e.getEntity() instanceof Player) {
- Player victim = (Player) e.getEntity();
- FPlayer Fvictim = FPlayers.getInstance().getByPlayer(victim);
- if (e.getDamager() instanceof Player) {
- if (Fvictim.getRelationToLocation() != Relation.NEUTRAL) {
- if (Fvictim.isInOwnTerritory()) {
- victim.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7Enemy damage reduced by &c30%&7."));
- Double percent = e.getDamage() * 0.30;
- e.setDamage(e.getDamage() - percent);
- }
- }
- }
- }
- }
- @EventHandler
- public void naturesProc(EntityDamageByEntityEvent e) {
- if (e.getEntity() instanceof Player) {
- if (e.getDamager() instanceof Player) {
- final Player victim = (Player) e.getEntity();
- //Player attacker = (Player) e.getDamager();
- int chance = 1; //Percent
- int soulsPerUse = 75; //Souls
- if (victim.getInventory().getLeggings() != null) {
- ItemStack legs = victim.getInventory().getLeggings();
- if (legs.hasItemMeta()) {
- if (legs.getItemMeta().hasLore()) {
- if (legs.getItemMeta().getLore().contains(Translate("&cNatures Wrath IV"))) {
- if (!main.nwProc.contains(victim)) {
- if (main.canPvp(victim)) {
- if (ThreadLocalRandom.current().nextInt(101) <= chance) {
- main.nwProc.add(victim);
- for (ItemStack rune : victim.getInventory().getContents()) {
- if (rune != null) {
- if (rune.hasItemMeta()) {
- if (rune.getItemMeta().hasLore()) {
- if (rune.getItemMeta().hasDisplayName()) {
- if (rune.getType() == Material.EMERALD) {
- if (rune.getItemMeta().getLore().contains(Translate("&c&lUSES"))) {
- String[] section = ChatColor.stripColor(rune.getItemMeta().getDisplayName()).split("\\[");
- int gem = Integer.parseInt(section[1].substring(0, (section[1].length() - 1)));
- if (gem >= soulsPerUse) {
- int math = gem - soulsPerUse;
- main.setEnergy(rune, math);
- victim.sendMessage(" ");
- victim.sendMessage(Translate("&a&l** NATURE'S WRATH **"));
- victim.sendMessage(Translate("&c&l- ") + soulsPerUse + Translate(" &c&lEnergy"));
- victim.sendMessage(Translate("&7You have &7&n" + math + Translate("&r &7souls left.")));
- victim.sendMessage(" ");
- victim.updateInventory();
- victim.playSound(victim.getLocation(), Sound.ORB_PICKUP, 3f, 0.4f);
- victim.playSound(victim.getLocation(), Sound.EXPLODE, 3f, 0.1f);
- new BukkitRunnable() {
- public void run() {
- victim.playSound(victim.getLocation(), Sound.ORB_PICKUP, 3f, 0.6f);
- }
- }.runTaskLater(main, 5L);
- new BukkitRunnable() {
- public void run() {
- victim.playSound(victim.getLocation(), Sound.ORB_PICKUP, 3f, 0.7f);
- }
- }.runTaskLater(main, 6L);
- List<Entity> list = new ArrayList<Entity>();
- for (Entity p : victim.getNearbyEntities(20, 20, 20)) {
- if (p instanceof Player) {
- Player plr = (Player) p;
- if (main.canPvp(plr)) {
- FPlayer fp1 = FPlayers.getInstance().getByPlayer(victim);
- FPlayer fp2 = FPlayers.getInstance().getByPlayer(plr);
- if (!(fp2.getRelationTo(fp1) == Relation.MEMBER) || !(fp2.getRelationTo(fp1) == Relation.ALLY)) {
- plr.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 240, 100));
- plr.playSound(plr.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 2f);
- //plr.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 240, 100));
- plr.setNoDamageTicks(1);
- list.add(plr);
- }
- }
- }
- }
- BukkitTask nw = new NaturesWrathTask(victim, list, main).runTaskTimer(plugin, 20L, 20L);
- break;
- } else {
- victim.sendMessage(Translate("&c&l** OUT OF SOULS **"));
- victim.playSound(victim.getLocation(), Sound.ITEM_BREAK, 3f, 0.5f);
- break;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement