Search in sources :

Example 1 with ItemHandler

use of com.github.sirblobman.api.nms.ItemHandler in project CombatLogX by SirBlobman.

the class StoredInventory method loadItemStack.

@Nullable
private static ItemStack loadItemStack(CitizensExpansion expansion, ConfigurationSection section, String path) {
    Validate.notNull(section, "section must not be null!");
    Validate.notEmpty(path, "path must not be empty!");
    if (!section.isSet(path)) {
        return null;
    }
    if (!section.isString(path)) {
        return null;
    }
    String value = section.getString(path);
    if (value == null) {
        return null;
    }
    ICombatLogX plugin = expansion.getPlugin();
    MultiVersionHandler multiVersionHandler = plugin.getMultiVersionHandler();
    ItemHandler itemHandler = multiVersionHandler.getItemHandler();
    return itemHandler.fromBase64String(value);
}
Also used : MultiVersionHandler(com.github.sirblobman.api.nms.MultiVersionHandler) ItemHandler(com.github.sirblobman.api.nms.ItemHandler) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with ItemHandler

use of com.github.sirblobman.api.nms.ItemHandler in project CombatLogX by SirBlobman.

the class StoredInventory method saveItemStack.

private static void saveItemStack(CitizensExpansion expansion, ConfigurationSection section, String path, ItemStack item) {
    if (item == null) {
        section.set(path, null);
        return;
    }
    ICombatLogX plugin = expansion.getPlugin();
    MultiVersionHandler multiVersionHandler = plugin.getMultiVersionHandler();
    ItemHandler itemHandler = multiVersionHandler.getItemHandler();
    String base64 = itemHandler.toBase64String(item);
    section.set(path, base64);
}
Also used : MultiVersionHandler(com.github.sirblobman.api.nms.MultiVersionHandler) ItemHandler(com.github.sirblobman.api.nms.ItemHandler) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Aggregations

ItemHandler (com.github.sirblobman.api.nms.ItemHandler)2 MultiVersionHandler (com.github.sirblobman.api.nms.MultiVersionHandler)2 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)2 Nullable (org.jetbrains.annotations.Nullable)1