Fix last build, rename scoreboard type enum

This commit is contained in:
libraryaddict 2024-08-21 21:51:10 +12:00
parent e28e1f164a
commit 31fdb53f01
11 changed files with 42 additions and 29 deletions

View File

@ -230,7 +230,7 @@ public class DisguiseConfig {
private static boolean tallSelfDisguises, tallSelfDisguisesScaling;
@Getter
@Setter
private static PlayerNameType playerNameType = PlayerNameType.TEAMS;
private static DisguiseNameType disguiseNameType = DisguiseNameType.TEAMS;
@Getter
@Setter
private static boolean overrideCustomNames;
@ -300,11 +300,11 @@ public class DisguiseConfig {
private static boolean uniquePlayerDisguiseUUIDs;
public static boolean isArmorstandsName() {
return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
return getDisguiseNameType() == DisguiseNameType.ARMORSTANDS;
}
public static boolean isExtendedNames() {
return getPlayerNameType() == PlayerNameType.EXTENDED;
return getDisguiseNameType() == DisguiseNameType.EXTENDED;
}
public static boolean isAutoUpdate() {
@ -532,7 +532,11 @@ public class DisguiseConfig {
}
public static boolean isScoreboardNames() {
return getPlayerNameType() != PlayerNameType.VANILLA;
// TODO Rename this to a more informative name
// For example, what does "scoreboard" mean in this context?
// Is it using scoreboard listener? Is it using scoreboard to store names? Is it using scoreboard for colors?
// Is this for the text limit? Too many questions! Expand out the config, or add these questions to the enum itself!
return getDisguiseNameType() != DisguiseNameType.VANILLA;
}
public static void removeCustomDisguise(String disguise) {
@ -714,7 +718,7 @@ public class DisguiseConfig {
}
try {
setPlayerNameType(PlayerNameType.valueOf(config.getString("PlayerNames").toUpperCase(Locale.ENGLISH)));
setDisguiseNameType(DisguiseNameType.valueOf(config.getString("PlayerNames").toUpperCase(Locale.ENGLISH)));
} catch (Exception ex) {
LibsDisguises.getInstance().getLogger()
.warning("Cannot parse '" + config.getString("PlayerNames") + "' to a valid option for PlayerNames");
@ -1158,15 +1162,23 @@ public class DisguiseConfig {
PacketsManager.setHearDisguisesListener(isSoundsEnabled);
}
public enum PlayerNameType {
public enum DisguiseNameType {
VANILLA,
TEAMS,
EXTENDED,
TEAMS,
ARMORSTANDS;
public boolean isTeams() {
return this == TEAMS || this == EXTENDED;
}
public boolean isDisplayNameCopy() {
return this != VANILLA && this != EXTENDED;
}
public boolean isScoreboardPacketListenerNeeded() {
return this == EXTENDED || this == TEAMS;
}
}
public enum UpdatesBranch {

View File

@ -246,7 +246,7 @@ public abstract class Disguise {
continue;
}
List<PacketWrapper<?>> packets = DisguiseUtilities.getNamePackets(this, oldName);
List<PacketWrapper<?>> packets = DisguiseUtilities.getNamePackets(this, player, oldName);
for (PacketWrapper<?> packet : packets) {
PacketEvents.getAPI().getPlayerManager().sendPacket(player, packet);

View File

@ -515,7 +515,7 @@ public class FlagWatcher {
continue;
}
List<PacketWrapper<?>> packets = DisguiseUtilities.getNamePackets(getDisguise(), new String[0]);
List<PacketWrapper<?>> packets = DisguiseUtilities.getNamePackets(getDisguise(), player, new String[0]);
for (PacketWrapper<?> packet : packets) {
PacketEvents.getAPI().getPlayerManager().sendPacket(player, packet);

View File

@ -292,8 +292,7 @@ public class PlayerDisguise extends TargetedDisguise {
}
}
if (DisguiseConfig.isCopyPlayerTeamInfo() && (DisguiseConfig.getPlayerNameType() == DisguiseConfig.PlayerNameType.TEAMS ||
DisguiseConfig.getPlayerNameType() == DisguiseConfig.PlayerNameType.ARMORSTANDS)) {
if (DisguiseConfig.isCopyPlayerTeamInfo() && DisguiseConfig.getDisguiseNameType().isDisplayNameCopy()) {
name = DisguiseUtilities.getDisplayName(name);
}
@ -309,7 +308,7 @@ public class PlayerDisguise extends TargetedDisguise {
int cLimit;
switch (DisguiseConfig.getPlayerNameType()) {
switch (DisguiseConfig.getDisguiseNameType()) {
case TEAMS:
cLimit = (NmsVersion.v1_13.isSupported() ? 64 : 16) * 2;
break;

View File

@ -2921,7 +2921,8 @@ public class DisguiseUtilities {
}
p.sendMessage(ChatColor.RED +
"[LibsDisguises] Please ask the server owner to restart the server, an update for PacketEvents has been downloaded and is pending a " +
"[LibsDisguises] Please ask the server owner to restart the server, an update for PacketEvents has been downloaded and is
pending a " +
"server restart to install.");*/
return;
}
@ -3440,7 +3441,11 @@ public class DisguiseUtilities {
double heightScale = disguise.getNameHeightScale();
double startingY = loc.getY() + (height * heightScale);
startingY += (DisguiseUtilities.getNameSpacing() * (heightScale - 1)) * 0.35;
boolean useTextDisplay = NmsVersion.v1_19_R3.isSupported();
// TODO If we support text display, there will not be any real features unfortunately
// Text Display is too "jumpy" so it'd require the display to be mounted on another entity, which probably means more packets than before
// With the only upside that we can customize how the text is displayed, such as visible through blocks, background color, etc
// But then there's also the issue of how we expose that
boolean useTextDisplay = false;// LibsDisguises.getInstance().isDebuggingBuild() && NmsVersion.v1_19_R3.isSupported();
for (int i = 0; i < newNames.length; i++) {
if (i < internalOldNames.length) {
@ -3476,10 +3481,12 @@ public class DisguiseUtilities {
} else if (index == MetaIndex.ENTITY_CUSTOM_NAME_OLD) {
val = ChatColor.translateAlternateColorCodes('&', newNames[i]);
} else if (index == MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE) {
val = disguise.isPlayerDisguise() || disguise.getWatcher().isCustomNameVisible();
// Unfortunately text display custom name visible won't work as expected either
// It's either always hidden, or always showing if true
val = true; //disguise.isPlayerDisguise() || disguise.getWatcher().isCustomNameVisible();
}
// Armorstand specific
else if (index == MetaIndex.ENTITY_CUSTOM_NAME && !useTextDisplay) {
else if (index == MetaIndex.ENTITY_CUSTOM_NAME) {
val = Optional.of(getAdventureChat(newNames[i]));
}
// Text Display specific
@ -3488,6 +3495,7 @@ public class DisguiseUtilities {
} else if (index == MetaIndex.DISPLAY_SCALE && !disguise.isMiscDisguise()) {
Double scale = viewer == disguise.getEntity() ? disguise.getSelfDisguiseTallScaleMax() :
((LivingWatcher) disguise.getWatcher()).getScale();
// TODO Expand this out
} else if (index == MetaIndex.DISPLAY_BILLBOARD_RENDER_CONSTRAINTS) {
val = (byte) ReflectionManager.enumOrdinal(Display.Billboard.CENTER);
}

View File

@ -329,6 +329,8 @@ public class LibsPremium {
}
}
bisectHosted = isPremium("", "");
if (!foundBetter) {
File f = LibsDisguises.getInstance().getFile();
@ -345,9 +347,4 @@ public class LibsPremium {
LibsDisguises.getInstance().getLogger().info("Premium enabled, thank you for supporting Lib's Disguises!" + (!prem ? "!" : ""));
}
}
public static String[] ignoredDirectories() {
return new String[]{"META-INF/", "libsdisg/", "me/libraryaddict/disguise/utilities/reflection/v",
"me/libraryaddict/disguise/utilities/reflection/ReflectionManagerAbstract.class", "fernflower_", "net/kyori/adventure/"};
}
}

View File

@ -335,7 +335,7 @@ public class PlayerSkinHandler implements Listener {
}
if (DisguiseConfig.isArmorstandsName() && disguise.isNameVisible() && disguise.getMultiNameLength() > 0) {
List<PacketWrapper<?>> packets = DisguiseUtilities.getNamePackets(disguise, new String[0]);
List<PacketWrapper<?>> packets = DisguiseUtilities.getNamePackets(disguise, player, new String[0]);
for (PacketWrapper p : packets) {
PacketEvents.getAPI().getPlayerManager().sendPacket(player, p);

View File

@ -199,7 +199,7 @@ public class PacketsManager {
PacketEvents.getAPI().getEventManager().registerListener(mainListener);
PacketEvents.getAPI().getEventManager().registerListener(new PacketListenerEntityDestroy());
if (NmsVersion.v1_13.isSupported() && DisguiseConfig.getPlayerNameType() != DisguiseConfig.PlayerNameType.ARMORSTANDS) {
if (NmsVersion.v1_13.isSupported() && DisguiseConfig.getDisguiseNameType().isScoreboardPacketListenerNeeded()) {
PacketEvents.getAPI().getEventManager().registerListener(new PacketListenerScoreboardTeam());
}
}

View File

@ -345,7 +345,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
}
if (!disguise.isPlayerDisguise() || inLineOfSight) {
DisguiseUtilities.getNamePackets(disguise, new String[0]).forEach(packets::addPacket);
DisguiseUtilities.getNamePackets(disguise, observer, new String[0]).forEach(packets::addPacket);
}
// If armor must be sent because its currently not displayed and would've been sent normally

View File

@ -34,7 +34,7 @@ public class PacketListenerMain extends SimplePacketListenerAbstract {
return;
}
final Player observer = (Player) event.getPlayer();
final Player observer = event.getPlayer();
if (observer == null) {
return;
@ -84,7 +84,6 @@ public class PacketListenerMain extends SimplePacketListenerAbstract {
if (packet == wrapper) {
event.markForReEncode(true);
continue;
//packet = DisguiseUtilities.unsafeClone(event, wrapper);
}
PacketEvents.getAPI().getPlayerManager().sendPacketSilently(observer, packet);

View File

@ -204,11 +204,9 @@ public class DisguisePermissions {
permissions.put("libsdisguises.*.*.*", true);
isOperator = true;
} else {
isOperator = sender.isOp();
isOperator = sender == Bukkit.getConsoleSender() || sender.isOp();
}
isOperator = sender == Bukkit.getConsoleSender() || sender.isOp();
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
String perm = permission.getPermission().toLowerCase(Locale.ENGLISH);