public class MetricsLite
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
BASE_URL
The base url of the metrics domain
|
private org.bukkit.configuration.file.YamlConfiguration |
configuration
The plugin configuration file
|
private java.io.File |
configurationFile
The plugin configuration file
|
private boolean |
debug
Debug mode
|
private java.lang.String |
guid
Unique server id
|
private java.lang.Object |
optOutLock
Lock for synchronization
|
private static int |
PING_INTERVAL
Interval of time to ping (in minutes)
|
private org.bukkit.plugin.Plugin |
plugin
The plugin this metrics submits for
|
private static java.lang.String |
REPORT_URL
The url used to report a server's status
|
private static int |
REVISION
The current revision number
|
private org.bukkit.scheduler.BukkitTask |
task
Id of the scheduled task
|
Constructor and Description |
---|
MetricsLite(org.bukkit.plugin.Plugin plugin) |
Modifier and Type | Method and Description |
---|---|
void |
disable()
Disables metrics for the server by setting "opt-out" to true in the
config file and canceling the metrics task.
|
void |
enable()
Enables metrics for the server by setting "opt-out" to false in the
config file and starting the metrics task.
|
private static java.lang.String |
encode(java.lang.String text)
Encode text as UTF-8
|
private static void |
encodeDataPair(java.lang.StringBuilder buffer,
java.lang.String key,
java.lang.String value)
Encode a key/value data pair to be used in a HTTP post request.
|
java.io.File |
getConfigFile()
Gets the File object of the config file that should be used to store data
such as the GUID and opt-out status
|
private boolean |
isMineshafterPresent()
Check if mineshafter is present.
|
boolean |
isOptOut()
Has the server owner denied plugin metrics?
|
private void |
postPlugin(boolean isPing)
Generic method that posts a plugin to the metrics website
|
boolean |
start()
Start measuring statistics.
|
private static final int REVISION
private static final java.lang.String BASE_URL
private static final java.lang.String REPORT_URL
private static final int PING_INTERVAL
private final org.bukkit.plugin.Plugin plugin
private final org.bukkit.configuration.file.YamlConfiguration configuration
private final java.io.File configurationFile
private final java.lang.String guid
private final boolean debug
private final java.lang.Object optOutLock
private volatile org.bukkit.scheduler.BukkitTask task
public MetricsLite(org.bukkit.plugin.Plugin plugin) throws java.io.IOException
java.io.IOException
private static java.lang.String encode(java.lang.String text) throws java.io.UnsupportedEncodingException
text
- the text to encodejava.io.UnsupportedEncodingException
private static void encodeDataPair(java.lang.StringBuilder buffer, java.lang.String key, java.lang.String value) throws java.io.UnsupportedEncodingException
Encode a key/value data pair to be used in a HTTP post request. This INCLUDES a & so the first key/value pair MUST be included manually, e.g:
StringBuffer data = new StringBuffer();
data.append(encode("guid")).append('=').append(encode(guid));
encodeDataPair(data, "version", description.getVersion());
buffer
- the stringbuilder to append the data pair ontokey
- the key valuevalue
- the valuejava.io.UnsupportedEncodingException
public void disable() throws java.io.IOException
java.io.IOException
public void enable() throws java.io.IOException
java.io.IOException
public java.io.File getConfigFile()
private boolean isMineshafterPresent()
public boolean isOptOut()
private void postPlugin(boolean isPing) throws java.io.IOException
java.io.IOException
public boolean start()