Skip to content

Commit 4f0a888

Browse files
committed
Update HookCheckTimerTask.java
1 parent 716d730 commit 4f0a888

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

plugin/src/main/java/net/momirealms/customfishing/mechanic/fishing/HookCheckTimerTask.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ public void run() {
120120
this.fishingPreparation.triggerActions(ActionTrigger.LAND);
121121
FishHookLandEvent event = new FishHookLandEvent(fishingPreparation.getPlayer(), FishHookLandEvent.Target.LAVA, fishHook, initialEffect);
122122
Bukkit.getPluginManager().callEvent(event);
123-
this.setWaitTime();
124123
this.firstTime = false;
125124
this.setTempState();
126125
}
@@ -140,7 +139,8 @@ public void run() {
140139
return;
141140
}
142141
reserve = true;
143-
this.startLavaFishingMechanic();
142+
if (this.loot != null)
143+
this.startLavaFishingMechanic();
144144
this.makeHookStatic(fishHook.getLocation());
145145
}
146146
return;
@@ -154,10 +154,12 @@ public void run() {
154154
this.fishingPreparation.triggerActions(ActionTrigger.LAND);
155155
FishHookLandEvent event = new FishHookLandEvent(fishingPreparation.getPlayer(), FishHookLandEvent.Target.WATER, fishHook, initialEffect);
156156
Bukkit.getPluginManager().callEvent(event);
157-
// if the hook is in water
158-
// then cancel the task
159-
this.setWaitTime();
160157
this.setTempState();
158+
if (this.loot == null) {
159+
fishHook.setWaitTime(Integer.MAX_VALUE);
160+
} else {
161+
this.setWaitTime();
162+
}
161163
return;
162164
}
163165
}
@@ -188,7 +190,7 @@ public void cancelSubTask() {
188190
private void setTempState() {
189191
Loot nextLoot = CustomFishingPlugin.get().getLootManager().getNextLoot(initialEffect, fishingPreparation);
190192
if (nextLoot == null) {
191-
fishHook.setWaitTime(Integer.MAX_VALUE);
193+
this.loot = null;
192194
CustomFishingPlugin.get().debug("No loot available at " + fishingPreparation.getLocation());
193195
return;
194196
}
@@ -200,11 +202,11 @@ private void setTempState() {
200202
fishingPreparation.insertArg("{statistics_size}", nextLoot.getStatisticKey().getSizeKey());
201203
fishingPreparation.insertArg("{statistics_amount}", nextLoot.getStatisticKey().getAmountKey());
202204
}
203-
CustomFishingPlugin.get().getScheduler().runTaskAsync(() -> manager.setTempFishingState(fishingPreparation.getPlayer(), new TempFishingState(
205+
manager.setTempFishingState(fishingPreparation.getPlayer(), new TempFishingState(
204206
initialEffect,
205207
fishingPreparation,
206208
nextLoot
207-
)));
209+
));
208210
}
209211

210212
/**

0 commit comments

Comments
 (0)