diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index bae7cb4..a57b72b 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java b/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java index f58ad9c..326a24b 100644 --- a/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java +++ b/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java @@ -1,14 +1,72 @@ package sig.plugin.TwosideKeeper; +import org.bukkit.ChatColor; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -public class ActionBarBuffUpdater implements Runnable{ - PotionEffectType type; - int ticks_remaining; +import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; - @Override - public void run() { - +public class ActionBarBuffUpdater{ + + public static String getActionBarPrefix(LivingEntity p) { + StringBuilder actionbardisplay = new StringBuilder(""); + for (PotionEffect pe : p.getActivePotionEffects()) { + if (pe.getAmplifier()>3) { + actionbardisplay.append(ParseEffect(p,pe)); + } + } + if (actionbardisplay.toString().contains(" ")) { + return actionbardisplay.toString().substring(0, actionbardisplay.toString().lastIndexOf(" ")); + } else { + return actionbardisplay.toString(); + } + } + + 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+"⚔"); + } else + if (pet.equals(PotionEffectType.DAMAGE_RESISTANCE)) { + effectString.append(ChatColor.BLUE+"❈"); + } else + if (pet.equals(PotionEffectType.REGENERATION)) { + effectString.append(ChatColor.GREEN+"✙"); + } else + if (pet.equals(PotionEffectType.SPEED)) { + effectString.append(ChatColor.WHITE+"➠"); + } else + if (pet.equals(PotionEffectType.POISON) || + (pet.equals(PotionEffectType.BLINDNESS) && (p instanceof Monster))) { + effectString.append(ChatColor.YELLOW+"☣"); + } else + if ((pet.equals(PotionEffectType.UNLUCK) && p instanceof Monster)) { + effectString.append(ChatColor.DARK_RED+"☠"); + } else + if (pet.equals(PotionEffectType.SLOW)) { + effectString.append(ChatColor.DARK_AQUA+"♒"); + } else + if (pet.equals(PotionEffectType.WEAKNESS) || pet.equals(PotionEffectType.SLOW_DIGGING)) { + effectString.append(ChatColor.RED+"✘"); + } + if (effectString.length()>0) { + effectString.append(AppendAmplifier(pe.getAmplifier())); + effectString.append(" "); + } + if (effectString.length()>0) { + return effectString.toString()+ChatColor.RESET; + } else { + return ""; + } + } + + private static String AppendAmplifier(int amplifier) { + StringBuilder amp = new StringBuilder(" "); + amp.append(ChatColor.GRAY+WorldShop.toRomanNumeral(amplifier+1)); + return amp.toString(); } } diff --git a/src/sig/plugin/TwosideKeeper/CustomDamage.java b/src/sig/plugin/TwosideKeeper/CustomDamage.java index dd29f66..0e94f26 100644 --- a/src/sig/plugin/TwosideKeeper/CustomDamage.java +++ b/src/sig/plugin/TwosideKeeper/CustomDamage.java @@ -322,7 +322,7 @@ public class CustomDamage { GenericFunctions.addStackingPotionEffect(p, PotionEffectType.DAMAGE_RESISTANCE, 20*5, 4); if (p.isBlocking() && ItemSet.hasFullSet(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL)) { pd.vendetta_amt+=((1-CalculateDamageReduction(1,target,damager))*pd.lastrawdamage)*0.3; - aPlugin.API.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+" dmg stored"); + GenericFunctions.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+" dmg stored"); } } if (getDamagerEntity(damager) instanceof Enderman) { @@ -482,6 +482,8 @@ public class CustomDamage { GenericFunctions.RemoveNewDebuffs(p); } },1); + + appendDebuffsToName(target); } if (target instanceof Monster) { if (reason!=null && reason.equalsIgnoreCase("SUFFOCATION")) { @@ -491,6 +493,28 @@ public class CustomDamage { return damage; } + public static void appendDebuffsToName(LivingEntity target) { + if (target instanceof Monster) { + if (target.getCustomName()==null) { + //Setup name. + target.setCustomName(GenericFunctions.CapitalizeFirstLetters(target.getType().name().replace("_", " "))); + } + if (!target.getCustomName().contains(ChatColor.RESET+" ")) { //Append our separator character. + target.setCustomName(target.getCustomName()+ChatColor.RESET+" "); + } + //Now split it using that as our separator. + String[] split = target.getCustomName().split(ChatColor.RESET+" "); + + String suffix = ActionBarBuffUpdater.getActionBarPrefix(target); + + if (suffix.length()>0) { + target.setCustomName(split[0]+ChatColor.RESET+" "+suffix); + } else { + target.setCustomName(split[0]); + } + } + } + private static void reduceSwiftAegisBuff(Player p) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); if (pd.swiftaegisamt>0) { @@ -509,9 +533,9 @@ public class CustomDamage { TwosideKeeper.log(pd.swiftaegisamt+" stacks of Aegis remaining.", 5); } if (p.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE)) { - aPlugin.API.sendActionBarMessage(p, ChatColor.GRAY+"Resistance "+WorldShop.toRomanNumeral(GenericFunctions.getPotionEffectLevel(PotionEffectType.DAMAGE_RESISTANCE, p)+1)); + GenericFunctions.sendActionBarMessage(p, ChatColor.GRAY+"Resistance "+WorldShop.toRomanNumeral(GenericFunctions.getPotionEffectLevel(PotionEffectType.DAMAGE_RESISTANCE, p)+1)); } else { - aPlugin.API.sendActionBarMessage(p, ChatColor.GRAY+"Swift Aegis Resistance Removed."); + GenericFunctions.sendActionBarMessage(p, ChatColor.GRAY+"Swift Aegis Resistance Removed."); } } } @@ -882,7 +906,7 @@ public class CustomDamage { if (p.isBlocking() && ItemSet.hasFullSet(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL)) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); pd.vendetta_amt+=((1-CalculateDamageReduction(1,target,damager))*rawdmg); - aPlugin.API.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+" dmg stored"); + GenericFunctions.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+" dmg stored"); } return true; } diff --git a/src/sig/plugin/TwosideKeeper/EliteMonster.java b/src/sig/plugin/TwosideKeeper/EliteMonster.java index 6933cf6..27f59ba 100644 --- a/src/sig/plugin/TwosideKeeper/EliteMonster.java +++ b/src/sig/plugin/TwosideKeeper/EliteMonster.java @@ -94,7 +94,7 @@ public class EliteMonster { m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(DEFAULT_MOVE_SPD); this.hp_before_burstcheck=m.getHealth(); this.myspawn=m.getLocation(); - bar = m.getServer().createBossBar(m.getCustomName(), BarColor.WHITE, BarStyle.SEGMENTED_6, BarFlag.CREATE_FOG); + bar = m.getServer().createBossBar(GenericFunctions.getDisplayName(m), BarColor.WHITE, BarStyle.SEGMENTED_6, BarFlag.CREATE_FOG); willpower_bar = m.getServer().createBossBar("Willpower", BarColor.PINK, BarStyle.SOLID, BarFlag.CREATE_FOG); } @@ -158,13 +158,13 @@ public class EliteMonster { last_willpower_increase=TwosideKeeper.getServerTickTime(); if (!first_willpower_notification && willpower>20) { for (int i=0;i=100) { for (int i=0;i0) { - Bukkit.getServer().broadcastMessage(m.getCustomName()+" Takedown Failed..."); + Bukkit.getServer().broadcastMessage(GenericFunctions.getDisplayName(m)+" Takedown Failed..."); Bukkit.getServer().broadcastMessage(ChatColor.YELLOW+"DPS Breakdown:"); Bukkit.getServer().broadcastMessage(generateDPSReport()); - aPlugin.API.discordSendRaw(m.getCustomName()+" Takedown Failed...\n\n"+ChatColor.YELLOW+"DPS Breakdown:"+"\n```\n"+generateDPSReport()+"\n```"); + aPlugin.API.discordSendRaw(GenericFunctions.getDisplayName(m)+" Takedown Failed...\n\n"+ChatColor.YELLOW+"DPS Breakdown:"+"\n```\n"+generateDPSReport()+"\n```"); } bar.setColor(BarColor.WHITE); first_willpower_notification=false; @@ -489,7 +489,7 @@ public class EliteMonster { last_storingenergy_time=TwosideKeeper.getServerTickTime(); storingenergy=true; for (int i=0;i0) { storingenergy_hit=(last_storingenergy_health-m.getHealth())*500d; for (int i=0;i0) { + aPlugin.API.sendActionBarMessage(p, message+" "+prefix); + } else { + if (message.length()>0) { + aPlugin.API.sendActionBarMessage(p, message); + } + } + } + + public static String getDisplayName(LivingEntity ent) { + //Strips off the suffix of a mob. + if (ent.getCustomName()==null) { + return GenericFunctions.CapitalizeFirstLetters(ent.getType().name().replace("_", " ")); + } else { + return ent.getCustomName().split(ChatColor.RESET+" ")[0]; + } + } } diff --git a/src/sig/plugin/TwosideKeeper/MonsterStructure.java b/src/sig/plugin/TwosideKeeper/MonsterStructure.java index 348f5f5..63997f8 100644 --- a/src/sig/plugin/TwosideKeeper/MonsterStructure.java +++ b/src/sig/plugin/TwosideKeeper/MonsterStructure.java @@ -95,6 +95,7 @@ public class MonsterStructure { for (EliteMonster em : TwosideKeeper.elitemonsters) { if (em.getMonster().equals(m)) { setGlow(p,em.getGlow()); + handled=true; } } if (!handled) { diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 180fb41..207bce7 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -378,7 +378,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static void ScheduleRemoval(Set list, Object remove) { Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin,new ThreadSafeCollection(list,remove),1); } - public void ScheduleRemoval(HashMap map, Object remove) { + public static void ScheduleRemoval(HashMap map, Object remove) { Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin,new ThreadSafeCollection(map,remove),1); } public static void ScheduleRemoval(Collection list, Object remove) { @@ -866,9 +866,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { stack.append("\n"+stacktrace[i].getClassName()+": **"+stacktrace[i].getFileName()+"** "+stacktrace[i].getMethodName()+"():"+stacktrace[i].getLineNumber()); } DiscordMessageSender.sendToSpam(stack.toString());*/ - /*Monster m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE); - m.setHealth(m.getMaxHealth()/16d);*/ - //aPlugin.API.sendActionBarMessage(p, "Testing/nMultiple Lines.\nLolz"); + Monster m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE); + + //GenericFunctions.sendActionBarMessage(p, "Testing/nMultiple Lines.\nLolz"); //TwosideKeeperAPI.setItemSet(p.getEquipment().getItemInMainHand(), ItemSet.PANROS); //p.getWorld().dropItemNaturally(p.getLocation(), TwosideKeeperAPI.generateMegaPiece(Material.LEATHER_CHESTPLATE, true, true, 5)); //p.getWorld().dropItemNaturally(p.getLocation(), HUNTERS_COMPASS.getItemStack()); @@ -2684,6 +2684,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //Modify the death message. This is a fix for getting rid of the healthbar from the player name. final Player p = ev.getEntity(); if (!DeathManager.deathStructureExists(p)) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + if (pd.target!=null && + pd.target.getCustomName()!=null) { + ev.setDeathMessage(ev.getDeathMessage().replace(pd.target.getCustomName(), GenericFunctions.getDisplayName(pd.target))); + } String[] parsed_msg = ev.getDeathMessage().split(" "); //Get rid of the name. //NOTE: If you change how the suffix looks YOU MUST UPDATE THIS! @@ -2695,7 +2700,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { newDeathMsg+=" "+parsed_msg[i]; } } - PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + if (pd.lasthitdesc!=null) { newDeathMsg = getFancyDeathMessage(p); } @@ -3738,7 +3743,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { m.setTarget(((Monster)ev.getEntity()).getTarget()); MonsterController.MobHeightControl(m,true); if (m.getCustomName()!=null) { - m.setCustomName(m.getCustomName()+" Minion"); + m.setCustomName(GenericFunctions.getDisplayName(m)+" Minion"); } else { m.setCustomName("Zombie Minion"); } @@ -3981,7 +3986,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { GenericFunctions.removeNoDamageTick((LivingEntity)ev.getEntity(), ev.getDamager()); CustomDamage.ApplyDamage(pd.vendetta_amt, ev.getDamager(), (LivingEntity)ev.getEntity(), null, "Vendetta"); pd.vendetta_amt=0.0; - aPlugin.API.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+" dmg stored"); + GenericFunctions.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+" dmg stored"); } else { CustomDamage.ApplyDamage(0, ev.getDamager(), (LivingEntity)ev.getEntity(), weapon, null); if (ev.getDamager() instanceof Projectile) { @@ -4441,8 +4446,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } Bukkit.getServer().broadcastMessage(ChatColor.YELLOW+"DPS Breakdown:"); - Bukkit.getServer().broadcastMessage(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" have successfully slain "+m.getCustomName()+ChatColor.WHITE+"!"); - aPlugin.API.discordSendRaw(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" have successfully slain **"+m.getCustomName()+ChatColor.WHITE+"**!"); + Bukkit.getServer().broadcastMessage(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" have successfully slain "+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"!"); + aPlugin.API.discordSendRaw(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" have successfully slain **"+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"**!"); m.getWorld().spawnEntity(m.getLocation(), EntityType.LIGHTNING); m.getWorld().setStorm(true); m.getWorld().setWeatherDuration(20*60*15); @@ -4703,7 +4708,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { PlayerStructure pd = (PlayerStructure)playerdata.get(ev.getPlayer().getUniqueId()); pd.velocity = new Vector(ev.getFrom().getX(),0,ev.getFrom().getZ()).distanceSquared(new Vector(ev.getTo().getX(),0,ev.getTo().getZ())); if (pd.highwinder && pd.target!=null && !pd.target.isDead()) { - aPlugin.API.sendActionBarMessage(ev.getPlayer(), drawVelocityBar(pd.velocity,pd.highwinderdmg)); + GenericFunctions.sendActionBarMessage(ev.getPlayer(), drawVelocityBar(pd.velocity,pd.highwinderdmg)); } } } @@ -6399,16 +6404,19 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (Bukkit.getPlayer(pd2.name)!=null && pd2.target!=null) { String MonsterName = pd2.target.getType().toString().toLowerCase(); if (pd2.target.getCustomName()!=null) { - MonsterName = pd2.target.getCustomName(); - if (pd2.target.getCustomName()!=null && - !pd2.target.getCustomName().contains("Leader") && + MonsterName = GenericFunctions.getDisplayName(pd2.target); + if (GenericFunctions.getDisplayName(pd2.target)!=null && + !GenericFunctions.getDisplayName(pd2.target).contains("Leader") && MonsterController.isZombieLeader(pd2.target)) { - pd2.target.setCustomName(pd2.target.getCustomName()+" Leader"); - MonsterName = pd2.target.getCustomName(); + pd2.target.setCustomName(GenericFunctions.getDisplayName(pd2.target)+" Leader"); + MonsterName = GenericFunctions.getDisplayName(pd2.target); } } else { MonsterName = GenericFunctions.CapitalizeFirstLetters(MonsterName.replace("_", " ")); } + if (MonsterName.contains(ChatColor.RESET+" ")) { + MonsterName = MonsterName.split(ChatColor.RESET+" ")[0]; + } final String finalMonsterName = MonsterName; String heartdisplay = "", remainingheartdisplay = ""; int color1=0,color2=1; diff --git a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java index 1e726b5..87fcff8 100644 --- a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java +++ b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java @@ -47,7 +47,8 @@ final class runServerHeartbeat implements Runnable { sendAllLoggedMessagesToSpam(); //SAVE SERVER SETTINGS. - if (TwosideKeeper.getServerTickTime()-TwosideKeeper.LASTSERVERCHECK>=TwosideKeeper.SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT) + final long serverTickTime = TwosideKeeper.getServerTickTime(); + if (serverTickTime-TwosideKeeper.LASTSERVERCHECK>=TwosideKeeper.SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT) ServerHeartbeat.saveOurData(); //Advertisement messages could go here. @@ -67,13 +68,13 @@ final class runServerHeartbeat implements Runnable { getServer().broadcastMessage(" "); */ //End Advertisements. - TwosideKeeper.LASTSERVERCHECK=TwosideKeeper.getServerTickTime(); + TwosideKeeper.LASTSERVERCHECK=serverTickTime; } if (Bukkit.getWorld("world").getTime()>=12000) { Collection players = ServerHeartbeat.getServer().getOnlinePlayers(); //Count the number of players sleeping. Compare to "sleepingplayers" count. - TwosideKeeper.log("[DEBUG] Time: "+Bukkit.getWorld("world").getTime()+" Full Time: "+Bukkit.getWorld("world").getFullTime() + " SERVERTICKTIME: "+TwosideKeeper.getServerTickTime(),4); + TwosideKeeper.log("[DEBUG] Time: "+Bukkit.getWorld("world").getTime()+" Full Time: "+Bukkit.getWorld("world").getFullTime() + " SERVERTICKTIME: "+serverTickTime,4); //This functionality only makes sense when two or more players are on. int sleeping=0; for (Player p : players) { @@ -118,8 +119,8 @@ final class runServerHeartbeat implements Runnable { PlayerStructure pd = (PlayerStructure)TwosideKeeper.playerdata.get(p.getUniqueId()); GenericFunctions.RemoveNewDebuffs(p); - if (p.isSprinting() && pd.lastsprintcheck+(20*5)256) { pd.target=null; } - if (pd.lasthittarget+20*15<=TwosideKeeper.getServerTickTime() && pd.storedbowxp>0 && GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) && + if (pd.lasthittarget+20*15<=serverTickTime && pd.storedbowxp>0 && GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) && p.getEquipment().getItemInMainHand().getType()==Material.BOW) { AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), pd.storedbowxp, p); TwosideKeeper.log("Added "+pd.storedbowxp+" Artifact XP", 2); @@ -184,15 +185,15 @@ final class runServerHeartbeat implements Runnable { ItemStack[] equips = p.getEquipment().getArmorContents(); - if (pd.last_regen_time+TwosideKeeper.HEALTH_REGENERATION_RATE<=TwosideKeeper.getServerTickTime()) { - pd.last_regen_time=TwosideKeeper.getServerTickTime(); + if (pd.last_regen_time+TwosideKeeper.HEALTH_REGENERATION_RATE<=serverTickTime) { + pd.last_regen_time=serverTickTime; //See if this player needs to be healed. if (p!=null && !p.isDead() && //Um, don't heal them if they're dead...That's just weird. p.getHealth()=16) { - if (PlayerMode.getPlayerMode(p)!=PlayerMode.SLAYER || pd.lastcombat+(20*60) data= TwosideKeeper.monsterdata.keySet(); + TwosideKeeper.log("Size: "+TwosideKeeper.monsterdata.size(), 2); for (UUID id : data) { MonsterStructure ms = TwosideKeeper.monsterdata.get(id); - if (ms.m==null || !ms.m.isValid()) { - TwosideKeeper.monsterdata.remove(data); - TwosideKeeper.log("Removed Monster Structure for "+id+". New Size: "+TwosideKeeper.monsterdata.size(), 5); + if (!ms.m.isValid()) { + //TwosideKeeper.monsterdata.remove(data); + TwosideKeeper.ScheduleRemoval(TwosideKeeper.monsterdata, ms); + TwosideKeeper.ScheduleRemoval(data, id); + TwosideKeeper.log("Removed Monster Structure for "+id+".", 2); } else { AddEliteStructureIfOneDoesNotExist(ms); ms.UpdateGlow();