Handle team packets async
This commit is contained in:
parent
348ef9e25d
commit
0d558d79be
@ -68,6 +68,7 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -91,14 +92,18 @@ public class DisguiseUtilities {
|
|||||||
return split[1];
|
return split[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefix() {
|
public synchronized String getPrefix() {
|
||||||
return split[0];
|
return split[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSuffix() {
|
public synchronized String getSuffix() {
|
||||||
return split[2];
|
return split[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void setSplit(String[] split) {
|
||||||
|
this.split = split;
|
||||||
|
}
|
||||||
|
|
||||||
public void handleTeam(Scoreboard board, boolean nameVisible) {
|
public void handleTeam(Scoreboard board, boolean nameVisible) {
|
||||||
nameVisible = !DisguiseConfig.isArmorstandsName() && nameVisible;
|
nameVisible = !DisguiseConfig.isArmorstandsName() && nameVisible;
|
||||||
Team team = board.getTeam(getTeamName());
|
Team team = board.getTeam(getTeamName());
|
||||||
@ -181,6 +186,8 @@ public class DisguiseUtilities {
|
|||||||
private final static List<UUID> viewSelf = new ArrayList<>();
|
private final static List<UUID> viewSelf = new ArrayList<>();
|
||||||
private final static List<UUID> viewBar = new ArrayList<>();
|
private final static List<UUID> viewBar = new ArrayList<>();
|
||||||
private static long lastSavedPreferences;
|
private static long lastSavedPreferences;
|
||||||
|
@Getter
|
||||||
|
private final static ConcurrentHashMap<String, DScoreTeam> teams = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only allow saves every 2 minutes
|
* Only allow saves every 2 minutes
|
||||||
@ -1710,6 +1717,8 @@ public class DisguiseUtilities {
|
|||||||
exName.setTeamName(getUniqueTeam());
|
exName.setTeamName(getUniqueTeam());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTeams().put(exName.getTeamName(), exName);
|
||||||
|
|
||||||
for (Scoreboard board : getAllScoreboards()) {
|
for (Scoreboard board : getAllScoreboards()) {
|
||||||
exName.handleTeam(board, disguise.isNameVisible());
|
exName.handleTeam(board, disguise.isNameVisible());
|
||||||
}
|
}
|
||||||
@ -1748,6 +1757,7 @@ public class DisguiseUtilities {
|
|||||||
t.unregister();
|
t.unregister();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTeams().remove(removed.getScoreboardName().getTeamName());
|
||||||
removed.getScoreboardName().setTeamName(null);
|
removed.getScoreboardName().setTeamName(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ public class PacketsManager {
|
|||||||
if (NmsVersion.v1_13.isSupported() &&
|
if (NmsVersion.v1_13.isSupported() &&
|
||||||
DisguiseConfig.getPlayerNameType() != DisguiseConfig.PlayerNameType.ARMORSTANDS) {
|
DisguiseConfig.getPlayerNameType() != DisguiseConfig.PlayerNameType.ARMORSTANDS) {
|
||||||
scoreboardTeamListener = new PacketListenerScoreboardTeam();
|
scoreboardTeamListener = new PacketListenerScoreboardTeam();
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(scoreboardTeamListener);
|
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(scoreboardTeamListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,25 +33,7 @@ public class PacketListenerScoreboardTeam extends PacketAdapter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisguiseUtilities.DScoreTeam team = null;
|
DisguiseUtilities.DScoreTeam team = DisguiseUtilities.getTeams().get(name);
|
||||||
|
|
||||||
loop:
|
|
||||||
for (Set<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
|
|
||||||
for (Disguise disguise : disguises) {
|
|
||||||
if (!disguise.isPlayerDisguise() || !((PlayerDisguise) disguise).hasScoreboardName()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DisguiseUtilities.DScoreTeam t = ((PlayerDisguise) disguise).getScoreboardName();
|
|
||||||
|
|
||||||
if (!name.equals(t.getTeamName())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
team = t;
|
|
||||||
break loop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (team == null) {
|
if (team == null) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user