1 Create an integration
Thijs Wiefferink edited this page 2018-08-11 23:19:01 +02:00

To hook into AreaShop from your own plugin you can add it as a Maven dependency (recommended) or manual dependency.

Add AreaShop as Maven dependency

  1. Add my Maven repository:

    <repositories>
      <repository>
        <id>nlthijs48</id>
        <url>http://maven.wiefferink.me</url>
      </repository>
    </repositories>
    
  2. Add the Maven dependency:

    <dependencies>
      <dependency>
        <groupId>me.wiefferink</groupId>
        <artifactId>areashop</artifactId>
        <version>2.4.0-SNAPSHOT</version>
      </dependency>
    </dependencies>
    

Get all AreaShop regions

  1. Get a reference to Areashop:
    • Use AreaShop areaShop = AreaShop.getInstance();
    • Or use AreaShop areaShop = (AreaShop)Bukkit.getServer().getPluginManager().getPlugin("AreaShop");
    • Using AreaShop as optional dependency? Use the second option, check if getPlugin() returns non-null, after that instantiate your classes that use AreaShop.
  2. Use areaShop.getFileManager().getRegions() (or getBuys() or getRents() or getRegion(String name))
  3. Call methods on the region to edit anything you need (see the javadocs)

Listen to AreaShop region changes

  1. Choose an event to listen for, see available types here.
    • In the ask folder are cancel-able events for renting/buying/etc.
    • In the notify folder are the same events, buy only for notifying a certain action happened.
  2. Create a standard Bukkit event handler:
    @EventHandler
    public void sellingRegion(SellingRegionEvent event) {
        // Handle the event
    }