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:
@@ -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<Integer, Integer> 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);
|
||||
|
||||
@@ -267,12 +267,19 @@ public class BukkitConfigManager extends ConfigManager {
|
||||
MechanicType type = MechanicType.index().value(entry.getKey());
|
||||
if (entry.getValue() instanceof Section inner) {
|
||||
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()) {
|
||||
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<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;
|
||||
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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user