Search in sources :

Example 1 with SlimefunItems

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

the class CustomTextureService method register.

/**
 * This method registers the given {@link SlimefunItem SlimefunItems} to this {@link CustomTextureService}.
 * If saving is enabled, it will save them to the {@link Config} file.
 *
 * @param items
 *            The {@link SlimefunItem SlimefunItems} to register
 * @param save
 *            Whether to save this file
 */
public void register(@Nonnull Collection<SlimefunItem> items, boolean save) {
    Validate.notEmpty(items, "items must neither be null or empty.");
    loadDefaultValues();
    for (SlimefunItem item : items) {
        if (item != null) {
            config.setDefaultValue(item.getId(), 0);
            if (config.getInt(item.getId()) != 0) {
                modified = true;
            }
        }
    }
    version = config.getString("version");
    if (save) {
        config.save();
    }
}
Also used : SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem)

Example 2 with SlimefunItems

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

the class SlimefunItemsProvider method getAsItemStack.

private ItemStack getAsItemStack(String fieldName) {
    Class<SlimefunItems> clazz = SlimefunItems.class;
    Field field;
    try {
        field = clazz.getField(fieldName);
        return (ItemStack) field.get(null);
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        throw new IllegalArgumentException("Could not find field SlimefunItems." + fieldName);
    }
}
Also used : Field(java.lang.reflect.Field) SlimefunItems(io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

SlimefunItem (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem)1 SlimefunItems (io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems)1 Field (java.lang.reflect.Field)1 ItemStack (org.bukkit.inventory.ItemStack)1