mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 06:59:27 +00:00
add first capture condition
This commit is contained in:
@@ -96,6 +96,7 @@ public class ContextKeys<T> {
|
||||
public static final ContextKeys<Double> BASE = of("base", Double.class);
|
||||
public static final ContextKeys<Integer> LOOT_ORDER = of("loot_order", Integer.class);
|
||||
public static final ContextKeys<Effect> EFFECT = of("effect", Effect.class);
|
||||
public static final ContextKeys<Boolean> FIRST_CAPTURE = of("first_capture", Boolean.class);
|
||||
|
||||
private final String key;
|
||||
private final Class<T> type;
|
||||
|
||||
@@ -623,6 +623,10 @@ public class CustomFishingHook {
|
||||
if (!nextLoot.disableStats()) {
|
||||
plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresent(
|
||||
userData -> {
|
||||
int amount = userData.statistics().getAmount(nextLoot.statisticKey().amountKey());
|
||||
if (amount == 0) {
|
||||
context.arg(ContextKeys.FIRST_CAPTURE, true);
|
||||
}
|
||||
Pair<Integer, Integer> 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)).ifPresentOrElse(size -> {
|
||||
|
||||
@@ -113,7 +113,7 @@ public class VanillaMechanic implements HookMechanic {
|
||||
if (player.isOnline() && hook.isValid()) {
|
||||
AntiAutoFishing.prevent(player, hook);
|
||||
}
|
||||
}, RandomUtils.generateRandomInt(20, SparrowHeart.getInstance().getWaitTime(hook) + lureTime - 5), hook.getLocation());
|
||||
}, RandomUtils.generateRandomInt(20, Math.max(20, SparrowHeart.getInstance().getWaitTime(hook) + lureTime - 5)), hook.getLocation());
|
||||
}
|
||||
}, hook.getLocation());
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ subprojects {
|
||||
}
|
||||
}
|
||||
|
||||
fun versionBanner() = project.providers.exec {
|
||||
fun versionBanner(): String = project.providers.exec {
|
||||
commandLine("git", "rev-parse", "--short=8", "HEAD")
|
||||
}.standardOutput.asText.map { it.trim() }.getOrElse("Unknown")
|
||||
|
||||
fun builder() = project.providers.exec {
|
||||
fun builder(): String = project.providers.exec {
|
||||
commandLine("git", "config", "user.name")
|
||||
}.standardOutput.asText.map { it.trim() }.getOrElse("Unknown")
|
||||
@@ -166,6 +166,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
|
||||
}
|
||||
|
||||
private void registerBuiltInRequirements() {
|
||||
this.registerFirstCaptureRequirement();
|
||||
this.registerTimeRequirement();
|
||||
this.registerYRequirement();
|
||||
this.registerInWaterRequirement();
|
||||
@@ -458,6 +459,19 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
|
||||
}, "&&");
|
||||
}
|
||||
|
||||
private void registerFirstCaptureRequirement() {
|
||||
registerRequirement((args, actions, runActions) -> {
|
||||
boolean required = (boolean) args;
|
||||
return context -> {
|
||||
Boolean arg = context.arg(ContextKeys.FIRST_CAPTURE);
|
||||
boolean first = arg != null && arg;
|
||||
if (first == required) return true;
|
||||
if (runActions) ActionManager.trigger(context, actions);
|
||||
return false;
|
||||
};
|
||||
}, "first-capture");
|
||||
}
|
||||
|
||||
private void registerInWaterRequirement() {
|
||||
registerRequirement((args, actions, runActions) -> {
|
||||
boolean inWater = (boolean) args;
|
||||
|
||||
Reference in New Issue
Block a user