Search in sources :

Example 6 with Slimefun

use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.

the class TestChargeCommand method testCommand.

@Test
@DisplayName("Test if /sf charge charges the item the player is holding")
void testCommand() {
    ItemGroup itemGroup = TestUtilities.getItemGroup(plugin, "rechargeable");
    SlimefunItemStack RECHARGEABLE_ITEM = new SlimefunItemStack("SF_CHARGE_TEST_ITEM", Material.REDSTONE_BLOCK, "Rechargeable Item", "This isn't real", LoreBuilder.powerCharged(0, 100));
    new RechargeableMock(itemGroup, RECHARGEABLE_ITEM, RecipeType.NULL, new ItemStack[9]).register(plugin);
    Player player = server.addPlayer();
    player.setOp(true);
    player.getInventory().setItemInMainHand(RECHARGEABLE_ITEM.clone());
    ItemStack chargedItemStack = player.getInventory().getItemInMainHand();
    Rechargeable chargedItem = (Rechargeable) SlimefunItem.getByItem(chargedItemStack);
    Assertions.assertEquals(chargedItem.getItemCharge(chargedItemStack), 0);
    server.execute("slimefun", player, "charge");
    chargedItemStack = player.getInventory().getItemInMainHand();
    chargedItem = (Rechargeable) SlimefunItem.getByItem(chargedItemStack);
    Assertions.assertEquals(chargedItem.getItemCharge(chargedItemStack), chargedItem.getMaxItemCharge(chargedItemStack));
}
Also used : Player(org.bukkit.entity.Player) ItemGroup(io.github.thebusybiscuit.slimefun4.api.items.ItemGroup) ItemStack(org.bukkit.inventory.ItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) Rechargeable(io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 7 with Slimefun

use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.

the class TestResearchCommand method load.

@BeforeAll
public static void load() {
    server = MockBukkit.mock();
    Slimefun plugin = MockBukkit.load(Slimefun.class);
    research = new Research(new NamespacedKey(plugin, "command_test"), 999, "Test", 10);
    research.register();
    research2 = new Research(new NamespacedKey(plugin, "command_test_two"), 1000, "Test Two", 10);
    research2.register();
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) Slimefun(io.github.thebusybiscuit.slimefun4.implementation.Slimefun) Research(io.github.thebusybiscuit.slimefun4.api.researches.Research) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 8 with Slimefun

use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.

the class TestResearchCommand method testResearchAll.

@Test
@DisplayName("Test /sf research all")
void testResearchAll() throws InterruptedException {
    Slimefun.getRegistry().setResearchingEnabled(true);
    Player player = server.addPlayer();
    PlayerProfile profile = TestUtilities.awaitProfile(player);
    server.executeConsole("slimefun", "research", player.getName(), "all").assertSucceeded();
    Assertions.assertTrue(profile.hasUnlocked(research));
    Assertions.assertTrue(profile.hasUnlocked(research2));
}
Also used : Player(org.bukkit.entity.Player) PlayerProfile(io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 9 with Slimefun

use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.

the class TestGuideOpening method testOpenMainMenu.

@Test
@DisplayName("Test if the Slimefun Guide Main Menu can be opened from the History")
void testOpenMainMenu() throws InterruptedException {
    SlimefunGuideImplementation guide = Mockito.mock(SlimefunGuideImplementation.class);
    PlayerProfile profile = prepare(guide, history -> {
    });
    Mockito.verify(guide).openMainMenu(profile, 1);
}
Also used : PlayerProfile(io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 10 with Slimefun

use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project Slimefun4 by Slimefun.

the class TestGuideOpening method testOpenSearch.

@Test
@DisplayName("Test if the Slimefun Search can be opened from the History")
void testOpenSearch() throws InterruptedException {
    String query = "electric";
    SlimefunGuideImplementation guide = Mockito.mock(SlimefunGuideImplementation.class);
    PlayerProfile profile = prepare(guide, history -> history.add(query));
    Mockito.verify(guide).openSearch(profile, query, false);
}
Also used : PlayerProfile(io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

SlimefunItemStack (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)17 SlimefunItem (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem)16 ItemStack (org.bukkit.inventory.ItemStack)14 DisplayName (org.junit.jupiter.api.DisplayName)14 Test (org.junit.jupiter.api.Test)14 Player (org.bukkit.entity.Player)12 CustomItemStack (io.github.bakedlibs.dough.items.CustomItemStack)10 Slimefun (io.github.thebusybiscuit.slimefun4.implementation.Slimefun)8 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)7 NamespacedKey (org.bukkit.NamespacedKey)7 PlayerProfile (io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile)6 ArrayList (java.util.ArrayList)6 Nonnull (javax.annotation.Nonnull)6 BeforeAll (org.junit.jupiter.api.BeforeAll)4 TagMisconfigurationException (io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException)3 ItemGroup (io.github.thebusybiscuit.slimefun4.api.items.ItemGroup)3 Block (org.bukkit.block.Block)3 ItemMeta (org.bukkit.inventory.meta.ItemMeta)3 PotionEffect (org.bukkit.potion.PotionEffect)3 AndroidMineEvent (io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent)2