raf132-hue

make an plugin where you cant use any bow any sword and any crossbow in a region called afk you cant use any abilities anything

Kodari AI
KodariMar 7 at 9:12 pm 3,968 (v2)

I’ll create a plugin that prevents weapon usage and abilities in the “afk” WorldGuard region.

AFKRegionProtection
A region protection plugin that restricts combat and ability usage within designated AFK zones. Prevents players from using bows, swords, crossbows, and item abilities while inside the configured region. Integrates with WorldGuard for region detection and provides customizable blocked item types and player feedback messages. Perfect for spawn AFK zones where combat should be disabled.

I’ll create a plugin that blocks all weapon usage and abilities in the “afk” region using WorldGuard.

Plugin created successfully! This blocks all bows, swords, crossbows, and right-click abilities within the “afk” WorldGuard region. Players will receive a message when their actions are blocked.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
5 237
src/main/java/com/example/afkregion/AFKRegionProtection.java
package com.example.afkregion;

import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class AFKRegionProtection extends JavaPlugin {

    private String regionName;
    private String weaponsDisabledMessage;
    private String worldGuardNotFoundMessage;
    private boolean worldGuardEnabled = false;

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

        if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null) {
            getLogger().severe(ChatColor.stripColor(worldGuardNotFoundMessage));
            getLogger().severe("Disabling plugin...");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }

        worldGuardEnabled = true;

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

        getLogger().info("AFKRegionProtection has been enabled!");
        getLogger().info("Protected region: " + regionName);
    }

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

    private void loadConfiguration() {
        regionName = getConfig().getString("region-name", "afk");
        weaponsDisabledMessage = ChatColor.translateAlternateColorCodes('&', 
            getConfig().getString("messages.weapons-disabled", "&cWeapons and abilities are disabled in this region!"));
        worldGuardNotFoundMessage = ChatColor.translateAlternateColorCodes('&',
            getConfig().getString("messages.worldguard-not-found", "&cWorldGuard is not installed! This plugin requires WorldGuard."));
    }

    public void reloadConfiguration() {
        reloadConfig();
        loadConfiguration();
    }
}