• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CommandContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sk89q.minecraft.util.commands.CommandContext的典型用法代码示例。如果您正苦于以下问题:Java CommandContext类的具体用法?Java CommandContext怎么用?Java CommandContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CommandContext类属于com.sk89q.minecraft.util.commands包,在下文中一共展示了CommandContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: min

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
@Command(
    aliases = {"min"},
    desc = "Change the minimum number of players required to start the match.",
    min = 1,
    max = 1
)
@CommandPermissions("pgm.team.size")
public static void min(CommandContext args, CommandSender sender) throws CommandException {
    FreeForAllMatchModule ffa = CommandUtils.getMatchModule(FreeForAllMatchModule.class, sender);
    if("default".equals(args.getString(0))) {
        ffa.setMinPlayers(null);
    } else {
        int minPlayers = args.getInteger(0);
        if(minPlayers < 0) throw new CommandException("min-players cannot be less than 0");
        if(minPlayers > ffa.getMaxPlayers()) throw new CommandException("min-players cannot be greater than max-players");
        ffa.setMinPlayers(minPlayers);
    }

    sender.sendMessage(ChatColor.WHITE + "Minimum players is now " + ChatColor.AQUA + ffa.getMinPlayers());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:21,代码来源:FreeForAllCommands.java


示例2: max

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的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());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:27,代码来源:FreeForAllCommands.java


示例3: restart

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
@Command(
    aliases = {"restart"},
    desc = "Queues a server restart after a certain amount of time",
    usage = "[seconds] - defaults to 30 seconds",
    flags = "f",
    min = 0,
    max = 1
)
@CommandPermissions("server.restart")
public void restart(CommandContext args, CommandSender sender) throws CommandException {
    // Countdown defers automatic restart, so don't allow excessively long times
    Duration countdown = TimeUtils.min(
        tc.oc.commons.bukkit.commands.CommandUtils.getDuration(args, 0, Duration.ofSeconds(30)),
        Duration.ofMinutes(5)
    );

    final Match match = CommandUtils.getMatch(sender);
    if(!match.canAbort() && !args.hasFlag('f')) {
        throw new CommandException(PGMTranslations.get().t("command.admin.restart.matchRunning", sender));
    }

    restartListener.queueRestart(match, countdown, "/restart command");
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:24,代码来源:AdminCommands.java


示例4: create

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
public void create(CommandContext args, CommandSender sender, @Nullable Type type, @Nullable Duration duration) throws CommandException {
    final User punisher = userFinder.getLocalUser(sender);
    final String reason = args.getRemainingString(duration == null ? 1 : 2);
    final boolean auto = flag('a', args, sender);
    final boolean silent = flag('s', args, sender);
    final boolean offrecord = flag('o', args, sender);
    if(permission(sender, type)) {
        syncExecutor.callback(
            userFinder.findUser(sender, args, 0),
            response -> {
                punishmentCreator.create(
                    punisher,
                    response.user,
                    reason,
                    type,
                    duration,
                    silent,
                    auto,
                    offrecord
                );
            }
        );
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:25,代码来源:PunishmentCommands.java


示例5: skipto

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的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));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:22,代码来源:AdminCommands.java


示例6: maplist

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的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 */);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:19,代码来源:MapCommands.java


示例7: force

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的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);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:24,代码来源:TeamCommands.java


示例8: shuffle

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
@Command(
    aliases = {"shuffle"},
    desc = "Shuffle the teams",
    min = 0,
    max = 0
)
@CommandPermissions("pgm.team.shuffle")
public void shuffle(CommandContext args, CommandSender sender) throws CommandException {
    TeamMatchModule tmm = utils.module();
    Match match = tmm.getMatch();

    if(match.isRunning()) {
        throw new CommandException(Translations.get().t("command.team.shuffle.matchRunning", sender));
    } else {
        List<Team> teams = new ArrayList<>(this.teams);
        List<MatchPlayer> participating = new ArrayList<>(match.getParticipatingPlayers());
        Collections.shuffle(participating);
        for(int i = 0; i < participating.size(); i++) {
            tmm.forceJoin(participating.get(i), teams.get((i * teams.size()) / participating.size()));
        }
        match.sendMessage(new TranslatableComponent("command.team.shuffle.success"));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:24,代码来源:TeamCommands.java


示例9: throwError

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
@Command(
    aliases = "throw",
    desc = "Throw a test RuntimeException",
    usage = "[message]",
    flags = "tr",
    min = 0,
    max = 1
)
@CommandPermissions(Permissions.DEVELOPER)
public void throwError(CommandContext args, CommandSender sender) throws CommandException {
    if(args.hasFlag('r')) {
        Logger.getLogger("").severe("Test root logger error from " + sender.getName());
    } else if(args.hasFlag('t')) {
        scheduler.createTask(() -> {
            throwError(args, sender, "task");
        });
    } else {
        throwError(args, sender, "command");
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:21,代码来源:DebugCommands.java


示例10: inventory

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的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");
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:18,代码来源:InventoryCommands.java


示例11: loadNewMaps

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
@Command(
    aliases = {"loadnewmaps", "findnewmaps", "newmaps"},
    desc = "Scan for new maps and load them",
    min = 0,
    max = 0
)
@CommandPermissions("pgm.loadnewmaps")
public void loadNewMaps(CommandContext args, CommandSender sender) throws CommandException {
    final Audience audience = audiences.get(sender);
    audience.sendMessage(new Component(new TranslatableComponent("command.loadNewMaps.loading"), ChatColor.WHITE));
    // Clear errors for maps that failed to load, because we want to see those errors again
    mapErrorTracker.clearErrorsExcept(mapLibrary.getMaps());
    try {
        final Set<PGMMap> newMaps = matchManager.loadMapsAndRotations();

        if(newMaps.isEmpty()) {
            audience.sendMessage(new Component(new TranslatableComponent("command.loadNewMaps.noNewMaps"), ChatColor.WHITE));
        } else if(newMaps.size() == 1) {
            audience.sendMessage(new Component(new TranslatableComponent("command.loadNewMaps.foundSingleMap", new Component(newMaps.iterator().next().getInfo().name, ChatColor.YELLOW)), ChatColor.WHITE));
        } else {
            audience.sendMessage(new Component(new TranslatableComponent("command.loadNewMaps.foundMultipleMaps", new Component(Integer.toString(newMaps.size()), ChatColor.AQUA)), ChatColor.WHITE));
        }
    } catch(MapNotFoundException e) {
        audience.sendWarning(new TranslatableComponent("command.loadNewMaps.noMaps"), false);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:27,代码来源:MapDevelopmentCommands.java


示例12: featureCommand

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的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.");
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:MapDevelopmentCommands.java


示例13: pushMaps

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
@Command(
    aliases = {"pushmaps"},
    desc = "Synchronizes ALL loaded maps with the database",
    min = 0,
    max = 0
)
@CommandPermissions(Permissions.DEVELOPER)
public void pushMaps(CommandContext args, final CommandSender sender) throws CommandException {
    Audience audience = audiences.get(sender);
    audience.sendMessage(new Component("Pushing " + mapLibrary.getMaps().size() + " maps..."));

    syncExecutor.callback(
        mapLibrary.pushAllMaps(),
        CommandFutureCallback.onSuccess(sender, args, response ->
            audience.sendMessage(new Component(response.toString()))
        )
    );
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:19,代码来源:MapDevelopmentCommands.java


示例14: setCompletion

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
public void setCompletion(CommandContext args, CommandSender sender, Destroyable destroyable, String value) throws CommandException {
    assertEditPerms(sender);

    Double completion;
    Integer breaks;

    if(value.endsWith("%")) {
        completion = Double.parseDouble(value.substring(0, value.length() - 1)) / 100d;
        breaks = null;
    } else {
        completion = null;
        breaks = Integer.parseInt(value);
    }

    try {
        if(completion != null) {
            destroyable.setDestructionRequired(completion);
        }
        else if(breaks != null) {
            destroyable.setBreaksRequired(breaks);
        }
    } catch(IllegalArgumentException e) {
        throw new CommandException(e.getMessage());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:26,代码来源:DestroyableCommands.java


示例15: freeze

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
@Command(
    aliases = { "freeze", "f" },
    usage = "<player>",
    desc = "Freeze a player",
    min = 1,
    max = 1
)
@CommandPermissions(Freeze.PERMISSION)
public void freeze(final CommandContext args, final CommandSender sender) throws CommandException {
    if(!freeze.enabled()) {
        throw new ComponentCommandException(new TranslatableComponent("command.freeze.notEnabled"));
    }

    executor.callback(
        userFinder.findLocalPlayer(sender, args, 0),
        CommandFutureCallback.onSuccess(sender, args, response -> freeze.toggleFrozen(sender, response.player()))
    );
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:19,代码来源:FreezeCommands.java


示例16: start

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
@Command(
    aliases = {"on", "start"},
    desc = "Start logging packets",
    min = 0,
    max = 1
)
public void start(CommandContext args, CommandSender sender) throws CommandException {
    if(sender instanceof Player || args.argsLength() >= 1) {
        final Player player = (Player) getCommandSenderOrSelf(args, sender, 0);
        if(PacketTracer.start(player, Bukkit.getLogger())) {
            sender.sendMessage("Started packet trace for " + player.getName(sender));
        }
    } else if(traceAll.compareAndSet(false, true)) {
        onlinePlayers.all().forEach(player -> PacketTracer.start(player, Bukkit.getLogger()));
        sender.sendMessage("Started global packet trace");
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:18,代码来源:TraceCommands.java


示例17: beginVote

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
@Command(
        aliases = {"beginvote", "startvote"},
        desc = "Begins a map selection vote.",
        min = 0,
        max = 0,
        flags = "ct:"
)
@Console
@CommandPermissions("tourney.map.beginvote")
public void beginVote(CommandContext args, CommandSender sender) throws CommandException {
    if (!tourney.getState().equals(TourneyState.ENABLED_WAITING_FOR_READY)) {
        throw new CommandException("This match is not in a state that is eligible for map selection.");
    } else if (voteContext.voteInProgress()) {
        throw new CommandException("There is already a map selection vote in progress.");
    } else if (!args.hasFlag('c')) {
        throw new CommandException("Re-run command with -c to confirm. Map selection may not be ended pre-maturely.");
    }

    if (args.hasFlag('t')) {
        MapClassification classification = classificationManager.classificationFromSearch(args.getFlag('t'));
        if (classification == null) throw new CommandException("No classification matched query.");
        voteContext.startVote(Collections.singleton(classification));
    } else {
        voteContext.startVote(classificationManager.getClassifications());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:27,代码来源:MapSelectionCommands.java


示例18: listTeams

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
@Command(
        aliases = {"teams", "listteams"},
        desc = "Lists the teams registered for competition on this server.",
        min = 0,
        max = 1,
        usage = "[page]"
)
@Console
@CommandPermissions("tourney.listteams")
public void listTeams(final CommandContext args, final CommandSender sender) throws CommandException {
    new Paginator<team.Id>()
        .title(new TranslatableComponent("tourney.teams.title", tournamentName))
        .entries((team, index) -> teamName(team))
        .display(audiences.get(sender),
                 tournament.accepted_teams(),
                 args.getInteger(0, 1));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:18,代码来源:TeamCommands.java


示例19: invalidate

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的package包/类
@Command(
        aliases = {"invalidate", "nosave", "norecord"},
        desc = "Indicates that the current match should not be saved to the database.",
        min = 0,
        max = 0,
        flags = "c"
)
@Console
@CommandPermissions("tourney.invalidate")
public static void invalidate(final CommandContext args, final CommandSender sender) throws CommandException {
    Tourney plugin = Tourney.get();
    if (!Arrays.asList(TourneyState.ENABLED_RUNNING, TourneyState.ENABLED_FINISHED).contains(plugin.getState())) {
        throw new CommandException("This match may not be invalidated at this time.");
    }

    if (plugin.isRecordQueued()) {
        if (args.hasFlag('c')) {
            plugin.setRecordQueued(false);
            sender.sendMessage(ChatColor.YELLOW + "Match successfully invalidated.");
        } else {
            throw new CommandException("Match is eligible for invalidation. Re-run command with -c to confirm. Invalidation may not be reversed.");
        }
    } else {
        throw new CommandException("This match is not queued to be recorded.");
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:27,代码来源:TourneyCommands.java


示例20: hub

import com.sk89q.minecraft.util.commands.CommandContext; //导入依赖的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());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:20,代码来源:ServerCommands.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IntervalTree类代码示例发布时间:2022-05-22
下一篇:
Java Repository类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap