kashifshaikh3536-stack
📎 1 file 1,849 chars
📄
pasted-code-1775487948103.txt
txt 55 lines
▶
Create a Minecraft plugin for PaperMC (version 1.20.1) written in Java that acts as an addon for the BedWars1058 plugin.

Requirements:

* The plugin must NOT modify or override any existing BedWars1058 files, configs, or internal behavior. It should work purely as an external addon using the BedWars1058 API (if available) or safe event hooks.
* The main feature: automatically destroy all beds in an active BedWars match after a configurable amount of time set by the server owner.

Core Functionality:

1. Detect when a BedWars1058 game starts.
2. Start a timer for that arena/match.
3. After the configured time (e.g., 10 minutes), trigger a "bed break" event for ALL teams:

   * All beds in the arena should be removed/destroyed.
   * Players should no longer be able to respawn after this point.
4. Broadcast a message to all players in the arena when beds are destroyed (configurable message).

Configuration:

* Create a config.yml file with:

  * bed-destroy-time: integer (seconds)
  * broadcast-message: string (supports color codes)
* The plugin must reload config with a command (/bwaddon reload).

Compatibility:

* Must support PaperMC 1.20.1.
* Must hook into BedWars1058 safely (softdepend in plugin.yml).
* Should handle multiple arenas running simultaneously.

Code Quality:

* Use clean, modular Java code.
* Include proper null checks and error handling.
* Use Bukkit scheduler for timing tasks.
* Separate classes for:

  * Main plugin class
  * Arena/game listener
  * Timer manager

Extras:

* Ensure it does not crash if BedWars1058 is not installed (log warning and disable plugin).
* Add debug logs (optional toggle in config).

Output:

* Provide full source code (multiple classes if needed).
* Include plugin.yml and config.yml.
* Add brief setup instructions.

Do NOT include unnecessary features beyond this scope.
Kodari AI
KodariApr 6 at 3:07 pm 8,339 (v2)

I’ll create a BedWars1058 addon plugin that automatically destroys beds after a configurable time.

BedWarsAutoDestroy
An addon for BedWars1058 that automatically destroys all beds in active matches after a configurable time period. Features per-arena timers, customizable broadcast messages, and multi-arena support. Safely hooks into BedWars1058 API without modifying core plugin files. Includes reload command and debug logging for arena management.

Now I’ll create the BedWars1058 addon plugin with automatic bed destruction timers.

All files created successfully! The plugin is now complete with the following features:

Core Features:

  • Detects when BedWars1058 games start via GameStateChangeEvent

  • Starts individual timers for each arena

  • Automatically destroys all beds after configured time

  • Broadcasts customizable message to players

  • Handles multiple arenas simultaneously

  • Cancels timers when games end early

Configuration:

  • bed-destroy-time: Time in seconds before beds are destroyed (default: 600 = 10 minutes)

  • broadcast-message: Customizable message with color code support

  • debug: Toggle debug logging

Commands:

  • /bwaddon reload - Reloads configuration (requires bedwarsautodestroy.admin permission)

Safety Features:

  • Checks for BedWars1058 on startup and disables gracefully if not found

  • Uses softdepend in plugin.yml for proper load order

  • Cleans up all timers on plugin disable

  • Properly cancels timers when games end prematurely

  • Null checks throughout the code

The plugin works purely as an external addon without modifying any BedWars1058 files or configs.

kashifshaikh3536-stack

That 600 is in minutes or seconds

Kodari AI
KodariApr 6 at 3:18 pm 2,079 (v2)

I’ll check the existing code to clarify whether the timer value is in minutes or seconds.

Based on the code, 600 is in seconds.

Looking at ArenaTimerManager.java, you can see:

Java
int delaySeconds = plugin.getConfig().getInt("bed-destroy-time", 600);
long delayTicks = delaySeconds * 20L;

The variable is named delaySeconds and it multiplies by 20 to convert to ticks (Minecraft runs at 20 ticks per second).

Also, in the debug output in BedWarsAutoDestroy.java:

Java
getLogger().info("Bed destroy time: " + getConfig().getInt("bed-destroy-time") + " seconds");

So 600 seconds = 10 minutes is when all beds will be automatically destroyed after the game starts.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
7 325
src/main/java/com/example/bedwarsautodestroy/BedWarsAutoDestroy.java
package com.example.bedwarsautodestroy;

import com.andrei1058.bedwars.api.BedWars;
import com.example.bedwarsautodestroy.command.ReloadCommand;
import com.example.bedwarsautodestroy.listener.ArenaListener;
import com.example.bedwarsautodestroy.manager.ArenaTimerManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class BedWarsAutoDestroy extends JavaPlugin {

    private BedWars bedWarsAPI;
    private ArenaTimerManager timerManager;

    @Override
    public void onEnable() {
        if (!loadBedWarsAPI()) {
            getLogger().severe("BedWars1058 not found! This plugin requires BedWars1058 to function.");
            getLogger().severe("Disabling plugin...");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }

        saveDefaultConfig();

        this.timerManager = new ArenaTimerManager(this);

        Bukkit.getPluginManager().registerEvents(new ArenaListener(this), this);

        ReloadCommand reloadCommand = new ReloadCommand(this);
        getCommand("bwaddon").setExecutor(reloadCommand);
        getCommand("bwaddon").setTabCompleter(reloadCommand);

        getLogger().info("BedWarsAutoDestroy has been enabled!");
        if (getConfig().getBoolean("debug", false)) {
            getLogger().info("Debug mode is enabled");
            getLogger().info("Bed destroy time: " + getConfig().getInt("bed-destroy-time") + " seconds");
        }
    }

    @Override
    public void onDisable() {
        if (timerManager != null) {
            timerManager.cancelAllTimers();
        }
        getLogger().info("BedWarsAutoDestroy has been disabled!");
    }

    private boolean loadBedWarsAPI() {
        RegisteredServiceProvider<BedWars> registration = Bukkit.getServicesManager().getRegistration(BedWars.class);
        if (registration == null) {
            return false;
        }
        this.bedWarsAPI = registration.getProvider();
        return true;
    }

    public void debug(String message) {
        if (getConfig().getBoolean("debug", false)) {
            getLogger().info("[DEBUG] " + message);
        }
    }
}