+ Added Custom Graph for MCStats.
This commit is contained in:
parent
57e01b75b7
commit
1697351805
@ -41,6 +41,7 @@ import nl.Steffion.BlockHunt.Managers.MessageM;
|
|||||||
import nl.Steffion.BlockHunt.Managers.PermissionsM;
|
import nl.Steffion.BlockHunt.Managers.PermissionsM;
|
||||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||||
import nl.Steffion.BlockHunt.mcstats.Metrics;
|
import nl.Steffion.BlockHunt.mcstats.Metrics;
|
||||||
|
import nl.Steffion.BlockHunt.mcstats.Metrics.Graph;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -79,6 +80,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public static PluginDescriptionFile pdfFile;
|
public static PluginDescriptionFile pdfFile;
|
||||||
|
public static BlockHunt plugin;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public static List<String> BlockHuntCMD = new ArrayList<String>() {
|
public static List<String> BlockHuntCMD = new ArrayList<String>() {
|
||||||
@ -117,7 +119,6 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
public static CommandM CMDtokens;
|
public static CommandM CMDtokens;
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(new OnBlockBreakEvent(),
|
getServer().getPluginManager().registerEvents(new OnBlockBreakEvent(),
|
||||||
@ -234,25 +235,65 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
ArenaHandler.loadArenas();
|
ArenaHandler.loadArenas();
|
||||||
|
|
||||||
try {
|
Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
|
||||||
Metrics metrics = new Metrics(this);
|
|
||||||
metrics.start();
|
@Override
|
||||||
FileConfiguration metrics_fc = new YamlConfiguration();
|
public void run() {
|
||||||
metrics_fc.load(metrics.getConfigFile());
|
try {
|
||||||
if (!metrics_fc.getBoolean("opt-out", false)) {
|
Metrics metrics = new Metrics(plugin);
|
||||||
MessageM.sendMessage(null,
|
Graph playersPlayingBlockHunt = metrics
|
||||||
"%TAG%NSending %AMCStats %Nto their server.");
|
.createGraph("Players playing BlockHunt");
|
||||||
} else {
|
|
||||||
MessageM.sendMessage(null,
|
playersPlayingBlockHunt.addPlotter(new Metrics.Plotter(
|
||||||
"%TAG%EUnable to send %AMCStats %Eto their server. %AMCStats%E is disabled?");
|
"Playing") {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getValue() {
|
||||||
|
int playersPlaying = 0;
|
||||||
|
for (Arena arena : W.arenaList) {
|
||||||
|
playersPlaying = playersPlaying
|
||||||
|
+ arena.playersInArena.size();
|
||||||
|
}
|
||||||
|
return playersPlaying;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
playersPlayingBlockHunt.addPlotter(new Metrics.Plotter(
|
||||||
|
"Not playing") {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getValue() {
|
||||||
|
int playersPlaying = 0;
|
||||||
|
for (Arena arena : W.arenaList) {
|
||||||
|
playersPlaying = playersPlaying
|
||||||
|
+ arena.playersInArena.size();
|
||||||
|
}
|
||||||
|
return Bukkit.getOnlinePlayers().length
|
||||||
|
- playersPlaying;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
metrics.start();
|
||||||
|
FileConfiguration metrics_fc = new YamlConfiguration();
|
||||||
|
metrics_fc.load(metrics.getConfigFile());
|
||||||
|
if (!metrics_fc.getBoolean("opt-out", false)) {
|
||||||
|
MessageM.sendMessage(null,
|
||||||
|
"%TAG%NSending %AMCStats%N to the server...");
|
||||||
|
} else {
|
||||||
|
MessageM.sendMessage(null,
|
||||||
|
"%TAG%EUnable to send %AMCStats %Eto the server. %AMCStats%E is disabled?");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
MessageM.sendMessage(null,
|
||||||
|
"%TAG%EUnable to send %AMCStats %Eto the server. Something went wrong ;(!");
|
||||||
|
} catch (InvalidConfigurationException e) {
|
||||||
|
MessageM.sendMessage(null,
|
||||||
|
"%TAG%EUnable to send %AMCStats %Eto the server. Something went wrong ;(!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
}, 0, 100);
|
||||||
MessageM.sendMessage(null,
|
|
||||||
"%TAG%EUnable to send %AMCStats %Eto their server. Something went wrong ;(!");
|
|
||||||
} catch (InvalidConfigurationException e) {
|
|
||||||
MessageM.sendMessage(null,
|
|
||||||
"%TAG%EUnable to send %AMCStats %Eto their server. Something went wrong ;(!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((Boolean) W.config.get(ConfigC.autoUpdateCheck)) {
|
if ((Boolean) W.config.get(ConfigC.autoUpdateCheck)) {
|
||||||
if ((Boolean) W.config.get(ConfigC.autoDownloadUpdate)) {
|
if ((Boolean) W.config.get(ConfigC.autoDownloadUpdate)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user