package me.kaZep.Base; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collection; import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.List; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; public class PlayerBuffData { Player p; int base_spdlv; int base_armorlv; List armorbufflist; double base_hplv; List hpbufflist; short helmet_durability,chestplate_durability,leggings_durability,boots_durability; int potion_spdlv; long potion_time; long hpbuff_time; double extra_hp=0; double money_gained=0; long last_money_report_time=0; public Main plugin; public String healthbar(double curHP,double maxHP) { //█ ▌ int bits=(int)(Math.ceil(curHP/maxHP*10)); String bar=" "; if (bits>6) { bar+=ChatColor.GREEN+""; } else if (bits>3) { bar+=ChatColor.YELLOW+""; } else { bar+=ChatColor.RED+""; } for (int i=0;i(); this.hpbufflist=new ArrayList(); this.last_money_report_time=Bukkit.getWorld("world").getFullTime(); this.money_gained=0; if (p.getInventory().getHelmet()!=null) { this.helmet_durability=p.getInventory().getHelmet().getDurability(); } else { this.helmet_durability=-1; } if (p.getInventory().getChestplate()!=null) { this.chestplate_durability=p.getInventory().getChestplate().getDurability(); } else { this.chestplate_durability=-1; } if (p.getInventory().getLeggings()!=null) { this.leggings_durability=p.getInventory().getLeggings().getDurability(); } else { this.leggings_durability=-1; } if (p.getInventory().getBoots()!=null) { this.boots_durability=p.getInventory().getBoots().getDurability(); } else { this.boots_durability=-1; } this.plugin=thisplugin; try { Iterator effects = p.getActivePotionEffects().iterator(); //Figure out potion effects when player joins. while (effects.hasNext()) { PotionEffect nexteffect = effects.next(); if (nexteffect.getType().getName().compareTo(PotionEffectType.SPEED.getName())==0) { potion_spdlv = nexteffect.getAmplifier(); //Bukkit.getLogger().info("Speed level is "+nexteffect.getAmplifier()+" and lasts for "+nexteffect.getDuration()+" ticks."); potion_time = Bukkit.getWorld("world").getFullTime()+nexteffect.getDuration(); } effects.remove(); } } catch (ConcurrentModificationException ex_e) { Bukkit.getLogger().warning("Potion Effect Collection not accessible while initializing player speed."); } p.removePotionEffect(PotionEffectType.SPEED); } public void setBaseSpd(int spd) { this.base_spdlv=spd; } public void updateBaseArmor() { } public void updatePlayerSpd() { if (!p.isDead()) { //Don't even try to set things if we're dead. base_hplv=20; base_hplv+=hpbufflist.size()*10; if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")>0) { base_hplv+=this.plugin.getStatBonus(7, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat8")/2); } //Check player equipment to see if an item could possibly have a health buff. for (int i=0;i effects = p.getActivePotionEffects().iterator(); //Figure out potion effects when player joins. while (effects.hasNext()) { PotionEffect nexteffect = effects.next(); if (nexteffect.getType().getName().compareTo(PotionEffectType.HEALTH_BOOST.getName())==0) { base_hplv+=(nexteffect.getAmplifier()+1)*4; extra_hp=(nexteffect.getAmplifier()+1)*4; } if (nexteffect.getType().getName().compareTo(PotionEffectType.ABSORPTION.getName())==0) { hasabsorption=true; } effects.remove(); } } catch (ConcurrentModificationException ex_e) { Bukkit.getLogger().warning("Potion Effect Collection not accessible while finalizing player speed."); } if (!hasabsorption && this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")>0) { p.removePotionEffect(PotionEffectType.ABSORPTION); p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,3590,this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")/3)/4-1)); //p.sendMessage("Absorption level is "+(this.plugin.getStatBonus(3, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat4")/4)/4-1)); } if (this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")>0) { p.removePotionEffect(PotionEffectType.FAST_DIGGING); p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING,399,this.plugin.getStatBonus(1, this.plugin.getAccountsConfig().getInt(p.getName()+".stats.stat2")/4)/20-1)); } //p.sendMessage("Health: "+p.getHealth()+"/"+p.getMaxHealth()+" Base HP Level: "+base_hplv); if (p.getHealth()>p.getMaxHealth()) { p.setHealth(p.getMaxHealth()); //p.sendMessage("Health: "+p.getHealth()+"/"+p.getMaxHealth()+" Set new health: "+p.getMaxHealth()+"+"+extra_hp); } if (base_hplv!=p.getMaxHealth()) { double temphp=0; if (base_hplvbase_hplv) { p.setHealth(base_hplv); //p.sendMessage("Health too high. Lowering to "+p.getMaxHealth()); }*/ //Send new speed totals so the player's speed can be manually adjusted. if (potion_spdlv>0 && potion_time effects = p.getActivePotionEffects().iterator(); //Figure out potion effects when player joins. while (effects.hasNext()) { PotionEffect nexteffect = effects.next(); if (nexteffect.getType().getName().compareTo(PotionEffectType.INCREASE_DAMAGE.getName())==0) { if (nexteffect.getAmplifier()>0) { p.removePotionEffect(PotionEffectType.INCREASE_DAMAGE); p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,nexteffect.getDuration()*4,0)); } } if (nexteffect.getType().getName().compareTo(PotionEffectType.SPEED.getName())==0) { if (nexteffect.getDuration()<47479999) { //This is not a buff we applied via our plugin. potion_spdlv+=nexteffect.getAmplifier()+1; //p.sendMessage("Store speed "+nexteffect.getAmplifier()+" for "+nexteffect.getDuration()+" ticks."); potion_time = Bukkit.getWorld("world").getFullTime()+nexteffect.getDuration(); } } effects.remove(); } if (hpbuff_time0) { hpbufflist.remove(0); } } } catch (ConcurrentModificationException ex_e) { Bukkit.getLogger().warning("Potion Effect Collection not accessible while finalizing player speed."); } p.removePotionEffect(PotionEffectType.SPEED); if ((base_spdlv+potion_spdlv)>0) { //Bukkit.getPlayer("AaMay").sendMessage("Explorer giving speed buff: "+(base_spdlv-1+potion_spdlv)); p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 2147479999, base_spdlv-1+potion_spdlv, true)); } if (last_money_report_time+72000