mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 11:45:52 -07:00
SPIGOT-2450: Improve scoreboard criteria API, add missing DisplaySlots
By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
@@ -99,6 +99,16 @@ public final class TestServer implements InvocationHandler {
|
||||
}
|
||||
}
|
||||
);
|
||||
methodMap.put(
|
||||
Server.class.getMethod("getScoreboardCriteria", String.class),
|
||||
new MethodHandler() {
|
||||
@Override
|
||||
public Object handle(TestServer server, Object[] args) {
|
||||
// Does not need to return anything. Exists solely to test CriteriaTest which has static init fields
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
methods = methodMap.build();
|
||||
|
||||
TestServer server = new TestServer();
|
||||
|
@@ -0,0 +1,24 @@
|
||||
package org.bukkit.scoreboard;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.TestServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CriteriaTest {
|
||||
|
||||
@Test
|
||||
public void testStatistic() {
|
||||
TestServer.getInstance();
|
||||
|
||||
Assert.assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.AVIATE_ONE_CM, Material.STONE)); // Generic statistic with block
|
||||
Assert.assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.AVIATE_ONE_CM, EntityType.CREEPER)); // Generic statistic with entity type
|
||||
|
||||
Assert.assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.ENTITY_KILLED_BY, Material.AMETHYST_SHARD)); // Entity statistic with material
|
||||
Assert.assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.MINE_BLOCK, Material.DIAMOND_PICKAXE)); // Block statistic with item
|
||||
Assert.assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.BREAK_ITEM, Material.WATER)); // Item statistic with block
|
||||
Assert.assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.KILL_ENTITY, Material.STONE)); // Entity statistic with Material
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user