ClassJS

A KubeJS addon to create Java classes

File Details

ClassJS v0.1-alpha.6

  • A
  • Dec 27, 2025
  • 207.96 KB
  • 2.5K
  • 1.20.1
  • Forge

File Name

classjs-1.20.1-0.1-alpha.6.jar

Supported Versions

  • 1.20.1

Curse Maven Snippet

Forge

implementation fg.deobf("curse.maven:classjs-1365022:7384369")
Curse Maven does not yet support mods that have disabled 3rd party sharing

Learn more about Curse Maven

New Features

  • annotated

    • Use annotated on ClassCreator, MethodCreator, or FieldCreator to add annotations on them.

      let test = ClassCreator.create("AnnotationTest")
      .toPublic()
      .defaultConstructor()
      .annotated("java.lang.Deprecated")
          .build()
      .createField("testField", "int")
          .toPublic().toStatic()
          .annotated("java.lang.Deprecated")
              .withString("since", "1230912-39")
              .build()
          .build()
      .createMethod("test", [], "void")
          .toPublic().toStatic()
          .annotated("java.lang.Deprecated")
              .withBoolean("forRemoval", true)
              .build()
          .annotated("dev.latvian.mods.kubejs.typings.Info")
              .withString("value", "method")
              .withAnnotationArray("params", "dev.latvian.mods.kubejs.typings.Param", [
                  a => a.withString("value", "AAA"),
                  a => a.withString("value", "BBB"),
              ])
              .build()
          .codeJS(() => console.info("TEST METHOD"))
      .defineClass();
      
      console.info(test.__javaObject__.getMethods()[0].getAnnotations());
      // Output in startup.log:
      // [@java.lang.Deprecated(forRemoval=true, since=""), @dev.latvian.mods.kubejs.typings.Info(params={@dev.latvian.mods.kubejs.typings.Param(name="", value="AAA"), @dev.latvian.mods.kubejs.typings.Param(name="", value="BBB")}, value="method")] [java.util.ArrayList]
      
      console.info(test.__javaObject__.getFields()[0].getAnnotations());
      // Output in startup.log:
      // [@java.lang.Deprecated(forRemoval=false, since="1230912-39")] [java.util.ArrayList]
      
  • ClassCreator.createAnnotationMethod

    • Add an anntation method to an @interface class.
    • There is possibly some bug, so currently no example is provided.

Fixed Bug

  • Could not invokeJS when parameter list is empty.