Skip to content
Plugins

Territoryv0.4.2

C++by yuhangleA three-dimensional territory plugin developed for Endstone using C++.

Stars
12

PLUGINSTERRITORY

# Install

Archive extracted into C:\Users\you\bedrock_server\plugins

Use the animation for reference. Follow the plugin's README for exact steps.

# README

header

Introduction

The Territory plugin is a 3D territory management plugin developed in C++ for the endstone plugin loader. It uses an SQLite database to store territory data and supports features such as anti-interaction, anti-block breaking, anti-block placement, anti-entity explosion, preventing general damage to entities within the territory from outsiders, territory teleportation, member management, and adding territory administrators. You can use it to protect players' buildings and property on endstone server.

The Territory plugin supports sub-territories, which can be created within a parent territory by the parent territory owner and administrators. Sub-territory permissions and members are independent from the parent territory. Sub-territories are fully controlled by their owners and are not controlled by the parent territory. If a parent territory is deleted, its sub-territories will lose their parent territory tag and become independent territories, and will not be deleted along with the parent territory.

The Territory plugin supports the integration of the money_connect plugin as an economic bridge, with the economy being disabled by default. After enabling the economy in the configuration file, creating a territory will charge players based on the territory's area multiplied by the unit price. Deleting a territory will refund the player at the current price.

Features

The Territory plugin is developed in C++ and uses SQLite for land data storage, delivering excellent theoretical performance.

Extreme Performance Optimization

Architecture-Level Optimization
  • Pure C++ Implementation: Zero interpreter overhead for great execution efficiency
  • Dual-Mode Storage Engine: SQLite persistence + in-memory cache, balancing startup speed, query stability, and crash safety
Algorithm & Data Structure Optimization
  • Spatial Grid Index: Reduces O(n) full table scans to O(1) approximate constant-time lookups
  • Permission Cache: Builds a hash set once when loading or modifying land data, reducing permission checks from O(k) string splitting to O(1) hash lookups
Real-World Test Data Under Million-Scale Load
  • Average interaction event latency: 36.8 μs
  • Average location query (full processing) latency: 125 μs
  • Under a million land claims, single interaction latency is consistently below 40 μs (approximately 0.04 milliseconds)

Performance Test Under 500 Random Land Claims

Test Environment: 500 random land claims. The recorded values represent the total execution time of a single event or periodically executed function.

RankPlugin NameInteraction Inside LandInteraction Outside LandLocation Info Send (Full Processing)Overall Assessment
🥇Territory12.4711.3839.83🚀 Excellent, highly efficient and lightweight
🥈Land of U89.37106.18372.58✅ Good, suitable for small to medium servers
🥉Land of E6,949.441,093.681,138.25❌ High latency, not recommended for heavy loads

Data Interpretation

  • Interaction Inside Land: Average latency of the corresponding function when a player interacts inside a land claim.
  • Interaction Outside Land: Average latency of the corresponding function when a player interacts outside any land claim.
  • Location Info Send: Average latency of the corresponding function when fully processing player movement and sending land information.
  • All time units are in microseconds (μs).

How to use

Install & Config

Install Endstone

Please refer to the endstone documentation for this step.

Download & Install Territory Plugin

Go to the Releases page to download the latest version of the plugin archive, then extract it into the plugins folder in your server directory. The directory structure is as follows:

Windows:

plugins/
├── endstone_territory.dll    # Plugin file for Windows
└── territory/                # Data directory
    └── language/             # Language directory

Linux:

plugins/
├── endstone_territory.so     # Plugin file for Linux
└── territory/                # Data directory
    └── language/             # Language directory

Language

The plugin loads all .json language files from the language/ directory on startup and serves each player in their own client language automatically — Chinese (zh_CN) players see Chinese messages, English (en_US) players see English messages, and so on. The server-side default language is set by the language config field.

If a player's language is not available (e.g. zh_TW), the plugin falls back to the closest match (e.g. zh_CN → "language-family fallback"). If no match is found, it falls back to English, and then to the raw translation key.

The GitHub Releases page provides pre-packaged archives with Chinese and English language files. You may add or edit .json files in the language/ directory to add support for additional languages.

Config

After running the plugin for the first time, a "territory" folder will be automatically created in the plugins directory. This folder contains the configuration file "config.json" and the territory database file "territory_data.db".

The default configuration of the configuration file is as follows:

{
    "actor_fire_attack_protect": true,
    "allow_fly_on_territory": false,
    "allow_op_as_member": false,
    "language": "zh_CN",
    "max_tty_area": 4000000,
    "money_connect": false,
    "player_max_tty_num": 20,
    "price": 1.0
}

language is the language used by the plugin, which is Chinese by default. You can change the configuration according to the language file in the language folder.

actor_fire_attack_protect indicates whether to enable creature fire protection, which is enabled by default. While the plugin can intercept direct attacks from players on creatures, if a player's weapon has a fire aspect enchantment, the enchantment effect will still apply to the creatures, causing damage and resulting in incomplete protection. After enabling creature fire protection in the configuration file, unauthorized players will be unable to inflict any damage, including fire aspect damage, on creatures within the territory. However, creatures will also gain immunity to some fire damage.

max_tty_area represents the maximum area for a player-created territory, with a default of 4,000,000 units (2000x2000). Territories exceeding this size cannot be created.

money_connect indicates whether to enable the economy system, which is disabled by default. When enabled, creating territories will incur charges to the player through the economy system via the money_connect plugin.

player_max_tty_num is the maximum number of territories a player can own, with a default value of 20.

price is the price per unit area of territory, with a default value of 1.0. When the economy is enabled, this value serves as the price per unit area of territory for calculating the total territory cost.

allow_fly_on_territory indicates whether players are allowed to fly within the territory. This is disabled by default.

allow_op_as_member indicates whether server operators are treated as territory members for bypassing protection (breaking, placing, interacting, damaging entities) and teleportation. This is disabled by default.


Command Usage and Territory Management

Command list

Open territory menu

/tty

Create New Territory

/tty add Territory-corner-coordinate-1 Territory-corner-coordinate-2

Create New Sub-Territory

/tty add_sub Sub-Territory-corner-coordinate-1 Sub-Territory-corner-coordinate-2

Open quick territory creation menu

/tty quick add

Open quick sub-territory creation menu

/tty quick add_sub

List Territory

/tty list

Delete Territory

/tty del territory-name

Rename Territory

/tty rename old-name new-name

Set Territory Permissions

/tty set permission(if_jiaohu|if_break|if_tp|if_build|if_bomb|if_damage|if_edge_piston|if_wither) permission-value territory-name

Where the permission names respectively represent:

  • Whether to allow outsiders to interact within the territory.
  • Whether to allow outsiders to destroy within the territory.
  • Whether to allow outsiders to teleport to the territory.
  • Whether to allow outsiders to place within the territory.
  • Whether to allow entity explosions within the territory.
  • Whether to allow outsiders to attack entities.
  • Whether to allow pistons to work at the territory edge.
  • Whether to allow wither activities within the territory.

Set Territory Administrators

/tty manager add|remove player-name territory-name

Set Territory Members

/tty member add|remove player-name territory-name

Set Territory Teleport Point

/tty settp Territory-teleport-coordinates Territory-name

Teleport to Territory

/tty tp territory-name

Resize Territory

/tty resize territory-name new-coordinate-1 new-coordinate-2

Administrator Commands

Delete Territory

/optty del territory-name

Delete All Territories of a Player

/optty del_all player-name

Set Territory Permissions for a Player

/optty set permission(if_jiaohu|if_break|if_tp|if_build|if_bomb|if_damage|if_edge_piston|if_wither) permission-value territory-name

Transfer a Territory to Another Player

/optty transfer territory-name player-name

Transfer All Territories of a Player to Another Player

/optty transfer_all old-player-name new-player-name

Reload Territory Data and Configuration

/optty reload

Acknowledgments & Third-Party Libraries

This plugin is built upon the following open-source projects. Special thanks to their authors and maintainers:

  • nlohmann/json
    A high-performance, easy-to-use JSON parser and serialization library

  • fmtlib/fmt
    A modern string formatting library offering safe and efficient output

  • GlacieTeam/BinaryStream
    A binary stream parsing library for efficient packet handling

© 2023–2026 EndstoneMC

Not an official Minecraft product. Not approved by or associated with Mojang or Microsoft.