use of org.bstats.charts.SimplePie in project AuthMeReloaded by AuthMe.
the class OnStartupTasks method sendMetrics.
/**
* Sends bstats metrics.
*
* @param plugin the plugin instance
* @param settings the settings
*/
public static void sendMetrics(AuthMe plugin, Settings settings) {
final Metrics metrics = new Metrics(plugin, 164);
metrics.addCustomChart(new SimplePie("messages_language", () -> settings.getProperty(PluginSettings.MESSAGES_LANGUAGE)));
metrics.addCustomChart(new SimplePie("database_backend", () -> settings.getProperty(DatabaseSettings.BACKEND).toString()));
}
use of org.bstats.charts.SimplePie in project VotingPlugin by Ben12345rocks.
the class VotingPluginVelocity method onProxyInitialization.
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
File configFile = new File(dataDirectory.toFile(), "bungeeconfig.yml");
configFile.getParentFile().mkdirs();
if (!configFile.exists()) {
try {
configFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
InputStream toCopyStream = VotingPluginVelocity.class.getClassLoader().getResourceAsStream("bungeeconfig.yml");
try (FileOutputStream fos = new FileOutputStream(configFile)) {
byte[] buf = new byte[2048];
int r;
while (-1 != (r = toCopyStream.read(buf))) {
fos.write(buf, 0, r);
}
} catch (IOException e) {
e.printStackTrace();
}
}
config = new Config(configFile);
server.getChannelRegistrar().register(CHANNEL);
method = BungeeMethod.getByName(config.getBungeeMethod());
boolean mysqlLoaded = true;
try {
if (!config.getString(config.getNode("Host"), "").isEmpty()) {
loadMysql();
} else {
mysqlLoaded = false;
logger.error("MySQL settings not set in bungeeconfig.yml");
}
} catch (Exception e) {
mysqlLoaded = false;
e.printStackTrace();
}
CommandMeta meta = server.getCommandManager().metaBuilder("votingpluginbungee").aliases("vpb").build();
server.getCommandManager().register(meta, new VotingPluginVelocityCommand(this));
if (mysqlLoaded) {
uuidPlayerNameCache = mysql.getRowsUUIDNameQuery();
voteCacheFile = new VoteCache(new File(dataDirectory.toFile(), "votecache.yml"));
nonVotedPlayersCache = new NonVotedPlayersCache(new File(dataDirectory.toFile(), "nonvotedplayerscache.yml"), this);
timeHandle = new TimeHandle(voteCacheFile.getNode("Time", "Month").getString(""), voteCacheFile.getNode("Time", "Day").getInt(), voteCacheFile.getNode("Time", "Week").getInt()) {
@Override
public void save() {
voteCacheFile.getNode("Time", "Month").setValue(timeHandle.getMonth());
voteCacheFile.getNode("Time", "Day").setValue(timeHandle.getDay());
voteCacheFile.getNode("Time", "Week").setValue(timeHandle.getWeek());
}
};
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
try {
for (String serverToCheck : voteCacheFile.getServers()) {
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
for (String num : voteCacheFile.getServerVotes(serverToCheck)) {
ConfigurationNode data = voteCacheFile.getServerVotes(serverToCheck, num);
vote.add(new OfflineBungeeVote(data.getNode("Name").getString(), data.getNode("UUID").getString(), data.getNode("Service").getString(), data.getNode("Time").getLong(), data.getNode("Real").getBoolean(), data.getNode("TEXT").getString()));
}
cachedVotes.put(server.getServer(serverToCheck).get(), vote);
}
} catch (Exception e) {
e.printStackTrace();
}
try {
for (String player : voteCacheFile.getPlayers()) {
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
for (String num : voteCacheFile.getOnlineVotes(player)) {
ConfigurationNode data = voteCacheFile.getOnlineVotes(player, num);
vote.add(new OfflineBungeeVote(data.getNode("Name").getString(), data.getNode("UUID").getString(), data.getNode("Service").getString(), data.getNode("Time").getLong(), data.getNode("Real").getBoolean(), data.getNode("TEXT").getString()));
}
cachedOnlineVotes.put(player, vote);
}
} catch (Exception e) {
e.printStackTrace();
}
voteCacheFile.clearData();
server.getScheduler().buildTask(this, () -> {
for (RegisteredServer server : cachedVotes.keySet()) {
checkCachedVotes(server);
}
for (String player : cachedOnlineVotes.keySet()) {
if (server.getPlayer(UUID.fromString(player)).isPresent()) {
checkOnlineVotes(server.getPlayer(UUID.fromString(player)).get(), player, null);
}
}
}).delay(15L, TimeUnit.SECONDS).repeat(30l, TimeUnit.SECONDS).schedule();
server.getScheduler().buildTask(this, () -> {
if (nonVotedPlayersCache != null) {
debug("Checking nonvotedplayerscache.yml...");
nonVotedPlayersCache.check();
}
}).delay(1L, TimeUnit.MINUTES).repeat(60l, TimeUnit.MINUTES).schedule();
} else if (method.equals(BungeeMethod.SOCKETS)) {
encryptionHandler = new EncryptionHandler(new File(dataDirectory.toFile(), "secretkey.key"));
socketHandler = new SocketHandler(server.getPluginManager().getPlugin("votingplugin").get().getDescription().getVersion().get(), config.getBungeeHost(), config.getBungeePort(), encryptionHandler, config.getDebug());
socketHandler.add(new SocketReceiver() {
@Override
public void onReceive(String[] data) {
if (data.length > 1) {
if (data.length > 2) {
if (data[0].equalsIgnoreCase("Broadcast")) {
sendServerMessage(data);
}
}
}
}
});
socketHandler.add(new SocketReceiver() {
@Override
public void onReceive(String[] data) {
if (data.length > 1) {
if (data[0].equalsIgnoreCase("StatusOkay")) {
String server = data[1];
logger.info("Voting communicaton okay with " + server);
}
}
}
});
clientHandles = new HashMap<String, ClientHandler>();
List<String> l = config.getBlockedServers();
for (ConfigurationNode d : config.getSpigotServers()) {
String s = d.getKey().toString();
if (!l.contains(s)) {
clientHandles.put(s, new ClientHandler(d.getNode("Host").getString("0.0.0.0"), d.getNode("Port").getInt(1298), encryptionHandler, config.getDebug()));
}
}
}
}
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired() + voteCacheFile.getVotePartyInreaseVotesRequired();
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
try {
getVersionFile();
if (versionFile != null) {
versionFile.delete();
versionFile.getParentFile().delete();
}
} catch (Exception e) {
e.printStackTrace();
}
Metrics metrics = metricsFactory.make(this, 11547);
metrics.addCustomChart(new SimplePie("bungee_method", () -> getConfig().getBungeeMethod().toString()));
metrics.addCustomChart(new SimplePie("sendtoallservers", () -> "" + getConfig().getSendVotesToAllServers()));
metrics.addCustomChart(new SimplePie("allowunjoined", () -> "" + getConfig().getAllowUnJoined()));
metrics.addCustomChart(new SimplePie("pointsonvote", () -> "" + getConfig().getPointsOnVote()));
metrics.addCustomChart(new SimplePie("bungeemanagetotals", () -> "" + getConfig().getBungeeManageTotals()));
metrics.addCustomChart(new SimplePie("waitforuseronline", () -> "" + getConfig().getWaitForUserOnline()));
metrics.addCustomChart(new SimplePie("plugin_version", () -> "" + version));
if (!buildNumber.equals("NOTSET")) {
metrics.addCustomChart(new SimplePie("dev_build_number", () -> "" + buildNumber));
}
logger.info("VotingPlugin velocity loaded, method: " + method.toString() + ", PluginMessagingVersion: " + BungeeVersion.getPluginMessageVersion() + ", Internal Jar Version: " + version);
if (!buildNumber.equals("NOTSET")) {
logger.info("Detected using dev build number: " + buildNumber);
}
}
Aggregations