// Path: src/main/java/myessentials/entities/api/tool/ToolManager.java
// public class ToolManager {
// 
//     public static final ToolManager instance = new ToolManager();
// 
//     private final List<Tool> tools = new ArrayList<Tool>();
// 
//     public boolean register(Tool tool) {
//         for(Tool t : tools) {
//             if(t.owner == tool.owner && t.getItemStack() != null) {
//                 t.owner.addChatMessage(new ChatComponentText("You already have a tool!"));
//                 return false;
//             }
//         }
// 
//         tools.add(tool);
//         tool.giveItemStack();
//         return true;
//     }
// 
//     public Tool get(EntityPlayer owner) {
//         for(Tool tool : tools) {
//             if(tool.owner == owner) {
//                 return tool;
//             }
//         }
//         return null;
//     }
// 
//     public void remove(Tool tool) {
//         tools.remove(tool);
//         PlayerUtils.takeItemFromPlayer(tool.owner, tool.getItemStack(), 1);
//     }
// 
//     @SubscribeEvent
//     public void onPlayerInteract(PlayerInteractEvent ev) {
//         if(!(ev.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR || ev.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)) {
//             return;
//         }
// 
//         ItemStack currentStack = ev.entityPlayer.inventory.getCurrentItem();
//         if(currentStack == null) {
//             return;
//         }
// 
//         for(Iterator<Tool> it = tools.iterator(); it.hasNext(); ) {
//             Tool tool = it.next();
//             if(tool.owner == null) {
//                 it.remove();
//                 continue;
//             }
// 
//             if(ev.entityPlayer == tool.owner && tool.getItemStack() == currentStack) {
//                 if (ev.entityPlayer.isSneaking() && ev.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) {
//                     tool.onShiftRightClick();
//                     return;
//                 } else if (ev.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
//                     tool.onItemUse(new BlockPos(ev.x, ev.y, ev.z, ev.world.provider.dimensionId), ev.face);
//                     return;
//                 }
//             }
//         }
//     }
// 
//     @SubscribeEvent
//     public void onUseHoe(UseHoeEvent ev) {
//         for(Tool tool : tools) {
//             if (ev.current == tool.getItemStack()) {
//                 ev.setCanceled(true);
//                 return;
//             }
//         }
//     }
// 
//     @SubscribeEvent
//     public void onPlayerLogout(PlayerEvent.PlayerLoggedOutEvent ev) {
//         for(int i = 0; i < ev.player.inventory.getSizeInventory(); i++) {
//             ItemStack stack = ev.player.inventory.getStackInSlot(i);
//             if(stack == null || !stack.getDisplayName().startsWith(Tool.IDENTIFIER)) {
//                 continue;
//             }
// 
//             PlayerUtils.takeItemFromPlayer(ev.player, stack, 1);
//         }
//     }
// }
// 
// Path: src/test/java/myessentials/test/MECTest.java
// public class MECTest extends BaseTest {
// 
//     @Before
//     public void initConfig() {
//         TestConfig.instance.init(configFile, Constants.MOD_ID);
//     }
// 
// }


import junit.framework.Assert;
import metest.api.TestPlayer;
import myessentials.entities.api.tool.ToolManager;
import myessentials.test.MECTest;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import org.junit.Before;
import org.junit.Test;
package myessentials.test.entities.tool;


public class ToolTest extends MECTest {

    private EntityPlayerMP player;

    @Before
    public void initTool() {
        player = new TestPlayer(server, "Tool Tester");
        server.worldServerForDimension(0).setBlock(21, 200, 21, Blocks.stone);
    }

    private FakeTool createTool() {
        player.inventory.dropAllItems();
        FakeTool tool = new FakeTool(player);
        // FakePlayer problems
        try {
            // REF: Method ToolManager.register is calling giveItemStack which should not
            ToolManager.instance.register(tool);
// Path: src/main/java/myessentials/entities/api/tool/ToolManager.java
// public class ToolManager {
// 
//     public static final ToolManager instance = new ToolManager();
// 
//     private final List<Tool> tools = new ArrayList<Tool>();
// 
//     public boolean register(Tool tool) {
//         for(Tool t : tools) {
//             if(t.owner == tool.owner && t.getItemStack() != null) {
//                 t.owner.addChatMessage(new ChatComponentText("You already have a tool!"));
//                 return false;
//             }
//         }
// 
//         tools.add(tool);
//         tool.giveItemStack();
//         return true;
//     }
// 
//     public Tool get(EntityPlayer owner) {
//         for(Tool tool : tools) {
//             if(tool.owner == owner) {
//                 return tool;
//             }
//         }
//         return null;
//     }
// 
//     public void remove(Tool tool) {
//         tools.remove(tool);
//         PlayerUtils.takeItemFromPlayer(tool.owner, tool.getItemStack(), 1);
//     }
// 
//     @SubscribeEvent
//     public void onPlayerInteract(PlayerInteractEvent ev) {
//         if(!(ev.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR || ev.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)) {
//             return;
//         }
// 
//         ItemStack currentStack = ev.entityPlayer.inventory.getCurrentItem();
//         if(currentStack == null) {
//             return;
//         }
// 
//         for(Iterator<Tool> it = tools.iterator(); it.hasNext(); ) {
//             Tool tool = it.next();
//             if(tool.owner == null) {
//                 it.remove();
//                 continue;
//             }
// 
//             if(ev.entityPlayer == tool.owner && tool.getItemStack() == currentStack) {
//                 if (ev.entityPlayer.isSneaking() && ev.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) {
//                     tool.onShiftRightClick();
//                     return;
//                 } else if (ev.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
//                     tool.onItemUse(new BlockPos(ev.x, ev.y, ev.z, ev.world.provider.dimensionId), ev.face);
//                     return;
//                 }
//             }
//         }
//     }
// 
//     @SubscribeEvent
//     public void onUseHoe(UseHoeEvent ev) {
//         for(Tool tool : tools) {
//             if (ev.current == tool.getItemStack()) {
//                 ev.setCanceled(true);
//                 return;
//             }
//         }
//     }
// 
//     @SubscribeEvent
//     public void onPlayerLogout(PlayerEvent.PlayerLoggedOutEvent ev) {
//         for(int i = 0; i < ev.player.inventory.getSizeInventory(); i++) {
//             ItemStack stack = ev.player.inventory.getStackInSlot(i);
//             if(stack == null || !stack.getDisplayName().startsWith(Tool.IDENTIFIER)) {
//                 continue;
//             }
// 
//             PlayerUtils.takeItemFromPlayer(ev.player, stack, 1);
//         }
//     }
// }
// 
// Path: src/test/java/myessentials/test/MECTest.java
// public class MECTest extends BaseTest {
// 
//     @Before
//     public void initConfig() {
//         TestConfig.instance.init(configFile, Constants.MOD_ID);
//     }
// 
// }


// Path: src/test/java/myessentials/test/entities/tool/ToolTest.java
import junit.framework.Assert;
import metest.api.TestPlayer;
import myessentials.entities.api.tool.ToolManager;
import myessentials.test.MECTest;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import org.junit.Before;
import org.junit.Test;

package myessentials.test.entities.tool;


public class ToolTest extends MECTest {

    private EntityPlayerMP player;

    @Before
    public void initTool() {
        player = new TestPlayer(server, "Tool Tester");
        server.worldServerForDimension(0).setBlock(21, 200, 21, Blocks.stone);
    }

    private FakeTool createTool() {
        player.inventory.dropAllItems();
        FakeTool tool = new FakeTool(player);
        // FakePlayer problems
        try {
            // REF: Method ToolManager.register is calling giveItemStack which should not
            ToolManager.instance.register(tool);
        } catch (NullPointerException ex) {}