[SPIGOT-5345] Generic Java library support for plugins Created: 25/Sep/19  Updated: 14/May/21  Resolved: 14/May/21

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: Perzan Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: 1.14, Spigot, bukkit
Environment:

Windows 10

Processor: Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz 3.00 GHz

Installed memory: 8.00 GB (7.80 GB usable)

System Type: 64-bit Operating System, x64-based processor


Issue Links:
Relates
relates to SPIGOT-5352 Create public addURL method to Plugin... Open
Version: git-Spigot-94af569-a3fdef8 (MC: 1.14.4) (Implementing API version 1.14.4-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

Although this isn't necessarily an issue, and the same goal can easily be achieved with various other methods, my suggestion is to have a "libraries" folder where jar libraries can be placed in order for other plugins to use.

A few non-limiting possibilities regarding the programmatic name of the library:

  1. The file name can be the name of the library
  2. The library jar will need a resource called "name.txt"

 

Library names can be listed in the "depend" or "softdepend" part of the plugin.yml of other plugins.

During runtime, a plugin can also maybe do something like this:

//
PluginManager plugman = myPlugin.getServer().getPluginManager();
if (plugman.isLibraryEnabled("MyLibrary")) {...}

or whatever is best.

 

Libraries won't necessarily need to be 'enabled', just their URLs loaded into the necessary classloaders.

 

Again, this obviously isn't an absolute necessity. It's also (most likely) not even a good idea because I'm sure there is some complicated unforeseen mechanic of spigot waiting to annihilate me with fax and logic 

 

PS: I also tried using --rev latest and the server still says I'm 4 versions behind so sorry if that is not the latest one

PS (AGAIN): Never-mind, I forgot to drag in the compiled jar into my server's directory like a dolt



 Comments   
Comment by md_5 [ 14/May/21 ]

New libraries section in plugin.yml allows loading maven libraries from central

Comment by Duy Anh [ 27/Sep/19 ]

Multi-version will cause conflicts. I guess Spigot needs to relocate them (with asm, for e.g).

Comment by Black Hole [ 26/Sep/19 ]

How about versioning of class libraries? So a plugin could specify a version range like in maven.

Comment by Perzan [ 26/Sep/19 ]

Yep, that's why it was just an option because I knew there were various other ways to do it. require_packages is a good idea. However, we can probably make it more detailed. require_packages can be a map where the key is the name of the package and the value is a boolean that represents whether or not to load sub-packages recursively.

Comment by Duy Anh [ 26/Sep/19 ]

eh, instead of "Library names can be listed in the "depend" or "softdepend" part of the plugin.yml of other plugins", it is better to have:

require_packages:
- com.author.lib
require_classes:
- com.author.lib.TestClass

Spigot only needs to check if they are present in the class loader. These classes/packages can be plugin's or library's

A folder for libraries is awesome. But don't force the library to have a resource file in the jar.  It is too complicated. 

Generated at Tue Apr 08 01:20:54 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.