Don't repeatedly update FTeamWrapper for the same faction
This commit is contained in:
parent
81182dccaa
commit
00045b0186
@ -14,6 +14,7 @@ public class FTeamWrapper {
|
|||||||
private static final Map<Faction, FTeamWrapper> wrappers = new HashMap<Faction, FTeamWrapper>();
|
private static final Map<Faction, FTeamWrapper> wrappers = new HashMap<Faction, FTeamWrapper>();
|
||||||
private static final List<FScoreboard> tracking = new ArrayList<FScoreboard>();
|
private static final List<FScoreboard> tracking = new ArrayList<FScoreboard>();
|
||||||
private static int factionTeamPtr;
|
private static int factionTeamPtr;
|
||||||
|
private static final Set<Faction> updating = new HashSet<Faction>();
|
||||||
|
|
||||||
private final Map<FScoreboard, Team> teams = new HashMap<FScoreboard, Team>();
|
private final Map<FScoreboard, Team> teams = new HashMap<FScoreboard, Team>();
|
||||||
private final String teamName;
|
private final String teamName;
|
||||||
@ -25,19 +26,27 @@ public class FTeamWrapper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updating.add(faction)) {
|
||||||
Bukkit.getScheduler().runTask(P.p, new Runnable() {
|
Bukkit.getScheduler().runTask(P.p, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
updating.remove(faction);
|
||||||
applyUpdates(faction);
|
applyUpdates(faction);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void applyUpdates(Faction faction) {
|
public static void applyUpdates(Faction faction) {
|
||||||
if (!FScoreboard.isSupportedByServer()) {
|
if (!FScoreboard.isSupportedByServer()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updating.contains(faction)) {
|
||||||
|
// Faction will be updated soon.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FTeamWrapper wrapper = wrappers.get(faction);
|
FTeamWrapper wrapper = wrappers.get(faction);
|
||||||
Set<FPlayer> factionMembers = faction.getFPlayers();
|
Set<FPlayer> factionMembers = faction.getFPlayers();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user