本文整理了Java中org.bukkit.command.Command
类的一些代码示例,展示了Command
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Command
类的具体详情如下:
包路径:org.bukkit.command.Command
类名称:Command
[英]Represents a Command, which executes various tasks upon user input
[中]表示一个命令,该命令根据用户输入执行各种任务
代码示例来源:origin: Bukkit/Bukkit
/**
* {@inheritDoc}
*/
public boolean register(String fallbackPrefix, Command command) {
return register(command.getName(), fallbackPrefix, command);
}
代码示例来源:origin: Bukkit/Bukkit
public GenericCommandHelpTopic(Command command) {
this.command = command;
if (command.getLabel().startsWith("/")) {
name = command.getLabel();
} else {
name = "/" + command.getLabel();
int i = command.getDescription().indexOf("\n");
if (i > 1) {
shortText = command.getDescription().substring(0, i - 1);
} else {
shortText = command.getDescription();
sb.append("Description: ");
sb.append(ChatColor.WHITE);
sb.append(command.getDescription());
sb.append("Usage: ");
sb.append(ChatColor.WHITE);
sb.append(command.getUsage().replace("<command>", name.substring(1)));
if (command.getAliases().size() > 0) {
sb.append("\n");
sb.append(ChatColor.GOLD);
sb.append("Aliases: ");
sb.append(ChatColor.WHITE);
sb.append(ChatColor.WHITE + StringUtils.join(command.getAliases(), ", "));
代码示例来源:origin: Bukkit/Bukkit
Bukkit.getServer().getLogger().severe("Could not load command " + entry.getKey() + " for plugin " + plugin.getName() + ": Illegal Characters");
continue;
newCmd.setDescription(description.toString());
newCmd.setUsage(usage.toString());
for (Object o : (List<?>) aliases) {
if (o.toString().contains(":")) {
Bukkit.getServer().getLogger().severe("Could not load alias " + o.toString() + " for plugin " + plugin.getName() + ": Illegal Characters");
continue;
Bukkit.getServer().getLogger().severe("Could not load alias " + aliases.toString() + " for plugin " + plugin.getName() + ": Illegal Characters");
} else {
aliasList.add(aliases.toString());
newCmd.setAliases(aliasList);
newCmd.setPermission(permission.toString());
newCmd.setPermissionMessage(permissionMessage.toString());
代码示例来源:origin: Bukkit/Bukkit
if (conflict != null && conflict.getLabel().equals(label)) {
return false;
command.setLabel(label);
代码示例来源:origin: Bukkit/Bukkit
/**
* {@inheritDoc}
*/
public boolean register(String label, String fallbackPrefix, Command command) {
label = label.toLowerCase().trim();
fallbackPrefix = fallbackPrefix.toLowerCase().trim();
boolean registered = register(label, command, false, fallbackPrefix);
Iterator<String> iterator = command.getAliases().iterator();
while (iterator.hasNext()) {
if (!register(iterator.next(), command, true, fallbackPrefix)) {
iterator.remove();
}
}
// If we failed to register under the real name, we need to set the command label to the direct address
if (!registered) {
command.setLabel(fallbackPrefix + ":" + label);
}
// Register to us so further updates of the commands label and aliases are postponed until its reregistered
command.register(this);
return registered;
}
代码示例来源:origin: BigScary/GriefPrevention
if(cmd.getName().equalsIgnoreCase("claim") && player != null)
if(cmd.getName().equalsIgnoreCase("extendclaim") && player != null)
if(cmd.getName().equalsIgnoreCase("abandonclaim") && player != null)
if(cmd.getName().equalsIgnoreCase("abandontoplevelclaim") && player != null)
if(cmd.getName().equalsIgnoreCase("ignoreclaims") && player != null)
else if(cmd.getName().equalsIgnoreCase("abandonallclaims") && player != null)
else if(cmd.getName().equalsIgnoreCase("restorenature") && player != null)
else if(cmd.getName().equalsIgnoreCase("restorenatureaggressive") && player != null)
else if(cmd.getName().equalsIgnoreCase("restorenaturefill") && player != null)
else if(cmd.getName().equalsIgnoreCase("trust") && player != null)
else if(cmd.getName().equalsIgnoreCase("transferclaim") && player != null)
else if(cmd.getName().equalsIgnoreCase("trustlist") && player != null)
else if(cmd.getName().equalsIgnoreCase("untrust") && player != null)
else if(cmd.getName().equalsIgnoreCase("accesstrust") && player != null)
else if(cmd.getName().equalsIgnoreCase("containertrust") && player != null)
代码示例来源:origin: catageek/ByteCart
private boolean onCommand(CommandSender a, Command b , String c, String[] d,int n)
if(b.getName().equalsIgnoreCase("host"))
if (a.hasPermission("bytecart.host.manager")) {
String hostname = getName(d,1,1);
hostname = Normalizer.normalize(hostname, Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
if(!safeName(hostname))
a.sendMessage(ChatColor.DARK_GREEN+"[Bytecart] " + ChatColor.RED + "No hacking this time");
return true;
a.sendMessage(ChatColor.DARK_GREEN+"[Bytecart] " + ChatColor.RED + "Wrong IP/Name or not enough args.");
return true;
if((a instanceof Player))
uu=((Player)a).getUniqueId().toString();
user=((Player)a).getName();
代码示例来源:origin: eccentricdevotion/TARDIS
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("tardisgravity")) {
Player player = null;
if (sender instanceof Player) {
return false;
if (!player.hasPermission("tardis.gravity")) {
TARDISMessage.send(sender, "NO_PERMS");
return true;
String mess_stub = (player.getLocation().getWorld().getName().contains("TARDIS_WORLD_")) ? "GRAVITY_OWN_WORLD" : "GRAVITY_A_WORLD";
TARDISMessage.send(player, mess_stub);
return true;
values[2] = 0.5D;
plugin.getTrackerKeeper().getGravity().put(player.getUniqueId(), values);
String message = (dir.equals("remove")) ? "GRAVITY_CLICK_REMOVE" : "GRAVITY_CLICK_SAVE";
TARDISMessage.send(player, message);
代码示例来源:origin: marcelo-mason/PreciousStones
if (command.getName().equals("ps")) {
Player player = null;
if (plugin.getSettingsManager().isBlacklistedWorld(player.getWorld())) {
ChatHelper.send(player, "psDisabled");
return true;
args = Helper.removeFirst(args);
Block block = hasplayer ? player.getWorld().getBlockAt(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()) : null;
Player allowed = Bukkit.getServer().getPlayerExact(playerName);
plugin.getEntryManager().reevaluateEnteredFields(Bukkit.getServer().getPlayerExact(playerName));
plugin.getEntryManager().reevaluateEnteredFields(Bukkit.getServer().getPlayerExact(playerName));
} else if (cmd.equals(ChatHelper.format("commandLocations"))) {
if (args.length == 0 && plugin.getPermissionsManager().has(player, "preciousstones.benefit.locations") && hasplayer) {
plugin.getCommunicationManager().showFieldLocations(sender, -1, sender.getName());
return true;
plugin.getForceFieldManager().giveField(recipient, settings, count);
ChatHelper.send(sender, "fieldsGiven", playerName, settings.getTitle(), count);
ChatHelper.send(recipient, "fieldsGivenPlayer", sender.getName(), settings.getTitle(), count);
} else {
ChatHelper.send(sender, "fieldNotFound", fieldName);
代码示例来源:origin: eccentricdevotion/TARDIS
if (cmd.getName().equalsIgnoreCase("tardistravel")) {
if (player == null) {
TARDISMessage.send(sender, "CMD_PLAYER");
return true;
if (player.hasPermission("tardis.timetravel")) {
if (args.length < 1) {
new TARDISCommandHelper(plugin).getCommand("tardistravel", sender);
where.put("uuid", player.getUniqueId().toString());
ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0);
if (!rs.resultSet()) {
wheret.put("uuid", player.getUniqueId().toString());
ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);
if (!rst.resultSet()) {
return true;
set.put("world", l.getWorld().getName());
set.put("x", l.getBlockX());
set.put("y", l.getBlockY());
return true;
return true;
代码示例来源:origin: MilkBowl/Vault
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
if (!sender.hasPermission("vault.admin")) {
sender.sendMessage("You do not have permission to use that command!");
return true;
}
if (command.getName().equalsIgnoreCase("vault-info")) {
infoCommand(sender);
return true;
} else if (command.getName().equalsIgnoreCase("vault-convert")) {
convertCommand(sender, args);
return true;
} else {
// Show help
sender.sendMessage("Vault Commands:");
sender.sendMessage(" /vault-info - Displays information about Vault");
sender.sendMessage(" /vault-convert [economy1] [economy2] - Converts from one Economy to another");
return true;
}
}
代码示例来源:origin: SkyWars/SkyWars
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!enabledCorrectly) {
sender.sendMessage(SkyTrans.get(TransKey.NOT_FULLY_ENABLED));
} else {
sender.sendMessage(SkyTrans.get(TransKey.NO_CLUE_COMMAND, cmd.getName()));
}
return true;
}
代码示例来源:origin: eccentricdevotion/TARDIS
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("tardisremote") && sender.hasPermission("tardis.remote")) {
if (args.length < 2) {
new TARDISCommandHelper(plugin).getCommand("tardisremote", sender);
if ((sender instanceof Player && !sender.hasPermission("tardis.admin")) || sender instanceof BlockCommandSender) {
return new TARDISHideCommand(plugin).hide(p);
} else {
return true;
set.put("world", rsh.getWorld().getName());
set.put("x", rsh.getX());
set.put("y", rsh.getY());
if ((!p.getPlayer().hasPermission(perm) && !p.getPlayer().hasPermission("tardis.area.*"))) {
TARDISMessage.send(sender, "TRAVEL_NO_AREA_PERM", args[3]);
return true;
return true;
set.put("world", l.getWorld().getName());
set.put("x", l.getBlockX());
set.put("y", l.getBlockY());
return true;
代码示例来源:origin: games647/ChangeSkin
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (plugin.isBungeeCord()) {
onBungeeCord(sender, command.getName(), args);
return true;
Player targetPlayer = Bukkit.getPlayerExact(args[0]);
if (targetPlayer == null) {
plugin.sendMessage(sender, "not-online");
if (!sender.hasPermission(permPrefix + targetPlayer.getUniqueId())
&& !sender.hasPermission(permPrefix + '*')) {
plugin.sendMessage(sender, "no-permission-other");
return true;
Bukkit.getScheduler().runTaskAsynchronously(plugin, skinInvalidate);
return true;
Bukkit.getScheduler().runTaskAsynchronously(plugin, new SkinInvalidator(plugin, sender, receiver));
return true;
代码示例来源:origin: eccentricdevotion/TARDIS
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("tardisbind")) {
if (!sender.hasPermission("tardis.update")) {
TARDISMessage.send(sender, "NO_PERMS");
return false;
if (!rs.fromUUID(player.getUniqueId().toString())) {
TARDISMessage.send(player, "NOT_A_TIMELORD");
return false;
wheret.put("uuid", player.getUniqueId().toString());
ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);
if (!rst.resultSet()) {
int did = qf.doSyncInsert("destinations", set);
if (did != 0) {
plugin.getTrackerKeeper().getBinder().put(player.getUniqueId(), did);
TARDISMessage.send(player, "BIND_CLICK");
return true;
代码示例来源:origin: eccentricdevotion/TARDIS
if (cmd.getName().equalsIgnoreCase("tardis")) {
Player player = null;
if (sender instanceof Player) {
tc = TARDIS_COMMAND.valueOf(args[0].toLowerCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
sender.sendMessage(plugin.getPluginName() + "That command wasn't recognised type " + ChatColor.GREEN + "/tardis help" + ChatColor.RESET + " to see the commands");
return false;
if (!rs.fromUUID(player.getUniqueId().toString())) {
TARDISMessage.send(player, "NOT_A_TIMELORD");
return true;
return new TARDISRoomCommand(plugin).startRoom(player, args);
case save_player:
ItemStack is = player.getInventory().getItemInMainHand();
if (heldDiskIsWrong(is, "Player Storage Disk")) {
TARDISMessage.send(player, "DISK_HAND_PLAYER");
return new TARDISExterminateCommand(plugin).doExterminate(player);
case save:
ItemStack itemStack = player.getInventory().getItemInMainHand();
if (!plugin.getDifficulty().equals(DIFFICULTY.EASY) && !plugin.getUtils().inGracePeriod(player, true)) {
if (plugin.getDifficulty().equals(DIFFICULTY.HARD) && heldDiskIsWrong(itemStack, "Save Storage Disk")) {
代码示例来源:origin: eccentricdevotion/TARDIS
if (cmd.getName().equalsIgnoreCase("tardisartron")) {
if (!sender.hasPermission("tardis.store")) {
TARDISMessage.send(sender, "NO_PERMS");
return true;
return true;
ItemStack is = player.getInventory().getItemInMainHand();
if (is == null || !is.hasItemMeta()) {
TARDISMessage.send(player, "CELL_IN_HAND");
String playerUUID = player.getUniqueId().toString();
int current_level;
if (which.equals("tardis")) {
代码示例来源:origin: eccentricdevotion/TARDIS
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!sender.hasPermission("tardis.admin")) {
TARDISMessage.send(sender, "NO_PERM_AREA");
return true;
if (cmd.getName().equalsIgnoreCase("tardisarea")) {
if (args.length == 0) {
new TARDISCommandHelper(plugin).getCommand("tardisarea", sender);
plugin.getTrackerKeeper().getArea().put(player.getUniqueId(), args[1]);
TARDISMessage.send(player, "AREA_CLICK_START");
return true;
case "end":
if (!plugin.getTrackerKeeper().getBlock().containsKey(player.getUniqueId())) {
TARDISMessage.send(player, "AREA_NO_START");
return false;
plugin.getTrackerKeeper().getEnd().put(player.getUniqueId(), "end");
TARDISMessage.send(player, "AREA_CLICK_END");
return true;
代码示例来源:origin: eccentricdevotion/TARDIS
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("tardisgive")) {
if (sender instanceof ConsoleCommandSender || sender.hasPermission("tardis.admin")) {
if (args.length == 1 && args[0].equalsIgnoreCase("list")) {
new TARDISGiveLister(plugin, sender).list();
TARDISMessage.send(p, "GIVE_KIT", sender.getName(), args[2]);
return true;
him.setLore(Arrays.asList("Cyberhead from the", "Maldovar Market"));
handles.setItemMeta(him);
p.getInventory().addItem(handles);
p.updateInventory();
TARDISMessage.send(p, "GIVE_ITEM", sender.getName(), amount + " Handles");
return true;
代码示例来源:origin: TotalFreedom/TotalFreedomMod
if (command != null)
cmdName = command.getName().toLowerCase();
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
event.setCancelled(true);
return;
FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), message), true);
内容来源于网络,如有侵权,请联系作者删除!