mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-09-29 04:07:30 +02:00
Update WorldGuard support to WG7
This commit is contained in:
parent
ed369d55c9
commit
8d4a73256d
12
pom.xml
12
pom.xml
@ -89,6 +89,18 @@
|
|||||||
<version>6.1</version>
|
<version>6.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
|
<artifactId>worldedit-bukkit</artifactId>
|
||||||
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
<artifactId>worldguard-legacy</artifactId>
|
||||||
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.griefcraft</groupId>
|
<groupId>com.griefcraft</groupId>
|
||||||
<artifactId>entitylwc</artifactId>
|
<artifactId>entitylwc</artifactId>
|
||||||
|
@ -3,6 +3,7 @@ package com.dre.brewery;
|
|||||||
import com.dre.brewery.filedata.*;
|
import com.dre.brewery.filedata.*;
|
||||||
import com.dre.brewery.integration.LogBlockBarrel;
|
import com.dre.brewery.integration.LogBlockBarrel;
|
||||||
import com.dre.brewery.integration.WGBarrel;
|
import com.dre.brewery.integration.WGBarrel;
|
||||||
|
import com.dre.brewery.integration.WGBarrel7;
|
||||||
import com.dre.brewery.integration.WGBarrelNew;
|
import com.dre.brewery.integration.WGBarrelNew;
|
||||||
import com.dre.brewery.integration.WGBarrelOld;
|
import com.dre.brewery.integration.WGBarrelOld;
|
||||||
import com.dre.brewery.listeners.*;
|
import com.dre.brewery.listeners.*;
|
||||||
@ -31,6 +32,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class P extends JavaPlugin {
|
public class P extends JavaPlugin {
|
||||||
@ -263,19 +265,17 @@ public class P extends JavaPlugin {
|
|||||||
// Third-Party
|
// Third-Party
|
||||||
useWG = config.getBoolean("useWorldGuard", true) && getServer().getPluginManager().isPluginEnabled("WorldGuard");
|
useWG = config.getBoolean("useWorldGuard", true) && getServer().getPluginManager().isPluginEnabled("WorldGuard");
|
||||||
if (useWG) {
|
if (useWG) {
|
||||||
try {
|
Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||||
try {
|
if (plugin != null) {
|
||||||
Class.forName("com.sk89q.worldguard.bukkit.RegionContainer");
|
String wgv = plugin.getDescription().getVersion();
|
||||||
wg = new WGBarrelNew();
|
if (wgv.startsWith("7.")) wg = new WGBarrel7();
|
||||||
} catch (ClassNotFoundException e) {
|
else if (wgv.startsWith("6.")) wg = new WGBarrelNew();
|
||||||
wg = new WGBarrelOld();
|
else if (wgv.startsWith("5.")) wg = new WGBarrelOld();
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
if (wg == null) {
|
||||||
wg = null;
|
|
||||||
P.p.errorLog("Failed loading WorldGuard Integration! Opening Barrels will NOT work!");
|
P.p.errorLog("Failed loading WorldGuard Integration! Opening Barrels will NOT work!");
|
||||||
P.p.errorLog("Brewery was tested with version 5.8 to 6.1 of WorldGuard!");
|
P.p.errorLog("Brewery was tested with version 5.8, 6.1 and 7.0 of WorldGuard!");
|
||||||
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
P.p.errorLog("Disable the WorldGuard support in the config and do /brew reload");
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
useLWC = config.getBoolean("useLWC", true) && getServer().getPluginManager().isPluginEnabled("LWC");
|
useLWC = config.getBoolean("useLWC", true) && getServer().getPluginManager().isPluginEnabled("LWC");
|
||||||
|
38
src/com/dre/brewery/integration/WGBarrel7.java
Normal file
38
src/com/dre/brewery/integration/WGBarrel7.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package com.dre.brewery.integration;
|
||||||
|
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import com.dre.brewery.P;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.bukkit.permission.RegionPermissionModel;
|
||||||
|
import com.sk89q.worldguard.internal.platform.WorldGuardPlatform;
|
||||||
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
|
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||||
|
|
||||||
|
public class WGBarrel7 implements WGBarrel {
|
||||||
|
|
||||||
|
public boolean checkAccess(Player player, Block spigot, Plugin plugin) {
|
||||||
|
WorldGuardPlugin wg = (WorldGuardPlugin) plugin;
|
||||||
|
WorldGuardPlatform platform = WorldGuard.getInstance().getPlatform();
|
||||||
|
|
||||||
|
World world = platform.getWorldByName(spigot.getWorld().getName());
|
||||||
|
if (!platform.getGlobalStateManager().get(world).useRegions) return true; // Region support disabled
|
||||||
|
if (new RegionPermissionModel(wg, player).mayIgnoreRegionProtection(spigot.getWorld())) return true; // Whitelisted cause
|
||||||
|
|
||||||
|
RegionQuery query = platform.getRegionContainer().createQuery();
|
||||||
|
|
||||||
|
if (!query.testBuild(new Location(world, spigot.getX(), spigot.getY(), spigot.getZ()), wg.wrapPlayer(player), Flags.USE, Flags.CHEST_ACCESS)) {
|
||||||
|
P.p.msg(player, P.p.languageReader.get("Error_NoBarrelAccess"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user