From 0f1e8967223464ad4a3b4f688ea80e421c54709d Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Fri, 11 Nov 2016 22:32:25 -0500 Subject: [PATCH] Started work on a metrics system Tracking player login events, etc --- src/alisolarflare/modules/Module.java | 21 +++++++++++++++++++ .../modules/metrics/MetricsModule.java | 16 ++++++++++++++ .../listeners/PlayerLoginListener.java | 20 ++++++++++++++++++ src/graveyard/autouhc/UHCModule.java | 2 +- .../autouhc/controller/SetMatchState.java | 2 +- src/graveyard/autouhc/idle/AddToUHC.java | 1 + src/graveyard/autouhc/idle/JoinUHC.java | 2 +- .../autouhc/intro/ConfigureMatch.java | 2 +- .../autouhc/intro/IntroductionCutscene.java | 2 +- .../autouhc/intro/ScheduleMatch.java | 2 +- src/graveyard/autouhc/intro/StartMatch.java | 2 +- .../listeners/MatchCyclingListener.java | 1 + .../autouhc/listeners/MatchMainLoop.java | 2 +- src/graveyard/autouhc/memory/MatchState.java | 2 +- src/graveyard/autouhc/memory/UHCMatch.java | 2 +- 15 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 src/alisolarflare/modules/metrics/MetricsModule.java create mode 100644 src/alisolarflare/modules/metrics/listeners/PlayerLoginListener.java diff --git a/src/alisolarflare/modules/Module.java b/src/alisolarflare/modules/Module.java index 6446ff0..9818c99 100644 --- a/src/alisolarflare/modules/Module.java +++ b/src/alisolarflare/modules/Module.java @@ -1,5 +1,6 @@ package alisolarflare.modules; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; @@ -20,6 +21,7 @@ import buttondevteam.lib.chat.TBMCCommandBase; * */ public abstract class Module{ + /** * Registers the module, when called by the JavaPlugin class. Call * registerCommand() and registerListener() within this method. @@ -46,5 +48,24 @@ public abstract class Module{ TBMCCoreAPI.RegisterEventsForExceptions(listener, plugin); return listener; } + + public void saveData(FileConfiguration config, String pathToData, Object data){ + + config.set("moduledata." + this.getClassName() + "." + pathToData, data); + } + public Object getData(FileConfiguration config, String pathToData, Object data){ + return config.get("moduledata." + this.getClassName() + "." + pathToData, data); + } + + public String getClassName(){ + Class enclosingClass = getClass().getEnclosingClass(); + String className = "nullModule"; + if (enclosingClass != null) { + className = (enclosingClass.getName()); + } else { + className = (getClass().getName()); + } + return className; + } } diff --git a/src/alisolarflare/modules/metrics/MetricsModule.java b/src/alisolarflare/modules/metrics/MetricsModule.java new file mode 100644 index 0000000..a4ca43e --- /dev/null +++ b/src/alisolarflare/modules/metrics/MetricsModule.java @@ -0,0 +1,16 @@ +package alisolarflare.modules.metrics; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.plugin.java.JavaPlugin; + +import alisolarflare.modules.Module; + +public class MetricsModule extends Module{ + + public FileConfiguration config; + + @Override + public void register(JavaPlugin plugin) { + this.config = plugin.getConfig(); + } +} diff --git a/src/alisolarflare/modules/metrics/listeners/PlayerLoginListener.java b/src/alisolarflare/modules/metrics/listeners/PlayerLoginListener.java new file mode 100644 index 0000000..b512120 --- /dev/null +++ b/src/alisolarflare/modules/metrics/listeners/PlayerLoginListener.java @@ -0,0 +1,20 @@ +package alisolarflare.modules.metrics.listeners; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerLoginEvent; + +import alisolarflare.modules.metrics.MetricsModule; + +public class PlayerLoginListener implements Listener{ + + private MetricsModule module; + public PlayerLoginListener(MetricsModule module){ + this.module = module; + } + @EventHandler + public void onPlayerLogin(PlayerLoginEvent event){ + module.saveData(module.config, "loginlog."+System.currentTimeMillis(), event.getPlayer().getName()); + event.getPlayer(); + } +} diff --git a/src/graveyard/autouhc/UHCModule.java b/src/graveyard/autouhc/UHCModule.java index c3b36ae..1891c31 100644 --- a/src/graveyard/autouhc/UHCModule.java +++ b/src/graveyard/autouhc/UHCModule.java @@ -1,11 +1,11 @@ package graveyard.autouhc; -/**@deprecated*/ import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.modules.Module; import graveyard.autouhc.memory.MatchState; import graveyard.autouhc.memory.UHCMatch; +/**@deprecated*/ public class UHCModule extends Module { public UHCMatch match; diff --git a/src/graveyard/autouhc/controller/SetMatchState.java b/src/graveyard/autouhc/controller/SetMatchState.java index 483c74c..00f8d94 100644 --- a/src/graveyard/autouhc/controller/SetMatchState.java +++ b/src/graveyard/autouhc/controller/SetMatchState.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import alisolarflare.modules.ModCommand; import graveyard.autouhc.memory.MatchState; import graveyard.autouhc.memory.UHCMatch; - +/**@deprecated*/ public class SetMatchState extends ModCommand{ UHCMatch match; diff --git a/src/graveyard/autouhc/idle/AddToUHC.java b/src/graveyard/autouhc/idle/AddToUHC.java index 821e16b..f1ffa57 100644 --- a/src/graveyard/autouhc/idle/AddToUHC.java +++ b/src/graveyard/autouhc/idle/AddToUHC.java @@ -11,6 +11,7 @@ import graveyard.autouhc.memory.UHCMatch; * * @author Alisolarflare */ +/**@deprecated*/ public class AddToUHC extends ModCommand { private UHCMatch match; diff --git a/src/graveyard/autouhc/idle/JoinUHC.java b/src/graveyard/autouhc/idle/JoinUHC.java index 9234aff..c37d301 100644 --- a/src/graveyard/autouhc/idle/JoinUHC.java +++ b/src/graveyard/autouhc/idle/JoinUHC.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import alisolarflare.modules.ModCommand; import graveyard.autouhc.memory.UHCMatch; - +/**@deprecated*/ public class JoinUHC extends ModCommand{ private UHCMatch match; diff --git a/src/graveyard/autouhc/intro/ConfigureMatch.java b/src/graveyard/autouhc/intro/ConfigureMatch.java index e3aa894..49f1bfb 100644 --- a/src/graveyard/autouhc/intro/ConfigureMatch.java +++ b/src/graveyard/autouhc/intro/ConfigureMatch.java @@ -4,7 +4,7 @@ import org.bukkit.command.CommandSender; import alisolarflare.modules.ModCommand; import graveyard.autouhc.memory.UHCMatch; - +/**@deprecated*/ public class ConfigureMatch extends ModCommand{ public ConfigureMatch(UHCMatch match) { diff --git a/src/graveyard/autouhc/intro/IntroductionCutscene.java b/src/graveyard/autouhc/intro/IntroductionCutscene.java index 3727cec..e548dc8 100644 --- a/src/graveyard/autouhc/intro/IntroductionCutscene.java +++ b/src/graveyard/autouhc/intro/IntroductionCutscene.java @@ -1,5 +1,5 @@ package graveyard.autouhc.intro; - +/**@deprecated*/ public class IntroductionCutscene { //TODO: Teleport all players to the area. } diff --git a/src/graveyard/autouhc/intro/ScheduleMatch.java b/src/graveyard/autouhc/intro/ScheduleMatch.java index 8190d2c..91b130a 100644 --- a/src/graveyard/autouhc/intro/ScheduleMatch.java +++ b/src/graveyard/autouhc/intro/ScheduleMatch.java @@ -4,7 +4,7 @@ import org.bukkit.command.CommandSender; import alisolarflare.modules.ModCommand; import graveyard.autouhc.memory.UHCMatch; - +/**@deprecated*/ public class ScheduleMatch extends ModCommand{ public ScheduleMatch(UHCMatch match) { diff --git a/src/graveyard/autouhc/intro/StartMatch.java b/src/graveyard/autouhc/intro/StartMatch.java index 2a6134e..22f2b5a 100644 --- a/src/graveyard/autouhc/intro/StartMatch.java +++ b/src/graveyard/autouhc/intro/StartMatch.java @@ -8,7 +8,7 @@ import graveyard.autouhc.memory.UHCMatch; public class StartMatch extends ModCommand { private UHCMatch match; - + /**@deprecated*/ public StartMatch(UHCMatch match) { this.match = match; } diff --git a/src/graveyard/autouhc/listeners/MatchCyclingListener.java b/src/graveyard/autouhc/listeners/MatchCyclingListener.java index 5a21b9c..c15fbcd 100644 --- a/src/graveyard/autouhc/listeners/MatchCyclingListener.java +++ b/src/graveyard/autouhc/listeners/MatchCyclingListener.java @@ -9,6 +9,7 @@ import org.bukkit.scheduler.BukkitTask; * ghostie powers if an Ultrahardcore Match is going on, * and it's time for powers to activate */ +/**@deprecated*/ public class MatchCyclingListener implements Listener { public BukkitTask PowerCyclingTask; diff --git a/src/graveyard/autouhc/listeners/MatchMainLoop.java b/src/graveyard/autouhc/listeners/MatchMainLoop.java index 0698590..e300596 100644 --- a/src/graveyard/autouhc/listeners/MatchMainLoop.java +++ b/src/graveyard/autouhc/listeners/MatchMainLoop.java @@ -1,7 +1,7 @@ package graveyard.autouhc.listeners; import org.bukkit.scheduler.BukkitRunnable; - +/**@deprecated*/ public class MatchMainLoop extends BukkitRunnable{ @Override public void run() { diff --git a/src/graveyard/autouhc/memory/MatchState.java b/src/graveyard/autouhc/memory/MatchState.java index c97ed01..68a6c48 100644 --- a/src/graveyard/autouhc/memory/MatchState.java +++ b/src/graveyard/autouhc/memory/MatchState.java @@ -1,5 +1,5 @@ package graveyard.autouhc.memory; - +/**@deprecated*/ public enum MatchState { IDLE, //Idle: Configure Match, Wait: Schedule Match, Intro: Start Match WAITING, //SETUP: Scheduled Time, INTRO: No Setup diff --git a/src/graveyard/autouhc/memory/UHCMatch.java b/src/graveyard/autouhc/memory/UHCMatch.java index f408d2c..a5f4538 100644 --- a/src/graveyard/autouhc/memory/UHCMatch.java +++ b/src/graveyard/autouhc/memory/UHCMatch.java @@ -7,7 +7,7 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.configuration.file.FileConfiguration; - +/**@deprecated*/ public class UHCMatch { private FileConfiguration config; private MatchState matchState = MatchState.IDLE;