Fix signs

master
sky 2020-01-17 18:33:47 +08:00
parent 3831158a6b
commit 098970b05d
3 changed files with 11 additions and 10 deletions

View File

@ -91,8 +91,9 @@ public class PacketSerializer implements Listener {
Packet packet = null;
try {
packet = parser.parser((JsonObject) new JsonParser().parse(origin));
} catch (JsonSyntaxException e) {
e.printStackTrace();
} catch (JsonSyntaxException ignore) {
} catch (Throwable t) {
t.printStackTrace();
}
return packet == null ? new PacketEmpty(0) : packet;
}

View File

@ -2,6 +2,7 @@ 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,11 +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) {
throw new RuntimeException("Not Found Cache.");
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
}
Field field = fields.get(fieldName);
if (value == null) {
throw new RuntimeException("Not Found Field.");
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
}
try {
field.set(instance, value);
@ -81,11 +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) {
throw new RuntimeException("Not Found Cache.");
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
}
Field field = fields.get(fieldName);
if (field == null) {
throw new RuntimeException("Not Found Field.");
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
}
try {
return field.get(instance);
@ -98,11 +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) {
throw new RuntimeException("Not Found Cache.");
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
}
Field field = fields.get(fieldName);
if (field == null) {
throw new RuntimeException("Not Found Field.");
TLogger.getGlobalLogger().error("Field Not Found: " + nmsClass.getName());
}
try {
return (T) field.get(instance);

View File

@ -10,7 +10,6 @@ import io.izzel.taboolib.module.packet.TPacket;
import org.apache.commons.lang3.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
@ -38,7 +37,7 @@ public class Signs {
Location location = player.getLocation();
location.setY(0);
try {
player.sendBlockChange(location, Material.WALL_SIGN, (byte) 0);
player.sendBlockChange(location, Materials.OAK_WALL_SIGN.parseMaterial(), (byte) 0);
player.sendSignChange(location, format(origin));
} catch (Throwable t) {
t.printStackTrace();