#Load Priority Issue

1 messages · Page 1 of 1 (latest)

stable kelp
#

Hey everyone! I'm having an issue with load priority of my plugins, it depends on NTLibrary and NTLibrary does have an instance static variable that is set on load, but it gives me this error: [05:36:03 INFO]: [NTLibrary] Enabling NTLibrary v1.0.0* [05:36:03 INFO]: [NTLibrary] [ACF] Enabled Asynchronous Tab Completion Support! [05:36:03 INFO]: [ViaBackwards] Enabling ViaBackwards v4.8.1 [05:36:03 INFO]: [Basic] Enabling Basic v1.0.0* [05:36:03 INFO]: [Basic] [ACF] Enabled Asynchronous Tab Completion Support! [05:36:03 ERROR]: Error occurred while enabling Basic v1.0.0 (Is it up to date?) kotlin.UninitializedPropertyAccessException: lateinit property instance has not been initialized at services.neptune.library.bukkit.NTLibraryBukkit$Companion.getInstance(NTLibraryBukkit.kt:17) ~[?:?] at services.neptune.library.bukkit.plugin.NeptuneSpigotPlugin.onEnable(NeptuneSpigotPlugin.kt:22) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-794] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-794] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-794] at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-794] at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-794] at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:599) ~[patched_1.16.5.jar:git-Paper-794] at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-794] at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Paper-794] at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-794] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312] [05:36:03 INFO]: [Basic] Disabling Basic v1.0.0

#

ill send the code

#
package services.neptune.library.bukkit.plugin

import co.aikar.commands.PaperCommandManager
import org.bukkit.plugin.java.JavaPlugin
import services.neptune.commons.global.styling.Style
import services.neptune.library.bukkit.NTLibraryBukkit

abstract class NeptuneSpigotPlugin : JavaPlugin() {
    lateinit var acf: PaperCommandManager
    lateinit var style: Style

    abstract fun load()
    abstract fun enable()
    abstract fun disable()

    override fun onLoad() {
        load()
    }

    override fun onEnable() {
        acf = PaperCommandManager(this)
        style = NTLibraryBukkit.instance.style

        acf.enableUnstableAPI("help")
        style.setCommandManagerFormat(acf)

        enable()
    }

    override fun onDisable() {
        disable()
    }
}
``` NeptuneSpigotPlugin (basic extends this instead of JavaPlugin)
#
package services.neptune.library.bukkit

import co.aikar.commands.PaperCommandManager
import lombok.Getter
import org.bukkit.plugin.java.JavaPlugin
import services.neptune.commons.global.mongo.MongoFactory
import services.neptune.commons.global.styling.Style
import services.neptune.commons.global.styling.StyleFactory
import services.neptune.library.bukkit.command.NtLibCommand
import services.neptune.library.bukkit.config.MainConfig
import services.neptune.library.bukkit.menu.MenuManager
import xyz.mkotb.configapi.ConfigFactory

class NTLibraryBukkit : JavaPlugin() {
    companion object {
        @JvmStatic
        lateinit var instance: NTLibraryBukkit
    }

    private lateinit var manager: PaperCommandManager

    lateinit var mainConfig: MainConfig
    private var configFactory: ConfigFactory = ConfigFactory.newFactory(this)

    @Getter
    lateinit var style: Style

    @Getter
    lateinit var menuManager: MenuManager

    lateinit var mongoFactory: MongoFactory

    override fun onLoad() {
        instance = this
    }

    override fun onEnable() {

        manager = PaperCommandManager(this)
        manager.enableUnstableAPI("help")

        manager.registerCommand(NtLibCommand())

        mainConfig = configFactory.fromFile("config", MainConfig::class.java)
        style = StyleFactory().getStyle(StyleFactory.Styles.valueOf(mainConfig.style))

        style.setCommandManagerFormat(manager)

        if(mainConfig.useMongo) mongoFactory = MongoFactory(mainConfig.databaseUrl)

        menuManager = MenuManager(this)
    }
}
```NTLibrary plugin main class
#

it works fine on spigot 1.8 but not 1.16.5

#

if anyone could help that would be great. ping me if you need any more code snippets

proven dock
#

Init the lateinit props in constructor

stable kelp
#

? wdym

#

like make a constructor in the ntlib plugin main class

#

and initialize the thing there?

#

or just initialize it in the companion class

#

sorry i dont really know terminology like that

proven dock
#

Set values to lateinit vars in the constructor

stable kelp
#
companion object {
        @JvmStatic
        lateinit var instance: NTLibraryBungee
    }
    
    constructor() {
        instance = this
    }
#

like that??

proven dock
#

Make the instance nullable

#

Instead of lateinit

stable kelp
#

kotlin dont work like that

#

@JvmStatic @Nullable
var instance: NTLibraryBungee

#

cant do that

proven dock
#

Bro the ?

stable kelp
#

oh bruh

#

my bad

#

ok but then what

proven dock
#

Remove lateinit

stable kelp
#

Property must be initialized or be abstract

proven dock
#

set to null

stable kelp
#

the weird thing is it worked fine the old way on 1.8

#

but 1.16.5 it stopped working

#

lets see if this works

proven dock
#

Prob not

stable kelp
#

yeah no

#

but

#

whats weird is its saying lateinit property hasnt been initialized still

proven dock
stable kelp
#

even though its not lateinit anymore

stable kelp
#

because thats when they would be initialized if i was doing a normal plugin

#

man this is annoying

#

like why does it just not work on a version of minecraft while it works on another

proven dock
#

Bro

stable kelp
#

especially since this is literally part of kotlin, not the spigot api

proven dock
#

Read the docs

#

Of lateinit

stable kelp
#

but why does it work on 1.8 then

#

when minecraft version is irrelevant to kotlin features

#

??

lethal flume
#

Neptune services skullWazowski

proven dock
#

You may used old versions of kotlin which allowed this

novel gate
stable kelp
#

that makes sense

novel gate
#

A lot has changed in fact since java 8

proven dock
#

Make it nullableuwu

stable kelp
#

on the 1.16.5 plugin

proven dock
#

1.16.5 is java 17

#

Or 16

stable kelp
#

but java 8 works fine and it works cross-version so

novel gate
#

Ah so we found your issue

stable kelp
#

i want this plugin to work on both 1.8 and 1.16

novel gate
#

You can compile with 8 but for 1.16 and above java 17 has to be used for the server

#

Normally not an issue but it can be if reflection is involved

stable kelp
#

hm

#

does java 16 work with spigot 1.8

proven dock
#

Yeah

stable kelp
#

ok i upgraded the server to java 16

#

now to upgrade the actual plugin projecta

#

and hope theres not a billion errors

novel gate
#

Lol dev fun uwu

stable kelp
#

real

#

well the library compiled well

#

now for the plugins themselves

proven dock
#

And why lateinit everywere?

stable kelp
#

because thats how i learned

proven dock
#

You could do the Type?

stable kelp
#

so

#

now im getting a NullPointerException

#

so it didnt fix it

#

all it did is change the way i do the thing that is still randomly broken

graceful cobalt
#

Where do you get it

stable kelp
#

this abstraction of JavaPlugin: ```kt
package services.neptune.library.bukkit.plugin

import co.aikar.commands.PaperCommandManager
import org.bukkit.plugin.java.JavaPlugin
import services.neptune.commons.global.styling.Style
import services.neptune.library.bukkit.NTLibraryBukkit

abstract class NeptuneSpigotPlugin : JavaPlugin() {
lateinit var acf: PaperCommandManager
lateinit var style: Style

abstract fun load()
abstract fun enable()
abstract fun disable()

override fun onLoad() {
    load()
}

override fun onEnable() {
    acf = PaperCommandManager(this)
    style = NTLibraryBukkit.instance!!.style

    acf.enableUnstableAPI("help")
    style.setCommandManagerFormat(acf)

    enable()
}

override fun onDisable() {
    disable()
}

}

#

every plugin that uses that will depend NTLibrary

#

so NTLibraryBukkit's static instance will have loaded by then

graceful cobalt
#

Also, you can just have a val by lazy

stable kelp
#

apparently me using lateinit isnt the issue

#

because i tried something else (nullable) and it does the exact same thing

#

so

graceful cobalt
#

What does it do

stable kelp
#

it just doesnt load

#

before Basic

#

so when Basic tries to load

graceful cobalt
#

What errors etc.

stable kelp
#
[06:22:16 INFO]: [NTLibrary] [ACF] Enabled Asynchronous Tab Completion Support!
[06:22:16 INFO]: [ViaBackwards] Enabling ViaBackwards v4.8.1
[06:22:16 INFO]: [Basic] Enabling Basic v1.0.0*
[06:22:16 INFO]: [Basic] [ACF] Enabled Asynchronous Tab Completion Support!
[06:22:16 ERROR]: Error occurred while enabling Basic v1.0.0 (Is it up to date?)
java.lang.NullPointerException: null
        at services.neptune.library.bukkit.plugin.NeptuneSpigotPlugin.onEnable(NeptuneSpigotPlugin.kt:22) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:599) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-794]
        at java.lang.Thread.run(Thread.java:831) [?:?```
#

which is bullshit because it works on minecraft v1.8

graceful cobalt
#

And what si line 22

novel gate
#

Why is your main class abstract?

stable kelp
#

style = NTLibraryBukkit.instance!!.style

stable kelp
#

i did an abstraction of JavaPlugin that automatically handles stuff like acf initialization and style management

#

also no, java 16 oes not work on minecraft 1.8 for plugins

#

thanks for making me upgrade to something that doesnt work @proven dock

novel gate
#

Why did you abstract javaplugin?

#

Was plugin not good enough?

stable kelp
#

i didnt know the difference

#

would that really affect anything to do with the variable for instance not being initialized

#

now i gotta go downgrade to java 8 again

#

ffs

graceful cobalt
novel gate
stable kelp
#

i suppose

stable kelp
graceful cobalt
#

Oh u don’t want that

stable kelp
#

nope

#

honestly im boutta give up and make the entire network 1.8

graceful cobalt
stable kelp
#
@PluginData(
    name = "Basic",
    version = "1.0.0",
    description = "Plugin handling various basic tasks",
    depends = [PluginDependency(name = "NTLibrary", soft = false)]
)
#

which

#

compiles to

#

hang on

#

lemme decomp

#
depend: [NTLibrary]
name: Basic
description: Plugin handling various basic tasks
main: services.neptune.basic.Basic
version: 1.0.0

#

it does harddepend it

graceful cobalt
#

And in the NTLibraryBungee?

stable kelp
#

bukkit

graceful cobalt
#

U wrote bungee tho

stable kelp
#

name: NTLibrary
main: services.neptune.library.bukkit.NTLibraryBukkit
description: Library plugin for Neptune Services.
version: 1.0.0

stable kelp
stable kelp
#

it is currently ```kt
companion object {
@JvmStatic
var instance: NTLibraryBukkit? = null
}

#

but ill recompile and check just in the off chance i changed it and forgot

#

this is gonna be a major issue if i dont get this fixed

#

because eventually this core will be used on minecraft servers running new versions

#

and having it only support 1.8 will not work

#
[06:39:39 INFO]: [NTLibrary] Enabling NTLibrary v1.0.0*
[06:39:39 INFO]: [NTLibrary] [ACF] Enabled Asynchronous Tab Completion Support!
[06:39:39 INFO]: [ViaBackwards] Enabling ViaBackwards v4.8.1
[06:39:39 INFO]: [Basic] Enabling Basic v1.0.0*
[06:39:39 INFO]: [Basic] [ACF] Enabled Asynchronous Tab Completion Support!
[06:39:39 ERROR]: Error occurred while enabling Basic v1.0.0 (Is it up to date?)
java.lang.NullPointerException: null
        at services.neptune.library.bukkit.plugin.NeptuneSpigotPlugin.onEnable(NeptuneSpigotPlugin.kt:22) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-794]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:599) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Paper-794]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-794]
        at java.lang.Thread.run(Thread.java:831) [?:?]
[06:39:39 INFO]: [Basic] Disabling Basic v1.0.0
``` nope
#

still

graceful cobalt
#

When was it set in the library plugin?

stable kelp
#

on load

#
override fun onLoad() {
        instance = this
    }
#
companion object {
        @JvmStatic
        var instance: NTLibraryBukkit? = null
    }
graceful cobalt
#

And it prints out properly if you debug it there?

stable kelp
#

it works properly on 1.8 spigot

#

both plugins work and load perfectly

graceful cobalt
#

Debug thank you

stable kelp
#

wdym by debug?

graceful cobalt
#

println instance after setting it i guess

stable kelp
#

oh

#

on 1.16: [06:43:42 INFO]: [NTLibrary] Loading NTLibrary v1.0.0 [06:43:42 INFO]: NTLibrary v1.0.0
on 1.8: [NTLibrary] Loading NTLibrary v1.0.0 14.11 01:44:29 [Server] [INFO] NTLibrary v1.0.0

#

which is really weird

#

because it does load

#

before basic

#

it should be initialized

#

but for some weird ass reason

#

its not

graceful cobalt
#

It does not print?

stable kelp
#

assuming thats what the NTLibrary v1.0.0 line is

#

because it prints that a second time but only for ntlib

#

does NOT look like a class print tho

graceful cobalt
#

Perhaps, though i did think it would print the clas guess tostring is doing weird stuff

#

Try running some method on it i guess like instance getdesc

novel gate
#

Does NTLibrary depend on anything?

stable kelp
novel gate
#

Is that library yours?

stable kelp
#

yes

novel gate
#

Seems it uses acf?

graceful cobalt
#

Gl, gotta go see pt. now hf with ur weird code

stable kelp
#

ok update

novel gate
#

Which would mean it does depend on something

stable kelp
#

it does work

#

[06:51:23 INFO]: [NTLibrary] Loading NTLibrary v1.0.0 [06:51:23 INFO]: NTLIB DEBUG: NTLibrary v1.0.0 - Library plugin for Neptune Services

stable kelp
#

ntlib is a plugin in itself

#

while also being a dependency used by other plugins in my suite

novel gate
#

Doesnt mean dependencies cant cause issues

#

Have you tried updating acf?

stable kelp
#

its latest version

novel gate
#

I am thinking it has to be a reflection issue

graceful cobalt
#

What reflection?

novel gate
#

Well acf uses reflection, not sure what their lib does

stable kelp
#

acf works on all versions

#

i know it works on 1.16.5

#

and 1.8

graceful cobalt
#

Try again on 1.8

stable kelp
#

try debugging again?

novel gate
#

But i never seen anyone abstract javaplugin before though

graceful cobalt
#

There isn’t muuch reason to

novel gate
#

Typically you would use pluginbase if you want to abstract

stable kelp
#

should i abstract plugin instead

stable kelp
#

works on 1.8

novel gate
#

Spigot 1.8 right?

stable kelp
#

paper

#

paper 1.16 too

novel gate
#

That may be your issue and also you do know you are in spigot

#

Paper is vastly different now

#

You may be better off getting help in their discord in regards to the changes from 1.8 to latest

stable kelp
#

bruhhhh

#

alright

novel gate
#

Well they know their software is my point

novel gate
#

I know paper but not as well as they do

stable kelp
graceful cobalt
#

They’re reasonable and don’t support legacy versions

stable kelp
#

thats why i didnt want to go to them

graceful cobalt
#

Just implement the class in java. Kotlin / java can sideload

novel gate
stable kelp
#

im considering just giving up

#

which i really dont wanna do because like this core is the future of my development career

novel gate
stable kelp
#

and it being able to work on modern versions as well

novel gate
#

Paper literally has stuff multi threaded that spigot doesnt even touch

stable kelp
#

yeah but the way they load plugins shouldnt be THAT different

#

especially since im not using the paper api

#

im using the spigot api

novel gate
#

It can be, its their stuff and free to change like they did with the multi threading chunks and entities

#

Sure they may implement the spigot api, that doesnt mean how they implement is the exact same. Sometimes implementation detail is important

stable kelp
#

gonna try using spigot instead of paper

#

for server software

#

ok that didnt work

#

still the same issue

#

so its nothhing to do with papermc

#

@novel gate

novel gate
#

Is it the exact same?

stable kelp
#

yes

novel gate
#

Then not sure what changed that would cause that issue at least not without being at my computer to check code

stable kelp
#

so shoudl i just give up for tonight

novel gate
#

Might be wise to give it a break and come back when refreshed lol

#

Before more things break or something else XD

stable kelp
#

yeah

#

this really pisses me off

#

because i need to get this fixed

#

and not even knowing whats causing the error after hours of work on it is not a good sign

novel gate
#

But i am currently at work on my phone. Dont get home for another 6 hours

stable kelp
#

👍

#

im going to sleep ill be back in the morning, ping me if you find anything or if you need more info or anything

novel gate
#

Ok

stable kelp
#

@novel gate Anything?

stable kelp
#

i've fixed the issue

#

it was related to dependency shading