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


Java DefaultDomain类代码示例

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


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


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