Fix some lag with f show. Remove offline permission lookups.
The lookup was locking up my server on almost any f show executions. It's just not worth it.
This commit is contained in:
parent
41d0195c9e
commit
d0b514eff6
@ -296,21 +296,49 @@ public abstract class MCommand<T extends MPlugin> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String replaceFPlayerTags(String s, FPlayer player) {
|
public String replaceFPlayerTags(String s, FPlayer player) {
|
||||||
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - player.getLastLoginTime(), true, true) + " ago";
|
if (s.contains("{balance}")) {
|
||||||
String lastSeen = player.isOnline() ? ChatColor.GREEN + "Online" : (System.currentTimeMillis() - player.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
|
String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance";
|
||||||
String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance";
|
s = s.replace("{balance}", balance);
|
||||||
String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded();
|
}
|
||||||
String group = P.p.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId())));
|
if (s.contains("{lastSeen}")) {
|
||||||
return s.replace("{balance}", balance).replace("{lastSeen}", lastSeen).replace("{power}", power).replace("{group}", group);
|
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - player.getLastLoginTime(), true, true) + " ago";
|
||||||
|
String lastSeen = player.isOnline() ? ChatColor.GREEN + "Online" : (System.currentTimeMillis() - player.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
|
||||||
|
s = s.replace("{lastSeen}", lastSeen);
|
||||||
|
}
|
||||||
|
if (s.contains("{power}")) {
|
||||||
|
String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded();
|
||||||
|
s = s.replace("{power}", power);
|
||||||
|
}
|
||||||
|
if (s.contains("{group}")) {
|
||||||
|
String group = P.p.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId())));
|
||||||
|
s = s.replace("{group}", group);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String replaceFactionTags(String s, Faction faction) {
|
public String replaceFactionTags(String s, Faction faction) {
|
||||||
boolean raidable = faction.getLandRounded() > faction.getPower();
|
if (s.contains("{power}")) {
|
||||||
FPlayer fLeader = faction.getFPlayerAdmin();
|
s = s.replace("{power}", String.valueOf(faction.getPowerRounded()));
|
||||||
String online = String.valueOf(faction.getOnlinePlayers().size());
|
}
|
||||||
String members = String.valueOf(faction.getSize());
|
if (s.contains("{maxPower}")) {
|
||||||
String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length());
|
s = s.replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded()));
|
||||||
return s.replace("{power}", String.valueOf(faction.getPowerRounded())).replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded())).replace("{leader}", leader).replace("{chunks}", String.valueOf(faction.getLandRounded())).replace("{raidable}", String.valueOf(raidable)).replace("{warps}", String.valueOf(faction.getWarps().size())).replace("{online}", online).replace("{members}", members);
|
}
|
||||||
|
if (s.contains("{leader}")) {
|
||||||
|
FPlayer fLeader = faction.getFPlayerAdmin();
|
||||||
|
String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length());
|
||||||
|
s = s.replace("{leader}", leader);
|
||||||
|
}
|
||||||
|
if (s.contains("{chunks}")) {
|
||||||
|
s = s.replace("{chunks}", String.valueOf(faction.getLandRounded()));
|
||||||
|
}
|
||||||
|
if (s.contains("{members}")) {
|
||||||
|
s = s.replace("{members}", String.valueOf(faction.getSize()));
|
||||||
|
|
||||||
|
}
|
||||||
|
if (s.contains("{online}")) {
|
||||||
|
s = s.replace("{online}", String.valueOf(faction.getOnlinePlayers().size()));
|
||||||
|
}
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -514,9 +514,6 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void losePowerFromBeingOffline() {
|
public void losePowerFromBeingOffline() {
|
||||||
if(P.perms != null && P.perms.playerHas((String) null, getName(), "factions.dontlosepoweroffline")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Conf.powerOfflineLossPerDay > 0.0 && this.power > Conf.powerOfflineLossLimit) {
|
if (Conf.powerOfflineLossPerDay > 0.0 && this.power > Conf.powerOfflineLossLimit) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long millisPassed = now - this.lastPowerUpdateTime;
|
long millisPassed = now - this.lastPowerUpdateTime;
|
||||||
|
Loading…
Reference in New Issue
Block a user