From 959064b983a8039831f0ff55e458c3154e632619 Mon Sep 17 00:00:00 2001 From: sigonasr2 <sigonasr2@gmail.com> Date: Wed, 11 Dec 2013 10:57:54 -0700 Subject: [PATCH] Modifications to Powered mobs. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 13 +- .../src/me/kaZep/Base/PlayerListener.java | 261 ++++++++++-------- .../me/kaZep/Commands/commandBankEconomy.java | 10 + 3 files changed, 164 insertions(+), 120 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index 9f3a847..ae4216a 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -2076,9 +2076,18 @@ public void runTick() { } if (nearby.get(i).getType()==EntityType.SKELETON || nearby.get(i).getType()==EntityType.ZOMBIE || - nearby.get(i).getType()==EntityType.SPIDER) { + nearby.get(i).getType()==EntityType.SPIDER|| + nearby.get(i).getType()==EntityType.CREEPER|| + nearby.get(i).getType()==EntityType.ENDERMAN) { LivingEntity l = (LivingEntity)nearby.get(i); - if (l.getKiller()!=null && Math.random()<=0.5/l.getNearbyEntities(10, 10, 10).size()) { + List<Entity> ents = l.getNearbyEntities(10, 10, 10); + for (int m=0;m<ents.size();m++) { + if (!(ents.get(m) instanceof Monster)) { + ents.remove(m); + m--; + } + } + if (l.getKiller()!=null && Math.random()<=1.15/ents.size()) { if (!contains_mob) { powered_mob_list.add(new PoweredMob(l.getUniqueId(), Main.SERVER_TICK_TIME)); l.getWorld().playSound(l.getLocation(), Sound.SPIDER_DEATH, 0.4f, 0.04f); diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index fea66a1..10738bc 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -9398,6 +9398,32 @@ implements Listener if (e.getEntity() instanceof LivingEntity) { final LivingEntity l = (LivingEntity)e.getEntity(); + if (e.getDamager() instanceof Projectile) { + if (((Projectile)e.getDamager()).getShooter() instanceof LivingEntity) { + LivingEntity l2 = ((Projectile)e.getDamager()).getShooter(); + for (int i=0;i<this.plugin.powered_mob_list.size();i++) { + if (this.plugin.powered_mob_list.get(i).id.equals(l2.getUniqueId())) { + //This mob will damage you if you are not blocking. + if (l instanceof Player) { + Player p = (Player)l; + if (!p.isBlocking()) { + if (p.getHealth()-e.getDamage()*4<0) { + p.setHealth(0); + } else { + p.setHealth(p.getHealth()-e.getDamage()*4); + } + Main.playFirework(p.getLocation()); + Main.playFirework(p.getLocation()); + Main.playFirework(p.getLocation()); + } + } + this.plugin.powered_mob_list.remove(i); + i--; + break; + } + } + } + } if (e.getDamager() instanceof LivingEntity) { LivingEntity l2 = (LivingEntity)e.getDamager(); for (int i=0;i<this.plugin.powered_mob_list.size();i++) { @@ -9406,10 +9432,10 @@ implements Listener if (l instanceof Player) { Player p = (Player)l; if (!p.isBlocking()) { - if (p.getHealth()-e.getDamage()<0) { + if (p.getHealth()-e.getDamage()*2<0) { p.setHealth(0); } else { - p.setHealth(p.getHealth()-e.getDamage()); + p.setHealth(p.getHealth()-e.getDamage()*2); } Main.playFirework(p.getLocation()); Main.playFirework(p.getLocation()); @@ -10892,139 +10918,138 @@ implements Listener if (p.getEquipment().getLeggings()!=null) {legs_dura=p.getEquipment().getLeggings().getDurability();} if (p.getEquipment().getBoots()!=null) {boots_dura=p.getEquipment().getBoots().getDurability();} final int prev_helm_dura=helm_dura,prev_chest_dura=chest_dura,prev_legs_dura=legs_dura,prev_boots_dura=boots_dura; - if (p.getNoDamageTicks()<p.getMaximumNoDamageTicks()/2.0f) { - p.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { - @Override - public void run() { - //This player lost durability, we will attempt to give it back based on certain conditions. - //CASE 1: The player actually loses more durability if it's weak armor. - //CASE 2: The player gains back -1 durability if they have +X% Durability. The chance of it occuring is Math.random()*X<=100 - //CASE 3: The amount lost by the blocking stat has the possibility to be gained back. - int helm_dura=-1,chest_dura=-1,legs_dura=-1,boots_dura=-1; - boolean weak_helm=false,weak_chest=false,weak_legs=false,weak_boots=false; - if (p.getEquipment().getHelmet()!=null) {helm_dura=p.getEquipment().getHelmet().getDurability();} - if (p.getEquipment().getChestplate()!=null ) {chest_dura=p.getEquipment().getChestplate().getDurability();} - if (p.getEquipment().getLeggings()!=null) {legs_dura=p.getEquipment().getLeggings().getDurability();} - if (p.getEquipment().getBoots()!=null) {boots_dura=p.getEquipment().getBoots().getDurability();} - Bukkit.getLogger().info("Durability of items are: "+helm_dura+","+chest_dura+","+legs_dura+","+boots_dura); - int gained_back=0; - if (p.getEquipment().getHelmet()!=null && helm_dura!=-1 && p.getEquipment().getHelmet().hasItemMeta() && - p.getEquipment().getHelmet().getItemMeta().hasLore()) { - List<String> lore = p.getEquipment().getHelmet().getItemMeta().getLore(); - for (int i=0;i<lore.size();i++) { - if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) { - helm_dura+=3; - weak_helm=true; - } - if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) { - helm_dura+=3; - } + //if (p.getNoDamageTicks()<p.getMaximumNoDamageTicks()/2.0f) { + p.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() { + @Override + public void run() { + //This player lost durability, we will attempt to give it back based on certain conditions. + //CASE 1: The player actually loses more durability if it's weak armor. + //CASE 2: The player gains back -1 durability if they have +X% Durability. The chance of it occuring is Math.random()*X<=100 + //CASE 3: The amount lost by the blocking stat has the possibility to be gained back. + int helm_dura=-1,chest_dura=-1,legs_dura=-1,boots_dura=-1; + boolean weak_helm=false,weak_chest=false,weak_legs=false,weak_boots=false; + if (p.getEquipment().getHelmet()!=null) {helm_dura=p.getEquipment().getHelmet().getDurability();} + if (p.getEquipment().getChestplate()!=null ) {chest_dura=p.getEquipment().getChestplate().getDurability();} + if (p.getEquipment().getLeggings()!=null) {legs_dura=p.getEquipment().getLeggings().getDurability();} + if (p.getEquipment().getBoots()!=null) {boots_dura=p.getEquipment().getBoots().getDurability();} + Bukkit.getLogger().info("Durability of items are: "+helm_dura+","+chest_dura+","+legs_dura+","+boots_dura); + int gained_back=0; + if (p.getEquipment().getHelmet()!=null && helm_dura!=-1 && p.getEquipment().getHelmet().hasItemMeta() && + p.getEquipment().getHelmet().getItemMeta().hasLore()) { + List<String> lore = p.getEquipment().getHelmet().getItemMeta().getLore(); + for (int i=0;i<lore.size();i++) { + if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) { + helm_dura+=3; + weak_helm=true; + } + if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) { + helm_dura+=3; } } - if (p.getEquipment().getChestplate()!=null && chest_dura!=-1 && p.getEquipment().getChestplate().hasItemMeta() && - p.getEquipment().getChestplate().getItemMeta().hasLore()) { - List<String> lore = p.getEquipment().getChestplate().getItemMeta().getLore(); - for (int i=0;i<lore.size();i++) { - if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) { - chest_dura+=3; - weak_chest=true; - } - if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) { - chest_dura+=3; - } + } + if (p.getEquipment().getChestplate()!=null && chest_dura!=-1 && p.getEquipment().getChestplate().hasItemMeta() && + p.getEquipment().getChestplate().getItemMeta().hasLore()) { + List<String> lore = p.getEquipment().getChestplate().getItemMeta().getLore(); + for (int i=0;i<lore.size();i++) { + if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) { + chest_dura+=3; + weak_chest=true; + } + if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) { + chest_dura+=3; } } - if (p.getEquipment().getLeggings()!=null && legs_dura!=-1 && p.getEquipment().getLeggings().hasItemMeta() && - p.getEquipment().getLeggings().getItemMeta().hasLore()) { - List<String> lore = p.getEquipment().getLeggings().getItemMeta().getLore(); - for (int i=0;i<lore.size();i++) { - if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) { - legs_dura+=3; - weak_legs=true; - } - if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) { - Bukkit.getLogger().info("Leggings Block Chance."); - legs_dura+=3; - } + } + if (p.getEquipment().getLeggings()!=null && legs_dura!=-1 && p.getEquipment().getLeggings().hasItemMeta() && + p.getEquipment().getLeggings().getItemMeta().hasLore()) { + List<String> lore = p.getEquipment().getLeggings().getItemMeta().getLore(); + for (int i=0;i<lore.size();i++) { + if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) { + legs_dura+=3; + weak_legs=true; + } + if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) { + Bukkit.getLogger().info("Leggings Block Chance."); + legs_dura+=3; } } - if (p.getEquipment().getBoots()!=null && boots_dura!=-1 && p.getEquipment().getBoots().hasItemMeta() && - p.getEquipment().getBoots().getItemMeta().hasLore()) { - List<String> lore = p.getEquipment().getBoots().getItemMeta().getLore(); - for (int i=0;i<lore.size();i++) { - if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) { - boots_dura+=3; - weak_boots=true; - } - if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) { - boots_dura+=3; - } + } + if (p.getEquipment().getBoots()!=null && boots_dura!=-1 && p.getEquipment().getBoots().hasItemMeta() && + p.getEquipment().getBoots().getItemMeta().hasLore()) { + List<String> lore = p.getEquipment().getBoots().getItemMeta().getLore(); + for (int i=0;i<lore.size();i++) { + if (lore.get(i).contains(ChatColor.RED+"-400% Durability")) { + boots_dura+=3; + weak_boots=true; + } + if (!blocked_hunter && blocked && plug.containsEnchantment(lore.get(i), "Block Chance")) { + boots_dura+=3; } } - if (p.getEquipment().getHelmet()!=null && helm_dura!=-1 && p.getEquipment().getHelmet().hasItemMeta() && - p.getEquipment().getHelmet().getItemMeta().hasLore()) { - List<String> lore = p.getEquipment().getHelmet().getItemMeta().getLore(); - for (int i=0;i<lore.size();i++) { - double dura_numb=0; - if (plug.containsEnchantment(lore.get(i), "Durability")) { - dura_numb+=plug.getEnchantmentNumb(lore.get(i)); - } - if (!weak_helm) {dura_numb+=300; /*Bukkit.getLogger().info("1 not weak.");*/} - if (Math.random()*dura_numb>100) { - helm_dura-=1; - } + } + if (p.getEquipment().getHelmet()!=null && helm_dura!=-1 && p.getEquipment().getHelmet().hasItemMeta() && + p.getEquipment().getHelmet().getItemMeta().hasLore()) { + List<String> lore = p.getEquipment().getHelmet().getItemMeta().getLore(); + double dura_numb=0; + for (int i=0;i<lore.size();i++) { + if (plug.containsEnchantment(lore.get(i), "Durability")) { + dura_numb+=plug.getEnchantmentNumb(lore.get(i)); } } - if (p.getEquipment().getChestplate()!=null && chest_dura!=-1 && p.getEquipment().getChestplate().hasItemMeta() && - p.getEquipment().getChestplate().getItemMeta().hasLore()) { - List<String> lore = p.getEquipment().getChestplate().getItemMeta().getLore(); - for (int i=0;i<lore.size();i++) { - double dura_numb=0; - if (plug.containsEnchantment(lore.get(i), "Durability")) { - dura_numb+=plug.getEnchantmentNumb(lore.get(i)); - } - if (!weak_chest) {dura_numb+=300; /*Bukkit.getLogger().info("2 not weak.");*/} - if (Math.random()*dura_numb>100) { - chest_dura-=1; - } + if (!weak_helm) {dura_numb+=300; /*Bukkit.getLogger().info("1 not weak.");*/} + if (Math.random()*dura_numb>100) { + helm_dura-=1; + } + } + if (p.getEquipment().getChestplate()!=null && chest_dura!=-1 && p.getEquipment().getChestplate().hasItemMeta() && + p.getEquipment().getChestplate().getItemMeta().hasLore()) { + List<String> lore = p.getEquipment().getChestplate().getItemMeta().getLore(); + double dura_numb=0; + for (int i=0;i<lore.size();i++) { + if (plug.containsEnchantment(lore.get(i), "Durability")) { + dura_numb+=plug.getEnchantmentNumb(lore.get(i)); } } - if (p.getEquipment().getLeggings()!=null && legs_dura!=-1 && p.getEquipment().getLeggings().hasItemMeta() && - p.getEquipment().getLeggings().getItemMeta().hasLore()) { - List<String> lore = p.getEquipment().getLeggings().getItemMeta().getLore(); - for (int i=0;i<lore.size();i++) { - double dura_numb=0; - if (plug.containsEnchantment(lore.get(i), "Durability")) { - dura_numb+=plug.getEnchantmentNumb(lore.get(i)); - } - if (!weak_legs) {dura_numb+=300; /*Bukkit.getLogger().info("3 not weak.");*/} - if (Math.random()*dura_numb>100) { - legs_dura-=1; - } + if (!weak_chest) {dura_numb+=300; /*Bukkit.getLogger().info("2 not weak.");*/} + if (Math.random()*dura_numb>100) { + chest_dura-=1; + } + } + if (p.getEquipment().getLeggings()!=null && legs_dura!=-1 && p.getEquipment().getLeggings().hasItemMeta() && + p.getEquipment().getLeggings().getItemMeta().hasLore()) { + List<String> lore = p.getEquipment().getLeggings().getItemMeta().getLore(); + double dura_numb=0; + for (int i=0;i<lore.size();i++) { + if (plug.containsEnchantment(lore.get(i), "Durability")) { + dura_numb+=plug.getEnchantmentNumb(lore.get(i)); } } - if (p.getEquipment().getBoots()!=null && boots_dura!=-1 && p.getEquipment().getBoots().hasItemMeta() && - p.getEquipment().getBoots().getItemMeta().hasLore()) { - List<String> lore = p.getEquipment().getBoots().getItemMeta().getLore(); - for (int i=0;i<lore.size();i++) { - double dura_numb=0; - if (plug.containsEnchantment(lore.get(i), "Durability")) { - dura_numb+=plug.getEnchantmentNumb(lore.get(i)); - } - if (!weak_boots) {dura_numb+=300; /*Bukkit.getLogger().info("4 not weak.");*/} - if (Math.random()*dura_numb>100) { - boots_dura-=1; - } + if (!weak_legs) {dura_numb+=300; /*Bukkit.getLogger().info("3 not weak.");*/} + if (Math.random()*dura_numb>100) { + legs_dura-=1; + } + } + if (p.getEquipment().getBoots()!=null && boots_dura!=-1 && p.getEquipment().getBoots().hasItemMeta() && + p.getEquipment().getBoots().getItemMeta().hasLore()) { + List<String> lore = p.getEquipment().getBoots().getItemMeta().getLore(); + double dura_numb=0; + for (int i=0;i<lore.size();i++) { + if (plug.containsEnchantment(lore.get(i), "Durability")) { + dura_numb+=plug.getEnchantmentNumb(lore.get(i)); } } - if (p.getEquipment().getBoots()!=null && boots_dura!=-1) {ItemStack i = p.getEquipment().getBoots(); i.setDurability((short)boots_dura); p.getEquipment().setBoots(i);} - if (p.getEquipment().getLeggings()!=null && legs_dura!=-1) {ItemStack i = p.getEquipment().getLeggings(); i.setDurability((short)legs_dura); p.getEquipment().setLeggings(i);} - if (p.getEquipment().getChestplate()!=null && chest_dura!=-1) {ItemStack i = p.getEquipment().getChestplate(); i.setDurability((short)chest_dura); p.getEquipment().setChestplate(i);} - if (p.getEquipment().getHelmet()!=null && helm_dura!=-1) {ItemStack i = p.getEquipment().getHelmet(); i.setDurability((short)helm_dura); p.getEquipment().setHelmet(i);} - Bukkit.getLogger().info("Durability of items now are: "+helm_dura+","+chest_dura+","+legs_dura+","+boots_dura); + if (!weak_boots) {dura_numb+=300; /*Bukkit.getLogger().info("4 not weak.");*/} + if (Math.random()*dura_numb>100) { + boots_dura-=1; + } } - },1); - } + if (p.getEquipment().getBoots()!=null && boots_dura!=-1) {ItemStack i = p.getEquipment().getBoots(); i.setDurability((short)boots_dura); p.getEquipment().setBoots(i);} + if (p.getEquipment().getLeggings()!=null && legs_dura!=-1) {ItemStack i = p.getEquipment().getLeggings(); i.setDurability((short)legs_dura); p.getEquipment().setLeggings(i);} + if (p.getEquipment().getChestplate()!=null && chest_dura!=-1) {ItemStack i = p.getEquipment().getChestplate(); i.setDurability((short)chest_dura); p.getEquipment().setChestplate(i);} + if (p.getEquipment().getHelmet()!=null && helm_dura!=-1) {ItemStack i = p.getEquipment().getHelmet(); i.setDurability((short)helm_dura); p.getEquipment().setHelmet(i);} + Bukkit.getLogger().info("Durability of items now are: "+helm_dura+","+chest_dura+","+legs_dura+","+boots_dura); + } + },1); } } diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index c2ada10..f72c743 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -834,6 +834,16 @@ public String convertToItemName(String val) { // Arrows i.setItem(count+=1, new ItemStack(Material.ARROW, 64)); + temp = new ItemStack(Material.getMaterial(34),64); + ItemMeta meta = temp.getItemMeta(); + meta.setDisplayName(ChatColor.LIGHT_PURPLE+"Job Boost Card"); + List<String> lore = new ArrayList<String>(); + lore.add("Use /jobs boost <jobname> to instantly level up"); + lore.add("that job with this card!"); + meta.setLore(lore); + temp.setItemMeta(meta); + i.setItem(count+=1, temp); + p.openInventory(i);