Class ClassPreloader
java.lang.Object
fr.robie.machineengine.api.paper.ClassPreloader
Loads a plugin's own classes when it starts. The JVM loads classes on first use, from the jar
file; if the jar is replaced while the server runs (a rebuild on a dev server, an update copied
over it), a class first used later fails with
NoClassDefFoundError. The shutdown save is
the worst place for that: machines would not be saved. With every class loaded up front, the
running plugin no longer reads its jar.-
Method Summary
-
Method Details
-
preload
public static int preload(@NotNull @NotNull Class<?> anchor, @NotNull @NotNull String packagePrefix, @NotNull @NotNull String... skipped) Loads (without initializing) every class underpackagePrefixin the jar ofanchor. Classes that cannot load here (e.g. they need an optional plugin that is missing) are skipped.- Parameters:
packagePrefix- e.g.fr/robie/machineengine/skipped- prefixes under it never to load, e.g. the nms modules of other Minecraft versions: Java 25 classes make Paper 1.20.6's class loader throw (its ASM reads every class first), which is not aLinkageError- Returns:
- how many classes were loaded
-