diff --git a/src/main/java/xyz/nkomarn/Harbor/command/HarborCommand.java b/src/main/java/xyz/nkomarn/Harbor/command/HarborCommand.java index 241f247..00a5f57 100644 --- a/src/main/java/xyz/nkomarn/Harbor/command/HarborCommand.java +++ b/src/main/java/xyz/nkomarn/Harbor/command/HarborCommand.java @@ -47,10 +47,10 @@ public class HarborCommand implements TabExecutor { new AccelerateNightTask(world).runTaskTimer(Harbor.getHarbor(), 0L, 1); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "&7Forcing night skip in your world.")); + } else { + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + + Config.getString("messages.miscellaneous.unrecognized-command"))); } - - sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix - + Config.getString("messages.miscellaneous.unrecognized-command"))); return true; } diff --git a/src/main/java/xyz/nkomarn/Harbor/task/AccelerateNightTask.java b/src/main/java/xyz/nkomarn/Harbor/task/AccelerateNightTask.java index 26fee8c..30c021f 100644 --- a/src/main/java/xyz/nkomarn/Harbor/task/AccelerateNightTask.java +++ b/src/main/java/xyz/nkomarn/Harbor/task/AccelerateNightTask.java @@ -20,7 +20,13 @@ public class AccelerateNightTask extends BukkitRunnable { public void run() { final long time = world.getTime(); final int dayTime = Config.getInteger("night-skip.daytime-ticks"); - final int timeRate = Config.getInteger("night-skip.time-rate"); + final int sleeping = Checker.getSleeping(world).size(); + double timeRate = Config.getInteger("night-skip.time-rate"); + + if (Config.getBoolean("night-skip.proportional-acceleration")) { + if (sleeping != 0) timeRate = Math.min(timeRate, Math.round(timeRate / + world.getPlayers().size() * sleeping)); + } if (time >= (dayTime - timeRate * 1.5) && time <= dayTime) { if (Config.getBoolean("night-skip.clear-rain")) { @@ -39,7 +45,7 @@ public class AccelerateNightTask extends BukkitRunnable { Messages.sendRandomChatMessage(world, "messages.chat.night-skipped"); this.cancel(); } else { - world.setTime(time + timeRate); + world.setTime(time + (int) timeRate); } } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ff64951..41e2b43 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -11,8 +11,7 @@ night-skip: time-rate: 70 # The amount of ticks added to the current time every tick when skipping the night 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-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) + proportional-acceleration: false # Increase the night skipping speed based on the amount of sleeping players 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+)