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


Java DefaultDomain.addPlayer方法代码示例

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


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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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.addPlayer(((Player) o).getName());
			} else if (mark == 1) {
				owners.addPlayer(((Player) o).getUniqueId());
			} else if (mark == 0) {
				owners.addPlayer(((Player) o).getName());
			}
		} else if ((o instanceof OfflinePlayer)) {
			if (mark == -1) {
				owners.addPlayer(((OfflinePlayer) o).getName());
			} else if (mark == 1) {
				owners.addPlayer(((OfflinePlayer) o).getUniqueId());
			} else if (mark == 0) {
				owners.addPlayer(((OfflinePlayer) o).getName());
			}
		} else {
			owners.addPlayer(o.toString());
		}
	}

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

示例9: addOwner

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

示例10: addMember

import com.sk89q.worldguard.domains.DefaultDomain; //导入方法依赖的package包/类
public static void addMember(OfflinePlayer p, ProtectedRegion r){
	DefaultDomain members = r.getMembers();
	members.addPlayer(p.getUniqueId());
	r.setMembers(members);
}
 
开发者ID:gvlfm78,项目名称:BukkitHotels,代码行数:6,代码来源:HTWorldGuardManager.java

示例11: setMember

import com.sk89q.worldguard.domains.DefaultDomain; //导入方法依赖的package包/类
public static void setMember(UUID uuid, ProtectedRegion r){
	DefaultDomain member = new DefaultDomain();
	member.addPlayer(uuid);
	r.setMembers(member);
}
 
开发者ID:gvlfm78,项目名称:BukkitHotels,代码行数:6,代码来源:HTWorldGuardManager.java

示例12: setOwner

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

示例13: setMembers

import com.sk89q.worldguard.domains.DefaultDomain; //导入方法依赖的package包/类
public static void setMembers(ArrayList<UUID> uuids, ProtectedRegion r){
	DefaultDomain members = new DefaultDomain();
	for(UUID uuid : uuids)
		members.addPlayer(uuid);
	r.setMembers(members);
}
 
开发者ID:gvlfm78,项目名称:BukkitHotels,代码行数:7,代码来源:HTWorldGuardManager.java

示例14: setOwners

import com.sk89q.worldguard.domains.DefaultDomain; //导入方法依赖的package包/类
public static void setOwners(ArrayList<UUID> uuids, ProtectedRegion r){
	DefaultDomain owners = new DefaultDomain();
	for(UUID uuid : uuids)
		owners.addPlayer(uuid);
	r.setOwners(owners);
}
 
开发者ID:gvlfm78,项目名称:BukkitHotels,代码行数:7,代码来源:HTWorldGuardManager.java


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