From b94799dcea07f68f085c4bd9917dc734c17f9df1 Mon Sep 17 00:00:00 2001 From: GeekFrog Date: Mon, 31 Jul 2017 01:45:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=AF=E5=BE=84BUG=20?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 253 +++++++++--------- .../frog/mc/permissionstime/PluginMain.java | 7 +- .../mc/permissionstime/utils/FileUtil.java | 94 +++---- src/resources/plugin.yml | 2 +- 4 files changed, 183 insertions(+), 173 deletions(-) diff --git a/pom.xml b/pom.xml index 0791668..7ab6edb 100644 --- a/pom.xml +++ b/pom.xml @@ -1,125 +1,132 @@ - - 4.0.0 - gg.frog.mc - permissionstime - 0.2.3-SNAPSHOT - jar - PermissionsTime - 支持跨服的权限限时插件 - - https://github.com/geekfrog - GeekFrog - - https://github.com/geekfrog/PermissionsTime/ - - UTF-8 - - - - spigotmc-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - - dakani - Dakani Nexus Repo - https://repo.dakanilabs.com/repository/public/ - - - vault-repo - http://nexus.hc.to/content/repositories/pub_releases/ - - - Plugin Metrics - http://repo.mcstats.org/content/repositories/public - - - - - org.bukkit - bukkit - 1.8-R0.1-SNAPSHOT - jar - compile - - - org.mcstats.bukkit - metrics - R8-SNAPSHOT - compile - - - net.milkbowl.vault - VaultAPI - 1.6 - provided - - - lib.PatPeter.SQLibrary - SQLibrary - 7.1 - - - - PermissionsTime-${project.version} - ${basedir}/src/main - - - src/resources - - - . - true - ${basedir} - - README.md - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.6.1 - - 1.8 - 1.8 - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.0.2 - - UTF-8 - - - - org.apache.maven.plugins - maven-shade-plugin - 3.0.0 - - false - - - org.mcstats.*:* - - - - - - package - - shade - - - - - - - - Jenkins - http://ci.frog.gg/jenkins/job/PermissionsTime/ - + + 4.0.0 + gg.frog.mc + permissionstime + 0.2.4-SNAPSHOT + jar + PermissionsTime + 支持跨服的权限限时插件 + + https://github.com/geekfrog + GeekFrog + + https://github.com/geekfrog/PermissionsTime/ + + UTF-8 + + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + dakani + Dakani Nexus Repo + https://repo.dakanilabs.com/repository/public/ + + + vault-repo + http://nexus.hc.to/content/repositories/pub_releases/ + + + bstats-repo + http://repo.bstats.org/content/repositories/releases/ + + + + + org.bukkit + bukkit + 1.9-R0.1-SNAPSHOT + jar + compile + + + org.bstats + bstats-bukkit + 1.2 + + + net.milkbowl.vault + VaultAPI + 1.6 + provided + + + lib.PatPeter.SQLibrary + SQLibrary + 7.1 + + + + PermissionsTime-${project.version} + ${basedir}/src/main + + + src/resources + + + . + true + ${basedir} + + README.md + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.2 + + UTF-8 + + + + org.apache.maven.plugins + maven-shade-plugin + 3.0.0 + + false + + + org.bstats:* + + + + + org.bstats + + gg.frog.mc.permissionstime + + + + + + package + + shade + + + + + + + + Jenkins + http://ci.frog.gg/jenkins/job/PermissionsTime/ + diff --git a/src/main/gg/frog/mc/permissionstime/PluginMain.java b/src/main/gg/frog/mc/permissionstime/PluginMain.java index 2df511f..ec4ce87 100644 --- a/src/main/gg/frog/mc/permissionstime/PluginMain.java +++ b/src/main/gg/frog/mc/permissionstime/PluginMain.java @@ -5,6 +5,7 @@ import java.util.Locale; import java.util.UUID; import java.util.logging.Logger; +import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.plugin.RegisteredServiceProvider; @@ -41,7 +42,6 @@ public class PluginMain extends JavaPlugin { @Override public void onEnable() { - super.onEnable(); pm = this; cm = new ConfigManager(pm); getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "===============================")); @@ -64,8 +64,8 @@ public class PluginMain extends JavaPlugin { } if (PluginCfg.IS_METRICS) { try { - org.mcstats.Metrics mcstats = new org.mcstats.Metrics(pm); - mcstats.start(); + Metrics metrics = new Metrics(pm); +// metrics.addCustomChart(new Metrics.SimplePie("chart_id", () -> "My value")); } catch (Exception e) { e.printStackTrace(); } @@ -132,7 +132,6 @@ public class PluginMain extends JavaPlugin { @Override public void onDisable() { - super.onDisable(); getServer().getServicesManager().unregisterAll(pm); Bukkit.getScheduler().cancelTasks(pm); try { diff --git a/src/main/gg/frog/mc/permissionstime/utils/FileUtil.java b/src/main/gg/frog/mc/permissionstime/utils/FileUtil.java index b99ba99..2447ee8 100644 --- a/src/main/gg/frog/mc/permissionstime/utils/FileUtil.java +++ b/src/main/gg/frog/mc/permissionstime/utils/FileUtil.java @@ -4,57 +4,61 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; +import java.net.URLDecoder; +import java.nio.charset.Charset; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; public class FileUtil { - public interface FindFilesDo { - boolean isProcess(String fileName); - void process(String fileName, InputStream is); - } + public interface FindFilesDo { + boolean isProcess(String fileName); - public static void findFilesFromJar(FindFilesDo ffd, Class jarClazz) { - JarFile jarFile = null; - try { - String jarFilePath = jarClazz.getProtectionDomain().getCodeSource().getLocation().getFile(); - jarFile = new JarFile(jarFilePath); - Enumeration entries = jarFile.entries(); - while (entries.hasMoreElements()) { - JarEntry e = entries.nextElement(); - if (ffd.isProcess(e.getName())) { - InputStream is = jarFile.getInputStream(e); - ffd.process(e.getName(), is); - try { - is.close(); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (jarFile != null) { - try { - jarFile.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } + void process(String fileName, InputStream is); + } - public static void writeOnFile(String fileName, String content) { - FileWriter fw; - try { - File f = new File(fileName); - fw = new FileWriter(f, true); - fw.write(content + "\r\n"); - fw.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } + public static void findFilesFromJar(FindFilesDo ffd, Class jarClazz) { + JarFile jarFile = null; + try { + String jarFilePath = jarClazz.getProtectionDomain().getCodeSource().getLocation().getFile(); + jarFilePath = URLDecoder.decode(jarFilePath, Charset.defaultCharset().name()); + jarFile = new JarFile(jarFilePath); + Enumeration entries = jarFile.entries(); + while (entries.hasMoreElements()) { + JarEntry e = entries.nextElement(); + if (ffd.isProcess(e.getName())) { + InputStream is = jarFile.getInputStream(e); + ffd.process(e.getName(), is); + try { + is.close(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (jarFile != null) { + try { + jarFile.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + public static void writeOnFile(String fileName, String content) { + FileWriter fw; + try { + File f = new File(fileName); + fw = new FileWriter(f, true); + fw.write(content + "\r\n"); + fw.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/src/resources/plugin.yml b/src/resources/plugin.yml index 049333b..a3643fa 100644 --- a/src/resources/plugin.yml +++ b/src/resources/plugin.yml @@ -1,5 +1,5 @@ name: PermissionsTime -version: 0.2.3-SNAPSHOT +version: 0.2.4-SNAPSHOT main: gg.frog.mc.permissionstime.PluginMain author: GeekFrog softdepend: