9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2026-01-04 15:41:35 +00:00

fix async event

This commit is contained in:
XiaoMoMi
2024-01-25 01:32:33 +08:00
parent c979173ba9
commit 381566e531
4 changed files with 15 additions and 6 deletions

View File

@@ -79,7 +79,7 @@ public class CompetitionCommand {
} else {
FishingCompetition competition = CustomFishingPlugin.get().getCompetitionManager().getOnGoingCompetition();
if (competition != null) {
competition.end();
CustomFishingPlugin.get().getScheduler().runTaskAsync(competition::end);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_End_Competition);
} else {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_No_Competition_Ongoing);
@@ -99,7 +99,7 @@ public class CompetitionCommand {
} else {
FishingCompetition competition = CustomFishingPlugin.get().getCompetitionManager().getOnGoingCompetition();
if (competition != null) {
competition.stop();
CustomFishingPlugin.get().getScheduler().runTaskAsync(competition::stop);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_Stop_Competition);
} else {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CFLocale.MSG_No_Competition_Ongoing);

View File

@@ -58,7 +58,13 @@ public class CompetitionManagerImpl implements CompetitionManager {
public void load() {
loadConfig();
this.timerCheckTask = plugin.getScheduler().runTaskAsyncTimer(
this::timerCheck,
() -> {
try {
timerCheck();
} catch (Exception e) {
e.printStackTrace();
}
},
1,
1,
TimeUnit.SECONDS
@@ -295,8 +301,10 @@ public class CompetitionManagerImpl implements CompetitionManager {
}, 1, TimeUnit.SECONDS);
} else {
// start instantly
this.currentCompetition = new Competition(config);
this.currentCompetition.start();
plugin.getScheduler().runTaskAsync(() -> {
this.currentCompetition = new Competition(config);
this.currentCompetition.start();
});
}
}