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


Java Command.broadcastCommandMessage方法代碼示例

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


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

示例1: execute

import cn.nukkit.command.Command; //導入方法依賴的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

示例2: execute

import cn.nukkit.command.Command; //導入方法依賴的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

示例3: execute

import cn.nukkit.command.Command; //導入方法依賴的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;
    }

    sender.getServer().getNameBans().remove(args[0]);

    Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.unban.success", args[0]));

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

示例4: execute

import cn.nukkit.command.Command; //導入方法依賴的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:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:25,代碼來源:DeopCommand.java

示例5: execute

import cn.nukkit.command.Command; //導入方法依賴的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;
    }

    int difficulty = Server.getDifficultyFromString(args[0]);

    if (sender.getServer().isHardcore()) {
        difficulty = 3;
    }

    if (difficulty != -1) {
        sender.getServer().setPropertyInt("difficulty", difficulty);

        SetDifficultyPacket pk = new SetDifficultyPacket();
        pk.difficulty = sender.getServer().getDifficulty();
        Server.broadcastPacket(new ArrayList<>(sender.getServer().getOnlinePlayers().values()), pk);

        Command.broadcastCommandMessage(sender, new TranslationContainer("commands.difficulty.success", String.valueOf(difficulty)));
    } else {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));

        return false;
    }

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

示例6: execute

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

    Command.broadcastCommandMessage(sender, new TranslationContainer(TextFormat.YELLOW + "%nukkit.command.reload.reloading" + TextFormat.WHITE));

    sender.getServer().reload();

    Command.broadcastCommandMessage(sender, new TranslationContainer(TextFormat.YELLOW + "%nukkit.command.reload.reloaded" + TextFormat.WHITE));

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

示例7: execute

import cn.nukkit.command.Command; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }
    sender.getServer().setAutoSave(true);
    Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.enabled"));
    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:10,代碼來源:SaveOnCommand.java

示例8: execute

import cn.nukkit.command.Command; //導入方法依賴的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 name = args[0];
    String reason = "";
    for (int i = 1; i < args.length; i++) {
        reason += args[i] + " ";
    }

    if (reason.length() > 0) {
        reason = reason.substring(0, reason.length() - 1);
    }

    sender.getServer().getNameBans().addBan(name, reason, null, sender.getName());

    Player player = sender.getServer().getPlayerExact(name);
    if (player != null) {
        player.kick(PlayerKickEvent.Reason.NAME_BANNED, !reason.isEmpty() ? "Banned by admin. Reason: " + reason : "Banned by admin");
    }

    Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.ban.success", player != null ? player.getName() : name));

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

示例9: execute

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

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

    sender.getServer().shutdown();

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

示例10: execute

import cn.nukkit.command.Command; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }
    if (args.length < 2) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return true;
    }
    Player player = sender.getServer().getPlayer(args[0]);
    if (player == null) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
        return true;
    }
    int enchantId;
    int enchantLevel;
    try {
        enchantId = getIdByName(args[1]);
        enchantLevel = args.length == 3 ? Integer.parseInt(args[2]) : 1;
    } catch (NumberFormatException e) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return true;
    }
    Enchantment enchantment = Enchantment.getEnchantment(enchantId);
    if (enchantment == null) {
        sender.sendMessage(new TranslationContainer("commands.enchant.notFound", String.valueOf(enchantId)));
        return true;
    }
    enchantment.setLevel(enchantLevel);
    Item item = player.getInventory().getItemInHand();
    if (item.getId() <= 0) {
        sender.sendMessage(new TranslationContainer("commands.enchant.noItem"));
        return true;
    }
    item.addEnchantment(enchantment);
    player.getInventory().setItemInHand(item);
    Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.enchant.success"));
    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:40,代碼來源:EnchantCommand.java

示例11: execute

import cn.nukkit.command.Command; //導入方法依賴的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 name = args[0];

    String reason = "";
    for (int i = 1; i < args.length; i++) {
        reason += args[i] + " ";
    }

    if (reason.length() > 0) {
        reason = reason.substring(0, reason.length() - 1);
    }

    Player player = sender.getServer().getPlayer(name);
    if (player != null) {
        player.kick(PlayerKickEvent.Reason.KICKED_BY_ADMIN, reason);
        if (reason.length() >= 1) {
            Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success.reason", new String[]{player.getName(), reason})
            );
        } else {
            Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success", player.getName()));
        }
    } else {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
    }

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

示例12: execute

import cn.nukkit.command.Command; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }
    sender.getServer().setAutoSave(false);
    Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.disabled"));
    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:10,代碼來源:SaveOffCommand.java

示例13: execute

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

    if (args.length == 0 || args.length > 2) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return true;
    }

    if (args.length == 1) {
        if (this.badPerm(sender, args[0].toLowerCase())) {
            return false;
        }
        switch (args[0].toLowerCase()) {
            case "reload":
                sender.getServer().reloadWhitelist();
                Command.broadcastCommandMessage(sender, new TranslationContainer("commands.whitelist.reloaded"));

                return true;
            case "on":
                sender.getServer().setPropertyBoolean("white-list", true);
                Command.broadcastCommandMessage(sender, new TranslationContainer("commands.whitelist.enabled"));

                return true;
            case "off":
                sender.getServer().setPropertyBoolean("white-list", false);
                Command.broadcastCommandMessage(sender, new TranslationContainer("commands.whitelist.disabled"));

                return true;
            case "list":
                String result = "";
                int count = 0;
                for (String player : sender.getServer().getWhitelist().getAll().keySet()) {
                    result += player + ", ";
                    ++count;
                }
                sender.sendMessage(new TranslationContainer("commands.whitelist.list", new String[]{String.valueOf(count), String.valueOf(count)}));
                sender.sendMessage(result.length() > 0 ? result.substring(0, result.length() - 2) : "");

                return true;

            case "add":
                sender.sendMessage(new TranslationContainer("commands.generic.usage", "%commands.whitelist.add.usage"));
                return true;

            case "remove":
                sender.sendMessage(new TranslationContainer("commands.generic.usage", "%commands.whitelist.remove.usage"));
                return true;
        }
    } else if (args.length == 2) {
        if (this.badPerm(sender, args[0].toLowerCase())) {
            return false;
        }
        switch (args[0].toLowerCase()) {
            case "add":
                sender.getServer().getOfflinePlayer(args[1]).setWhitelisted(true);
                Command.broadcastCommandMessage(sender, new TranslationContainer("commands.whitelist.add.success", args[1]));

                return true;
            case "remove":
                sender.getServer().getOfflinePlayer(args[1]).setWhitelisted(false);
                Command.broadcastCommandMessage(sender, new TranslationContainer("commands.whitelist.remove.success", args[1]));

                return true;
        }
    }

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


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