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


Java WorldGuardPlugin类代码示例

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


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

示例1: SingleRoom

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
/**
 * Creates a room with specified region and sign location.
 *
 * @param region
 *            name of the WorldGuard region
 * @param signLoc
 *            location of the room sign
 * @throws Exception
 */
public SingleRoom(RoomRent plugin, World world, String regionName, String signLoc) throws RoomException {
	this.world = world;
	this.plugin = plugin;
	region = WorldGuardPlugin.inst().getRegionManager(world).getRegion(regionName);
	if (region == null) {
		throw new RoomException("Region with given name does not exist!");
	}
	sign = getBlock(signLoc, world);
	FileConfiguration config = plugin.getDB().getConfig();
	String rawRenter = config.getString(world.getName() + "." + regionName + ".player");
	renter = (rawRenter == null) ? null : Bukkit.getOfflinePlayer(UUID.fromString(rawRenter));
	String rawTime = config.getString(world.getName() + "." + regionName + ".time");
	time = (rawTime == null) ? -1 : Long.parseLong(rawTime);
	schematicFile = new File(plugin.getDataFolder(), sign.getWorld().getName() + File.separator + regionName);
	if (schematicFile.exists()) {
		schematic = SchematicFormat.getFormat(schematicFile);
	}
}
 
开发者ID:Co0sh,项目名称:RoomRent,代码行数:28,代码来源:SingleRoom.java

示例2: addRegion

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
/**
 * Criar uma nova região no WorldGuard
 *
 * @param name O nome da nova região
 * @param center O lugar central dela (para ser baseado o tamanho)
 * @param larg Um número inteiro para representar a largura
 * @param comp Um número inteiro para representar o comprimento
 * @param priority A prioridade da região
 * @return Retorna a região que foi criada se for criada com sucesso. Se já houver uma região com esse nome OU houver uma falha, retorna null.
 */
@Nullable
public static ProtectedRegion addRegion ( final String name, final Location center, final int larg, final int comp, final int priority )
{
	Preconditions.checkArgument( center.getWorld().getName().equalsIgnoreCase( center.getWorld().getName() ), "Worlds not same!" );
	Location prim = new Location( center.getWorld(), center.getBlockX() + larg, center.getBlockY(), center.getBlockZ() );
	Location sec = new Location( center.getWorld(), center.getBlockX() - comp, center.getBlockY(), center.getBlockZ() - comp );
	prim = Framework.getMinimumPoint( prim, sec );
	sec = Framework.getMaximumPoint( prim, sec );
	final WorldGuardPlugin plugin = ( WorldGuardPlugin ) Framework.worldguard;
	final RegionManager rm = plugin.getRegionManager( center.getWorld() );
	if ( rm.hasRegion( name ) )
	{
		return null;
	}
	else
	{
		final ProtectedCuboidRegion cuboid = new ProtectedCuboidRegion( name, Framework.getWorldEditVector( prim ), Framework.getWorldEditVector( sec ) );
		cuboid.setPriority( priority );
		rm.addRegion( cuboid );
		return cuboid;
	}
}
 
开发者ID:ProjectSandstone,项目名称:EventoZero,代码行数:33,代码来源:Framework.java

示例3: getPrioritizedRegion

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
/**
 * Método que obtém a região com maior prioridade em um certo local
 *
 * @param around Local onde existe as regiões
 * @return Retorna a região com maior prioridade
 */
public static ProtectedRegion getPrioritizedRegion ( final Location around )
{
	final WorldGuardPlugin plugin = ( WorldGuardPlugin ) Framework.worldguard;
	final ApplicableRegionSet set = plugin.getRegionManager( around.getWorld() ).getApplicableRegions( around );
	ProtectedRegion prime = null;
	for ( final ProtectedRegion region : set )
	{
		if ( ( prime != null ) && ( region.getPriority() > prime.getPriority() ) )
		{
			prime = region;
		}
		else
		{
			prime = region;
		}
	}

	return prime;
}
 
开发者ID:ProjectSandstone,项目名称:EventoZero,代码行数:26,代码来源:Framework.java

示例4: protectIsland

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
public static boolean protectIsland(uSkyBlock plugin, CommandSender sender, IslandInfo islandConfig) {
    try {
        WorldGuardPlugin worldGuard = getWorldGuard();
        RegionManager regionManager = worldGuard.getRegionManager(plugin.getWorld());
        String regionName = islandConfig.getName() + "island";
        if (islandConfig != null && noOrOldRegion(regionManager, regionName, islandConfig)) {
            updateRegion(islandConfig);
            islandConfig.setRegionVersion(getVersion());
            return true;
        }
    } catch (Exception ex) {
        String name = islandConfig != null ? islandConfig.getLeader() : "Unknown";
        LogUtil.log(Level.SEVERE, "ERROR: Failed to protect " + name + "'s Island (" + sender.getName() + ")", ex);
    }
    return false;
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:17,代码来源:WorldGuardHandler.java

示例5: setVersionSpecificFlags

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
private static void setVersionSpecificFlags(ProtectedCuboidRegion region) {
    WorldGuardPlugin worldGuard = getWorldGuard();
    if (worldGuard != null && worldGuard.isEnabled() && worldGuard.getDescription() != null) {
        VersionUtil.Version wgVersion = VersionUtil.getVersion(worldGuard.getDescription().getVersion());
        if (wgVersion.isGTE("6.0")) {
            // Default values sort of bring us there... niiiiice
        } else {
            // 5.9 or below
            region.setFlag(DefaultFlag.ENTITY_ITEM_FRAME_DESTROY, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.ENTITY_PAINTING_DESTROY, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.CHEST_ACCESS, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.USE, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.DESTROY_VEHICLE, StateFlag.State.DENY);
        }
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:17,代码来源:WorldGuardHandler.java

示例6: getNetherRegionAt

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
public static ProtectedRegion getNetherRegionAt(Location location) {
    if (!Settings.nether_enabled || location == null) {
        return null;
    }
    WorldGuardPlugin worldGuard = getWorldGuard();
    RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
    if (regionManager == null) {
        return null;
    }
    Iterable<ProtectedRegion> applicableRegions = regionManager.getApplicableRegions(location);
    for (ProtectedRegion region : applicableRegions) {
        String id = region.getId().toLowerCase();
        if (!id.equalsIgnoreCase("__global__") && id.endsWith("nether")) {
            return region;
        }
    }
    return null;
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:19,代码来源:WorldGuardHandler.java

示例7: SprawdzCzyWterenie

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
public static boolean  SprawdzCzyWterenie(Location loc,String nazwaAreny)
 {
  WorldGuardPlugin wg = getWorldGuard();
  Vector pt = toVector(loc); // This also takes a location
  RegionManager regionManager = wg.getRegionManager(loc.getWorld());
  ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
  for (ProtectedRegion region : set) {
		   if(region.getId().equalsIgnoreCase(nazwaAreny)){
			  // System.out.println("Jestes w tym regionie"); 
			   //p.sendMessage("Jestes w tym regionie");
			   return true;
		   }
	}
 
return false;

 }
 
开发者ID:grzegorz2047,项目名称:AceOfSpadesMiniGame,代码行数:18,代码来源:CheckArea.java

示例8: exec

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
@Override
public Construct exec(Target t, Environment env, Construct... args) throws CancelCommandException, ConfigRuntimeException {
	Static.checkPlugin("WorldGuard", t);
	World world;

	world = Bukkit.getServer().getWorld(args[1].val());

	RegionManager mgr = WorldGuardPlugin.inst().getRegionManager(world);

	ProtectedRegion region = mgr.getRegion(args[0].val());

	if (region == null) {
		throw new CREPluginInternalException(String.format("The region (%s) does not exist in world (%s).", args[0].val(), args[1].val()), t);
	}

	return new CInt(region.volume(), t);
}
 
开发者ID:jb-aero,项目名称:SKCompat,代码行数:18,代码来源:CHWorldGuard.java

示例9: run

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
@Override
public void run() {
	if(wg == null){
		wg = WorldGuardPlugin.inst();
	}
	if(rm == null ){
		rm = wg.getRegionManager(Bukkit.getWorld(Bukkit.getServerName()));
	}
	System.out.println("Updating scores.");
	final Collection<? extends Player> players = Bukkit.getOnlinePlayers();
	for(Player p : players){
		if(p != null){
			ApplicableRegionSet set = rm.getApplicableRegions(p.getLocation());
			for(ProtectedRegion r : set){
				if(r.getId().equalsIgnoreCase("OriginStation")){
					p.sendMessage("Your score was not updated because you are in the spawn no-pvp zone.");
					continue;
				}
			}
			SQLDatabase.addScore(p.getUniqueId(), 1);
		}
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:24,代码来源:ScoreUpdateTask.java

示例10: onBlockBreak

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
@EventHandler 
public void onBlockBreak(BlockBreakEvent event) {
	if (event.isCancelled())
		return;
	WorldGuardPlugin wg = plugin.getWorldGuard();
	boolean canBuild;
	if (wg == null) {
		canBuild = true;
	} else {
		canBuild = wg.canBuild(event.getPlayer(), event.getBlock());
	}
	if (bl.isLogged(event.getBlock()) && canBuild) {
		if (!res(event.getPlayer())) {
			msg(event.getPlayer(), "A creative mode player placed this block.");
		}
		event.setCancelled(true);
		event.getBlock().setType(Material.AIR);
		bl.remove(event.getBlock());
	}
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:21,代码来源:DemiGodPackage.java

示例11: findById

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
@Override
public Region findById(String id) {
    Region r = super.findById(id);
    if (r == null) {
        String[] split = id.split(";");
        if (split.length != 2) {
            return null;
        }
        World world = Bukkit.getWorld(split[0]);
        if (world == null) {
            return null;
        }
        ProtectedRegion region = WorldGuardPlugin.inst().getRegionManager(world).getRegion(split[1]);
        if (region == null) {
            return null;
        }
        r = create(world, region);
    }
    return r;
}
 
开发者ID:macalinao,项目名称:cloudgame,代码行数:21,代码来源:Regions.java

示例12: initModule

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
/**
 * initModule enables the module called by {@link TerraCraftTools}
 */
public void initModule(TerraCraftTools sst) {
    plugin = sst;
    // Do we have worldguard?
    if (!(plugin.getServer().getPluginManager().getPlugin("WorldGuard") instanceof WorldGuardPlugin)) {
        plugin.logger
                .info("[TerraCraftTools][Plots] No WorldGuard found! Exiting via exception...");
        throw new RuntimeException();
    }
    wg = (WorldGuardPlugin) plugin.getServer().getPluginManager()
            .getPlugin("WorldGuard");
    plugin.commandRegistrar.registerCommand("plot", this);
    plotPrefixes = plugin.getModuleConfig("Plots")
            .getStringList("Prefixes");
    manualSelections = new HashMap<Player, Location>();
    plugin.logger.info(plugin.getLoggerTag() + moduleLoggerTag + "Plots Module enabled!");
}
 
开发者ID:CoderMonkeys,项目名称:TerraCraftTools,代码行数:20,代码来源:Plots.java

示例13: initDependencies

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
private void initDependencies() {
    PluginManager pm = getServer().getPluginManager();
    heroes = (Heroes) pm.getPlugin("Heroes");

    Plugin townyPlugin = pm.getPlugin("Towny");
    if (townyPlugin != null && townyPlugin instanceof Towny) {
        towny = new TownyFacade((Towny) townyPlugin);
        usingTowny = true;
        Messaging.log("Linked with Towny");
    }

    Plugin worldGuardPlugin = pm.getPlugin("WorldGuard");
    if (worldGuardPlugin != null && worldGuardPlugin instanceof WorldGuardPlugin) {
        worldGuard = new WorldGuardFacade((WorldGuardPlugin) worldGuardPlugin);
        usingWorldGuard = true;
        Messaging.log("Linked with WorldGuard");
    }
}
 
开发者ID:galaran,项目名称:PvpRealm,代码行数:19,代码来源:PvpRealm.java

示例14: checkWG

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
/**
    * This method checks to see if WorldGuard is loaded.
    * 
    * @param host  Reference to the currently running plugin (the class that extends JavaPlugin)
    * @returns <b>true</b> if Worldguard is available, <b>false</b> otherwise.
    */
public static boolean checkWG(Plugin host) {
     //Is there a plugin with the name WorldGuard?
    Plugin plugin = host.getServer().getPluginManager().getPlugin("WorldGuard");
 
    //If we have found a plugin by the name of "WorldGuard", check if it is actually
       //WorldGuard. If not, or if we didn't find it, then it's not loaded in.
    if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
           _isAvailable = false;
        return false; //Nope, it's not loaded.
    }
       
       //Tell this class where the plugin is.
       wgPlugin = (WorldGuardPlugin) plugin;
       
       //Set the _isAvailable flag to false
       _isAvailable = true;
    return true;
}
 
开发者ID:Tribalforge,项目名称:AntiPotionField,代码行数:25,代码来源:WorldGuardInit.java

示例15: sendVanishQuitMessage

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入依赖的package包/类
public static void sendVanishQuitMessage(Player p) {
	if(!vanishApi.isVanished(p)) {
		if(Bukkit.getPluginManager().isPluginEnabled("WorldGuard")) {
			WorldGuardPlugin wg = (WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard");
			for(ProtectedRegion region : wg.getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation())) {
				if(region.getFlag(DefaultFlag.MOB_SPAWNING) == State.DENY) {
					Bukkit.broadcastMessage(ChatColor.RED + "Whoosh!" + ChatColor.GRAY + " staff member " + ChatColor.GREEN + p.getName() + ChatColor.GRAY + " has left the game safely!");
					vanishApi.vanish(p);
					return;
				}
			}
			Bukkit.broadcastMessage(ChatColor.RED + "Whoosh!" + ChatColor.GRAY + " staff member " + ChatColor.GREEN + p.getName() + ChatColor.GRAY + " has left the game in wild!");
			vanishApi.vanish(p);
		}
	} else {
		p.sendMessage(ChatColor.RED + "you are allready vanished so you can't fake quit, use /vanish fakejoin instead or /vanish");
	}
}
 
开发者ID:xize,项目名称:xEssentials_old_Source,代码行数:19,代码来源:worldguard.java


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