Largely improved efficiency of glows on monsters and improved efficiency
of the bar created on the scoreboard.
This commit is contained in:
parent
4b53d3a837
commit
f8a64d792d
@ -2,9 +2,9 @@
|
|||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||||
<classpathentry kind="lib" path="D:/Documents/Test Server/plugins/aPlugin (90).jar"/>
|
|
||||||
<classpathentry kind="lib" path="D:/Documents/Test Server/plugins/AutoPluginUpdate.jar"/>
|
<classpathentry kind="lib" path="D:/Documents/Test Server/plugins/AutoPluginUpdate.jar"/>
|
||||||
<classpathentry kind="lib" path="D:/Documents/Test Server/plugins/GlowAPI_v1.4.4.jar"/>
|
<classpathentry kind="lib" path="D:/Documents/Test Server/plugins/GlowAPI_v1.4.4.jar"/>
|
||||||
<classpathentry kind="lib" path="D:/Documents/Test Server/spigot-1.9.2-R0.1-SNAPSHOT.jar"/>
|
<classpathentry kind="lib" path="D:/Documents/Test Server/spigot-1.9.2-R0.1-SNAPSHOT.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/Documents/Test Server/plugins/aPlugin (91).jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
Binary file not shown.
@ -12,7 +12,8 @@ public class DiscordStatusUpdater implements Runnable{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DiscordMessageSender.setPlaying(ProduceMessage());
|
//DiscordMessageSender.setPlaying(ProduceMessage());
|
||||||
|
aPlugin.API.discordSetPlaying(ProduceMessage());
|
||||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(Bukkit.getPluginManager().getPlugin("TwosideKeeper"), this, 300l);
|
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(Bukkit.getPluginManager().getPlugin("TwosideKeeper"), this, 300l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4314,6 +4314,28 @@ public class GenericFunctions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void logToFile(String message, String filename) {
|
||||||
|
try {
|
||||||
|
if (!TwosideKeeper.filesave.exists()) {
|
||||||
|
TwosideKeeper.filesave.mkdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
File saveTo = new File(TwosideKeeper.filesave, filename);
|
||||||
|
if (!saveTo.exists()) {
|
||||||
|
saveTo.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
FileWriter fw = new FileWriter(saveTo, true);
|
||||||
|
PrintWriter pw = new PrintWriter(fw);
|
||||||
|
|
||||||
|
pw.println(message);
|
||||||
|
pw.flush();
|
||||||
|
pw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isSkullItem(ItemStack item) {
|
public static boolean isSkullItem(ItemStack item) {
|
||||||
if (item!=null &&
|
if (item!=null &&
|
||||||
item.getType()!=Material.AIR && (item.getType()==Material.SKULL_ITEM)) {
|
item.getType()!=Material.AIR && (item.getType()==Material.SKULL_ITEM)) {
|
||||||
|
@ -20,7 +20,7 @@ public class LivingEntityStructure {
|
|||||||
public boolean isElite=false;
|
public boolean isElite=false;
|
||||||
public double original_movespd = 0.0d;
|
public double original_movespd = 0.0d;
|
||||||
public HashMap<UUID,Long> hitlist = new HashMap<UUID,Long>();
|
public HashMap<UUID,Long> hitlist = new HashMap<UUID,Long>();
|
||||||
public HashMap<Player,GlowAPI.Color> glowcolorlist = new HashMap<Player,GlowAPI.Color>();
|
public HashMap<UUID,GlowAPI.Color> glowcolorlist = new HashMap<UUID,GlowAPI.Color>();
|
||||||
//public long lastSpiderBallThrow = 0;
|
//public long lastSpiderBallThrow = 0;
|
||||||
public BossMonster bm = null;
|
public BossMonster bm = null;
|
||||||
public boolean checkedforcubes=false;
|
public boolean checkedforcubes=false;
|
||||||
@ -83,12 +83,12 @@ public class LivingEntityStructure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setGlow(Player p, GlowAPI.Color col) {
|
public void setGlow(Player p, GlowAPI.Color col) {
|
||||||
glowcolorlist.put(p, col);
|
glowcolorlist.put(p.getUniqueId(), col);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGlobalGlow(GlowAPI.Color col) {
|
public void setGlobalGlow(GlowAPI.Color col) {
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
glowcolorlist.put(p, col);
|
glowcolorlist.put(p.getUniqueId(), col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,9 +118,18 @@ public class LivingEntityStructure {
|
|||||||
setGlow(p,GlowAPI.Color.WHITE);
|
setGlow(p,GlowAPI.Color.WHITE);
|
||||||
} else {
|
} else {
|
||||||
//No glow.
|
//No glow.
|
||||||
setGlow(p,null);
|
//setGlow(p,null);
|
||||||
|
if (glowcolorlist.containsKey(p.getUniqueId())) {
|
||||||
|
GlowAPI.setGlowing(m, null, p);
|
||||||
|
glowcolorlist.remove(p.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!GlowAPI.isGlowing(m, p) && glowcolorlist.containsKey(p.getUniqueId())) {
|
||||||
|
GlowAPI.setGlowing(m, glowcolorlist.get(p.getUniqueId()), p);
|
||||||
|
} else
|
||||||
|
if (GlowAPI.isGlowing(m, p) && !glowcolorlist.get(p.getUniqueId()).equals(GlowAPI.getGlowColor(m, p))) {
|
||||||
|
GlowAPI.setGlowing(m, glowcolorlist.get(p.getUniqueId()), p);
|
||||||
}
|
}
|
||||||
GlowAPI.setGlowing(m, glowcolorlist.get(p), p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8802,20 +8802,37 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
pe.getType().equals(PotionEffectType.WITHER) ||
|
pe.getType().equals(PotionEffectType.WITHER) ||
|
||||||
pe.getType().equals(PotionEffectType.UNLUCK)) {
|
pe.getType().equals(PotionEffectType.UNLUCK)) {
|
||||||
hasDebuff=true;
|
hasDebuff=true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String bar = " ";
|
StringBuilder bar = new StringBuilder(Character.toString(' '));
|
||||||
|
|
||||||
boolean isslayer = PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER;
|
boolean isslayer = PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER;
|
||||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||||
double hpval = (isslayer)?pd.slayermodehp:p.getHealth();
|
double hpval = (isslayer)?pd.slayermodehp:p.getHealth();
|
||||||
if (isslayer) {p.setHealth(pd.slayermodehp);}
|
if (isslayer) {p.setHealth(pd.slayermodehp);}
|
||||||
|
|
||||||
if (pcthp==100) {bar += ((isHungry)?ChatColor.BLUE:ChatColor.AQUA)+""+Math.round(hpval)+""+Character.toString((char)0x2665);} else
|
if (pcthp==100) {
|
||||||
if (pcthp>66) {bar += ((isHungry)?ChatColor.DARK_GREEN:ChatColor.GREEN)+""+Math.round(hpval)+""+Character.toString((char)0x2665);}
|
bar.append(((isHungry)?ChatColor.BLUE:ChatColor.AQUA));
|
||||||
else if (pcthp>33) {bar += ((isHungry)?ChatColor.GOLD:ChatColor.YELLOW)+""+Math.round(hpval)+""+Character.toString((char)0x2665);}
|
bar.append(Math.round(hpval));
|
||||||
else {bar += ((isHungry)?ChatColor.DARK_RED:ChatColor.RED)+""+Math.round(hpval)+""+Character.toString((char)0x2665);}
|
bar.append('\u2665');
|
||||||
|
} else
|
||||||
|
if (pcthp>66) {
|
||||||
|
bar.append(((isHungry)?ChatColor.DARK_GREEN:ChatColor.GREEN));
|
||||||
|
bar.append(Math.round(hpval));
|
||||||
|
bar.append('\u2665');
|
||||||
|
}
|
||||||
|
else if (pcthp>33) {
|
||||||
|
bar.append(((isHungry)?ChatColor.GOLD:ChatColor.YELLOW));
|
||||||
|
bar.append(Math.round(hpval));
|
||||||
|
bar.append('\u2665');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bar.append(((isHungry)?ChatColor.DARK_RED:ChatColor.RED));
|
||||||
|
bar.append(Math.round(hpval));
|
||||||
|
bar.append('\u2665');
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (absorptionlv>0) {
|
if (absorptionlv>0) {
|
||||||
@ -8823,11 +8840,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (hasDebuff||isHungry||inNether) {
|
if (hasDebuff||isHungry||inNether) {
|
||||||
bar+=" ";
|
bar.append(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasDebuff) {
|
if (hasDebuff) {
|
||||||
bar+=ChatColor.GRAY+"!";
|
bar.append(ChatColor.GRAY);
|
||||||
|
bar.append('!');
|
||||||
}
|
}
|
||||||
/*if (isHungry) {
|
/*if (isHungry) {
|
||||||
bar+=ChatColor.RED+""+ChatColor.BOLD+"!";
|
bar+=ChatColor.RED+""+ChatColor.BOLD+"!";
|
||||||
@ -8836,18 +8854,21 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
/* 058D:Counter-clockwise portal
|
/* 058D:Counter-clockwise portal
|
||||||
* 058E:Clockwise portal
|
* 058E:Clockwise portal
|
||||||
*/
|
*/
|
||||||
bar+=ChatColor.DARK_PURPLE+""+Character.toString((char)0x25CA);
|
bar.append(ChatColor.DARK_PURPLE);
|
||||||
|
bar.append('\u25ca');
|
||||||
|
//bar+=ChatColor.DARK_PURPLE+""+Character.toString((char)0x25CA);
|
||||||
//bar+=ChatColor.DARK_PURPLE+""+"�";
|
//bar+=ChatColor.DARK_PURPLE+""+"�";
|
||||||
} else
|
} else
|
||||||
if (inEnd) {
|
if (inEnd) {
|
||||||
/* 058D:Counter-clockwise portal
|
/* 058D:Counter-clockwise portal
|
||||||
* 058E:Clockwise portal
|
* 058E:Clockwise portal
|
||||||
*/
|
*/
|
||||||
bar+=ChatColor.DARK_BLUE+""+Character.toString((char)0x25CA);
|
bar.append(ChatColor.DARK_BLUE);
|
||||||
|
bar.append('\u25ca');
|
||||||
//bar+=ChatColor.DARK_PURPLE+""+"�";
|
//bar+=ChatColor.DARK_PURPLE+""+"�";
|
||||||
}
|
}
|
||||||
|
|
||||||
return bar;
|
return bar.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,12 +319,17 @@ final class runServerHeartbeat implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ManagePlayerScoreboardAndHealth(Player p) {
|
private void ManagePlayerScoreboardAndHealth(Player p) {
|
||||||
|
long time=System.nanoTime();
|
||||||
if (!p.isDead()) {TwosideKeeper.log("Player is not dead.",5); TwosideKeeper.setPlayerMaxHealth(p);}
|
if (!p.isDead()) {TwosideKeeper.log("Player is not dead.",5); TwosideKeeper.setPlayerMaxHealth(p);}
|
||||||
|
TwosideKeeper.HeartbeatLogger.AddEntry("==Scoreboard/Health Management - Set Player Max Health", (int)(System.nanoTime()-time));time=System.nanoTime();
|
||||||
if (p.getScoreboard().getTeam(p.getName().toLowerCase())==null) {
|
if (p.getScoreboard().getTeam(p.getName().toLowerCase())==null) {
|
||||||
p.getScoreboard().registerNewTeam(p.getName().toLowerCase()).addPlayer(p);
|
p.getScoreboard().registerNewTeam(p.getName().toLowerCase()).addPlayer(p);
|
||||||
|
TwosideKeeper.HeartbeatLogger.AddEntry("==Scoreboard/Health Management - Register New Team", (int)(System.nanoTime()-time));time=System.nanoTime();
|
||||||
}
|
}
|
||||||
p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(TwosideKeeper.createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p));
|
p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(TwosideKeeper.createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p));
|
||||||
|
TwosideKeeper.HeartbeatLogger.AddEntry("==Scoreboard/Health Management - Set Suffix", (int)(System.nanoTime()-time));time=System.nanoTime();
|
||||||
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p));
|
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p));
|
||||||
|
TwosideKeeper.HeartbeatLogger.AddEntry("==Scoreboard/Health Management - Set Prefix", (int)(System.nanoTime()-time));time=System.nanoTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HealForSleeping(Player p, PlayerStructure pd) {
|
private void HealForSleeping(Player p, PlayerStructure pd) {
|
||||||
@ -589,6 +594,8 @@ final class runServerHeartbeat implements Runnable {
|
|||||||
aPlugin.API.takeTimings(3600);
|
aPlugin.API.takeTimings(3600);
|
||||||
}
|
}
|
||||||
TwosideKeeper.lastTimingReport=TwosideKeeper.getServerTickTime();
|
TwosideKeeper.lastTimingReport=TwosideKeeper.getServerTickTime();
|
||||||
|
GenericFunctions.logToFile("["+TwosideKeeper.getServerTickTime()+"] TPS: "+tps+"\n------------------\n"+TwosideKeeper.HeartbeatLogger.outputReport(),"logs/"+TwosideKeeper.getServerTickTime());
|
||||||
|
aPlugin.API.discordPostFileAttachment(new File(TwosideKeeper.filesave, "logs/"+TwosideKeeper.getServerTickTime()));
|
||||||
}
|
}
|
||||||
if (tps<18) {
|
if (tps<18) {
|
||||||
GenericFunctions.logToFile("["+TwosideKeeper.getServerTickTime()+"] TPS: "+tps+"\n------------------\n"+TwosideKeeper.HeartbeatLogger.outputReport());
|
GenericFunctions.logToFile("["+TwosideKeeper.getServerTickTime()+"] TPS: "+tps+"\n------------------\n"+TwosideKeeper.HeartbeatLogger.outputReport());
|
||||||
@ -607,7 +614,8 @@ final class runServerHeartbeat implements Runnable {
|
|||||||
File config;
|
File config;
|
||||||
config = new File(TwosideKeeper.filesave,"users/"+user+".data");
|
config = new File(TwosideKeeper.filesave,"users/"+user+".data");
|
||||||
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
|
FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
|
||||||
aPlugin.DiscordMessageSender.sendPM("A storm"+((Bukkit.getWorld("world").isThundering())?" (With Thunder)":"")+" is now occuring on the server. (Day "+(int)(TwosideKeeper.getServerTickTime()/48000)+")", workable.getString("weatherwatch_user"));
|
//aPlugin.DiscordMessageSender.sendPM("A storm"+((Bukkit.getWorld("world").isThundering())?" (With Thunder)":"")+" is now occuring on the server. (Day "+(int)(TwosideKeeper.getServerTickTime()/48000)+")", workable.getString("weatherwatch_user"));
|
||||||
|
aPlugin.API.discordSendDM(workable.getString("weatherwatch_user"), "A storm"+((Bukkit.getWorld("world").isThundering())?" (With Thunder)":"")+" is now occuring on the server. (Day "+(int)(TwosideKeeper.getServerTickTime()/48000)+")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -798,10 +806,12 @@ final class runServerHeartbeat implements Runnable {
|
|||||||
private void MaintainMonsterData() {
|
private void MaintainMonsterData() {
|
||||||
Set<UUID> data= TwosideKeeper.livingentitydata.keySet();
|
Set<UUID> data= TwosideKeeper.livingentitydata.keySet();
|
||||||
TwosideKeeper.log("Size: "+TwosideKeeper.livingentitydata.size(), 5);
|
TwosideKeeper.log("Size: "+TwosideKeeper.livingentitydata.size(), 5);
|
||||||
|
long time = System.nanoTime();
|
||||||
for (UUID id : data) {
|
for (UUID id : data) {
|
||||||
LivingEntityStructure ms = TwosideKeeper.livingentitydata.get(id);
|
LivingEntityStructure ms = TwosideKeeper.livingentitydata.get(id);
|
||||||
if (ms.checkedforcubes) {
|
if (ms.checkedforcubes) {
|
||||||
ms.checkedforcubes=false;
|
ms.checkedforcubes=false;
|
||||||
|
TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Magma Cube Clear", (int)(System.nanoTime()-time));time=System.nanoTime();
|
||||||
}
|
}
|
||||||
if (!ms.m.isValid() || ms.m instanceof Player) {
|
if (!ms.m.isValid() || ms.m instanceof Player) {
|
||||||
//TwosideKeeper.monsterdata.remove(data);
|
//TwosideKeeper.monsterdata.remove(data);
|
||||||
@ -809,15 +819,19 @@ final class runServerHeartbeat implements Runnable {
|
|||||||
TwosideKeeper.ScheduleRemoval(data, id);
|
TwosideKeeper.ScheduleRemoval(data, id);
|
||||||
TwosideKeeper.ScheduleRemoval(TwosideKeeper.habitat_data.startinglocs, id);
|
TwosideKeeper.ScheduleRemoval(TwosideKeeper.habitat_data.startinglocs, id);
|
||||||
TwosideKeeper.log("Removed Monster Structure for "+id+".", 5);
|
TwosideKeeper.log("Removed Monster Structure for "+id+".", 5);
|
||||||
|
TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Removed Monster Structure Data.", (int)(System.nanoTime()-time));time=System.nanoTime();
|
||||||
} else {
|
} else {
|
||||||
AddEliteStructureIfOneDoesNotExist(ms);
|
AddEliteStructureIfOneDoesNotExist(ms);
|
||||||
|
TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Add Elite Structure", (int)(System.nanoTime()-time));time=System.nanoTime();
|
||||||
if (ms.GetTarget()!=null && ms.GetTarget().isValid() && !ms.GetTarget().isDead() && ms.m.hasAI()) {
|
if (ms.GetTarget()!=null && ms.GetTarget().isValid() && !ms.GetTarget().isDead() && ms.m.hasAI()) {
|
||||||
//Randomly move this monster a tiny bit in case they are stuck.
|
//Randomly move this monster a tiny bit in case they are stuck.
|
||||||
double xdir=((ms.m.getLocation().getX()>ms.GetTarget().getLocation().getX())?-0.25:0.25)+(Math.random()/8)-(Math.random()/8);
|
double xdir=((ms.m.getLocation().getX()>ms.GetTarget().getLocation().getX())?-0.25:0.25)+(Math.random()/8)-(Math.random()/8);
|
||||||
double zdir=((ms.m.getLocation().getZ()>ms.GetTarget().getLocation().getZ())?-0.25:0.25)+(Math.random()/8)-(Math.random()/8);
|
double zdir=((ms.m.getLocation().getZ()>ms.GetTarget().getLocation().getZ())?-0.25:0.25)+(Math.random()/8)-(Math.random()/8);
|
||||||
ms.m.setVelocity(ms.m.getVelocity().add(new Vector(xdir,0,zdir)));
|
ms.m.setVelocity(ms.m.getVelocity().add(new Vector(xdir,0,zdir)));
|
||||||
|
TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Randomly Move this Monster", (int)(System.nanoTime()-time));time=System.nanoTime();
|
||||||
}
|
}
|
||||||
ms.UpdateGlow();
|
ms.UpdateGlow();
|
||||||
|
TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Update Glow", (int)(System.nanoTime()-time));time=System.nanoTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -904,7 +918,7 @@ final class runServerHeartbeat implements Runnable {
|
|||||||
}
|
}
|
||||||
TwosideKeeper.log_messages.clear();
|
TwosideKeeper.log_messages.clear();
|
||||||
if (finalstring.length()>0) {
|
if (finalstring.length()>0) {
|
||||||
DiscordMessageSender.sendToSpam(finalstring.toString());
|
//DiscordMessageSender.sendToSpam(finalstring.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user