Skip to content

Change JavaPlugin to Plugin#26

Merged
TechnicallyCoded merged 2 commits into
TechnicallyCoded:mainfrom
failutee:JavaPluginToPlugin
Oct 15, 2024
Merged

Change JavaPlugin to Plugin#26
TechnicallyCoded merged 2 commits into
TechnicallyCoded:mainfrom
failutee:JavaPluginToPlugin

Conversation

@failutee

Copy link
Copy Markdown
Contributor

Please, I'm begging you 😭

@TechnicallyCoded

Copy link
Copy Markdown
Owner

Please explain your reasoning

@failutee

failutee commented Aug 31, 2024

Copy link
Copy Markdown
Contributor Author

Please explain your reasoning

There is no major reason, simply compatibility with other projects, everyone uses the Plugin interface and today, when I wanted to use your lib, I was surprised when I had to make a slight change and use JavaPlugin instead of Plugin

@jquery-package

Copy link
Copy Markdown

+1,
I find this change quite useful too. When refactoring lots of legacy plugins I had to cast to JavaPlugin without any reason. With this change it will be just simpler to use and give more freedom to the developers. Can't see any reason to keep the only one constructor, we can add another one with Plugin

@jquery-package

Copy link
Copy Markdown

@failutee Would you mind to update this PR to make two constructors? For Plugin and JavaPlugin to maintain compatibility. If not, I'll make a separate PR with those changes

@TechnicallyCoded

Copy link
Copy Markdown
Owner

@failutee Would you mind to update this PR to make two constructors? For Plugin and JavaPlugin to maintain compatibility. If not, I'll make a separate PR with those changes

Unless someone is using reflection to instantiate FoliaLib, Plugin being a supertype of JavaPlugin should allow it to just work with no modifications to constructors. Did I miss something?

@jquery-package

Copy link
Copy Markdown

Unless someone is using reflection to instantiate FoliaLib, Plugin being a supertype of JavaPlugin should allow it to just work with no modifications to constructors. Did I miss something?

Nah, this will change byte code and cause NoSuchMethodError:
java.lang.NoSuchMethodError: 'void xx.folialib.FoliaLib.(org.bukkit.plugin.java.JavaPlugin)'

@TechnicallyCoded

TechnicallyCoded commented Oct 14, 2024

Copy link
Copy Markdown
Owner

You would be recompiling with the library attached. There is no case in which you compiled the plugin with folialib of a different version (idk how that would happen). The relocations that are required avoid this exact issue. Any dev that relocates the lib will not be interacting with anyone else's loaded classes.

@jquery-package

Copy link
Copy Markdown

You would be recompiling with the library attached. There is no case in which you compiled the plugin with folialib of a different version (idk how that would happen). The relocations that are required avoid this exact issue. Any dev that relocates the lib will not be interacting with anyone else's loaded classes.

That's right, but that error is possible if I compile FoliaLib as independent plugin to use it as a library for another plugins, so I don't have to shade it every time

@TechnicallyCoded

Copy link
Copy Markdown
Owner

It's not a plugin nor an API, and has no intention of being so, such behavior will not be supported.

@TechnicallyCoded TechnicallyCoded merged commit 0f76d84 into TechnicallyCoded:main Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants