9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00

fix success-times

This commit is contained in:
XiaoMoMi
2025-01-20 18:15:08 +08:00
parent 66ce7da7e2
commit b52459a2b6
3 changed files with 27 additions and 3 deletions

View File

@@ -44,6 +44,7 @@ import net.momirealms.customfishing.api.util.EventUtils;
import net.momirealms.customfishing.api.util.PlayerUtils; import net.momirealms.customfishing.api.util.PlayerUtils;
import net.momirealms.customfishing.common.helper.AdventureHelper; import net.momirealms.customfishing.common.helper.AdventureHelper;
import net.momirealms.customfishing.common.plugin.scheduler.SchedulerTask; 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.TriConsumer;
import net.momirealms.customfishing.common.util.TriFunction; import net.momirealms.customfishing.common.util.TriFunction;
import net.momirealms.sparrow.heart.SparrowHeart; import net.momirealms.sparrow.heart.SparrowHeart;
@@ -604,8 +605,9 @@ public class CustomFishingHook {
if (!nextLoot.disableStats()) { if (!nextLoot.disableStats()) {
plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresent( plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresent(
userData -> { userData -> {
userData.statistics().addAmount(nextLoot.statisticKey().amountKey(), 1); Pair<Integer, Integer> result = userData.statistics().addAmount(nextLoot.statisticKey().amountKey(), 1);
context.arg(ContextKeys.TOTAL_AMOUNT, userData.statistics().getAmount(nextLoot.statisticKey().amountKey())); 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 -> { Optional.ofNullable(context.arg(ContextKeys.SIZE)).ifPresent(size -> {
float max = Math.max(0, userData.statistics().getMaxSize(nextLoot.statisticKey().sizeKey())); float max = Math.max(0, userData.statistics().getMaxSize(nextLoot.statisticKey().sizeKey()));
context.arg(ContextKeys.RECORD, max); context.arg(ContextKeys.RECORD, max);

View File

@@ -267,12 +267,19 @@ public class BukkitConfigManager extends ConfigManager {
MechanicType type = MechanicType.index().value(entry.getKey()); MechanicType type = MechanicType.index().value(entry.getKey());
if (entry.getValue() instanceof Section inner) { if (entry.getValue() instanceof Section inner) {
Map<ActionTrigger, Action<Player>[]> actionMap = new HashMap<>(); Map<ActionTrigger, Action<Player>[]> actionMap = new HashMap<>();
Map<ActionTrigger, TreeMap<Integer, Action<Player>[]>> actionTimesMap = new HashMap<>();
for (Map.Entry<String, Object> innerEntry : inner.getStringRouteMappedValues(false).entrySet()) { for (Map.Entry<String, Object> innerEntry : inner.getStringRouteMappedValues(false).entrySet()) {
if (innerEntry.getValue() instanceof Section actionSection) { 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_ACTIONS.put(type, actionMap);
EventManager.GLOBAL_TIMES_ACTION.put(type, actionTimesMap);
} }
} }
} }
@@ -1183,6 +1190,21 @@ public class BukkitConfigManager extends ConfigManager {
Action<Player>[] actions = plugin.getActionManager().parseActions(section); Action<Player>[] actions = plugin.getActionManager().parseActions(section);
return builder -> builder.action(ActionTrigger.NEW_SIZE_RECORD, actions); return builder -> builder.action(ActionTrigger.NEW_SIZE_RECORD, actions);
}, "events", "new_size_record"); }, "events", "new_size_record");
this.registerEventParser(object -> {
Section section = (Section) object;
Action<Player>[] 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<Integer, Action<Player>[]> actions = plugin.getActionManager().parseTimesActions(section);
return builder -> builder.actionTimes(ActionTrigger.SUCCESS, actions);
}, "events", "success_times");
this.registerEventParser(object -> {
Section section = (Section) object;
TreeMap<Integer, Action<Player>[]> actions = plugin.getActionManager().parseTimesActions(section);
return builder -> builder.actionTimes(ActionTrigger.SUCCESS, actions);
}, "events", "success-times");
} }
private void registerBuiltInLootParser() { private void registerBuiltInLootParser() {

View File

@@ -1,6 +1,6 @@
# Project settings # Project settings
# Rule: [major update].[feature update].[bug fix] # Rule: [major update].[feature update].[bug fix]
project_version=2.3.2 project_version=2.3.3
config_version=38 config_version=38
project_group=net.momirealms project_group=net.momirealms