Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
RawDiamondMC committed Dec 7, 2024
1 parent 7d026f2 commit 2a4a464
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions base/common/src/main/java/band/kessoku/lib/api/KessokuLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ public final class KessokuLib {
private KessokuLib() {
}

public static void loadModule(@NotNull Class<?> moduleCommonClass) {
public static void loadModule(@NotNull final Class<?> moduleCommonClass) {
if (moduleCommonClass.isArray())
throw new UnsupportedOperationException("What the hell are you doing?? KessokuLib.loadModule receives an array class! " + moduleCommonClass.getName());
if (isModuleLoaded(moduleCommonClass)) {
throw new UnsupportedOperationException("Module `" + moduleCommonClass.getName() + "` has already been loaded!");
}
// Try to get module name
String moduleName;
final String moduleName;
try {
final Field field = moduleCommonClass.getField("NAME");
moduleName = (String) ReflectionUtil.getStaticFieldValue(field);
} catch (NoSuchFieldException e) {
moduleName = moduleCommonClass.getName();
getLogger().warn("Field `NAME` is not found in {}! Using fully qualified class name.", moduleName);
getLogger().error("Invalid Kessoku module! Field `NAME` is not found in {}!", moduleCommonClass.getName());
return;
} catch (NullPointerException e) {
moduleName = moduleCommonClass.getName();
getLogger().warn("NAME in {} is not static! Using package name.", moduleName);
getLogger().error("Invalid Kessoku module! NAME in {} is not static!", moduleCommonClass.getName());
return;
}
initializedModules.add(moduleCommonClass);
getLogger().info("{} loaded!", moduleName);
Expand Down

0 comments on commit 2a4a464

Please sign in to comment.