1
mirror of https://github.com/CarmJos/UltraDepository.git synced 2026-06-04 16:48:21 +08:00

[v1.1.6] 版本更新

- [U] 采用EasyPlugin项目代码,并将此项目作为示范项目。
- [A] 添加数个事件,便于其他插件的开发。
- [A] 提供JSON存储格式,便于其他情况下的使用。
- [U] 添加StorageMethod枚举类,并允许自定义存储源。
- [U] 不再强制为数据加上 “:0”数据结尾,简化数据格式。
This commit is contained in:
2022-01-05 04:05:54 +08:00
parent 64acb25bfc
commit 976d9c32ff
52 changed files with 703 additions and 2464 deletions
-51
View File
@@ -1,51 +0,0 @@
import cc.carm.plugin.ultradepository.configuration.gui.GUIActionType;
import cc.carm.plugin.ultradepository.configuration.gui.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());
}
}
}
+20 -4
View File
@@ -1,6 +1,7 @@
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.lang.reflect.Method;
import java.util.*;
public class GsonMapTest {
@@ -15,8 +16,8 @@ public class GsonMapTest {
List<Test> tests = new ArrayList<>();
tests.add(new Test1());
tests.add(new Test2());
tests.stream().map(test -> test.getClass().getSimpleName()).forEach(System.out::println);
tests.add(new Test3());
tests.stream().map(test -> test.getClass().getSimpleName() + " : " + test.isOverride("load")).forEach(System.out::println);
Map<String, Map<String, Map<String, Integer>>> values = new LinkedHashMap<>();
@@ -54,6 +55,19 @@ public class GsonMapTest {
void load();
default boolean isOverride(String methodName) {
Map<Method, Method> methodMap = new HashMap<>();
Arrays.stream(Test.class.getDeclaredMethods())
.filter(method -> method.getName().equals(methodName))
.forEach(method -> Arrays.stream(getClass().getDeclaredMethods())
.filter(extend -> extend.getName().equals(methodName))
.filter(extend -> extend.getReturnType().equals(method.getReturnType()))
.filter(extend -> extend.getParameterTypes().length == method.getParameterTypes().length)
.findFirst().ifPresent(extendMethod -> methodMap.put(method, extendMethod))
);
return !methodMap.isEmpty();
}
}
public static class Test1 implements Test {
@@ -65,12 +79,14 @@ public class GsonMapTest {
}
}
public static class Test2 implements Test {
public static class Test2 extends Test1 {
}
public static class Test3 extends Test2 {
@Override
public void load() {
System.out.println("test2");
}
}