1
0
mirror of https://github.com/nkomarn/harbor.git synced 2024-12-17 22:07:35 +01:00

Clear weather for instant skip as well

This commit is contained in:
Mykyta Komarnytskyy 2020-12-11 11:07:50 -08:00
parent 2c871f2b26
commit 308d890c00
2 changed files with 21 additions and 12 deletions

View File

@ -21,18 +21,7 @@ public class AccelerateNightTask extends BukkitRunnable {
this.world = world;
harbor.getMessages().sendRandomChatMessage(world, "messages.chat.night-skipping");
Bukkit.getScheduler().runTask(harbor, () -> {
Config config = harbor.getConfiguration();
if (config.getBoolean("night-skip.clear-rain")) {
world.setStorm(false);
}
if (config.getBoolean("night-skip.clear-thunder")) {
world.setThundering(false);
}
});
checker.clearWeather(world);
runTaskTimer(harbor, 1, 1);
}

View File

@ -85,6 +85,7 @@ public class Checker extends BukkitRunnable {
if (config.getBoolean("night-skip.instant-skip")) {
messages.sendRandomChatMessage(world, "messages.chat.night-skipped");
clearWeather(world);
Bukkit.getScheduler().runTask(harbor, () -> world.setTime(config.getInteger("night-skip.daytime-ticks")));
return;
}
@ -248,4 +249,23 @@ public class Checker extends BukkitRunnable {
public void resetStatus(@NotNull World world) {
skippingWorlds.remove(world.getUID());
}
/**
* Resets the weather states in the provided world.
*
* @param world The world for which to clear weather.
*/
public void clearWeather(@NotNull World world) {
Bukkit.getScheduler().runTask(harbor, () -> {
Config config = harbor.getConfiguration();
if (world.hasStorm() && config.getBoolean("night-skip.clear-rain")) {
world.setStorm(false);
}
if (world.isThundering() && config.getBoolean("night-skip.clear-thunder")) {
world.setThundering(false);
}
});
}
}