Search in sources :

Example 71 with Location

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.");
    }
}
Also used : LocalPlayer(com.sk89q.worldguard.LocalPlayer) Location(com.sk89q.worldedit.util.Location) Command(com.sk89q.minecraft.util.commands.Command) CommandPermissions(com.sk89q.minecraft.util.commands.CommandPermissions)

Example 72 with Location

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);
}
Also used : RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) Location(com.sk89q.worldedit.util.Location)

Example 73 with Location

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);
}
Also used : RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) Location(com.sk89q.worldedit.util.Location)

Example 74 with Location

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);
}
Also used : RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) Location(com.sk89q.worldedit.util.Location)

Example 75 with Location

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;
}
Also used : RegionContainer(com.sk89q.worldguard.protection.regions.RegionContainer) LocalPlayer(com.sk89q.worldguard.LocalPlayer) RegionQuery(com.sk89q.worldguard.protection.regions.RegionQuery) Location(com.sk89q.worldedit.util.Location)

Aggregations

Location (com.sk89q.worldedit.util.Location)75 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)26 BaseEntity (com.sk89q.worldedit.entity.BaseEntity)12 World (com.sk89q.worldedit.world.World)12 CompoundTag (com.sk89q.jnbt.CompoundTag)11 Region (com.sk89q.worldedit.regions.Region)10 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)9 Command (org.enginehub.piston.annotation.Command)9 MutableBlockVector3 (com.fastasyncworldedit.core.math.MutableBlockVector3)8 Tag (com.sk89q.jnbt.Tag)8 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)8 RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)8 List (java.util.List)8 ListTag (com.sk89q.jnbt.ListTag)7 Player (com.sk89q.worldedit.entity.Player)7 Vector3 (com.sk89q.worldedit.math.Vector3)7 BaseBlock (com.sk89q.worldedit.world.block.BaseBlock)7 LocalPlayer (com.sk89q.worldguard.LocalPlayer)7 StringTag (com.sk89q.jnbt.StringTag)6 BlockVector2 (com.sk89q.worldedit.math.BlockVector2)6