Update JDK 11

This commit is contained in:
sky 2020-02-02 17:31:20 +08:00
parent 3a70acebd8
commit 725d2899b2
3 changed files with 12 additions and 5 deletions

View File

@ -2,7 +2,6 @@ package io.izzel.taboolib.module.lite;
import com.google.common.collect.Maps;
import io.izzel.taboolib.TabooLibAPI;
import io.izzel.taboolib.module.locale.logger.TLogger;
import io.izzel.taboolib.util.Ref;
import java.lang.reflect.Field;
@ -65,7 +64,7 @@ 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) {
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
return;
}
Field field = fields.get(fieldName);
if (value == null) {
@ -81,7 +80,7 @@ public class SimpleReflection {
public static Object getFieldValue(Class<?> nmsClass, Object instance, String fieldName) {
Map<String, Field> fields = fieldCached.get(nmsClass.getName());
if (fields == null) {
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
return null;
}
Field field = fields.get(fieldName);
if (field == null) {
@ -99,7 +98,7 @@ 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) {
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
return null;
}
Field field = fields.get(fieldName);
if (field == null) {

View File

@ -1,5 +1,6 @@
package io.izzel.taboolib.util;
import com.google.common.base.Preconditions;
import com.google.gson.annotations.SerializedName;
import io.izzel.taboolib.TabooLib;
import io.izzel.taboolib.TabooLibAPI;
@ -56,6 +57,7 @@ public class Ref {
}
public static void putField(Object src, Field field, Object value) {
Preconditions.checkNotNull(field);
if (Modifier.isStatic(field.getModifiers())) {
Object base = getUnsafe().staticFieldBase(field);
long offset = getUnsafe().staticFieldOffset(field);
@ -97,6 +99,8 @@ public class Ref {
}
public static Object getField(Object src, Field field) {
Preconditions.checkNotNull(field);
getUnsafe().ensureClassInitialized(field.getDeclaringClass());
if (Modifier.isStatic(field.getModifiers())) {
Object base = getUnsafe().staticFieldBase(field);
long offset = getUnsafe().staticFieldOffset(field);

View File

@ -1,5 +1,6 @@
package io.izzel.taboolib.util.item;
import io.izzel.taboolib.util.Reflection;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -161,7 +162,10 @@ public class MapBuilder {
if (isNewVersion) {
MapMeta mapMeta = (MapMeta) item.getItemMeta();
mapMeta.setMapView(map);
try {
Reflection.invokeMethod(mapMeta, "setMapView", map);
} catch (Throwable ignored) {
}
item.setItemMeta(mapMeta);
} else {
item.setDurability(getMapId(map));