9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00
This commit is contained in:
XiaoMoMi
2024-12-10 17:05:24 +08:00
parent e3200a3d05
commit dfebe52f46
14 changed files with 169 additions and 17 deletions

View File

@@ -180,8 +180,6 @@ public class CustomFishingHook {
context.arg(ContextKeys.OTHER_Z, hook.getLocation().getBlockZ());
// get the next loot
Loot loot;
try {
loot = plugin.getLootManager().getNextLoot(tempEffect, context);
@@ -201,11 +199,11 @@ public class CustomFishingHook {
context.arg(ContextKeys.of("data_" + entry.getKey(), String.class), entry.getValue().render(context));
}
plugin.debug("Next loot: " + loot.id());
plugin.debug("Next Loot: " + loot.id());
plugin.debug(context);
// get its basic properties
Effect baseEffect = loot.baseEffect().toEffect(context);
plugin.debug(baseEffect);
plugin.debug("Loot Base Effect:" + baseEffect);
tempEffect.combine(baseEffect);
// apply the gears' effects
for (EffectModifier modifier : gears.effectModifiers()) {
@@ -218,6 +216,7 @@ public class CustomFishingHook {
EventUtils.fireAndForget(new FishingEffectApplyEvent(this, tempEffect, FishingEffectApplyEvent.Stage.FISHING));
// start the mechanic
plugin.debug("Final Effect:" + tempEffect);
mechanic.start(tempEffect);
this.tempFinalEffect = tempEffect;

View File

@@ -89,9 +89,10 @@ public class VanillaMechanic implements HookMechanic {
return;
}
if (!ConfigManager.overrideVanillaWaitTime()) {
int before = Math.max(SparrowHeart.getInstance().getWaitTime(hook), 0);
int rawBefore = SparrowHeart.getInstance().getWaitTime(hook);
int before = Math.max(rawBefore, 0);
int after = (int) Math.max(100, before * effect.waitTimeMultiplier() + effect.waitTimeAdder());
BukkitCustomFishingPlugin.getInstance().debug("Wait time: " + before + " -> " + after + " ticks");
BukkitCustomFishingPlugin.getInstance().debug("Wait time: " + rawBefore + " -> " + after + " ticks");
SparrowHeart.getInstance().setWaitTime(hook, after);
} else {
int before = ThreadLocalRandom.current().nextInt(ConfigManager.waterMaxTime() - ConfigManager.waterMinTime() + 1) + ConfigManager.waterMinTime();

View File

@@ -27,6 +27,7 @@ import org.bukkit.entity.FishHook;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -46,7 +47,7 @@ public interface ItemManager extends Reloadable {
boolean registerItem(@NotNull CustomFishingItem item);
/**
* Builds an internal representation of an item using the given context and item ID.
* Builds an item using the given context and item ID.
*
* @param context the {@link Context} in which the item is built
* @param id the ID of the item to be built
@@ -54,6 +55,7 @@ public interface ItemManager extends Reloadable {
* @throws NullPointerException if the item ID is not found
*/
@Nullable
@ApiStatus.Internal
ItemStack buildInternal(@NotNull Context<Player> context, @NotNull String id) throws NullPointerException;
/**