#access public static methods of another plugin

1 messages · Page 1 of 1 (latest)

dusky hemlock
#

is there a way to access public static methods of another plugin but so that it actually uses the same class as the other plugin does? chatgpt said it has seperated classloaders and when shading i have a copy AFAIK

high cloud
#

yes

#

Don't shade

dusky hemlock
#

then its methodnotfoundexception

thorn glen
#

yaml -> libraries
and scope provided

dusky hemlock
#

some of my dependencies for the util plugin arent in MavenCentral

thorn glen
#

that doesnt matter for this afaik

dusky hemlock
#

libraries in plugin.yml only works for mavencentral

#

or did u mean something else

thorn glen
#

ah, depend/softdepend

#

riiiight

high cloud
#

A common way of doing so is having a lib plugin

#

So it's only shaded in to that and not to the other plugins

thorn glen
#

i mean to have scope provided provided, so that when the plugin loaded on the server the classes are present

high cloud
#

Alternatively shade in to one of your plugins but not the other one

dusky hemlock
high cloud
#

How am I supposed to know

#

Maybe 🤷‍♂️

dusky hemlock
#

maybe i should give some context:
i have a TottoriUtils plugin with shaded dependencies and a TottoriLobby plugin that depends on TottoriUtils where i want to access public static methods in TottoriUtils.

high cloud
#

Yes

#

That will work just fine

#

Just don't shade things in to lobby

dusky hemlock
#

i dont but it still doesnt work

high cloud
#

What about it doesn't work

dusky hemlock
#

oh right:
my TottoriUtils class needs to be initialized first, and i do so from the TottoriUtils plugin

dusky hemlock
high cloud
#

What happens

dusky hemlock
#

NoSuchMethodExceprtion

high cloud
#

Are both plugins loaded

dusky hemlock
#

yea

high cloud
#

Is lobby set to depend on Utils

dusky hemlock
#

yea

high cloud
#

in the plugin.yml

#

is that a yes?

dusky hemlock
#

yes

high cloud
#

Are you using maven or gradle

dusky hemlock
#

gradle

high cloud
#

Could you send your build files for the two plugins

dusky hemlock
#

?paste

lucid gullBOT
dusky hemlock
#

maybe i should also note that the method thats not found has a return type which is defined in a dependency of TottoriUtils

#

ill try getting some primitive from utils wait

#

ooh so accessing a primitive works

#

@high cloud do i need to publish some shaded artifact to mavenlocal ?

#

or idk what im doing rn but it seems to be dependency issue

high cloud
#

Try using implementation instead of api

dusky hemlock
#

now i cant access the dependencies in TottoriLobby

#

i kinda need both api and implementation

#

ig i could shade taskchain into my lobby plugin too, but then id have 2 copies

#

well if it works

#

but if i update versions i need to change both

#

and id need to shade it in every consumer of TottoriUtils#

#

its a dilemma

high cloud
#

Yeah that's not quite right