From 72c29a959151e37fb247ea1413bb230261a06937 Mon Sep 17 00:00:00 2001 From: XiaoMoMi Date: Mon, 31 Mar 2025 23:46:11 +0800 Subject: [PATCH] added actionbar tip --- .../customfishing/api/mechanic/context/ContextKeys.java | 2 ++ .../api/mechanic/fishing/CustomFishingHook.java | 5 ++++- .../customfishing/bukkit/game/BukkitGameManager.java | 4 ++++ core/src/main/resources/config.yml | 2 +- core/src/main/resources/contents/minigame/default.yml | 3 +++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/context/ContextKeys.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/context/ContextKeys.java index 69e30710..2c0bdbfb 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/context/ContextKeys.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/context/ContextKeys.java @@ -86,7 +86,9 @@ public class ContextKeys { public static final ContextKeys TIME_LEFT = of("time_left", String.class); public static final ContextKeys PROGRESS = of("progress", String.class); public static final ContextKeys RECORD = of("record", Float.class); + public static final ContextKeys PREVIOUS_RECORD = of("previous_record", Float.class); public static final ContextKeys RECORD_FORMATTED = of("record_formatted", String.class); + public static final ContextKeys PREVIOUS_RECORD_FORMATTED = of("previous_record_formatted", String.class); public static final ContextKeys CLICKS_LEFT = of("left_clicks", Integer.class); public static final ContextKeys REQUIRED_TIMES = of("clicks", Integer.class); public static final ContextKeys SLOT = of("hand", EquipmentSlot.class); 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 f62ebf56..18699065 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 @@ -620,9 +620,12 @@ public class CustomFishingHook { Pair result = userData.statistics().addAmount(nextLoot.statisticKey().amountKey(), 1); context.arg(ContextKeys.TOTAL_AMOUNT, userData.statistics().getAmount(nextLoot.statisticKey().amountKey())); Optional.ofNullable(context.arg(ContextKeys.SIZE)).ifPresent(size -> { - float max = Math.max(size, userData.statistics().getMaxSize(nextLoot.statisticKey().sizeKey())); + float currentRecord = userData.statistics().getMaxSize(nextLoot.statisticKey().sizeKey()); + float max = Math.max(size, currentRecord); context.arg(ContextKeys.RECORD, max); + context.arg(ContextKeys.PREVIOUS_RECORD, currentRecord); context.arg(ContextKeys.RECORD_FORMATTED, String.format("%.2f", max)); + context.arg(ContextKeys.PREVIOUS_RECORD_FORMATTED, String.format("%.2f", currentRecord)); if (userData.statistics().updateSize(nextLoot.statisticKey().sizeKey(), size)) { plugin.getEventManager().trigger(context, id, MechanicType.LOOT, ActionTrigger.NEW_SIZE_RECORD); } diff --git a/core/src/main/java/net/momirealms/customfishing/bukkit/game/BukkitGameManager.java b/core/src/main/java/net/momirealms/customfishing/bukkit/game/BukkitGameManager.java index 32d6150f..5b70f8d3 100644 --- a/core/src/main/java/net/momirealms/customfishing/bukkit/game/BukkitGameManager.java +++ b/core/src/main/java/net/momirealms/customfishing/bukkit/game/BukkitGameManager.java @@ -563,6 +563,7 @@ public class BukkitGameManager implements GameManager { private final String font = section.getString("subtitle.font"); private final String barImage = section.getString("subtitle.bar"); private final String tip = section.getString("tip"); + private final String actionbarTip = section.getString("actionbar-tip"); @Override public BiFunction gamingPlayerProvider() { @@ -599,6 +600,9 @@ public class BukkitGameManager implements GameManager { endGame(); return; } + if (actionbarTip != null) { + SparrowHeart.getInstance().sendActionBar(getPlayer(), AdventureHelper.miniMessageToJson(actionbarTip)); + } showUI(); } diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index 52f2b9f4..1d78b04c 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -56,7 +56,7 @@ mechanics: actions: actionbar_action: type: actionbar - value: '<#FFD700>[New Record] <#FFFFF0>You caught a(n) {nick} measuring <#FFA500>{size_formatted}cm long!' + value: '<#FFD700>[New Record] <#FFFFF0>You caught a(n) {nick} measuring <#FFA500>{size_formatted}cm long! <#C0C0C0>(Previous record: {previous_record_formatted}cm)' sound_action: type: sound value: diff --git a/core/src/main/resources/contents/minigame/default.yml b/core/src/main/resources/contents/minigame/default.yml index 56b7dbf1..e67289f0 100644 --- a/core/src/main/resources/contents/minigame/default.yml +++ b/core/src/main/resources/contents/minigame/default.yml @@ -1500,6 +1500,7 @@ tension_game_easy: title: '{progress}' # Tip would show on the title to guide the player how to play tip: 'Press to start' + actionbar-tip: 'Press to pull the fish' subtitle: font: 'customfishing:default' bar: '뀑' @@ -1539,6 +1540,7 @@ tension_game_normal: title: '{progress}' # Tip would show on the title to guide the player how to play tip: 'Press to start' + actionbar-tip: 'Press to pull the fish' subtitle: font: 'customfishing:default' bar: '뀑' @@ -1578,6 +1580,7 @@ tension_game_hard: title: '{progress}' # Tip would show on the title to guide the player how to play tip: 'Press to start' + actionbar-tip: 'Press to pull the fish' subtitle: font: 'customfishing:default' bar: '뀑'