From b52459a2b68cf64a00432700bc7d29d89302d12b Mon Sep 17 00:00:00 2001 From: XiaoMoMi Date: Mon, 20 Jan 2025 18:15:08 +0800 Subject: [PATCH] fix success-times --- .../mechanic/fishing/CustomFishingHook.java | 4 +++- .../bukkit/config/BukkitConfigManager.java | 24 ++++++++++++++++++- gradle.properties | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/CustomFishingHook.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/CustomFishingHook.java index 71993695..e9467687 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/CustomFishingHook.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/CustomFishingHook.java @@ -44,6 +44,7 @@ import net.momirealms.customfishing.api.util.EventUtils; import net.momirealms.customfishing.api.util.PlayerUtils; import net.momirealms.customfishing.common.helper.AdventureHelper; import net.momirealms.customfishing.common.plugin.scheduler.SchedulerTask; +import net.momirealms.customfishing.common.util.Pair; import net.momirealms.customfishing.common.util.TriConsumer; import net.momirealms.customfishing.common.util.TriFunction; import net.momirealms.sparrow.heart.SparrowHeart; @@ -604,8 +605,9 @@ public class CustomFishingHook { if (!nextLoot.disableStats()) { plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresent( userData -> { - userData.statistics().addAmount(nextLoot.statisticKey().amountKey(), 1); + Pair result = userData.statistics().addAmount(nextLoot.statisticKey().amountKey(), 1); context.arg(ContextKeys.TOTAL_AMOUNT, userData.statistics().getAmount(nextLoot.statisticKey().amountKey())); + plugin.getEventManager().trigger(context, id, MechanicType.LOOT, ActionTrigger.SUCCESS, result.left(), result.right()); Optional.ofNullable(context.arg(ContextKeys.SIZE)).ifPresent(size -> { float max = Math.max(0, userData.statistics().getMaxSize(nextLoot.statisticKey().sizeKey())); context.arg(ContextKeys.RECORD, max); diff --git a/core/src/main/java/net/momirealms/customfishing/bukkit/config/BukkitConfigManager.java b/core/src/main/java/net/momirealms/customfishing/bukkit/config/BukkitConfigManager.java index a851999e..f685e87e 100644 --- a/core/src/main/java/net/momirealms/customfishing/bukkit/config/BukkitConfigManager.java +++ b/core/src/main/java/net/momirealms/customfishing/bukkit/config/BukkitConfigManager.java @@ -267,12 +267,19 @@ public class BukkitConfigManager extends ConfigManager { MechanicType type = MechanicType.index().value(entry.getKey()); if (entry.getValue() instanceof Section inner) { Map[]> actionMap = new HashMap<>(); + Map[]>> actionTimesMap = new HashMap<>(); for (Map.Entry innerEntry : inner.getStringRouteMappedValues(false).entrySet()) { if (innerEntry.getValue() instanceof Section actionSection) { - actionMap.put(ActionTrigger.valueOf(innerEntry.getKey().toUpperCase(Locale.ENGLISH)), plugin.getActionManager().parseActions(actionSection)); + String trigger = innerEntry.getKey().toUpperCase(Locale.ENGLISH); + if (trigger.equals("SUCCESS_TIMES") || trigger.equals("SUCCESS-TIMES")) { + actionTimesMap.put(ActionTrigger.SUCCESS, plugin.getActionManager().parseTimesActions(actionSection)); + } else { + actionMap.put(ActionTrigger.valueOf(trigger), plugin.getActionManager().parseActions(actionSection)); + } } } EventManager.GLOBAL_ACTIONS.put(type, actionMap); + EventManager.GLOBAL_TIMES_ACTION.put(type, actionTimesMap); } } } @@ -1183,6 +1190,21 @@ public class BukkitConfigManager extends ConfigManager { Action[] actions = plugin.getActionManager().parseActions(section); return builder -> builder.action(ActionTrigger.NEW_SIZE_RECORD, actions); }, "events", "new_size_record"); + this.registerEventParser(object -> { + Section section = (Section) object; + Action[] actions = plugin.getActionManager().parseActions(section); + return builder -> builder.action(ActionTrigger.NEW_SIZE_RECORD, actions); + }, "events", "new-size-record"); + this.registerEventParser(object -> { + Section section = (Section) object; + TreeMap[]> actions = plugin.getActionManager().parseTimesActions(section); + return builder -> builder.actionTimes(ActionTrigger.SUCCESS, actions); + }, "events", "success_times"); + this.registerEventParser(object -> { + Section section = (Section) object; + TreeMap[]> actions = plugin.getActionManager().parseTimesActions(section); + return builder -> builder.actionTimes(ActionTrigger.SUCCESS, actions); + }, "events", "success-times"); } private void registerBuiltInLootParser() { diff --git a/gradle.properties b/gradle.properties index 40c21c41..3458945d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # Project settings # Rule: [major update].[feature update].[bug fix] -project_version=2.3.2 +project_version=2.3.3 config_version=38 project_group=net.momirealms