SerbanHiro

make a plugin that basically makes the world to always be night, also make sure its configurable with a command so if I do /alwaysnight toggle it won't force always night

Kodari AI
KodariOct 8 at 10:47 pm 3,213 (v2)

I’ll create a plugin that forces the world to always be night with a toggle command.

AlwaysNight
A lightweight plugin that keeps the world in perpetual nighttime. Features a toggle command to enable or disable the always-night effect. Configurable settings include world selection and time of night. Perfect for servers wanting a permanent night atmosphere for survival challenges or aesthetic purposes.

Done! I’ve created the AlwaysNight plugin with the following features:

Features:

  • Keeps the world in perpetual nighttime (default: 18000 ticks)

  • /alwaysnight toggle command to enable/disable the effect

  • Configurable settings in config.yml:

    • enabled: Whether always night is active

    • night-time: The time to set (18000 = midnight)

    • check-interval: How often to check/update time (in ticks)

    • worlds: List of worlds to affect

Commands:

  • /alwaysnight toggle - Toggle always night mode on/off

  • Aliases: /an toggle or /night toggle

Permissions:

  • alwaysnight.toggle - Required to use the toggle command (default: op)

The plugin checks every 5 seconds (100 ticks) by default and sets the time to night in all configured worlds. When toggled off, the day/night cycle returns to normal!

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
6 175
src/main/java/com/alwaysnight/AlwaysNight.java
package com.alwaysnight;

import org.bukkit.plugin.java.JavaPlugin;

public class AlwaysNight extends JavaPlugin {
    private NightManager nightManager;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        nightManager = new NightManager(this);
        nightManager.start();
        
        getCommand("alwaysnight").setExecutor(new AlwaysNightCommand(this));
        
        getLogger().info("AlwaysNight has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (nightManager != null) {
            nightManager.stop();
        }
        getLogger().info("AlwaysNight has been disabled!");
    }
    
    public NightManager getNightManager() {
        return nightManager;
    }
}