Search in sources :

Example 21 with CustomItemStack

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]);
    }
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) ItemStack(org.bukkit.inventory.ItemStack) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) ItemStackWrapper(io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 22 with CustomItemStack

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());
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) ItemStack(org.bukkit.inventory.ItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 23 with CustomItemStack

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());
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) Research(io.github.thebusybiscuit.slimefun4.api.researches.Research) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 24 with CustomItemStack

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());
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 25 with CustomItemStack

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));
}
Also used : Player(org.bukkit.entity.Player) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CustomItemStack (io.github.bakedlibs.dough.items.CustomItemStack)172 Test (org.junit.jupiter.api.Test)100 DisplayName (org.junit.jupiter.api.DisplayName)90 SlimefunItem (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem)83 ItemStack (org.bukkit.inventory.ItemStack)70 SlimefunItemStack (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)43 NamespacedKey (org.bukkit.NamespacedKey)31 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 Player (org.bukkit.entity.Player)25 ChestMenu (me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu)22 ItemGroup (io.github.thebusybiscuit.slimefun4.api.items.ItemGroup)20 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)18 Slimefun (io.github.thebusybiscuit.slimefun4.implementation.Slimefun)12 PlayerProfile (io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile)11 FlexItemGroup (io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup)10 ArrayList (java.util.ArrayList)10 Nonnull (javax.annotation.Nonnull)10 Material (org.bukkit.Material)10 LockedItemGroup (io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup)9 Location (org.bukkit.Location)9