Search in sources :

Example 16 with SlimefunItemStack

use of io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack in project Slimefun4 by Slimefun.

the class TestCoolerListener method load.

@BeforeAll
public static void load() {
    server = MockBukkit.mock();
    Slimefun plugin = MockBukkit.load(Slimefun.class);
    ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "cooler_test"), new CustomItemStack(Material.SNOWBALL, "Mr. Freeze"));
    SlimefunItemStack item = new SlimefunItemStack("TEST_COOLER", Material.SNOWBALL, "&6Test Cooler", "", "&7ID: <ID>");
    cooler = new Cooler(18, itemGroup, item, RecipeType.NULL, new ItemStack[9]);
    cooler.register(plugin);
    SlimefunItemStack juiceItem = new SlimefunItemStack("TEST_JUICE", Color.RED, new PotionEffect(PotionEffectType.HEALTH_BOOST, 6, 0), "&4Test Juice");
    juice = new Juice(itemGroup, juiceItem, RecipeType.NULL, new ItemStack[9]);
    juice.register(plugin);
    listener = new CoolerListener(plugin, cooler);
}
Also used : Cooler(io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler) ItemGroup(io.github.thebusybiscuit.slimefun4.api.items.ItemGroup) PotionEffect(org.bukkit.potion.PotionEffect) NamespacedKey(org.bukkit.NamespacedKey) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) Slimefun(io.github.thebusybiscuit.slimefun4.implementation.Slimefun) Juice(io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice) ItemStack(org.bukkit.inventory.ItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 17 with SlimefunItemStack

use of io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack in project Slimefun4 by Slimefun.

the class TestBackpackListener method openMockBackpack.

private PlayerBackpack openMockBackpack(Player player, String id, int size) throws InterruptedException {
    SlimefunItemStack item = new SlimefunItemStack(id, Material.CHEST, "&4Mock Backpack", "", "&7Size: &e" + BACKPACK_SIZE, "&7ID: <ID>", "", "&7&eRight Click&7 to open");
    PlayerProfile profile = TestUtilities.awaitProfile(player);
    PlayerBackpack backpack = profile.createBackpack(size);
    listener.setBackpackId(player, item, 2, backpack.getId());
    ItemGroup itemGroup = new ItemGroup(new NamespacedKey(plugin, "test_backpacks"), new CustomItemStack(Material.CHEST, "&4Test Backpacks"));
    SlimefunBackpack slimefunBackpack = new SlimefunBackpack(size, itemGroup, item, RecipeType.NULL, new ItemStack[9]);
    slimefunBackpack.register(plugin);
    listener.openBackpack(player, item, slimefunBackpack);
    return backpack;
}
Also used : PlayerBackpack(io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack) ItemGroup(io.github.thebusybiscuit.slimefun4.api.items.ItemGroup) PlayerProfile(io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile) NamespacedKey(org.bukkit.NamespacedKey) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SlimefunBackpack(io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)

Example 18 with SlimefunItemStack

use of io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack in project Slimefun4 by Slimefun.

the class TestCargoNodeListener method testInvalidSidePlacement.

@Test
@DisplayName("Test placing Cargo nodes on invalid sides of blocks")
void testInvalidSidePlacement() {
    Player player = server.addPlayer();
    Location l = new Location(player.getWorld(), 190, 50, 400);
    Block b = l.getBlock();
    Block against = b.getRelative(BlockFace.DOWN);
    ItemGroup itemGroup = TestUtilities.getItemGroup(plugin, "cargo_test");
    SlimefunItemStack item = new SlimefunItemStack("MOCK_CARGO_NODE", new CustomItemStack(Material.PLAYER_HEAD, "&4Cargo node!"));
    CargoInputNode node = new CargoInputNode(itemGroup, item, RecipeType.NULL, new ItemStack[9], null);
    node.register(plugin);
    BlockPlaceEvent event = new BlockPlaceEvent(b, b.getState(), against, item, player, true, EquipmentSlot.HAND);
    listener.onCargoNodePlace(event);
    Assertions.assertTrue(event.isCancelled());
}
Also used : Player(org.bukkit.entity.Player) ItemGroup(io.github.thebusybiscuit.slimefun4.api.items.ItemGroup) CargoInputNode(io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoInputNode) BlockPlaceEvent(org.bukkit.event.block.BlockPlaceEvent) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) Block(org.bukkit.block.Block) Location(org.bukkit.Location) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 19 with SlimefunItemStack

use of io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack in project Slimefun4 by Slimefun.

the class TestCargoNodeListener method testGrassPlacement.

@Test
@DisplayName("Test placing Cargo nodes on grass")
void testGrassPlacement() {
    Player player = server.addPlayer();
    Location l = new Location(player.getWorld(), 300, 25, 1200);
    Block b = l.getBlock();
    b.setType(Material.GRASS);
    ItemGroup itemGroup = TestUtilities.getItemGroup(plugin, "cargo_test");
    SlimefunItemStack item = new SlimefunItemStack("MOCK_CARGO_NODE_2", new CustomItemStack(Material.PLAYER_HEAD, "&4Cargo node!"));
    CargoInputNode node = new CargoInputNode(itemGroup, item, RecipeType.NULL, new ItemStack[9], null);
    node.register(plugin);
    BlockPlaceEvent event = new BlockPlaceEvent(b, b.getState(), b, item, player, true, EquipmentSlot.HAND);
    listener.onCargoNodePlace(event);
    Assertions.assertTrue(event.isCancelled());
}
Also used : Player(org.bukkit.entity.Player) ItemGroup(io.github.thebusybiscuit.slimefun4.api.items.ItemGroup) CargoInputNode(io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoInputNode) BlockPlaceEvent(org.bukkit.event.block.BlockPlaceEvent) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) Block(org.bukkit.block.Block) Location(org.bukkit.Location) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 20 with SlimefunItemStack

use of io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack in project Slimefun4 by Slimefun.

the class TestRadioactiveItem method testWikiPages.

@ParameterizedTest
@EnumSource(value = Radioactivity.class)
@DisplayName("Test radioactive items being radioactive")
void testWikiPages(Radioactivity radioactivity) {
    ItemGroup itemGroup = TestUtilities.getItemGroup(plugin, "radioactivity_test");
    SlimefunItemStack stack = new SlimefunItemStack("RADIOACTIVE_" + radioactivity.name(), Material.EMERALD, "&4Radioactive!!!", "Imagine dragons");
    RadioactiveItem item = new RadioactiveItem(itemGroup, radioactivity, stack, RecipeType.NULL, new ItemStack[9]);
    Assertions.assertEquals(radioactivity, item.getRadioactivity());
}
Also used : ItemGroup(io.github.thebusybiscuit.slimefun4.api.items.ItemGroup) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

SlimefunItemStack (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)80 ItemStack (org.bukkit.inventory.ItemStack)45 CustomItemStack (io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack)20 SlimefunItem (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem)18 CustomItemStack (io.github.bakedlibs.dough.items.CustomItemStack)15 ItemGroup (io.github.thebusybiscuit.slimefun4.api.items.ItemGroup)13 DisplayName (org.junit.jupiter.api.DisplayName)11 Player (org.bukkit.entity.Player)9 ItemMeta (org.bukkit.inventory.meta.ItemMeta)9 PotionEffect (org.bukkit.potion.PotionEffect)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 NamespacedKey (org.bukkit.NamespacedKey)7 Test (org.junit.jupiter.api.Test)7 Juice (io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice)5 BonemealableItem (io.github.thebusybiscuit.exoticgarden.items.BonemealableItem)4 Research (io.github.thebusybiscuit.slimefun4.api.researches.Research)4 Nonnull (javax.annotation.Nonnull)4 Material (org.bukkit.Material)4 Block (org.bukkit.block.Block)4 RecipeType (io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType)3