Advertisement
Guest User

Help

a guest
Feb 4th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 KB | None | 0 0
  1. package me.AopAndDie.PhoenixCore;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.concurrent.ThreadLocalRandom;
  6.  
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.Material;
  9. import org.bukkit.Sound;
  10. import org.bukkit.entity.Entity;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  15. import org.bukkit.inventory.ItemStack;
  16. import org.bukkit.plugin.java.JavaPlugin;
  17. import org.bukkit.potion.PotionEffect;
  18. import org.bukkit.potion.PotionEffectType;
  19. import org.bukkit.scheduler.BukkitRunnable;
  20. import org.bukkit.scheduler.BukkitTask;
  21.  
  22. import com.massivecraft.factions.FPlayer;
  23. import com.massivecraft.factions.FPlayers;
  24. import com.massivecraft.factions.struct.Relation;
  25. import me.AopAndDie.PhoenixCore.NaturesWrathTask;
  26.  
  27. public class SoulEnchants implements Listener {
  28.  
  29.  
  30.  
  31. public SoulEnchants(JavaPlugin plugin) {
  32. this.plugin = plugin;
  33. }
  34.  
  35. private final JavaPlugin plugin;
  36. private Main main;
  37.  
  38. static String Translate(String text) {
  39. return ChatColor.translateAlternateColorCodes('&', text);
  40.  
  41. }
  42. @EventHandler
  43. public void damageInTerritory(EntityDamageByEntityEvent e) { //Damage in territory
  44. if (e.getEntity() instanceof Player) {
  45. Player victim = (Player) e.getEntity();
  46. FPlayer Fvictim = FPlayers.getInstance().getByPlayer(victim);
  47. if (e.getDamager() instanceof Player) {
  48. if (Fvictim.getRelationToLocation() != Relation.NEUTRAL) {
  49. if (Fvictim.isInOwnTerritory()) {
  50. victim.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7Enemy damage reduced by &c30%&7."));
  51. Double percent = e.getDamage() * 0.30;
  52. e.setDamage(e.getDamage() - percent);
  53. }
  54. }
  55. }
  56. }
  57. }
  58.  
  59. @EventHandler
  60. public void naturesProc(EntityDamageByEntityEvent e) {
  61. if (e.getEntity() instanceof Player) {
  62. if (e.getDamager() instanceof Player) {
  63. final Player victim = (Player) e.getEntity();
  64. //Player attacker = (Player) e.getDamager();
  65. int chance = 1; //Percent
  66. int soulsPerUse = 75; //Souls
  67. if (victim.getInventory().getLeggings() != null) {
  68. ItemStack legs = victim.getInventory().getLeggings();
  69. if (legs.hasItemMeta()) {
  70. if (legs.getItemMeta().hasLore()) {
  71. if (legs.getItemMeta().getLore().contains(Translate("&cNatures Wrath IV"))) {
  72. if (!main.nwProc.contains(victim)) {
  73. if (main.canPvp(victim)) {
  74. if (ThreadLocalRandom.current().nextInt(101) <= chance) {
  75. main.nwProc.add(victim);
  76. for (ItemStack rune : victim.getInventory().getContents()) {
  77. if (rune != null) {
  78. if (rune.hasItemMeta()) {
  79. if (rune.getItemMeta().hasLore()) {
  80. if (rune.getItemMeta().hasDisplayName()) {
  81. if (rune.getType() == Material.EMERALD) {
  82. if (rune.getItemMeta().getLore().contains(Translate("&c&lUSES"))) {
  83. String[] section = ChatColor.stripColor(rune.getItemMeta().getDisplayName()).split("\\[");
  84. int gem = Integer.parseInt(section[1].substring(0, (section[1].length() - 1)));
  85. if (gem >= soulsPerUse) {
  86. int math = gem - soulsPerUse;
  87. main.setEnergy(rune, math);
  88.  
  89. victim.sendMessage(" ");
  90. victim.sendMessage(Translate("&a&l** NATURE'S WRATH **"));
  91. victim.sendMessage(Translate("&c&l- ") + soulsPerUse + Translate(" &c&lEnergy"));
  92. victim.sendMessage(Translate("&7You have &7&n" + math + Translate("&r &7souls left.")));
  93. victim.sendMessage(" ");
  94. victim.updateInventory();
  95. victim.playSound(victim.getLocation(), Sound.ORB_PICKUP, 3f, 0.4f);
  96. victim.playSound(victim.getLocation(), Sound.EXPLODE, 3f, 0.1f);
  97. new BukkitRunnable() {
  98. public void run() {
  99. victim.playSound(victim.getLocation(), Sound.ORB_PICKUP, 3f, 0.6f);
  100. }
  101. }.runTaskLater(main, 5L);
  102.  
  103. new BukkitRunnable() {
  104. public void run() {
  105. victim.playSound(victim.getLocation(), Sound.ORB_PICKUP, 3f, 0.7f);
  106. }
  107. }.runTaskLater(main, 6L);
  108.  
  109. List<Entity> list = new ArrayList<Entity>();
  110.  
  111. for (Entity p : victim.getNearbyEntities(20, 20, 20)) {
  112. if (p instanceof Player) {
  113. Player plr = (Player) p;
  114. if (main.canPvp(plr)) {
  115. FPlayer fp1 = FPlayers.getInstance().getByPlayer(victim);
  116. FPlayer fp2 = FPlayers.getInstance().getByPlayer(plr);
  117. if (!(fp2.getRelationTo(fp1) == Relation.MEMBER) || !(fp2.getRelationTo(fp1) == Relation.ALLY)) {
  118. plr.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 240, 100));
  119. plr.playSound(plr.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 2f);
  120. //plr.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 240, 100));
  121. plr.setNoDamageTicks(1);
  122. list.add(plr);
  123. }
  124. }
  125. }
  126. }
  127.  
  128.  
  129.  
  130. BukkitTask nw = new NaturesWrathTask(victim, list, main).runTaskTimer(plugin, 20L, 20L);
  131.  
  132.  
  133. break;
  134. } else {
  135. victim.sendMessage(Translate("&c&l** OUT OF SOULS **"));
  136. victim.playSound(victim.getLocation(), Sound.ITEM_BREAK, 3f, 0.5f);
  137. break;
  138. }
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }
  152. }
  153. }
  154. }
  155. }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement