Skip to content

Commit 2016f62

Browse files
[1.13.13.1]CommandTree不再限制重复注册,添加一些debug信息
1 parent e8559fd commit 2016f62

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
java.sourceCompatibility = JavaVersion.VERSION_1_8
22
java.targetCompatibility = JavaVersion.VERSION_1_8
33
rootProject.group = "com.crypticlib"
4-
rootProject.version = "1.13.13.0"
4+
rootProject.version = "1.13.13.1"
55
//全项目重构时更新大版本号
66
//添加模块或有较大更改时更新次版本号
77
//有API变动(新增/删除/更改声明)时更新修订号

platform/bukkit/src/main/java/crypticlib/BukkitPlugin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public final void onLoad() {
5858
BukkitConfigContainer configContainer = new BukkitConfigContainer(configClass, configWrapper);
5959
configContainerMap.put(configClass, configContainer);
6060
configContainer.reload();
61+
IOHelper.debug("Loaded config file: " + path);
6162
}
6263
);
6364
whenLoad();
@@ -74,6 +75,7 @@ public final void onEnable() {
7475
}
7576
Listener listener = (Listener) ReflectionHelper.getSingletonClassInstance(listenerClass);
7677
Bukkit.getPluginManager().registerEvents(listener, this);
78+
IOHelper.debug("Registered listener for class: " + listenerClass.getName());
7779
} catch (ClassNotFoundException | NoClassDefFoundError e) {
7880
EventListener annotation = listenerClass.getAnnotation(EventListener.class);
7981
if (!annotation.ignoreClassNotFound()) {
@@ -96,6 +98,7 @@ public final void onEnable() {
9698
}
9799
CommandTree commandTree = (CommandTree) ReflectionHelper.getSingletonClassInstance(commandClass);
98100
commandTree.register();
101+
IOHelper.debug("Registered command `" + commandTree.commandInfo().name() + "`, handler class: " + commandTree.getClass().getName());
99102
} catch (ClassNotFoundException | NoClassDefFoundError e) {
100103
if (!annotation.ignoreClassNotFound()) {
101104
e.printStackTrace();

platform/bungee/src/main/java/crypticlib/BungeePlugin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public final void onLoad() {
5757
BungeeConfigContainer configContainer = new BungeeConfigContainer(configClass, configWrapper);
5858
configContainerMap.put(configClass, configContainer);
5959
configContainer.reload();
60+
IOHelper.debug("Loaded config file: " + path);
6061
}
6162
);
6263
whenLoad();
@@ -73,6 +74,7 @@ public final void onEnable() {
7374
}
7475
Listener listener = (Listener) ReflectionHelper.getSingletonClassInstance(listenerClass);
7576
getProxy().getPluginManager().registerListener(this, listener);
77+
IOHelper.debug("Registered listener for class: " + listenerClass.getName());
7678
} catch (ClassNotFoundException | NoClassDefFoundError e) {
7779
EventListener annotation = listenerClass.getAnnotation(EventListener.class);
7880
if (!annotation.ignoreClassNotFound()) {
@@ -95,6 +97,7 @@ public final void onEnable() {
9597
}
9698
CommandTree commandTree = (CommandTree) ReflectionHelper.getSingletonClassInstance(commandClass);
9799
commandTree.register();
100+
IOHelper.debug("Registered command `" + commandTree.commandInfo().name() + "`, handler class: " + commandTree.getClass().getName());
98101
} catch (ClassNotFoundException | NoClassDefFoundError e) {
99102
if (!annotation.ignoreClassNotFound()) {
100103
e.printStackTrace();

platform/common/src/main/java/crypticlib/command/CommandTree.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
*/
1313
public class CommandTree extends CommandNode {
1414

15-
private boolean registered = false;
16-
1715
public CommandTree(@NotNull CommandInfo commandInfo) {
1816
super(commandInfo);
1917
}
@@ -40,12 +38,9 @@ public CommandTree regSub(@NotNull CommandNode commandNode) {
4038
}
4139

4240
public final void register() {
43-
if (registered)
44-
throw new UnsupportedOperationException("Cannot register a command repeatedly");
4541
scanSubCommands();
4642
registerPerms();
4743
CrypticLib.commandManager().register(this);
48-
registered = true;
4944
}
5045

5146
}

platform/common/src/main/java/crypticlib/internal/PluginScanner.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package crypticlib.internal;
22

3+
import crypticlib.util.IOHelper;
34
import org.jetbrains.annotations.NotNull;
45

56
import java.io.File;
@@ -47,6 +48,7 @@ public void scanJar(@NotNull JarFile jarFile) {
4748
.replace('/', '.')
4849
.substring(0, entry.getName().length() - 6);
4950
Class<?> clazz = classLoader.loadClass(className);
51+
IOHelper.debug("Loaded class: " + className);
5052
pluginClassMap.put(className, clazz);
5153
//添加注解缓存
5254
for (Annotation annotation : clazz.getAnnotations()) {

platform/velocity/src/main/java/crypticlib/VelocityPlugin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public final void onProxyInitialization(ProxyInitializeEvent event) {
7373
VelocityConfigContainer configContainer = new VelocityConfigContainer(configClass, configWrapper);
7474
configContainerMap.put(configClass, configContainer);
7575
configContainer.reload();
76+
IOHelper.debug("Loaded config file: " + path);
7677
}
7778
);
7879
whenLoad();
@@ -84,6 +85,7 @@ public final void onProxyInitialization(ProxyInitializeEvent event) {
8485
try {
8586
Object listener = ReflectionHelper.getSingletonClassInstance(listenerClass);
8687
proxyServer.getEventManager().register(this, listener);
88+
IOHelper.debug("Registered listener for class: " + listenerClass.getName());
8789
} catch (ClassNotFoundException | NoClassDefFoundError e) {
8890
EventListener annotation = listenerClass.getAnnotation(EventListener.class);
8991
if (!annotation.ignoreClassNotFound()) {
@@ -107,6 +109,7 @@ public final void onProxyInitialization(ProxyInitializeEvent event) {
107109
}
108110
CommandTree commandTree = (CommandTree) ReflectionHelper.getSingletonClassInstance(commandClass);
109111
commandTree.register();
112+
IOHelper.debug("Registered command `" + commandTree.commandInfo().name() + "`, handler class: " + commandTree.getClass().getName());
110113
} catch (ClassNotFoundException | NoClassDefFoundError e) {
111114
if (!annotation.ignoreClassNotFound()) {
112115
e.printStackTrace();

0 commit comments

Comments
 (0)