Skip to content

Commit

Permalink
temp fix for item parsing in 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Jun 22, 2024
1 parent bf62206 commit 61009cc
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.hsgamer.hscore.common.MapUtils;
import me.hsgamer.modularmob.api.abstraction.LivingMobModifier;
import me.hsgamer.modularmob.api.abstraction.RandomListMobModifier;
import me.hsgamer.modularmob.util.ConfigUtil;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EntityEquipment;
Expand All @@ -12,6 +13,7 @@
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;

public class ItemEquipmentModifier implements LivingMobModifier, RandomListMobModifier.Chance {
private final int chance;
Expand All @@ -25,7 +27,10 @@ public ItemEquipmentModifier(Object value, Slot slot) {

chance = Optional.ofNullable(map.get("chance")).map(String::valueOf).map(Integer::parseInt).orElse(1);
dropChance = Optional.ofNullable(map.get("drop-chance")).map(String::valueOf).map(Float::parseFloat).orElse(0F);
item = Optional.ofNullable(map.get("item")).flatMap(MapUtils::castOptionalStringObjectMap).map(XItemStack::deserialize).orElseGet(() -> new ItemStack(Material.AIR));
item = Optional.ofNullable(map.get("item"))
.flatMap(MapUtils::castOptionalStringObjectMap)
.map(itemMap -> XItemStack.edit(new ItemStack(Material.STONE), ConfigUtil.mapToConfigSection(itemMap), Function.identity(), null))
.orElseGet(() -> new ItemStack(Material.AIR));
}

@Override
Expand Down

0 comments on commit 61009cc

Please sign in to comment.