Fix scoreboards
This commit is contained in:
parent
3f43bf6924
commit
d9238a01c6
@ -15,7 +15,7 @@ import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException
|
|||||||
import me.libraryaddict.disguise.utilities.PacketsManager;
|
import me.libraryaddict.disguise.utilities.PacketsManager;
|
||||||
|
|
||||||
public class DisguiseConfig {
|
public class DisguiseConfig {
|
||||||
public static enum DisguisePushing {
|
public static enum DisguisePushing { // This enum has a really bad name..
|
||||||
MODIFY_SCOREBOARD, IGNORE_SCOREBOARD, CREATE_SCOREBOARD;
|
MODIFY_SCOREBOARD, IGNORE_SCOREBOARD, CREATE_SCOREBOARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class DisguiseUtilities {
|
|||||||
private static HashSet<UUID> selfDisguised = new HashSet<>();
|
private static HashSet<UUID> selfDisguised = new HashSet<>();
|
||||||
private static Thread mainThread;
|
private static Thread mainThread;
|
||||||
private static PacketContainer spawnChunk;
|
private static PacketContainer spawnChunk;
|
||||||
private static HashMap<UUID, String> previousTeam = new HashMap<UUID, String>();
|
private static HashMap<UUID, String> preDisguiseTeam = new HashMap<UUID, String>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
@ -1031,18 +1031,20 @@ public class DisguiseUtilities {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
String prevTeam = previousTeam.remove(player.getUniqueId());
|
String originalTeam = preDisguiseTeam.remove(player.getUniqueId());
|
||||||
|
|
||||||
if (DisguiseConfig.getPushingOption() != DisguisePushing.IGNORE_SCOREBOARD) {
|
if (DisguiseConfig.getPushingOption() != DisguisePushing.IGNORE_SCOREBOARD) {
|
||||||
// Code to stop player pushing in 1.9
|
// Code to stop player pushing
|
||||||
Scoreboard scoreboard = player.getScoreboard();
|
Scoreboard scoreboard = player.getScoreboard();
|
||||||
Team team = prevTeam == null ? null : scoreboard.getTeam(prevTeam);
|
Team team = originalTeam == null ? null : scoreboard.getTeam(originalTeam);
|
||||||
Team ldTeam = scoreboard.getEntryTeam(player.getName());
|
Team ldTeam = scoreboard.getEntryTeam(player.getName());
|
||||||
|
|
||||||
if (ldTeam != null) {
|
if (ldTeam != null) {
|
||||||
if (!ldTeam.getName().equals("LDPushing") && !ldTeam.getName().endsWith("_LDP"))
|
if (!ldTeam.getName().equals("LDPushing") && !ldTeam.getName().endsWith("_LDP")) {
|
||||||
|
// Its not a team assigned by me
|
||||||
ldTeam = null;
|
ldTeam = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (team != null) {
|
if (team != null) {
|
||||||
team.addEntry(player.getName());
|
team.addEntry(player.getName());
|
||||||
@ -1137,47 +1139,59 @@ public class DisguiseUtilities {
|
|||||||
// Code to stop player pushing
|
// Code to stop player pushing
|
||||||
Scoreboard scoreboard = player.getScoreboard();
|
Scoreboard scoreboard = player.getScoreboard();
|
||||||
Team prevTeam = scoreboard.getEntryTeam(player.getName());
|
Team prevTeam = scoreboard.getEntryTeam(player.getName());
|
||||||
|
Team ldTeam = null;
|
||||||
|
|
||||||
if (prevTeam != null && pOption == DisguisePushing.CREATE_SCOREBOARD) {
|
// If the player is in a team already
|
||||||
previousTeam.put(player.getUniqueId(), prevTeam.getName());
|
if (prevTeam != null) {
|
||||||
}
|
// If we're creating a scoreboard
|
||||||
|
|
||||||
Team t;
|
|
||||||
String createName = null;
|
|
||||||
|
|
||||||
if (pOption == DisguisePushing.CREATE_SCOREBOARD) {
|
if (pOption == DisguisePushing.CREATE_SCOREBOARD) {
|
||||||
createName = (prevTeam == null ? "No Team" : prevTeam.getName());
|
// Remember his old team so we can give him it back later
|
||||||
|
preDisguiseTeam.put(player.getUniqueId(), prevTeam.getName());
|
||||||
createName = createName.substring(0, Math.min(12, createName.length()));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
createName = "LDPushing";
|
// We're modifying the scoreboard
|
||||||
|
ldTeam = prevTeam;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((t = scoreboard.getTeam(createName)) == null) {
|
String ldTeamName = null;
|
||||||
t = scoreboard.registerNewTeam(createName);
|
|
||||||
|
// If we are creating a new scoreboard because the current one must not be modified
|
||||||
|
if (pOption == DisguisePushing.CREATE_SCOREBOARD) {
|
||||||
|
// If they have a team, we'll reuse that name. Otherwise go for another name
|
||||||
|
ldTeamName = (prevTeam == null ? "No Team" : prevTeam.getName());
|
||||||
|
|
||||||
|
// Give the teamname a custom name
|
||||||
|
ldTeamName = ldTeamName.substring(0, Math.min(12, ldTeamName.length())) + "_LDP";
|
||||||
|
}
|
||||||
|
else if (ldTeam == null) {
|
||||||
|
ldTeamName = "LDPushing";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.getOption(Option.COLLISION_RULE) != OptionStatus.NEVER) {
|
if (ldTeamName != null && (ldTeam = scoreboard.getTeam(ldTeamName)) == null) {
|
||||||
t.setOption(Option.COLLISION_RULE, OptionStatus.NEVER);
|
ldTeam = scoreboard.registerNewTeam(ldTeamName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.canSeeFriendlyInvisibles()) {
|
if (ldTeam.getOption(Option.COLLISION_RULE) != OptionStatus.NEVER) {
|
||||||
t.setCanSeeFriendlyInvisibles(false);
|
ldTeam.setOption(Option.COLLISION_RULE, OptionStatus.NEVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!t.hasEntry(player.getName()))
|
if (ldTeam.canSeeFriendlyInvisibles()) {
|
||||||
t.addEntry(player.getName());
|
ldTeam.setCanSeeFriendlyInvisibles(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ldTeam.hasEntry(player.getName()))
|
||||||
|
ldTeam.addEntry(player.getName());
|
||||||
|
|
||||||
if (pOption == DisguisePushing.CREATE_SCOREBOARD && prevTeam != null) {
|
if (pOption == DisguisePushing.CREATE_SCOREBOARD && prevTeam != null) {
|
||||||
t.setAllowFriendlyFire(prevTeam.allowFriendlyFire());
|
ldTeam.setAllowFriendlyFire(prevTeam.allowFriendlyFire());
|
||||||
t.setCanSeeFriendlyInvisibles(prevTeam.canSeeFriendlyInvisibles());
|
ldTeam.setCanSeeFriendlyInvisibles(prevTeam.canSeeFriendlyInvisibles());
|
||||||
t.setDisplayName(prevTeam.getDisplayName());
|
ldTeam.setDisplayName(prevTeam.getDisplayName());
|
||||||
t.setPrefix(prevTeam.getPrefix());
|
ldTeam.setPrefix(prevTeam.getPrefix());
|
||||||
t.setSuffix(prevTeam.getSuffix());
|
ldTeam.setSuffix(prevTeam.getSuffix());
|
||||||
|
|
||||||
for (Option option : Team.Option.values()) {
|
for (Option option : Team.Option.values()) {
|
||||||
t.setOption(option, prevTeam.getOption(option));
|
ldTeam.setOption(option, prevTeam.getOption(option));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user