com.sk89q.worldguard.LocalPlayer Java Examples
The following examples show how to use
com.sk89q.worldguard.LocalPlayer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Worldguard.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public boolean isAllowed(LocalPlayer localplayer, ProtectedRegion region) { if (region.isOwner(localplayer) || region.isOwner(localplayer.getName())) { return true; } else if (region.getId().toLowerCase().equals(localplayer.getName().toLowerCase())) { return true; } else if (region.getId().toLowerCase().contains(localplayer.getName().toLowerCase() + "//")) { return true; } else if (region.isOwner("*")) { return true; } if (localplayer.hasPermission("fawe.worldguard.member")) { if (region.isMember(localplayer) || region.isMember(localplayer.getName())) { return true; } else if (region.isMember("*")) { return true; } } return false; }
Example #2
Source File: Worldguard.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public ProtectedRegion getRegion(final com.sk89q.worldguard.LocalPlayer player, final Location loc) { RegionManager manager = this.worldguard.getRegionManager(loc.getWorld()); if (manager == null) { if (this.worldguard.getGlobalStateManager().get(loc.getWorld()).useRegions) { System.out.println("Region capability is not enabled for WorldGuard."); } else { System.out.println("WorldGuard is not enabled for that world."); } return null; } final ProtectedRegion global = manager.getRegion("__global__"); if (global != null && isAllowed(player, global)) { return global; } final ApplicableRegionSet regions = manager.getApplicableRegions(loc); for (final ProtectedRegion region : regions) { if (isAllowed(player, region)) { return region; } } return null; }
Example #3
Source File: FaweWorldEditFlagMaskManager.java From WorldGuardExtraFlagsPlugin with MIT License | 6 votes |
public ProtectedRegion getRegion(Player player, Location loc) { final com.sk89q.worldguard.LocalPlayer localplayer = this.plugin.getWorldGuardCommunicator().wrapPlayer(player); AbstractRegionManagerWrapper manager = this.plugin.getWorldGuardCommunicator().getRegionContainer().get(player.getWorld()); final ProtectedRegion global = manager.getRegion("__global__"); if (global != null && !isDenied(localplayer, global)) { return global; } final ApplicableRegionSet regions = manager.getApplicableRegions(player.getLocation()); for (final ProtectedRegion region : regions) { if (!isDenied(localplayer, region)) { return region; } } return null; }
Example #4
Source File: WorldGuard.java From Modern-LWC with MIT License | 5 votes |
/** * Check if a player can build in a region * * @param player * @param block * @return */ private boolean canBuild(Player player, Block block) { LocalPlayer localPlayer = worldGuardPlugin.wrapPlayer(player); RegionPermissionModel regionPermissionModel = new RegionPermissionModel(localPlayer); if (regionPermissionModel.mayIgnoreRegionProtection(BukkitAdapter.adapt(block.getWorld()))) { return true; } RegionQuery regionQuery = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); return regionQuery.testBuild(BukkitAdapter.adapt(block.getLocation()), localPlayer); }
Example #5
Source File: WorldGuard7FAWEHook.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public boolean canBuild_i(final Player p, final Location l) { if (p.hasPermission("worldguard.region.bypass." + l.getWorld().getName())) return true; RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); LocalPlayer player = WorldGuardPlugin.inst().wrapPlayer(p); return query.testState(BukkitAdapter.adapt(l), player, Flags.BUILD); }
Example #6
Source File: HandlerWrapper.java From WorldGuardExtraFlagsPlugin with MIT License | 5 votes |
@Override public boolean onCrossBoundary(LocalPlayer localPlayer, com.sk89q.worldedit.util.Location from, com.sk89q.worldedit.util.Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType) { //It turns out that this is fired every time player moves //The plugin flags assume already that nothing changes unless region is crossed, so ignore when there isn't a region change //This optimization is already in place in the FVCH if (entered.isEmpty() && exited.isEmpty() && from.getExtent().equals(to.getExtent())) { return true; } return this.onCrossBoundary(((BukkitPlayer)localPlayer).getPlayer(), BukkitAdapter.adapt(from), BukkitAdapter.adapt(to), toSet, entered, exited, moveType); }
Example #7
Source File: HandlerWrapper.java From WorldGuardExtraFlagsPlugin with MIT License | 4 votes |
@Override public State getInvincibility(LocalPlayer localPlayer) { return this.getInvincibility(((BukkitPlayer)localPlayer).getPlayer()); }
Example #8
Source File: WorldGuard7Hook.java From RandomTeleport with GNU General Public License v3.0 | 4 votes |
private boolean canBuild(LocalPlayer player, Location location) { return WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().testBuild(location, player, Flags.BUILD); }
Example #9
Source File: WorldGuardSixCommunicator.java From WorldGuardExtraFlagsPlugin with MIT License | 4 votes |
@Override public LocalPlayer wrapPlayer(Player player) { return WorldGuardPlugin.inst().wrapPlayer(player); }
Example #10
Source File: FaweWorldEditFlagMaskManager.java From WorldGuardExtraFlagsPlugin with MIT License | 4 votes |
public boolean isDenied(LocalPlayer localplayer, ProtectedRegion region) { return region.getFlag(Flags.WORLDEDIT) == State.DENY; }
Example #11
Source File: WorldGuardSevenCommunicator.java From WorldGuardExtraFlagsPlugin with MIT License | 4 votes |
@Override public LocalPlayer wrapPlayer(Player player) { return WorldGuardPlugin.inst().wrapPlayer(player); }
Example #12
Source File: WorldGuardIntegration.java From QuickShop-Reremake with GNU General Public License v3.0 | 4 votes |
@Override public boolean canCreateShopHere(@NotNull Player player, @NotNull Location location) { LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); com.sk89q.worldedit.util.Location wgLoc = BukkitAdapter.adapt(location); boolean canBypass = WorldGuard.getInstance() .getPlatform() .getSessionManager() .hasBypass(localPlayer, BukkitAdapter.adapt(location.getWorld())); if (canBypass) { Util.debugLog( "Player " + player.getName() + " bypassing the protection checks, because player have bypass permission in WorldGuard"); return true; } RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); RegionQuery query = container.createQuery(); if (query.getApplicableRegions(wgLoc).getRegions().isEmpty()) { return !whiteList; } for (WorldGuardFlags flag : createFlags) { switch (flag) { case BUILD: if (query.queryState(wgLoc, localPlayer, Flags.BUILD) == StateFlag.State.DENY) { return false; } break; case FLAG: if (query.queryState(wgLoc, localPlayer, this.createFlag) == StateFlag.State.DENY) { return false; } break; case CHEST_ACCESS: if (query.queryState(wgLoc, localPlayer, Flags.CHEST_ACCESS) == StateFlag.State.DENY) { return false; } break; case INTERACT: if (query.queryState(wgLoc, localPlayer, Flags.INTERACT) == StateFlag.State.DENY) { return false; } break; } } return true; }
Example #13
Source File: HandlerWrapper.java From WorldGuardExtraFlagsPlugin with MIT License | 4 votes |
@Override public void tick(LocalPlayer localPlayer, ApplicableRegionSet set) { this.tick(((BukkitPlayer)localPlayer).getPlayer(), set); }
Example #14
Source File: HandlerWrapper.java From WorldGuardExtraFlagsPlugin with MIT License | 4 votes |
@Override public void initialize(LocalPlayer localPlayer, com.sk89q.worldedit.util.Location current, ApplicableRegionSet set) { this.initialize(((BukkitPlayer)localPlayer).getPlayer(), BukkitAdapter.adapt(current), set); }
Example #15
Source File: WorldGuardUtils.java From WorldGuardExtraFlagsPlugin with MIT License | 4 votes |
private static LocalPlayer wrapPlayer(Player player) { return WorldGuardUtils.getCommunicator().wrapPlayer(player); }
Example #16
Source File: WorldGuard.java From Modern-LWC with MIT License | 4 votes |
@Override public void onAccessRequest(LWCAccessEvent event) { if (event.getAccess() != Permission.Access.NONE) { // Player already has access. return; } // WorldGuard must be running and LWC must be configured to interface // with it. if (worldGuardPlugin == null) { return; } if (!configuration.getBoolean("worldguard.enabled", false)) { return; } if (!configuration .getBoolean("worldguard.allowRegionPermissions", true)) { return; } Protection protection = event.getProtection(); LocalPlayer wgPlayer = worldGuardPlugin.wrapPlayer(event.getPlayer()); for (Permission permission : protection.getPermissions()) { if (permission.getType() != Permission.Type.REGION) { continue; } String regionName = permission.getName(); if (regionName.equalsIgnoreCase("#this")) { // Handle the special value which tells us to not actually look // up a region but // check just the player's WG build permissions on the block. It // may be in multiple // regions or none; we don't care here. That's WorldGuard's // domain. if (!canBuild(event.getPlayer(), protection.getBlock())) { continue; } } else if (regionName.startsWith("#")) { // Silently disallow looking up regions by index, a newer WG // feature. // Iterating through potentially thousands of regions each time // we check a block's // ACL is not a good idea. It would be cleaner to use // regionManager.getRegionExact() // below, but that would break compatibility with older versions // of WG. continue; } else { // Region name specified, go look it up World world; int c = regionName.indexOf(':'); if (c < 0) { // No world specified in ACL. Use the block's world. world = protection.getBlock().getWorld(); } else { // World specified. Partition the string and look up the // world. String worldName = regionName.substring(c + 1); world = event.getLWC().getPlugin().getServer() .getWorld(worldName); regionName = regionName.substring(0, c); } if (world == null) { continue; } RegionManager regionManager = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world)); if (regionManager == null) { continue; } ProtectedRegion region = regionManager.getRegion(regionName); if (region == null) { continue; } // Check the region (and its parents) to see if the player is a // member (or an owner). if (!region.isMember(wgPlayer)) { continue; } } // We match the region, so bump up our access level. Whether we get // PLAYER access or // ADMIN access depends solely on the LWC permission entry. (I.e., // WG owner does not // imply LWC admin.) if (permission.getAccess().ordinal() > event.getAccess().ordinal()) { event.setAccess(permission.getAccess()); if (event.getAccess().ordinal() >= Permission.Access.ADMIN .ordinal()) { return; } // else we just have PLAYER access. Keep looking; maybe we match // another region // that grants us ADMIN. } } }
Example #17
Source File: WorldGuardIntegration.java From QuickShop-Reremake with GNU General Public License v3.0 | 4 votes |
@Override public boolean canTradeShopHere(@NotNull Player player, @NotNull Location location) { LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); com.sk89q.worldedit.util.Location wgLoc = BukkitAdapter.adapt(location); boolean canBypass = WorldGuard.getInstance() .getPlatform() .getSessionManager() .hasBypass(localPlayer, BukkitAdapter.adapt(location.getWorld())); if (canBypass) { Util.debugLog( "Player " + player.getName() + " bypassing the protection checks, because player have bypass permission in WorldGuard"); return true; } RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); RegionQuery query = container.createQuery(); if (query.getApplicableRegions(wgLoc).getRegions().isEmpty()) { return !whiteList; } for (WorldGuardFlags flag : tradeFlags) { switch (flag) { case BUILD: if (!query.testState(wgLoc, localPlayer, Flags.BUILD)) { return false; } break; case FLAG: if (!query.testState(wgLoc, localPlayer, this.tradeFlag)) { return false; } break; case CHEST_ACCESS: if (!query.testState(wgLoc, localPlayer, Flags.CHEST_ACCESS)) { return false; } break; case INTERACT: if (!query.testState(wgLoc, localPlayer, Flags.INTERACT)) { return false; } break; } } return true; }
Example #18
Source File: WorldGuardCommunicator.java From WorldGuardExtraFlagsPlugin with MIT License | votes |
public LocalPlayer wrapPlayer(Player player);