9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-28 03:09:14 +00:00

feature: Add Lands support

This commit is contained in:
SamB440
2022-05-11 20:46:12 +01:00
parent c13346d307
commit 041e9fe8a5
3 changed files with 80 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ dependencies {
}
compileOnly(":Residence4.9.2.2") // residence
compileOnly(":GriefPrevention") // griefprevention
compileOnly("com.github.angeschossen:LandsAPI:6.0.2") // lands
if (ultraRegionsSupport) compileOnly(":UltraRegions") // ultraregions
compileOnly(project(":api", "shadow"))

View File

@@ -0,0 +1,78 @@
package net.islandearth.rpgregions.api.integrations.lands;
import me.angeschossen.lands.api.land.Land;
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.bukkit.plugin.Plugin;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
public class LandsIntegration implements IntegrationManager {
private final IRPGRegionsAPI plugin;
private final me.angeschossen.lands.api.integration.LandsIntegration lands;
public LandsIntegration(IRPGRegionsAPI plugin) {
this.plugin = plugin;
this.lands = new me.angeschossen.lands.api.integration.LandsIntegration((Plugin) plugin);
}
@Override
public boolean isInRegion(Location location) {
return lands.isClaimed(location);
}
@Override
public void handleMove(PlayerMoveEvent pme) {
Player player = pme.getPlayer();
if (pme.getTo() == null) return;
Land oldLand = lands.getLand(pme.getFrom());
Land land = lands.getLand(pme.getTo());
if (oldLand == null || land == null || !land.exists()) return;
if (!checkRequirements(pme, land.getName())) return;
Bukkit.getPluginManager().callEvent(new RegionsEnterEvent(player, land.getName(), !oldLand.equals(land)));
}
@Override
public Optional<ConfiguredRegion> getPrioritisedRegion(Location location) {
Land land = lands.getLand(location);
return land == null || !land.exists()
? Optional.empty()
: plugin.getManagers().getRegionsCache().getConfiguredRegion(land.getName());
}
@Override
public boolean exists(World location, String region) {
Land land = lands.getLand(region);
return land != null && land.exists();
}
@Override
public Set<String> getAllRegionNames(World world) {
Set<String> landNames = new HashSet<>();
for (Land land : lands.getLands()) {
final String name = land.getName();
landNames.add(name);
}
return landNames;
}
@Override
public @NonNull List<Location> getBoundingBoxPoints(Location regionLocation, @Nullable String regionId) {
return new ArrayList<>();
}
}

View File

@@ -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]
softdepend: [Hyperverse, Multiverse, UltraRegions, WorldGuard, PlaceholderAPI, HeadDatabase, Residence, Plan, GriefPrevention, Vault, MythicMobs, AlonsoLevels, Dynmap, ProtocolLib, Quests, BetonQuest, Lands]
authors: [SamB440]
description: Discoverable regions
website: https://fortitude.islandearth.net