ClaimAndProtect

PocketMine plugin to manage each player's land

ClaimAndProtect Plugin ๐Ÿฐ

A powerful land claiming and protection plugin for PocketMine-MP that gives players complete control over their territory.

โœจ Key Features

๐Ÿ›ก๏ธ Advanced Protection

  • Full protection against griefing, building, and breaking
  • Customizable permissions for every action
  • Flag system to control PvP, explosions, and more
  • Protect your builds, farms, and valuables

๐Ÿ‘ฅ Social Features

  • Add friends to your land with custom permissions
  • Transfer land ownership
  • Easy-to-use Forms UI for management

๐Ÿ’Ž Economy Integration

๐ŸŽฎ User Experience

  • Visual selection tools for claiming
  • Form-based interface for all features
  • Intuitive command system

๐ŸŒ Multi-Language

  • Has language features that match the player's minecraft language
  • support 2 languages โ€‹โ€‹for now (english, indonesian)
  • Message content and form content can be changed according to language

๐ŸŽฏ Perfect For

  • Survival servers
  • Towny servers
  • RPG servers
  • Creative servers
  • Any server needing land protection

๐Ÿ“ Commands and Permissions

Main Command: /claimandprotect or /cnp

SubcommandDescriptionPermissionDefaultAliases
setfirstSet the first position for claiming landclaimandprotect.command.setfirsttruefirst, f
setsecondSet the second position for claiming landclaimandprotect.command.setsecondtruesecond, sec, s
claimClaim your land after setupclaimandprotect.command.claimtrue-
settingsSettings your landclaimandprotect.command.settingstruesetting
hereWhose land is in this area?claimandprotect.command.heretrue-
mylandView all owned landclaimandprotect.command.mylandtrue-
infoInformation of land with idclaimandprotect.command.infolandtrue-
removeRemove/sell your landclaimandprotect.command.removetruesell, rm, delete
tpTeleport to land with idclaimandprotect.command.tptruemove, teleport, mv
adminAdmin featureclaimandprotect.command.adminop-
migrationMigration plugin EconomyLand to ClaimAndProtectclaimandprotect.command.migrationopmigrate

Admin Permissions

PermissionDescriptionDefault
claimandprotect.bypassBypass all protectionsop
claimandprotect.admin.settingsAdmin manage settings landop
claimandprotect.admin.tpTeleport to any landop
claimandprotect.admin.mylandSee any player's landop
claimandprotect.admin.removeRemove any player's landop

๐Ÿ“‘ How to migrate EconomyLand plugin to ClaimAndProtect

  1. Step one move the Land.yml file to the migrate ClaimAndProtect folder

    Path Land.yml

    plugin_data ๐Ÿ“
      โ”‚
      โ”œโ”€โ”€ EconomyLand ๐Ÿ“
      โ”‚    โ””โ”€โ”€ Land.yml ๐Ÿ“„ (copy this)
    

    Path Migrate Plugin

    plugin_data ๐Ÿ“
      โ”‚
      โ”œโ”€โ”€ ClaimAndProtect ๐Ÿ“
      โ”‚    โ””โ”€โ”€ migration ๐Ÿ“
      โ”‚        โ””โ”€โ”€Land.yml ๐Ÿ“„ (paste here)
    
  2. Step two run command in console (console only)

    /claimandprotect migration
    

    if successful it will be like this migrate_succes

โš™๏ธ Configuration

# DO NOT EDIT THIS VALUE, INTERNAL USE ONLY.
config-version: 5

# Sets the prefix for this plugin.
prefix: "[&bClaim And Protect&r]"

# Sets the default language for the plugin, you can edit text and messages in this file.
default-language: en_US

# multi-economy setting
economy:
  # bedrockeconomy = BedrockEconomy
  # economys, economyapi = EconomyAPI
  # experience, exp, xp = Exp Minecraft
  provider: economyapi

# all settings of this plugin are here
cnp-settings:
  # players limit land
  # infinity for infinity limit
  player-limit-land: infinity
  # to maximize friends in your land
  # 'infinity' for infinite max friend
  max-friends: 5
  # price per block, ex 6 block 6 * price
  price-per-block: 100
  # Worlds to blacklist players to buy
  # ex, blacklist-world: ["lobby", "world"]
  blacklist-world: []
  # This is the percentage of the discount you get when selling land.
  # For example, if a player buys land for a price of '1000', if the value is filled in as '10'
  # it means he gets '900' because it is cut by 10%.
  percent-sold: 10
  # if 'true' will allow explosion on land
  # if 'false' then explosions are not allowed on land
  explosion: false

session-timer:
  first-session: false
    # If true, this will enable the first session timer.
  first-timer: 15 # Timer duration in seconds.

  second-session: false
    # If true, this will enable the second session timer.
  second-timer: 15 # Timer duration in seconds.

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป For Developer

๐Ÿ”ง Import LandManager Namespace

use xeonch\ClaimAndProtect\manager\LandManager;

๐Ÿ” Check if the Player is in a Land Area

the first parameter is the position in pocketmine\world\Position;

$landManager = new LandManager();
if ($landManager->isInArea(Position)){
  // in area
} else {
  // not in area

๐Ÿ“œ Check Data in Land Area

Get the land data for the area the player is in. The first parameter is the position from pocketmine\world\Position;.

$landManager = new LandManager();
$landsInArea = $landManager->getLandsIn($position);

foreach ($landsInArea as $landId => $landData) {
  // Get Land ID
  echo $landId; // e.x: 4

  // Get Owner Name
  echo $landData['owner']; // e.x: ItsMeLordzy

  // Get World Name
  echo $landData['world']; // e.x: lobby

  // Get Position Coordinates
  echo $landData['pos']['first']; // e.x: 20, 55, 222, world
  echo $landData['pos']['second']; // e.x: 69, 55, 262, world

  // Get Land Price ๐Ÿ’ฐ
  echo $landData['price']; // e.x: 1200

  // Get Width of the Land ๐Ÿ“
  echo $landData['wide'] . " Block"; // e.x: 90 Block

  // Get Land Members ๐Ÿ‘ฅ
  foreach ($landData['member'] as $member) {
    echo $member . "\n"; // e.x: Luqman
  }
}

๐Ÿ‘ค Check Data Using Owner Land

Get all the land data owned by the specified player.

$name = 'ItsMeLordzy';
$landManager = new LandManager();
$lands = $landManager->getLandsByOwner($name);

if (empty($lands)) {
  echo "$name doesn't own any land yet";
  // Output: ItsMeLordzy doesn't own any land yet
}

foreach ($lands as $landId => $landData) {
  // Display all land IDs owned by the owner
  echo $landId . ", ";
  // e.x: 1, 4, 7
}

๐Ÿ†” Check Data Using Land Id

Get the land data for a specific land by ID.

$id = 1;
$landManager = new LandManager();
$landData = $landManager->getLand($id);

// Get Owner Name
echo $landData['owner']; // e.x: ItsMeLordzy
// ur code

๐Ÿšถโ€โ™‚๏ธ Example: Player Interaction with Land

An example where the playerโ€™s position is checked to see if they are within a land area. Displays land ID and owner name upon movement.

use xeonch\ClaimAndProtect\manager\LandManager;
use pocketmine\event\player\PlayerMoveEvent;

    public function onPlayerMove(PlayerMoveEvent $event): void
    {
        $player = $event->getPlayer();
        $landManager = new LandManager();
        $landsInArea = $landManager->getLandsIn($player->getPosition());

        // Check if there is no land in the area ๐Ÿ›‘
        if (empty($landsInArea)){
            $player->sendTip("There is no land here");
        }

        foreach ($landsInArea as $landId => $landData) {
            $player->sendTip("You are in land with ID: " . $landId . ", Owner: " . $landData['owner']);
            //output: You are in land with ID: 7, Owner: ItsMeLordzy
        }
    }

๐Ÿ† Contribution:

  • Bug Testing: A special thanks to LuqmanDv for identifying and reporting critical issues that helped improve the stability and performance of this project.
  • Feedback: Your invaluable suggestions played a key role in enhancing the project.

๐Ÿš€ Thanks for Reading!

We appreciate your time spent reading this documentation. If you have any questions or suggestions, feel free to open an issue or contribute to the repository.

Happy coding! ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ‘ฉโ€๐Ÿ’ป

๐Ÿ“ฌ Contact Us

For further inquiries, please contact us at:

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

Details

Version: 1.0.1

Downloads: 363

Updated: 2/11/2025

Supported API versions: 5.0.0 to 5.30.1

Categories: General, World Editing and Management, Economy, Teleportation, Anti-Griefing Tools

License: MIT

Producers

Contributor

Collaborator