Search in sources :

Example 96 with CustomItemStack

use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.

the class TestMultiblockListener method load.

@BeforeAll
public static void load() {
    server = MockBukkit.mock();
    plugin = MockBukkit.load(Slimefun.class);
    listener = new MultiBlockListener(plugin);
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_LISTENER_TEST", new CustomItemStack(Material.DIAMOND, "&9Some multiblock item"));
    multiblock = new MultiBlock(item, new Material[] { null, Material.EMERALD_BLOCK, null, null, Material.DIAMOND_BLOCK, null, null, Material.LAPIS_BLOCK, null }, BlockFace.SELF);
    Slimefun.getRegistry().getMultiBlocks().add(multiblock);
}
Also used : MultiBlock(io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) Slimefun(io.github.thebusybiscuit.slimefun4.implementation.Slimefun) Material(org.bukkit.Material) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 97 with CustomItemStack

use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.

the class TestPiglinListener method testPiglinInteractWithSlimefunItem.

@ParameterizedTest
@EnumSource(value = EquipmentSlot.class, names = { "HAND", "OFF_HAND" })
void testPiglinInteractWithSlimefunItem(EquipmentSlot hand) {
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PIGLIN_GIVE_" + hand.name(), new CustomItemStack(Material.GOLD_INGOT, "&6Piglin Bait"));
    item.register(plugin);
    PlayerInteractEntityEvent event = createInteractEvent(hand, item.getItem());
    listener.onInteract(event);
    Assertions.assertTrue(event.isCancelled());
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) PlayerInteractEntityEvent(org.bukkit.event.player.PlayerInteractEntityEvent) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 98 with CustomItemStack

use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.

the class TestIronGolemListener method testWithSlimefunIron.

@Test
@DisplayName("Test Iron Golem Healing with Slimefun Items being cancelled")
void testWithSlimefunIron() {
    SlimefunItem slimefunItem = TestUtilities.mockSlimefunItem(plugin, "SLIMEFUN_IRON", new CustomItemStack(Material.IRON_INGOT, "&cSlimefun Iron"));
    slimefunItem.register(plugin);
    // The Event should be cancelled, we do not wanna use Slimefun Items for this
    PlayerInteractEntityEvent event = callIronGolemEvent(EquipmentSlot.HAND, slimefunItem.getItem());
    Assertions.assertTrue(event.isCancelled());
    PlayerInteractEntityEvent event2 = callIronGolemEvent(EquipmentSlot.OFF_HAND, slimefunItem.getItem());
    Assertions.assertTrue(event2.isCancelled());
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) PlayerInteractEntityEvent(org.bukkit.event.player.PlayerInteractEntityEvent) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 99 with CustomItemStack

use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.

the class TestItemPickupListener method testAltarProbeForInventories.

@ParameterizedTest
@ValueSource(booleans = { true, false })
void testAltarProbeForInventories(boolean flag) {
    Inventory inventory = new HopperInventoryMock(null);
    ItemStack stack;
    if (flag) {
        stack = new CustomItemStack(Material.DIAMOND, AncientPedestal.ITEM_PREFIX + System.nanoTime());
    } else {
        stack = new CustomItemStack(Material.DIAMOND, "&5Just a normal named diamond");
    }
    AtomicBoolean removed = new AtomicBoolean(false);
    Item item = new ItemEntityMock(server, UUID.randomUUID(), stack) {

        @Override
        public void remove() {
            removed.set(true);
        }
    };
    InventoryPickupItemEvent event = new InventoryPickupItemEvent(inventory, item);
    listener.onHopperPickup(event);
    Assertions.assertEquals(flag, event.isCancelled());
    Assertions.assertEquals(flag, removed.get());
}
Also used : HopperInventoryMock(be.seeseemelk.mockbukkit.inventory.HopperInventoryMock) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Item(org.bukkit.entity.Item) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) InventoryPickupItemEvent(org.bukkit.event.inventory.InventoryPickupItemEvent) ItemStack(org.bukkit.inventory.ItemStack) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) ItemEntityMock(be.seeseemelk.mockbukkit.entity.ItemEntityMock) Inventory(org.bukkit.inventory.Inventory) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 100 with CustomItemStack

use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.

the class TestMultiBlocks method testSymmetry.

@Test
@DisplayName("Test symmetric MultiBlocks")
void testSymmetry() {
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItemStack(Material.BRICK, "&5Multiblock Test"));
    MultiBlock multiblock = new MultiBlock(item, new Material[] { null, null, null, Material.DIAMOND_BLOCK, null, Material.DIAMOND_BLOCK, null, Material.DISPENSER, null }, BlockFace.DOWN);
    Assertions.assertTrue(multiblock.isSymmetric());
    MultiBlock multiblock2 = new MultiBlock(item, new Material[] { Material.EMERALD_BLOCK, null, null, Material.EMERALD_BLOCK, null, Material.DIAMOND_BLOCK, Material.EMERALD_BLOCK, Material.DISPENSER, null }, BlockFace.DOWN);
    Assertions.assertFalse(multiblock2.isSymmetric());
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) Test(org.junit.jupiter.api.Test) 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