Add repos, update dependencies, set compiler version
This commit is contained in:
parent
122d9fe5cc
commit
7fa3cc114b
BIN
Factions.jar
BIN
Factions.jar
Binary file not shown.
33
pom.xml
33
pom.xml
@ -25,6 +25,15 @@
|
|||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>2.0.2</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.6</source>
|
||||||
|
<target>1.6</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
@ -51,22 +60,40 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<releases>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
</snapshots>
|
||||||
|
<id>bukkit-repo</id>
|
||||||
|
<url>http://repo.bukkit.org/content/repositories/releases/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<releases>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
</snapshots>
|
||||||
|
<id>dynmap-repo</id>
|
||||||
|
<url>http://repo.mikeprimm.com/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dynmap</groupId>
|
<groupId>org.dynmap</groupId>
|
||||||
<artifactId>dynmap-api</artifactId>
|
<artifactId>dynmap-api</artifactId>
|
||||||
<version>[0.70,)</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>[1.3.1-R1.0,1.7)</version>
|
<version>1.4.5-R1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.massivecraft</groupId>
|
<groupId>com.massivecraft</groupId>
|
||||||
<artifactId>Factions</artifactId>
|
<artifactId>Factions</artifactId>
|
||||||
<version>1.7.7</version>
|
<version>1.8.0</version>
|
||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${project.basedir}/Factions.jar</systemPath>
|
<systemPath>${project.basedir}/Factions.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -26,13 +26,14 @@
|
|||||||
* either expressed or implied, of anybody else.
|
* either expressed or implied, of anybody else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.dynmap.factions;
|
package org.mcstats;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -52,7 +53,7 @@ public class MetricsLite {
|
|||||||
/**
|
/**
|
||||||
* The current revision number
|
* The current revision number
|
||||||
*/
|
*/
|
||||||
private final static int REVISION = 5;
|
private final static int REVISION = 6;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base url of the metrics domain
|
* The base url of the metrics domain
|
||||||
@ -89,6 +90,11 @@ public class MetricsLite {
|
|||||||
*/
|
*/
|
||||||
private final String guid;
|
private final String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debug mode
|
||||||
|
*/
|
||||||
|
private final boolean debug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lock for synchronization
|
* Lock for synchronization
|
||||||
*/
|
*/
|
||||||
@ -97,7 +103,7 @@ public class MetricsLite {
|
|||||||
/**
|
/**
|
||||||
* Id of the scheduled task
|
* Id of the scheduled task
|
||||||
*/
|
*/
|
||||||
private volatile int taskId = -1;
|
private volatile BukkitTask task = null;
|
||||||
|
|
||||||
public MetricsLite(Plugin plugin) throws IOException {
|
public MetricsLite(Plugin plugin) throws IOException {
|
||||||
if (plugin == null) {
|
if (plugin == null) {
|
||||||
@ -113,6 +119,7 @@ public class MetricsLite {
|
|||||||
// add some defaults
|
// add some defaults
|
||||||
configuration.addDefault("opt-out", false);
|
configuration.addDefault("opt-out", false);
|
||||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||||
|
configuration.addDefault("debug", false);
|
||||||
|
|
||||||
// Do we need to create the file?
|
// Do we need to create the file?
|
||||||
if (configuration.get("guid", null) == null) {
|
if (configuration.get("guid", null) == null) {
|
||||||
@ -122,6 +129,7 @@ public class MetricsLite {
|
|||||||
|
|
||||||
// Load the guid then
|
// Load the guid then
|
||||||
guid = configuration.getString("guid");
|
guid = configuration.getString("guid");
|
||||||
|
debug = configuration.getBoolean("debug", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,12 +147,12 @@ public class MetricsLite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Is metrics already running?
|
// Is metrics already running?
|
||||||
if (taskId >= 0) {
|
if (task != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Begin hitting the server with glorious data
|
// Begin hitting the server with glorious data
|
||||||
taskId = plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
|
task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
private boolean firstPost = true;
|
private boolean firstPost = true;
|
||||||
|
|
||||||
@ -153,9 +161,9 @@ public class MetricsLite {
|
|||||||
// This has to be synchronized or it can collide with the disable method.
|
// This has to be synchronized or it can collide with the disable method.
|
||||||
synchronized (optOutLock) {
|
synchronized (optOutLock) {
|
||||||
// Disable Task, if it is running and the server owner decided to opt-out
|
// Disable Task, if it is running and the server owner decided to opt-out
|
||||||
if (isOptOut() && taskId > 0) {
|
if (isOptOut() && task != null) {
|
||||||
plugin.getServer().getScheduler().cancelTask(taskId);
|
task.cancel();
|
||||||
taskId = -1;
|
task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +176,9 @@ public class MetricsLite {
|
|||||||
// Each post thereafter will be a ping
|
// Each post thereafter will be a ping
|
||||||
firstPost = false;
|
firstPost = false;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
//Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
if (debug) {
|
||||||
|
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0, PING_INTERVAL * 1200);
|
}, 0, PING_INTERVAL * 1200);
|
||||||
@ -188,10 +198,14 @@ public class MetricsLite {
|
|||||||
// Reload the metrics file
|
// Reload the metrics file
|
||||||
configuration.load(getConfigFile());
|
configuration.load(getConfigFile());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
if (debug) {
|
||||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (InvalidConfigurationException ex) {
|
} catch (InvalidConfigurationException ex) {
|
||||||
|
if (debug) {
|
||||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return configuration.getBoolean("opt-out", false);
|
return configuration.getBoolean("opt-out", false);
|
||||||
@ -201,7 +215,7 @@ public class MetricsLite {
|
|||||||
/**
|
/**
|
||||||
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws java.io.IOException
|
||||||
*/
|
*/
|
||||||
public void enable() throws IOException {
|
public void enable() throws IOException {
|
||||||
// This has to be synchronized or it can collide with the check in the task.
|
// This has to be synchronized or it can collide with the check in the task.
|
||||||
@ -213,7 +227,7 @@ public class MetricsLite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enable Task, if it is not running
|
// Enable Task, if it is not running
|
||||||
if (taskId < 0) {
|
if (task == null) {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,7 +236,7 @@ public class MetricsLite {
|
|||||||
/**
|
/**
|
||||||
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
|
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws java.io.IOException
|
||||||
*/
|
*/
|
||||||
public void disable() throws IOException {
|
public void disable() throws IOException {
|
||||||
// This has to be synchronized or it can collide with the check in the task.
|
// This has to be synchronized or it can collide with the check in the task.
|
||||||
@ -234,9 +248,9 @@ public class MetricsLite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Disable Task, if it is running
|
// Disable Task, if it is running
|
||||||
if (taskId > 0) {
|
if (task != null) {
|
||||||
this.plugin.getServer().getScheduler().cancelTask(taskId);
|
task.cancel();
|
||||||
taskId = -1;
|
task = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,24 +276,52 @@ public class MetricsLite {
|
|||||||
* Generic method that posts a plugin to the metrics website
|
* Generic method that posts a plugin to the metrics website
|
||||||
*/
|
*/
|
||||||
private void postPlugin(boolean isPing) throws IOException {
|
private void postPlugin(boolean isPing) throws IOException {
|
||||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
// Server software specific section
|
||||||
final PluginDescriptionFile description = plugin.getDescription();
|
PluginDescriptionFile description = plugin.getDescription();
|
||||||
|
String pluginName = description.getName();
|
||||||
|
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||||
|
String pluginVersion = description.getVersion();
|
||||||
|
String serverVersion = Bukkit.getVersion();
|
||||||
|
int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
|
||||||
|
|
||||||
|
// END server software specific section -- all code below does not use any code outside of this class / Java
|
||||||
|
|
||||||
// Construct the post data
|
// Construct the post data
|
||||||
final StringBuilder data = new StringBuilder();
|
final StringBuilder data = new StringBuilder();
|
||||||
|
|
||||||
|
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||||
data.append(encode("guid")).append('=').append(encode(guid));
|
data.append(encode("guid")).append('=').append(encode(guid));
|
||||||
encodeDataPair(data, "version", description.getVersion());
|
encodeDataPair(data, "version", pluginVersion);
|
||||||
encodeDataPair(data, "server", Bukkit.getVersion());
|
encodeDataPair(data, "server", serverVersion);
|
||||||
encodeDataPair(data, "players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length));
|
encodeDataPair(data, "players", Integer.toString(playersOnline));
|
||||||
encodeDataPair(data, "revision", String.valueOf(REVISION));
|
encodeDataPair(data, "revision", String.valueOf(REVISION));
|
||||||
|
|
||||||
|
// New data as of R6
|
||||||
|
String osname = System.getProperty("os.name");
|
||||||
|
String osarch = System.getProperty("os.arch");
|
||||||
|
String osversion = System.getProperty("os.version");
|
||||||
|
String java_version = System.getProperty("java.version");
|
||||||
|
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||||
|
|
||||||
|
// normalize os arch .. amd64 -> x86_64
|
||||||
|
if (osarch.equals("amd64")) {
|
||||||
|
osarch = "x86_64";
|
||||||
|
}
|
||||||
|
|
||||||
|
encodeDataPair(data, "osname", osname);
|
||||||
|
encodeDataPair(data, "osarch", osarch);
|
||||||
|
encodeDataPair(data, "osversion", osversion);
|
||||||
|
encodeDataPair(data, "cores", Integer.toString(coreCount));
|
||||||
|
encodeDataPair(data, "online-mode", Boolean.toString(onlineMode));
|
||||||
|
encodeDataPair(data, "java_version", java_version);
|
||||||
|
|
||||||
// If we're pinging, append it
|
// If we're pinging, append it
|
||||||
if (isPing) {
|
if (isPing) {
|
||||||
encodeDataPair(data, "ping", "true");
|
encodeDataPair(data, "ping", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the url
|
// Create the url
|
||||||
URL url = new URL(BASE_URL + String.format(REPORT_URL, encode(plugin.getDescription().getName())));
|
URL url = new URL(BASE_URL + String.format(REPORT_URL, encode(pluginName)));
|
||||||
|
|
||||||
// Connect to the website
|
// Connect to the website
|
||||||
URLConnection connection;
|
URLConnection connection;
|
||||||
@ -310,7 +352,6 @@ public class MetricsLite {
|
|||||||
if (response == null || response.startsWith("ERR")) {
|
if (response == null || response.startsWith("ERR")) {
|
||||||
throw new IOException(response); //Throw the exception
|
throw new IOException(response); //Throw the exception
|
||||||
}
|
}
|
||||||
//if (response.startsWith("OK")) - We should get "OK" followed by an optional description if everything goes right
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user