Division error when trying to fetch sleeping data

Hey there,
Im trying to calculate the percentage of players currently sleeping with these lines of code:

   private static final ArrayList<Player> playerSleeping = new ArrayList<>();

    @EventHandler
    public void onBedEnterEvent(PlayerBedEnterEvent event) {
        Player player = event.getPlayer();
        playerSleeping.add(player);

        int actualSleeping = (playerSleeping.size() / Bukkit.getOnlinePlayers().size());

        Bukkit.broadcastMessage(String.valueOf(actualSleeping));
    }

But when there are two players on the server and one goes to sleep it outputs 0, why?

int wholeNumber = 1 / 2; // => 0.

double number = 1 / 2d; // => 0.5

int cannot contain comma numbers.

1 Like

Thank you, what a silly mistake…