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

Paper Plugins, Bootstrappers, Loaders and More? #8108

Merged
merged 40 commits into from
Feb 19, 2023

Conversation

Owen1212055
Copy link
Member

@Owen1212055 Owen1212055 commented Jul 7, 2022

This implements paper plugins, which can be created by paper-plugin.yml in your plugin resources.
At runtime, they are all in the end the same "JavaPlugins". However, in the future, it is possible that this can be expanded.
Note: You can have both paper plugin and spigot plugin ymls and paper will prioritize the paper yml. The goal is to also have paper and spigot plugins work fine together (because again, they are the same at run time).

This was opened to collect a lot of feedback
Difference between paper plugins:

  • library loading is done at runtime by plugin loaders, not anymore in the config.
  • They have a cool bootstrapper field, allowing code to be executed even before a Minecraft server is created!
  • Cannot be pre-1.19
  • Cannot be loaded on spigot servers (shocker)

Resolves:
#5992
#7961
#7955


Final testing process

Hoping to target this release to allow for future API to move forward. Please test this on your servers to ensure that all spigot plugins work.
Paper plugins will be experimental.


Download the paperclip jar for this pull request: paper-8108.zip

@lokka30
Copy link

lokka30 commented Jul 7, 2022

Although I like the library loading feature, I've heard it's against Maven Central's TOS. I believe Paper should adhere to that in order to avoid potential issues down the line. It's also important to factor in that lots of servers are floating around, hopefully they aren't already putting too much strain on Central. For now, I am quite certain only a small amount of plugins use library-loading, so the damage shouldn't be too bad, I assume.

@electronicboy
Copy link
Member

the library loader is fine, bar the fact that it's pointed directly to central, ideally what we do is just flip it over to our own repo at some point, just some pending stuff in the works, etc

@underscore11code
Copy link
Member

While I'm fully aware of how non-trivial it is, having checks on all the adventure-deprecated methods (Player#sendMessage(String) and such) to see if the caller is a paper plugin or not, and if so, in some way flagging it (cancel it, console warn, shutdown server, something), seems like a good idea to try to help force people off legacy code. Same goes for ChatColor etc.

@Owen1212055
Copy link
Member Author

The /plugins command has received some changes
image
Clicking on a plugin name will now automatically run /version
The version command will be redone in the future as well.

image
image

Descriptions will probably be moved to the doc website.
Changes:

  • Added custom paper plugins command
  • If an initializer fails, the corresponding plugin provider will be skipped.

@lokka30
Copy link

lokka30 commented Jul 8, 2022

Looks awesome Owen!

@kashike kashike self-requested a review July 8, 2022 06:03
Copy link
Contributor

@Lulu13022002 Lulu13022002 left a comment

Choose a reason for hiding this comment

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

A first quick glance, i can't really help you with configurate

patches/api/0387-Paper-Plugins.patch Outdated Show resolved Hide resolved
patches/api/0387-Paper-Plugins.patch Outdated Show resolved Hide resolved
patches/api/0387-Paper-Plugins.patch Outdated Show resolved Hide resolved
patches/api/0387-Paper-Plugins.patch Outdated Show resolved Hide resolved
patches/api/0387-Paper-Plugins.patch Outdated Show resolved Hide resolved
patches/server/0925-Paper-Plugins.patch Outdated Show resolved Hide resolved
patches/server/0925-Paper-Plugins.patch Outdated Show resolved Hide resolved
patches/server/0925-Paper-Plugins.patch Outdated Show resolved Hide resolved
patches/server/0925-Paper-Plugins.patch Outdated Show resolved Hide resolved
@Owen1212055 Owen1212055 changed the title Paper Plugins, Initializers and More? Paper Plugins, Bootstrappers, Loaders and More? Jul 9, 2022
@Owen1212055
Copy link
Member Author

Owen1212055 commented Jul 9, 2022

Plugin Loaders

public class TestPluginLoader implements PluginLoader {
    
    @Override
    public void classloader(PluginClasspathBuilder classpathBuilder) {
        classpathBuilder.addLibrary(new JarLibrary(Path.of("bob.jar")));

        MavenLibraryResolver resolver = new MavenLibraryResolver();
        resolver.addDependency(new Dependency(new DefaultArtifact("com.owen1212055:particlehelper:1.0.0-SNAPSHOT"), null));
        resolver.addRepository(new RemoteRepository.Builder("bytecode", "default", "https://repo.bytecode.space/repository/maven-public/").build());

        resolver.setFilter(new DependencyFilter() {
            @Override
            public boolean accept(DependencyNode node, List<DependencyNode> parents) {
                return true;
            }
        });

        classpathBuilder.addLibrary(resolver);
    }
}

Plugin loaders allow you to configure certain things about your plugin before it is created at all. In this case, a new robust way of adding libraries to your plugin! This allows you to add jars/dependencies before your plugin is created, making it a bit nicer for plugins that may require a lot of complex library logic.

Plugin Initializers have also been renamed to PluginBootstrappers.

  • Should it be bootstrapper or just bootstrap?

@TheFruxz
Copy link
Contributor

TheFruxz commented Jul 9, 2022

image
Is it is possible to disable the advertisement (like Hangar), in the server properties?

@Owen1212055
Copy link
Member Author

image
Is it is possible to disable the advertisement (like Hangar), in the server properties?

It might be moved to the paper docs instead? Does that sound fine? I can make a config option to disable these types of links tho.

@TheFruxz
Copy link
Contributor

TheFruxz commented Jul 9, 2022

image
Is it is possible to disable the advertisement (like Hangar), in the server properties?

It might be moved to the paper docs instead? Does that sound fine? I can make a config option to disable these types of links tho.

That would be great, thank you!

@Owen1212055
Copy link
Member Author

image
Is it is possible to disable the advertisement (like Hangar), in the server properties?

It might be moved to the paper docs instead? Does that sound fine? I can make a config option to disable these types of links tho.

That would be great, thank you!

For clarification, the config or the moving it to the docs? (I’m fine with both)

@TheFruxz
Copy link
Contributor

TheFruxz commented Jul 9, 2022

image
Is it is possible to disable the advertisement (like Hangar), in the server properties?

It might be moved to the paper docs instead? Does that sound fine? I can make a config option to disable these types of links tho.

That would be great, thank you!

For clarification, the config or the moving it to the docs? (I’m fine with both)

For me personally, the text can stand as it is, including the link to Hangar. For many inexperienced players or server owners, this could be a good help. But in my opinion, it should be possible to disable it optionally via the configuration. It doesn't have to move somewhere else, this seems to be a good place for that type of information

@jpenilla
Copy link
Member

jpenilla commented Jul 9, 2022

I don't think linking to our own site like this is "advertising". We can choose to link Hanagar or not, personally I think it's a good idea, but a config option for this seems like totally unnecessary bloat.

@TheFruxz
Copy link
Contributor

TheFruxz commented Jul 9, 2022

I don't think linking to our own site like this is "advertising". We can choose to link Hanagar or not, personally I think it's a good idea, but a config option for this seems like totally unnecessary bloat.

I would definitely say that promoting another product/service (no matter how strongly related to the manufacturer) is advertisement.

@jpenilla
Copy link
Member

In the literal sense sure, hence the quotes in my comment, but using that word to describe this is somewhat disingenuous in my opinion and implies unfair comparisons. You could also argue /ver is advertising our downloads site. Additionally there is the precedent of Bukkit, Spigot, and Paper linking to their various sites such as forums, discord, irc, etc. in their config files.

@electronicboy
Copy link
Member

I think in the config files makes sense, or maybe if there's 0 plugins installed, but, otherwise, chat is a limited space and it just feels like extra pointless fluff which should be on the "getting started" guide

@jpenilla
Copy link
Member

jpenilla commented Jul 10, 2022

It's a hover text, not a chat message, which I would agree would be too much. Again I don't feel super strongly for or against linking Hangar here, just pointing out the "advertising" point is not really relevant to that decision in my mind.

@Owen1212055
Copy link
Member Author

Owen1212055 commented Jul 11, 2022

I've implemented dependency loading, would appreciate if anyone would like to look over that.

There are now two "plugin loaders", legacy and modern. Modern plugin loading (default) does not allow infinite dependency loops, as this caused issues in the past. If infinite dependency loops are detected the servers shuts down.

Optionally, this can be switched by using the LEGACY plugin loader in paper global config (misc.plugin-loading-strategy)

Please feel free to test if plugins correctly load in order.
Also /plugins now split every 10 plugins

@Owen1212055
Copy link
Member Author

The test plugin has been relocated to io.papermc.testplugin inorder to properly block plugins loading in the io.papermc.paper namespace.

This can be reverted, but currently applies for:

  "net.minecraft.",
   "org.bukkit.",
   [NEW] "io.papermc.paper.",
   [NEW] "com.destroystokoyo.paper."

@Owen1212055 Owen1212055 marked this pull request as ready for review July 17, 2022 20:34
@Owen1212055 Owen1212055 requested a review from a team as a code owner July 17, 2022 20:34
@Owen1212055
Copy link
Member Author

I'm going to mark this as ready for review, most of the larger requirements have been resolved.

The api support has been finished, and PluginLoader has been deprecated.

@Andre601
Copy link

Andre601 commented Aug 5, 2022

I like the improved plugin thing, tho it feels a bit much...

Maybe keep it closer to the original but like this?

<white>Server Plugins (3):
<green>PaperPlugin</green><grey>, <gold>LegacyPlugin</gold>, <red>DisabledPlugin</red>

Then have hover text displaying plugin info and what plugin type it is.
Or have the asterisk next to the plugin for more info.

Just an idea tho.

Also regarding the yaml file:
Maybe allow api-version for paper to allow multiple versions, to A) avoid legacy warning on load and B) allow a plugin to load on newer versions without older versions failing.


Example I had imagined:

2022-08-05.17-55-03.mp4

@Amejonah1200
Copy link

@Owen1212055 Congratulations! I hope you will continue to drive this project onward! 🥳

@kangarko
Copy link

kangarko commented Mar 9, 2023

This seems to break the async chat listener priorities, I got multiple reports regarding this such as kangarko/ChatControl-Red#2306

@electronicboy
Copy link
Member

electronicboy commented Mar 9, 2023 via email

rymiel added a commit to rymiel/Paper that referenced this pull request Feb 17, 2024
"Schematic versioning" is not a real thing. The intended versioning
scheme is "semantic versioning". Introduced in PaperMC#8108.
Machine-Maker pushed a commit that referenced this pull request Feb 17, 2024
"Schematic versioning" is not a real thing. The intended versioning
scheme is "semantic versioning". Introduced in #8108.
@Owen1212055 Owen1212055 deleted the plugin-work branch February 22, 2024 01:57
lynxplay pushed a commit to lynxplay/paper that referenced this pull request Feb 23, 2024
"Schematic versioning" is not a real thing. The intended versioning
scheme is "semantic versioning". Introduced in PaperMC#8108.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-pr-jar Enables a workflow to build Paperclip jars on the pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.