Skip to content

Commit afba5de

Browse files
authored
Merge pull request #1 from ILikePlayingGames/round-up
Rounding fix - Floating point value cannot be assigned to Integer directly. - Using `100.0` rather than `worldSleepPercent.floatValue()` to produce a value that can be rounded. Round up on 'sleepers needed' placeholder instead of rounding down
2 parents cdfd8ee + 1bff83f commit afba5de

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/adhdmc/sleepmessages/SleepListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void onPlayerSleep(PlayerDeepSleepEvent event) {
2626
int currentSleepCount = 0;
2727
int worldOnlineTotal = world.getPlayerCount();
2828
Integer worldSleepPercent = world.getGameRuleValue(GameRule.PLAYERS_SLEEPING_PERCENTAGE);
29-
Integer neededSleepers = (worldSleepPercent / 100) * worldOnlineTotal;
29+
Integer neededSleepers = (int) Math.ceil((worldSleepPercent / 100.0) * worldOnlineTotal);
3030
List<Player> playerList = world.getPlayers();
3131
for (Player player : playerList) {
3232
if (player.isDeeplySleeping()) currentSleepCount += 1;

0 commit comments

Comments
 (0)