catbaksykua

Hi! Can you create a Java 1.21.11 plugin for regions ? (Like /rg claim commands) and for its to work on java and on bedrock (GeyserMC)

Kodari AI
KodariJan 21 at 6:37 pm 14,037 (v2)

I’ll create a comprehensive region management plugin that works for both Java and Bedrock players.

RegionProtect
A powerful region management system allowing players to claim and protect areas. Features include visual region selection, territory claiming with customizable limits, admin tools for region management, comprehensive protection against griefing, and full Bedrock Edition support via GeyserMC/Floodgate. Includes economy integration, per-region flags, and persistent storage.

Done! I’ve created RegionProtect, a comprehensive region management plugin for Minecraft 1.21.1 with full Java and Bedrock (GeyserMC) support.

Features

Core Functionality:

  • /pos1 & /pos2 - Set region boundaries (also works with wooden axe)

  • /rg claim <name> - Claim selected region

  • /rg unclaim <name> - Remove your region

  • /rg list - View your claimed regions

  • /rg info - Check region details at your location

  • /rg flag <region> <flag> <value> - Configure region flags (admin)

Protection Flags:

  • PVP control

  • Mob damage/spawning

  • Explosions (creepers, TNT)

  • Fire spread

  • Liquid flow (lava/water)

  • Leaf decay

Cross-Platform:

  • Works seamlessly with Bedrock players via Floodgate/GeyserMC

  • XSeries ensures compatibility across versions

  • Visual particle feedback for selections

Configuration:

  • Max regions per player

  • Min/max region sizes

  • Default flag values

  • Fully customizable messages

The plugin automatically detects Floodgate and treats Java/Bedrock players identically. All data persists to regions.yml. Use a wooden axe to quick-select positions!

catbaksykua

The compilation failed with this error:

code
Validation failed for compilation: Compilation failed with 1 error(s):

ERROR in src/main/java/com/regionprotect/listeners/SelectionListener.java at line 29: incompatible types: XMaterial cannot be converted to Optional<XMaterial>
        Optional<XMaterial> materialOpt = XMaterial.matchXMaterial(item.getType());
                                                                  ^


=== COMPILATION ERROR ANALYSIS ===

TYPE MISMATCHES:
  - incompatible types: XMaterial cannot be converted to Optional<XMaterial>
ACTION: Fix variable types or casting

FILES TO INVESTIGATE:
  - src/main/java/com/regionprotect/listeners/SelectionListener.java
 exceeds maximum 

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariJan 21 at 6:46 pm 4,895 (v2)

I need to read the SelectionListener.java file to see the exact issue and fix it.

Analysis

The error is on line 29 of SelectionListener.java. The issue is that XMaterial.matchXMaterial(Material) returns Optional<XMaterial>, but the code is calling it with item.getType() which returns a Material. The correct method to use is XMaterial.matchXMaterial(String) for string matching, or we need to use the proper XMaterial method.

Looking at the code, the issue is that we’re trying to match a Material to get an Optional<XMaterial>, but then comparing it incorrectly. The fix is to use the correct XMaterial matching approach.

Fixed the compilation error by using XMaterial.matchXMaterial(ItemStack) which returns an XMaterial directly (not Optional), allowing direct comparison with XMaterial.WOODEN_AXE.

catbaksykua

Can you please make that you can add and remove people to private ?

Kodari AI
KodariJan 28 at 10:19 pm 17,977 (v2)

I’ll help you add functionality to add and remove people from private regions. Let me first read the existing files to understand the current structure.

I’ll add functionality to add and remove members to private regions. This will allow region owners to grant access to specific players.

Perfect! I’ve added the member management system to your plugin. Here’s what was added:

New Commands:

  • /rg addmember <region> <player> - Add a player to your region

  • /rg removemember <region> <player> - Remove a player from your region

  • /rg members <region> - List all members of a region

Features:

  • Members can build, break, and interact within the region

  • Only the owner (or admins) can add/remove members

  • Members are saved/loaded from the regions.yml file

  • Players get notifications when added/removed

  • Tab completion for online players when adding/removing members

  • All member data persists across server restarts

Permissions:

  • regionprotect.addmember - Add members (default: true)

  • regionprotect.removemember - Remove members (default: true)

  • regionprotect.members - View member list (default: true)

Members now have full access to the region just like the owner!

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
14 1,323
src/main/java/com/regionprotect/RegionProtect.java
package com.regionprotect;

import com.regionprotect.commands.RegionCommand;
import com.regionprotect.commands.PositionCommand;
import com.regionprotect.listeners.ProtectionListener;
import com.regionprotect.listeners.SelectionListener;
import com.regionprotect.managers.RegionManager;
import com.regionprotect.managers.SelectionManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class RegionProtect extends JavaPlugin {
    
    private RegionManager regionManager;
    private SelectionManager selectionManager;
    private boolean floodgateEnabled;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.floodgateEnabled = getServer().getPluginManager().getPlugin("Floodgate") != null;
        
        if (floodgateEnabled) {
            getLogger().info("Floodgate detected! Bedrock player support enabled.");
        }
        
        this.regionManager = new RegionManager(this);
        this.selectionManager = new SelectionManager(this);
        
        regionManager.loadRegions();
        
        registerCommands();
        registerListeners();
        
        getLogger().info("RegionProtect has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (regionManager != null) {
            regionManager.saveRegions();
        }
        
        getLogger().info("RegionProtect has been disabled!");
    }
    
    private void registerCommands() {
        RegionCommand regionCommand = new RegionCommand(this);
        getCommand("rg").setExecutor(regionCommand);
        getCommand("rg").setTabCompleter(regionCommand);
        
        PositionCommand posCommand = new PositionCommand(this);
        getCommand("pos1").setExecutor(posCommand);
        getCommand("pos2").setExecutor(posCommand);
    }
    
    private void registerListeners() {
        getServer().getPluginManager().registerEvents(new ProtectionListener(this), this);
        getServer().getPluginManager().registerEvents(new SelectionListener(this), this);
    }
    
    public String getMessage(String key) {
        String prefix = getConfig().getString("messages.prefix", "&8[&bRegionProtect&8]&r");
        String message = getConfig().getString("messages." + key, key);
        return colorize(prefix + " " + message);
    }
    
    public String colorize(String text) {
        return text.replace("&", "§");
    }
}