RegionGuard - A plugin to protect territories

This is a discussion topic for the Ore project, RegionGuard. View the full project on Ore for downloads and more information.


RegionGuard

LocaleAPI - required.

MySQLDriver - optional support included.

This job was quite a challenge for me. And it was the first time I did such a large-scale work. Therefore, I will be glad to receive suggestions on how to improve the code.

For server admins:

Features:

  • The commands are partially similar to those in the WorldGuard plugin.
  • Working with flags is similar to what you may have seen in the GriefPrevention plugin.
  • WECui support. No dependence on WorldEdit.
  • Players in regions can be assigned different roles.
  • Player limits are set via metadata in the permissions plugin.
  • Optional Sponge economy support.
  • MySQL support.
  • Ability to regenerate territory when a region is removed.
  • Developers can use the plugin API to extend its functionality and use its functions in their plugins.

Commands:

/rg wand - Get an item to create regions.
/rg claim - Claim the allocated region.
/rg delete - Delete the region.
/rg info - Information about the region.
/rg limits - Information about your limits.
/rg setname <ClearFlag> <OptionalLocale> [Name] - Set the name of the region.
/rg setmessage <CommandFlags> <Locale> [Message] - Set/remove the join/exit message in the region.
/rg flag [FlagName] [Value] <Source> <Target> - Set the flag parameters.
/rg leave - Leave from region.
/rg setowner [Player] - Set the owner of the region.
/rg trust [Player] [TrustType] - Add a player to the region and specify his rights in the region.
/rg untrust [Player] - Remove a player from the region.
/rg setselector [Type] - Select the type of area selection.
/rg setcreatingtype [Type] - Select the type of region to be created.
/rg wecui - Switch the sending status of WECui packets.
/rg list - Show list of regions.
/rg buylimit blocks [Volume] - Payment in game currency to increase the limit of blocks.
/rg buylimit claims [Volume] - Payment in game currency to increase the limit of claims.
/rg buylimit subdivisions [Volume] - Payment in game currency to increase the limit of subdivisions.
/rg buylimit members [Volume] - Payment in game currency to increase the limit of region members.
/rg selllimit blocks [Volume] - Selling the limit of blocks for game currency.
/rg selllimit claims [Volume] - Selling the limit of claims for game currency.
/rg selllimit subdivisions [Volume] - Selling the limit of subdivisions for game currency.
/rg selllimit members [Volume] - Selling the limit of region members for game currency.
/rg setlimit blocks [Player] [Size] - Change the blocks limit of the player.
/rg setlimit claims [Player] [Size] - Change the claims limit of the player.
/rg setlimit subdivisions [Player] [Size] - Change the subdivisions limit of the player.
/rg setlimit members [Player] [Size] - Changing the limit of members in the player regions.
/rg updatedefaultflags - Setting default flags based on those available in the region at the player location.

Region member types:

Hunter - Can only attack hostile monsters.
Sleep - Can only use the bed.
Container - Can use a bed and containers.
User - An ordinary member of the region. Can break and place blocks, attack any mobs and so on.
Builder - Can break, place blocks, use containers.
Manager - Has all the same rights as a normal region member, but in addition can add or exclude other members.
Owner - Region Owner.

Permissions:

regionguard.user.help - Main command.
regionguard.user.wand - Get an item for allocating regions.
regionguard.user.claim - Claimed region.
regionguard.user.delete - Delete region.
regionguard.user.info - Region info command.
regionguard.user.trust - Add a player to the region and assign him permissions.
regionguard.user.setmessage - Set/clear join/exit message for region.
regionguard.user.setname - Set name for region.
regionguard.user.selector - Change the type of area you want to select.
regionguard.user.flag - View Flags. You cannot change a flag without a permission for him.
regionguard.user.wecui - Displaying region boundaries with WECui mod, as well as switching the status of working with the mod.
regionguard.user.buy.blocks - Payment in game currency to increase the limit of blocks.
regionguard.user.buy.claims - Payment in game currency to increase the limit of claims.
regionguard.user.buy.subdivisions - Payment in game currency to increase the limit of subdivisions.
regionguard.user.buy.members - Payment in game currency to increase the limit of region members.
regionguard.user.sell.blocks - Selling the limit of blocks for game currency.
regionguard.user.sell.claims - Selling the limit of claims for game currency.
regionguard.user.sell.subdivisions - Selling the limit of subdivisions for game currency.
regionguard.user.sell.members - Selling the limit of region members for game currency.
regionguard.user.list - Show list of regions.
regionguard.user.teleport - Teleportation to the region.
regionguard.flags - Access flags by their lowercase name.
regionguard.flag.bypass - Flags bypass. For admins. You can add specific flags in lower-case to the permission.
regionguard.unlimit.blocks - Unlimited number of blocks that can be claimed.
regionguard.unlimit.claims - Unlimited number of regions created.
regionguard.unlimit.subdivisions - Unlimited subdivisions per region.
regionguard.unlimit.members - Unlimited number of players you can add to the region.
regionguard.staff.delete - Removing the region of any player.
regionguard.staff.resize - Change the size of any player’s region.
regionguard.staff.trust - Adding players to the region of any player.
regionguard.staff.setmessage - Set/remove the join/exit message for any region.
regionguard.staff.setname - Set a name for any region.
regionguard.staff.setregiontype - Change the type of region and select the type of regions to be created.
regionguard.staff.flag - Changing flags in any region.
regionguard.staff.list - Getting a list of regions of any player. The ability to teleport is available by default.
regionguard.staff.setlimit.blocks - Change the blocks limit of the player.
regionguard.staff.setlimit.claims - Change the claims limit of the player.
regionguard.staff.setlimit.subdivisions - Change the subdivisions limit of the player.
regionguard.staff.setlimit.subdivisions - Change the subdivisions limit of the player.
regionguard.staff.setlimit.members - Changing the limit of members in the player regions.
regionguard.staff.adminclaim - Creation of subdivisions in admin regions.
regionguard.staff.updatedefaultflags - Setting default flags based on those available in the region at the player location.

Metaperms:

regionguard.limit.blocks - The limit of blocks a player can claim.
regionguard.limit.claims - Player claims limit.
regionguard.limit.subdivisions - Player subdivisions limit per region.
regionguard.limit.members - Members limit for each player region.
regionguard.limit.max.blocks - The maximum number of blocks a player can claim when using the economy.
regionguard.limit.max.claims - The maximum number of regions a player can claim when using the economy.
regionguard.limit.max.subdivisions - The maximum number of subdivisions a player can claim when using the economy.
regionguard.limit.max.members - The maximum number of region members a player can add using the economy.
regionguard.buy.blockprice - Purchase price of 1 block.
regionguard.buy.regionprice - Purchase price of 1 region.
regionguard.buy.subdivisionprice - Purchase price of 1 subdivision.
regionguard.buy.memberprice - The price for increasing the limit of participants by 1.
regionguard.sell.blockprice - Selling price of 1 block.
regionguard.sell.regionprice - Selling price of 1 region.
regionguard.sell.subdivisionprice - Selling price of 1 subdivision.
regionguard.sell.memberprice - The price of reducing the limit of participants by 1.
regionguard.transaction.currency - Currency in which the player will be buying and selling limits.

Example set metaperms:

lp group default meta set regionguard.limit.claims 3
lp group default meta set regionguard.limit.subdivisions 5
lp group default meta set regionguard.limit.blocks 1000
lp group default meta set regionguard.limit.members 5

WECui forge version → https://www.curseforge.com/minecraft/mc-mods/worldeditcui-forge-edition-3

For developers:

javadoc → Overview (RegionGuard 1.5.0-S8.0.0-RELEASE API)

Get API:
@Plugin("pluginid")
public class Main {
	private Main instance;
	private Logger logger;
	private RegionAPI regionAPI;

	// Get API. This happens in event `ConstructPluginEvent`.
	@Listener
	public void onRegionAPIPostEvent(RegionAPIPostEvent.PostAPI event) {
		instance = this;
		logger = LogManager.getLogger("PluginName");
		regionAPI = event.getAPI();
	}

	// At this stage, you can access the regions.
	@Listener
	public void onCompleteLoadRegionsEvent(RegionAPIPostEvent.CompleteLoadRegions event) {
		logger.info(event.getTotalLoaded());
		//TODO
	}

}
Gradle:
repositories {
	...
	maven { 
		name = "JitPack"
		url 'https://jitpack.io' 
	}
}
dependencies {
	...
	implementation 'com.github.SawFowl:RegionGuard:1.5.0'
}

A new version has been released for RegionGuard, it is available for download here.


First Release. Since I can not check everything myself, there may be bugs in the work of some elements. If you notice anything, please let me know.

A new version has been released for RegionGuard, it is available for download here.


Fixed various errors. Reduced RAM consumption.

A new version has been released for RegionGuard, it is available for download here.


Fixed a few bugs.
Added economy support.
Added MySQL support.
Added region deletion event.
Added a command to get the list of regions.
Added commands to buy/sell the limits available to the player (requires an economy plugin on the server).
Added ability to regenerate territory.

1 Like

Hello I am trying to run a small pixelmon server for a few friends. I want a space in spawn protected area to create a rentable region, rent not buy to prevent that horrible sight of abandoned building in servers. Is there any way to add a sign command for that purpose? The perms and sell commands and economy are already there is there any way to add this option? And by the way does this plugin support 3D zones to allow for something like a multiplayer motel?

Thank you very much for your work this is already the newest best plug-in available for region protect, it is just a suggestion.

1 Like

Hello. I didn’t plan to do a region rental functionality, but if you have an entry-level plugin developer on your team, he may well implement this feature for your server. The plugin has the necessary API for this. I recommend that you do a plugin event listen, so you do not need to retrieve the region from the position yourself.
3D zones are supported. You can set them by default in the configuration file. Section DefaultValues, Selector. Note that in 3D mode the occupied blocks are calculated on three axes. Also, all of the subdivisions are in 3D format.

Thanks for the review.

A new version has been released for RegionGuard, it is available for download here.


Fixes for various minor bugs.

A new version has been released for RegionGuard, it is available for download here.


Implement async territory regeneration.
Implemented the ChangeEntityWorldEvent.Reposition event listener.
Added the event of teleporting a player to a region with the /rg list command.
Improved default flags settings.
Added ability to customize WECui visualization.
The logic of the regions resizing process has been improved.
Added administrative commands to change player limits.
Changes in the construction of the plugin commands.
Fixed territory regen by staff.

A new version has been released for RegionGuard, it is available for download here.


Fixed a permission to change the region’s members limit.

A section in the configuration file has been changed specifying the default selectior type. The default selectior type is now specified in the DefaultSelector section.

A new version has been released for RegionGuard, it is available for download here.


Various fixes to the commands.
Added a command to change default flags based on the region the player is in (child regions are not used).
When compiling, the MySQL driver is now added to the plugin.

A new version has been released for RegionGuard, it is available for download here.


Fixed various bugs in the code.
Added optional support for the plugin with the MySQL driver.
Improved how piston flags work. They can now accept source and target event arguments.
The Piston-Grief flag now completely blocks pistons from entering the region. Block penetration is also blocked by the Piston flag.
Two piston events have been added to the API. One is distributed only within region, the second event occurs when piston tries to interact with another region.
Flags registration was added to the API. Flags added by other plugins will be available in game.
Work has been done on adding additional data to the region by other plugins. Functionality is tested and usable.
Now, when writing addons, the development environment will show the documentation and source code.

A new version has been released for RegionGuard, it is available for download here.


Fixed wecui packet listening conflict with WorldEdit plugin.
Fixed one NPE error in the region class.
Reworked the configuration. Redesigned to a more convenient form in terms of development.
Modified the event of affecting regions with pistons. Now when searching for affected regions, a collection is created instead of just one unique region.
Modified build.gradle to automatically generate the sponge_plugins.json file