当前位置: 首页>>代码示例>>Java>>正文


Java WGBukkit类代码示例

本文整理汇总了Java中com.sk89q.worldguard.bukkit.WGBukkit的典型用法代码示例。如果您正苦于以下问题:Java WGBukkit类的具体用法?Java WGBukkit怎么用?Java WGBukkit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WGBukkit类属于com.sk89q.worldguard.bukkit包,在下文中一共展示了WGBukkit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
protected void execute(Event event) {
	String name = (String) this.name.getSingle(event);
	World world = (World) this.world.getSingle(event);

	RegionManager regionManager = WGBukkit.getRegionManager(world);
	if (!regionManager.hasRegion(name)) {
		Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
		return;
	}

	regionManager.removeRegion(name, RemovalStrategy.REMOVE_CHILDREN);
	try {
		regionManager.save();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:18,代码来源:EffDeleteRegion.java

示例2: onEnable

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
public void onEnable(){
    instance = this;
    files.setupFiles();

    registerEvents();
    registerCommands();
    pe.registerRecipe();

    RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
    if (economyProvider != null) {
        eco = economyProvider.getProvider();
    }

    Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
    if (plugin != null) {
        wg = WGBukkit.getPlugin();
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:19,代码来源:SafariNet.java

示例3: execute

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
protected void execute(Event event) {
	String name = (String) this.name.getSingle(event);
	World world = (World) this.world.getSingle(event);
	ItemStack block = (ItemStack) this.block.getSingle(event);

	RegionManager regionManager = WGBukkit.getRegionManager((org.bukkit.World) world);
	if (!regionManager.hasRegion(name)) {
		Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
		return;
	}

	Vector v1 = regionManager.getRegion(name).getMaximumPoint();
	Vector v2 = regionManager.getRegion(name).getMinimumPoint();
	Region region = new CuboidRegion(v1, v2);
	BaseBlock b = new BaseBlock(block.getTypeId(), block.getData().getData());

	EditSession es = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
	try {
		es.setBlocks(region, b);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:24,代码来源:EffSetBlocks.java

示例4: get

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
protected String[] get(Event event) {
	World world = (World) this.world.getSingle(event);
	if (world == null) {
		for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
			for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
				if (b.getKey().equals(region.getSingle(event))) {
					world = Bukkit.getWorld(a.getName());
					break;
				}

			}
		}
	}

	RegionManager rm = WGBukkit.getRegionManager(world);
	ProtectedRegion pregion = rm.getRegion(region.getSingle(event));
	List<String> list = new ArrayList<String>(pregion.getMembers().getPlayers());

	String[] s = new String[list.size()];
	return (String[]) list.toArray(s);
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:22,代码来源:ExprAllMembers.java

示例5: get

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
protected String[] get(Event event) {
	World world = (World) this.world.getSingle(event);
	if (world == null) {
		for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
			for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
				if (b.getKey().equals(region.getSingle(event))) {
					world = Bukkit.getWorld(a.getName());
					break;
				}

			}
		}
	}

	RegionManager rm = WGBukkit.getRegionManager(world);
	ProtectedRegion pregion = rm.getRegion(region.getSingle(event));
	List<String> rfl = new ArrayList<String>();

	for (Entry<Flag<?>, Object> ra : pregion.getFlags().entrySet()) {
		rfl.add(ra.getKey().getName());
	}

	String[] s = new String[rfl.size()];
	return (String[]) rfl.toArray(s);
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:26,代码来源:ExprAllFlagsOfRegion.java

示例6: get

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
protected Location[] get(Event event) {
	String name = (String) this.region.getSingle(event);
	World world = (World) this.world.getSingle(event);

	RegionManager regionManager = WGBukkit.getRegionManager(world);
	if (!regionManager.hasRegion(name)) {
		Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
		return null;
	}

	double x = regionManager.getRegion(name).getMaximumPoint().getX();
	double y = regionManager.getRegion(name).getMaximumPoint().getY();
	double z = regionManager.getRegion(name).getMaximumPoint().getZ();

	Location pos1 = new Location(world, x, y, z);

	return new Location[] { pos1 };
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:19,代码来源:ExprGetPoint2.java

示例7: get

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
protected String[] get(Event event) {
	World world = (World) this.world.getSingle(event);
	if (world == null) {
		for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
			for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
				if (b.getKey().equals(region.getSingle(event))) {
					world = Bukkit.getWorld(a.getName());
					break;
				}

			}
		}
	}

	RegionManager rm = WGBukkit.getRegionManager(world);
	ProtectedRegion pregion = rm.getRegion(region.getSingle(event));
	List<String> list = new ArrayList<String>(pregion.getOwners().getPlayers());

	String[] s = new String[list.size()];
	return (String[]) list.toArray(s);
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:22,代码来源:ExprAllOwners.java

示例8: execute

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
protected void execute(Event event) {
	String name = (String) this.name.getSingle(event);
	Location loc1 = (Location) this.loc1.getSingle(event);
	Location loc2 = (Location) this.loc2.getSingle(event);
	World world = (World) this.world.getSingle(event);

	int x1 = loc1.getBlockX();
	int y1 = loc1.getBlockY();
	int z1 = loc1.getBlockZ();

	int x2 = loc2.getBlockX();
	int y2 = loc2.getBlockY();
	int z2 = loc2.getBlockZ();

	Vector p1 = new Vector(x1, y1, z1);
	Vector p2 = new Vector(x2, y2, z2);
	RegionManager regionManager = WGBukkit.getRegionManager(world);
	ProtectedCuboidRegion region = new ProtectedCuboidRegion(name, p1.toBlockVector(), p2.toBlockVector());
	regionManager.addRegion(region);
	try {
		regionManager.save();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:26,代码来源:EffCreateRegion.java

示例9: get

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
protected Location[] get(Event event) {
	String name = (String) this.region.getSingle(event);
	World world = (World) this.world.getSingle(event);

	RegionManager regionManager = WGBukkit.getRegionManager(world);
	if (!regionManager.hasRegion(name)) {
		Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
		return null;
	}

	double x = regionManager.getRegion(name).getMinimumPoint().getX();
	double y = regionManager.getRegion(name).getMinimumPoint().getY();
	double z = regionManager.getRegion(name).getMinimumPoint().getZ();

	Location pos1 = new Location(world, x, y, z);

	return new Location[] { pos1 };
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:19,代码来源:ExprGetPoint1.java

示例10: setFlag

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
public static <T> void setFlag(ProtectedRegion region, Flag<T> flag, String value) throws CommandException, InvalidFlagFormat {
	CommandContext ccontext = new CommandContext("rg "+value, valueFlags);
	region.setFlag(flag, flag.parseInput(WGBukkit.getPlugin(), Bukkit.getConsoleSender(), ccontext.getRemainingString(0)));
	if (ccontext.hasFlag('g')) {
		String group = ccontext.getFlag('g');
		RegionGroupFlag groupFlag = flag.getRegionGroupFlag();
		if (groupFlag == null) {
			return;
		}
		RegionGroup groupValue = groupFlag.parseInput(WGBukkit.getPlugin(), Bukkit.getConsoleSender(), group);
		if (groupValue == groupFlag.getDefault()) {
			region.setFlag(groupFlag, null);
		} else {
			region.setFlag(groupFlag, groupValue);
		}
	}
}
 
开发者ID:Shevchik,项目名称:WGBuyFlags,代码行数:18,代码来源:Utils.java

示例11: isInventoryAccessible

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
/**
 * Check if the given player has access rights for the given block.
 *
 * @param player player to check
 * @param block block to check
 * @return true if the player may access the block's contents
 */
public boolean isInventoryAccessible(Player player, Block block) {
    switch (invProtectionType) {
        case LWC:
            LWC lwc = SensibleToolboxPlugin.getInstance().getLWC();
            Protection prot = lwc.findProtection(block);
            if (prot != null) {
                boolean ok = lwc.canAccessProtection(player, prot);
                Debugger.getInstance().debug(2, "LWC check: can " + player.getName() + " access " + block + "? " + ok);
                return ok;
            } else {
                return true;
            }
        case WORLDGUARD:
            ApplicableRegionSet set = WGBukkit.getRegionManager(block.getWorld()).getApplicableRegions(block.getLocation());
            return set.allows(DefaultFlag.CHEST_ACCESS, WGBukkit.getPlugin().wrapPlayer(player));
        case BEST:
            throw new IllegalArgumentException("should never get here!");
        default:
            return true;
    }
}
 
开发者ID:desht,项目名称:sensibletoolbox,代码行数:29,代码来源:BlockProtection.java

示例12: playerCanBuild

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
/**
 * Check if the given player UUID has construction rights for the given
 * block.
 *
 * @param player the player
 * @param block the block to check for
 * @return true if the player has construction rights; false otherwise
 */
public boolean playerCanBuild(Player player, Block block, Operation op) {
    switch (blockProtectionType) {
        case WORLDGUARD:
            return WGBukkit.getPlugin().canBuild(player, block);
        case PRECIOUS_STONES:
            switch (op) {
                case PLACE:
                    return PreciousStones.API().canPlace(player, block.getLocation());
                case BREAK:
                    return PreciousStones.API().canBreak(player, block.getLocation());
                default:
                    return false;
            }
        case BEST:
            throw new IllegalArgumentException("should never get here!");
        default:
            return true;
    }
}
 
开发者ID:desht,项目名称:sensibletoolbox,代码行数:28,代码来源:BlockProtection.java

示例13: onSpawn

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSpawn(PlayerInteractEvent e){
    Player p = e.getPlayer();

    if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if(e.getHand() != EquipmentSlot.HAND) return;
        if (e.getItem() == null || !e.getItem().hasItemMeta() || !e.getItem().getItemMeta().hasDisplayName() || e.getItem().getType() != Material.MONSTER_EGG) return;
        if (!ChatColor.stripColor(e.getItem().getItemMeta().getDisplayName()).contains("Spawn")) return;
        if (!files.getConfig().getStringList("mundosPermitidos").contains(p.getLocation().getWorld().getName())) {
            p.sendMessage(this.plugin.getPrefix() + ChatColor.RED + "No se puede usar en este mundo");
            return;
        }
        int id = Integer.parseInt(e.getItem().getItemMeta().getLore().get(0));
        String s = e.getItem().getItemMeta().getLore().get(1);

        RegionManager m = WGBukkit.getPlugin().getRegionManager(p.getWorld());
        if (m != null) {
            m.getApplicableRegions(p.getLocation()).getRegions().forEach(re ->{
                if (re != null && re.getOwners().contains(p.getUniqueId())) {
                    return;
                }
            });
        }

        SNMob mob = new SNMob(p);
        if (!mob.isOwner(id)) {
           p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No eres el dueño de este huevo");
            return;
        }
        mob.spawnMob(id, s);
        p.getInventory().getItemInMainHand().setAmount(-1);
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:34,代码来源:SpawnMob.java

示例14: validatePlayer

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
public boolean validatePlayer(Player player)
{
    if (player == null) return false;
    if (!player.isOnline()) return false;
    if (player.getGameMode() == GameMode.CREATIVE && Thirst.getInstance().getYAMLConfig().ignoreCreative) return false;
    if (player.isOp() && Thirst.getInstance().getYAMLConfig().ignoreOP)  return false;
    if (player.hasPermission("thirst.ignore") || player.hasPermission("thirst.*"))  return false;

    String world = player.getWorld().getName();
    List<String> worlds = Arrays.asList(Thirst.getInstance().getYAMLConfig().disabledWorlds);
    if ( worlds.size() > 0)
    {
        if (worlds.contains(world)) return false;
    }

    if (Thirst.getInstance().isWorldGuardEnabled())
    {
        for(ProtectedRegion region : WGBukkit.getRegionManager(player.getWorld()).getApplicableRegions(player.getLocation()))
        {
            if (region == null) continue;
            ArrayList<String> regions = new ArrayList<>(Arrays.asList(Thirst.getInstance().getYAMLConfig().disabledRegions));

            if (regions.contains(region.getId())) return false;
        }
    }
    return true;
}
 
开发者ID:GamerKing195,项目名称:Thirst,代码行数:28,代码来源:ThirstManager.java

示例15: regionAt

import com.sk89q.worldguard.bukkit.WGBukkit; //导入依赖的package包/类
public Boolean regionAt(Chunk chunk) {
	String regionName = this.randomRegionName();
	
	int x1 = chunk.getX() << 4,
		z1 = chunk.getZ() << 4,
		y1 = 0;
	
	int x2 = x1 + 15,
		z2 = z1 + 15,
		y2 = chunk.getWorld().getMaxHeight();
	
	BlockVector point1 = new BlockVector(x1, y1, z1);
	BlockVector point2 = new BlockVector(x2, y2, z2);
	
	ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion(regionName, point1, point2);
	
	// Check over the regions, and ensure that none are in the configuration to ignore
	
	ApplicableRegionSet regions = WGBukkit.getRegionManager(chunk.getWorld()).getApplicableRegions(chunkRegion);
	for (ProtectedRegion region : regions) {
		if (Config.get().worldGuardIgnoreRegions.contains(region.getId())) continue;
		return true;
	}
	
	return false;
	
}
 
开发者ID:redstone,项目名称:FreshWilderness,代码行数:28,代码来源:WorldGuardEngine.java


注:本文中的com.sk89q.worldguard.bukkit.WGBukkit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。