From 405deda1d5629e374cdd1d05e45bacce2454fc76 Mon Sep 17 00:00:00 2001 From: GeekFrog Date: Mon, 10 Jul 2017 13:06:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BB=9F=E8=AE=A1=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 39 +++++++++++++++++- .../frog/mc/permissionstime/PluginMain.java | 41 ++++++++++++++----- .../mc/permissionstime/config/PluginCfg.java | 3 ++ 3 files changed, 70 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 7a1969d..ad9b606 100644 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,10 @@ vault-repo http://nexus.hc.to/content/repositories/pub_releases/ + + Plugin Metrics + http://repo.mcstats.org/content/repositories/public + @@ -36,7 +40,13 @@ bukkit 1.11.2-R0.1-SNAPSHOT jar - provided + compile + + + org.mcstats.bukkit + metrics + R8-SNAPSHOT + compile net.milkbowl.vault @@ -49,7 +59,6 @@ SQLibrary 7.1 - PermissionsTime-${project.version} @@ -98,6 +107,32 @@ UTF-8 + + org.apache.maven.plugins + maven-shade-plugin + 3.0.0 + + + + org.mcstats.*:* + + + + + org.mcstats + gg.frog.mc.permissionstime + + + + + + package + + shade + + + + diff --git a/src/main/gg/frog/mc/permissionstime/PluginMain.java b/src/main/gg/frog/mc/permissionstime/PluginMain.java index 3953684..072f9f3 100644 --- a/src/main/gg/frog/mc/permissionstime/PluginMain.java +++ b/src/main/gg/frog/mc/permissionstime/PluginMain.java @@ -2,7 +2,9 @@ package gg.frog.mc.permissionstime; import java.util.Locale; import java.util.logging.Logger; + import org.bukkit.plugin.java.JavaPlugin; +import org.mcstats.Metrics; import gg.frog.mc.permissionstime.command.TheCommand; import gg.frog.mc.permissionstime.config.ConfigManager; @@ -22,17 +24,29 @@ public class PluginMain extends JavaPlugin { @Override public void onEnable() { - pm = this; - cm = new ConfigManager(); - registerListeners(); - registerCommands(); - pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "===============================")); - pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX)); - pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " " + PluginMain.PLUGIN_NAME + " v" + PluginMain.PLUGIN_VERSION)); - pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " author:GeekFrog QQ:324747460")); - pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " https://github.com/geekfrog/PermissionsTime/ ")); - pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX)); - pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "===============================")); + if (!checkPluginDepends()) { + + } else { + pm = this; + cm = new ConfigManager(); + registerListeners(); + registerCommands(); + pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "===============================")); + pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX)); + pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " " + PluginMain.PLUGIN_NAME + " v" + PluginMain.PLUGIN_VERSION)); + pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " author:GeekFrog QQ:324747460")); + pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " https://github.com/geekfrog/PermissionsTime/ ")); + pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX)); + pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "===============================")); + if(PluginCfg.IS_METRICS){ + try { + Metrics metrics = new Metrics(this); + metrics.start(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } } public static PluginMain getInstance() { @@ -58,4 +72,9 @@ public class PluginMain extends JavaPlugin { public ConfigManager getConfigManager() { return cm; } + + private boolean checkPluginDepends() { + // return false; + return true; + } } diff --git a/src/main/gg/frog/mc/permissionstime/config/PluginCfg.java b/src/main/gg/frog/mc/permissionstime/config/PluginCfg.java index 78453df..19a2e06 100644 --- a/src/main/gg/frog/mc/permissionstime/config/PluginCfg.java +++ b/src/main/gg/frog/mc/permissionstime/config/PluginCfg.java @@ -12,6 +12,7 @@ import gg.frog.mc.permissionstime.utils.config.PluginConfig; public class PluginCfg extends PluginConfig { public static String PLUGIN_PREFIX = null; + public static Boolean IS_METRICS = null; public static Boolean IS_DEBUG = null; public static String LANG = null; public static String SQL_HOSTNAME; @@ -27,6 +28,7 @@ public class PluginCfg extends PluginConfig { @Override protected void init() { getConfig().set("lang","zh-cn"); + getConfig().set("metrics", true); getConfig().set("debug", false); saveConfig(); } @@ -35,6 +37,7 @@ public class PluginCfg extends PluginConfig { protected void loadToDo() { PLUGIN_PREFIX = getConfig().getString("pluginPrefix","&b["+PluginMain.PLUGIN_NAME+"]&r"); IS_DEBUG = getConfig().getBoolean("debug", false); + IS_METRICS = getConfig().getBoolean("metrics", true); LANG = getConfig().getString("lang","zh-cn"); }