Fix TextAlignment typo, holding off on pushing until paper has pulled upstream. Added untested setTablistName support

This commit is contained in:
libraryaddict 2023-04-13 20:38:52 +12:00
parent 3f2f3c4551
commit 9b83a5a2df
5 changed files with 44 additions and 8 deletions

View File

@ -22,6 +22,7 @@ public class PlayerDisguise extends TargetedDisguise {
private transient LibsProfileLookup currentLookup;
private WrappedGameProfile gameProfile;
private String playerName = "Herobrine";
private String tablistName;
private String skinToUse;
private boolean nameVisible = true;
/**
@ -278,6 +279,32 @@ public class PlayerDisguise extends TargetedDisguise {
return playerName;
}
public String getTablistName() {
if (tablistName == null) {
return getName();
}
return tablistName;
}
public void setTablistName(String tablistName) {
this.tablistName = tablistName;
if (!isDisplayedInTab() || !isDisguiseInUse()) {
return;
}
PacketContainer addTab = ReflectionManager.createTablistPacket(this, PlayerInfoAction.UPDATE_DISPLAY_NAME);
for (Player player : Bukkit.getOnlinePlayers()) {
if (!canSee(player)) {
continue;
}
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
}
}
public void setName(String name) {
if (getName().equals("<Inherit>") && getEntity() != null) {
name = getEntity().getCustomName();
@ -357,7 +384,7 @@ public class PlayerDisguise extends TargetedDisguise {
}
}
if (isDisplayedInTab()) {
if (isDisplayedInTab() && tablistName == null) {
PacketContainer addTab = ReflectionManager.createTablistPacket(this, PlayerInfoAction.UPDATE_DISPLAY_NAME);
for (Player player : Bukkit.getOnlinePlayers()) {

View File

@ -50,6 +50,15 @@ public class PlayerWatcher extends LivingWatcher {
((PlayerDisguise) getDisguise()).setName(name);
}
public String getTablistName() {
return ((PlayerDisguise) getDisguise()).getTablistName();
}
@RandomDefaultValue
public void setTablistName(String tablistName) {
((PlayerDisguise) getDisguise()).setTablistName(tablistName);
}
@Override
public PlayerWatcher clone(Disguise disguise) {
PlayerWatcher watcher = (PlayerWatcher) super.clone(disguise);

View File

@ -86,17 +86,17 @@ public class TextDisplayWatcher extends DisplayWatcher {
this.setFlag(4, defaultBackground);
}
public TextDisplay.TextAligment getAlignment() {
public TextDisplay.TextAlignment getAlignment() {
int flags = getData(MetaIndex.TEXT_DISPLAY_FLAGS);
if ((flags & 8) != 0) {
return TextDisplay.TextAligment.LEFT;
return TextDisplay.TextAlignment.LEFT;
} else {
return (flags & 16) != 0 ? TextDisplay.TextAligment.RIGHT : TextDisplay.TextAligment.CENTER;
return (flags & 16) != 0 ? TextDisplay.TextAlignment.RIGHT : TextDisplay.TextAlignment.CENTER;
}
}
public void setAlignment(TextDisplay.TextAligment alignment) {
public void setAlignment(TextDisplay.TextAlignment alignment) {
switch (alignment.ordinal()) {
case 0:
this.setFlag(8, false);

View File

@ -147,7 +147,7 @@ public class ParamInfoTypes {
new ParamInfoQuaternionf(Quaternionf.class, "Quaternion", "Quaternion (X, Y, Z, W)", "Four values used to define part of a Transformation"));
paramInfos.add(new ParamInfoEnum(ItemDisplay.ItemDisplayTransform.class, "Item Display Transform", "How the Item Display is transformed"));
paramInfos.add(new ParamInfoEnum(Display.Billboard.class, "Display Billboard", "How the billboard is aligned"));
paramInfos.add(new ParamInfoEnum(TextDisplay.TextAligment.class, "Text Display Alignment", "How the text is aligned in the display"));
paramInfos.add(new ParamInfoEnum(TextDisplay.TextAlignment.class, "Text Display Alignment", "How the text is aligned in the display"));
}
paramInfos.add(new ParamInfoEnum(DisguiseConfig.NotifyBar.class, "NotifyBar", "Where the disguised indicator should appear"));

View File

@ -977,13 +977,13 @@ public class ReflectionManager {
return createTablistPacket(disguise, EnumWrappers.PlayerInfoAction.ADD_PLAYER);
}
return nmsReflection.getTabListPacket(disguise.getName(), disguise.getGameProfile(), disguise.isDisplayedInTab(),
return nmsReflection.getTabListPacket(disguise.getTablistName(), disguise.getGameProfile(), disguise.isDisplayedInTab(),
EnumWrappers.PlayerInfoAction.ADD_PLAYER, EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME, EnumWrappers.PlayerInfoAction.UPDATE_LISTED);
}
public static PacketContainer createTablistPacket(PlayerDisguise disguise, EnumWrappers.PlayerInfoAction action) {
if (nmsReflection != null) {
return nmsReflection.getTabListPacket(disguise.getName(), disguise.getGameProfile(), disguise.isDisplayedInTab(), action);
return nmsReflection.getTabListPacket(disguise.getTablistName(), disguise.getGameProfile(), disguise.isDisplayedInTab(), action);
}
try {