1
0
mirror of https://github.com/nkomarn/harbor.git synced 2025-01-05 07:07:34 +01:00

⏱ Proportional acceleration

This commit is contained in:
Mykyta 2020-04-03 21:27:10 -07:00
parent 35407752c9
commit f727f2738e
No known key found for this signature in database
GPG Key ID: C147E30C19EA3570
3 changed files with 12 additions and 7 deletions

View File

@ -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;
}

View File

@ -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);
}
}
}

View File

@ -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+)