Merge branch 'master' of https://github.com/Bkm016/TabooLib
# Conflicts: # src/main/scala/io/izzel/taboolib/module/lite/SimpleReflection.java
This commit is contained in:
commit
1483ba8e84
@ -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:.*')
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.izzel.taboolib.module.lite;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import io.izzel.taboolib.TabooLibAPI;
|
||||
import io.izzel.taboolib.module.locale.logger.TLogger;
|
||||
import io.izzel.taboolib.util.Ref;
|
||||
@ -11,7 +10,6 @@ import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Author 坏黑
|
||||
@ -20,7 +18,6 @@ import java.util.Set;
|
||||
public class SimpleReflection {
|
||||
|
||||
private static Map<String, Map<String, Field>> fieldCached = Maps.newHashMap();
|
||||
private static Set<String> fieldLogger = Sets.newHashSet();
|
||||
|
||||
public static boolean isExists(Class<?> nmsClass) {
|
||||
return fieldCached.containsKey(nmsClass.getName());
|
||||
@ -69,15 +66,11 @@ public class SimpleReflection {
|
||||
public static void setFieldValue(Class<?> nmsClass, Object instance, String fieldName, Object value) {
|
||||
Map<String, Field> fields = fieldCached.get(nmsClass.getName());
|
||||
if (fields == null) {
|
||||
if (fieldLogger.add(nmsClass.getName() + "$" + fieldName)) {
|
||||
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName() + "$" + fieldName);
|
||||
}
|
||||
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
|
||||
}
|
||||
Field field = fields.get(fieldName);
|
||||
if (value == null) {
|
||||
if (fieldLogger.add(nmsClass.getName() + "$" + fieldName)) {
|
||||
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName() + "$" + fieldName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
field.set(instance, value);
|
||||
@ -89,15 +82,11 @@ public class SimpleReflection {
|
||||
public static Object getFieldValue(Class<?> nmsClass, Object instance, String fieldName) {
|
||||
Map<String, Field> fields = fieldCached.get(nmsClass.getName());
|
||||
if (fields == null) {
|
||||
if (fieldLogger.add(nmsClass.getName() + "$" + fieldName)) {
|
||||
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName() + "$" + fieldName);
|
||||
}
|
||||
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
|
||||
}
|
||||
Field field = fields.get(fieldName);
|
||||
if (field == null) {
|
||||
if (fieldLogger.add(nmsClass.getName() + "$" + fieldName)) {
|
||||
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName() + "$" + fieldName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return field.get(instance);
|
||||
@ -110,15 +99,11 @@ public class SimpleReflection {
|
||||
public static <T> T getFieldValue(Class<?> nmsClass, Object instance, String fieldName, T def) {
|
||||
Map<String, Field> fields = fieldCached.get(nmsClass.getName());
|
||||
if (fields == null) {
|
||||
if (fieldLogger.add(nmsClass.getName() + "$" + fieldName)) {
|
||||
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName() + "$" + fieldName);
|
||||
}
|
||||
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
|
||||
}
|
||||
Field field = fields.get(fieldName);
|
||||
if (field == null) {
|
||||
if (fieldLogger.add(nmsClass.getName() + "$" + fieldName)) {
|
||||
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName() + "$" + fieldName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return (T) field.get(instance);
|
||||
@ -154,6 +139,6 @@ public class SimpleReflection {
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
return mapType[1] == null ? null : mapType ;
|
||||
return mapType[1] == null ? null : mapType;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -77,6 +77,8 @@ public class TLocaleJson extends TLocaleSerialize {
|
||||
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())));
|
||||
}
|
||||
|
@ -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() {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user