Added support for WorldGuard 6.0

This commit is contained in:
Grafe 2015-01-05 16:15:49 +01:00
parent 703edfc8b8
commit 68d5820501
3 changed files with 11 additions and 16 deletions

View File

@ -1,5 +1,5 @@
name: Brewery name: Brewery
version: 1.3 version: 1.3.1
main: com.dre.brewery.P main: com.dre.brewery.P
authors: [Milan Albrecht, Frank Baumann] authors: [Milan Albrecht, Frank Baumann]
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention] softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention]

View File

@ -4,7 +4,7 @@
<groupId>com.dre</groupId> <groupId>com.dre</groupId>
<artifactId>brewery</artifactId> <artifactId>brewery</artifactId>
<version>1.3</version> <version>1.3.1</version>
<name>Brewery</name> <name>Brewery</name>
<build> <build>
@ -130,9 +130,7 @@
<dependency> <dependency>
<groupId>com.sk89q</groupId> <groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId> <artifactId>worldguard</artifactId>
<version>LATEST</version> <version>6.0.0-beta-01</version>
<scope>compile</scope>
<type>jar</type>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -5,27 +5,24 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import com.dre.brewery.P; import com.dre.brewery.P;
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.bukkit.RegionQuery;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.DefaultFlag; import com.sk89q.worldguard.protection.flags.DefaultFlag;
public class WGBarrel { public class WGBarrel {
public static boolean checkAccess(Player player, Block spigot, Plugin plugin) { public static boolean checkAccess(Player player, Block spigot, Plugin plugin) {
WorldGuardPlugin wg = (WorldGuardPlugin) plugin; WorldGuardPlugin wg = (WorldGuardPlugin) plugin;
if (!wg.getGlobalRegionManager().hasBypass(player, player.getWorld())) { if (!wg.getGlobalRegionManager().hasBypass(player, player.getWorld())) {
ApplicableRegionSet region = wg.getRegionManager(player.getWorld()).getApplicableRegions(spigot.getLocation()); RegionQuery query = wg.getRegionContainer().createQuery();
if (region != null) {
LocalPlayer localPlayer = wg.wrapPlayer(player); if(!query.testState(player.getLocation(), player, DefaultFlag.CHEST_ACCESS, DefaultFlag.BUILD)){
if (!region.allows(DefaultFlag.CHEST_ACCESS, localPlayer)) { P.p.msg(player, P.p.languageReader.get("Error_NoBarrelAccess"));
if (!region.canBuild(localPlayer)) { return false;
P.p.msg(player, P.p.languageReader.get("Error_NoBarrelAccess"));
return false;
}
}
} }
} }
return true; return true;
} }
} }