1
0
mirror of https://github.com/nkomarn/harbor.git synced 2024-11-16 07:05:22 +01:00

🔨 Fix up weather clearing + improve day checking

This commit is contained in:
Mykyta 2020-04-03 12:28:49 -07:00
parent 04994edbf4
commit b5c7f60fdd
No known key found for this signature in database
GPG Key ID: C147E30C19EA3570
4 changed files with 20 additions and 16 deletions

View File

@ -17,7 +17,7 @@ import java.util.List;
public class HarborCommand implements TabExecutor {
@Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
final String prefix = Config.getString("messages.miscellaneous.prefix");
final String prefix = Config.getString("messages.miscellaneous.chat-prefix");
if (args.length < 1) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "&7Harbor version "

View File

@ -1,8 +1,10 @@
package xyz.nkomarn.Harbor.task;
import org.bukkit.Bukkit;
import org.bukkit.Statistic;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitRunnable;
import xyz.nkomarn.Harbor.Harbor;
import xyz.nkomarn.Harbor.util.Config;
import xyz.nkomarn.Harbor.util.Messages;
@ -20,12 +22,12 @@ public class AccelerateNightTask extends BukkitRunnable {
final int dayTime = Config.getInteger("night-skip.daytime-ticks");
final int timeRate = Config.getInteger("night-skip.time-rate");
if (time >= (dayTime - timeRate * 2) && time <= dayTime) {
if (Config.getBoolean("features.clear-rain")) {
if (time >= (dayTime - timeRate * 1.5) && time <= dayTime) {
if (Config.getBoolean("night-skip.clear-rain")) {
world.setStorm(false);
}
if (Config.getBoolean("features.clear-thunder")) {
if (Config.getBoolean("night-skip.clear-thunder")) {
world.setThundering(false);
}
@ -33,7 +35,7 @@ public class AccelerateNightTask extends BukkitRunnable {
world.getPlayers().forEach(player -> player.setStatistic(Statistic.TIME_SINCE_REST, 0));
}
Checker.skippingWorlds.remove(world);
Bukkit.getScheduler().runTaskLaterAsynchronously(Harbor.getHarbor(), () -> Checker.skippingWorlds.remove(world), 20);
Messages.sendRandomChatMessage(world, "messages.chat.night-skipped");
this.cancel();
} else {

View File

@ -32,21 +32,23 @@ public class Checker implements Runnable {
if (sleeping > 0 && needed > 0) {
// TODO redo bossbars
final double sleepingPercentage = Math.min(1, (double) sleeping / getSkipAmount(world));
Messages.sendBossBarMessage(world, Config.getString("messages.bossbar.sleeping.message"),
BarColor.valueOf(Config.getString("messages.bossbar.sleeping.color")), sleepingPercentage);
Messages.sendBossBarMessage(world, Config.getString("messages.bossbar.players-sleeping.message"),
BarColor.valueOf(Config.getString("messages.bossbar.players-sleeping.color")), sleepingPercentage);
Messages.sendActionBarMessage(world, Config.getString("messages.actionbar.players-sleeping"));
} else if (needed == 0 && sleeping > 0) {
Messages.sendBossBarMessage(world, Config.getString("messages.bossbar.everyone.message"),
BarColor.valueOf(Config.getString("messages.bossbar.everyone.color")), 1);
Messages.sendBossBarMessage(world, Config.getString("messages.bossbar.night-skipping.message"),
BarColor.valueOf(Config.getString("messages.bossbar.night-skipping.color")), 1);
Messages.sendActionBarMessage(world, Config.getString("messages.actionbar.night-skipping"));
if (!Config.getBoolean("night-skip.enabled")) return;
if (Config.getBoolean("night-skip.instant-skip")) {
world.setTime(Config.getInteger("night-skip.daytime-ticks"));
Bukkit.getScheduler().runTask(Harbor.getHarbor(), () ->
world.setTime(Config.getInteger("night-skip.daytime-ticks")));
Messages.sendRandomChatMessage(world, "messages.chat.night-skipped");
} else {
skippingWorlds.add(world);
new AccelerateNightTask(world).runTaskTimer(Harbor.getHarbor(), 1, 1);
@ -99,6 +101,6 @@ public class Checker implements Runnable {
if (Config.getBoolean("exclusions.exclude-vanished")) {
for (MetadataValue meta : player.getMetadata("vanished")) if (meta.asBoolean()) return true;
}
return excludedByCreative || excludedBySpectator || excludedByPermission || excludedByAfk;
return excludedByCreative || excludedBySpectator || excludedByPermission || excludedByAfk || player.isSleepingIgnored();
}
}

View File

@ -9,10 +9,10 @@ night-skip:
enabled: true # Skip the night if a percentage of the players in a world are sleeping
percentage: 50 # Percentage of players required to be sleeping to skip the night (0 - 100)
time-rate: 60 # The amount of ticks added to the current time every tick when skipping the night
daytime-ticks: 1000 # The time in ticks that Harbor considers day TODO
daytime-ticks: 1200 # The time in ticks that Harbor considers day
instant-skip: false # Instantly skip the night instead of showing the full animation
variable-speed: false # Increase the night skipping speed based on the amount of sleeping players
speed-multiplier: 0.5 # Multiplier used for variable night skipping (TODO explain formula)
variable-rate: false # Increase the night skipping speed based on the amount of sleeping players
rate-multiplier: 0.5 # Multiplier used for variable night skipping (TODO explain formula)
clear-rain: true # Clear rain (if it's raining) when the night is skipped
clear-thunder: true # Clear thunder (if it's thundering) when the night is skipped
reset-phantom-statistic: true # Treats everyone online as if they have slept in the last 3 days after the night is skipped (check out /gamerule doInsomnia on 1.15+)
@ -48,8 +48,8 @@ messages:
- "&eArghh, it's so bright outside."
actionbar:
enabled: true
players-sleeping: "&e[sleeping] out of [needed] players are sleeping ([more] more needed to skip)."
night-skipping: "&eEveryone is sleeping. Sweet dreams!"
players-sleeping: "&e[sleeping] out of [needed] players are sleeping ([more] more needed to skip)"
night-skipping: "&eEveryone is sleeping- sweet dreams!"
bossbar:
enabled: true
players-sleeping: