-
-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add several scoreboard type wrappers #2819
Conversation
I have manually tested everything with the hacky code below on 1.8.9, 1.12.2, 1.13, 1.16.5, 1.17, 1.20.2 and 1.20.4. Everything appears to be working correctly. public void testProtocolLib() {
ProtocolManager pm = ProtocolLibrary.getProtocolManager();
if (new MinecraftVersion(1, 20, 2).atOrAbove()) {
getLogger().info("Testing DisplaySlot (1.20.2+)");
pm.createPacket(PacketType.Play.Server.SCOREBOARD_DISPLAY_OBJECTIVE)
.getDisplaySlots()
.write(0, EnumWrappers.DisplaySlot.LIST);
}
// expect parameters to be supported on 1.17+
Preconditions.checkState(WrappedTeamParameters.isSupported() == MinecraftVersion.CAVES_CLIFFS_1.atOrAbove());
if (MinecraftVersion.CAVES_CLIFFS_1.atOrAbove()) {
getLogger().info("Testing WrappedTeamParameters (1.17+)");
WrappedChatComponent c = WrappedChatComponent.fromText("test");
WrappedTeamParameters p = WrappedTeamParameters.newBuilder()
.displayName(c)
.prefix(c)
.suffix(c)
.nametagVisibility("never")
.collisionRule("always")
.color(EnumWrappers.ChatFormatting.OBFUSCATED)
.options(1)
.build();
Preconditions.checkState(p.getDisplayName().getHandle() == c.getHandle());
Preconditions.checkState(p.getPrefix().getHandle() == c.getHandle());
Preconditions.checkState(p.getSuffix().getHandle() == c.getHandle());
Preconditions.checkState(p.getNametagVisibility().equals("never"));
Preconditions.checkState(p.getCollisionRule().equals("always"));
Preconditions.checkState(p.getColor() == EnumWrappers.ChatFormatting.OBFUSCATED);
Preconditions.checkState(p.getOptions() == 1);
}
getLogger().info("Testing ChatFormatting");
Object colorHandle = EnumWrappers.getChatFormattingConverter().getGeneric(EnumWrappers.ChatFormatting.DARK_AQUA);
Preconditions.checkState(EnumWrappers.ChatFormatting.DARK_AQUA == EnumWrappers.getChatFormattingConverter().getSpecific(colorHandle));
Preconditions.checkState(WrappedNumberFormat.isSupported() == MinecraftVersion.v1_20_4.atOrAbove());
getLogger().info("Testing RenderType");
pm.createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE)
.getRenderTypes()
.write(0, EnumWrappers.RenderType.HEARTS);
{
getLogger().info("Testing WrappedComponentStyle");
JsonObject style = (JsonObject) new JsonParser().parse("{\"color\":\"green\",\"bold\":true}");
WrappedComponentStyle wrappedStyle = WrappedComponentStyle.fromJson(style);
Preconditions.checkState(wrappedStyle.getJson().equals(style));
}
getLogger().info("All tests passed!");
} |
Also FYI @dmulloy2 the tests don't currently run because of a version mismatch between spigot-api and spigot. org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT in the https://repo.dmulloy2.net/ repo needs to be updated to the latest version. |
@dmulloy2 pls let me know if you are interested in this PR so I can know if I should update it for 1.20.6 |
@vytskalt this looks great! Would love if you could update it for 1.20.6. Seems like it's failing to compile because those new methods already exist in serialized offline player |
@@ -291,6 +291,18 @@ public void setWhitelisted(boolean whitelisted) { | |||
this.whitelisted = whitelisted; | |||
} | |||
|
|||
@Nullable | |||
@Override | |||
public Location getRespawnLocation() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no longer necessary
Added wrappers for these NMS types (Mojang mapped names):
I also fixed a compile error.
Marked as draft for now as I haven't fully tested it yet.Closes #2617