forked from xjboss/KCauldronX
move statistics class to kcauldronx package
This commit is contained in:
parent
a99c7d39ba
commit
823599a9ec
@ -8,7 +8,16 @@
|
|||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -34,9 +35,24 @@
|
@@ -14,6 +15,8 @@
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
+
|
||||||
|
+import kcauldronx.YUMCStatistics;
|
||||||
|
import net.minecraft.command.ICommandSender;
|
||||||
|
import net.minecraft.command.ServerCommand;
|
||||||
|
import net.minecraft.crash.CrashReport;
|
||||||
|
@@ -34,9 +37,23 @@
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldSettings;
|
import net.minecraft.world.WorldSettings;
|
||||||
import net.minecraft.world.WorldType;
|
import net.minecraft.world.WorldType;
|
||||||
@ -27,13 +36,12 @@
|
|||||||
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
||||||
+import org.bukkit.event.player.PlayerLoginEvent;
|
+import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
+import org.bukkit.event.server.ServerCommandEvent;
|
+import org.bukkit.event.server.ServerCommandEvent;
|
||||||
+import pw.yumc.KCXStatistics;
|
|
||||||
+// CraftBukkit end
|
+// CraftBukkit end
|
||||||
+
|
+
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
public class DedicatedServer extends MinecraftServer implements IServer
|
public class DedicatedServer extends MinecraftServer implements IServer
|
||||||
{
|
{
|
||||||
@@ -44,18 +60,21 @@
|
@@ -44,18 +61,21 @@
|
||||||
public final List pendingCommandList = Collections.synchronizedList(new ArrayList());
|
public final List pendingCommandList = Collections.synchronizedList(new ArrayList());
|
||||||
private RConThreadQuery theRConThreadQuery;
|
private RConThreadQuery theRConThreadQuery;
|
||||||
private RConThreadMain theRConThreadMain;
|
private RConThreadMain theRConThreadMain;
|
||||||
@ -47,7 +55,7 @@
|
|||||||
private static final String __OBFID = "CL_00001784";
|
private static final String __OBFID = "CL_00001784";
|
||||||
-
|
-
|
||||||
- public DedicatedServer(File p_i1508_1_)
|
- public DedicatedServer(File p_i1508_1_)
|
||||||
+ private KCXStatistics yumc_statistics;
|
+ private YUMCStatistics yumc_statistics;
|
||||||
+ // CraftBukkit start - Signature changed
|
+ // CraftBukkit start - Signature changed
|
||||||
+ public DedicatedServer(joptsimple.OptionSet options)
|
+ public DedicatedServer(joptsimple.OptionSet options)
|
||||||
{
|
{
|
||||||
@ -60,7 +68,7 @@
|
|||||||
{
|
{
|
||||||
private static final String __OBFID = "CL_00001787";
|
private static final String __OBFID = "CL_00001787";
|
||||||
{
|
{
|
||||||
@@ -82,31 +101,77 @@
|
@@ -82,31 +102,77 @@
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +153,7 @@
|
|||||||
field_155771_h.info("Starting minecraft server version 1.7.10");
|
field_155771_h.info("Starting minecraft server version 1.7.10");
|
||||||
|
|
||||||
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L)
|
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L)
|
||||||
@@ -117,7 +182,7 @@
|
@@ -117,7 +183,7 @@
|
||||||
FMLCommonHandler.instance().onServerStart(this);
|
FMLCommonHandler.instance().onServerStart(this);
|
||||||
|
|
||||||
field_155771_h.info("Loading properties");
|
field_155771_h.info("Loading properties");
|
||||||
@ -154,7 +162,7 @@
|
|||||||
this.field_154332_n = new ServerEula(new File("eula.txt"));
|
this.field_154332_n = new ServerEula(new File("eula.txt"));
|
||||||
|
|
||||||
if (!this.field_154332_n.func_154346_a())
|
if (!this.field_154332_n.func_154346_a())
|
||||||
@@ -172,6 +237,18 @@
|
@@ -172,6 +238,18 @@
|
||||||
this.setServerPort(this.settings.getIntProperty("server-port", 25565));
|
this.setServerPort(this.settings.getIntProperty("server-port", 25565));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +181,7 @@
|
|||||||
field_155771_h.info("Generating keypair");
|
field_155771_h.info("Generating keypair");
|
||||||
this.setKeyPair(CryptManager.createNewKeyPair());
|
this.setKeyPair(CryptManager.createNewKeyPair());
|
||||||
field_155771_h.info("Starting Minecraft server on " + (this.getServerHostname().length() == 0 ? "*" : this.getServerHostname()) + ":" + this.getServerPort());
|
field_155771_h.info("Starting Minecraft server on " + (this.getServerHostname().length() == 0 ? "*" : this.getServerHostname()) + ":" + this.getServerPort());
|
||||||
@@ -180,7 +257,7 @@
|
@@ -180,7 +258,7 @@
|
||||||
{
|
{
|
||||||
this.func_147137_ag().addLanEndpoint(inetaddress, this.getServerPort());
|
this.func_147137_ag().addLanEndpoint(inetaddress, this.getServerPort());
|
||||||
}
|
}
|
||||||
@ -182,7 +190,7 @@
|
|||||||
{
|
{
|
||||||
field_155771_h.warn("**** FAILED TO BIND TO PORT!");
|
field_155771_h.warn("**** FAILED TO BIND TO PORT!");
|
||||||
field_155771_h.warn("The exception was: {}", new Object[] {ioexception.toString()});
|
field_155771_h.warn("The exception was: {}", new Object[] {ioexception.toString()});
|
||||||
@@ -196,10 +273,17 @@
|
@@ -196,10 +274,17 @@
|
||||||
field_155771_h.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
|
field_155771_h.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +210,7 @@
|
|||||||
|
|
||||||
if (!PreYggdrasilConverter.func_152714_a(this.settings))
|
if (!PreYggdrasilConverter.func_152714_a(this.settings))
|
||||||
{
|
{
|
||||||
@@ -208,7 +292,8 @@
|
@@ -208,7 +293,8 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FMLCommonHandler.instance().onServerStarted();
|
FMLCommonHandler.instance().onServerStarted();
|
||||||
@ -212,7 +220,7 @@
|
|||||||
long j = System.nanoTime();
|
long j = System.nanoTime();
|
||||||
|
|
||||||
if (this.getFolderName() == null)
|
if (this.getFolderName() == null)
|
||||||
@@ -274,11 +359,40 @@
|
@@ -274,11 +360,40 @@
|
||||||
this.theRConThreadMain.startThread();
|
this.theRConThreadMain.startThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +242,7 @@
|
|||||||
+ FakePlayer.fakePlayers=null;
|
+ FakePlayer.fakePlayers=null;
|
||||||
+ FakePlayer.BukkitInited=true;
|
+ FakePlayer.BukkitInited=true;
|
||||||
+ //Yumc Statistcs start
|
+ //Yumc Statistcs start
|
||||||
+ yumc_statistics=new KCXStatistics();
|
+ yumc_statistics=new YUMCStatistics();
|
||||||
+ yumc_statistics.start();
|
+ yumc_statistics.start();
|
||||||
+ //Yumc Statistcs end
|
+ //Yumc Statistcs end
|
||||||
+ // KCauldronX end
|
+ // KCauldronX end
|
||||||
@ -253,7 +261,7 @@
|
|||||||
public boolean canStructuresSpawn()
|
public boolean canStructuresSpawn()
|
||||||
{
|
{
|
||||||
return this.canSpawnStructures;
|
return this.canSpawnStructures;
|
||||||
@@ -364,11 +478,19 @@
|
@@ -364,11 +479,19 @@
|
||||||
|
|
||||||
public void executePendingCommands()
|
public void executePendingCommands()
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ import cpw.mods.fml.common.FMLLog;
|
|||||||
|
|
||||||
public class KCauldron {
|
public class KCauldron {
|
||||||
public static final ThreadGroup sKCauldronThreadGroup = new ThreadGroup("KCauldron");
|
public static final ThreadGroup sKCauldronThreadGroup = new ThreadGroup("KCauldron");
|
||||||
|
public static final String name="KCauldronX";
|
||||||
private static boolean sManifestParsed = false;
|
private static boolean sManifestParsed = false;
|
||||||
|
|
||||||
private static void parseManifest() {
|
private static void parseManifest() {
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package org.bstats;
|
package kcauldronx;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import kcauldron.KCauldron;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.ServicePriority;
|
import org.bukkit.plugin.ServicePriority;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
@ -62,26 +61,33 @@ public class BMetrics {
|
|||||||
|
|
||||||
// The uuid of the server
|
// The uuid of the server
|
||||||
private static String serverUUID;
|
private static String serverUUID;
|
||||||
|
|
||||||
// The plugin
|
|
||||||
private final JavaPlugin plugin;
|
|
||||||
|
|
||||||
// A list with all custom charts
|
// A list with all custom charts
|
||||||
private final List<CustomChart> charts = new ArrayList<>();
|
private final List<CustomChart> charts = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the File object of the config file that should be used to store data such as the GUID and opt-out status
|
||||||
|
*
|
||||||
|
* @return the File object for the config file
|
||||||
|
*/
|
||||||
|
public File getConfigFile() {
|
||||||
|
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
|
||||||
|
// is to abuse the plugin object we already have
|
||||||
|
// plugin.getDataFolder() => base/plugins/PluginA/
|
||||||
|
// pluginsFolder => base/plugins/
|
||||||
|
// The base is not necessarily relative to the startup directory.
|
||||||
|
// File pluginsFolder = plugin.getDataFolder().getParentFile();
|
||||||
|
|
||||||
|
// return => base/plugins/PluginMetrics/config.yml
|
||||||
|
return new File(new File((File) net.minecraft.server.MinecraftServer.getServer().options.valueOf("plugins"), "PluginMetrics"), "config.yml");
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Class constructor.
|
* Class constructor.
|
||||||
*
|
*
|
||||||
* @param plugin The plugin which stats should be submitted.
|
* @param plugin The plugin which stats should be submitted.
|
||||||
*/
|
*/
|
||||||
public BMetrics(JavaPlugin plugin) {
|
public BMetrics() {
|
||||||
if (plugin == null) {
|
|
||||||
throw new IllegalArgumentException("Plugin cannot be null!");
|
|
||||||
}
|
|
||||||
this.plugin = plugin;
|
|
||||||
|
|
||||||
// Get the config file
|
// Get the config file
|
||||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
File bStatsFolder = new File(getConfigFile(), "bStats");
|
||||||
File configFile = new File(bStatsFolder, "config.yml");
|
File configFile = new File(bStatsFolder, "config.yml");
|
||||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
|
|
||||||
@ -111,21 +117,8 @@ public class BMetrics {
|
|||||||
serverUUID = config.getString("serverUuid");
|
serverUUID = config.getString("serverUuid");
|
||||||
logFailedRequests = config.getBoolean("logFailedRequests", false);
|
logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||||
if (config.getBoolean("enabled", true)) {
|
if (config.getBoolean("enabled", true)) {
|
||||||
boolean found = false;
|
Bukkit.getServicesManager().getKnownServices().add(BMetrics.class);
|
||||||
// Search for all other bStats Metrics classes to see if we are the first one
|
startSubmitting();
|
||||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
|
||||||
try {
|
|
||||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
|
||||||
found = true; // We aren't the first
|
|
||||||
break;
|
|
||||||
} catch (NoSuchFieldException ignored) { }
|
|
||||||
}
|
|
||||||
// Register our service
|
|
||||||
Bukkit.getServicesManager().register(BMetrics.class, this, plugin, ServicePriority.Normal);
|
|
||||||
if (!found) {
|
|
||||||
// We are the first!
|
|
||||||
startSubmitting();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,13 +142,9 @@ public class BMetrics {
|
|||||||
timer.scheduleAtFixedRate(new TimerTask() {
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!plugin.isEnabled()) { // Plugin was disabled
|
|
||||||
timer.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
|
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
|
||||||
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
|
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
|
||||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
FMLCommonHandler.instance().getMinecraftServerInstance().processQueue.add(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
submitData();
|
submitData();
|
||||||
@ -177,8 +166,8 @@ public class BMetrics {
|
|||||||
public JSONObject getPluginData() {
|
public JSONObject getPluginData() {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
|
|
||||||
String pluginName = plugin.getDescription().getName();
|
String pluginName = KCauldron.name;
|
||||||
String pluginVersion = plugin.getDescription().getVersion();
|
String pluginVersion = KCauldron.getCurrentVersion();
|
||||||
|
|
||||||
data.put("pluginName", pluginName); // Append the name of the plugin
|
data.put("pluginName", pluginName); // Append the name of the plugin
|
||||||
data.put("pluginVersion", pluginVersion); // Append the version of the plugin
|
data.put("pluginVersion", pluginVersion); // Append the version of the plugin
|
||||||
@ -203,17 +192,7 @@ public class BMetrics {
|
|||||||
*/
|
*/
|
||||||
private JSONObject getServerData() {
|
private JSONObject getServerData() {
|
||||||
// Minecraft specific data
|
// Minecraft specific data
|
||||||
int playerAmount;
|
int playerAmount=Bukkit.getServer().getOnlinePlayers().size();
|
||||||
try {
|
|
||||||
// Around MC 1.8 the return type was changed to a collection from an array,
|
|
||||||
// This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
|
|
||||||
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
|
|
||||||
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
|
|
||||||
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
|
|
||||||
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
|
||||||
} catch (Exception e) {
|
|
||||||
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
|
|
||||||
}
|
|
||||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||||
String bukkitVersion = org.bukkit.Bukkit.getVersion();
|
String bukkitVersion = org.bukkit.Bukkit.getVersion();
|
||||||
bukkitVersion = bukkitVersion.substring(bukkitVersion.indexOf("MC: ") + 4, bukkitVersion.length() - 1);
|
bukkitVersion = bukkitVersion.substring(bukkitVersion.indexOf("MC: ") + 4, bukkitVersion.length() - 1);
|
||||||
@ -247,23 +226,8 @@ public class BMetrics {
|
|||||||
*/
|
*/
|
||||||
private void submitData() {
|
private void submitData() {
|
||||||
final JSONObject data = getServerData();
|
final JSONObject data = getServerData();
|
||||||
|
|
||||||
JSONArray pluginData = new JSONArray();
|
JSONArray pluginData = new JSONArray();
|
||||||
// Search for all other bStats Metrics classes to get their plugin data
|
|
||||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
|
||||||
try {
|
|
||||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
|
||||||
|
|
||||||
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
|
|
||||||
try {
|
|
||||||
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
|
|
||||||
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
|
|
||||||
}
|
|
||||||
} catch (NoSuchFieldException ignored) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
data.put("plugins", pluginData);
|
data.put("plugins", pluginData);
|
||||||
|
|
||||||
// Create a new thread for the connection to the bStats server
|
// Create a new thread for the connection to the bStats server
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -272,10 +236,6 @@ public class BMetrics {
|
|||||||
// Send the data
|
// Send the data
|
||||||
sendData(data);
|
sendData(data);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Something went wrong! :(
|
|
||||||
if (logFailedRequests) {
|
|
||||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2015 喵♂呜. All rights reserved.
|
* Copyright 2011-2015 喵♂呜. All rights reserved.
|
||||||
*/
|
*/
|
||||||
package pw.yumc;
|
package kcauldronx;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -43,7 +43,7 @@ import org.json.simple.JSONValue;
|
|||||||
* @since 2015年12月14日 下午1:36:42
|
* @since 2015年12月14日 下午1:36:42
|
||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
*/
|
*/
|
||||||
public class KCXStatistics {
|
public class YUMCStatistics {
|
||||||
/**
|
/**
|
||||||
* 统计系统版本
|
* 统计系统版本
|
||||||
*/
|
*/
|
||||||
@ -85,7 +85,7 @@ public class KCXStatistics {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
* IO异常
|
* IO异常
|
||||||
*/
|
*/
|
||||||
public KCXStatistics() {
|
public YUMCStatistics() {
|
||||||
try {
|
try {
|
||||||
if (!configfile.exists()) {
|
if (!configfile.exists()) {
|
||||||
configfile.getParentFile().mkdirs();
|
configfile.getParentFile().mkdirs();
|
||||||
@ -179,7 +179,7 @@ public class KCXStatistics {
|
|||||||
*/
|
*/
|
||||||
public void print(final String msg) {
|
public void print(final String msg) {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
System.out.println("[KCXStatistics] " + msg);
|
System.out.println("[YUMCStatistics] " + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ public class KCXStatistics {
|
|||||||
*/
|
*/
|
||||||
private void postPlugin() throws IOException {
|
private void postPlugin() throws IOException {
|
||||||
// 服务器数据获取
|
// 服务器数据获取
|
||||||
final String pluginname = "KCauldronX";
|
final String pluginname = KCauldron.name;
|
||||||
final String tmposarch = System.getProperty("os.arch");
|
final String tmposarch = System.getProperty("os.arch");
|
||||||
|
|
||||||
final Map<String, Object> data = new HashMap();
|
final Map<String, Object> data = new HashMap();
|
@ -28,6 +28,7 @@
|
|||||||
package org.spigotmc;
|
package org.spigotmc;
|
||||||
|
|
||||||
import kcauldron.KCauldron;
|
import kcauldron.KCauldron;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
@ -336,7 +337,7 @@ public class Metrics {
|
|||||||
// File pluginsFolder = plugin.getDataFolder().getParentFile();
|
// File pluginsFolder = plugin.getDataFolder().getParentFile();
|
||||||
|
|
||||||
// return => base/plugins/PluginMetrics/config.yml
|
// return => base/plugins/PluginMetrics/config.yml
|
||||||
return new File(new File((File) net.minecraft.server.MinecraftServer.getServer().options.valueOf("plugins"), "PluginMetrics"), "config.yml");
|
return new File(new File((File) MinecraftServer.getServer().options.valueOf("plugins"), "PluginMetrics"), "config.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -344,7 +345,7 @@ public class Metrics {
|
|||||||
*/
|
*/
|
||||||
private void postPlugin(final boolean isPing) throws IOException {
|
private void postPlugin(final boolean isPing) throws IOException {
|
||||||
// Server software specific section
|
// Server software specific section
|
||||||
String pluginName = "KCauldronX";
|
String pluginName = KCauldron.name;
|
||||||
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||||
String pluginVersion = (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown";
|
String pluginVersion = (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown";
|
||||||
String serverVersion = KCauldron.getCurrentVersion();
|
String serverVersion = KCauldron.getCurrentVersion();
|
||||||
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import kcauldronx.BMetrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -20,7 +21,6 @@ import com.google.common.base.Throwables;
|
|||||||
|
|
||||||
import gnu.trove.map.hash.TObjectIntHashMap;
|
import gnu.trove.map.hash.TObjectIntHashMap;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import pw.yumc.KCXStatistics;
|
|
||||||
|
|
||||||
public class SpigotConfig
|
public class SpigotConfig
|
||||||
{
|
{
|
||||||
@ -43,6 +43,7 @@ public class SpigotConfig
|
|||||||
static Map<String, Command> commands;
|
static Map<String, Command> commands;
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
private static Metrics metrics;
|
private static Metrics metrics;
|
||||||
|
private static BMetrics bstats;
|
||||||
|
|
||||||
public static void init()
|
public static void init()
|
||||||
{
|
{
|
||||||
@ -75,6 +76,17 @@ public class SpigotConfig
|
|||||||
Bukkit.getServer().getLogger().log( Level.SEVERE, "Could not start metrics service", ex );
|
Bukkit.getServer().getLogger().log( Level.SEVERE, "Could not start metrics service", ex );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( bstats == null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bstats = new BMetrics();
|
||||||
|
bstats.start();
|
||||||
|
} catch ( IOException ex )
|
||||||
|
{
|
||||||
|
Bukkit.getServer().getLogger().log( Level.SEVERE, "Could not start bstats metrics service", ex );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void readConfig(Class<?> clazz, Object instance)
|
static void readConfig(Class<?> clazz, Object instance)
|
||||||
|
Loading…
Reference in New Issue
Block a user