diff --git a/src/main/java/buttondevteam/presents/Main.java b/src/main/java/buttondevteam/presents/Main.java index d27ecfc..e967e0c 100644 --- a/src/main/java/buttondevteam/presents/Main.java +++ b/src/main/java/buttondevteam/presents/Main.java @@ -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()+ ")."); } diff --git a/src/main/java/buttondevteam/presents/hello/effects/HelloBedsplode.java b/src/main/java/buttondevteam/presents/hello/effects/HelloBedsplode.java index 6ca4c8b..b2b50f2 100644 --- a/src/main/java/buttondevteam/presents/hello/effects/HelloBedsplode.java +++ b/src/main/java/buttondevteam/presents/hello/effects/HelloBedsplode.java @@ -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( diff --git a/src/main/java/buttondevteam/presents/metrics/MetricsComponent.java b/src/main/java/buttondevteam/presents/metrics/MetricsComponent.java new file mode 100644 index 0000000..0687604 --- /dev/null +++ b/src/main/java/buttondevteam/presents/metrics/MetricsComponent.java @@ -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)); + } + +} diff --git a/src/main/java/buttondevteam/presents/metrics/PlayerLogins.java b/src/main/java/buttondevteam/presents/metrics/PlayerLogins.java new file mode 100644 index 0000000..95cf5dc --- /dev/null +++ b/src/main/java/buttondevteam/presents/metrics/PlayerLogins.java @@ -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(); + } +} diff --git a/src/main/java/buttondevteam/presents/metrics/PlayerLoginsPage.java b/src/main/java/buttondevteam/presents/metrics/PlayerLoginsPage.java new file mode 100644 index 0000000..50bcb6a --- /dev/null +++ b/src/main/java/buttondevteam/presents/metrics/PlayerLoginsPage.java @@ -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 = "

Player Login Metrics Screen

"; + return outputString; + } + +}