Used Potato to test metrics

This commit is contained in:
alisolarflare 2016-11-17 18:44:32 -05:00
parent 07fb4113af
commit c2f7726ed1
5 changed files with 23 additions and 67 deletions

View file

@ -12,23 +12,24 @@ import org.bukkit.inventory.ItemStack;
import buttondevteam.lib.chat.TBMCCommandBase; import buttondevteam.lib.chat.TBMCCommandBase;
public abstract class BaseCommand extends TBMCCommandBase{ public abstract class BaseCommand extends TBMCCommandBase{
public static ItemStack CreateDebugPotato(List<String> debugMessage){ public static ItemStack CreateDebugPotato(List<String> message){
ItemStack debugPotato = new ItemStack(Material.BAKED_POTATO); ItemStack potato = new ItemStack(Material.BAKED_POTATO);
debugPotato.getItemMeta().setDisplayName("Spicy Debug Potato"); potato.getItemMeta().setDisplayName("Spicy Debug Potato");
debugPotato.getItemMeta().setLore(debugMessage); potato.getItemMeta().setLore(message);
debugPotato.addEnchantment(Enchantment.ARROW_FIRE, 10); potato.addEnchantment(Enchantment.ARROW_FIRE, 10);
return debugPotato; return potato;
} }
public static ItemStack CreateDebugPotato(String debugMessage){ public static ItemStack CreateDebugPotato(String message){
return CreateDebugPotato(Arrays.asList(debugMessage)); return CreateDebugPotato(Arrays.asList(message));
} }
public static void SendDebugPotato(Player player, List<String> debugMessage){
player.getInventory().addItem(CreateDebugPotato(debugMessage)); public static void SendDebugPotato(Player player, List<String> message){
player.getInventory().addItem(CreateDebugPotato(message));
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0);
return; return;
} }
public static void SendDebugPotato(Player player, String debugMessage){ public static void SendDebugPotato(Player player, String message){
SendDebugPotato(player, Arrays.asList(debugMessage)); SendDebugPotato(player, Arrays.asList(message));
} }
} }

View file

@ -22,6 +22,9 @@ public class MetricsModule extends Component{
@Override @Override
public void register(JavaPlugin plugin){ public void register(JavaPlugin plugin){
registerCommand(plugin, new GetMetrics(this));
registerListener(plugin, new PlayerJoinListener(this));
try { try {
metricsYml = loadFileConfiguration(plugin, "metrics.yml"); metricsYml = loadFileConfiguration(plugin, "metrics.yml");
} catch (IOException | InvalidConfigurationException e) { } catch (IOException | InvalidConfigurationException e) {
@ -31,8 +34,6 @@ public class MetricsModule extends Component{
//metricsList = metricsYml.getStringList("playerLogins"); //metricsList = metricsYml.getStringList("playerLogins");
metricsList = new ArrayList<String>(); metricsList = new ArrayList<String>();
registerCommand(plugin, new GetMetrics(this));
registerListener(plugin, new PlayerJoinListener(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

@ -1,6 +1,7 @@
package alisolarflare.components.metrics.commands; package alisolarflare.components.metrics.commands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import alisolarflare.components.ModCommand; import alisolarflare.components.ModCommand;
import alisolarflare.components.metrics.MetricsModule; import alisolarflare.components.metrics.MetricsModule;
@ -15,8 +16,10 @@ public class GetMetrics extends ModCommand{
@Override @Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) { public boolean OnCommand(CommandSender sender, String alias, String[] args) {
Player player = (Player) sender;
for (String metric : module.metricsList){ for (String metric : module.metricsList){
sender.sendMessage(metric); SendDebugPotato(player, module.metricsList);
SendDebugPotato(player, metric);
} }
return true; return true;
} }

View file

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

View file

@ -4,6 +4,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import alisolarflare.components.BaseCommand;
import alisolarflare.components.metrics.MetricsModule; import alisolarflare.components.metrics.MetricsModule;
public class PlayerJoinListener implements Listener{ public class PlayerJoinListener implements Listener{
@ -13,9 +14,9 @@ public class PlayerJoinListener implements Listener{
this.module = module; this.module = module;
} }
@EventHandler @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.saveData(module.metricsYml, "loginlog."+System.currentTimeMillis()+event.getPlayer().getName(), event.getPlayer().getName());
module.metricsList.add("loginlog."+System.currentTimeMillis()+event.getPlayer().getName()); module.metricsList.add("loginlog."+System.currentTimeMillis()+event.getPlayer().getName());
event.getPlayer(); BaseCommand.SendDebugPotato(event.getPlayer(), "loginlog."+System.currentTimeMillis()+event.getPlayer().getName());
} }
} }