Search in sources :

Example 41 with Slimefun

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

the class TestMeatJerky method registerSlimefunItem.

@Override
public MeatJerky registerSlimefunItem(Slimefun plugin, String id) {
    SlimefunItemStack item = new SlimefunItemStack(id, Material.COOKED_BEEF, "&5Test Jerky");
    MeatJerky meat = new MeatJerky(TestUtilities.getItemGroup(plugin, "test_jerky"), item, RecipeType.NULL, new ItemStack[9]);
    meat.register(plugin);
    return meat;
}
Also used : SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)

Example 42 with Slimefun

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

the class TestSoulboundItem method testSoulboundSlimefunItem.

@Test
@DisplayName("Test that soulbound Slimefun Items are soulbound")
void testSoulboundSlimefunItem() {
    SlimefunItem item = new SoulboundMock(new ItemGroup(new NamespacedKey(plugin, "soulbound_itemgroup"), new CustomItemStack(Material.REDSTONE, "&4Walshrus forever")));
    item.register(plugin);
    Assertions.assertTrue(SlimefunUtils.isSoulbound(item.getItem()));
}
Also used : ItemGroup(io.github.thebusybiscuit.slimefun4.api.items.ItemGroup) NamespacedKey(org.bukkit.NamespacedKey) 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)

Example 43 with Slimefun

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

the class TestResearchCommand method testResearchSpecific.

@Test
@DisplayName("Test /sf research <research id>")
void testResearchSpecific() throws InterruptedException {
    Slimefun.getRegistry().setResearchingEnabled(true);
    Player player = server.addPlayer();
    PlayerProfile profile = TestUtilities.awaitProfile(player);
    server.executeConsole("slimefun", "research", player.getName(), research.getKey().toString()).assertSucceeded();
    Assertions.assertTrue(profile.hasUnlocked(research));
    Assertions.assertFalse(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 44 with Slimefun

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

the class TestResearchCommand method testResearchReset.

@Test
@DisplayName("Test /sf research reset")
void testResearchReset() 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));
    server.executeConsole("slimefun", "research", player.getName(), "reset").assertSucceeded();
    Assertions.assertFalse(profile.hasUnlocked(research));
    Assertions.assertFalse(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 45 with Slimefun

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

the class SlimefunUtils method getCustomHead.

/**
 * This method returns an {@link ItemStack} for the given texture.
 * The result will be a Player Head with this texture.
 *
 * @param texture
 *            The texture for this head (base64 or hash)
 *
 * @return An {@link ItemStack} with this Head texture
 */
@Nonnull
public static ItemStack getCustomHead(@Nonnull String texture) {
    Validate.notNull(texture, "The provided texture is null");
    if (Slimefun.instance() == null) {
        throw new PrematureCodeException("You cannot instantiate a custom head before Slimefun was loaded.");
    }
    if (Slimefun.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) {
        // com.mojang.authlib.GameProfile does not exist in a Test Environment
        return new ItemStack(Material.PLAYER_HEAD);
    }
    String base64 = texture;
    if (CommonPatterns.HEXADECIMAL.matcher(texture).matches()) {
        base64 = Base64.getEncoder().encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}").getBytes(StandardCharsets.UTF_8));
    }
    PlayerSkin skin = PlayerSkin.fromBase64(base64);
    return PlayerHead.getItemStack(skin);
}
Also used : PlayerSkin(io.github.bakedlibs.dough.skins.PlayerSkin) PrematureCodeException(io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException) ItemStack(org.bukkit.inventory.ItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) Nonnull(javax.annotation.Nonnull)

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