Started work on a metrics system

Tracking player login events, etc
This commit is contained in:
alisolarflare 2016-11-11 22:32:25 -05:00
parent 8f9a3b7457
commit 0f1e896722
15 changed files with 69 additions and 10 deletions

View file

@ -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.
@ -47,4 +49,23 @@ public abstract class Module{
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;
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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;

View file

@ -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;

View file

@ -11,6 +11,7 @@ import graveyard.autouhc.memory.UHCMatch;
*
* @author Alisolarflare
*/
/**@deprecated*/
public class AddToUHC extends ModCommand {
private UHCMatch match;

View file

@ -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;

View file

@ -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) {

View file

@ -1,5 +1,5 @@
package graveyard.autouhc.intro;
/**@deprecated*/
public class IntroductionCutscene {
//TODO: Teleport all players to the area.
}

View file

@ -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) {

View file

@ -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;
}

View file

@ -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;

View file

@ -1,7 +1,7 @@
package graveyard.autouhc.listeners;
import org.bukkit.scheduler.BukkitRunnable;
/**@deprecated*/
public class MatchMainLoop extends BukkitRunnable{
@Override
public void run() {

View file

@ -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

View file

@ -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;