From d0b514eff6eaeac5466cc9543ace47556836f69d Mon Sep 17 00:00:00 2001 From: drtshock Date: Sat, 25 Apr 2015 19:15:54 -0500 Subject: [PATCH] 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. --- .../massivecraft/factions/cmd/CmdShow.java | 2 +- .../massivecraft/factions/zcore/MCommand.java | 52 ++++++++++++++----- .../factions/zcore/persist/MemoryFPlayer.java | 3 -- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index 5ba7c650..583d3cf3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -56,7 +56,7 @@ public class CmdShow extends FCommand { double powerBoost = faction.getPowerBoost(); String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString() + powerBoost + ")"); - + List allies = new ArrayList(); List enemies = new ArrayList(); if (!faction.isNone()) { diff --git a/src/main/java/com/massivecraft/factions/zcore/MCommand.java b/src/main/java/com/massivecraft/factions/zcore/MCommand.java index 2d0abbdd..c6900bb0 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MCommand.java +++ b/src/main/java/com/massivecraft/factions/zcore/MCommand.java @@ -296,21 +296,49 @@ public abstract class MCommand { } public String replaceFPlayerTags(String s, FPlayer player) { - 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); - String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance"; - String power = player.getPowerRounded() + "/" + player.getPowerMaxRounded(); - String group = P.p.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(player.getId()))); - return s.replace("{balance}", balance).replace("{lastSeen}", lastSeen).replace("{power}", power).replace("{group}", group); + if (s.contains("{balance}")) { + String balance = Econ.isSetup() ? Econ.getFriendlyBalance(player) : "no balance"; + s = s.replace("{balance}", balance); + } + if (s.contains("{lastSeen}")) { + 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) { - boolean raidable = faction.getLandRounded() > faction.getPower(); - FPlayer fLeader = faction.getFPlayerAdmin(); - String online = String.valueOf(faction.getOnlinePlayers().size()); - String members = String.valueOf(faction.getSize()); - String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length()); - 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("{power}")) { + s = s.replace("{power}", String.valueOf(faction.getPowerRounded())); + } + if (s.contains("{maxPower}")) { + s = s.replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded())); + } + 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; } // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index 9047f3d3..8bddbe81 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -514,9 +514,6 @@ public abstract class MemoryFPlayer implements FPlayer { } 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) { long now = System.currentTimeMillis(); long millisPassed = now - this.lastPowerUpdateTime;