oxy1337_

make me a plugin that is called DonutToggleMobSpawn that creates a command called /mobspawntoggle and it disables all mob spawns like zombie creeper ederman skeleton and more and when i activate or desactivate it shows a text up of the health bar like the thing bar at the middle mob spawns activated in white text and it disables the mob spawns on his side

Kodari AI
KodariMar 24 at 7:01 pm 7,515 (v2)

I’ll create a plugin that toggles mob spawns per-player with an action bar notification.

DonutToggleMobSpawn
A player-specific mob spawn control plugin that allows individual players to toggle mob spawning in their vicinity. Features a /mobspawntoggle command that prevents hostile and passive mobs from spawning near players who have disabled spawns. Displays action bar notifications when toggling the feature on or off. Includes configurable range and customizable messages for enhanced player experience.

Plugin created! DonutToggleMobSpawn allows players to individually toggle mob spawning in their area with action bar notifications.

Features:

  • /mobspawntoggle command (aliases: /mst, /togglemobs)

  • Shows “Mob spawns activated/deactivated” in white text above health bar

  • Per-player toggle - only affects spawns within 32 blocks of players who disabled it

  • Blocks all hostile and passive mobs (zombies, creepers, endermen, skeletons, animals, etc.)

  • Excludes spawners, spawn eggs, and custom spawns so they still work

  • Customizable range and messages in config.yml

  • Permission: donuttogglemobspawn.toggle (default: true)

oxy1337_

dont modify plugin just a question can anyone use this

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
6 263
src/main/java/com/donutorder/donuttogglemobspawn/DonutToggleMobSpawn.java
package com.donutorder.donuttogglemobspawn;

import com.donutorder.donuttogglemobspawn.commands.MobSpawnToggleCommand;
import com.donutorder.donuttogglemobspawn.listeners.MobSpawnListener;
import lombok.Getter;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashMap;
import java.util.UUID;

@Getter
public class DonutToggleMobSpawn extends JavaPlugin {

    private final HashMap<UUID, Boolean> toggledPlayers = new HashMap<>();
    private int range;

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

        getCommand("mobspawntoggle").setExecutor(new MobSpawnToggleCommand(this));
        getServer().getPluginManager().registerEvents(new MobSpawnListener(this), this);

        getLogger().info("DonutToggleMobSpawn has been enabled!");
    }

    @Override
    public void onDisable() {
        toggledPlayers.clear();
        getLogger().info("DonutToggleMobSpawn has been disabled!");
    }

    public void loadConfig() {
        reloadConfig();
        FileConfiguration config = getConfig();
        range = config.getInt("range", 32);
    }

    public boolean hasMobSpawnsDisabled(UUID uuid) {
        return toggledPlayers.getOrDefault(uuid, false);
    }

    public void toggleMobSpawns(UUID uuid) {
        boolean current = toggledPlayers.getOrDefault(uuid, false);
        toggledPlayers.put(uuid, !current);
    }

    public String getMessage(String path) {
        return getConfig().getString("messages." + path, "").replace("&", "§");
    }
}