9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-28 11:29:15 +00:00
This commit is contained in:
XiaoMoMi
2023-11-14 22:39:35 +08:00
parent e7f946b662
commit f3ba8111ca
5 changed files with 20 additions and 12 deletions

View File

@@ -788,7 +788,9 @@ public class ActionManagerImpl implements ActionManager {
registerAction("random-title", (args, chance) -> {
if (args instanceof ConfigurationSection section) {
List<String> titles = section.getStringList("titles");
if (titles.size() == 0) titles.add("");
List<String> subtitles = section.getStringList("subtitles");
if (subtitles.size() == 0) subtitles.add("");
int fadeIn = section.getInt("fade-in", 20);
int stay = section.getInt("stay", 30);
int fadeOut = section.getInt("fade-out", 10);

View File

@@ -182,12 +182,13 @@ public class Competition implements FishingCompetition {
Pair<String, Double> competitionPlayer = iterator.next();
this.publicPlaceholders.put("{" + i + "_player}", competitionPlayer.left());
this.publicPlaceholders.put("{" + i + "_score}", String.format("%.2f", competitionPlayer.right()));
i++;
if (i < rewardsMap.size()) {
Player player = Bukkit.getPlayer(competitionPlayer.left());
if (player != null)
for (Action action : rewardsMap.get(String.valueOf(i)))
action.trigger(new Condition(player));
i++;
} else {
Action[] actions = rewardsMap.get("participation");
if (actions != null) {

View File

@@ -322,15 +322,7 @@ public class FishingManagerImpl implements Listener, FishingManager {
// Store fishhook entity and apply the effects
final FishHook fishHook = event.getHook();
this.hookCacheMap.put(player.getUniqueId(), fishHook);
// fishHook.setMaxWaitTime(Math.max(100, (int) (fishHook.getMaxWaitTime() * initialEffect.getHookTimeModifier())));
// fishHook.setMinWaitTime(Math.max(100, (int) (fishHook.getMinWaitTime() * initialEffect.getHookTimeModifier())));
if (CFConfig.overrideVanilla) {
double initialTime = ThreadLocalRandom.current().nextInt(CFConfig.waterMaxTime - CFConfig.waterMinTime + 1) + CFConfig.waterMinTime;
fishHook.setWaitTime(Math.max(1, (int) (initialTime * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
} else {
fishHook.setMaxWaitTime(Math.max(2, (int) (fishHook.getMaxWaitTime() * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
fishHook.setMinWaitTime(Math.max(1, (int) (fishHook.getMinWaitTime() * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
}
// Reduce amount & Send animation
var baitItem = fishingPreparation.getBaitItemStack();
if (baitItem != null) {

View File

@@ -113,7 +113,8 @@ public class HookCheckTimerTask implements Runnable {
this.fishingPreparation.triggerActions(ActionTrigger.LAND);
FishHookLandEvent event = new FishHookLandEvent(fishingPreparation.getPlayer(), FishHookLandEvent.Target.LAVA, fishHook, initialEffect);
Bukkit.getPluginManager().callEvent(event);
firstTime = false;
this.setWaitTime();
this.firstTime = false;
this.setTempState();
}
// simulate fishing mechanic
@@ -148,6 +149,7 @@ public class HookCheckTimerTask implements Runnable {
// if the hook is in water
// then cancel the task
this.destroy();
this.setWaitTime();
this.setTempState();
return;
}
@@ -289,4 +291,14 @@ public class HookCheckTimerTask implements Runnable {
public boolean isFishHooked() {
return fishHooked;
}
private void setWaitTime() {
if (CFConfig.overrideVanilla) {
double initialTime = ThreadLocalRandom.current().nextInt(CFConfig.waterMaxTime - CFConfig.waterMinTime + 1) + CFConfig.waterMinTime;
fishHook.setWaitTime(Math.max(1, (int) (initialTime * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
} else {
fishHook.setMaxWaitTime(Math.max(2, (int) (fishHook.getMaxWaitTime() * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
fishHook.setMinWaitTime(Math.max(1, (int) (fishHook.getMinWaitTime() * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
}
}
}