diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index 5e849f8..9007674 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -203,6 +203,7 @@ public class Main extends JavaPlugin public List revive_inventory_list = null; public List powered_mob_list = null; public List chunk_queue_list = null; + public List mob_list = null; public static List recycling_center_list = null; public static List bonus_enchantment_list = null; public DamageAPI DMGCALC = null; @@ -355,6 +356,7 @@ public class Main extends JavaPlugin chunk_queue_list = new ArrayList(); bonus_enchantment_list = new ArrayList(); powered_mob_list = new ArrayList(); + mob_list = new ArrayList(); recycling_center_list = new ArrayList(); @@ -1863,6 +1865,14 @@ public void runTick() { } } if (Main.SERVER_TICK_TIME%20==0) { + List playerheads = getMobHeads(p); + int creeperrareheads = getMobHeadAmt(new MobHead(MobHeadType.CREEPER,true,MobHeadRareType.RARE_TYPE_B), playerheads); + int creeperpoweredheads = getMobHeadAmt(new MobHead(MobHeadType.CREEPER,false,true), playerheads); + int creeperpoweredrareheads = getMobHeadAmt(new MobHead(MobHeadType.CREEPER,true,true), playerheads); + int aoedmg = 0; + aoedmg+=creeperrareheads; + aoedmg+=creeperpoweredheads; + aoedmg+=creeperpoweredrareheads*3; for (int j=0;j0) { + if (nearby.get(i).getLocation().distance(p.getLocation())<=9) { + //p.sendMessage("AOE Damage is "+aoedmg); + LivingEntity l = (LivingEntity)nearby.get(i); + l.damage(aoedmg); + } + } if (contains) { LivingEntity l = (LivingEntity)nearby.get(i); + /* + if (l.hasPotionEffect(PotionEffectType.POISON)) { + Collection pots = l.getActivePotionEffects(); + int poison_power=0; + for (PotionEffect effect : pots) { + if (effect.getType().getName().equalsIgnoreCase("poison")) { + poison_power = effect.getAmplifier(); + break; + } + } + l.damage(poison_power+1); + }*/ + for (int j=0;j0) { + l.damage(1); + } else { + mob_list.remove(j); + j--; + } + } + } if (l.getCustomName()!=null && l.hasLineOfSight(p)) { if (!lineofsight_check.contains(l.getUniqueId())) { l.setCustomNameVisible(true); @@ -2320,6 +2360,10 @@ public void runTick() { } } } + if (Main.SERVER_TICK_TIME%36000==0) { + //Every 30 minutes, clear out the list of poisoned mobs, in case some are non-existent now. + mob_list.clear(); + } if (Main.SERVER_TICK_TIME%600==0) { saveAccountsConfig(); //Save account data once every 30 seconds. if (turnedon==false && Bukkit.getWorld("world").getTime()>13000) { @@ -6271,6 +6315,7 @@ public void payDay(int time) public static void playFirework(Location loc) { Random gen = new Random(); + try { Firework fw = loc.getWorld().spawn(loc, Firework.class); @@ -6509,7 +6554,7 @@ public void payDay(int time) //Check the lore for a valid mob head. if (getMobHead(item)!=null) { mobheadlist.add(getMobHead(item)); - Bukkit.getLogger().info("Mob head "+getMobHead(item).toString()+" added."); + //Bukkit.getLogger().info("Mob head "+getMobHead(item).toString()+" added."); } } } diff --git a/BankEconomyMod/src/me/kaZep/Base/MobManager.java b/BankEconomyMod/src/me/kaZep/Base/MobManager.java new file mode 100644 index 0000000..a2bea88 --- /dev/null +++ b/BankEconomyMod/src/me/kaZep/Base/MobManager.java @@ -0,0 +1,61 @@ +package me.kaZep.Base; + +import java.util.UUID; + +/** + * The MobManager class handles a certain mob in the game. + * It will allow you to define new properties for mobs + * to keep track of. This is similar to the PlayerData + * class for players. + */ +public class MobManager { + UUID id; + long poison_time; + /** + * Adds a new mob to be tracked. + * @param id The UUID of the mob. + */ + public MobManager(UUID id) { + this.id=id; + this.poison_time=Main.SERVER_TICK_TIME; + } + /** + * If there are already poison ticks on this mob, + * adds to the duration in ticks for the poison + * to last. Otherwise works just like setPoison(). + * @param ticks + */ + public void addPoison(long ticks) { + if (poison_time>=Main.SERVER_TICK_TIME) { + poison_time+=ticks; + } else { + setPoison(ticks); + } + } + /** + * Sets the poison ticks directly, overwriting + * any previous poison tick data. + * @param ticks + */ + public void setPoison(long ticks) { + poison_time=Main.SERVER_TICK_TIME+ticks; + } + /** + * Removes the poison ticks from this mob. + */ + public void removePoison() { + poison_time=Main.SERVER_TICK_TIME; + } + /** + * Returns the number of ticks of poison + * left on this mob. + * @return + */ + public long getPoisonTicks() { + if (poison_time>=Main.SERVER_TICK_TIME) { + return poison_time-Main.SERVER_TICK_TIME; + } else { + return 0; //0 ticks, since the stored time is smaller. + } + } +} diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index 5f2a3d1..71ec824 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -10155,7 +10155,7 @@ implements Listener l2.setHealth(l2.getHealth()-dmg); if (l2 instanceof Player) { Player p = (Player)l2; - p.playSound(p.getLocation(), Sound.HURT, 0.5f, 1.0f); + p.playSound(p.getLocation(), Sound.HURT_FLESH, 0.5f, 1.0f); DecimalFormat df = new DecimalFormat("#0.0"); DecimalFormat df2 = new DecimalFormat("#0"); if (this.plugin.getAccountsConfig().getBoolean(p.getName().toLowerCase()+".settings.notify5")) { @@ -10955,10 +10955,74 @@ implements Listener final Player p = (Player) e.getDamager(); if (e.getEntity() instanceof Monster) { Monster m = (Monster)e.getEntity(); + + List playerheads = this.plugin.getMobHeads(p); + int creeperheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.CREEPER), playerheads); + int creeperrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.CREEPER,true), playerheads); + int creeperpoweredheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.CREEPER,false,true), playerheads); + int creeperpoweredrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.CREEPER,true,true), playerheads); + int aoedmg = 0; + + aoedmg+=creeperheads*5; + aoedmg+=creeperrareheads*20; + aoedmg+=creeperpoweredheads*5; + aoedmg+=creeperpoweredrareheads*30; + + + int spiderheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SPIDER), playerheads); + int spiderrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SPIDER,true), playerheads); + int spiderpoweredheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SPIDER,false,true), playerheads); + int spiderpoweredrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SPIDER,true,true), playerheads); + int slowdownpct = 0; + + slowdownpct+=spiderheads*5; + slowdownpct+=spiderrareheads*15; + slowdownpct+=spiderpoweredheads*5; + slowdownpct+=spiderpoweredrareheads*30; + + spiderrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SPIDER,true,MobHeadRareType.RARE_TYPE_B), playerheads); + int poisondur = 0; //Amount of poison duration (seconds) to add to the current poison amount. + + poisondur+=spiderrareheads*2; + poisondur+=spiderpoweredheads*1; + poisondur+=spiderpoweredrareheads*5; + + m.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,60,slowdownpct/15,true)); + + int poisonduration=0; + //First see if the mob is already a poisoned mob. + boolean found=false; + for (int i=0;i nearby_mobs = m.getNearbyEntities(2, 2, 2); + for (int i=0;i playerheads = this.plugin.getMobHeads(p); int witherskeletonheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.WITHER_SKELETON), playerheads); int witherskeletonrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.WITHER_SKELETON,true), playerheads); int witherskeletonpoweredheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.WITHER_SKELETON,false,true), playerheads); @@ -11061,13 +11125,13 @@ implements Listener //int zombierarebheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.ZOMBIE,true,MobHeadRareType.RARE_TYPE_B), playerheads); int zombiepoweredheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.ZOMBIE,false,true), playerheads); int zombiepoweredrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.ZOMBIE,true,true), playerheads); - Bukkit.getLogger().info("Head counts are "+zombieheads+", "+zombierareaheads+", "+zombiepoweredheads+", "+zombiepoweredrareheads); - Bukkit.getLogger().info("Life Steal is "+life_steal+"%"); + //Bukkit.getLogger().info("Head counts are "+zombieheads+", "+zombierareaheads+", "+zombiepoweredheads+", "+zombiepoweredrareheads); + //Bukkit.getLogger().info("Life Steal is "+life_steal+"%"); life_steal+=zombieheads; life_steal+=zombiepoweredheads; life_steal+=zombierareaheads*3; life_steal+=zombiepoweredrareheads*5; - Bukkit.getLogger().info("Life Steal is "+life_steal+"%"); + //Bukkit.getLogger().info("Life Steal is "+life_steal+"%"); if (this.plugin.getPlayerData(p).furytime!=0) { attack_speed+=this.plugin.getPlayerData(p).furyamt; } @@ -11199,11 +11263,124 @@ implements Listener p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(healthbar(p.getHealth(),p.getMaxHealth(),p.getFoodLevel())); ItemStack item = p.getItemInHand(); double critical_chance=0,armor_pen=0,life_steal=0,attack_speed=0,dmg=0,armor_pen_dmg=0; - List player_mobheads = this.plugin.getMobHeads(p); - int skeleton_heads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SKELETON), player_mobheads); - int powered_skeleton_heads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SKELETON, false, true), player_mobheads); - int rare_skeleton_heads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SKELETON, true, MobHeadRareType.RARE_TYPE_A), player_mobheads); - int powered_rare_skeleton_heads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SKELETON, true, MobHeadRareType.RARE_TYPE_A, true), player_mobheads); + + List playerheads = this.plugin.getMobHeads(p); + if (e.getEntity() instanceof Monster) { + Monster m = (Monster)e.getEntity(); + int creeperheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.CREEPER), playerheads); + int creeperrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.CREEPER,true), playerheads); + int creeperpoweredheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.CREEPER,false,true), playerheads); + int creeperpoweredrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.CREEPER,true,true), playerheads); + int aoedmg = 0; + + aoedmg+=creeperheads*5; + aoedmg+=creeperrareheads*20; + aoedmg+=creeperpoweredheads*5; + aoedmg+=creeperpoweredrareheads*30; + + + int spiderheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SPIDER), playerheads); + int spiderrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SPIDER,true), playerheads); + int spiderpoweredheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SPIDER,false,true), playerheads); + int spiderpoweredrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SPIDER,true,true), playerheads); + int slowdownpct = 0; + + slowdownpct+=spiderheads*5; + slowdownpct+=spiderrareheads*15; + slowdownpct+=spiderpoweredheads*5; + slowdownpct+=spiderpoweredrareheads*30; + + spiderrareheads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SPIDER,true,MobHeadRareType.RARE_TYPE_B), playerheads); + int poisondur = 0; //Amount of poison duration (seconds) to add to the current poison amount. + + poisondur+=spiderrareheads*2; + poisondur+=spiderpoweredheads*1; + poisondur+=spiderpoweredrareheads*5; + + m.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,60,slowdownpct/15,true)); + + + int poisonduration=0; + //First see if the mob is already a poisoned mob. + boolean found=false; + for (int i=0;i nearby_mobs = m.getNearbyEntities(2, 2, 2); + for (int i=0;i effects = m.getActivePotionEffects().iterator(); + //Figure out potion effects when player joins. + while (effects.hasNext()) { + PotionEffect nexteffect = effects.next(); + //Bukkit.getLogger().info("Effect Type is "+nexteffect.getType().getName()+", amplifier is "+nexteffect.getAmplifier()+", duration is "+nexteffect.getDuration()); + if (witherskeletonheads+witherskeletonrareheads+witherskeletonpoweredheads+witherskeletonpoweredrareheads>0 && nexteffect.getType().getName().compareTo(PotionEffectType.WITHER.getName())==0) { + witherduration=nexteffect.getDuration(); + witheramplifier=nexteffect.getAmplifier(); + } + if (nexteffect.getType().getName().compareTo(PotionEffectType.SLOW.getName())==0 && nexteffect.getAmplifier()==6 && nexteffect.getDuration()<=60) { + m.removePotionEffect(PotionEffectType.SLOW); + //Bukkit.getLogger().info("Removed slow."); + //p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 200, nexteffect.getAmplifier()+1, true)); + break; + } + /*if (nexteffect.getType().getName().compareTo(PotionEffectType.JUMP.getName())==0) { + p.removePotionEffect(PotionEffectType.JUMP); + p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 360000, nexteffect.getAmplifier()+2, true)); + }*/ + effects.remove(); + } + } catch (ConcurrentModificationException ex_e) { + Bukkit.getLogger().warning("Potion Effect Collection not accessible while trying to remove slow debuff."); + } + if (witherskeletonpoweredrareheads>0) { + if (witherduration==0) {witherduration=400;} + Bukkit.getLogger().info("Adding potion effect WITHER with amplifier "+(witheramplifier+2*witherskeletonpoweredrareheads)+" + duration "+witherduration); + m.addPotionEffect(new PotionEffect(PotionEffectType.WITHER,witherduration,witheramplifier+2*witherskeletonpoweredrareheads),true); + } else if (witherskeletonpoweredheads>0) { + if (witherduration==0) {witherduration=100;} + Bukkit.getLogger().info("Adding potion effect WITHER with amplifier "+(witheramplifier+1*witherskeletonpoweredrareheads)+" + duration "+witherduration); + m.addPotionEffect(new PotionEffect(PotionEffectType.WITHER,witherduration,witheramplifier+1*witherskeletonpoweredrareheads),true); + } else if (witherskeletonrareheads>0) { + Bukkit.getLogger().info("Adding potion effect WITHER with amplifier 2 + duration "+(witherduration+300*witherskeletonrareheads)); + m.addPotionEffect(new PotionEffect(PotionEffectType.WITHER,witherduration+300*witherskeletonrareheads,2),true); + } else if (witherskeletonheads>0) { + Bukkit.getLogger().info("Adding potion effect WITHER with amplifier 0 + duration "+(witherduration+100*witherskeletonrareheads)); + m.addPotionEffect(new PotionEffect(PotionEffectType.WITHER,witherduration+100*witherskeletonrareheads,0),true); + } + } + int skeleton_heads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SKELETON), playerheads); + int powered_skeleton_heads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SKELETON, false, true), playerheads); + int rare_skeleton_heads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SKELETON, true, MobHeadRareType.RARE_TYPE_A), playerheads); + int powered_rare_skeleton_heads = this.plugin.getMobHeadAmt(new MobHead(MobHeadType.SKELETON, true, MobHeadRareType.RARE_TYPE_A, true), playerheads); /*if (skeleton_heads>0) { Bukkit.getLogger().info("Found "+skeleton_heads+" skeleton mob heads."); } diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index 07917d1..7a83364 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -1025,7 +1025,7 @@ public String convertToItemName(String val) { f.getInventory().addItem(i); } - if (args[0].equalsIgnoreCase("regen_chunk")) { + if (args[0].equalsIgnoreCase("regen_chunk") && 0==1 /*DISABLED to prevent accidental execution.*/) { if (p.hasPermission("maintenance-mode-admin")) { //boolean result=p.getWorld().regenerateChunk(p.getLocation().getBlockX()/16, p.getLocation().getBlockZ()/16); //Bukkit.getLogger().info("Chunk regenerated: "+result+" ("+p.getLocation().getBlockX()/16+","+p.getLocation().getBlockZ()/16+")");