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


Java CommandSender.hasPermission方法代碼示例

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


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

示例1: execute

import cn.nukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String s, String[] args){
    if(!sender.hasPermission(this.getPermission())){
        sender.sendMessage(TextFormat.RED+"You don't have permission.");
        return true;
    }
    if(plugin.status != 0){
        plugin.status = 0;
        plugin.set = "";
        plugin.player = null;
        plugin.line = null;
        plugin.start = null;
        plugin.top = null;
        plugin.pos1 = null;
        plugin.pos2 = null;
        plugin.first = 0.0D;
        sender.sendMessage(TextFormat.GREEN+"成功刪除配置");
    }else{
        sender.sendMessage(TextFormat.RED+"你還未設置");
    }
    return true;
}
 
開發者ID:WetABQ,項目名稱:Nukkit-DontTapTheWhiteTile,代碼行數:23,代碼來源:DelGame.java

示例2: badPerm

import cn.nukkit.command.CommandSender; //導入方法依賴的package包/類
private boolean badPerm(CommandSender sender, String perm) {
    if (!sender.hasPermission("nukkit.command.whitelist" + perm)) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));

        return true;
    }

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

示例3: execute

import cn.nukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String s, String[] args){
    if(!sender.hasPermission(this.getPermission())){
        sender.sendMessage(TextFormat.RED+"You don't have permission.");
        return true;
    }
    if(args.length == 0){
        if(plugin.status == 0){
            plugin.set = sender.getName();
            sender.sendMessage(TextFormat.GREEN+"你已經處於設置狀態下,請先設置一個4(寬)*5(高)的方框");
        }else{
            sender.sendMessage(TextFormat.RED+"已經設置 或 你處於設置狀態");
        }
    }else if(args[0].equals("b")){
        plugin.status = 0;
        plugin.set = "";
        plugin.player = null;
        plugin.line = null;
        plugin.start = null;
        plugin.top = null;
        plugin.pos1 = null;
        plugin.pos2 = null;
        plugin.first = 0.0D;
        sender.sendMessage(TextFormat.GREEN+"成功退出設置");
    }
    return true;
}
 
開發者ID:WetABQ,項目名稱:Nukkit-DontTapTheWhiteTile,代碼行數:28,代碼來源:SetGame.java

示例4: execute

import cn.nukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (args.length == 0) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return false;
    }

    int gameMode = Server.getGamemodeFromString(args[0]);
    if (gameMode == -1) {
        sender.sendMessage("Unknown game mode");
        return true;
    }

    CommandSender target = sender;
    if (args.length > 1) {
        if (sender.hasPermission("nukkit.command.gamemode.other")) {
            target = sender.getServer().getPlayer(args[1]);
            if (target == null) {
                sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
                return true;
            }
        } else {
            sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
            return true;
        }
    } else if (!(sender instanceof Player)) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return true;
    }

    if ((gameMode == 0 && !sender.hasPermission("nukkit.command.gamemode.survival")) ||
            (gameMode == 1 && !sender.hasPermission("nukkit.command.gamemode.creative")) ||
            (gameMode == 2 && !sender.hasPermission("nukkit.command.gamemode.adventure")) ||
            (gameMode == 3 && !sender.hasPermission("nukkit.command.gamemode.spectator"))) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
        return true;
    }

    if (!((Player) target).setGamemode(gameMode)) {
        sender.sendMessage("Game mode update for " + target.getName() + " failed");
    } else {
        if (target.equals(sender)) {
            Command.broadcastCommandMessage(sender, new TranslationContainer("commands.gamemode.success.self", Server.getGamemodeString(gameMode)));
        } else {
            target.sendMessage(new TranslationContainer("gameMode.changed"));
            Command.broadcastCommandMessage(sender, new TranslationContainer("commands.gamemode.success.other", new String[]{target.getName(), Server.getGamemodeString(gameMode)}));
        }
    }

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

示例5: execute

import cn.nukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (args.length == 0) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return false;
    }

    int gameMode = Server.getGamemodeFromString(args[0]);
    if (gameMode == -1) {
        sender.sendMessage("Unknown game mode");
        return true;
    }

    CommandSender target = sender;
    if (args.length > 1) {
        if (sender.hasPermission("nukkit.command.gamemode.other")) {
            target = sender.getServer().getPlayer(args[1]);
            if (target == null) {
                sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
                return true;
            }
        } else {
            sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
            return true;
        }
    } else if (!(sender instanceof Player)) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return true;
    }

    if ((gameMode == 0 && !sender.hasPermission("nukkit.command.gamemode.survival")) ||
            (gameMode == 1 && !sender.hasPermission("nukkit.command.gamemode.creative")) ||
            (gameMode == 2 && !sender.hasPermission("nukkit.command.gamemode.adventure")) ||
            (gameMode == 3 && !sender.hasPermission("nukkit.command.gamemode.spectator"))) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
        return true;
    }

    if (!((Player) target).setGamemode(gameMode)) {
        sender.sendMessage("" + target.getName() + "のゲームモード変更に失敗しました。");
    } else {
        if (target.equals(sender)) {
            Command.broadcastCommandMessage(sender, new TranslationContainer("commands.gamemode.success.self", Server.getGamemodeString(gameMode)));
        } else {
            target.sendMessage(new TranslationContainer("gameMode.changed"));
            Command.broadcastCommandMessage(sender, new TranslationContainer("commands.gamemode.success.other", new String[]{target.getName(), Server.getGamemodeString(gameMode)}));
        }
    }

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


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