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;
public abstract class BaseCommand extends TBMCCommandBase{
public static ItemStack CreateDebugPotato(List<String> 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<String> 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<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);
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));
}
}

View file

@ -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<String>();
registerCommand(plugin, new GetMetrics(this));
registerListener(plugin, new PlayerJoinListener(this));
}
private FileConfiguration loadFileConfiguration(JavaPlugin plugin, String fileName) throws FileNotFoundException, IOException, InvalidConfigurationException {

View file

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

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.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());
}
}