9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-26 18:39:11 +00:00
This commit is contained in:
XiaoMoMi
2023-11-12 20:44:21 +08:00
parent 3b0d3b9147
commit 0c0a0d8f2b
6 changed files with 33 additions and 43 deletions

View File

@@ -299,15 +299,13 @@ public class FishingManagerImpl implements Listener, FishingManager {
}
// Check mechanic requirements
if (!RequirementManager.isRequirementMet(
fishingPreparation, RequirementManagerImpl.mechanicRequirements
fishingPreparation, RequirementManagerImpl.mechanicRequirements
)) {
removeTempFishingState(player);
return;
}
// Merge rod/bait/util effects
FishingEffect initialEffect = plugin.getEffectManager().getInitialEffect();
fishingPreparation.mergeEffect(initialEffect);
// Merge totem effects
EffectCarrier totemEffect = plugin.getTotemManager().getTotemEffect(player.getLocation());
if (totemEffect != null)

View File

@@ -26,7 +26,7 @@ import net.momirealms.customfishing.api.event.LavaFishingEvent;
import net.momirealms.customfishing.api.mechanic.TempFishingState;
import net.momirealms.customfishing.api.mechanic.action.ActionTrigger;
import net.momirealms.customfishing.api.mechanic.condition.FishingPreparation;
import net.momirealms.customfishing.api.mechanic.effect.Effect;
import net.momirealms.customfishing.api.mechanic.effect.FishingEffect;
import net.momirealms.customfishing.api.mechanic.loot.Loot;
import net.momirealms.customfishing.api.scheduler.CancellableTask;
import net.momirealms.customfishing.setting.CFConfig;
@@ -56,7 +56,7 @@ public class HookCheckTimerTask implements Runnable {
private LavaEffectTask lavaFishingTask;
private final FishHook fishHook;
private final FishingPreparation fishingPreparation;
private final Effect initialEffect;
private final FishingEffect initialEffect;
private final int lureLevel;
private boolean firstTime;
private boolean fishHooked;
@@ -77,7 +77,7 @@ public class HookCheckTimerTask implements Runnable {
FishingManagerImpl manager,
FishHook fishHook,
FishingPreparation fishingPreparation,
Effect initialEffect
FishingEffect initialEffect
) {
this.manager = manager;
this.fishHook = fishHook;
@@ -102,15 +102,16 @@ public class HookCheckTimerTask implements Runnable {
}
if (fishHook.getLocation().getBlock().getType() == Material.LAVA) {
// if player can fish in lava
if (!initialEffect.canLavaFishing()) {
this.destroy();
return;
}
if (firstTime) {
this.fishingPreparation.setLocation(fishHook.getLocation());
this.fishingPreparation.mergeEffect(initialEffect);
if (!initialEffect.canLavaFishing()) {
this.destroy();
return;
}
this.fishingPreparation.insertArg("{lava}", "true");
this.fishingPreparation.triggerActions(ActionTrigger.LAND);
FishHookLandEvent event = new FishHookLandEvent(fishingPreparation.getPlayer(), FishHookLandEvent.Target.LAVA, fishHook);
FishHookLandEvent event = new FishHookLandEvent(fishingPreparation.getPlayer(), FishHookLandEvent.Target.LAVA, fishHook, initialEffect);
Bukkit.getPluginManager().callEvent(event);
firstTime = false;
this.setTempState();
@@ -138,10 +139,11 @@ public class HookCheckTimerTask implements Runnable {
}
if (fishHook.isInWater()) {
this.fishingPreparation.setLocation(fishHook.getLocation());
this.fishingPreparation.mergeEffect(initialEffect);
this.fishingPreparation.insertArg("{lava}", "false");
this.fishingPreparation.insertArg("{open-water}", String.valueOf(fishHook.isInOpenWater()));
this.fishingPreparation.triggerActions(ActionTrigger.LAND);
FishHookLandEvent event = new FishHookLandEvent(fishingPreparation.getPlayer(), FishHookLandEvent.Target.WATER, fishHook);
FishHookLandEvent event = new FishHookLandEvent(fishingPreparation.getPlayer(), FishHookLandEvent.Target.WATER, fishHook, initialEffect);
Bukkit.getPluginManager().callEvent(event);
// if the hook is in water
// then cancel the task

View File

@@ -361,6 +361,9 @@ public class ItemManagerImpl implements ItemManager, Listener {
@NotNull
public ItemStack build(Player player, ItemBuilder builder, Map<String, String> placeholders) {
ItemStack temp = itemLibraryMap.get(builder.getLibrary()).buildItem(player, builder.getId());
if (temp.getType() == Material.AIR) {
return temp;
}
temp.setAmount(builder.getAmount());
NBTItem nbtItem = new NBTItem(temp);
for (ItemBuilder.ItemPropertyEditor editor : builder.getEditors()) {

View File

@@ -1,25 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.mechanic.misc.value;
import org.bukkit.entity.Player;
public interface Value {
double get(Player player);
}