本文整理汇总了Java中com.sk89q.minecraft.util.commands.CommandException类的典型用法代码示例。如果您正苦于以下问题:Java CommandException类的具体用法?Java CommandException怎么用?Java CommandException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandException类属于com.sk89q.minecraft.util.commands包,在下文中一共展示了CommandException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deployInfo
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = "deployinfo",
desc = "What is deployed on this server?",
min = 0,
max = 0
)
@CommandPermissions(Permissions.DEVELOPER)
public void deployInfo(CommandContext args, CommandSender sender) throws CommandException {
final DeployInfo info = startupDocument.deploy_info();
if(info == null) {
throw new CommandException("No deploy info was loaded");
} else {
sender.sendMessage(new Component("Nextgen"));
sender.sendMessage(new Component(" path: " + info.nextgen().path()));
sender.sendMessage(new Component(" version: " + format(info.nextgen().version())));
for(Map.Entry<String, DeployInfo.Version> entry : info.packages().entrySet()) {
sender.sendMessage(new Component(entry.getKey() + ": " + format(entry.getValue())));
}
}
}
示例2: max
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"max", "size"},
desc = "Change the maximum number of players allowed to participate in the match.",
min = 1,
max = 2
)
@CommandPermissions("pgm.team.size")
public static void max(CommandContext args, CommandSender sender) throws CommandException {
FreeForAllMatchModule ffa = CommandUtils.getMatchModule(FreeForAllMatchModule.class, sender);
if("default".equals(args.getString(0))) {
ffa.setMaxPlayers(null, null);
} else {
int maxPlayers = args.getInteger(0);
if(maxPlayers < 0) throw new CommandException("max-players cannot be less than 0");
int maxOverfill = args.argsLength() >= 2 ? args.getInteger(1) : maxPlayers;
if(maxOverfill < maxPlayers) throw new CommandException("max-overfill cannot be less than max-players");
if(maxPlayers < ffa.getMinPlayers()) throw new CommandException("max-players cannot be less than min-players");
ffa.setMaxPlayers(maxPlayers, maxOverfill);
}
sender.sendMessage(ChatColor.WHITE + "Maximum players is now " + ChatColor.AQUA + ffa.getMaxPlayers() +
ChatColor.WHITE + " and overfill is " + ChatColor.AQUA + ffa.getMaxOverfill());
}
示例3: add
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"add"},
desc = "Add a player to the whitelist",
usage = "<username>",
min = 1,
max = 1
)
public void add(CommandContext args, final CommandSender sender) throws CommandException {
syncExecutor.callback(
userFinder.findUser(sender, args, 0),
CommandFutureCallback.onSuccess(sender, args, result -> {
whitelist.add(result.user);
audiences.get(sender).sendMessage(
new TranslatableComponent(
"whitelist.add",
new PlayerComponent(identities.currentIdentity(result.user), NameStyle.FANCY)
)
);
})
);
}
示例4: sleep
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = "sleep",
desc = "Put the main server thread to sleep for the given duration",
usage = "<time>",
flags = "",
min = 1,
max = 1
)
@CommandPermissions(Permissions.DEVELOPER)
public void sleep(CommandContext args, CommandSender sender) throws CommandException {
try {
Thread.sleep(durationParser.parse(args.getString(0)).toMillis());
} catch(InterruptedException e) {
throw new CommandException("Sleep was interrupted", e);
}
}
示例5: session
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"session"},
desc = "Session status control",
usage = "[on|off|clear]",
max = 1
)
@CommandPermissions("bungeecord.command.session")
public void session(final CommandContext args, CommandSender sender) throws CommandException {
if (args.argsLength() == 1) {
String arg = args.getString(0);
SessionState newState = parseSessionStateCommand(arg);
if (newState == null) throw new CommandException("Unknown session state command: " + arg);
sender.sendMessage(new ComponentBuilder("Old Force Status: " + monitor.getForceState()).color(ChatColor.LIGHT_PURPLE).create());
monitor.setForceState(newState);
}
sender.sendMessage(new ComponentBuilder("Current Force Status: " + monitor.getForceState()).color(ChatColor.GOLD).create());
sender.sendMessage(new ComponentBuilder("Current Session Status: " + monitor.getDiscoveredState()).color(ChatColor.GOLD).create());
}
示例6: skipto
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"skipto"},
desc = "Skip to a certain point in the rotation",
usage = "[n]",
min = 1,
max = 1
)
@CommandPermissions("pgm.skip")
public void skipto(CommandContext args, CommandSender sender) throws CommandException {
RotationManager manager = PGM.getMatchManager().getRotationManager();
RotationState rotation = manager.getRotation();
int newNextId = args.getInteger(0) - 1;
if(RotationState.isNextIdValid(rotation.getMaps(), newNextId)) {
rotation = rotation.skipTo(newNextId);
manager.setRotation(rotation);
sender.sendMessage(ChatColor.GREEN + PGMTranslations.get().t("command.admin.skipto.success", sender, rotation.getNext().getInfo().getShortDescription(sender) + ChatColor.GREEN));
} else {
throw new CommandException(PGMTranslations.get().t("command.admin.skipto.invalidPoint", sender));
}
}
示例7: remove
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"remove"},
desc = "Remove a player from the whitelist",
usage = "<username>",
min = 1,
max = 1
)
public void remove(CommandContext args, final CommandSender sender) throws CommandException {
final String username = args.getString(0);
for(Iterator<PlayerId> iter = whitelist.iterator(); iter.hasNext();) {
PlayerId playerId = iter.next();
if(username.equalsIgnoreCase(playerId.username())) {
iter.remove();
audiences.get(sender).sendMessage(
new TranslatableComponent(
"whitelist.remove",
new PlayerComponent(identities.currentIdentity(playerId), NameStyle.FANCY)
)
);
return;
}
}
throw new TranslatableCommandException("whitelist.notFound", username);
}
示例8: message
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"msg", "message", "whisper", "pm", "tell", "dm"},
usage = "<target> <message...>",
desc = "Private message a user",
min = 2,
max = -1
)
@CommandPermissions("projectares.msg")
public void message(final CommandContext args, final CommandSender sender) throws CommandException {
final Player player = CommandUtils.senderToPlayer(sender);
final Identity from = identityProvider.currentIdentity(player);
final String content = args.getJoinedStrings(1);
executor.callback(
userFinder.findUser(sender, args, 0),
CommandFutureCallback.onSuccess(sender, args, response -> {
whisperSender.send(sender, from, identityProvider.createIdentity(response), content);
})
);
}
示例9: maplist
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"maplist", "maps", "ml"},
desc = "Shows the maps that are currently loaded",
usage = "[page]",
min = 0,
max = 1,
help = "Shows all the maps that are currently loaded including ones that are not in the rotation."
)
@CommandPermissions("pgm.maplist")
public static void maplist(CommandContext args, final CommandSender sender) throws CommandException {
final Set<PGMMap> maps = ImmutableSortedSet.copyOf(new PGMMap.DisplayOrder(), PGM.getMatchManager().getMaps());
new PrettyPaginatedResult<PGMMap>(PGMTranslations.get().t("command.map.mapList.title", sender)) {
@Override public String format(PGMMap map, int index) {
return (index + 1) + ". " + map.getInfo().getShortDescription(sender);
}
}.display(new BukkitWrappedCommandSender(sender), maps, args.getInteger(0, 1) /* page */);
}
示例10: force
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"force"},
desc = "Force a player onto a team",
usage = "<player> [team]",
min = 1,
max = 2
)
@CommandPermissions("pgm.team.force")
public void force(CommandContext args, CommandSender sender) throws CommandException, SuggestException {
MatchPlayer player = CommandUtils.findSingleMatchPlayer(args, sender, 0);
if(args.argsLength() >= 2) {
String name = args.getString(1);
if(name.trim().toLowerCase().startsWith("obs")) {
player.getMatch().setPlayerParty(player, player.getMatch().getDefaultParty());
} else {
Team team = utils.teamArgument(args, 1);
utils.module().forceJoin(player, team);
}
} else {
utils.module().forceJoin(player, null);
}
}
示例11: min
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"min"},
desc = "Change the minimum size of a team.",
usage = "<team> (default | <min-players>)",
min = 2,
max = 2
)
@CommandPermissions("pgm.team.size")
public void min(CommandContext args, CommandSender sender) throws CommandException, SuggestException {
Team team = utils.teamArgument(args, 0);
if("default".equals(args.getString(1))) {
team.resetMinSize();
} else {
int minPlayers = args.getInteger(1);
if(minPlayers < 0) throw new CommandException("min-players cannot be less than 0");
team.setMinSize(minPlayers);
}
sender.sendMessage(team.getColoredName() +
ChatColor.WHITE + " now has min size " + ChatColor.AQUA + team.getMinPlayers());
}
示例12: inventory
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"inventory", "inv", "vi"},
desc = "View a player's inventory",
usage = "<player>",
min = 1,
max = 1
)
public void inventory(CommandContext args, CommandSender sender) throws CommandException {
final Player viewer = senderToPlayer(sender);
Player holder = findOnlinePlayer(args, viewer, 0);
if(vimm.canPreviewInventory(viewer, holder)) {
vimm.previewInventory((Player) sender, holder.getInventory());
} else {
throw new TranslatableCommandException("player.inventoryPreview.notViewable");
}
}
示例13: hub
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"hub", "lobby"},
desc = "Teleport to the lobby"
)
public void hub(final CommandContext args, CommandSender sender) throws CommandException {
if(sender instanceof ProxiedPlayer) {
final ProxiedPlayer player = (ProxiedPlayer) sender;
final Server server = Futures.getUnchecked(executor.submit(() -> serverTracker.byPlayer(player)));
if(server.role() == ServerDoc.Role.LOBBY || server.role() == ServerDoc.Role.PGM) {
// If Bukkit server is running Commons, let it handle the command
throw new CommandBypassException();
}
player.connect(proxy.getServerInfo("default"));
player.sendMessage(new ComponentBuilder("Teleporting you to the lobby").color(ChatColor.GREEN).create());
} else {
sender.sendMessage(new ComponentBuilder("Only players may use this command").color(ChatColor.RED).create());
}
}
示例14: featuresCommand
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"matchfeatures", "features"},
desc = "Lists all features by ID and type",
min = 0,
max = 1
)
@CommandPermissions(Permissions.MAPDEV)
public void featuresCommand(CommandContext args, CommandSender sender) throws CommandException {
final Match match = tc.oc.pgm.commands.CommandUtils.getMatch(sender);
new PrettyPaginatedResult<Feature>("Match Features") {
@Override
public String format(Feature feature, int i) {
String text = (i + 1) + ". " + ChatColor.RED + feature.getClass().getSimpleName();
if(feature instanceof SluggedFeature) {
text += ChatColor.GRAY + " - " +ChatColor.GOLD + ((SluggedFeature) feature).slug();
}
return text;
}
}.display(new BukkitWrappedCommandSender(sender),
match.features().all().collect(Collectors.toList()),
args.getInteger(0, 1));
}
示例15: featureCommand
import com.sk89q.minecraft.util.commands.CommandException; //导入依赖的package包/类
@Command(
aliases = {"feature", "fl"},
desc = "Prints information regarding a specific feature",
min = 1,
max = -1
)
@CommandPermissions(Permissions.MAPDEV)
public void featureCommand(CommandContext args, CommandSender sender) throws CommandException {
final String slug = args.getJoinedStrings(0);
final Optional<Feature<?>> feature = matchManager.getCurrentMatch(sender).features().bySlug(slug);
if(feature.isPresent()) {
sender.sendMessage(ChatColor.GOLD + slug + ChatColor.GRAY + " corresponds to: " + ChatColor.WHITE + feature.get().toString());
} else {
sender.sendMessage(ChatColor.RED + "No feature by the name of " + ChatColor.GOLD + slug + ChatColor.RED + " was found.");
}
}