📗
Wiki
  • WIKI
  • Plugins
    • InfoHeads
      • Installation
      • FAQ
      • Using the Wizard
    • MailMe
      • Updating to MailMe Rewrite
      • FAQ
      • Setup
      • Tutorials
        • Niche
        • MailPresets
      • API
        • Setup
        • Interacting with the Database
  • Libraries
    • ProtectionAPI
      • Introduction
      • Getting Started
      • Tutorials
        • Creating a UniversalRegion
        • Collision Detection
      • Change Log
    • HexiTextLib
      • Introduction
      • Setup
        • Gradle
        • Maven
      • Using HexResolver
      • Using FontResolver
      • Change Log
Powered by GitBook
On this page
  • Regions
  • Creating a Polygon Region
  • Adding Region Attributes

Was this helpful?

  1. Libraries
  2. ProtectionAPI
  3. Tutorials

Creating a UniversalRegion

Universal Regions are the home to most of the important methods. Learn how to make one!

PreviousTutorialsNextCollision Detection

Last updated 5 years ago

Was this helpful?

Regions

The API is documented. You can view the code and most up-to-date code and new methods

UniversalRegion abstract

UniversalRegion is an abstract class type. Therefore you cannot create an instance of it directly. To create your own universal region class type you have to use the child class Region3D

new Region3D();

Furthermore, the Region3D class requires the parameters: World, Vector...

So, to create a region based off of a simple min and max point, you would write the following code:

Vector min = new Vector(0,0,0);
Vector max = new Vector(5,10,5);
World world = Bukkit.getWorld("world");

// Create the region
new Region3D(world, min, max);

Creating a Polygon Region

To create a polygon region, you need to specify all the points when creating the Region3D object. It's important that you input the points in the correct path order to create the object. Otherwise instead of looking like this:

It will look like this:

Example Code:

Vector point1 = new Vector(0,0,0);
Vector point2 = new Vector(0,0,5);
Vector point3 = new Vector(5,0,0);
World world = Bukkit.getWorld("world");

new Region3D(world, point1, point2, point3);

Adding Region Attributes

The UniversalRegion has a Builder Pattern. This means you can string along your setters in one long path.

new Region3d(world, point1, point2)
    .setDateCreated(date)
    .setAdmins(admins)
    .setOwners(owners)
    .setMembers(members);
here
Good representation
Poor Representation