Solved If world time is night

Discussion in 'Spigot Plugin Development' started by asdasaf, Jan 14, 2022.

Thread Status:
Not open for further replies.
  1. How do i make execute my code only if the time is night. Here's chunk of my code.
    Code (Java):
    if (Bukkit.getServer().getWorld("world").getTime()  <= 10000 ) {
  2. Code (Text):
    public boolean day() {
        Server server = getServer();
        long time = server.getWorld("world").getTime();

        if(time > 0 && time < 12300) {
            return true;
        } else {
            return false;
    The function return night when it gets dark.
    (It is already night when time is 12000 but then it isn't dark)

    Don't forget to change the world name to the name of your world!
    • Friendly Friendly x 1
  3. What if i use public void run
  4. No, problem, just call the day() function in the run method. And check if the value is true (day) or false (night).
    • Agree Agree x 1
  5. Nvm, i solved the problem, thanks for help.
Thread Status:
Not open for further replies.