本文整理汇总了Java中net.canarymod.chat.MessageReceiver.asPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java MessageReceiver.asPlayer方法的具体用法?Java MessageReceiver.asPlayer怎么用?Java MessageReceiver.asPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.canarymod.chat.MessageReceiver
的用法示例。
在下文中一共展示了MessageReceiver.asPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteZown
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"delete"
}, parent = "zown", description = "zown delete", permissions = {
"zown.zown.manage.delete"
}, toolTip = "/zown delete <zown>")
public void deleteZown(final MessageReceiver caller, final String[] parameters) {
World world = null;
Player player = null;
String zown = null;
if (caller instanceof Player) {
player = caller.asPlayer();
switch (parameters.length) {
case 2:
world = player.getWorld();
zown = parameters[1];
break;
default:
sendMessage(caller, "Usage: /zown delete <zown>");
}
} else {
switch (parameters.length) {
case 3:
world = worldManager.getWorld(parameters[1], false);
zown = parameters[2];
break;
default:
sendMessage(caller, "Usage: /zown delete <world> <zown>");
}
}
if (world != null && zown != null) {
if (zownManager.removeZown(world, zown, player)) {
sendMessage(caller, "Deleted zown '" + zown + "'.");
} else {
sendMessage(caller, "Failed to delete zown '" + zown + "'.");
}
}
}
示例2: listZowns
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"list"
}, parent = "zown", description = "zown list", permissions = {
"zown.zown.list"
}, toolTip = "/zown list")
public void listZowns(final MessageReceiver caller, final String[] parameters) {
World world = null;
if (caller instanceof Player) {
final Player player = caller.asPlayer();
switch (parameters.length) {
case 1:
world = player.getWorld();
break;
default:
sendMessage(caller, "Usage: /zown list");
}
} else {
switch (parameters.length) {
case 2:
world = worldManager.getWorld(parameters[1], false);
break;
default:
sendMessage(caller, "Usage: /zown list <world>");
}
}
if (world != null) {
final Tree<? extends IZown> zownRootTree = zownManager.getZown(world);
for (final Tree<? extends IZown> zownTree : zownRootTree) {
sendMessage(caller, zownTree.getData().getName());
}
}
}
示例3: showZown
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"show"
}, parent = "zown", description = "zown show", permissions = {
"zown.zown.show"
}, toolTip = "/zown show [zown]")
public void showZown(final MessageReceiver caller, final String[] parameters) {
String zown = null;
Player player = null;
if (caller instanceof Player) {
player = caller.asPlayer();
switch (parameters.length) {
case 2:
zown = parameters[1];
break;
default:
sendMessage(caller, "Usage: /zown show <zown>");
}
}
if (zown != null && player != null) {
final Tree<? extends IZown> zownTree = zownManager.getZown(player.getWorld(), zown);
if (zownTree == null) {
sendMessage(caller, "No zown '" + zown + "' exists.");
} else {
final Point minPoint = zownTree.getData().getMinPoint();
final Point maxPoint = zownTree.getData().getMaxPoint();
if (minPoint != null && maxPoint != null) {
drawTemporaryZownBorder(player, minPoint, maxPoint);
} else {
sendMessage(caller, "You cannot show a global zown.");
}
}
}
}
示例4: applyTemplateToZown
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"apply"
}, parent = "template", description = "zown template apply", permissions = {
"zown.template.apply"
}, toolTip = "/zown template apply <zown> <template>")
public void applyTemplateToZown(final MessageReceiver caller, final String[] parameters) {
World world = null;
String zown = null;
String template = null;
if (caller instanceof Player) {
final Player player = caller.asPlayer();
switch (parameters.length) {
case 3:
world = player.getWorld();
zown = parameters[1];
template = parameters[2];
break;
default:
sendMessage(caller, "Usage: /zown template apply <zown> <template>");
}
} else {
switch (parameters.length) {
case 4:
world = worldManager.getWorld(parameters[1], false);
zown = parameters[2];
template = parameters[3];
break;
default:
sendMessage(caller, "Usage: /zown template apply <world> <zown> <template>");
}
}
if (world != null && zown != null && template != null) {
final ITemplate t = templateManager.getTemplate(template);
if (t != null) {
if (zownManager.applyTemplate(world, zown, t)) {
sendMessage(caller, "Applied template '" + template + "' to zown '" + zown + "'.");
} else {
sendMessage(caller, "Failed to apply template '" + template + "'.");
}
} else {
sendMessage(caller, "No template '" + template + "' exists.");
}
}
}
示例5: createZown
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"create"
}, parent = "zown", description = "zown create", permissions = {
"zown.zown.manage.create"
}, toolTip = "/zown create <zown> [template] <x1 y1 z1> <x2 y2 z2>")
public void createZown(final MessageReceiver caller, final String[] parameters) {
final ParameterTokenizer pTokens = new ParameterTokenizer(parameters);
World world = null;
Player player = null;
String zown = null;
ITemplate template = null;
Point p1 = null;
Point p2 = null;
if (caller instanceof Player) {
player = caller.asPlayer();
if (player.isOperator()) {
switch (parameters.length) {
case 8:
world = player.getWorld();
zown = pTokens.readString();
p1 = pTokens.readPoint();
p2 = pTokens.readPoint();
break;
case 9:
world = player.getWorld();
zown = pTokens.readString();
template = pTokens.readTemplate(templateManager);
p1 = pTokens.readPoint();
p2 = pTokens.readPoint();
break;
default:
sendMessage(caller, "Usage: /zown create <zown> [template] <x1 y1 z1> <x2 y2 z2>");
}
} else {
switch (parameters.length) {
case 8:
world = player.getWorld();
zown = pTokens.readString();
template = templateManager.getTemplate(config.getDefaultWorldTemplate(world));
p1 = pTokens.readPoint();
p2 = pTokens.readPoint();
break;
default:
sendMessage(caller, "Usage: /zown create <zown> <x1 y1 z1> <x2 y2 z2>");
}
}
} else {
switch (parameters.length) {
case 9:
world = pTokens.readWorld(worldManager);
zown = pTokens.readString();
p1 = pTokens.readPoint();
p2 = pTokens.readPoint();
break;
case 10:
world = pTokens.readWorld(worldManager);
zown = pTokens.readString();
template = pTokens.readTemplate(templateManager);
p1 = pTokens.readPoint();
p2 = pTokens.readPoint();
break;
default:
sendMessage(caller, "Usage: /zown create <world> <zown> [template] <x1 y1 z1> <x2 y2 z2>");
}
}
if (world != null && zown != null && p1 != null && p2 != null) {
final Tree<? extends IZown> zownTree = zownManager.createZown(world, zown, template, p1, p2,
player);
if (zownTree == null) {
sendMessage(caller, "Failed to create zown '" + zown + "'.");
} else {
sendMessage(caller, "Created zown '" + zown + "'.");
}
}
}
示例6: editZownPoints
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"editpoints"
}, parent = "zown", description = "zown editpoints", permissions = {
"zown.zown.manage.editpoints"
}, toolTip = "/zown editpoints <zown> <x1 y1 z1> <x2 y2 z2>")
public void editZownPoints(final MessageReceiver caller, final String[] parameters) {
final ParameterTokenizer pTokens = new ParameterTokenizer(parameters);
World world = null;
Player player = null;
String zown = null;
Point p1 = null;
Point p2 = null;
if (caller instanceof Player) {
player = caller.asPlayer();
switch (parameters.length) {
case 8:
world = player.getWorld();
zown = pTokens.readString();
p1 = pTokens.readPoint();
p2 = pTokens.readPoint();
break;
default:
sendMessage(caller, "Usage: /zown editpoints <zown> <x1 y1 z1> <x2 y2 z2>");
}
} else {
switch (parameters.length) {
case 9:
world = pTokens.readWorld(worldManager);
zown = pTokens.readString();
p1 = pTokens.readPoint();
p2 = pTokens.readPoint();
break;
default:
sendMessage(caller, "Usage: /zown editpoints <world> <zown> <x1 y1 z1> <x2 y2 z2>");
}
}
if (world != null && zown != null && p1 != null && p2 != null) {
final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
if (zownTree != null) {
if (zownManager.resizeZown(world, zown, p1, p2, player)) {
sendMessage(caller, "Resized zown '" + zown + "'.");
} else {
sendMessage(caller, "Failed to resize zown '" + zown + "'.");
}
} else {
sendMessage(caller, "No zown '" + zown + "' exists.");
}
}
}
示例7: expandZown
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"expand"
}, parent = "zown", description = "zown expand", permissions = {
"zown.zown.manage.expand"
}, toolTip = "/zown expand <zown>")
public void expandZown(final MessageReceiver caller, final String[] parameters) {
World world = null;
Player player = null;
String zown = null;
if (caller instanceof Player) {
player = caller.asPlayer();
switch (parameters.length) {
case 2:
world = player.getWorld();
zown = parameters[1];
break;
default:
sendMessage(caller, "Usage: /zown expand <zown>");
}
} else {
switch (parameters.length) {
case 3:
world = worldManager.getWorld(parameters[1], false);
zown = parameters[2];
break;
default:
sendMessage(caller, "Usage: /zown expand <world> <zown>");
}
}
if (world != null && zown != null) {
final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
if (zownTree != null) {
final Point p1 = zownTree.getData().getMinPoint().clone();
p1.y = 0;
final Point p2 = zownTree.getData().getMaxPoint().clone();
p2.y = 255;
if (zownManager.resizeZown(world, zown, p1, p2, player)) {
sendMessage(caller, "Expanded zown '" + zown + "'.");
} else {
sendMessage(caller, "Failed to expand zown '" + zown + "'.");
}
} else {
sendMessage(caller, "No zown '" + zown + "' exists.");
}
}
}
示例8: flagZown
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"flag"
}, parent = "zown", description = "zown flag", permissions = {
"zown.zown.flag"
}, toolTip = "/zown flag <zown> <flag>:<ALLOW | DENY>...")
public void flagZown(final MessageReceiver caller, final String[] parameters) {
World world = null;
String zown = null;
int index = 0;
Player player = null;
if (caller instanceof Player) {
player = caller.asPlayer();
if (parameters.length >= 3) {
world = player.getWorld();
zown = parameters[1];
index = 2;
} else {
sendMessage(caller, "Usage: /zown flag <zown> <flag>:<ALLOW | DENY>...");
}
} else {
if (parameters.length >= 4) {
world = worldManager.getWorld(parameters[1], false);
zown = parameters[2];
index = 3;
} else {
sendMessage(caller, "Usage: /zown flag <world> <zown> <flag>:<ALLOW | DENY>...");
}
}
if (world != null && zown != null) {
final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
if (zownTree == null) {
sendMessage(caller, "Zown '" + zown + "' doesn't exist.");
} else {
if (!zownTree.getData().overridesConfiguration()) {
// TODO put in zownManager
zownTree.getData().setOverridesConfiguration(true);
zownManager.saveZownConfiguration(world, zown);
}
boolean changed = false;
final IConfiguration config = zownTree.getData().getConfiguration();
for (int i = index; i < parameters.length; i++) {
final String[] flag = parameters[i].split(":");
if (flag.length == 2) {
if (player != null) {
if (player.isOperator() || player.safeHasPermission("zown.admin.flag")) {
config.setFlag(flag[0],
"allow".equalsIgnoreCase(flag[1]) || "true".equalsIgnoreCase(flag[1]));
changed = true;
} else {
if (zownTree.getData().isOwner(player)
&& zownTree.getData().getConfiguration().hasOwnerPermission(flag[0])) {
config.setFlag(flag[0],
"allow".equalsIgnoreCase(flag[1]) || "true".equalsIgnoreCase(flag[1]));
changed = true;
}
}
} else {
config.setFlag(flag[0], "allow".equalsIgnoreCase(flag[1]));
changed = true;
}
} else {
sendMessage(caller, "Bad flag: " + parameters[i]);
}
}
if (changed) {
zownManager.saveZownConfiguration(world, zown);
sendMessage(caller, "Added flags to zown '" + zown + "'.");
} else {
sendMessage(caller, "No flags set in zown '" + zown + "'.");
}
}
}
}
示例9: flagZownAccess
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"flagaccess"
}, parent = "zown", description = "zown flagaccess", permissions = {
"zown.admin.flagaccess"
}, toolTip = "/zown flagaccess <zown> <add | remove> <flag>")
public void flagZownAccess(final MessageReceiver caller, final String[] parameters) {
World world = null;
String zown = null;
String action = null;
String flag = null;
if (caller instanceof Player) {
final Player player = caller.asPlayer();
switch (parameters.length) {
case 4:
world = player.getWorld();
zown = parameters[1];
action = parameters[2];
flag = parameters[3];
break;
default:
sendMessage(caller, "Usage: /zown flag access <zown> <add | remove> <flag>");
}
} else {
switch (parameters.length) {
case 5:
world = worldManager.getWorld(parameters[1], false);
zown = parameters[2];
action = parameters[3];
flag = parameters[4];
break;
default:
sendMessage(caller, "Usage: /zown flag access <world> <zown> <add | remove> <flag>");
}
}
if (world != null && zown != null && action != null && flag != null) {
final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
if (zownTree == null) {
sendMessage(caller, "No zown '" + zown + "' exists.");
} else {
if ("add".equalsIgnoreCase(action)) {
if (!zownTree.getData().overridesConfiguration()) {
// TODO put in zownManager
zownTree.getData().setOverridesConfiguration(true);
zownManager.saveZownConfiguration(world, zown);
}
if (zownTree.getData().getConfiguration().addOwnerPermission(flag)) {
sendMessage(caller, "Added owner permission '" + flag + "' to zown '" + zown + "'.");
zownManager.saveZownConfiguration(world, zown);
} else {
sendMessage(caller, "Owner permission '" + flag + "' already exists on zown.");
}
} else if ("remove".equalsIgnoreCase(action)) {
if (zownTree.getData().overridesConfiguration()) {
if (zownTree.getData().getConfiguration().removeOwnerPermission(flag)) {
sendMessage(caller, "Removed owner permission '" + flag + "' from zown '" + zown
+ "'.");
zownManager.saveZownConfiguration(world, zown);
} else {
sendMessage(caller, "Owner permission '" + flag + "' does not exist on zown.");
}
} else {
sendMessage(caller, "Zown '" + zown + "' inherits from template '"
+ zownTree.getData().getTemplate().getName() + "'.");
}
} else {
sendMessage(caller, "Unrecognized action '" + action + "' must be <add | remove>.");
}
}
}
}
示例10: renameZown
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"rename"
}, parent = "zown", description = "zown rename", permissions = {
"zown.zown.manage.rename"
}, toolTip = "/zown rename <zown> <newZown>")
public void renameZown(final MessageReceiver caller, final String[] parameters) {
World world = null;
Player player = null;
String zown = null;
String newZown = null;
if (caller instanceof Player) {
player = caller.asPlayer();
switch (parameters.length) {
case 3:
world = player.getWorld();
zown = parameters[1];
newZown = parameters[2];
break;
default:
sendMessage(caller, "Usage: /zown rename <zown> <newZown>");
}
} else {
switch (parameters.length) {
case 4:
world = worldManager.getWorld(parameters[1], false);
zown = parameters[2];
newZown = parameters[3];
break;
default:
sendMessage(caller, "Usage: /zown rename <world> <zown> <newZown>");
}
}
if (world != null && zown != null && newZown != null) {
if (zownManager.renameZown(world, zown, newZown, player)) {
sendMessage(caller, "Renamed zown to '" + newZown + "'.");
} else {
sendMessage(caller, "Failed to rename zown '" + zown + "'.");
}
}
}
示例11: restrictZownCommand
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"restrictcommand"
}, parent = "zown", description = "zown restrictcommand", permissions = {
"zown.admin.restrictcommand"
}, toolTip = "/zown restrictcommand <zown> <add | remove> <command>")
public void restrictZownCommand(final MessageReceiver caller, final String[] parameters) {
World world = null;
String zown = null;
String action = null;
String command = null;
if (caller instanceof Player) {
final Player player = caller.asPlayer();
switch (parameters.length) {
case 4:
world = player.getWorld();
zown = parameters[1];
action = parameters[2];
command = parameters[3];
break;
default:
sendMessage(caller, "Usage: /zown restrictcommand <zown> <add | remove> <command>");
}
} else {
switch (parameters.length) {
case 5:
world = worldManager.getWorld(parameters[1], false);
zown = parameters[2];
action = parameters[3];
command = parameters[4];
break;
default:
sendMessage(caller,
"Usage: /zown restrictcommand <world> <zown> <add | remove> <command>");
}
}
if (world != null && zown != null && action != null && command != null) {
final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
if (zownTree == null) {
sendMessage(caller, "No zown '" + zown + "' exists.");
} else {
if ("add".equalsIgnoreCase(action)) {
if (!zownTree.getData().overridesConfiguration()) {
// TODO put in zownManager
zownTree.getData().setOverridesConfiguration(true);
zownManager.saveZownConfiguration(world, zown);
}
if (zownTree.getData().getConfiguration().addCommandRestriction(command)) {
sendMessage(caller, "Added command restriction '" + command + "' to zown '" + zown
+ "'.");
zownManager.saveZownConfiguration(world, zown);
} else {
sendMessage(caller, "Command restriction '" + command + "' already exists on zown.");
}
} else if ("remove".equalsIgnoreCase(action)) {
if (zownTree.getData().overridesConfiguration()) {
if (zownTree.getData().getConfiguration().removeCommandRestriction(command)) {
sendMessage(caller, "Removed command restriction '" + command + "' from zown '"
+ zown + "'.");
zownManager.saveZownConfiguration(world, zown);
} else {
sendMessage(caller, "Command restriction '" + command + "' does not exist on zown.");
}
} else {
sendMessage(caller, "Zown '" + zown + "' inherits from template '"
+ zownTree.getData().getTemplate().getName() + "'.");
}
} else {
sendMessage(caller, "Unrecognized action '" + action + "' must be <add | remove>.");
}
}
}
}
示例12: zownInfo
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"info"
}, parent = "zown", description = "zown info", permissions = {
"zown.zown.info"
}, toolTip = "/zown info [zown]")
public void zownInfo(final MessageReceiver caller, final String[] parameters) {
World world = null;
String zown = null;
Tree<? extends IZown> zownTree = null;
if (caller instanceof Player) {
final Player player = caller.asPlayer();
switch (parameters.length) {
case 1:
world = player.getWorld();
zownTree = zownManager.getZown(player.getLocation());
break;
case 2:
world = player.getWorld();
zown = parameters[1];
break;
default:
sendMessage(caller, "Usage: /zown info [zown]");
}
} else {
switch (parameters.length) {
case 3:
world = worldManager.getWorld(parameters[1], false);
zown = parameters[2];
break;
default:
sendMessage(caller, "Usage: /zown info <world> <zown>");
}
}
if (world != null && zown != null) {
zownTree = zownManager.getZown(world, zown);
}
if (zownTree == null) {
sendMessage(caller, "There is no zown '" + zown + "' in world " + world.getFqName() + ".");
} else {
sendMessage(caller, zownTree.getData().getDisplay());
}
}
示例13: zownMember
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"member"
}, parent = "zown", description = "zown member", permissions = {
"zown.zown.player.member"
}, toolTip = "/zown member <zown> <add | remove> <player>")
public void zownMember(final MessageReceiver caller, final String[] parameters) {
World world = null;
String zown = null;
String action = null;
String playerName = null;
Player callingPlayer = null;
if (caller instanceof Player) {
callingPlayer = caller.asPlayer();
switch (parameters.length) {
case 4:
world = callingPlayer.getWorld();
zown = parameters[1];
action = parameters[2];
playerName = parameters[3];
break;
default:
sendMessage(caller, "Usage: /zown member <zown> <add | remove> <player>");
}
} else {
switch (parameters.length) {
case 5:
world = worldManager.getWorld(parameters[1], false);
zown = parameters[2];
action = parameters[3];
playerName = parameters[4];
break;
default:
sendMessage(caller, "Usage: /zown member <world> <zown> <add | remove> <player>");
}
}
if (world != null && zown != null && action != null && playerName != null) {
final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
final Player player = Canary.getServer().getPlayer(playerName);
if (zownTree == null) {
sendMessage(caller, "No zown '" + zown + "' exists.");
} else if (player == null) {
sendMessage(caller, "No player '" + playerName + "' is online.");
} else {
if (callingPlayer == null || callingPlayer.isOperator()
|| player.safeHasPermission("zown.admin.player.member")
|| zownTree.getData().isOwner(callingPlayer)) {
if ("add".equalsIgnoreCase(action)) {
if (zownTree.getData().addMember(player)) {
sendMessage(caller, "Added member '" + playerName + "' to zown '" + zown + "'.");
zownManager.saveZownConfiguration(world, zown);
} else {
sendMessage(caller, "Member '" + playerName + "' already exists on zown.");
}
} else if ("remove".equalsIgnoreCase(action)) {
if (zownTree.getData().removeMember(player)) {
sendMessage(caller, "Removed member '" + playerName + "' from zown '" + zown + "'.");
zownManager.saveZownConfiguration(world, zown);
} else {
sendMessage(caller, "Member '" + playerName + "' does not exist on zown.");
}
} else {
sendMessage(caller, "Unrecognized action '" + action + "' must be <add | remove>.");
}
} else {
sendMessage(caller, "You are not an owner of this zown");
}
}
}
}
示例14: zownOwner
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"owner"
}, parent = "zown", description = "zown owner", permissions = {
"zown.zown.player.owner"
}, toolTip = "/zown owner <zown> <add | remove> <player>")
public void zownOwner(final MessageReceiver caller, final String[] parameters) {
World world = null;
String zown = null;
String action = null;
String playerName = null;
Player callingPlayer = null;
if (caller instanceof Player) {
callingPlayer = caller.asPlayer();
switch (parameters.length) {
case 4:
world = callingPlayer.getWorld();
zown = parameters[1];
action = parameters[2];
playerName = parameters[3];
break;
default:
sendMessage(caller, "Usage: /zown owner <zown> <add | remove> <player>");
}
} else {
switch (parameters.length) {
case 5:
world = worldManager.getWorld(parameters[1], false);
zown = parameters[2];
action = parameters[3];
playerName = parameters[4];
break;
default:
sendMessage(caller, "Usage: /zown owner <world> <zown> <add | remove> <player>");
}
}
if (world != null && zown != null && action != null && playerName != null) {
final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
final Player player = Canary.getServer().getPlayer(playerName);
if (zownTree == null) {
sendMessage(caller, "No zown '" + zown + "' exists.");
} else if (player == null) {
sendMessage(caller, "No player '" + playerName + "' is online.");
} else {
if (callingPlayer == null || callingPlayer.isOperator()
|| player.safeHasPermission("zown.admin.player.owner")
|| zownTree.getData().isOwner(callingPlayer)) {
if ("add".equalsIgnoreCase(action)) {
if (zownTree.getData().addOwner(player)) {
sendMessage(caller, "Added owner '" + playerName + "' to zown '" + zown + "'.");
zownManager.saveZownConfiguration(world, zown);
} else {
sendMessage(caller, "Owner '" + playerName + "' already exists on zown.");
}
} else if ("remove".equalsIgnoreCase(action)) {
if (zownTree.getData().removeOwner(player)) {
sendMessage(caller, "Removed owner '" + playerName + "' from zown '" + zown + "'.");
zownManager.saveZownConfiguration(world, zown);
} else {
sendMessage(caller, "Owner '" + playerName + "' does not exist on zown.");
}
} else {
sendMessage(caller, "Unrecognized action '" + action + "' must be <add | remove>.");
}
} else {
sendMessage(caller, "You are not an owner of this zown");
}
}
}
}
示例15: zownMessage
import net.canarymod.chat.MessageReceiver; //导入方法依赖的package包/类
@Command(aliases = {
"message"
}, parent = "zown", description = "zown message", permissions = {
"zown.zown.message"
}, toolTip = "/zown message <zown> <welcome | farewell | restrictentry> \"<message>\"")
public void zownMessage(final MessageReceiver caller, final String[] parameters) {
World world = null;
String zown = null;
String type = null;
String message = null;
Player player = null;
if (caller instanceof Player) {
player = caller.asPlayer();
if (parameters.length > 3) {
world = player.getWorld();
zown = parameters[1];
type = parameters[2];
message = parseMessage(parameters, 3);
} else {
sendMessage(caller,
"Usage: /zown message <zown> <welcome | farewell | restrictentry> \"<message>\"");
}
} else {
if (parameters.length > 4) {
world = worldManager.getWorld(parameters[1], false);
zown = parameters[2];
type = parameters[3];
message = parseMessage(parameters, 4);
} else {
sendMessage(caller,
"Usage: /zown message <world> <zown> <welcome | farewell | restrictentry> \"<message>\"");
}
}
if (world != null && zown != null && type != null) {
if (message == null) {
sendMessage(caller, "Bad message specified.");
} else {
final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
if (zownTree == null) {
sendMessage(caller, "No zown '" + zown + "' exists.");
} else {
if (player == null || player.isOperator()
|| player.safeHasPermission("zown.admin.message")
|| zownTree.getData().isOwner(player)) {
if ("welcome".equalsIgnoreCase(type)) {
zownTree.getData().setWelcomeMessage(message);
sendMessage(caller, "Added welcome message to zown '" + zown + "'.");
zownManager.saveZownConfiguration(world, zown);
} else if ("farewell".equalsIgnoreCase(type)) {
zownTree.getData().setFarewellMessage(message);
sendMessage(caller, "Added farewell message to zown '" + zown + "'.");
zownManager.saveZownConfiguration(world, zown);
} else if ("restrictentry".equalsIgnoreCase(type)) {
// TODO Add support for restrictentry message
throw new UnsupportedOperationException("Do not yet support restrictentry messages");
} else {
sendMessage(caller, "Unrecognized message type '" + type
+ "' must be <welcome | farewell | restrictentry>.");
}
} else {
sendMessage(caller, "You are not an owner of this zown");
}
}
}
}
}