mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-29 11:49:08 +00:00
Merge branch 'master' into 'master'
Add GriefDefender integration See merge request SamB440/rpgregions-2!5
This commit is contained in:
@@ -11,6 +11,7 @@ public enum IntegrationType {
|
||||
WORLDGUARD("WorldGuard", "worldguard.WorldGuardIntegration"),
|
||||
RESIDENCE("Residence", "residence.ResidenceIntegration"),
|
||||
GRIEFPREVENTION("GriefPrevention", "griefprevention.GriefPreventionIntegration"),
|
||||
GRIEFDEFENDER("GriefDefender", "griefdefender.GriefDefenderIntegration"),
|
||||
LANDS("Lands", "lands.LandsIntegration"),
|
||||
ULTRAREGIONS("UltraRegions", "ultraregions.UltraRegionsIntegration"),
|
||||
RPGREGIONS("RPGRegions", "rpgregions.RPGRegionsIntegration");
|
||||
|
||||
@@ -55,6 +55,9 @@ allprojects {
|
||||
// Dynmap
|
||||
maven("https://repo.mikeprimm.com")
|
||||
|
||||
// GriefDefender
|
||||
maven("https://repo.glaremasters.me/repository/bloodshot")
|
||||
|
||||
flatDir { dir("../libraries") }
|
||||
}
|
||||
|
||||
|
||||
@@ -19,5 +19,6 @@ dependencies {
|
||||
compileOnly(":Residence4.9.2.2") // residence
|
||||
compileOnly(":GriefPrevention") // griefprevention
|
||||
compileOnly("com.github.angeschossen:LandsAPI:6.0.2") // lands
|
||||
compileOnly("com.griefdefender:api:2.1.0-SNAPSHOT") // GriefDefender
|
||||
if (ultraRegionsSupport) compileOnly(":UltraRegions") // ultraregions
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package net.islandearth.rpgregions.api.integrations.griefdefender;
|
||||
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.lib.flowpowered.math.vector.Vector3i;
|
||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||
import net.islandearth.rpgregions.api.events.RegionsEnterEvent;
|
||||
import net.islandearth.rpgregions.api.integrations.IntegrationManager;
|
||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class GriefDefenderIntegration implements IntegrationManager {
|
||||
|
||||
private final IRPGRegionsAPI plugin;
|
||||
|
||||
public GriefDefenderIntegration(IRPGRegionsAPI plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInRegion(Location location) {
|
||||
Claim claim = GriefDefender.getCore().getClaimAt(location);
|
||||
return claim != null && !claim.isWilderness();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMove(PlayerMoveEvent pme) {
|
||||
Player player = pme.getPlayer();
|
||||
if (pme.getTo() == null) return;
|
||||
Optional<ConfiguredRegion> getPrioritisedRegion = getPrioritisedRegion(pme.getTo());
|
||||
if (!getPrioritisedRegion.isPresent()) return;
|
||||
Claim oldClaim = GriefDefender.getCore().getClaimAt(pme.getFrom());
|
||||
if (oldClaim == null || oldClaim.isWilderness()) return;
|
||||
Claim claim = GriefDefender.getCore().getClaimAt(pme.getTo());
|
||||
|
||||
List<String> stringClaim = new ArrayList<>();
|
||||
if (!checkRequirements(pme, getPrioritisedRegion.get(), "" + claim.getUniqueId())) return;
|
||||
|
||||
stringClaim.add("" + claim.getUniqueId());
|
||||
Bukkit.getPluginManager().callEvent(new RegionsEnterEvent(player, stringClaim, !oldClaim.equals(claim)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ConfiguredRegion> getPrioritisedRegion(Location location) {
|
||||
Claim claim = GriefDefender.getCore().getClaimAt(location);
|
||||
if (claim == null || claim.isWilderness()) return Optional.empty();
|
||||
return plugin.getManagers().getRegionsCache().getConfiguredRegion("" + claim.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(World world, String region) {
|
||||
final Claim claim = GriefDefender.getCore().getClaim(UUID.fromString(region));
|
||||
return claim != null && !claim.isWilderness();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getAllRegionNames(World world) {
|
||||
Set<String> claimsString = new HashSet<>();
|
||||
if (!GriefDefender.getCore().isEnabled(world.getUID())) return claimsString;
|
||||
for (Claim claim : GriefDefender.getCore().getClaimManager( world.getUID() ).getWorldClaims()) {
|
||||
claimsString.add("" + claim.getUniqueId());
|
||||
}
|
||||
return claimsString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull List<Location> getBoundingBoxPoints(Location regionLocation, @Nullable String regionId) {
|
||||
List<Location> points = new ArrayList<>();
|
||||
Claim claim = GriefDefender.getCore().getClaimAt(regionLocation);
|
||||
if (claim == null) return points;
|
||||
if (regionId != null && !String.valueOf(claim.getUniqueId()).equals(regionId)) {
|
||||
return points;
|
||||
}
|
||||
|
||||
final Vector3i max = claim.getGreaterBoundaryCorner();
|
||||
final Vector3i min = claim.getLesserBoundaryCorner();
|
||||
World world = Bukkit.getWorld(claim.getWorldUniqueId());
|
||||
points.add(new Location(world, max.getX(), max.getY(), max.getZ()));
|
||||
points.add(new Location(world, min.getX(), min.getY(), min.getZ()));
|
||||
return points;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ settings:
|
||||
debug: false # Enables debug output. Will spam console!
|
||||
disable-slow-storage-warn: false # Should we send a warning if storage response times are slow?
|
||||
integration:
|
||||
name: RPGRegions # Name of the integration: WorldGuard, Residence, GriefPrevention, UltraRegions, Lands, RPGRegions
|
||||
name: RPGRegions # Name of the integration: WorldGuard, Residence, GriefPrevention, GriefDefender, UltraRegions, Lands, RPGRegions
|
||||
external:
|
||||
dynmap: true # Enable dynmap support
|
||||
storage:
|
||||
|
||||
@@ -4,7 +4,7 @@ main: net.islandearth.rpgregions.RPGRegions
|
||||
api-version: '1.16'
|
||||
libraries:
|
||||
- "com.zaxxer:HikariCP:4.0.3" # database
|
||||
softdepend: [Hyperverse, Multiverse, UltraRegions, WorldGuard, PlaceholderAPI, HeadDatabase, Residence, Plan, GriefPrevention, Vault, MythicMobs, AlonsoLevels, Dynmap, ProtocolLib, Quests, BetonQuest, Lands, MMOCore]
|
||||
softdepend: [Hyperverse, Multiverse, UltraRegions, WorldGuard, PlaceholderAPI, HeadDatabase, Residence, Plan, GriefPrevention, GriefDefender, Vault, MythicMobs, AlonsoLevels, Dynmap, ProtocolLib, Quests, BetonQuest, Lands, MMOCore]
|
||||
authors: [SamB440]
|
||||
description: Discoverable regions
|
||||
website: https://fortitude.islandearth.net
|
||||
Reference in New Issue
Block a user