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

Sign update #5797

Open
wants to merge 24 commits into
base: dev/feature
Choose a base branch
from
Open

Sign update #5797

wants to merge 24 commits into from

Conversation

TheLimeGlass
Copy link
Collaborator

@TheLimeGlass TheLimeGlass commented Jul 7, 2023

Description

  • Updated ExprSignText to modern standards.
  • Added Skript's ChatFormat support with Adventure API.
  • Added support for multiple signs.
  • Did all the versioning for 1.20 where there can now be two sides to a sign.
  • Added changers as Njol's comment from 9 years stated to do.

Notes:

  • This class is a large review due to versioning, adventure api AND 1.20 changes. o7
  • BlockState#update(boolean, boolean) is 1.13+ so no need for try/catch anymore, also made the force boolean true because the user is modifying the value.
  • I have an aliases update for 1.20 covering many sign features Aliases for 1.20 skript-aliases#88

Target Minecraft Versions: any
Requirements: Paper is optional
Related Issues: #4576 #5778

@TheLimeGlass TheLimeGlass added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Jul 7, 2023
@TheLimeGlass TheLimeGlass marked this pull request as draft July 7, 2023 19:23
@TheLimeGlass TheLimeGlass marked this pull request as ready for review July 7, 2023 19:35
@TheLimeGlass TheLimeGlass changed the base branch from master to dev/feature October 14, 2023 11:16
@TheLimeGlass
Copy link
Collaborator Author

TheLimeGlass commented Feb 14, 2024

Changed to a functional interface to support:

Sign::getLines
Sign::getLine
Sign::setLine
Sign::line
SignChangeEvent::getLines
SignChangeEvent::getLine
SignChangeEvent::setLine
SignChangeEvent::line
SignSide::getLines
SignSide::getLine
SignSide::setLine
SignSide::line

Tests failing is not related to this pull request. Fix at #6433


void setLine(int line, @NotNull String value);

static void setLine(SetSignLine<Integer, String> setLineMethod, int line, String value) {
Copy link
Member

Choose a reason for hiding this comment

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

What is the point of these static methods? Why not just call setLineMethod.setLine(line, value) directly? Rather than all of these interfaces, I think it would be better just to have a Spigot and Adventure implementations of an interface with set/get methods. The Adventure implementation can handle the string->component conversions.

Copy link
Collaborator Author

@TheLimeGlass TheLimeGlass Aug 31, 2024

Choose a reason for hiding this comment

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

It's required to be static, because that's how FunctionalInterface works. One method must be static.

Adventure doesn't exist on Spigot, so you can't rely on Adventure to handle the string to component conversions as the method doesn't exist.

It's a functional interface because AdventureSetSignLine has to be a separate class due to the classes not existing and needing to be statically initialized.

Copy link
Member

Choose a reason for hiding this comment

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

There should be no problem to call the interface methods directly? There's no requirement for there be a static method.

If the Adventure implementation is used only on Paper, I don't see why it would be an issue to handle the component parsing in the interface implantation rather than the syntax's change method. I think the implementation right now is somewhat over complicated for what we need

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't agree with it being more complex. It's making it simpler to read. You have to deal with all the provided methods I posted #5797 (comment)

Copy link
Member

@APickledWalrus APickledWalrus Sep 1, 2024

Choose a reason for hiding this comment

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

I think it's unnecessary for the Adventure interface to be something we're specifically checking for in change. There should just be an implementation for Adventure of SetSignLine that handles the component conversion (that way adventure doesn't need passed/handled as it's own parameter). Additionally, I'm still not seeing why these static methods are necessary. If you have the interface object, why can't you just call the method it has directly?

src/main/java/ch/njol/skript/expressions/ExprSignText.java Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants