mirror of
https://github.com/CarmJos/EasyPlugin.git
synced 2026-06-05 00:58:17 +08:00
1713fb1324
- [U] 不再允许重写onLoad、onEnable与onDisable方法。 - [F] 修复GUI打开时的空指针异常。 - [A] 添加outputInfo方法,方便插件输出相关信息。 - [A] 添加 EasyPluginMessageProvider 用于实现多语言支持。
53 lines
1.3 KiB
Java
53 lines
1.3 KiB
Java
|
|
import cc.carm.lib.easyplugin.gui.configuration.GUIActionType;
|
|
import cc.carm.lib.easyplugin.gui.configuration.GUIConfiguration;
|
|
import org.bukkit.event.inventory.ClickType;
|
|
import org.junit.Test;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
public class ActionReadTest {
|
|
|
|
|
|
@Test
|
|
public void test() {
|
|
|
|
List<String> actions = Arrays.asList(
|
|
"[CHAT] 123123",
|
|
"[SHIFT_LEFT:CHAT] /test qwq",
|
|
"[CONSOLE] say hello",
|
|
"[CLOSE]"
|
|
);
|
|
|
|
for (String actionString : actions) {
|
|
int prefixStart = actionString.indexOf("[");
|
|
int prefixEnd = actionString.indexOf("]");
|
|
if (prefixStart < 0 || prefixEnd < 0) continue;
|
|
|
|
String prefix = actionString.substring(prefixStart + 1, prefixEnd);
|
|
ClickType clickType = null;
|
|
GUIActionType actionType;
|
|
if (prefix.contains(":")) {
|
|
String[] args = prefix.split(":");
|
|
clickType = GUIConfiguration.readClickType(args[0]);
|
|
actionType = GUIActionType.readActionType(args[1]);
|
|
} else {
|
|
actionType = GUIActionType.readActionType(prefix);
|
|
}
|
|
|
|
if (actionType == null) {
|
|
System.out.println("# " + actionString);
|
|
System.out.println("- actionType is Null");
|
|
continue;
|
|
}
|
|
|
|
System.out.println("# " + actionType.name() + " " + (clickType == null ? "" : clickType.name()));
|
|
System.out.println("- " + actionString.substring(prefixEnd + 1).trim());
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|