• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DefaultDomain类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addMembers

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
/**
 * Adds a list of members to a region.
 *
 * @param world World were the region is.
 * @param regionName The ID of the region.
 * @param playerNames Players to be added.
 * @return true on succes, false on failure.
 */
public boolean addMembers(World world, String regionName, String[] playerNames) {
    RegionManager rm = wgp.getRegionManager(world);
    if (rm == null) {
        return false;
    }
    ProtectedRegion region = rm.getRegion(regionName);
    if (region == null) {
        return false;
    }
    DefaultDomain members = region.getMembers();
    for (String playerName : playerNames) {
        members.addPlayer(playerName);
    }
    region.setMembers(members);
    try {
        rm.save();
    } catch (ProtectionDatabaseException ex) {
        plugin.getLogger().log(Level.SEVERE, "Unexpected failure saving WorldGuard configuration: {0}", ex.toString());
        return false;
    }
    return true;
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:31,代码来源:WorldGuardManager.java


示例2: removeMembers

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
/**
 * Removes a list of members from a region.
 *
 * @param world World were the region is.
 * @param regionName The ID of the region.
 * @param playerNames Players to be added.
 * @return true on succes, false on failure.
 */
public boolean removeMembers(World world, String regionName, String[] playerNames) {
    RegionManager rm = wgp.getRegionManager(world);
    if (rm == null) {
        return false;
    }
    ProtectedRegion region = rm.getRegion(regionName);
    if (region == null) {
        return false;
    }
    DefaultDomain members = region.getMembers();
    for (String playerName : playerNames) {
        members.removePlayer(playerName);
    }
    region.setMembers(members);
    try {
        rm.save();
    } catch (ProtectionDatabaseException ex) {
        plugin.getLogger().log(Level.SEVERE, "Unexpected failure saving WorldGuard configuration: {0}", ex.toString());
        return false;
    }
    return true;
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:31,代码来源:WorldGuardManager.java


示例3: getPBregion

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
/**
 * returns a calculated ProtectedCuboidRegion from given params.
 *
 * @param loc Location of the protection block
 * @param length The lenght of the region
 * @param height The height of the region
 * @param width The width of the reguion
 * @param playerName The Owner of the region.
 * @return ProtectedCuboidRegion
 */
public ProtectedCuboidRegion getPBregion(Location loc, int length, int height, int width, String playerName) {

    BlockVector min = new BlockVector(loc.getBlockX() - ((length - 1) / 2),
            0,
            loc.getBlockZ() - ((width - 1) / 2));
    BlockVector max = new BlockVector(loc.getBlockX() + ((length - 1) / 2),
            255,
            loc.getBlockZ() + ((width - 1) / 2));

    if (height != 0) {
        min = min.setY(loc.getBlockY() - ((height - 1) / 2)).toBlockVector();
        max = max.setY(loc.getBlockY() + ((height - 1) / 2)).toBlockVector();
    }

    ProtectedCuboidRegion region = new ProtectedCuboidRegion("ps"
            + loc.getBlockX() + "x"
            + loc.getBlockY() + "y"
            + loc.getBlockZ() + "z", min, max);

    DefaultDomain dd = new DefaultDomain();
    dd.addPlayer(playerName);
    region.setOwners(dd);
    return region;
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:35,代码来源:WorldGuardManager.java


示例4: decode

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public DefaultDomain decode(BsonReader reader, DecoderContext decoderContext) {
    DefaultDomain domain = new DefaultDomain();

    reader.readStartDocument();
    while (reader.readBsonType() != BsonType.END_OF_DOCUMENT) {
        String name = reader.readName();
        if ("players".equals(name)) {
            reader.readStartArray();
            while (reader.readBsonType() != BsonType.END_OF_DOCUMENT)
                domain.addPlayer(UUID.fromString(reader.readString()));
            reader.readEndArray();
        } else if ("groups".equals(name)) {
            reader.readStartArray();
            while (reader.readBsonType() != BsonType.END_OF_DOCUMENT)
                domain.addGroup(reader.readString());
            reader.readEndArray();
        } else {
            reader.skipValue();
        }
    }
    reader.readEndDocument();

    return domain;
}
 
开发者ID:maxikg,项目名称:mongowg,代码行数:29,代码来源:DefaultDomainCodec.java


示例5: encode

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void encode(BsonWriter writer, DefaultDomain value, EncoderContext encoderContext) {
    writer.writeStartDocument();
    writer.writeName("players");
    writer.writeStartArray();
    for (UUID uuid : value.getUniqueIds())
        writer.writeString(uuid.toString());
    writer.writeEndArray();
    writer.writeName("groups");
    writer.writeStartArray();
    for (String group : value.getGroups())
        writer.writeString(group);
    writer.writeEndArray();
    writer.writeEndDocument();
}
 
开发者ID:maxikg,项目名称:mongowg,代码行数:19,代码来源:DefaultDomainCodec.java


示例6: testCodec

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
@Test
public void testCodec() throws IOException {
    Codec<DefaultDomain> codec = DefaultDomainCodec.INSTANCE;
    DefaultDomain domain = new DefaultDomain();
    domain.addPlayer(UUID.randomUUID());
    domain.addGroup("test_group");

    DefaultDomain other;
    try (StringWriter sw = new StringWriter()) {
        codec.encode(new JsonWriter(sw), domain, EncoderContext.builder().build());
        other = codec.decode(new JsonReader(sw.toString()), DecoderContext.builder().build());
    }

    Assert.assertEquals(domain.getPlayers(), other.getPlayers());
    Assert.assertEquals(domain.getUniqueIds(), other.getUniqueIds());
    Assert.assertEquals(domain.getGroups(), other.getGroups());
}
 
开发者ID:maxikg,项目名称:mongowg,代码行数:18,代码来源:DefaultDomainCodecTest.java


示例7: buildDomain

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
/**
 * Build a DefaultDomain from a RegionAccessSet.
 * @param regionAccessSet RegionAccessSet to read
 * @return DefaultDomain containing the entities from the RegionAccessSet
 */
private DefaultDomain buildDomain(RegionAccessSet regionAccessSet) {
	DefaultDomain owners = new DefaultDomain();

	for(String playerName : regionAccessSet.getPlayerNames()) {
		owners.addPlayer(playerName);
	}

	// Add by name since UUIDs were not yet supported
	for(UUID uuid : regionAccessSet.getPlayerUniqueIds()) {
		OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
		if(offlinePlayer != null && offlinePlayer.getName() != null) {
			owners.addPlayer(offlinePlayer.getName());
		}
	}

	for(String group : regionAccessSet.getGroupNames()) {
		owners.addGroup(group);
	}

	return owners;
}
 
开发者ID:NLthijs48,项目名称:AreaShop,代码行数:27,代码来源:WorldGuardHandler5.java


示例8: buildDomain

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
/**
 * Build a DefaultDomain from a RegionAccessSet.
 * @param regionAccessSet RegionAccessSet to read
 * @return DefaultDomain containing the entities from the RegionAccessSet
 */
private DefaultDomain buildDomain(RegionAccessSet regionAccessSet) {
	DefaultDomain owners = new DefaultDomain();

	for(String playerName : regionAccessSet.getPlayerNames()) {
		owners.addPlayer(playerName);
	}

	for(UUID uuid : regionAccessSet.getPlayerUniqueIds()) {
		owners.addPlayer(uuid);
	}

	for(String group : regionAccessSet.getGroupNames()) {
		owners.addGroup(group);
	}

	return owners;
}
 
开发者ID:NLthijs48,项目名称:AreaShop,代码行数:23,代码来源:WorldGuardHandler6.java


示例9: process

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
private void process(ProtectedRegion r){
	DefaultDomain owners = r.getOwners();
	boolean found = false;
	for (String s : owners.getPlayers()) {
		User u = e.getOfflineUser(s);
		if(u != null){
			long time = System.currentTimeMillis() - u.getLastLogout();
			System.out.println("Milliseconds since last played: " + time);
			if (time < WorldRestore.month) {
				System.out.println("Found an owner played within last month.");
				found = true;
				break;
			}
		}
	}
	if(!found){
		rm.removeRegion(r.getId());
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:20,代码来源:OldWGRemover.java


示例10: addMemberPlayer

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
public void addMemberPlayer(final ProtectedRegion pr, final String playerName) {
    Bukkit.getScheduler().runTask(plugin, new Runnable() {
        @Override
        public void run() {
            DefaultDomain dd = pr.getMembers();
            dd.addPlayer(playerName);
        }
    });
}
 
开发者ID:ddonofrio,项目名称:LibelulaProtectionBlocks,代码行数:10,代码来源:WorldGuardManager.java


示例11: delMemberPlayer

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
public boolean delMemberPlayer(ProtectedRegion pr, String playerName) {
    boolean result = true;
    DefaultDomain dd = pr.getMembers();
    if (dd.contains(playerName)) {
        dd.removePlayer(playerName);
    } else {
        result = false;
    }
    return result;
}
 
开发者ID:ddonofrio,项目名称:LibelulaProtectionBlocks,代码行数:11,代码来源:WorldGuardManager.java


示例12: vaultCreated

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
@EventHandler
public void vaultCreated(PlayerVaultCreationEvent event) {
    // some listener already claimed this event
    if (event.isValid()) return;

    if (event.getType().equals("region")) {
        Player player = event.getCause().getPlayer();
        if (!createvault_worldguard.allowed(player)) {
            player.sendMessage(LANG.plugin_faction_noVaultPerm);
            return;
        }

        String regionId = event.getCause().getLine(2);
        String[] regionComponents = regionId.split("-",1);

        WorldGuardAccountHolder owner;
        if (regionComponents.length == 1) {
            // try to guess the world
            owner = getAccountHolder(regionComponents[0]);
        } else {
            String world = regionComponents[0];
            String id = regionComponents[1];
            owner = getAccountHolder(world, id);
        }

        if (owner != null && (owner.region.hasMembersOrOwners() || createvault_admin.allowed(player))) {
            DefaultDomain regionOwners = owner.region.getOwners();
            if (regionOwners.contains(player.getName())) {
                event.setOwner(owner);
                event.setValid(true);
            }
        }
    }
}
 
开发者ID:sakunc,项目名称:Gringotts-,代码行数:35,代码来源:WorldGuardHandler.java


示例13: removeOwners

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
public static void removeOwners(DefaultDomain dd, ProtectedRegion r){
	DefaultDomain owners = r.getOwners();
	owners.removeAll(dd);
	r.setOwners(owners);
}
 
开发者ID:gvlfm78,项目名称:BukkitHotels,代码行数:6,代码来源:HTWorldGuardManager.java


示例14: removeMembers

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
public static void removeMembers(List<UUID> ids, ProtectedRegion r){
	DefaultDomain members = r.getMembers();
	DefaultDomain toRemove = new DefaultDomain();
	ids.forEach(toRemove::addPlayer);
	members.removeAll(toRemove);
	r.setMembers(members);
}
 
开发者ID:gvlfm78,项目名称:BukkitHotels,代码行数:8,代码来源:HTWorldGuardManager.java


示例15: setOwners

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
@Override
public void setOwners(ProtectedRegion region, RegionAccessSet regionAccessSet) {
	DefaultDomain defaultDomain = buildDomain(regionAccessSet);
	if(!region.getOwners().toUserFriendlyString().equals(defaultDomain.toUserFriendlyString())) {
		region.setOwners(defaultDomain);
	}
}
 
开发者ID:NLthijs48,项目名称:AreaShop,代码行数:8,代码来源:WorldGuardHandler5.java


示例16: setMembers

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
@Override
public void setMembers(ProtectedRegion region, RegionAccessSet regionAccessSet) {
	DefaultDomain defaultDomain = buildDomain(regionAccessSet);
	if(!region.getMembers().toUserFriendlyString().equals(defaultDomain.toUserFriendlyString())) {
		region.setMembers(defaultDomain);
	}
}
 
开发者ID:NLthijs48,项目名称:AreaShop,代码行数:8,代码来源:WorldGuardHandler5.java


示例17: process

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
@Override
public void process(World from, World to) {
	if(rm == null){
		rm = ((WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard")).getRegionManager(to);
	}
	System.out.println("Preprocessing: WG Region " + r.getId());
	if (r.getId().equalsIgnoreCase("__global__")) {
		System.out.println("Global region, returning!");
		return;
	}
	DefaultDomain owners = r.getOwners();
	boolean found = false;
	for (String s : owners.getPlayers()) {
		User u = e.getOfflineUser(s);
		if(u != null){
			long time = System.currentTimeMillis() - u.getLastLogout();
			System.out.println("Milliseconds since last played: " + time);
			if (time < WorldRestore.month) {
				System.out.println("Found an owner played within last month.");
				found = true;
				break;
			}
		}
	}
	if (found) {
		BlockVector min = r.getMinimumPoint();
		BlockVector max = r.getMaximumPoint();

		System.out.println("min: " + min + "max: " + max);
		for (double x = min.getX(); x <= max.getX(); x++) {
			for (double y = min.getY(); y <= max.getY(); y++) {
				for (double z = min.getZ(); z <= max.getZ(); z++) {
					Block b = from.getBlockAt((int) x, (int) y, (int) z);
					WorldRestore.addToProcessQueues(b);
				}
			}
		}
		
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:41,代码来源:WGPreprocessTask.java


示例18: init

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
@Override
protected boolean init() {
	supportsUUIDs = Skript.methodExists(DefaultDomain.class, "getUniqueIds");
	return super.init();
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:6,代码来源:WorldGuardHook.java


示例19: execute

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
protected void execute(Event event) {
	String name = (String) this.name.getSingle(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(name)) {
					world = Bukkit.getWorld(a.getName());
					break;
				}

			}
		}

	}

	RegionManager regionManager = WGBukkit.getRegionManager(world);
	if (!regionManager.hasRegion(name)) {
		Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
		return;
	}
	DefaultDomain members = regionManager.getRegion(name).getMembers();
	Object[] arrayOfObject;
	int j = (arrayOfObject = this.players.getArray(event)).length;
	for (int i = 0; i < j; i++) {

		Object o = arrayOfObject[i];
		if ((o instanceof Player)) {

			if (mark == -1) {
				members.addPlayer(((Player) o).getName());
			} else if (mark == 1) {
				members.addPlayer(((Player) o).getUniqueId());
			} else if (mark == 0) {
				members.addPlayer(((Player) o).getName());
			}

		} else if ((o instanceof OfflinePlayer)) {
			if (mark == -1) {
				members.addPlayer(((OfflinePlayer) o).getName());
			} else if (mark == 1) {
				members.addPlayer(((OfflinePlayer) o).getUniqueId());
			} else if (mark == 0) {
				members.addPlayer(((OfflinePlayer) o).getName());
			}

		} else {
			members.addPlayer(o.toString());
		}
	}

	regionManager.getRegion(name).setMembers(members);
	try {
		regionManager.save();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:59,代码来源:EffAddMember.java


示例20: execute

import com.sk89q.worldguard.domains.DefaultDomain; //导入依赖的package包/类
protected void execute(Event event) {
	String name = (String) this.name.getSingle(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(name)) {
					world = Bukkit.getWorld(a.getName());
					break;
				}

			}
		}

	}

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

	DefaultDomain owners = regionManager.getRegion(name).getOwners();
	Object[] arrayOfObject;
	int j = (arrayOfObject = this.players.getArray(event)).length;
	for (int i = 0; i < j; i++) {
		Object o = arrayOfObject[i];
		if ((o instanceof Player)) {
			if (mark == -1) {
				owners.removePlayer(((Player) o).getName());
			} else if (mark == 1) {
				owners.removePlayer(((Player) o).getUniqueId());
			} else if (mark == 0) {
				owners.removePlayer(((Player) o).getName());
			}
		} else if ((o instanceof OfflinePlayer)) {
			if (mark == -1) {
				owners.removePlayer(((OfflinePlayer) o).getName());
			} else if (mark == 1) {
				owners.removePlayer(((OfflinePlayer) o).getUniqueId());
			} else if (mark == 0) {
				owners.removePlayer(((OfflinePlayer) o).getName());
			}
		} else {
			owners.removePlayer(o.toString());
		}
	}

	regionManager.getRegion(name).setOwners(owners);
	try {
		regionManager.save();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:56,代码来源:EffRemoveOwner.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HTMLRenderOption类代码示例发布时间:2022-05-22
下一篇:
Java Statistics类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap