user125135135135

wez zrob mi plugin ze caly czas bedzie dzien , + nie bedzie nigdy deszczu ani sniegu

Kodari AI
KodariJul 2 at 8:56 am 1
AlwaysDay
A lightweight Minecraft plugin that permanently locks the time to daytime and disables all weather. Runs every few ticks to keep time fixed at midday (1000 ticks) and blocks rain, thunder, and snow via both scheduled tasks and event listeners. Configurable per-world, supports reload command, and respects individual world time/weather states for multi-world servers. Minimal performance impact with efficient tick-based checks.

Plan:

  1. build.gradle, settings.gradle, gradle.properties — build setup

  2. plugin.yml + config.yml — plugin metadata and config

  3. AlwaysDay.java — main plugin class (onEnable, onDisable, reload command)

  4. TimeWeatherListener.java — listener + repeating task for time/weather lock

Wszystko gotowe. Plugin AlwaysDay kompletny — co robi:

  • Czas — ustawia każdy skonfigurowany świat na 1000 ticków (południe) i blokuje zmianę czasu

  • Pogoda — wyłącza deszcz, burzę i śnieg na stałe

  • Task cykliczny — sprawdza co 20 ticków (1 sek.) i poprawia czas/pogodę

  • Eventy — przechwytuje WeatherChangeEvent i ThunderChangeEvent, żeby deszcz/burza nie wystartowały

  • Konfiguracja — config.yml gdzie ustawiasz listę światów, czas w tickach, interwał, włącz/wyłącz czas/pogodę osobno

  • Komenda — /alwaysday reload (lub /ad reload) z permisją alwaysday.admin przeładowuje config

Po wrzuceniu .jar do plugins/ i restarcie serwera — zawsze dzień i bez deszczu.

Kodari can make mistakes. Review important code before using.
Files
AlwaysDay
gradle.properties
settings.gradle
Code
9 193
AlwaysDay/src/main/java/com/alwaysday/AlwaysDay.java
package com.alwaysday;

import com.alwaysday.listeners.TimeWeatherListener;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.List;

public class AlwaysDay extends JavaPlugin {

    private boolean lockTime;
    private long lockedTime;
    private boolean lockWeather;
    private List<String> managedWorlds;
    private int checkInterval;
    private TimeWeatherListener listener;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        loadConfig();

        listener = new TimeWeatherListener(this);
        getServer().getPluginManager().registerEvents(listener, this);
        listener.startTask();

        getCommand("alwaysday").setExecutor((sender, cmd, label, args) -> {
            if (args.length > 0 && args[0].equalsIgnoreCase("reload")) {
                if (!sender.hasPermission("alwaysday.admin")) {
                    sender.sendMessage("§cYou don't have permission to do this.");
                    return true;
                }
                reloadConfig();
                loadConfig();
                listener.cancelTask();
                listener.startTask();
                sender.sendMessage("§aAlwaysDay configuration reloaded.");
                return true;
            }
            return false;
        });

        getLogger().info("AlwaysDay enabled.");
    }

    @Override
    public void onDisable() {
        if (listener != null) {
            listener.cancelTask();
        }
        getLogger().info("AlwaysDay disabled.");
    }

    private void loadConfig() {
        lockTime = getConfig().getBoolean("lock-time", true);
        lockedTime = getConfig().getLong("locked-time", 1000);
        lockWeather = getConfig().getBoolean("lock-weather", true);
        managedWorlds = getConfig().getStringList("managed-worlds");
        checkInterval = getConfig().getInt("check-interval", 20);
        if (checkInterval < 1) checkInterval = 20;
    }

    public boolean shouldManageWorld(World world) {
        return managedWorlds.isEmpty() || managedWorlds.contains(world.getName());
    }

    public boolean isLockTime() {
        return lockTime;
    }

    public long getLockedTime() {
        return lockedTime;
    }

    public boolean isLockWeather() {
        return lockWeather;
    }

    public int getCheckInterval() {
        return checkInterval;
    }
}