Search in sources :

Example 1 with GameRuleManager

use of net.glowstone.util.GameRuleManager in project Glowstone by GlowstoneMC.

the class GlowEntityTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(server.getItemFactory()).thenReturn(itemFactory);
    when(server.getPluginManager()).thenReturn(pluginManager);
    ServerProvider.setMockServer(server);
    log = Logger.getLogger(getClass().getSimpleName());
    when(server.getLogger()).thenReturn(log);
    location = new Location(world, 0, 0, 0);
    when(world.getServer()).thenReturn(server);
    when(world.getDifficulty()).thenReturn(Difficulty.NORMAL);
    when(server.getWorlds()).thenReturn(Collections.singletonList(world));
    when(world.getBlockAt(any(Location.class))).thenReturn(block);
    when(block.getType()).thenReturn(Material.DIRT);
    when(block.getRelative(any(BlockFace.class))).thenReturn(block);
    when(world.getChunkAt(any(Location.class))).thenReturn(chunk);
    when(world.getChunkAt(any(Block.class))).thenReturn(chunk);
    when(world.getChunkAt(anyInt(), anyInt())).thenReturn(chunk);
    when(world.getChunk(notNull())).thenReturn(chunk);
    when(world.getGameRuleMap()).thenReturn(new GameRuleManager());
    when(server.getItemFactory()).thenReturn(itemFactory);
    entityManager = Mockito.spy(new EntityManager());
    when(world.getEntityManager()).thenReturn(entityManager);
    idManager = new EntityIdManager();
    when(server.getEntityIdManager()).thenReturn(idManager);
    when(server.getScoreboardManager()).thenReturn(scoreboardManager);
    scoreboard = new GlowScoreboard();
    when(scoreboardManager.getMainScoreboard()).thenReturn(scoreboard);
    when(itemFactory.ensureServerConversions(any(ItemStack.class))).thenAnswer(returnsFirstArg());
    oldEventFactory = EventFactory.getInstance();
    EventFactory.setInstance(eventFactory);
    when(eventFactory.callEvent(any(Event.class))).thenAnswer(returnsFirstArg());
    if (createEntityInSuperSetUp()) {
        entity = entityCreator.apply(location);
    }
    when(eventFactory.onEntityDamage(any(EntityDamageEvent.class))).thenAnswer(returnsFirstArg());
    inventory = new GlowPlayerInventory(player);
    when(player.getInventory()).thenReturn(inventory);
    when(player.getGameMode()).thenReturn(GameMode.SURVIVAL);
}
Also used : GlowScoreboard(net.glowstone.scoreboard.GlowScoreboard) GameRuleManager(net.glowstone.util.GameRuleManager) BlockFace(org.bukkit.block.BlockFace) GlowBlock(net.glowstone.block.GlowBlock) Block(org.bukkit.block.Block) Event(org.bukkit.event.Event) EntityDamageEvent(org.bukkit.event.entity.EntityDamageEvent) ItemStack(org.bukkit.inventory.ItemStack) Location(org.bukkit.Location) EntityDamageEvent(org.bukkit.event.entity.EntityDamageEvent) GlowPlayerInventory(net.glowstone.inventory.GlowPlayerInventory) Before(org.junit.Before)

Aggregations

GlowBlock (net.glowstone.block.GlowBlock)1 GlowPlayerInventory (net.glowstone.inventory.GlowPlayerInventory)1 GlowScoreboard (net.glowstone.scoreboard.GlowScoreboard)1 GameRuleManager (net.glowstone.util.GameRuleManager)1 Location (org.bukkit.Location)1 Block (org.bukkit.block.Block)1 BlockFace (org.bukkit.block.BlockFace)1 Event (org.bukkit.event.Event)1 EntityDamageEvent (org.bukkit.event.entity.EntityDamageEvent)1 ItemStack (org.bukkit.inventory.ItemStack)1 Before (org.junit.Before)1