Added WorldGuardPlugin.canBuild(player, x, y, z)

This commit is contained in:
sk89q 2011-02-04 20:51:14 -08:00
parent e78b639018
commit d042185660

View File

@ -20,6 +20,7 @@
package com.sk89q.worldguard.bukkit; package com.sk89q.worldguard.bukkit;
import static com.sk89q.worldguard.bukkit.BukkitUtil.matchSinglePlayer; import static com.sk89q.worldguard.bukkit.BukkitUtil.matchSinglePlayer;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.logging.*; import java.util.logging.*;
@ -45,10 +46,12 @@
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.ItemType; import com.sk89q.worldedit.blocks.ItemType;
import com.sk89q.worldedit.bukkit.WorldEditAPI; import com.sk89q.worldedit.bukkit.WorldEditAPI;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.*; import com.sk89q.worldguard.blacklist.*;
import com.sk89q.worldguard.blacklist.loggers.*; import com.sk89q.worldguard.blacklist.loggers.*;
import com.sk89q.worldguard.domains.DefaultDomain; import com.sk89q.worldguard.domains.DefaultDomain;
@ -1335,6 +1338,22 @@ public ProtectionDatabase getRegionLoader() {
return regionLoader; return regionLoader;
} }
public boolean canBuild(Player player, int x, int y, int z) {
if (useRegions) {
Vector pt = new Vector(x, y, z);
LocalPlayer localPlayer = wrapPlayer(player);
if (!hasPermission(player, "/regionbypass")
&& !regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
return false;
}
return true;
} else {
return true;
}
}
boolean inGroup(Player player, String group) { boolean inGroup(Player player, String group) {
try { try {
return perms.inGroup(player.getName(), group); return perms.inGroup(player.getName(), group);