Update 5.2

This commit is contained in:
sky 2020-03-10 10:14:57 +08:00
parent ea029a9466
commit 5ab083f19a
4 changed files with 9 additions and 19 deletions

View File

@ -6,7 +6,7 @@ plugins {
}
group = 'me.skymc'
version = '5.19'
version = '5.2'
sourceCompatibility = 1.8
targetCompatibility = 1.8

View File

@ -48,8 +48,7 @@ public class TConfigWatcher {
public void addSimpleListener(File file, Runnable runnable) {
try {
addListener(file, null, obj -> runnable.run());
} catch (Throwable t) {
t.printStackTrace();
} catch (Throwable ignored) {
}
}

View File

@ -48,13 +48,11 @@ public class TInjectHelper {
instance.add(PluginLoader.get(plugin));
}
// TInject
else if (TInjectCreator.getInstanceMap().entrySet().stream().anyMatch(e -> e.getKey().getType().equals(pluginClass))) {
if (TInjectCreator.getInstanceMap().entrySet().stream().anyMatch(e -> e.getKey().getType().equals(pluginClass))) {
TInjectCreator.getInstanceMap().entrySet().stream().filter(e -> e.getKey().getType().equals(pluginClass)).forEach(i -> instance.add(i.getValue().getInstance()));
}
// TListener
else {
instance.addAll(TListenerHandler.getInstance(plugin, pluginClass));
}
instance.addAll(TListenerHandler.getInstance(plugin, pluginClass));
}
// Nothing
if (instance.isEmpty()) {
@ -84,9 +82,11 @@ public class TInjectHelper {
instance.add(PluginLoader.get(plugin));
}
// TInject
else if (TInjectCreator.getInstanceMap().entrySet().stream().anyMatch(e -> e.getKey().getType().equals(pluginClass))) {
if (TInjectCreator.getInstanceMap().entrySet().stream().anyMatch(e -> e.getKey().getType().equals(pluginClass))) {
TInjectCreator.getInstanceMap().entrySet().stream().filter(e -> e.getKey().getType().equals(pluginClass)).forEach(i -> instance.add(i.getValue().getInstance()));
}
// TListener
instance.addAll(TListenerHandler.getInstance(plugin, pluginClass));
}
// Nothing
if (instance.isEmpty()) {

View File

@ -11,7 +11,6 @@ import io.izzel.taboolib.module.nms.nbt.Attribute;
import io.izzel.taboolib.module.nms.nbt.NBTBase;
import io.izzel.taboolib.module.nms.nbt.NBTCompound;
import io.izzel.taboolib.module.nms.nbt.NBTList;
import io.izzel.taboolib.util.Reflection;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@ -76,11 +75,7 @@ public class Items {
public static Material asMaterial(String args) {
try {
Material material = Material.getMaterial(args.toUpperCase());
if (material != null) {
return material;
}
Object getById = Reflection.invokeMethod(Material.class, "getMaterial", NumberConversions.toInt(args));
return getById != null ? (Material) getById : null;
return material != null ? material : Material.getMaterial(Integer.valueOf(args));
} catch (Exception e) {
return Material.STONE;
}
@ -106,11 +101,7 @@ public class Items {
public static Enchantment asEnchantment(String enchant) {
try {
Enchantment enchantment = Enchantment.getByName(enchant);
if (enchantment != null) {
return enchantment;
}
Object getById = Reflection.invokeMethod(Enchantment.class, "getById", NumberConversions.toInt(enchant));
return getById != null ? (Enchantment) getById : null;
return enchantment != null ? enchantment : Enchantment.getById(Integer.valueOf(enchant));
} catch (Exception e) {
return null;
}