Skip to content
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

feat: introduce Paper's change on TextDisplay #3424

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ public void setText(String text) {
getHandle().setText(CraftChatMessage.fromString(text, true)[0]);
}

// Paper start
@Override
public net.kyori.adventure.text.Component text() {
return com.mohistmc.paper.adventure.PaperAdventure.asAdventure(this.getHandle().getText()); // Mohist - Use Mohist's PaperAdventure
}

@Override
public void text(net.kyori.adventure.text.Component text) {
this.getHandle().setText(text == null ? net.minecraft.network.chat.Component.empty() : com.mohistmc.paper.adventure.PaperAdventure.asVanilla(text)); // Mohist - Use Mohist's PaperAdventure
}
// Paper end

@Override
public int getLineWidth() {
return getHandle().getLineWidth();
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/bukkit/entity/TextDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,37 @@ public interface TextDisplay extends Display {
* Gets the displayed text.
*
* @return the displayed text.
* @deprecated in favour of {@link #text()}
*/
@Nullable
@Deprecated // Paper
String getText();

/**
* Sets the displayed text.
*
* @param text the new text
* @deprecated in favour of {@link #text(net.kyori.adventure.text.Component)}
*/
@Deprecated // Paper
void setText(@Nullable String text);

// Paper start
/**
* Gets the displayed text.
*
* @return the displayed text
*/
net.kyori.adventure.text.@NotNull Component text();

/**
* Sets the displayed text.
*
* @param text the new text
*/
void text(net.kyori.adventure.text.@Nullable Component text);
// Paper end

/**
* Gets the maximum line width before wrapping.
*
Expand Down