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


Java Command類代碼示例

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


Command類屬於cn.nukkit.command包,在下文中一共展示了Command類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 == 0) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return false;
    }

    String name = args[0];
    IPlayer player = sender.getServer().getOfflinePlayer(name);

    Command.broadcastCommandMessage(sender, new TranslationContainer("commands.op.success", player.getName()));
    if (player instanceof Player) {
        ((Player) player).sendMessage(new TranslationContainer(TextFormat.GRAY + "%commands.op.message"));
    }

    player.setOp(true);

    return true;
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:23,代碼來源:OpCommand.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 != 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:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:19,代碼來源:PardonCommand.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;
    }

    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:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:27,代碼來源:PardonIpCommand.java

示例6: onCommand

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

示例7: 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

示例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];
    IPlayer player = sender.getServer().getOfflinePlayer(name);

    Command.broadcastCommandMessage(sender, new TranslationContainer("commands.op.success", player.getName()));
    if (player instanceof Player) {
        ((Player) player).sendMessage(TextFormat.GRAY + "You are now op!");
    }

    player.setOp(true);

    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:23,代碼來源:OpCommand.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;
    }

    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);

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

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

    return true;
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:26,代碼來源:PardonIpCommand.java

示例10: onCommand

import cn.nukkit.command.Command; //導入依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!this.testPermission(sender)) {
        //sender.sendMessage(this.getPlugin().translateMessage("has-no-permission"));
        return true;
    }
    if (!(sender instanceof Player)) {
        sender.sendMessage(this.getPlugin().translateMessage("use-in-game"));
        return true;
    }
    sender.sendMessage(this.getPlugin().translateMessage("your-bank",
            "amount", getPlugin().getBank((Player) sender),
            "type", getPlugin().getCurrency1()
    ));
    return true;
}
 
開發者ID:Him188,項目名稱:Money,代碼行數:17,代碼來源:BankInfoCommand.java

示例11: onCommand

import cn.nukkit.command.Command; //導入依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	if (!this.testPermission(sender)) {
		//sender.sendMessage(this.getPlugin().translateMessage("has-no-permission"));
		return true;
	}
	if (!(sender instanceof Player)) {
		sender.sendMessage(this.getPlugin().translateMessage("use-in-game"));
		return true;
	}

	sender.sendMessage(this.getPlugin().translateMessage("your-money-1",
			"amount", getPlugin().getMoney((Player) sender, CurrencyType.FIRST),
			"type", getPlugin().getCurrency1()));
	return true;
}
 
開發者ID:Him188,項目名稱:Money,代碼行數:17,代碼來源:WalletInfo1Command.java

示例12: onCommand

import cn.nukkit.command.Command; //導入依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	if (!this.testPermission(sender)) {
		//sender.sendMessage(this.getPlugin().translateMessage("has-no-permission"));
		return true;
	}
	if (!(sender instanceof Player)) {
		sender.sendMessage(this.getPlugin().translateMessage("use-in-game"));
		return true;
	}

	sender.sendMessage(this.getPlugin().translateMessage("your-money-2",
			"amount", getPlugin().getMoney((Player) sender, CurrencyType.SECOND),
			"type", getPlugin().getCurrency2()));
	return true;
}
 
開發者ID:Him188,項目名稱:Money,代碼行數:17,代碼來源:WalletInfo2Command.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 < 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:CoreXDevelopment,項目名稱:CoreX,代碼行數:40,代碼來源:EnchantCommand.java

示例14: 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:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:34,代碼來源:DifficultyCommand.java

示例15: 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


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