本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}