use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestItemStackWrapper method testWrapArray.
@Test
@DisplayName("Test wrapping an ItemStack Array")
void testWrapArray() {
ItemStack[] items = { new ItemStack(Material.DIAMOND), null, new ItemStack(Material.EMERALD), new CustomItemStack(Material.REDSTONE, "&4Firey thing", "with lore :o") };
ItemStackWrapper[] wrappers = ItemStackWrapper.wrapArray(items);
Assertions.assertEquals(items.length, wrappers.length);
for (int i = 0; i < items.length; i++) {
assertWrapped(items[i], wrappers[i]);
}
ItemStackWrapper[] nestedWrap = ItemStackWrapper.wrapArray(wrappers);
Assertions.assertEquals(wrappers.length, nestedWrap.length);
for (int i = 0; i < wrappers.length; i++) {
// We want to check that the wrapper returned is of reference equality
Assertions.assertSame(wrappers[i], nestedWrap[i]);
}
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestSoulboundItem method testSetSoulbound.
@Test
@DisplayName("Test whether an Item can be marked as soulbound")
void testSetSoulbound() {
ItemStack item = new CustomItemStack(Material.DIAMOND, "&cI wanna be soulbound!");
Assertions.assertFalse(SlimefunUtils.isSoulbound(item));
SlimefunUtils.setSoulbound(item, true);
Assertions.assertTrue(SlimefunUtils.isSoulbound(item));
Assertions.assertTrue(item.getItemMeta().hasLore());
SlimefunUtils.setSoulbound(item, false);
Assertions.assertFalse(SlimefunUtils.isSoulbound(item));
Assertions.assertFalse(item.getItemMeta().hasLore());
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestResearches method testDisabledResearch.
@Test
@DisplayName("Test disabling a Research")
void testDisabledResearch() {
NamespacedKey key = new NamespacedKey(plugin, "disabled_research");
Research research = new Research(key, 2, "Test", 100);
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "RESEARCH_TEST", new CustomItemStack(Material.TORCH, "&bResearch Test"));
research.addItems(item);
Slimefun.getRegistry().setResearchingEnabled(true);
Slimefun.getResearchCfg().setValue(key.getNamespace() + '.' + key.getKey() + ".enabled", false);
research.register();
Assertions.assertFalse(research.isEnabled());
Assertions.assertNull(item.getResearch());
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestPermissionsService method testSetPermission.
@Test
@DisplayName("Test if a permission node can be set")
void testSetPermission() {
PermissionsService service = new PermissionsService(plugin);
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", new CustomItemStack(Material.EMERALD, "&bBad omen"));
Assertions.assertThrows(IllegalArgumentException.class, () -> service.setPermission(null, null));
service.setPermission(item, "slimefun.tests");
Optional<String> permission = service.getPermission(item);
Assertions.assertTrue(permission.isPresent());
Assertions.assertEquals("slimefun.tests", permission.get());
service.setPermission(item, null);
Assertions.assertFalse(service.getPermission(item).isPresent());
service.setPermission(item, "none");
Assertions.assertFalse(service.getPermission(item).isPresent());
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestPermissionsService method testHasPermissionSet.
@Test
@DisplayName("Test Player with permission passing the permission check")
void testHasPermissionSet() {
PermissionsService service = new PermissionsService(plugin);
Player player = server.addPlayer();
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PERMISSIONS_TEST", new CustomItemStack(Material.EMERALD, "&bBad omen"));
String permission = "slimefun.unit.tests.permission";
player.addAttachment(plugin, permission, true);
service.setPermission(item, permission);
Assertions.assertTrue(service.hasPermission(player, item));
}
Aggregations