use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestPermissionsService method testHasPermissionFalse.
@Test
@DisplayName("Test Players without permissions being denied access")
void testHasPermissionFalse() {
PermissionsService service = new PermissionsService(plugin);
Player player = server.addPlayer();
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", new CustomItemStack(Material.EMERALD, "&bBad omen"));
service.setPermission(item, "slimefun.tests");
Assertions.assertFalse(service.hasPermission(player, item));
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestPermissionsService method testDefaultPermission.
@ParameterizedTest
@DisplayName("Test if no permission is set by default")
@ValueSource(booleans = { false, true })
void testDefaultPermission(boolean registered) {
PermissionsService service = new PermissionsService(plugin);
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", new CustomItemStack(Material.EMERALD, "&bBad omen"));
if (registered) {
service.register(Arrays.asList(item), false);
}
Optional<String> permission = service.getPermission(item);
Assertions.assertFalse(permission.isPresent());
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestPermissionsService method testHasPermissionTrue.
@Test
@DisplayName("Test if the Player will pass the permissions check if no permission was set")
void testHasPermissionTrue() {
PermissionsService service = new PermissionsService(plugin);
Player player = server.addPlayer();
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", new CustomItemStack(Material.EMERALD, "&bBad omen"));
Assertions.assertTrue(service.hasPermission(player, null));
Assertions.assertTrue(service.hasPermission(player, item));
service.setPermission(item, "none");
Assertions.assertTrue(service.hasPermission(player, item));
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestGuideHistory method testSlimefunItem.
@Test
@DisplayName("Test adding a SlimefunItem to Guide History")
void testSlimefunItem() throws InterruptedException {
Player player = server.addPlayer();
PlayerProfile profile = TestUtilities.awaitProfile(player);
GuideHistory history = profile.getGuideHistory();
Assertions.assertThrows(IllegalArgumentException.class, () -> history.add((SlimefunItem) null));
Assertions.assertEquals(0, history.size());
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "HISTORIC_ITEM", new CustomItemStack(Material.DIORITE, "&4I am really running out of ideas for item names"));
history.add(item);
Assertions.assertEquals(1, history.size());
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestGuideHistory method testItemGroup.
@Test
@DisplayName("Test adding an ItemGroup to Guide History")
void testItemGroup() throws InterruptedException {
Player player = server.addPlayer();
PlayerProfile profile = TestUtilities.awaitProfile(player);
GuideHistory history = profile.getGuideHistory();
ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "itemgroup_guide_history"), new CustomItemStack(Material.BEDROCK, "&4Can't touch this"));
Assertions.assertThrows(IllegalArgumentException.class, () -> history.add((ItemGroup) null, 1));
Assertions.assertThrows(IllegalArgumentException.class, () -> history.add(itemGroup, -20));
Assertions.assertEquals(0, history.size());
history.add(itemGroup, 1);
Assertions.assertEquals(1, history.size());
// This should not add a new entry but rather only update the page
history.add(itemGroup, 2);
Assertions.assertEquals(1, history.size());
}
Aggregations