diff --git a/build.gradle b/build.gradle index f685b5a..c67f34b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { id 'com.github.johnrengelman.shadow' version '4.0.4' } group = 'me.skymc' -version = '4.84' +version = '4.85' sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -27,6 +27,7 @@ dependencies { exclude(module: 'slf4j-log4j12') exclude(module: 'log4j') } + compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8' shadow group: 'com.zaxxer', name: 'HikariCP', version: '3.1.0' shadow group: 'org.javalite', name: 'activejdbc', version: '2.0' compile group: 'org.ow2.asm', name: 'asm', version: '7.0-beta' diff --git a/src/main/resources/Addons/TabooLibDeprecated b/src/main/resources/Addons/TabooLibDeprecated index d4d77da..817fe8f 100644 Binary files a/src/main/resources/Addons/TabooLibDeprecated and b/src/main/resources/Addons/TabooLibDeprecated differ diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 71b5d29..ee79d9f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,7 @@ name: TabooLib main: me.skymc.taboolib.Main version: ${version} +api-version: 1.14 authors: - 坏黑 diff --git a/src/main/scala/com/ilummc/tlib/TLib.java b/src/main/scala/com/ilummc/tlib/TLib.java index 831c274..ad11ca0 100644 --- a/src/main/scala/com/ilummc/tlib/TLib.java +++ b/src/main/scala/com/ilummc/tlib/TLib.java @@ -87,7 +87,7 @@ public class TLib { public static void injectPluginManager() { if (!tLib.isInjectEnabled() || tLib.isBlackListPluginExists()) { - TLocale.Logger.fatal("TLIB.INJECTION-DISABLED"); + TLocale.Logger.warn("TLIB.INJECTION-DISABLED"); Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(plugin -> plugin != Main.getInst()).forEach(plugin -> TDependencyInjector.inject(plugin, plugin)); return; } diff --git a/src/main/scala/me/skymc/taboolib/common/io/IOUtils.java b/src/main/scala/me/skymc/taboolib/common/io/IOUtils.java new file mode 100644 index 0000000..49f3da8 --- /dev/null +++ b/src/main/scala/me/skymc/taboolib/common/io/IOUtils.java @@ -0,0 +1,83 @@ +package me.skymc.taboolib.common.io; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.URLConnection; +import java.nio.channels.Selector; + +/** + * from org.apache.commons.io + * support for 1.14 + */ +public class IOUtils { + + public static void close(URLConnection v) { + if (v instanceof HttpURLConnection) { + ((HttpURLConnection)v).disconnect(); + } + } + + public static void closeQuietly(Reader v) { + closeQuietly((Closeable)v); + } + + public static void closeQuietly(Writer v) { + closeQuietly((Closeable)v); + } + + public static void closeQuietly(InputStream v) { + closeQuietly((Closeable)v); + } + + public static void closeQuietly(OutputStream v) { + closeQuietly((Closeable)v); + } + + public static void closeQuietly(Closeable v) { + try { + if (v != null) { + v.close(); + } + } catch (IOException ignored) { + } + } + + public static void closeQuietly(Closeable... v) { + if (v != null) { + int var2 = v.length; + for (Closeable var4 : v) { + closeQuietly(var4); + } + } + } + + public static void closeQuietly(Socket v) { + if (v != null) { + try { + v.close(); + } catch (IOException ignored) { + } + } + + } + + public static void closeQuietly(Selector v) { + if (v != null) { + try { + v.close(); + } catch (IOException ignored) { + } + } + } + + public static void closeQuietly(ServerSocket v) { + if (v != null) { + try { + v.close(); + } catch (IOException ignored) { + } + } + } +} diff --git a/src/main/scala/me/skymc/taboolib/common/nms/NMSHandlerImpl.java b/src/main/scala/me/skymc/taboolib/common/nms/NMSHandlerImpl.java index 99979d1..c35bb0c 100644 --- a/src/main/scala/me/skymc/taboolib/common/nms/NMSHandlerImpl.java +++ b/src/main/scala/me/skymc/taboolib/common/nms/NMSHandlerImpl.java @@ -73,10 +73,16 @@ public class NMSHandlerImpl extends NMSHandler { name += ".effect." + ((net.minecraft.server.v1_8_R3.ItemStack) nmsItem).getTag().getString("Potion").replaceAll("minecraft:(strong_|long_)?", ""); } return name; - } else { + } else if (TabooLib.getVersionNumber() >= 11100) { String name = ((net.minecraft.server.v1_12_R1.ItemStack) nmsItem).getItem().a((net.minecraft.server.v1_12_R1.ItemStack) nmsItem); if (itemStack.getItemMeta() instanceof PotionMeta) { - return name.replace("item.", "") + ".effect." + ((net.minecraft.server.v1_8_R3.ItemStack) nmsItem).getTag().getString("Potion").replaceAll("minecraft:(strong_|long_)?", ""); + return name.replace("item.", "") + ".effect." + ((net.minecraft.server.v1_8_R3.ItemStack) nmsItem).getTag().getString("Potion").replaceAll("(minecraft:)?(strong_|long_)?", ""); + } + return name + ".name"; + } else { + String name = ((net.minecraft.server.v1_8_R3.ItemStack) nmsItem).getItem().getName(); + if (itemStack.getItemMeta() instanceof PotionMeta) { + return name.replace("item.", "") + ".effect." + ((net.minecraft.server.v1_8_R3.ItemStack) nmsItem).getTag().getString("Potion").replaceAll("(minecraft:)?(strong_|long_)?", ""); } return name + ".name"; } diff --git a/src/main/scala/me/skymc/taboolib/common/util/SimpleI18n.java b/src/main/scala/me/skymc/taboolib/common/util/SimpleI18n.java index 4b4066e..7cb28dd 100644 --- a/src/main/scala/me/skymc/taboolib/common/util/SimpleI18n.java +++ b/src/main/scala/me/skymc/taboolib/common/util/SimpleI18n.java @@ -5,12 +5,14 @@ import me.skymc.taboolib.Main; import me.skymc.taboolib.TabooLib; import me.skymc.taboolib.common.function.TFunction; import me.skymc.taboolib.common.nms.NMSHandler; +import me.skymc.taboolib.common.nms.nbt.NBTCompound; import me.skymc.taboolib.fileutils.ConfigUtils; import me.skymc.taboolib.fileutils.FileUtils; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Entity; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SpawnEggMeta; import org.bukkit.plugin.Plugin; @@ -62,8 +64,19 @@ public class SimpleI18n { if (item == null) { return "-"; } - if (TabooLib.getVersionNumber() < 11300) { - ItemMeta itemMeta = item.getItemMeta(); + ItemMeta itemMeta = item.getItemMeta(); + if (itemMeta instanceof BookMeta && ((BookMeta) itemMeta).getTitle() != null) { + return ((BookMeta) itemMeta).getTitle(); + } + if (TabooLib.getVersionNumber() < 11100) { + if (item.getType().name().equals("MONSTER_EGG")) { + NBTCompound nbtCompound = NMSHandler.getHandler().loadNBT(item); + if (nbtCompound.containsKey("EntityTag")) { + return lang.getString("item_monsterPlacer_name") + " " + lang.getString("entity_" + nbtCompound.get("EntityTag").asCompound().get("id").asString() + "_name"); + } + return lang.getString("item_monsterPlacer_name"); + } + } else if (TabooLib.getVersionNumber() < 11300) { if (itemMeta instanceof SpawnEggMeta) { String spawnEggType = lang.getString("entity_" + ((SpawnEggMeta) itemMeta).getSpawnedType().getEntityClass().getSimpleName().replace(".", "_") + "_name"); if (spawnEggType != null) { diff --git a/src/main/scala/me/skymc/taboolib/fileutils/FileUtils.java b/src/main/scala/me/skymc/taboolib/fileutils/FileUtils.java index 104a0a3..c16ab30 100644 --- a/src/main/scala/me/skymc/taboolib/fileutils/FileUtils.java +++ b/src/main/scala/me/skymc/taboolib/fileutils/FileUtils.java @@ -5,7 +5,7 @@ import com.ilummc.eagletdl.EagletTask; import com.ilummc.eagletdl.ProgressEvent; import com.ilummc.tlib.resources.TLocale; import me.skymc.taboolib.Main; -import org.apache.commons.io.IOUtils; +import me.skymc.taboolib.common.io.IOUtils; import org.bukkit.plugin.Plugin; import java.io.*;