mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 11:45:52 -07:00
#919: Add internal ItemType and BlockType, delegate Material methods to them
By: Jishuna <joshl5324@gmail.com> Also-by: Bjarne Koll <lynxplay101@gmail.com> Also-by: DerFrZocker <derrieple@gmail.com> Also-by: md_5 <git@md-5.net>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.scoreboard;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -11,12 +12,20 @@ public class CriteriaTest extends AbstractTestingBase {
|
||||
|
||||
@Test
|
||||
public void testStatistic() {
|
||||
Material item = mock();
|
||||
when(item.isItem()).thenReturn(true);
|
||||
when(item.isBlock()).thenReturn(false);
|
||||
|
||||
Material block = mock();
|
||||
when(block.isItem()).thenReturn(false);
|
||||
when(block.isBlock()).thenReturn(true);
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.AVIATE_ONE_CM, Material.STONE)); // Generic statistic with block
|
||||
assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.AVIATE_ONE_CM, EntityType.CREEPER)); // Generic statistic with entity type
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.ENTITY_KILLED_BY, Material.AMETHYST_SHARD)); // Entity statistic with material
|
||||
assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.MINE_BLOCK, Material.DIAMOND_PICKAXE)); // Block statistic with item
|
||||
assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.BREAK_ITEM, Material.WATER)); // Item statistic with block
|
||||
assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.MINE_BLOCK, item)); // Block statistic with item
|
||||
assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.BREAK_ITEM, block)); // Item statistic with block
|
||||
assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.KILL_ENTITY, Material.STONE)); // Entity statistic with Material
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user