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

Add support for 1.20.4 fixed formatting #46

Merged
merged 7 commits into from
Feb 24, 2024

Conversation

blubbarbs
Copy link
Contributor

This PR adds support for the 1.20.4 fixed formatting for the scoreboard scores. I tested this on Paper 1.19.4 so backwards compatibility should be working. The only underlying change to the protocol is the FixedFormat NMS objects that get sent from sendModernScorePacket() instead of BlankFormat objects if the score's text has been set.

@MrMicky-FR
Copy link
Owner

Thank you for your pull request but I’m not sure to understand exactly how it would look in game and the advantages of this, if you could provide an ingame screenshot with the explanations about the advantages for this, it would be perfect! Thanks

@blubbarbs
Copy link
Contributor Author

blubbarbs commented Dec 30, 2023

Sure! As you may know, 1.20.3 added support for formatting styles on the scoreboard's scores. FastBoard already uses the blank format on 1.20.3, where the scores are hidden. However, there are other options, namely the styled and fixed formats. The fixed format allows the scores to be displayed as any arbitrary text, and this PR adds support for this in FastBoard. Below is an example:

Here, we see my current code:

    @EventHandler
    public void onLogin(PlayerJoinEvent event) {
        FastBoard fastBoard = new FastBoard(event.getPlayer());

        fastBoard.updateTitle("Test");
        fastBoard.updateLine(0, "Line 1");
    }

and here is how it looks in game. The score is hidden, so we only see the line's text.
image

Now, I will change my code using the new API I added to modify a line's score:

    @EventHandler
    public void onLogin(PlayerJoinEvent event) {
        FastBoard fastBoard = new FastBoard(event.getPlayer());

        fastBoard.updateTitle("Test");
        fastBoard.updateLine(0, "Line 1");
        fastBoard.updateScore(0, ChatColor.BLUE + "Score 1");
    }

and the in game screenshot:
image

As can be seen, where the score would normally be is now filled with custom text.

As for its advantages, the main one I am thinking about is that scores are always right justified. I personally want to use this feature in my own plugin to display my player's scores more neatly compared to just adding the score at the end of the line. For example, this is how it'd be without this feature:

image

and this is with:
image

I think the latter looks much neater and easier to read.

@vicen621
Copy link

Any news on this pr? I found this very usefull and seems ready to be merged

@MrMicky-FR
Copy link
Owner

Hi, sorry for the long delay, I've pushed some changes with the goal of simplify cross-version (between pre and post 1.20.3) handling: the behavior of the scores is always the same, but of course the custom scores are only displayed on 1.20.3+

Reviews & comments are welcome :)

@MrMicky-FR MrMicky-FR added the enhancement New feature or request label Feb 14, 2024
Copy link
Contributor

@syldium syldium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition!

src/main/java/fr/mrmicky/fastboard/FastBoardBase.java Outdated Show resolved Hide resolved
src/main/java/fr/mrmicky/fastboard/FastBoardBase.java Outdated Show resolved Hide resolved
src/main/java/fr/mrmicky/fastboard/FastBoardBase.java Outdated Show resolved Hide resolved
Copy link

@vicen621 vicen621 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, nice additions!

Co-authored-by: syldium <syldium@mailo.com>
@MrMicky-FR
Copy link
Owner

Good catches @syldium , thanks!

@MrMicky-FR MrMicky-FR merged commit cb1a893 into MrMicky-FR:master Feb 24, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants