From 74179fffb1bc815e9c2f1393c04e655213847b0a Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Mon, 14 Nov 2016 23:55:48 -0500 Subject: [PATCH] Edited metrics module --- plugin.yml | 4 +++- .../components/metrics/MetricsModule.java | 13 ++++++---- .../metrics/commands/GetMetrics.java | 24 +++++++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 src/alisolarflare/components/metrics/commands/GetMetrics.java diff --git a/plugin.yml b/plugin.yml index fd3ecae..f90d093 100644 --- a/plugin.yml +++ b/plugin.yml @@ -58,4 +58,6 @@ commands: powerall: description: activate every player's power setproximitylocation: - description: sets one of two proximity blocks to create a space that players can change their flairs with using flairportals. Ask ali XD \ No newline at end of file + description: sets one of two proximity blocks to create a space that players can change their flairs with using flairportals. Ask ali XD + getMetrics: + description: Gets metrics \ No newline at end of file diff --git a/src/alisolarflare/components/metrics/MetricsModule.java b/src/alisolarflare/components/metrics/MetricsModule.java index e758136..8024426 100644 --- a/src/alisolarflare/components/metrics/MetricsModule.java +++ b/src/alisolarflare/components/metrics/MetricsModule.java @@ -3,6 +3,7 @@ package alisolarflare.components.metrics; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.List; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.FileConfiguration; @@ -10,22 +11,26 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.components.Component; +import alisolarflare.components.metrics.commands.GetMetrics; +import alisolarflare.components.metrics.listeners.PlayerLoginListener; public class MetricsModule extends Component{ - public FileConfiguration metricsYml; + public FileConfiguration metricsYml; // DATA - STRING + public List metricsList; @Override public void register(JavaPlugin plugin){ - try { - loadFileConfiguration(plugin, "config.yml"); + metricsYml = loadFileConfiguration(plugin, "metrics.yml"); } catch (IOException | InvalidConfigurationException e) { e.printStackTrace(); return; } - + metricsList = metricsYml.getStringList("playerLogins"); + registerCommand(plugin, new GetMetrics(this)); + registerListener(plugin, new PlayerLoginListener(this)); } private FileConfiguration loadFileConfiguration(JavaPlugin plugin, String fileName) throws FileNotFoundException, IOException, InvalidConfigurationException { diff --git a/src/alisolarflare/components/metrics/commands/GetMetrics.java b/src/alisolarflare/components/metrics/commands/GetMetrics.java new file mode 100644 index 0000000..8a643da --- /dev/null +++ b/src/alisolarflare/components/metrics/commands/GetMetrics.java @@ -0,0 +1,24 @@ +package alisolarflare.components.metrics.commands; + +import org.bukkit.command.CommandSender; + +import alisolarflare.components.ModCommand; +import alisolarflare.components.metrics.MetricsModule; + +public class GetMetrics extends ModCommand{ + + private MetricsModule module; + + public GetMetrics(MetricsModule metricsModule) { + this.module = metricsModule; + } + + @Override + public boolean OnCommand(CommandSender sender, String alias, String[] args) { + for (String metric : module.metricsList){ + sender.sendMessage(metric); + } + return true; + } + +}