Discord Bot Rewrite, Upgrades & Plugin Migration
- Replace deprecated Core Javacord implementation with a modern JDA 5.x Kotlin plugin
- Introduce event-driven architecture via ServerConfigEvent, ServerStartupEvent, ServerShutdownEvent, and CommandEvent
- Implemented global event posting functionality in Player class.
- Refactored PluginService to handle potential ClassNotFoundException more gracefully.
- Improved CustomPrintStream to better identify the caller context in log messages.
- Refactor server configuration into modular groups ("core" and "discord") with backward compatibility for legacy flat keys
This commit is contained in:
1 parent
87fece4854
commit
fbc3595da1
49 files changed
+1151
-665
No files matched your search
@@ -40,7 +40,7 @@ public final class PluginService {
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, "A problem was encountered while trying to load plugins.", e);
|
||||
}
|
||||
logger.info("Loaded: " + subscribers.size() + " plugins.");
|
||||
System.out.println("Loaded: " + subscribers.size() + " plugins.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,14 +80,22 @@ public final class PluginService {
|
||||
|
||||
if (!file.isDirectory()) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(base);
|
||||
Class<?> clazz = null;
|
||||
try {
|
||||
clazz = Class.forName(base);
|
||||
} catch (ClassNotFoundException e) {
|
||||
try {
|
||||
clazz = Class.forName(base + "Kt");
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
if (EventSubscriber.class.isAssignableFrom(clazz) && !Modifier.isInterface(clazz.getModifiers()) && !Modifier.isAbstract(clazz.getModifiers())) {
|
||||
if (clazz != null && EventSubscriber.class.isAssignableFrom(clazz) && !Modifier.isInterface(clazz.getModifiers()) && !Modifier.isAbstract(clazz.getModifiers())) {
|
||||
final EventSubscriber<?> sub = (EventSubscriber<?>) clazz.newInstance();
|
||||
|
||||
plugins.add(sub);
|
||||
}
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user