本文整理汇总了Java中com.sk89q.worldguard.LocalPlayer类的典型用法代码示例。如果您正苦于以下问题:Java LocalPlayer类的具体用法?Java LocalPlayer怎么用?Java LocalPlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LocalPlayer类属于com.sk89q.worldguard包,在下文中一共展示了LocalPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRegion
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
public ProtectedRegion getRegion(final Player player, final Location loc)
{
final com.sk89q.worldguard.LocalPlayer localplayer = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().wrapPlayer(player);
RegionManager manager = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionManager(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;
}
示例2: getRegionList
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
public List<ProtectedRegion> getRegionList(OfflinePlayer player, World world, LandTypes type) {
LocalPlayer lPlayer = CubitBukkitPlugin.inst().getWorldGuardPlugin().wrapOfflinePlayer(player);
RegionManager rm = CubitBukkitPlugin.inst().getWorldGuardPlugin().getRegionManager(world);
List<ProtectedRegion> toReturn = new ArrayList<>();
for (Map.Entry<String, ProtectedRegion> entry : rm.getRegions().entrySet()) {
if (entry.getValue().getOwners().contains(lPlayer)) {
RegionData regionData = new RegionData(world);
regionData.setWGRegion(entry.getValue());
if (regionData.getLandType() == type || type == LandTypes.NOTYPE) {
toReturn.add(entry.getValue());
}
}
}
return toReturn;
}
示例3: getRegion
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
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;
}
示例4: isAllowed
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
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;
}
示例5: isForbiddenSkillInRegion
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
public boolean isForbiddenSkillInRegion(Player player, SkillType skill) {
if (worldGuard != null) {
Location location = player.getLocation();
RegionManager regionManager = worldGuard.getRegionContainer().get(player.getWorld());
if (regionManager == null) {
return false;
}
ApplicableRegionSet regions = regionManager.getApplicableRegions(location);
LocalPlayer localPlayer = worldGuard.wrapPlayer(player);
return regions.queryAllValues(localPlayer, skillListFlag).contains(skill);
}
return false;
}
示例6: GetRegionNamesAtPoint
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
/**
* Get the regions at the players' location
*
* @param player The player you wish to get the ApplicableRegions from
* @returns A list of strings with the names of the applicable regions. This is null if there are no regions where the player is.
*
*/
public ArrayList<String> GetRegionNamesAtPoint(Player player) throws WorldGuardAPIException {
if (_wgPlugin == null) {
throw new WorldGuardAPIException(WorldGuardExceptions.NotEnabled);
}
//This "wrapping" is required for WorldGuard APIs
LocalPlayer lplayer = _wgPlugin.wrapPlayer(player);
//We require a WE vector rather than a location.
Vector pt = lplayer.getPosition();
//Get the region manager for the world we are currently in.
RegionManager rm = _wgPlugin.getRegionManager(player.getWorld());
//This is the set of regions we are in.
ApplicableRegionSet set = rm.getApplicableRegions(pt);
//Just return null if we get nothing.
if (set.size() == 0) {
return null;
}
//Put the region names in a list.
ArrayList<String> regions = new ArrayList<String>();
//For each Region in the set, just add the string with the region name to the return variable.
for (ProtectedRegion region : set) {
regions.add(region.getId());
}
//Return the list
return regions;
}
示例7: get
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
@Override
@Nullable
protected String[] get(Event e) {
WorldGuardPlugin wg = (WorldGuardPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
RegionManager regionManager = null;
if (wo != null) {
regionManager = wg.getRegionManager(wo.getSingle(e));
} else {
regionManager = wg.getRegionManager(Bukkit.getServer().getWorlds().get(0));
}
if (player.getSingle(e) == null) {
return new String[] {};
}
LocalPlayer wpl = null;
if (player.getSingle(e).isOnline()) {
wpl = wg.wrapPlayer(player.getSingle(e).getPlayer());
} else {
wpl = wg.wrapOfflinePlayer(player.getSingle(e));
}
ArrayList<String> pregions = new ArrayList<String>();
for (Entry<String, ProtectedRegion> reg : regionManager.getRegions().entrySet()) {
if (reg.getValue().isMember(wpl)) {
pregions.add(reg.getValue().getId());
}
}
return pregions.toArray(new String[pregions.size()]);
}
示例8: calculateLandCost
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
public double calculateLandCost(UUID uuid, World world, boolean buyTask) {
double landBasePrice = CubitBukkitPlugin.inst().getYamlManager().getSettings().landBasePrice;
double landTaxAddition = CubitBukkitPlugin.inst().getYamlManager().getSettings().landTaxAddition;
double landMaxPrice = CubitBukkitPlugin.inst().getYamlManager().getSettings().landMaxPrice;
double landSellPercent = CubitBukkitPlugin.inst().getYamlManager().getSettings().landSellPercent;
LocalPlayer localplayer = CubitBukkitPlugin.inst().getWorldGuardPlugin()
.wrapOfflinePlayer(Bukkit.getOfflinePlayer(uuid));
double regionSize = CubitBukkitPlugin.inst().getWorldGuardPlugin().getRegionManager(world)
.getRegionCountOfPlayer(localplayer);
double price;
if (buyTask) {
price = landBasePrice + (landTaxAddition * regionSize);
if (price > landMaxPrice) {
price = landMaxPrice;
}
} else {
double sellValue = landBasePrice + (landTaxAddition * regionSize);
if (sellValue > landMaxPrice) {
sellValue = landMaxPrice;
}
price = (sellValue * landSellPercent);
}
return price;
}
示例9: isAllowed
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
private boolean isAllowed(Player player, Location location, Action action) {
LocalPlayer localPlayer = worldGuard.wrapPlayer(player);
RegionContainer container = worldGuard.getRegionContainer();
RegionQuery query = container.createQuery();
Shop shop = plugin.getShopUtils().getShop(location);
if (action == Action.RIGHT_CLICK_BLOCK && shop != null) {
if (shop.getVendor().getUniqueId().equals(player.getUniqueId()) && shop.getShopType() != Shop.ShopType.ADMIN) {
return true;
}
if (!shop.getVendor().getUniqueId().equals(player.getUniqueId()) && player.isSneaking()) {
return player.hasPermission(Permissions.OPEN_OTHER);
}
}
if (ClickType.getPlayerClickType(player) != null) {
switch (ClickType.getPlayerClickType(player).getClickType()) {
case CREATE:
return query.testState(location, localPlayer, WorldGuardShopFlag.CREATE_SHOP);
case REMOVE:
case INFO:
return true;
}
} else {
if (shop != null) {
StateFlag flag = (shop.getShopType() == Shop.ShopType.NORMAL ? WorldGuardShopFlag.USE_SHOP : WorldGuardShopFlag.USE_ADMIN_SHOP);
return query.testState(location, localPlayer, flag);
}
}
return false;
}
示例10: isMember
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
/**
* returns true if the flag is set to allow or deny in a specific location presenting the region
*
* @author xize
* @param flag - the flag state which we will check
* @param loc - the location presenting the region
* @return boolean
*/
public boolean isMember(Player p, Location loc) {
try {
LocalPlayer lp = wg.wrapPlayer(p);
Object obj = wg.getRegionManager(loc.getWorld()).getClass().getMethod("getApplicableRegions", Location.class).invoke(wg.getRegionManager(loc.getWorld()), loc);
Method m1 = obj.getClass().getMethod("isMemberOfAll", LocalPlayer.class);
boolean bol = (p.isOp() ? true : (Boolean)m1.invoke(obj, lp));
return bol;
} catch(Exception e) {
e.printStackTrace();
}
return false;
}
示例11: onBlockBreak
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
@EventHandler (priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
if (event.isCancelled() || !Config.WORLDGUARD_ENABLED || !Config.WORLDGUARD_BREAK) return;
RegionManager rm = FramePicturePlugin.getWorldGuard().getRegionManager(player.getWorld());
LocalPlayer localPlayer = FramePicturePlugin.getWorldGuard().wrapPlayer(player);
BlockFace[] faces = { BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST };
if (!player.hasPermission("FramePicture.ignoreWorldGuard")) {
for (BlockFace face : faces) {
Location loc = block.getRelative(face).getLocation();
BlockFace frameFace = face.getOppositeFace();
Frame frame = this.manager.getFrame(loc, frameFace);
if (frame == null) continue;
if (!rm.getApplicableRegions(frame.getLocation()).canBuild(localPlayer)) {
player.sendMessage(Lang.PREFIX.getText() + Lang.NO_PERMISSION.getText());
event.setCancelled(true);
return;
}
}
}
}
示例12: onHangingBreak
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
@EventHandler (priority = EventPriority.HIGH)
public void onHangingBreak(HangingBreakEvent event) {
if (event.isCancelled() || (event.getEntity().getType() != EntityType.ITEM_FRAME)) return;
ItemFrame entity = (ItemFrame)event.getEntity();
Frame frame = this.manager.getFrame(entity);
if (frame == null) return;
Player player = null;
if (event instanceof HangingBreakByEntityEvent) {
Entity remover = ((HangingBreakByEntityEvent)event).getRemover();
if (remover.getType() == EntityType.PLAYER) {
player = (Player) remover;
}
}
if ((player != null) && Config.WORLDGUARD_ENABLED && Config.WORLDGUARD_BREAK && !player.hasPermission("FramePicture.ignoreWorldGuard"))
{
RegionManager rm = FramePicturePlugin.getWorldGuard().getRegionManager(player.getWorld());
LocalPlayer localPlayer = FramePicturePlugin.getWorldGuard().wrapPlayer(player);
if (!rm.getApplicableRegions(frame.getLocation()).canBuild(localPlayer)) {
player.sendMessage(Lang.PREFIX.getText() + Lang.NO_PERMISSION.getText());
event.setCancelled(true);
return;
}
}
this.manager.removeFrame(frame);
if (player != null)
player.sendMessage(Lang.PREFIX.getText() + Lang.FRAME_REMOVED.getText().replace("%id", String.valueOf(frame.getId())));
for (Entity e : entity.getNearbyEntities(32.0, 32.0, 32.0)) {
if (e.getType() != EntityType.PLAYER) continue;
Player p = (Player)e;
this.sendFrameDestroy(p, entity.getEntityId());
}
}
示例13: insideRegion
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
private boolean insideRegion(Player player, ProtectedRegion region){
LocalPlayer lp = RegionFX.getWorldGuard().wrapPlayer(player);
return region.contains(lp.getPosition());
}
示例14: isDenied
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
public boolean isDenied(LocalPlayer localplayer, ProtectedRegion region)
{
return region.getFlag(FlagUtils.WORLDEDIT) == State.DENY;
}
示例15: wrapPlayer
import com.sk89q.worldguard.LocalPlayer; //导入依赖的package包/类
public static LocalPlayer wrapPlayer(Player player)
{
return WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().wrapPlayer(player);
}