The start of the Metrics Plugin

This commit is contained in:
alisolarflare 2017-06-21 23:54:13 -04:00
parent 6a344eee0a
commit d9f6aa0620
5 changed files with 90 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.presents.hello.HelloComponent;
import buttondevteam.presents.metrics.MetricsComponent;
import buttondevteam.presents.rtp.RandomTeleportComponent;
public class Main extends JavaPlugin{
@ -17,6 +18,7 @@ PluginDescriptionFile pdfFile = getDescription();
new HelloComponent().register(this);
new RandomTeleportComponent().register(this);
new MetricsComponent().register(this);
logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ").");
}

View file

@ -9,6 +9,7 @@ public class HelloBedsplode implements Listener {
@EventHandler
public void onSleep(PlayerBedEnterEvent event){
Player player = event.getPlayer();
player.sendMessage("[ButtonPresents] Night night " + player.getName().toLowerCase());
if (player.getName().toLowerCase() != "alisolarflare") return;
player.getWorld().createExplosion(

View file

@ -0,0 +1,15 @@
package buttondevteam.presents.metrics;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.presents.architecture.Component;
public class MetricsComponent extends Component{
@Override
public void register(JavaPlugin plugin) {
registerListener(plugin, new PlayerLogins(plugin));
addPage(plugin, new PlayerLoginsPage(plugin));
}
}

View file

@ -0,0 +1,38 @@
package buttondevteam.presents.metrics;
import java.util.Objects;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class PlayerLogins implements Listener {
private JavaPlugin plugin;
public PlayerLogins(JavaPlugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPlayerLogin(PlayerLoginEvent event){
String[] array = {
event.getPlayer().getName(),
"login"
};
plugin.getConfig().set("metrics.logins." + Objects.toString(System.currentTimeMillis()), array);
plugin.saveConfig();
}
@EventHandler
public void onPlayerLogout(PlayerQuitEvent event){
String[] array = {
event.getPlayer().getName(),
"logout"
};
plugin.getConfig().set("metrics.logins." + Objects.toString(System.currentTimeMillis()), array);
plugin.saveConfig();
}
}

View file

@ -0,0 +1,34 @@
package buttondevteam.presents.metrics;
import org.bukkit.plugin.java.JavaPlugin;
import com.sun.net.httpserver.HttpExchange;
import buttondevteam.website.io.Response;
import buttondevteam.website.page.Page;
public class PlayerLoginsPage extends Page {
private JavaPlugin plugin;
public PlayerLoginsPage(JavaPlugin plugin) {
this.plugin = plugin;
}
@Override
public String GetName() {
// TODO Auto-generated method stub
return "/ali/metrics/logins";
}
@Override
public Response handlePage(HttpExchange exchange) {
return new Response(200, responseString(), exchange);
}
private String responseString() {
String outputString = "<h1>Player Login Metrics Screen</h1>";
return outputString;
}
}