Search in sources :

Example 26 with Slimefun

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

the class TestMonsterJerky method registerSlimefunItem.

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

Example 27 with Slimefun

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

the class TestClimbingPick method registerSlimefunItem.

@Override
public ClimbingPick registerSlimefunItem(Slimefun plugin, String id) {
    SlimefunItemStack item = new SlimefunItemStack(id, Material.IRON_PICKAXE, "&5Test Pick", id);
    ClimbingPick pick = new ClimbingPick(TestUtilities.getItemGroup(plugin, "climbing_pick"), item, RecipeType.NULL, new ItemStack[9]) {

        @Override
        public boolean isDualWieldingEnabled() {
            return false;
        }
    };
    pick.register(plugin);
    Assertions.assertFalse(pick.getClimbableSurfaces().isEmpty());
    return pick;
}
Also used : SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)

Example 28 with Slimefun

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

the class TestPortableDustbin method registerSlimefunItem.

@Override
public PortableDustbin registerSlimefunItem(Slimefun plugin, String id) {
    SlimefunItemStack item = new SlimefunItemStack(id, Material.BUCKET, "&4Test Dustbin");
    PortableDustbin dustbin = new PortableDustbin(TestUtilities.getItemGroup(plugin, "dustbin"), item, RecipeType.NULL, new ItemStack[9]);
    dustbin.register(plugin);
    return dustbin;
}
Also used : SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)

Example 29 with Slimefun

use of io.github.thebusybiscuit.slimefun4.implementation.Slimefun in project FN-FAL-s-Amplifications by FN-FAL113.

the class MainStick method transformWeapon.

/**
 * transform the weapon back to a stick if player doesn't have enough exp levels
 * @param p the player involved
 * @param item the weapon used
 * @param slimefunItem the item as an slimefun item instance
 * @param finalLore the final changes to the persistent lore before transforming the weapon
 * @param incrementLevel the value for incrementing the current exp level pdc data
 */
public void transformWeapon(Player p, ItemStack item, SlimefunItemStack slimefunItem, String finalLore, int incrementLevel, int damageAmount, boolean isLevelDeducted) {
    CustomItemStack item2 = new CustomItemStack(slimefunItem);
    ItemMeta meta = item.getItemMeta();
    List<String> lore = meta.getLore();
    PersistentDataContainer pdc = meta.getPersistentDataContainer();
    int xpAmount = getPdc(pdc, getStorageKey());
    int damageInflicted = damageAmount + getPdc(pdc, getStorageKey2());
    pdc.set(getStorageKey2(), PersistentDataType.INTEGER, damageInflicted);
    if (isLevelDeducted) {
        int amount = ++xpAmount + incrementLevel;
        pdc.set(getStorageKey(), PersistentDataType.INTEGER, amount);
        meta.setLore(loreUpdate(lore, damageInflicted, amount, finalLore));
    } else {
        meta.setLore(loreUpdate(lore, damageInflicted, xpAmount, finalLore));
    }
    item.setItemMeta(meta);
    if (p.getLevel() <= getRequiredLevel()) {
        if (lore.size() >= 4) {
            lore.subList(3, lore.size()).clear();
        }
        meta.setLore(lore);
        meta.getEnchants().forEach((enchant, value) -> meta.removeEnchant(enchant));
        item.setItemMeta(meta);
        item.setType(item2.getType());
    }
}
Also used : CustomItemStack(io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta) PersistentDataContainer(org.bukkit.persistence.PersistentDataContainer)

Example 30 with Slimefun

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

the class SetData method execute.

@Override
protected void execute(@Nonnull CommandSender commandSender, @Nonnull String[] strings) {
    if (!(commandSender instanceof Player)) {
        commandSender.sendMessage("Only players can use this!");
        return;
    }
    if (strings.length != 2) {
        commandSender.sendMessage(ChatColor.RED + "You must specify a key and value to set!");
        return;
    }
    Player p = (Player) commandSender;
    Block target = p.getTargetBlockExact(8, FluidCollisionMode.NEVER);
    if (target == null || target.getType() == Material.AIR) {
        p.sendMessage(ChatColor.RED + "You need to target a block to use this command!");
        return;
    }
    String id = BlockStorage.getLocationInfo(target.getLocation(), "id");
    if (id == null) {
        p.sendMessage(ChatColor.RED + "You need to target a slimefun block to use this command!");
        return;
    }
    if (strings[0].equals("id")) {
        p.sendMessage(ChatColor.RED + "You cannot change the id of this block, it could cause internal issues!");
        return;
    }
    if (strings[1].equals("\\remove")) {
        p.sendMessage(ChatColor.GREEN + "Successfully removed value of key '" + strings[0] + "' in " + id);
        BlockStorage.addBlockInfo(target, strings[0], null);
    } else {
        p.sendMessage(ChatColor.GREEN + "Successfully set key '" + strings[0] + "' to value '" + strings[1] + "' in " + id);
        BlockStorage.addBlockInfo(target, strings[0], strings[1]);
    }
    SlimefunItem unit = SlimefunItem.getById(id);
    if (unit instanceof StorageUnit) {
        ((StorageUnit) unit).reloadCache(target);
    }
}
Also used : Player(org.bukkit.entity.Player) Block(org.bukkit.block.Block) StorageUnit(io.github.mooy1.infinityexpansion.items.storage.StorageUnit) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem)

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