當前位置: 首頁>>代碼示例>>Java>>正文


Java CommandSender類代碼示例

本文整理匯總了Java中cn.nukkit.command.CommandSender的典型用法代碼示例。如果您正苦於以下問題:Java CommandSender類的具體用法?Java CommandSender怎麽用?Java CommandSender使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CommandSender類屬於cn.nukkit.command包,在下文中一共展示了CommandSender類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }

    if (args.length != 1) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));

        return false;
    }

    String value = args[0];

    if (Pattern.matches("^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$", value)) {
        sender.getServer().getIPBans().remove(value);
        sender.getServer().getNetwork().unblockAddress(value);

        Command.broadcastCommandMessage(sender, new TranslationContainer("commands.unbanip.success", value));
    } else {

        sender.sendMessage(new TranslationContainer("commands.unbanip.invalid"));
    }

    return true;
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:27,代碼來源:PardonIpCommand.java

示例2: PlayerChatEvent

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
public PlayerChatEvent(Player player, String message, String format, Set<CommandSender> recipients) {
    this.player = player;
    this.message = message;

    this.format = format;

    if (recipients == null) {
        for (Permissible permissible : Server.getInstance().getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_USERS)) {
            if (permissible instanceof CommandSender) {
                this.recipients.add((CommandSender) permissible);
            }
        }

    } else {
        this.recipients = recipients;
    }
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:18,代碼來源:PlayerChatEvent.java

示例3: execute

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }

    Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.start"));

    for (Player player : sender.getServer().getOnlinePlayers().values()) {
        player.save();
    }

    for (Level level : sender.getServer().getLevels().values()) {
        level.save(true);
    }

    Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.success"));
    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:20,代碼來源:SaveCommand.java

示例4: execute

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }

    if (args.length == 0) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));

        return false;
    }

    String playerName = args[0];
    IPlayer player = sender.getServer().getOfflinePlayer(playerName);
    player.setOp(false);

    if (player instanceof Player) {
        ((Player) player).sendMessage(new TranslationContainer(TextFormat.GRAY + "%commands.deop.message"));
    }

    Command.broadcastCommandMessage(sender, new TranslationContainer("commands.deop.success", new String[]{player.getName()}));

    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:25,代碼來源:DeopCommand.java

示例5: execute

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }
    String online = "";
    int onlineCount = 0;
    for (Player player : sender.getServer().getOnlinePlayers().values()) {
        if (player.isOnline() && (!(sender instanceof Player) || ((Player) sender).canSee(player))) {
            online += player.getDisplayName() + ", ";
            ++onlineCount;
        }
    }

    if (online.length() > 0) {
        online = online.substring(0, online.length() - 2);
    }

    sender.sendMessage(new TranslationContainer("commands.players.list",
            new String[]{String.valueOf(onlineCount), String.valueOf(sender.getServer().getMaxPlayers())}));
    sender.sendMessage(online);
    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:24,代碼來源:ListCommand.java

示例6: execute

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }
    if (args.length == 0) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", new String[]{this.usageMessage}));
        return false;
    }
    int gameMode = Server.getGamemodeFromString(args[0]);
    if (gameMode != -1) {
        sender.getServer().setPropertyInt("gamemode", gameMode);
        sender.sendMessage(new TranslationContainer("commands.defaultgamemode.success", new String[]{Server.getGamemodeString(gameMode)}));
    } else {
        sender.sendMessage("Unknown game mode"); //
    }
    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:19,代碼來源:DefaultGamemodeCommand.java

示例7: execute

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
    if(!this.testPermission(sender)) {
        return true;
    }
    if (this.plugin.getCustomName().containsKey(sender.getName())) {
        this.plugin.getCustomName().remove(sender.getName());
        sender.sendMessage(TextFormat.GRAY + "[ChestLocker] 以退出設置箱子自定義名字");
    } else {
        StringBuilder sb = new StringBuilder();
        if (args.length > 0) {
            for(int i = 0 ; i < args.length ; i++){
                sb.append(args[i]);
                if(i != args.length-1) {
                    sb.append(" ");
                }
            }
        }else{
            sb.append(sender.getName()).append("的箱子");
        }
        this.plugin.getCustomName().put(sender.getName(), sb.toString());
        sender.sendMessage(TextFormat.GREEN + "[ChestLocker] 請點擊你需要自定義名字的箱子,點擊之後係統將扣除500金幣並修改這個箱子的名字(如果箱子屬於你),取消請再次輸入命令");
    }
    return true;
}
 
開發者ID:zzz1999,項目名稱:ChestLocker,代碼行數:26,代碼來源:ChestCustom.java

示例8: execute

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }

    if (args.length == 0) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));

        return false;
    }

    String playerName = args[0];
    IPlayer player = sender.getServer().getOfflinePlayer(playerName);
    player.setOp(false);

    if (player instanceof Player) {
        ((Player) player).sendMessage(TextFormat.GRAY + "You are no longer op!");
    }

    Command.broadcastCommandMessage(sender, new TranslationContainer("commands.deop.success", new String[]{player.getName()}));

    return true;
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:25,代碼來源:DeopCommand.java

示例9: execute

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
public boolean execute(CommandSender sender, String label, String[] args){
    if(sender.isOp()){
        if(args.length < 1 || !sender.isPlayer()){
            sender.sendMessage("參數錯誤(/logloc [int]) 或 來自控製台的命令");
            return false;
        }
        int a = Integer.parseInt(args[0]);
        if(a < 0 || a > 3){
            sender.sendMessage("參數錯誤([登錄1][公告2][隱藏彩蛋3][跳躍彩蛋4])");
            return false;
        }
        main.currentButton = a;
        sender.sendMessage("§a綁定成功 : " + Login.getButton(a));
        return true;
    }else{
        sender.sendMessage("§c不合法的指令");
        return false;
    }
}
 
開發者ID:azon0320,項目名稱:Nukkit-LoginFrame,代碼行數:20,代碼來源:Login.java

示例10: execute

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
    if(!this.testPermission(sender)) {
        return true;
    }
    if(args.length == 1){
        String invite = args[0];
        if(this.plugin.getUnshareSetting().containsKey(sender.getName())){
            this.plugin.getUnshareSetting().remove(sender.getName());
            sender.sendMessage(TextFormat.GRAY+"[ChestLocker] 你已退出設置箱子取消共享狀態");
        }else{
            this.plugin.getUnshareSetting().put(sender.getName(),invite);
            sender.sendMessage(TextFormat.YELLOW+"[ChestLocker] 你希望取消箱子對"+invite+"的共享嗎,確認請點擊想要取消分享的箱子,取消請重新輸入此命令");


        }
    }else if (args.length == 0){
        if(this.plugin.getUnshareSetting().containsKey(sender.getName())){
            this.plugin.getUnshareSetting().remove(sender.getName());
            sender.sendMessage(TextFormat.GRAY+"[ChestLocker] 你已退出設置箱子取消共享狀態");
        }else{
            sender.sendMessage(TextFormat.YELLOW+"[ChestLocker] 用法"+this.getUsage());
        }
    }
    return true;
}
 
開發者ID:zzz1999,項目名稱:ChestLocker,代碼行數:27,代碼來源:ChestUnshare.java

示例11: onCommand

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    for (String cmd : getDescription().getCommands().keySet()) {
        if (command.getName().equalsIgnoreCase(cmd)) {
            if (args.length > 0) {
                List<String> subCmdArgs = new ArrayList<>(Arrays.asList(args));
                subCmdArgs.remove(0);
                for (Cmd subCmd : subCmds) {
                    if (subCmd.getCommand().equalsIgnoreCase(args[0])) {
                        subCmd.run(sender, subCmdArgs.toArray(new String[subCmdArgs.size()]));
                        return true;
                    }
                }
                sendHelp(sender);
            } else {
                sendHelp(sender);
            }
            return true;
        }
    }
    return false;
}
 
開發者ID:MinecraftMarket,項目名稱:MinecraftMarket-Plugin,代碼行數:23,代碼來源:MCMarket.java

示例12: execute

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }

    long seed;
    if (sender instanceof Player) {
        seed = ((Player) sender).getLevel().getSeed();
    } else {
        seed = sender.getServer().getDefaultLevel().getSeed();
    }

    sender.sendMessage(new TranslationContainer("commands.seed.success", String.valueOf(seed)));

    return true;
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:18,代碼來源:SeedCommand.java

示例13: execute

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
    if(!this.testPermission(sender)) {
        return true;
    }
    if(args.length >= 1){
        String invite = args[0];
        if(this.plugin.getShareSetting().containsKey(sender.getName())){
            this.plugin.getShareSetting().remove(sender.getName());
            sender.sendMessage(TextFormat.GRAY+"[ChestLocker] 你已退出設置箱子共享狀態");
        }else{
            this.plugin.getShareSetting().put(sender.getName(),invite);
            sender.sendMessage(TextFormat.YELLOW+"[ChestLocker] 你希望與"+invite+"一起分享箱子嗎,確認請點擊想要分享的箱子,取消請重新輸入此命令");


        }
    }else if (args.length == 0){
        if(this.plugin.getShareSetting().containsKey(sender.getName())){
            this.plugin.getShareSetting().remove(sender.getName());
            sender.sendMessage(TextFormat.GRAY+"[ChestLocker] 你已退出設置箱子共享狀態");
        }else{
            sender.sendMessage(TextFormat.YELLOW+"[ChestLocker] "+this.getUsage());
        }
    }
    return true;
}
 
開發者ID:zzz1999,項目名稱:ChestLocker,代碼行數:27,代碼來源:ChestShare.java

示例14: broadcast

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
public int broadcast(TextContainer message, String permissions) {
    Set<CommandSender> recipients = new HashSet<>();

    for (String permission : permissions.split(";")) {
        for (Permissible permissible : this.pluginManager.getPermissionSubscriptions(permission)) {
            if (permissible instanceof CommandSender && permissible.hasPermission(permission)) {
                recipients.add((CommandSender) permissible);
            }
        }
    }

    for (CommandSender recipient : recipients) {
        recipient.sendMessage(message);
    }

    return recipients.size();
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:18,代碼來源:Server.java

示例15: broadcastImportantMessage

import cn.nukkit.command.CommandSender; //導入依賴的package包/類
public int broadcastImportantMessage(String message, String permissions) {
    Set<CommandSender> recipients = new HashSet<>();

    for (String permission : permissions.split(";")) {
        for (Permissible permissible : this.pluginManager.getPermissionSubscriptions(permission)) {
            if (permissible instanceof CommandSender && permissible.hasPermission(permission)) {
                recipients.add((CommandSender) permissible);
            }
        }
    }

    for (CommandSender recipient : recipients) {
        recipient.sendImportantMessage(message);
    }

    return recipients.size();
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:18,代碼來源:Server.java


注:本文中的cn.nukkit.command.CommandSender類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。