From fa432ff7413d340ad4d457791c250a2784fe265c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Fri, 2 Aug 2019 10:36:01 +0800 Subject: [PATCH] fix forge --- build.gradle | 7 ++----- src/main/resources/plugin.yml | 5 +++++ .../scala/io/izzel/taboolib/module/db/sql/SQLTable.java | 4 ++++ src/main/scala/io/izzel/taboolib/util/Files.java | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 src/main/resources/plugin.yml diff --git a/build.gradle b/build.gradle index 8475a3a..d3da970 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 = '5.0' +version = '5.01' sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -63,10 +63,7 @@ processResources { from(sourceSets.main.resources.srcDirs) { include '__resources__/version' + include 'plugin.yml' expand 'version': project.version } - - from(sourceSets.main.resources.srcDirs) { - exclude '__resources__/version' - } } \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..b655493 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,5 @@ +name: TabooLib5 +main: io.izzel.taboolib.common.plugin.InternalJavaPlugin +version: ${version} + +author: 坏黑 \ No newline at end of file diff --git a/src/main/scala/io/izzel/taboolib/module/db/sql/SQLTable.java b/src/main/scala/io/izzel/taboolib/module/db/sql/SQLTable.java index cd09876..870f489 100644 --- a/src/main/scala/io/izzel/taboolib/module/db/sql/SQLTable.java +++ b/src/main/scala/io/izzel/taboolib/module/db/sql/SQLTable.java @@ -74,6 +74,10 @@ public class SQLTable { return executeUpdate("insert into " + tableName + " values(" + queryValues + ")"); } + public RunnableUpdate executeUpdateIfDuplicate(String queryValues, String queryUpdate) { + return executeUpdate("insert into " + tableName + " values(" + queryValues + ") on duplicate key update " + queryUpdate); + } + public RunnableUpdate executeUpdate(String query) { return new RunnableUpdate(query); } diff --git a/src/main/scala/io/izzel/taboolib/util/Files.java b/src/main/scala/io/izzel/taboolib/util/Files.java index 056b213..17e0359 100644 --- a/src/main/scala/io/izzel/taboolib/util/Files.java +++ b/src/main/scala/io/izzel/taboolib/util/Files.java @@ -3,6 +3,7 @@ package io.izzel.taboolib.util; import io.izzel.taboolib.TabooLib; import io.izzel.taboolib.common.plugin.InternalPlugin; import io.izzel.taboolib.module.inject.TSchedule; +import io.izzel.taboolib.util.plugin.PluginUtils; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.Plugin; @@ -73,7 +74,8 @@ public class Files { public static InputStream getCanonicalResource(Plugin plugin, String filename) { File file = file(new File("plugins/TabooLib/temp/" + UUID.randomUUID())); try { - ZipFile zipFile = new ZipFile(toFile(plugin.getClass().getProtectionDomain().getCodeSource().getLocation().openStream(), file)); + copy(plugin instanceof InternalPlugin ? new File("libs/TabooLib.jar") : PluginUtils.getPluginFile(plugin), file); + ZipFile zipFile = new ZipFile(file); ZipEntry entry = zipFile.getEntry(filename); if (entry != null) { return zipFile.getInputStream(entry);