Edited metrics module

This commit is contained in:
alisolarflare 2016-11-14 23:55:48 -05:00
parent 7886c052e0
commit 74179fffb1
3 changed files with 36 additions and 5 deletions

View file

@ -58,4 +58,6 @@ commands:
powerall: powerall:
description: activate every player's power description: activate every player's power
setproximitylocation: setproximitylocation:
description: sets one of two proximity blocks to create a space that players can change their flairs with using flairportals. Ask ali XD 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

View file

@ -3,6 +3,7 @@ package alisolarflare.components.metrics;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -10,22 +11,26 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.components.Component; import alisolarflare.components.Component;
import alisolarflare.components.metrics.commands.GetMetrics;
import alisolarflare.components.metrics.listeners.PlayerLoginListener;
public class MetricsModule extends Component{ public class MetricsModule extends Component{
public FileConfiguration metricsYml; public FileConfiguration metricsYml; // DATA - STRING
public List<String> metricsList;
@Override @Override
public void register(JavaPlugin plugin){ public void register(JavaPlugin plugin){
try { try {
loadFileConfiguration(plugin, "config.yml"); metricsYml = loadFileConfiguration(plugin, "metrics.yml");
} catch (IOException | InvalidConfigurationException e) { } catch (IOException | InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
return; 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 { private FileConfiguration loadFileConfiguration(JavaPlugin plugin, String fileName) throws FileNotFoundException, IOException, InvalidConfigurationException {

View file

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