diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index d7a2356..3192bd0 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 16ea70c..83a0c21 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.10.9e +version: 3.10.9f loadbefore: [aPlugin] commands: money: diff --git a/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java b/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java index 03ba2b6..0409bab 100644 --- a/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java +++ b/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java @@ -1,6 +1,9 @@ package sig.plugin.TwosideKeeper; +import java.util.HashMap; + import org.bukkit.ChatColor; +import org.bukkit.Color; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; @@ -20,6 +23,7 @@ public class ActionBarBuffUpdater{ } } actionbardisplay.append(AddAdditionalEffects(p)); + //TwosideKeeper.log(actionbardisplay.toString(), 0); if (actionbardisplay.toString().contains(" ")) { return actionbardisplay.toString().substring(0, actionbardisplay.toString().lastIndexOf(" ")); } else { @@ -32,42 +36,69 @@ public class ActionBarBuffUpdater{ if (p instanceof Player) { PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)p); if (p.getFireTicks()>=20) { - effectString.append(ChatColor.GOLD+"⚠"); + effectString.append(ChatColor.GOLD); + effectString.append("⚠"); effectString.append(AppendAmplifier((p.getFireTicks()/20)-1,false)); effectString.append(" "); } if (pd.lifestealstacks>4) { - effectString.append(ChatColor.AQUA+"❣"); + effectString.append(ChatColor.AQUA); + effectString.append("❣"); effectString.append(AppendAmplifier(pd.lifestealstacks-1)); effectString.append(" "); } if (pd.weaponcharges>4) { - effectString.append(ChatColor.DARK_AQUA+"☤"); + effectString.append(ChatColor.DARK_AQUA); + effectString.append("☤"); effectString.append(AppendAmplifier(pd.weaponcharges-1)); effectString.append(" "); } if (pd.damagepool>4) { - effectString.append(ChatColor.DARK_PURPLE+"♥"); + effectString.append(ChatColor.DARK_PURPLE); + effectString.append("♥"); effectString.append(AppendAmplifier((int)(pd.damagepool-1))); effectString.append(" "); } if (pd.lastvendettastack+200>TwosideKeeper.getServerTickTime() && ItemSet.hasFullSet(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL)) { - effectString.append(ChatColor.GRAY+"☉"); + effectString.append(ChatColor.GRAY); + effectString.append("☉"); effectString.append(AppendAmplifier(((int)((pd.lastvendettastack+200)-TwosideKeeper.getServerTickTime())/20)-1,false)); effectString.append(" "); } if (pd.swiftaegisamt>4) { - effectString.append(ChatColor.YELLOW+"❈"); + effectString.append(ChatColor.YELLOW); + effectString.append("❈"); effectString.append(AppendAmplifier((int)(GenericFunctions.getSwiftAegisAmt((Player)p)-1))); effectString.append(" "); } if (pd.regenpool>0) { - effectString.append(ChatColor.BLUE+""+ChatColor.BOLD+"✙"); + effectString.append(ChatColor.BLUE); + effectString.append(ChatColor.BOLD); + effectString.append("✙"); effectString.append(AppendAmplifier((int)(pd.regenpool))); effectString.append(" "); } } + HashMap buffMap = Buff.getBuffData(p); + for (String s : buffMap.keySet()) { + Buff b = buffMap.get(s); + + if (b.getRemainingBuffTime()>0) { + effectString.append(b.getBuffIcon()); + effectString.append(" "); + if (p instanceof Player) { + effectString.append(b.getDisplayName()); + } + effectString.append(ConvertBuffAmplifierToIcon(b.getAmplifier())); + effectString.append(" "); + if (b.getRemainingBuffTime()<=200) { + effectString.append(ConvertBuffTimeToIcon(b.getRemainingBuffTime())); + } + effectString.append(" "); + } + } + if (effectString.length()>0) { return effectString.toString()+ChatColor.RESET; } else { @@ -75,33 +106,115 @@ public class ActionBarBuffUpdater{ } } + private static String ConvertBuffAmplifierToIcon(int amplifier) { + if (amplifier==1) { + return "Ⅰ"; + } else + if (amplifier==2) { + return "Ⅱ"; + } else + if (amplifier==3) { + return "Ⅲ"; + } else + if (amplifier==4) { + return "Ⅳ"; + } else + if (amplifier==5) { + return "Ⅴ"; + } else + if (amplifier==6) { + return "Ⅵ"; + } else + if (amplifier==7) { + return "Ⅶ"; + } else + if (amplifier==8) { + return "Ⅷ"; + } else + if (amplifier==9) { + return "Ⅸ"; + } else + if (amplifier==10) { + return "Ⅹ"; + } else + if (amplifier==11) { + return "Ⅺ"; + } else + if (amplifier==12) { + return "Ⅻ"; + } else { + return Integer.toString(amplifier); + } + } + + private static String ConvertBuffTimeToIcon(long remainingBuffTime) { + if (remainingBuffTime>180) { + return "➓"; + } else + if (remainingBuffTime>160) { + return "➒"; + } else + if (remainingBuffTime>140) { + return "➑"; + } else + if (remainingBuffTime>120) { + return "➐"; + } else + if (remainingBuffTime>100) { + return "➏"; + } else + if (remainingBuffTime>80) { + return "➎"; + } else + if (remainingBuffTime>60) { + return "➍"; + } else + if (remainingBuffTime>40) { + return "➌"; + } else + if (remainingBuffTime>20) { + return "➋"; + } else + { + return "➊"; + } + } + private static String ParseEffect(LivingEntity p, PotionEffect pe) { StringBuilder effectString=new StringBuilder(""); PotionEffectType pet = pe.getType(); if (pet.equals(PotionEffectType.INCREASE_DAMAGE)) { - effectString.append(ChatColor.GOLD+"⚔"); + effectString.append(ChatColor.GOLD); + effectString.append("⚔"); } else if (pet.equals(PotionEffectType.DAMAGE_RESISTANCE)) { - effectString.append(ChatColor.BLUE+"❈"); + effectString.append(ChatColor.BLUE); + effectString.append("❈"); } else if (pet.equals(PotionEffectType.REGENERATION)) { - effectString.append(ChatColor.GREEN+"✙"); + effectString.append(ChatColor.GREEN); + effectString.append("✙"); } else if (pet.equals(PotionEffectType.SPEED)) { - effectString.append(ChatColor.WHITE+"➠"); + effectString.append(ChatColor.WHITE); + effectString.append("➠"); } else if (pet.equals(PotionEffectType.POISON) || (pet.equals(PotionEffectType.BLINDNESS) && (p instanceof LivingEntity && !(p instanceof Player)))) { - effectString.append(ChatColor.YELLOW+"☣"); - } else - if ((pet.equals(PotionEffectType.UNLUCK) && (p instanceof LivingEntity && !(p instanceof Player)))) { - effectString.append(ChatColor.DARK_RED+"☠"); + effectString.append(ChatColor.YELLOW); + effectString.append("☣"); } else + /*if ((pet.equals(PotionEffectType.UNLUCK) && (p instanceof LivingEntity && !(p instanceof Player)))) { + effectString.append(ChatColor.DARK_RED); + effectString.append("☠"); + } else*/ if (pet.equals(PotionEffectType.SLOW)) { - effectString.append(ChatColor.DARK_AQUA+"♒"); + effectString.append(ChatColor.DARK_AQUA); + effectString.append("♒"); } else if (pet.equals(PotionEffectType.WEAKNESS) || pet.equals(PotionEffectType.SLOW_DIGGING)) { - effectString.append(ChatColor.RED+"✘"); + effectString.append(ChatColor.RED); + effectString.append("✘"); } if (effectString.length()>0) { effectString.append(AppendAmplifier(pe.getAmplifier())); diff --git a/src/sig/plugin/TwosideKeeper/BossMonster.java b/src/sig/plugin/TwosideKeeper/BossMonster.java index 601542f..2dfa450 100644 --- a/src/sig/plugin/TwosideKeeper/BossMonster.java +++ b/src/sig/plugin/TwosideKeeper/BossMonster.java @@ -41,7 +41,7 @@ public class BossMonster { this.m = m; this.damagereduction=0.0; this.buffs=null; - this.movespd=LivingEntityStructure.getLivingEntityStructure(m).original_movespd; + this.movespd=LivingEntityStructure.GetLivingEntityStructure(m).original_movespd; this.hp_regen=0; this.bar = m.getServer().createBossBar(GenericFunctions.getDisplayName(m), BarColor.WHITE, BarStyle.SOLID, BarFlag.CREATE_FOG); } @@ -54,7 +54,7 @@ public class BossMonster { this.attackstrength = attackstrength; this.m = m; this.buffs=null; - this.movespd=LivingEntityStructure.getLivingEntityStructure(m).original_movespd; + this.movespd=LivingEntityStructure.GetLivingEntityStructure(m).original_movespd; this.hp_regen=0; this.bar = m.getServer().createBossBar(GenericFunctions.getDisplayName(m), BarColor.WHITE, BarStyle.SOLID, BarFlag.CREATE_FOG); } @@ -68,7 +68,7 @@ public class BossMonster { this.attackstrength = attackstrength; this.m = m; this.buffs = buffs; - this.movespd=LivingEntityStructure.getLivingEntityStructure(m).original_movespd; + this.movespd=LivingEntityStructure.GetLivingEntityStructure(m).original_movespd; this.hp_regen=0; this.bar = m.getServer().createBossBar(GenericFunctions.getDisplayName(m), BarColor.WHITE, BarStyle.SOLID, BarFlag.CREATE_FOG); } diff --git a/src/sig/plugin/TwosideKeeper/Buff.java b/src/sig/plugin/TwosideKeeper/Buff.java index 6ede043..38a13f2 100644 --- a/src/sig/plugin/TwosideKeeper/Buff.java +++ b/src/sig/plugin/TwosideKeeper/Buff.java @@ -1,10 +1,186 @@ package sig.plugin.TwosideKeeper; +import java.util.HashMap; +import java.util.List; + +import org.bukkit.ChatColor; import org.bukkit.Color; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import sig.plugin.TwosideKeeper.HelperStructures.Utils.TextUtils; public class Buff { - String displayName; - long expireTime; - int level; - Color col; + private String displayName; + private long expireTime; + private int level; + private Color col; + private String icon; + + public Buff(String displayName, long duration, int amplifier, Color buffcolor, String icon) { + this.displayName=displayName; + this.expireTime=TwosideKeeper.getServerTickTime()+duration; + this.level=amplifier; + this.col=buffcolor; + this.icon=icon; + } + + public static boolean hasBuffInHashMap(LivingEntity l, String name) { + if (l instanceof Player) { + Player p = (Player)l; + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + return pd.buffs.containsKey(name); + } else { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); + return les.buffs.containsKey(name); + } + } + + public static boolean hasBuff(LivingEntity l, String name) { + if (l instanceof Player) { + Player p = (Player)l; + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + if (pd.buffs.containsKey(name)) { + Buff b = pd.buffs.get(name); + return hasBuffExpired(b); + } else { + return false; + } + } else { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); + if (les.buffs.containsKey(name)) { + Buff b = les.buffs.get(name); + return hasBuffExpired(b); + } else { + return false; + } + } + } + + public static void outputBuffs(LivingEntity l) { + if (l instanceof Player) { + Player p = (Player)l; + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + TwosideKeeper.log(TextUtils.outputHashmap(pd.buffs),0); + } else { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); + TwosideKeeper.log(TextUtils.outputHashmap(les.buffs),0); + } + } + + public static HashMapgetBuffData(LivingEntity l) { + if (l instanceof Player) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); + return pd.buffs; + } else { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); + return les.buffs; + } + } + + /** + * Returns null if no buff found! Use hasBuff() to verify they have + * a buff beforehand. + */ + public static Buff getBuff(LivingEntity l, String name) { + if (hasBuff(l,name)) { + if (l instanceof Player) { + Player p = (Player)l; + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + if (pd.buffs.containsKey(name)) { + return pd.buffs.get(name); + } else { + return null; + } + } else { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); + if (les.buffs.containsKey(name)) { + Buff b = les.buffs.get(name); + return b; + } else { + return null; + } + } + } else { + return null; + } + } + public static void addBuff(LivingEntity l, String name, Buff buff) { + if (l instanceof Player) { + Player p = (Player)l; + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + pd.buffs.put(name, buff); + } else { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); + les.buffs.put(name, buff); + } + } + public static void removeBuff(LivingEntity l, String name) { + if (l instanceof Player) { + Player p = (Player)l; + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + pd.buffs.remove(name); + } else { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); + les.buffs.remove(name); + } + } + + public void increaseStacks(int amt) { + level+=amt; + } + public void decreaseStacks(int amt) { + level-=amt; + } + public void setStacks(int amt) { + level=amt; + } + public void increaseDuration(int duration) { + expireTime+=duration; + } + public void decreaseDuration(int duration) { + expireTime-=duration; + } + public void setDuration(int duration) { + refreshDuration(duration); + } + public void refreshDuration(int duration) { + expireTime=TwosideKeeper.getServerTickTime()+duration; + } + + private static boolean hasBuffExpired(Buff b) { + if (b.expireTime finallist = hitlist; - Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("TwosideKeeper"), new Runnable() { + /*Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("TwosideKeeper"), new Runnable() { public void run() { for (LivingEntity le : finallist) { - if (le!=null && !le.isDead() && !le.hasPotionEffect(PotionEffectType.UNLUCK)) { - GenericFunctions.ResetMobName(le); + if (le!=null && !le.isDead() && !Buff.hasBuff(le, "DeathMark")) { + LivingEntityStructure.UpdateMobName(le); //They don't have death marks anymore, so we just remove their name color. } } }} - ,100); + ,100);*/ increaseSwordComboCount(weapon, p); } @@ -732,7 +732,7 @@ public class CustomDamage { private static double IncreaseDamageDealtByElites(Player p, Entity damager, double damage) { LivingEntity shooter = getDamagerEntity(damager); if (shooter!=null) { - LivingEntityStructure les = LivingEntityStructure.getLivingEntityStructure(shooter); + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(shooter); if (les.isElite) { for (EliteMonster bm : TwosideKeeper.elitemonsters) { if (bm.getMonster().getUniqueId().equals(shooter.getUniqueId())) { @@ -1177,7 +1177,7 @@ public class CustomDamage { private static void triggerEliteBreakEvent(LivingEntity target) { if (target instanceof Monster && TwosideKeeper.livingentitydata.containsKey(target.getUniqueId())) { - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure((LivingEntity)target); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure((LivingEntity)target); if (ms.getElite()) { boolean exists=false; for (int i=0;i0) { ItemMeta m = item.getItemMeta(); @@ -189,6 +186,10 @@ public class GenericFunctions { } } + private static void showStackTrace() { + DebugUtils.showStackTrace(); + } + public static ItemStack convertArtifactToDust(ItemStack item) { //Add one line of lore to indicate it's broken dust. item = addObscureHardenedItemBreaks(item,1); @@ -2195,7 +2196,8 @@ public class GenericFunctions { item.getType()!=Material.AIR && (item.getType().toString().contains("BOOTS") || item.getType().toString().contains("CHESTPLATE") || item.getType().toString().contains("LEGGINGS") || - item.getType().toString().contains("HELMET"))) { + item.getType().toString().contains("HELMET") || + item.getType().toString().contains("SHIELD"))) { return true; } else { return false; @@ -2291,8 +2293,8 @@ public class GenericFunctions { ((Guardian)m).isElder()) || m.getType()==EntityType.ENDER_DRAGON || m.getType()==EntityType.WITHER || - LivingEntityStructure.getLivingEntityStructure(m).getLeader() || - LivingEntityStructure.getLivingEntityStructure(m).getElite()) { + LivingEntityStructure.GetLivingEntityStructure(m).getLeader() || + LivingEntityStructure.GetLivingEntityStructure(m).getElite()) { return true; } else { return false; @@ -2510,7 +2512,7 @@ public class GenericFunctions { public static void ApplyDeathMark(LivingEntity ent) { int stackamt = 0; - if (ent.hasPotionEffect(PotionEffectType.UNLUCK)) { + /*if (ent.hasPotionEffect(PotionEffectType.UNLUCK)) { //Add to the current stack of unluck. for (PotionEffect pe : ent.getActivePotionEffects()) { if (pe.getType().equals(PotionEffectType.UNLUCK)) { @@ -2527,8 +2529,22 @@ public class GenericFunctions { TwosideKeeper.log("Death mark stack is now T1", 5); ent.addPotionEffect(new PotionEffect(PotionEffectType.UNLUCK,99,0)); stackamt=1; - } + }*/ //Modify the color of the name of the monster. + HashMap buffdata = Buff.getBuffData(ent); + if (Buff.hasBuff(ent, "DeathMark")) { + Buff deathmarkBuff = buffdata.get("DeathMark"); + deathmarkBuff.increaseStacks(1); + deathmarkBuff.refreshDuration(99); + stackamt = deathmarkBuff.getAmplifier(); + } else { + buffdata.put("DeathMark", new Buff("Death Mark",99,1,org.bukkit.Color.MAROON,ChatColor.DARK_RED+"☠")); + stackamt = 1; + } + RefreshBuffColor(ent, stackamt); + } + + public static void RefreshBuffColor(LivingEntity ent, int stackamt) { if (ent instanceof LivingEntity) { LivingEntity m = (LivingEntity)ent; m.setCustomNameVisible(true); @@ -2541,34 +2557,19 @@ public class GenericFunctions { } public static int GetDeathMarkAmt(LivingEntity ent) { - if (ent.hasPotionEffect(PotionEffectType.UNLUCK)) { + /*if (ent.hasPotionEffect(PotionEffectType.UNLUCK)) { //Add to the current stack of unluck. for (PotionEffect pe : ent.getActivePotionEffects()) { if (pe.getType().equals(PotionEffectType.UNLUCK)) { return pe.getAmplifier()+1; } } - } - return 0; - } - - public static void ResetMobName(LivingEntity ent) { - if (ent instanceof LivingEntity) { - LivingEntity m = (LivingEntity)ent; - m.setCustomNameVisible(false); - if (m.getCustomName()!=null) { - m.setCustomName(ChatColor.stripColor(GenericFunctions.getDisplayName(m))); - if (m.getCustomName().contains("Dangerous")) { - m.setCustomName(ChatColor.DARK_AQUA+m.getCustomName()); - } - if (m.getCustomName().contains("Deadly")) { - m.setCustomName(ChatColor.GOLD+m.getCustomName()); - } - if (m.getCustomName().contains("Hellfire")) { - m.setCustomName(ChatColor.DARK_RED+m.getCustomName()); - } - CustomDamage.appendDebuffsToName(m); - } + }*/ + HashMap buffdata = Buff.getBuffData(ent); + if (Buff.hasBuff(ent, "DeathMark")) { + return buffdata.get("DeathMark").getAmplifier(); + } else { + return 0; } } @@ -2588,7 +2589,7 @@ public class GenericFunctions { } p.sendMessage(ChatColor.DARK_AQUA+"A level of "+ChatColor.YELLOW+"Mending"+ChatColor.DARK_AQUA+" has been knocked off of your "+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():UserFriendlyMaterialName(item))); } - if (infinitylv>0 && Math.random()<=0.005*(isHarvestingTool(item)?0.75:1d)) { + if (infinitylv>0 && Math.random()<=0.0015*(isHarvestingTool(item)?0.75:1d)) { infinitylv--; if (infinitylv>0) { item.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, infinitylv); @@ -2872,7 +2873,7 @@ public class GenericFunctions { Bukkit.getPluginManager().callEvent(ev); if (!ev.isCancelled()) { pd.last_dodge=TwosideKeeper.getServerTickTime(); - aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 100); + aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.DODGE_COOLDOWN,p)); SoundUtils.playLocalSound(p, Sound.ENTITY_DONKEY_CHEST, 1.0f, 1.0f); int dodgeduration = 20; @@ -3049,7 +3050,7 @@ public class GenericFunctions { } else if (entity instanceof LivingEntity) { LivingEntity m = (LivingEntity)entity; - LivingEntityStructure md = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure md = LivingEntityStructure.GetLivingEntityStructure(m); if (damager!=null) { if (damager instanceof Projectile) { if (CustomDamage.getDamagerEntity(damager)!=null) { @@ -3094,7 +3095,7 @@ public class GenericFunctions { } else if (entity instanceof LivingEntity) { LivingEntity m = (LivingEntity)entity; - LivingEntityStructure md = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure md = LivingEntityStructure.GetLivingEntityStructure(m); if (damager!=null) { if (damager instanceof Player) { Player p = (Player)damager; @@ -3131,7 +3132,7 @@ public class GenericFunctions { } else if (entity instanceof LivingEntity) { LivingEntity m = (LivingEntity)entity; - LivingEntityStructure md = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure md = LivingEntityStructure.GetLivingEntityStructure(m); if (damager!=null) { if (damager instanceof Projectile) { if (CustomDamage.getDamagerEntity(damager)!=null) { @@ -3698,7 +3699,6 @@ public class GenericFunctions { return revived; } - //TODO Fix Bauble Breaking. public static void RandomlyBreakBaubles(Player p) { /*for (int i=0;i<9;i++) { ItemSet set = ItemSet.GetSet(hotbar[i]); @@ -3919,7 +3919,7 @@ public class GenericFunctions { GlowAPI.setGlowing(m, color, p); } }*/ - LivingEntityStructure.getLivingEntityStructure(m).setGlobalGlow(color); + LivingEntityStructure.GetLivingEntityStructure(m).setGlobalGlow(color); } public static void DealDamageToNearbyPlayers(Location l, double basedmg, int range, boolean knockup, double knockupamt, Entity damager, String reason, boolean truedmg) { @@ -4037,7 +4037,7 @@ public class GenericFunctions { } public static boolean isEliteMonster(LivingEntity m) { - LivingEntityStructure md = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure md = LivingEntityStructure.GetLivingEntityStructure(m); return md.getElite(); } @@ -4717,8 +4717,8 @@ public class GenericFunctions { } public static boolean isSpecialGlowMonster(Monster m) { - return LivingEntityStructure.getLivingEntityStructure(m).isLeader || - LivingEntityStructure.getLivingEntityStructure(m).isElite; + return LivingEntityStructure.GetLivingEntityStructure(m).isLeader || + LivingEntityStructure.GetLivingEntityStructure(m).isElite; } public static boolean isSuppressed(Entity ent) { @@ -4764,7 +4764,7 @@ public class GenericFunctions { } if (ent instanceof LivingEntity) { //MonsterStructure.getMonsterStructure((Monster)ent).setGlobalGlow(GlowAPI.Color.BLACK); - LivingEntityStructure.getLivingEntityStructure((LivingEntity)ent).UpdateGlow(); + LivingEntityStructure.GetLivingEntityStructure((LivingEntity)ent).UpdateGlow(); } else { GlowAPI.setGlowing(ent, GlowAPI.Color.BLACK, Bukkit.getOnlinePlayers()); } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/RecyclingCenterNode.java b/src/sig/plugin/TwosideKeeper/HelperStructures/RecyclingCenterNode.java index 7114632..f87d22a 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/RecyclingCenterNode.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/RecyclingCenterNode.java @@ -46,5 +46,7 @@ public class RecyclingCenterNode { return loc; } - + public String toString() { + return "RecyclingCenterNode(x="+loc.getBlockX()+",y="+loc.getBlockY()+",z="+loc.getBlockZ()+",tools="+toolsAllowed+",itemsAllowed="+itemsAllowed+")"; + } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ArrayUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ArrayUtils.java index 06b2291..bec0503 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ArrayUtils.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ArrayUtils.java @@ -1,10 +1,13 @@ package sig.plugin.TwosideKeeper.HelperStructures.Utils; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import org.bukkit.inventory.ItemStack; +import sig.plugin.TwosideKeeper.TwosideKeeper; + public class ArrayUtils { public static String toString(Object[] items) { StringBuilder string = new StringBuilder(); @@ -21,4 +24,32 @@ public class ArrayUtils { } return string.toString(); } + + public static String[] combineArguments(String[] args) { + List newargs = new ArrayList(); + String collective = ""; + Character lookingfor = ' '; + for (int i=0;i0) { + if (args[i].charAt(args[i].length()-2)!='\\' && args[i].charAt(args[i].length()-1)==lookingfor) { + collective = collective + " " + args[i].substring(0, Math.max(0,args[i].length()-1)); + newargs.add(collective); + collective = ""; + lookingfor = ' '; + } else { + collective = collective + " " + args[i]; + TwosideKeeper.log(collective, 0); + } + } else { + newargs.add(args[i]); + } + } + return newargs.toArray(new String[newargs.size()]); + } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/DebugUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/DebugUtils.java new file mode 100644 index 0000000..14fcd30 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/DebugUtils.java @@ -0,0 +1,15 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Utils; + +import sig.plugin.TwosideKeeper.TwosideKeeper; + +public class DebugUtils { + + public static void showStackTrace() { + StackTraceElement[] stacktrace = new Throwable().getStackTrace(); + StringBuilder stack = new StringBuilder("Mini stack tracer:"); + for (int i=0;i ents = ent.getNearbyEntities(range, range, range); LivingEntityDifficulty strongest = null; for (Entity e : ents) { - if (e instanceof LivingEntity) { - LivingEntityStructure les = LivingEntityStructure.getLivingEntityStructure((LivingEntity)e); + if (e instanceof LivingEntity && !(e instanceof Player)) { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure((LivingEntity)e); les.checkedforcubes=true; LivingEntityDifficulty diff = MonsterController.getLivingEntityDifficulty((LivingEntity)e); if (e!=null && e.getType()==type && (strongest==null || !strongest.isStronger(diff))) { @@ -83,10 +87,79 @@ public class EntityUtils { return aec; } - public static void createPotionEffectSwirls(LivingEntity l,Color col) { - AreaEffectCloud aec = (AreaEffectCloud)l.getWorld().spawnEntity(l.getLocation(), EntityType.AREA_EFFECT_CLOUD); - aec.setColor(col); - aec.setDuration(5); - aec.setRadius(0.1f); + public static void createPotionEffectSwirls(LivingEntity l, Color col, int delay) { + Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, ()->{ + AreaEffectCloud aec = (AreaEffectCloud)l.getWorld().spawnEntity(l.getLocation(), EntityType.AREA_EFFECT_CLOUD); + aec.setColor(col); + aec.setDuration(5); + aec.setRadius(0.1f); + },delay); + } + + public static void applyBuff(LivingEntity l, String buffname, Buff buff) { + HashMap buffMap; + if (l instanceof Player) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); + buffMap = pd.buffs; + } else { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); + buffMap = les.buffs; + } + buffMap.put(buffname, buff); + updateBuffDisplay(l); + } + + public static void applyBuffs(LivingEntity l, String[] buffnames, Buff ... buffArr) { + HashMap buffMap; + if (buffnames.length==buffArr.length) { + if (l instanceof Player) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); + buffMap = pd.buffs; + } else { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); + buffMap = les.buffs; + } + for (int i=0;i buffMap; + if (l instanceof Player) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); + buffMap = pd.buffs; + } else { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); + buffMap = les.buffs; + } + buffMap.remove(buffName); + updateBuffDisplay(l); + } + + public static void removeBuffs(LivingEntity l, String ... buffNames) { + HashMap buffMap; + if (l instanceof Player) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); + buffMap = pd.buffs; + } else { + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); + buffMap = les.buffs; + } + for (int i=0;i buffs = new HashMap(); + public long lastpotionparticles=0; public LivingEntityStructure(LivingEntity m) { target=null; - original_name=""; + original_name=GetOriginalName(m); + //TwosideKeeper.log("Original name is "+original_name, 0); this.m=m; this.original_movespd = m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue(); } public LivingEntityStructure(LivingEntity m, LivingEntity target) { this.target=target; - original_name=""; + original_name=GetOriginalName(m); this.m=m; this.original_movespd = m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue(); } @@ -47,6 +51,14 @@ public class LivingEntityStructure { this.original_movespd = m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue(); } + private String GetOriginalName(LivingEntity m) { + if (m.getCustomName()!=null) { + return m.getCustomName(); + } else { + return GenericFunctions.CapitalizeFirstLetters(m.getType().name().replace("_", " ")); + } + } + public LivingEntity GetTarget() { if (this.target!=null && !this.target.isDead()) { @@ -135,15 +147,47 @@ public class LivingEntityStructure { } } + public static void UpdateMobName(LivingEntity ent) { + if (ent instanceof LivingEntity) { + LivingEntity m = (LivingEntity)ent; + m.setCustomNameVisible(false); + if (m.getCustomName()!=null) { + m.setCustomName(ChatColor.stripColor(GenericFunctions.getDisplayName(m))); + if (m.getCustomName().contains("Dangerous")) { + m.setCustomName(ChatColor.DARK_AQUA+m.getCustomName()); + } + if (m.getCustomName().contains("Deadly")) { + m.setCustomName(ChatColor.GOLD+m.getCustomName()); + } + if (m.getCustomName().contains("Hellfire")) { + m.setCustomName(ChatColor.DARK_RED+m.getCustomName()); + } + m.setCustomName(ChatColor.DARK_RED+m.getCustomName()+ChatColor.RESET+" "); + if (Buff.hasBuff(m, "DeathMark")) { + GenericFunctions.RefreshBuffColor(m, Buff.getBuff(m, "DeathMark").getAmplifier()); + } + CustomDamage.appendDebuffsToName(m); + if (m.getCustomName().contains(" ")) { + m.setCustomNameVisible(true); + } + } + } + } //Either gets a monster structure that exists or creates a new one. - public static LivingEntityStructure getLivingEntityStructure(LivingEntity m2) { - UUID id = m2.getUniqueId(); - if (TwosideKeeper.livingentitydata.containsKey(id)) { - return TwosideKeeper.livingentitydata.get(id); + public static LivingEntityStructure GetLivingEntityStructure(LivingEntity m) { + if (m instanceof Player) { + TwosideKeeper.log("ERROR!! We are trying to retrieve a LivingEntityStructure for a Player!", 0); + DebugUtils.showStackTrace(); + return null; } else { - LivingEntityStructure newstruct = new LivingEntityStructure(m2); - TwosideKeeper.livingentitydata.put(id,newstruct); - return TwosideKeeper.livingentitydata.get(id); + UUID id = m.getUniqueId(); + if (TwosideKeeper.livingentitydata.containsKey(id)) { + return TwosideKeeper.livingentitydata.get(id); + } else { + LivingEntityStructure newstruct = new LivingEntityStructure(m); + TwosideKeeper.livingentitydata.put(id,newstruct); + return TwosideKeeper.livingentitydata.get(id); + } } } } diff --git a/src/sig/plugin/TwosideKeeper/MonsterController.java b/src/sig/plugin/TwosideKeeper/MonsterController.java index aab58ec..56a2dd1 100644 --- a/src/sig/plugin/TwosideKeeper/MonsterController.java +++ b/src/sig/plugin/TwosideKeeper/MonsterController.java @@ -82,10 +82,12 @@ public class MonsterController { ent.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,Integer.MAX_VALUE,1)); //Monster m = (Monster)ent; LivingEntityStructure ms = TwosideKeeper.livingentitydata.get(ent.getUniqueId()); - LivingEntityDifficulty led = getLivingEntityDifficulty(ent); - ms.SetLeader(true); - convertLivingEntity(ent,led); - TwosideKeeper.log(" Converted "+GenericFunctions.GetEntityDisplayName(ent)+" to Leader!",TwosideKeeper.SPAWN_DEBUG_LEVEL); + if (ms!=null) { + LivingEntityDifficulty led = getLivingEntityDifficulty(ent); + ms.SetLeader(true); + convertLivingEntity(ent,led); + TwosideKeeper.log(" Converted "+GenericFunctions.GetEntityDisplayName(ent)+" to Leader!",TwosideKeeper.SPAWN_DEBUG_LEVEL); + } //Set the HP of the leader to a more proper amount. } else if (meetsConditionsToBeElite(ent) && !minion) { @@ -901,7 +903,7 @@ public class MonsterController { m.setMaxHealth(800); //Target is 800 HP. m.setHealth(m.getMaxHealth()); TwosideKeeper.log(m.getCustomName()+" health is "+m.getMaxHealth(), 5); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetLeader(true); ms.UpdateGlow(); TwosideKeeper.log("->Setting an entity with Difficulty "+led.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5); @@ -928,7 +930,7 @@ public class MonsterController { m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8)); m.setMaxHealth(1200); //Target is 1200 HP. m.setHealth(m.getMaxHealth()); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetLeader(true); ms.UpdateGlow(); TwosideKeeper.log("->Setting an entity with Difficulty "+led.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5); @@ -960,12 +962,12 @@ public class MonsterController { { TwosideKeeper.log(" Converting "+GenericFunctions.GetEntityDisplayName(m)+" to Leader.",TwosideKeeper.SPAWN_DEBUG_LEVEL); m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8)); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetLeader(true); ms.UpdateGlow(); m.setMaxHealth(1600); //Target is 1600 HP. m.setHealth(m.getMaxHealth()); - LivingEntityStructure.getLivingEntityStructure(m).SetLeader(true); + LivingEntityStructure.GetLivingEntityStructure(m).SetLeader(true); TwosideKeeper.log("->Setting an entity with Difficulty "+led.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5); } else { m.setMaxHealth(m.getMaxHealth()*4.0); @@ -994,7 +996,7 @@ public class MonsterController { } m.setCustomNameVisible(true); m.setRemoveWhenFarAway(false); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetElite(true); ms.UpdateGlow(); m.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(72.0); @@ -1013,7 +1015,7 @@ public class MonsterController { m.setMaxHealth(400); m.setHealth(m.getMaxHealth()); m.setCustomName("Zombie Leader"); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetLeader(true); ms.UpdateGlow(); TwosideKeeper.log("->Setting an entity with Difficulty "+led.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5); @@ -1040,7 +1042,7 @@ public class MonsterController { { m.setMaxHealth(32000); //Target is 1600 HP. m.setHealth(m.getMaxHealth()); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetLeader(true); ms.UpdateGlow(); TwosideKeeper.log("->Setting an entity with Difficulty "+led.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5); @@ -1076,7 +1078,7 @@ public class MonsterController { m.setMaxHealth(800); //Target is 800 HP. m.setHealth(m.getMaxHealth()); TwosideKeeper.log(m.getCustomName()+" health is "+m.getMaxHealth(), 5); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetLeader(true); ms.UpdateGlow(); TwosideKeeper.log("->Setting a monster with Difficulty "+md.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5); @@ -1102,7 +1104,7 @@ public class MonsterController { m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8)); m.setMaxHealth(1200); //Target is 1200 HP. m.setHealth(m.getMaxHealth()); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetLeader(true); ms.UpdateGlow(); TwosideKeeper.log("->Setting a monster with Difficulty "+md.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5); @@ -1133,12 +1135,12 @@ public class MonsterController { if(isZombieLeader(m)) { m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8)); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetLeader(true); ms.UpdateGlow(); m.setMaxHealth(1600); //Target is 1600 HP. m.setHealth(m.getMaxHealth()); - LivingEntityStructure.getLivingEntityStructure(m).SetLeader(true); + LivingEntityStructure.GetLivingEntityStructure(m).SetLeader(true); TwosideKeeper.log("->Setting a monster with Difficulty "+md.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5); } else { m.setMaxHealth(m.getMaxHealth()*4.0); @@ -1167,7 +1169,7 @@ public class MonsterController { } m.setCustomNameVisible(true); m.setRemoveWhenFarAway(false); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetElite(true); ms.UpdateGlow(); m.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(72.0); @@ -1186,7 +1188,7 @@ public class MonsterController { m.setMaxHealth(400); m.setHealth(m.getMaxHealth()); m.setCustomName("Zombie Leader"); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetLeader(true); ms.UpdateGlow(); TwosideKeeper.log("->Setting a monster with Difficulty "+md.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5); @@ -1213,7 +1215,7 @@ public class MonsterController { { m.setMaxHealth(32000); //Target is 1600 HP. m.setHealth(m.getMaxHealth()); - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); ms.SetLeader(true); ms.UpdateGlow(); TwosideKeeper.log("->Setting a monster with Difficulty "+md.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5); @@ -1312,7 +1314,7 @@ public class MonsterController { /*if (ent.getLocation().getY()<54) { } else */ { - LivingEntityStructure les = LivingEntityStructure.getLivingEntityStructure(ent); + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(ent); les.SetLeader(true); les.m.setMaxHealth(480000); les.m.setCustomName(ChatColor.RED+"Leader Wither"); diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index 3145b3a..c7171d9 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -197,6 +197,7 @@ public class PlayerStructure { public boolean vacuumsuckup=true; public boolean equipweapons=true; public boolean equiparmor=true; + public long lastpotionparticles=0; public Location restartLoc = null; //Set to a value when the player has to be re-teleported after being controlled by a camera. List equipmentset = new ArrayList(); diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index d8f95c7..8ca75cc 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -688,6 +688,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public void run(){ //Control charge zombies.. long time = System.nanoTime(); + long totaltime = System.nanoTime(); for (ChargeZombie cz : chargezombies.values()) { if (cz.m==null || !cz.m.isValid() || !cz.isAlive() || !cz.hasTarget() || (cz.GetZombie().getWorld().getName().equalsIgnoreCase("world") && cz.GetZombie().getLocation().getY()>32)) { //This has to be removed... @@ -797,7 +798,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (e==null || !e.isValid() || GenericFunctions.getSuppressionTime(e)<=0) { if (e!=null && e.isValid() && e instanceof LivingEntity) { - LivingEntityStructure les = LivingEntityStructure.getLivingEntityStructure((LivingEntity)e); + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure((LivingEntity)e); ((LivingEntity)e).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(les.original_movespd); ((LivingEntity)e).setAI(true); } @@ -848,6 +849,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } TwosideKeeper.HeartbeatLogger.AddEntry("Temporary Camera Handling", (int)(System.nanoTime()-time));time=System.nanoTime(); + if ((int)(System.nanoTime()-totaltime)/1000000d>50) { + TwosideKeeper.log("WARNING! Structure Handling took longer than 1 tick! "+((int)(System.nanoTime()-totaltime)/1000000d)+"ms", 0); + } + TwosideKeeper.HeartbeatLogger.AddEntry(ChatColor.LIGHT_PURPLE+"Total Structure Handling", (int)(System.nanoTime()-totaltime));totaltime=System.nanoTime(); } private void UpdateLavaBlock(Block lavamod) { @@ -1103,7 +1108,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { /*MonsterTemplate newtemp = new MonsterTemplate(new File(filesave+"/monsterdata/KingSlime.md")); int newint = (int)newtemp.getValue("timeToLive"); log(Integer.toString(newint),0);*/ - log(" This is here to change the file size if necessary Kappa Kappa Kappa No Copy-pasterino Kappachino Lulu c: Please update version number.",5); + log(" This is here to change the file size if necessary Kappa Kappa Kappa No Copy-pasterino Kappachino Lulu c: Please update version number. lololol",5); } private static void InitializeBotCommands() { @@ -1177,6 +1182,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { + args = ArrayUtils.combineArguments(args); + //TwosideKeeper.log(Arrays.toString(args), 0); if (cmd.getName().equalsIgnoreCase("log")) { LOGGING_LEVEL = (LOGGING_LEVEL+1) % 6; sender.sendMessage("Debugging Log Level is now "+ChatColor.RED+LOGGING_LEVEL+"."); @@ -1802,6 +1809,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener { aec.setDuration(5); aec.setRadius(0.1f); }break; + case "APPLYBUFF":{ + //p.spawnParticle(Particle.SPELL_MOB_AMBIENT, p.getLocation(), 30); + //EntityUtils.applyBuff(p, args[1], new Buff(args[2],20*10*60,2,Color.BLUE,"✌")); + //Buff.outputBuffs(p); + /*EntityUtils.applyBuffs(p, new String[]{"Poison","Slow","Bleed"}, new Buff[]{ + new Buff("Poison",20*20,3,Color.YELLOW,ChatColor.YELLOW+"☠"), + new Buff("Slowness",20*17,1,Color.GRAY,ChatColor.GRAY+"≈"), + new Buff("Bleeding",20*14,5,Color.MAROON,ChatColor.RED+"☣"), + });*/ + }break; } } @@ -2604,7 +2621,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } for (UUID id : livingentitydata.keySet()) { - LivingEntityStructure les = LivingEntityStructure.getLivingEntityStructure(livingentitydata.get(id).m); + LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(livingentitydata.get(id).m); les.setGlow(ev.getPlayer(), null); } @@ -4240,7 +4257,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { for (int i=0;i20) { @@ -5994,6 +6007,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { { TwosideKeeper.log(" This is a normal mob.",TwosideKeeper.SPAWN_DEBUG_LEVEL); if (!ev.getSpawnReason().equals(SpawnReason.SPAWNER_EGG) && !ev.getSpawnReason().equals(SpawnReason.SLIME_SPLIT)) { + if (ev.getEntity() instanceof LivingEntity) { + LivingEntity m = ev.getEntity(); + LivingEntityStructure.GetLivingEntityStructure(m); + } if (!habitat_data.addNewStartingLocation(ev.getEntity())) { ev.getEntity().remove(); ev.setCancelled(true); @@ -6041,6 +6058,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { return; } } + if (ev.getEntity() instanceof LivingEntity) { + LivingEntity m = ev.getEntity(); + LivingEntityStructure.GetLivingEntityStructure(m); + } } private void convertToStrongerShulker(LivingEntity entity) { @@ -6110,7 +6131,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } - //TODO Nerf Durability @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void dodgeEvent(PlayerDodgeEvent ev) { Player p = ev.getPlayer(); @@ -6652,7 +6672,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.setCancelled(true); return; } - LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m); + LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); if (ms.getElite()) { log("Target reason is "+ev.getReason(),5); EliteMonster em = null; @@ -6798,19 +6818,18 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (ev.getEntity() instanceof LivingEntity) { List droplist = ev.getDrops(); LivingEntity m = (LivingEntity)ev.getEntity(); - double dropmult = 0.0d; boolean isBoss=false; boolean isElite=false; boolean killedByPlayer = false; final Location deathloc = m.getLocation(); LivingEntityStructure ms = null; - if (livingentitydata.containsKey(m.getUniqueId())) { + /*if (livingentitydata.containsKey(m.getUniqueId())) { ms = (LivingEntityStructure)livingentitydata.get(m.getUniqueId()); if (ms.hasOriginalName()) { m.setCustomName(ms.getOriginalName()); } - } + }*/ if (ms!=null && (ms.GetTarget() instanceof Player)) { if ((m instanceof Slime) || @@ -7349,10 +7368,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } } - private Chest SpawnALootChest(int i, int j, int k) { - // TODO Auto-generated method stub - return null; - } private void AwardDeathAchievements(Player p, LivingEntity entity) { if (p.hasAchievement(Achievement.BUILD_SWORD) && (entity instanceof Monster) && !p.hasAchievement(Achievement.KILL_ENEMY)) { p.awardAchievement(Achievement.KILL_ENEMY); diff --git a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java index f90a9ea..cf1215d 100644 --- a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java +++ b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java @@ -2,6 +2,7 @@ package sig.plugin.TwosideKeeper; import java.io.File; import java.text.DecimalFormat; +import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.HashMap; @@ -24,6 +25,7 @@ import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Entity; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -49,6 +51,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.ServerType; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.HelperStructures.Effects.LavaPlume; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.EntityUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.InventoryUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemCubeUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.MessageUtils; @@ -81,6 +84,8 @@ final class runServerHeartbeat implements Runnable { //SAVE SERVER SETTINGS. final long serverTickTime = TwosideKeeper.getServerTickTime(); long time = System.nanoTime(); + long totaltime = System.nanoTime(); + if (serverTickTime-TwosideKeeper.LASTSERVERCHECK>=TwosideKeeper.SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT) if (TwosideKeeper.LAST_DEAL!=Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) { //This means the deal of the day has to be updated! @@ -297,6 +302,9 @@ final class runServerHeartbeat implements Runnable { adjustMiningFatigue(p); TwosideKeeper.HeartbeatLogger.AddEntry("Adjust Mining Fatigue", (int)(System.nanoTime()-time));time=System.nanoTime(); + + createPotionParticles(p); + TwosideKeeper.HeartbeatLogger.AddEntry("Potion Effect Particles", (int)(System.nanoTime()-time));time=System.nanoTime(); } //TwosideKeeper.outputArmorDurability(p,">"); } @@ -325,6 +333,48 @@ final class runServerHeartbeat implements Runnable { resetPigmanAggro(); TwosideKeeper.HeartbeatLogger.AddEntry("Reset Pigman Aggro", (int)(System.nanoTime()-time));time=System.nanoTime(); + if ((int)(System.nanoTime()-totaltime)/1000000d>50) { + TwosideKeeper.log("WARNING! Server heartbeat took longer than 1 tick! "+((int)(System.nanoTime()-totaltime)/1000000d)+"ms", 0); + } + TwosideKeeper.HeartbeatLogger.AddEntry(ChatColor.LIGHT_PURPLE+"Total Server Heartbeat", (int)(System.nanoTime()-totaltime));totaltime=System.nanoTime(); + } + + private void createPotionParticles(LivingEntity l) { + if (l instanceof Player) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); + if (pd.lastpotionparticles+100 colors = new ArrayList(); + for (String s : pd.buffs.keySet()) { + Buff b = pd.buffs.get(s); + if (b.getRemainingBuffTime()>0) { + colors.add(b.getBuffParticleColor()); + } + } + if (colors.size()>0) { + for (int i=0;i colors = new ArrayList(); + for (String s : les.buffs.keySet()) { + Buff b = les.buffs.get(s); + if (b.getRemainingBuffTime()>0) { + colors.add(b.getBuffParticleColor()); + } + } + if (colors.size()>0) { + for (int i=0;i