Skip to content

A KJSPKG library that simplifes making packages for both KubeJS 6 and Legacy.

License

Notifications You must be signed in to change notification settings

gcatkjspkgs/kjspkg-compat-layer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

KJSPKG Compatibility Layer

kjspkg-available

Backwards compatibility that Lat can only dream of :heh:

Features

onEvent sync

// KJSPKG compat layer adds a function that acts like the old onEvent
// If used on Legacy, it will just redirect to the regular onEvent function
// If used with KJS6, it will find the correct event function and call that instead
global.kjspkgCompatLayer.legacyOnEvent("player.tick", event => {
    console.log("do stuff!")
})

Forge event sync

// You can do a similar thing with forge events
global.kjspkgCompatLayer.legacyForgeEvent("some.forge.event.class.name", event => {
    console.log("do more stuff!")
})

Reflection sync

// KJSPKG compat layer also adds a simliar redirect function for java reflection functions
// On legacy, it will call the java() function. On KJS6, it will call Java.loadClass()
const someJavaThing = global.kjspkgCompatLayer.legacyJava("super.cool.and.long.class.name")

Getting the version ID

// If you couldn't find a function that suits your needs, you can always just check the version you're running
// To do that, you can get the version id by simply checking the versionId variable
// 6 - 1.16.5, 8 - 1.18.2, 9 - 1.19.2
if (global.kjspkgCompatLayer.versionId<9) console.log("Legacy") 
else console.log("KJS6+") 

About

A KJSPKG library that simplifes making packages for both KubeJS 6 and Legacy.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published