From a880637c4065cf7294d17bc4efa57a89d0646efb Mon Sep 17 00:00:00 2001 From: Arasple Date: Mon, 20 Jan 2020 19:56:04 +0800 Subject: [PATCH 1/4] fix TLocaleJSON url --- .../io/izzel/taboolib/module/locale/type/TLocaleJson.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleJson.java b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleJson.java index 6eb160b..90ab38a 100644 --- a/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleJson.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleJson.java @@ -74,9 +74,11 @@ public class TLocaleJson extends TLocaleSerialize { BaseComponent[] component = TextComponent.fromLegacyText(text); arg.forEach((key, value) -> { if (key.equalsIgnoreCase("suggest")) { - Arrays.stream(component).forEach(baseComponent -> baseComponent.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.valueOf(value)))); + Arrays.stream(component).forEach(baseComponent -> baseComponent. setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.valueOf(value)))); } else if (key.equalsIgnoreCase("command") || "commands".equalsIgnoreCase(key)) { Arrays.stream(component).forEach(baseComponent -> baseComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.valueOf(value)))); + } else if (key.equalsIgnoreCase("url")) { + Arrays.stream(component).forEach(baseComponent -> baseComponent.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, String.valueOf(value)))); } else if (key.equalsIgnoreCase("hover")) { Arrays.stream(component).forEach(baseComponent -> baseComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(TLocale.Translate.setColored(String.valueOf(value))).create()))); } From f6da4781e7b68d8bf1a73eda7c3bbc2777effe99 Mon Sep 17 00:00:00 2001 From: Arasple Date: Tue, 21 Jan 2020 14:05:38 +0800 Subject: [PATCH 2/4] Improved catchers --- .../izzel/taboolib/module/locale/type/TLocaleJson.java | 4 ++-- src/main/scala/io/izzel/taboolib/util/lite/Catchers.java | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleJson.java b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleJson.java index 90ab38a..fb36c51 100644 --- a/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleJson.java +++ b/src/main/scala/io/izzel/taboolib/module/locale/type/TLocaleJson.java @@ -4,9 +4,9 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import io.izzel.taboolib.TabooLib; +import io.izzel.taboolib.module.compat.PlaceholderHook; import io.izzel.taboolib.module.locale.TLocale; import io.izzel.taboolib.module.locale.TLocaleSerialize; -import io.izzel.taboolib.module.compat.PlaceholderHook; import io.izzel.taboolib.module.tellraw.TellrawJson; import io.izzel.taboolib.util.Strings; import io.izzel.taboolib.util.Variables; @@ -74,7 +74,7 @@ public class TLocaleJson extends TLocaleSerialize { BaseComponent[] component = TextComponent.fromLegacyText(text); arg.forEach((key, value) -> { if (key.equalsIgnoreCase("suggest")) { - Arrays.stream(component).forEach(baseComponent -> baseComponent. setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.valueOf(value)))); + Arrays.stream(component).forEach(baseComponent -> baseComponent.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, String.valueOf(value)))); } else if (key.equalsIgnoreCase("command") || "commands".equalsIgnoreCase(key)) { Arrays.stream(component).forEach(baseComponent -> baseComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.valueOf(value)))); } else if (key.equalsIgnoreCase("url")) { diff --git a/src/main/scala/io/izzel/taboolib/util/lite/Catchers.java b/src/main/scala/io/izzel/taboolib/util/lite/Catchers.java index b6af0c4..74094a8 100644 --- a/src/main/scala/io/izzel/taboolib/util/lite/Catchers.java +++ b/src/main/scala/io/izzel/taboolib/util/lite/Catchers.java @@ -39,13 +39,13 @@ public class Catchers implements Listener { e.setCancelled(true); // 1.14 supported. Bukkit.getScheduler().runTask(TabooLib.getPlugin(), () -> { + Catcher catcher = playerdata.get(e.getPlayer().getName()).getFirst(); // 退出 - if (e.getMessage().equalsIgnoreCase("quit()")) { + if (e.getMessage().split(" ")[0].matches(catcher.quit())) { playerdata.get(e.getPlayer().getName()).removeFirst().cancel(); } // 默认 else { - Catcher catcher = playerdata.get(e.getPlayer().getName()).getFirst(); // 如果终止引导 if (!catcher.after(e.getMessage())) { playerdata.get(e.getPlayer().getName()).removeFirst(); @@ -59,6 +59,10 @@ public class Catchers implements Listener { public interface Catcher { + default String quit() { + return "(?i)quit|cancel|exit"; + } + default Catcher before() { return this; } @@ -67,5 +71,6 @@ public class Catchers implements Listener { default void cancel() { } + } } From 03bf00a43de5958fad81fe9fcbe6dea95d75a0c6 Mon Sep 17 00:00:00 2001 From: Arasple Date: Wed, 22 Jan 2020 11:05:28 +0800 Subject: [PATCH 3/4] improved ref --- .../izzel/taboolib/module/lite/SimpleReflection.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/io/izzel/taboolib/module/lite/SimpleReflection.java b/src/main/scala/io/izzel/taboolib/module/lite/SimpleReflection.java index 6490000..4c9a714 100644 --- a/src/main/scala/io/izzel/taboolib/module/lite/SimpleReflection.java +++ b/src/main/scala/io/izzel/taboolib/module/lite/SimpleReflection.java @@ -70,7 +70,7 @@ public class SimpleReflection { } Field field = fields.get(fieldName); if (value == null) { - TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName()); + return; } try { field.set(instance, value); @@ -86,7 +86,7 @@ public class SimpleReflection { } Field field = fields.get(fieldName); if (field == null) { - TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName()); + return null; } try { return field.get(instance); @@ -103,7 +103,7 @@ public class SimpleReflection { } Field field = fields.get(fieldName); if (field == null) { - TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName()); + return null; } try { return (T) field.get(instance); @@ -113,7 +113,7 @@ public class SimpleReflection { return def; } - public static Class getListType(Field field) { + public static Class getListType(Field field) { Type genericType = field.getGenericType(); try { if (ParameterizedType.class.isAssignableFrom(genericType.getClass())) { @@ -127,7 +127,7 @@ public class SimpleReflection { return null; } - public static Class[] getMapType(Field field) { + public static Class[] getMapType(Field field) { Class[] mapType = new Class[2]; try { Type genericType = field.getGenericType(); @@ -139,6 +139,6 @@ public class SimpleReflection { } catch (Throwable t) { t.printStackTrace(); } - return mapType[1] == null ? null : mapType ; + return mapType[1] == null ? null : mapType; } } From af3f9d67bb09b7ea79937032f1080ef92aa2940b Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Wed, 22 Jan 2020 12:07:47 +0800 Subject: [PATCH 4/4] Remove duplicate gradle script --- build.gradle | 3 --- 1 file changed, 3 deletions(-) diff --git a/build.gradle b/build.gradle index f2bdbf0..cdb589f 100644 --- a/build.gradle +++ b/build.gradle @@ -44,9 +44,6 @@ shadowJar { // 免得 MANIFEST.MF 里面刷一堆 lib 难看 taskActions.removeIf { it.actionClassName.contains 'configureShadowTask' } - // 免得 MANIFEST.MF 里面刷一堆 lib 难看 - taskActions.removeIf { it.actionClassName.contains 'configureShadowTask' } - dependencies { it.include it.dependency('org.apache.commons:.*') it.include it.dependency('org.ow2.asm:.*')