mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-09-27 14:59:09 +02:00
optimizations
This commit is contained in:
@@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@@ -62,42 +61,36 @@ class WoodcuttingTest extends MMOTestEnvironment {
|
||||
void harvestLumberShouldDoubleDrop() {
|
||||
mmoPlayer.modifySkill(PrimarySkillType.WOODCUTTING, 1000);
|
||||
|
||||
BlockState blockState = Mockito.mock(BlockState.class);
|
||||
Block block = Mockito.mock(Block.class);
|
||||
// wire block
|
||||
Mockito.when(blockState.getBlock()).thenReturn(block);
|
||||
|
||||
// return empty collection if ItemStack
|
||||
Mockito.when(blockState.getBlock().getDrops(any())).thenReturn(Collections.emptyList());
|
||||
Mockito.when(blockState.getType()).thenReturn(Material.OAK_LOG);
|
||||
woodcuttingManager.processBonusDropCheck(blockState);
|
||||
Mockito.when(block.getDrops(any())).thenReturn(Collections.emptyList());
|
||||
Mockito.when(block.getType()).thenReturn(Material.OAK_LOG);
|
||||
woodcuttingManager.processBonusDropCheck(block);
|
||||
|
||||
// verify bonus drops were spawned
|
||||
// TODO: using at least once since triple drops can also happen
|
||||
// TODO: Change the test env to disallow triple drop in the future
|
||||
Mockito.verify(woodcuttingManager, Mockito.atLeastOnce()).spawnHarvestLumberBonusDrops(blockState);
|
||||
Mockito.verify(woodcuttingManager, Mockito.atLeastOnce()).spawnHarvestLumberBonusDrops(block);
|
||||
}
|
||||
|
||||
@Test
|
||||
void harvestLumberShouldNotDoubleDrop() {
|
||||
mmoPlayer.modifySkill(PrimarySkillType.WOODCUTTING, 0);
|
||||
|
||||
BlockState blockState = Mockito.mock(BlockState.class);
|
||||
Block block = Mockito.mock(Block.class);
|
||||
// wire block
|
||||
Mockito.when(blockState.getBlock()).thenReturn(block);
|
||||
|
||||
Mockito.when(blockState.getBlock().getDrops(any())).thenReturn(null);
|
||||
Mockito.when(blockState.getType()).thenReturn(Material.OAK_LOG);
|
||||
woodcuttingManager.processBonusDropCheck(blockState);
|
||||
Mockito.when(block.getDrops(any())).thenReturn(null);
|
||||
Mockito.when(block.getType()).thenReturn(Material.OAK_LOG);
|
||||
woodcuttingManager.processBonusDropCheck(block);
|
||||
|
||||
// verify bonus drops were not spawned
|
||||
Mockito.verify(woodcuttingManager, Mockito.times(0)).spawnHarvestLumberBonusDrops(blockState);
|
||||
Mockito.verify(woodcuttingManager, Mockito.times(0)).spawnHarvestLumberBonusDrops(block);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProcessWoodcuttingBlockXP() {
|
||||
BlockState targetBlock = Mockito.mock(BlockState.class);
|
||||
Block targetBlock = Mockito.mock(Block.class);
|
||||
Mockito.when(targetBlock.getType()).thenReturn(Material.OAK_LOG);
|
||||
// wire XP
|
||||
Mockito.when(ExperienceConfig.getInstance().getXp(PrimarySkillType.WOODCUTTING, Material.OAK_LOG)).thenReturn(5);
|
||||
|
Reference in New Issue
Block a user