use of com.sk89q.worldedit.util.Location in project WorldGuard by EngineHub.
the class GeneralCommands method locate.
@Command(aliases = { "locate" }, usage = "[player]", desc = "Locate a player", max = 1)
@CommandPermissions({ "worldguard.locate" })
public void locate(CommandContext args, Actor sender) throws CommandException {
LocalPlayer player = worldGuard.checkPlayer(sender);
if (args.argsLength() == 0) {
player.setCompassTarget(new Location(player.getWorld(), player.getWorld().getSpawnPosition().toVector3()));
sender.print("Compass reset to spawn.");
} else {
LocalPlayer target = worldGuard.getPlatform().getMatcher().matchSinglePlayer(sender, args.getString(0));
player.setCompassTarget(target.getLocation());
sender.print("Compass repointed.");
}
}
use of com.sk89q.worldedit.util.Location in project Nexus by ProjectEdenGG.
the class WorldGuardFlagUtils method test.
// Main Methods //
/**
* Test if the effective value for a list of flags is {@code ALLOW}.
*
* <p>This method does not check the region bypass permission. That must be done by the calling code.</p>
*
* @param location location of interaction
* @param associable object to check for region membership
* @param flags flags to check
* @return true if the result was {@code ALLOW}
* @see #hasBypass(HasPlayer)
*/
public static boolean test(@NotNull org.bukkit.Location location, @Nullable RegionAssociable associable, @NotNull StateFlag... flags) {
Validate.notNull(location, "Location cannot be null");
Validate.notNull(flags, "Flags cannot be null");
Location loc = BukkitAdapter.adapt(location);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
return container.createQuery().testState(loc, associable, flags);
}
use of com.sk89q.worldedit.util.Location in project Nexus by ProjectEdenGG.
the class WorldGuardFlagUtils method query.
/**
* Gets the effective state of a flag. This follows state rules, where {@code DENY} overrides
* {@code ALLOW} overrides {@code NONE}.
*
* @param location location of interaction
* @param associable object to check for region membership
* @param flags flags to check
* @return effective state
*/
public static State query(@NotNull org.bukkit.Location location, @Nullable RegionAssociable associable, @NotNull StateFlag... flags) {
Validate.notNull(location, "Location cannot be null");
Validate.notNull(flags, "Flags cannot be null");
Location loc = BukkitAdapter.adapt(location);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
return container.createQuery().queryState(loc, associable, flags);
}
use of com.sk89q.worldedit.util.Location in project Nexus by ProjectEdenGG.
the class WorldGuardFlagUtils method queryValue.
/**
* Gets the effective value of a flag.
*
* <p>This method does not check the region bypass permission. That must be done by the calling code.</p>
*
* @param location location of interaction
* @param associable object to check for region membership
* @param flag flag to check
* @return effective value
* @see #hasBypass(HasPlayer)
*/
public static <T> T queryValue(@NotNull org.bukkit.Location location, @Nullable RegionAssociable associable, @NotNull Flag<T> flag) {
Validate.notNull(location, "Location cannot be null");
Validate.notNull(flag, "Flag cannot be null");
Location loc = BukkitAdapter.adapt(location);
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
return container.createQuery().queryValue(loc, associable, flag);
}
use of com.sk89q.worldedit.util.Location in project SignShop by wargamer.
the class WorldGuardHook method canBuild.
@Override
public Boolean canBuild(Player player, Block block) {
if (HookManager.getHook("WorldGuard") == null)
return true;
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
Location loc = BukkitAdapter.adapt(block.getLocation());
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
boolean canBypass = WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld());
boolean canBuild = query.testState(loc, localPlayer, Flags.BUILD);
return canBypass || canBuild;
}
Aggregations