9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-27 18:59:10 +00:00

Implements #13

This commit is contained in:
SamB440
2020-05-15 17:13:29 +01:00
parent e30c890c5d
commit 59e5269781
5 changed files with 79 additions and 1 deletions

View File

@@ -39,6 +39,12 @@ repositories {
maven {
url = 'https://campfire.islandearth.net/maven/'
}
// plan
maven {
name = 'bintray'
url = 'https://dl.bintray.com/rsl1122/Plan-repository'
}
}
dependencies {
@@ -48,6 +54,7 @@ dependencies {
compileOnly 'me.clip:placeholderapi:2.10.4' // PAPI
compileOnly 'net.islandearth:languagy:2.0.0-SNAPSHOT' // languagy
compileOnly 'com.github.shynixn.headdatabase:hdb-api:1.0' // head database
compileOnly 'com.djrapitops:Plan-api:5.1-R0.4' // plan
implementation 'co.aikar:acf-paper:0.5.0-SNAPSHOT' // commands
implementation 'co.aikar:idb-core:1.0.0-SNAPSHOT' // database

View File

@@ -0,0 +1,50 @@
package net.islandearth.rpgregions.api.integrations.hooks;
import com.djrapitops.plan.extension.CallEvents;
import com.djrapitops.plan.extension.DataExtension;
import com.djrapitops.plan.extension.FormatType;
import com.djrapitops.plan.extension.annotation.NumberProvider;
import com.djrapitops.plan.extension.annotation.PluginInfo;
import com.djrapitops.plan.extension.icon.Color;
import com.djrapitops.plan.extension.icon.Family;
import net.islandearth.rpgregions.RPGRegions;
import net.islandearth.rpgregions.managers.data.account.RPGRegionsAccount;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
@PluginInfo(name = "RPGRegions", iconName = "map", iconFamily = Family.SOLID, color = Color.BLUE)
public class PlanRegionHook implements DataExtension {
private final RPGRegions plugin;
public PlanRegionHook(RPGRegions plugin) {
this.plugin = plugin;
}
@NumberProvider(
text = "Regions discovered",
description = "How many regions the player has discovered",
priority = 4,
iconFamily = Family.SOLID,
iconColor = Color.NONE,
format = FormatType.NONE
)
public long regionCount(UUID playerUUID) {
try {
// Have to do blocking operation :(
RPGRegionsAccount account = plugin.getManagers().getStorageManager().getAccount(playerUUID).get();
return account.getDiscoveredRegions().size();
} catch (InterruptedException | ExecutionException ignored) { }
return 0;
}
@Override
public CallEvents[] callExtensionMethodsOn() {
return new CallEvents[]{
CallEvents.PLAYER_JOIN,
CallEvents.PLAYER_LEAVE,
CallEvents.SERVER_EXTENSION_REGISTER
};
}
}

View File

@@ -0,0 +1,17 @@
package net.islandearth.rpgregions.managers;
import com.djrapitops.plan.extension.ExtensionService;
import net.islandearth.rpgregions.RPGRegions;
import net.islandearth.rpgregions.api.integrations.hooks.PlanRegionHook;
public class PlanRegistryManager {
public PlanRegistryManager(RPGRegions plugin) {
try {
PlanRegionHook planRegionHook = new PlanRegionHook(plugin);
ExtensionService.getInstance().register(planRegionHook);
} catch (NoClassDefFoundError | IllegalStateException | IllegalArgumentException e) {
e.printStackTrace();
}
}
}

View File

@@ -107,6 +107,10 @@ public class RPGRegionsManagers {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PlaceholderRegionHook(plugin).register();
}
if (Bukkit.getPluginManager().getPlugin("Plan") != null) {
new PlanRegistryManager(plugin);
}
}
public StorageManager getStorageManager() {

View File

@@ -3,7 +3,7 @@ version: @version@
main: net.islandearth.rpgregions.RPGRegions
api-version: '1.13'
depend: [Languagy]
softdepend: [WorldGuard, PlaceholderAPI, HeadDatabase, Residence]
softdepend: [WorldGuard, PlaceholderAPI, HeadDatabase, Residence, Plan, GriefPrevention]
authors: [SamB440]
description: Discoverable regions
website: https://fortitude.islandearth.net