mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-01-05 14:58:00 +01:00
WorldGuard 7.0.0 support
This commit is contained in:
parent
55a081c5cc
commit
9dcf8d5b60
@ -14,6 +14,12 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda.epicbosses</groupId>
|
||||
<artifactId>FactionHelper</artifactId>
|
||||
|
@ -14,6 +14,12 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda.epicbosses</groupId>
|
||||
<artifactId>FactionHelper</artifactId>
|
||||
|
@ -14,6 +14,12 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda.epicbosses</groupId>
|
||||
<artifactId>FactionHelper</artifactId>
|
||||
|
@ -14,6 +14,12 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda.epicbosses</groupId>
|
||||
<artifactId>FactionHelper</artifactId>
|
||||
|
42
api-modules/WorldGuard-Legacy/pom.xml
Normal file
42
api-modules/WorldGuard-Legacy/pom.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>EpicBosses</artifactId>
|
||||
<groupId>com.songoda.epicbosses</groupId>
|
||||
<version>maven-version-number</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>WorldGuard-Legacy</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda.epicbosses</groupId>
|
||||
<artifactId>WorldGuardHelper</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldedit</artifactId>
|
||||
<version>6.1.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.2.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -18,7 +18,7 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 16-Oct-18
|
||||
*/
|
||||
public class WorldGuardHelper implements IWorldGuardHelper {
|
||||
public class WorldGuardLegacyHelper implements IWorldGuardHelper {
|
||||
|
||||
private WorldGuardPlugin worldGuard;
|
||||
|
42
api-modules/WorldGuard/pom.xml
Normal file
42
api-modules/WorldGuard/pom.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>EpicBosses</artifactId>
|
||||
<groupId>com.songoda.epicbosses</groupId>
|
||||
<version>maven-version-number</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>WorldGuard</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.14.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda.epicbosses</groupId>
|
||||
<artifactId>WorldGuardHelper</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldedit</artifactId>
|
||||
<version>7.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>7.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,134 @@
|
||||
package com.songoda.epicbosses.utils.dependencies;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import com.songoda.epicbosses.utils.IWorldGuardHelper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 16-Oct-18
|
||||
*/
|
||||
public class WorldGuardHelper implements IWorldGuardHelper {
|
||||
|
||||
private WorldGuard worldGuard;
|
||||
|
||||
@Override
|
||||
public boolean isPvpAllowed(Location loc) {
|
||||
if(Bukkit.getServer().getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
if(worldGuard == null) {
|
||||
this.worldGuard = WorldGuard.getInstance();
|
||||
}
|
||||
|
||||
RegionQuery regionQuery = this.worldGuard.getPlatform().getRegionContainer().createQuery();
|
||||
ApplicableRegionSet applicableRegionSet = regionQuery.getApplicableRegions(BukkitAdapter.adapt(loc));
|
||||
StateFlag.State state = applicableRegionSet.queryState(null, Flags.PVP);
|
||||
|
||||
return state != StateFlag.State.DENY;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBreakAllowed(Location loc) {
|
||||
if(Bukkit.getServer().getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
if(worldGuard == null) {
|
||||
this.worldGuard = WorldGuard.getInstance();
|
||||
}
|
||||
|
||||
RegionQuery regionQuery = this.worldGuard.getPlatform().getRegionContainer().createQuery();
|
||||
ApplicableRegionSet applicableRegionSet = regionQuery.getApplicableRegions(BukkitAdapter.adapt(loc));
|
||||
StateFlag.State state = applicableRegionSet.queryState(null, Flags.BLOCK_BREAK);
|
||||
|
||||
return state != StateFlag.State.DENY;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExplosionsAllowed(Location loc) {
|
||||
if(Bukkit.getServer().getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
if(worldGuard == null) {
|
||||
this.worldGuard = WorldGuard.getInstance();
|
||||
}
|
||||
|
||||
RegionQuery regionQuery = this.worldGuard.getPlatform().getRegionContainer().createQuery();
|
||||
ApplicableRegionSet applicableRegionSet = regionQuery.getApplicableRegions(BukkitAdapter.adapt(loc));
|
||||
StateFlag.State state = applicableRegionSet.queryState(null, Flags.OTHER_EXPLOSION);
|
||||
|
||||
return state != StateFlag.State.DENY;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRegionNames(Location loc) {
|
||||
if(Bukkit.getServer().getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
if (worldGuard == null) {
|
||||
this.worldGuard = WorldGuard.getInstance();
|
||||
}
|
||||
|
||||
List<String> regions = new ArrayList<>();
|
||||
List<String> parentNames = new ArrayList<>();
|
||||
World world = BukkitAdapter.adapt(loc.getWorld());
|
||||
RegionManager regionManager = this.worldGuard.getPlatform().getRegionContainer().get(world);
|
||||
|
||||
if (regionManager == null) return null;
|
||||
|
||||
ApplicableRegionSet set = regionManager.getApplicableRegions(BukkitAdapter.asBlockVector(loc));
|
||||
|
||||
for (ProtectedRegion region : set) {
|
||||
String id = region.getId();
|
||||
|
||||
regions.add(id);
|
||||
|
||||
ProtectedRegion parent = region.getParent();
|
||||
|
||||
while (parent != null) {
|
||||
parentNames.add(parent.getId());
|
||||
parent = parent.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
for (String name : parentNames) {
|
||||
regions.remove(name);
|
||||
}
|
||||
|
||||
return regions;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMobSpawningAllowed(Location loc) {
|
||||
if(Bukkit.getServer().getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
if(worldGuard == null) {
|
||||
this.worldGuard = WorldGuard.getInstance();
|
||||
}
|
||||
|
||||
RegionQuery regionQuery = this.worldGuard.getPlatform().getRegionContainer().createQuery();
|
||||
ApplicableRegionSet applicableRegionSet = regionQuery.getApplicableRegions(BukkitAdapter.adapt(loc));
|
||||
StateFlag.State state = applicableRegionSet.queryState(null, Flags.MOB_SPAWNING);
|
||||
|
||||
return state != StateFlag.State.DENY;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -14,6 +14,12 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>FactionHelper</artifactId>
|
||||
@ -44,6 +50,24 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>WorldGuardHelper</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>WorldGuard</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>WorldGuard-Legacy</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.songoda.epicbosses.managers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.epicbosses.utils.dependencies.WorldGuardHelper;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import lombok.Getter;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.utils.IASkyblockHelper;
|
||||
@ -11,7 +14,7 @@ import utils.factions.FactionsM;
|
||||
import utils.factions.FactionsOne;
|
||||
import utils.factions.FactionsUUID;
|
||||
import utils.factions.LegacyFactions;
|
||||
import com.songoda.epicbosses.utils.dependencies.WorldGuardHelper;
|
||||
import com.songoda.epicbosses.utils.dependencies.WorldGuardLegacyHelper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -73,7 +76,11 @@ public class BossHookManager implements IReloadable {
|
||||
private void setupWorldGuard() {
|
||||
if(!isWorldguardEnabled()) return;
|
||||
|
||||
this.worldGuardHelper = new WorldGuardHelper();
|
||||
if (new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1)) {
|
||||
this.worldGuardHelper = new WorldGuardHelper();
|
||||
} else {
|
||||
this.worldGuardHelper = new WorldGuardLegacyHelper();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupFactions() {
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -90,7 +91,7 @@ public class ServerUtils {
|
||||
|
||||
public Entity getEntity(UUID uuid) {
|
||||
for (World world : Bukkit.getWorlds())
|
||||
for (Entity entity : world.getEntities())
|
||||
for (Entity entity : new ArrayList<>(world.getEntities()))
|
||||
if (entity.getUniqueId().equals(uuid))
|
||||
return entity;
|
||||
return null;
|
||||
|
@ -18,7 +18,10 @@ public enum Versions {
|
||||
v1_9_R2(7, "1.9.4"),
|
||||
v1_10_R1(8, "1.10"),
|
||||
v1_11_R1(9, "1.11.2"),
|
||||
v1_12_R1(10, "1.12.1");
|
||||
v1_12_R1(10, "1.12.1"),
|
||||
v1_13_R1(11, "1.13"),
|
||||
v1_13_R2(12, "1.13.2"),
|
||||
v1_14_R1(13, "1.14");
|
||||
|
||||
@Getter private String displayVersion, bukkitVersion;
|
||||
private int weight;
|
||||
|
@ -11,4 +11,13 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>FactionHelper</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
23
plugin-modules/WorldGuardHelper/pom.xml
Normal file
23
plugin-modules/WorldGuardHelper/pom.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>EpicBosses</artifactId>
|
||||
<groupId>com.songoda.epicbosses</groupId>
|
||||
<version>maven-version-number</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>WorldGuardHelper</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
36
pom.xml
36
pom.xml
@ -14,8 +14,11 @@
|
||||
<module>api-modules/FactionsOne</module>
|
||||
<module>api-modules/FactionsUUID</module>
|
||||
<module>api-modules/LegacyFactions</module>
|
||||
<module>api-modules/WorldGuard</module>
|
||||
<module>api-modules/WorldGuard-Legacy</module>
|
||||
<module>plugin-modules/Core</module>
|
||||
<module>plugin-modules/FactionHelper</module>
|
||||
<module>plugin-modules/WorldGuardHelper</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
@ -26,30 +29,12 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl</groupId>
|
||||
<artifactId>vault</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldedit</artifactId>
|
||||
<version>6.1.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.2.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.wasteofplastic</groupId>
|
||||
<artifactId>askyblock</artifactId>
|
||||
@ -153,6 +138,21 @@
|
||||
<artifactId>LegacyFactions</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>WorldGuardHelper</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>WorldGuard</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>WorldGuard-Legacy</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>Core</artifactId>
|
||||
|
Loading…
Reference in New Issue
Block a user