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

Removed PaperLib #2577

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Removed PaperLib #2577

wants to merge 2 commits into from

Conversation

gochi9
Copy link

@gochi9 gochi9 commented Dec 29, 2024

PaperLib has been removed from further paper versions. It now needs to be removed and replaced with paper's api.

https://github.com/PaperMC/PaperLib
The repo for it has been archived about a week ago. The README file states:
"PaperLib was meant as a temporary means of using more powerful Paper API while allowing full compatibility with Spigot as was necessary for a lot of people. Now, you're better off directly targeting Paper and uploading your plugin to one of the many other resource sites, such as Hangar, modrinth, BuiltByBit, or Polymart."

This has already affected some users on the newest paper versions and have been reported on the discord chat that they can no longer use BentoBox:
https://discord.com/channels/272499714048524288/310623455462686720/1322256049998397461
https://discord.com/channels/272499714048524288/310623455462686720/1322003693817561159
https://discord.com/channels/272499714048524288/310623455462686720/1321950945399017575
https://discord.com/channels/272499714048524288/310623455462686720/1321945727773184060
https://discord.com/channels/272499714048524288/310623455462686720/1321661933010812990

IslandsManagerTest needs to be fixed as well, but I have no idea how and I've not touched it.

@tastybento tastybento self-assigned this Dec 29, 2024
@tastybento tastybento added the Status: Under investigation Investigating the interest and the feasability of the issue. label Dec 29, 2024
@tastybento
Copy link
Member

tastybento commented Dec 29, 2024

Thanks!

Was this a temporary blip for some version of Paper, because it works on the latest versions. 3.1.1 doesn't work, but 3.1.2 snapshot does...

Either way, thanks for the PR. I will study it.

> version
[08:53:02 INFO]: Checking version, please wait...
[08:53:02 INFO]: This server is running Paper version 1.21.4-66-main@d00344a (2024-12-29T14:59:35Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21.4-62-dac977a (MC: 1.21.4)
> bbox v
[08:53:08 INFO]: Running PAPER 1.21.4.
[08:53:08 INFO]: (1.21.4-66-d00344a (MC: 1.21.4))
[08:53:08 INFO]: BentoBox version: 3.1.2-SNAPSHOT-LOCAL
[08:53:08 INFO]: Database: JSON
[08:53:08 INFO]: Loaded Game Worlds:
[08:53:08 INFO]: bskyblock_world (BSkyBlock): Overworld, Nether, The End
[08:53:08 INFO]: poseidon_world (Poseidon): Overworld, The End
[08:53:08 INFO]: Loaded Addons:
[08:53:08 INFO]: BSkyBlock 1.19.0 (ENABLED)
[08:53:08 INFO]: Challenges 1.4.0 (ENABLED)
[08:53:08 INFO]: FarmersDance 1.2.0 (ENABLED)
[08:53:08 INFO]: Greenhouses 1.9.0 (ENABLED)
[08:53:08 INFO]: InvSwitcher 1.15.0 (ENABLED)
[08:53:08 INFO]: Level 2.17.0 (ENABLED)
[08:53:08 INFO]: Poseidon 0.1.0-SNAPSHOT-LOCAL (ENABLED)
[08:53:08 INFO]: Warps 1.16.0 (ENABLED)
> 
> version
[08:55:04 INFO]: Checking version, please wait...
[08:55:04 INFO]: This server is running Paper version 1.21.3-82-ver/1.21.3@5a60ffb (2024-12-23T19:10:30Z) (Implementing API version 1.21.3-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21.4-66-d00344a (MC: 1.21.4)
> bbox v
[08:55:08 INFO]: Running PAPER 1.21.3.
[08:55:08 INFO]: (1.21.3-82-5a60ffb (MC: 1.21.3))
[08:55:08 INFO]: BentoBox version: 3.1.2-SNAPSHOT-LOCAL
[08:55:08 INFO]: Database: JSON
[08:55:08 INFO]: Loaded Game Worlds:
[08:55:08 INFO]: bskyblock_world (BSkyBlock): Overworld, Nether, The End
[08:55:08 INFO]: poseidon_world (Poseidon): Overworld, The End
[08:55:08 INFO]: Loaded Addons:
[08:55:08 INFO]: BSkyBlock 1.19.0 (ENABLED)
[08:55:08 INFO]: Challenges 1.4.0 (ENABLED)
[08:55:08 INFO]: FarmersDance 1.2.0 (ENABLED)
[08:55:08 INFO]: Greenhouses 1.9.0 (ENABLED)
[08:55:08 INFO]: InvSwitcher 1.15.0 (ENABLED)
[08:55:08 INFO]: Level 2.17.0 (ENABLED)
[08:55:08 INFO]: Poseidon 0.1.0-SNAPSHOT-LOCAL (ENABLED)
[08:55:08 INFO]: Warps 1.16.0 (ENABLED)

@gochi9
Copy link
Author

gochi9 commented Dec 29, 2024

I'm unsure why it works for you, but in any case the library is going to be discontinued as mentioned in their github repo so it'll be best to remove anything related to PaperLib asap.

Almost everything I changed is provided by Paper's API. To check if the server is using paper I simply check if a class from Paper's API like the ParticleBuilder is present, and it's also a class that's likely to stay.
The only thing that doesn't use the Paper API is the stuff I left for you at the bottom of the Util class to retrieve the version info, I'm unsure if the code will work as I just copied what PaperLib did. I left some space at the bottom so you can easily spot it.

There's also a method I commented out (In Util class) because I have no idea how I could recreate it. There's nothing in Paper's API for it and the object that it returns also doesn't exist. You might need to look how PaperLib does it and copy that, but from what I can see nothing used it so it might be easier to just remove it.

tastybento added a commit that referenced this pull request Dec 29, 2024
TODO: Get test working in Paper-land.

Relates to ##2577
@tastybento
Copy link
Member

Hey, tanks for this. What I've done is incorporated most of your changes into #2580 and merged that in. The main point of that PR is to keep Spigot compatibility, for now. However, I do anticipate moving to only using Paper, so that is when merging this in will make sense. I will credit you in the 3.2.0 release, for sure.

So, just to sum up what I did:

  1. Abstracted all the PaperLib stuff into Util. There were some direct PaperLib calls in the code.
  2. Use some reflection to determine if the server is Spigot or Paper and act accordingly
  3. Switch the Java 21 (over due)
  4. Tried to get the tests to work. This involved reworking a number of test classes. The issues go far beyond just the IslandManagerTest class, and touch on a myriad of areas. Huge work to get it all working again, I'm afraid. For now, just have to do in-game testing to verify stuff works.

The TODO plan is:

  1. Get tests working
  2. Rip out Spigot-specific code and go full Paper
  3. Change to be a Paper only plugin
  4. Say goodbye to spigotmc.org and list on Hanger
  5. Other stuff, I'm sure

@tastybento tastybento added Status: In progress Working on the issue. and removed Status: Under investigation Investigating the interest and the feasability of the issue. labels Dec 29, 2024
@gochi9
Copy link
Author

gochi9 commented Dec 30, 2024

Is there a reason you're using reflection instead of calling isPaper(), since you're using the latest version, you're pretty much guaranteed to have those methods if isPaper(). Or you could just straight up call entity.teleportAsync in a try catch with a NoSuchMethodException, basically what you're already doing but without reflection.
I generally tend to avoid reflection where possibly cause it can get annoying at times.

Anyway, I can help you with the tests. Should I close my current fork since it's no longer needed and create a new one for tests?

@tastybento
Copy link
Member

Thank you for your support!

Is there a reason you're using reflection instead of calling isPaper(), since you're using the latest version, you're pretty much guaranteed to have those methods if isPaper(). Or you could just straight up call entity.teleportAsync in a try catch with a NoSuchMethodException, basically what you're already doing but without reflection. I generally tend to avoid reflection where possibly cause it can get annoying at times.

I agree with you on reflection, but in this case it is required to keep compatibility with Spigot servers (for now) because a try-catch block does not work (I tried it) because a NoSuchMethodError occurs at class loading time, not at runtime execution of the code. However the backwards compatibility can all be removed in the next release (3.3.0) so it is just temporary. From 3.3.0 we switch to Paper support only.

Anyway, I can help you with the tests. Should I close my current fork since it's no longer needed and create a new one for tests?

Yes, you can close this one and open newer ones. I have started on enabling the tests to work with the paper-api. Generally, there are a lot of updates required so I have marked classes that have errors or failures with @ignore and then some reference to PaperAPI. So far, this is what I have done:

  1. Updated the ServerMocks class to add support for Paper's server. This required adding support for the versioning they do and the Registries that they have
  2. Adding the ServerBuildInfo.class to the @PrepareForTest for almost every class.
  3. Adding the ignores

The outstanding items are:

  1. There are some test failures - I suspect they are all driven by one or two common issues.
  2. There is a challenge around Material and the ItemType class. There is a common error where the get() in Material class returns a null and so the check they have to determine if the Material used in itemStack(Material) is an item fails. Some clever mocking is required here, I expect.
  3. Some classes now need the Server to be set using the ServerMock class that didn't before due to the Registry not being available (due to Paper's expansion)

I realize this is quite advanced test development, and I'll be plugging at it over this week. If you want to have a go at solving some of these issues (just comment out an @ignore and compile to get started) then I would be grateful. I should also probably look at the Paper test code and see how they do it. Or you can!

All the best!

@gochi9
Copy link
Author

gochi9 commented Dec 31, 2024

Alright, I'll see what I can do about the tests after New Years.
Happy holidays!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In progress Working on the issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants