From c0db08a30afc27fd2b195e6d2bf38db89acbcaaa Mon Sep 17 00:00:00 2001 From: MaiHuynhLinh <119683432+NguyenSonhoa@users.noreply.github.com> Date: Mon, 2 Jun 2025 16:18:48 +0700 Subject: [PATCH] Update FishingGears.java --- .../api/mechanic/fishing/FishingGears.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/FishingGears.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/FishingGears.java index d65dbf0b..3a410158 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/FishingGears.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/FishingGears.java @@ -239,6 +239,27 @@ public class FishingGears { } } } + ItemStack helmet = playerInventory.getHelmet(); + ItemStack chestplate = playerInventory.getChestplate(); + ItemStack leggings = playerInventory.getLeggings(); + ItemStack boots = playerInventory.getBoots(); + + ItemStack[] armorContents = new ItemStack[]{helmet, chestplate, leggings, boots}; + List> gearItemsList = new ArrayList<>(); + + for (ItemStack armorPiece : armorContents) { + if (armorPiece != null && armorPiece.getType() != Material.AIR) { + String gearID = BukkitCustomFishingPlugin.getInstance().getItemManager().getItemID(armorPiece); + List itemTypes = MechanicType.getTypeByID(gearID); + if (itemTypes != null && itemTypes.contains(MechanicType.GEAR)) { + gearItemsList.add(Pair.of(gearID, armorPiece)); + BukkitCustomFishingPlugin.getInstance().getEffectManager().getEffectModifier(gearID, MechanicType.GEAR).ifPresent(fishingGears.modifiers::add); + } + } + } + if (!gearItemsList.isEmpty()) { + fishingGears.gears.put(GearType.GEAR, gearItemsList); + } // check requirements before checking totems for (EffectModifier modifier : fishingGears.modifiers) { @@ -283,7 +304,17 @@ public class FishingGears { ((context, itemStack) -> {}), ((context, itemStack) -> {}) ); - + public static final GearType GEAR = new GearType(MechanicType.GEAR, + ((context, itemStack) -> {}), // castFunction + ((context, itemStack) -> {}), // reelFunction + ((context, itemStack) -> {}), // biteFunction + ((context, itemStack) -> {}), // successFunction + ((context, itemStack) -> {}), // failureFunction + ((context, itemStack) -> {}), // lureFunction + ((context, itemStack) -> {}), // escapeFunction + ((context, itemStack) -> {}), // landFunction + ((context, itemStack) -> {}) // hookFunction + ); public static final GearType BAIT = new GearType(MechanicType.BAIT, ((context, itemStack) -> { if (context.holder().getGameMode() != GameMode.CREATIVE)