From c2f7726ed1bea19f776f7f0bd75f3ca2354fa1ff Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Thu, 17 Nov 2016 18:44:32 -0500 Subject: [PATCH] Used Potato to test metrics --- src/alisolarflare/components/BaseCommand.java | 25 +++++----- .../components/metrics/MetricsModule.java | 5 +- .../metrics/commands/GetMetrics.java | 5 +- .../metrics/commands/TestEnchantment.java | 50 ------------------- .../metrics/listeners/PlayerJoinListener.java | 5 +- 5 files changed, 23 insertions(+), 67 deletions(-) delete mode 100644 src/alisolarflare/components/metrics/commands/TestEnchantment.java diff --git a/src/alisolarflare/components/BaseCommand.java b/src/alisolarflare/components/BaseCommand.java index 7e6c59d..ad0dcd2 100644 --- a/src/alisolarflare/components/BaseCommand.java +++ b/src/alisolarflare/components/BaseCommand.java @@ -12,23 +12,24 @@ import org.bukkit.inventory.ItemStack; import buttondevteam.lib.chat.TBMCCommandBase; public abstract class BaseCommand extends TBMCCommandBase{ - public static ItemStack CreateDebugPotato(List debugMessage){ - ItemStack debugPotato = new ItemStack(Material.BAKED_POTATO); - debugPotato.getItemMeta().setDisplayName("Spicy Debug Potato"); - debugPotato.getItemMeta().setLore(debugMessage); - debugPotato.addEnchantment(Enchantment.ARROW_FIRE, 10); - return debugPotato; + public static ItemStack CreateDebugPotato(List message){ + ItemStack potato = new ItemStack(Material.BAKED_POTATO); + potato.getItemMeta().setDisplayName("Spicy Debug Potato"); + potato.getItemMeta().setLore(message); + potato.addEnchantment(Enchantment.ARROW_FIRE, 10); + return potato; } - public static ItemStack CreateDebugPotato(String debugMessage){ - return CreateDebugPotato(Arrays.asList(debugMessage)); + public static ItemStack CreateDebugPotato(String message){ + return CreateDebugPotato(Arrays.asList(message)); } - public static void SendDebugPotato(Player player, List debugMessage){ - player.getInventory().addItem(CreateDebugPotato(debugMessage)); + + public static void SendDebugPotato(Player player, List message){ + player.getInventory().addItem(CreateDebugPotato(message)); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0); return; } - public static void SendDebugPotato(Player player, String debugMessage){ - SendDebugPotato(player, Arrays.asList(debugMessage)); + public static void SendDebugPotato(Player player, String message){ + SendDebugPotato(player, Arrays.asList(message)); } } diff --git a/src/alisolarflare/components/metrics/MetricsModule.java b/src/alisolarflare/components/metrics/MetricsModule.java index 5ee437f..9def30c 100644 --- a/src/alisolarflare/components/metrics/MetricsModule.java +++ b/src/alisolarflare/components/metrics/MetricsModule.java @@ -22,6 +22,9 @@ public class MetricsModule extends Component{ @Override public void register(JavaPlugin plugin){ + registerCommand(plugin, new GetMetrics(this)); + registerListener(plugin, new PlayerJoinListener(this)); + try { metricsYml = loadFileConfiguration(plugin, "metrics.yml"); } catch (IOException | InvalidConfigurationException e) { @@ -31,8 +34,6 @@ public class MetricsModule extends Component{ //metricsList = metricsYml.getStringList("playerLogins"); metricsList = new ArrayList(); - registerCommand(plugin, new GetMetrics(this)); - registerListener(plugin, new PlayerJoinListener(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 index 8a643da..9ca2186 100644 --- a/src/alisolarflare/components/metrics/commands/GetMetrics.java +++ b/src/alisolarflare/components/metrics/commands/GetMetrics.java @@ -1,6 +1,7 @@ package alisolarflare.components.metrics.commands; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import alisolarflare.components.ModCommand; import alisolarflare.components.metrics.MetricsModule; @@ -15,8 +16,10 @@ public class GetMetrics extends ModCommand{ @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { + Player player = (Player) sender; for (String metric : module.metricsList){ - sender.sendMessage(metric); + SendDebugPotato(player, module.metricsList); + SendDebugPotato(player, metric); } return true; } diff --git a/src/alisolarflare/components/metrics/commands/TestEnchantment.java b/src/alisolarflare/components/metrics/commands/TestEnchantment.java deleted file mode 100644 index 8cde4ff..0000000 --- a/src/alisolarflare/components/metrics/commands/TestEnchantment.java +++ /dev/null @@ -1,50 +0,0 @@ -package alisolarflare.components.metrics.commands; - -import org.bukkit.enchantments.Enchantment; -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.inventory.ItemStack; - -public class TestEnchantment extends Enchantment { - - public TestEnchantment(int id) { - super(id); - // TODO Auto-generated constructor stub - } - - @Override - public String getName() { - // TODO Auto-generated method stub - return null; - } - - @Override - public int getMaxLevel() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public int getStartLevel() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public EnchantmentTarget getItemTarget() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean conflictsWith(Enchantment other) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean canEnchantItem(ItemStack item) { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/src/alisolarflare/components/metrics/listeners/PlayerJoinListener.java b/src/alisolarflare/components/metrics/listeners/PlayerJoinListener.java index 3e0adc2..9fa249b 100644 --- a/src/alisolarflare/components/metrics/listeners/PlayerJoinListener.java +++ b/src/alisolarflare/components/metrics/listeners/PlayerJoinListener.java @@ -4,6 +4,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; +import alisolarflare.components.BaseCommand; import alisolarflare.components.metrics.MetricsModule; public class PlayerJoinListener implements Listener{ @@ -13,9 +14,9 @@ public class PlayerJoinListener implements Listener{ this.module = module; } @EventHandler - public void onPlayerLogin(PlayerJoinEvent event){ + public void onPlayerJoin(PlayerJoinEvent event){ module.saveData(module.metricsYml, "loginlog."+System.currentTimeMillis()+event.getPlayer().getName(), event.getPlayer().getName()); module.metricsList.add("loginlog."+System.currentTimeMillis()+event.getPlayer().getName()); - event.getPlayer(); + BaseCommand.SendDebugPotato(event.getPlayer(), "loginlog."+System.currentTimeMillis()+event.getPlayer().getName()); } }