Search in sources :

Example 1 with UuidListFile

use of net.glowstone.util.bans.UuidListFile in project Glowstone by GlowstoneMC.

the class GlowPlayerTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    PowerMockito.mockStatic(Bukkit.class);
    super.setUp();
    when(Bukkit.getServer()).thenReturn(server);
    when(Bukkit.getItemFactory()).thenReturn(itemFactory);
    opsListFile = File.createTempFile("test-ops-list", "");
    opsList = new UuidListFile(opsListFile);
    when(server.getSessionRegistry()).thenReturn(sessionRegistry);
    when(server.getPluginManager()).thenReturn(pluginManager);
    when(server.getMaterialValueManager()).thenReturn(materialValueManager);
    scheduler = new GlowScheduler(server, worldScheduler);
    when(session.getServer()).thenReturn(server);
    when(server.getScheduler()).thenReturn(scheduler);
    when(server.getOpsList()).thenReturn(opsList);
    when(server.getPlayerStatisticIoService()).thenReturn(statisticIoService);
    when(world.getSpawnLocation()).thenReturn(location);
    when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(block);
    when(world.getBlockAt(any(Location.class))).thenReturn(block);
    when(world.getChunkManager()).thenReturn(chunkManager);
    when(world.newChunkLock(anyString())).thenReturn(chunkLock);
    when(block.getLocation()).thenReturn(location);
    when(block.getType()).thenReturn(Material.AIR);
    when(block.getRelative(any(BlockFace.class))).thenReturn(block);
    when(block.getMaterialValues()).thenCallRealMethod();
    when(block.getWorld()).thenReturn(world);
    fishingRodItem = new ItemStack(Material.FISHING_ROD);
    entity = entityCreator.apply(location);
    entity.setItemInHand(fishingRodItem);
    entity.setDigging(null);
    entity.setLevel(1);
    when(session.getPlayer()).thenReturn(entity);
    when(session.getChannel()).thenReturn(null);
    when(world.getRawPlayers()).thenReturn(Collections.singletonList(entity));
    EventFactory.setInstance(eventFactory);
    when(eventFactory.callEvent(any(Event.class))).thenAnswer(returnsFirstArg());
}
Also used : UuidListFile(net.glowstone.util.bans.UuidListFile) BlockFace(org.bukkit.block.BlockFace) PlayerStatisticIncrementEvent(org.bukkit.event.player.PlayerStatisticIncrementEvent) Event(org.bukkit.event.Event) PlayerExpChangeEvent(org.bukkit.event.player.PlayerExpChangeEvent) PlayerLevelChangeEvent(org.bukkit.event.player.PlayerLevelChangeEvent) ItemStack(org.bukkit.inventory.ItemStack) GlowScheduler(net.glowstone.scheduler.GlowScheduler) Location(org.bukkit.Location) Before(org.junit.Before)

Aggregations

GlowScheduler (net.glowstone.scheduler.GlowScheduler)1 UuidListFile (net.glowstone.util.bans.UuidListFile)1 Location (org.bukkit.Location)1 BlockFace (org.bukkit.block.BlockFace)1 Event (org.bukkit.event.Event)1 PlayerExpChangeEvent (org.bukkit.event.player.PlayerExpChangeEvent)1 PlayerLevelChangeEvent (org.bukkit.event.player.PlayerLevelChangeEvent)1 PlayerStatisticIncrementEvent (org.bukkit.event.player.PlayerStatisticIncrementEvent)1 ItemStack (org.bukkit.inventory.ItemStack)1 Before (org.junit.Before)1