From d66e8b697bb74ca5f7c8bf70d875b56a1c1fb522 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Mon, 28 Nov 2016 18:41:01 -0500 Subject: [PATCH] Attempt at brute-force finding metrics.txt --- .../metrics/output/GetLoginMetrics.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/alisolarflare/components/metrics/output/GetLoginMetrics.java b/src/alisolarflare/components/metrics/output/GetLoginMetrics.java index 7fc8f78..cd5dee8 100644 --- a/src/alisolarflare/components/metrics/output/GetLoginMetrics.java +++ b/src/alisolarflare/components/metrics/output/GetLoginMetrics.java @@ -1,9 +1,17 @@ package alisolarflare.components.metrics.output; +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + import org.bukkit.entity.Player; import alisolarflare.architecture.commands.ModCommand; import alisolarflare.components.metrics.MetricsComponent; +import buttondevteam.lib.TBMCCoreAPI; public class GetLoginMetrics extends ModCommand{ @@ -15,6 +23,27 @@ public class GetLoginMetrics extends ModCommand{ @Override public boolean OnCommand(Player player, String alias, String[] args) { + if (args.length == 1){ + BufferedReader outputStream = null; + try { + outputStream = new BufferedReader(new FileReader(args[0])); + + List outputList = new ArrayList(); + String currentLine; + + while ((currentLine = outputStream.readLine()) != null){ + outputList.add(currentLine); + } + outputStream.close(); + for (String metric: outputList){ + player.sendMessage(metric); + } + } catch (FileNotFoundException e) { + TBMCCoreAPI.SendException(args[0] + " could not be found", e); + } catch (IOException e1) { + TBMCCoreAPI.SendException(args[0] + "encountered an I/O Exception!", e1); + } + } for (String metric : module.playerLoginsFile.toArrayList()){ player.sendMessage(metric); }