Skip to content

Commit

Permalink
⏱ Proportional acceleration
Browse files Browse the repository at this point in the history
  • Loading branch information
nkomarn committed Apr 4, 2020
1 parent 3540775 commit f727f27
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/main/java/xyz/nkomarn/Harbor/command/HarborCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ else if (args[0].equalsIgnoreCase("forceskip")) {
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;
}

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/xyz/nkomarn/Harbor/task/AccelerateNightTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ public AccelerateNightTask(final World world) {
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")) {
Expand All @@ -39,7 +45,7 @@ public void run() {
Messages.sendRandomChatMessage(world, "messages.chat.night-skipped");
this.cancel();
} else {
world.setTime(time + timeRate);
world.setTime(time + (int) timeRate);
}
}
}
3 changes: 1 addition & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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+)
Expand Down

0 comments on commit f727f27

Please sign in to comment.