本文整理匯總了Java中org.bukkit.command.CommandSender.hasPermission方法的典型用法代碼示例。如果您正苦於以下問題:Java CommandSender.hasPermission方法的具體用法?Java CommandSender.hasPermission怎麽用?Java CommandSender.hasPermission使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.command.CommandSender
的用法示例。
在下文中一共展示了CommandSender.hasPermission方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTabComplete
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
List<String> list = Lists.newArrayList();
if (args.length != 1) {
return Lists.newArrayList();
}
list.add("info");
if (sender.hasPermission(PERMISSION)) {
list.add("enable");
list.add("disable");
}
return StringUtil.copyPartialMatches(args[args.length - 1], list, Lists.newArrayList());
}
示例2: acceptTabComplete
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
public List<String> acceptTabComplete(CommandSender sender, Arguments args) throws Exception {
String cmd = args.next();
if (cmd == null) cmd = "";
if (subCommands.containsKey(cmd)) return null; //TODO dispatch to corresponding handler method
if (subCommandClasses.containsKey(cmd))
return subCommandClasses.get(cmd).acceptTabComplete(sender, args);
List<String> arr = new ArrayList<>();
for (String s : getSubcommands()) {
if (subCommandPermission.containsKey(s)) {
if (!sender.hasPermission(subCommandPermission.get(s))) {
continue;
}
}
if (s.startsWith(cmd)) {
arr.add(s);
}
}
return arr;
}
示例3: onSetPointGUI
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@PlayerCommand(cmd="set",arg = " <player>")
public void onSetPointGUI(CommandSender sender,String args[]){
if(sender instanceof Player){
if(!sender.hasPermission("pvpaswantedmanager." + args[0])) {
sender.sendMessage(Message.getMsg("player.noPermissionMessage"));
return;
}
if(args.length <= 1){
sender.sendMessage(Message.getMsg("admin.setPointsCorrectionsMessage"));
return;
}
Player player = (Player) sender;
String playerName = args[1];
InventoryManager.openSetPlayerGui(player, playerName);
}else{
sender.sendMessage(Message.getMsg("admin.ConsoleNotMessage"));
}
}
示例4: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length < 1) {
helpArgument.onCommand(sender, command, label, args);
return true;
}
CommandArgument argument = getArgument(args[0]);
if (argument != null) {
String permission = argument.getPermission();
if (permission == null || sender.hasPermission(permission)) {
argument.onCommand(sender, command, label, args);
return true;
}
}
helpArgument.onCommand(sender, command, label, args);
return true;
}
示例5: execute
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender arg0, String arg1, String[] arg2) {
for (Method m : c.getDeclaredMethods()) {
if (m.isAnnotationPresent(Command.Subcommand.class) && CommandConstruct.match(arg2, m.getAnnotation(Command.Subcommand.class).args())) {
try {
if (m.getAnnotation(Command.Subcommand.class).permission().equals("_")) {
m.invoke(ins, arg0, arg1, arg2);
return true;
} else if (arg0.hasPermission(m.getAnnotation(Command.Subcommand.class).permission())) {
m.invoke(ins, arg0, arg1, arg2);
return true;
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {e.printStackTrace();}
}
}
arg0.sendMessage(CommandConstruct.getNoArgsMessage());
return true;
}
示例6: command
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Command(aliases = {"minecordbot", "mcb"}, usage = "do /minecordbot help", desc = "general Minecordbot commands")
public void command(@Sender CommandSender commandSender, String s) {
if (s.equalsIgnoreCase("help")) {
help(commandSender);
} else if (s.equalsIgnoreCase("reload") && commandSender.hasPermission("minecordbot.reload")) {
Minecordbot.getInstance().getMcbConfigsManager().reloadAllConfig();
Minecordbot.getInstance().getMcbConfigsManager().setupConfigurations();
commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&a[&6Minecordbot&a] Reloaded configuration!"));
} else if(s.equalsIgnoreCase("start")){
Minecordbot mcb = Minecordbot.getInstance();
if(mcb.getBot().getJda() == null) {
mcb.getBot().start();
} else {
commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&a[&6Minecordbot&a] Minecordbot already running!"));
}
} else {
help(commandSender);
}
}
示例7: execute
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public void execute(CommandSenderWrapper wrapper, CommandArguments args) {
CommandSender sender = wrapper.getSender();
String perm = annotation.perm();
if (StringUtils.isNotEmpty(perm) && !sender.hasPermission(perm)) {
throw new PermissionDeniedException(this, perm);
}
String message = null;
if (annotation.min() > args.size())
message = String.format("인자를 %d 개 이상 입력하세요. (%d 개 부족)",
annotation.min(), annotation.min() - args.size());
else if (annotation.max() < args.size())
message = String.format("인자를 %d 개 이하로 입력하세요. (%d 개 초과)",
annotation.max(), args.size() - annotation.max());
else if (!annotation.type().isValid(sender))
message = annotation.type() == CommandType.PLAYER ? "플레이어만 사용 가능합니다." :
annotation.type() == CommandType.CONSOLE ? "콘솔만 사용 가능합니다." : "사용할 수 없는 명령어입니다.";
if (message != null) {
throw new InvalidUsageException(this, ChatColor.RED + message);
}
executable.execute(wrapper, args);
}
示例8: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if(!commandSender.hasPermission("placemc.generate")) return false;
for (int x = 0; x < 1000; x++) {
for (int z = 0; z < 1000; z++) {
w.getBlockAt(x, 30, z).setType(Material.WOOL);
}
}
return true;
}
示例9: a
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
public static void a(CommandSender sender, String label, String[] args) {
if (!sender.hasPermission("kp.reload")) {
sender.sendMessage(PermissionsCommand.PREFIX + "§cSorry, but you are lacking a permission.");
return;
}
PermissionsPlugin.getPlugin(PermissionsPlugin.class).reloadConfig();
sender.sendMessage(PermissionsCommand.PREFIX + "Successfully reloaded config.");
KevsPermissions.reload();
sender.sendMessage(PermissionsCommand.PREFIX + "Successfully updated permissions data.");
}
示例10: onTabComplete
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public final List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (!sender.hasPermission(this.permission)) {
sender.sendMessage(ChatColor.RED + "You do not have permission to do that!");
return Collections.emptyList();
}
if (this.requiresPlayer && !(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command can only be used by players!");
return Collections.emptyList();
}
return this.tabCompleteLogic(sender, command, alias, args);
}
示例11: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
/**
* This is the normal Bukkit command function, intercepted here so that we don't have to deal the same
* repetitive garbage over and over.
*/
@Override
public final boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!sender.hasPermission(this.permission)) {
sender.sendMessage(ChatColor.RED + "You do not have permission to do that!");
return true;
}
if (this.requiresPlayer && !(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command can only be used by players!");
return true;
}
return this.commandLogic(sender, command, label, args);
}
示例12: wipe
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
private void wipe(CommandSender sender){
if(!sender.hasPermission("antibots.wipe")){
sendNoPermissionsMessage(sender);
return;
}
try{
MainOperator.wipe();
sender.sendMessage(Main.PLUGIN_PREFIX + "Verified players database truncated successfully");
} catch(Exception e){
sender.sendMessage(Main.PLUGIN_PREFIX + "An exception occurred while truncating database! Check console logs for more informations");
e.printStackTrace();
}
}
示例13: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (commandSender.hasPermission(this.perm)) {
commandSender.sendMessage(this.pluginPrefix + " " + this.msg);
} else {
commandSender.sendMessage(this.pluginPrefix + " " + this.permMsg);
}
return true;
}
示例14: onCommand
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
/*if (commandLabel.equalsIgnoreCase("ecupdate")) {
if (sender.hasPermission("echopet.update")) {
if (updateChecked) {
@SuppressWarnings("unused")
Updater updater = new Updater(this, 53655, this.getFile(), Updater.UpdateType.NO_VERSION_CHECK, true);
return true;
} else {
sender.sendMessage(this.prefix + ChatColor.GOLD + " An update is not available.");
return true;
}
} else {
Lang.sendTo(sender, Lang.NO_PERMISSION.toString().replace("%perm%", "echopet.update"));
return true;
}
} else */if(commandLabel.equalsIgnoreCase("echopet")){
if (sender.hasPermission("echopet.petadmin")) {
PluginDescriptionFile pdFile = this.getDescription();
sender.sendMessage(ChatColor.RED + "-------- EchoPet --------");
sender.sendMessage(ChatColor.GOLD + "Author: " + ChatColor.YELLOW + "DSH105, Borlea");
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.YELLOW + pdFile.getVersion());
sender.sendMessage(ChatColor.GOLD + "Website: " + ChatColor.YELLOW + pdFile.getWebsite());
sender.sendMessage(ChatColor.GOLD + "Commands are registered at runtime to provide you with more dynamic control over the command labels.");
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.UNDERLINE + "Command Registration:");
sender.sendMessage(ChatColor.GOLD + "Main: " + EchoPetPlugin.OPTIONS.getCommandString());
sender.sendMessage(ChatColor.GOLD + "Admin: " + EchoPetPlugin.OPTIONS.getCommandString() + "admin");
} else {
Lang.sendTo(sender, Lang.NO_PERMISSION.toString().replace("%perm%", "echopet.petadmin"));
return true;
}
}
return false;
}
示例15: onSetPoint
import org.bukkit.command.CommandSender; //導入方法依賴的package包/類
@PlayerCommand(cmd="setPoint",arg = " <player> <value>")
public void onSetPoint(CommandSender sender,String args[]){
if(sender instanceof Player){
if(!sender.hasPermission("pvpaswantedmanager." + args[0])) {
sender.sendMessage(Message.getMsg("player.noPermissionMessage"));
return;
}
}
if(args.length <3){
sender.sendMessage(Message.getMsg("admin.wrongFormatMessage"));
return;
}
YamlConfiguration PlayerData = onLoadData(args[1]);
if(PlayerData == null){
sender.sendMessage(Message.getMsg("admin.playerNullMessage"));
return;
}
if(!Pattern.compile("[0-9]*").matcher(args[2]).matches()){
sender.sendMessage(Message.getMsg("admin.wrongFormatMessage"));
return;
}
int value = Integer.valueOf(args[2]);
if(PlayerData.getInt("wanted.points")==0&& value > 0){
PVPAsWantedManager.onCreateList(args[1], "WantedList");
}else if(PlayerData.getInt("wanted.points")>0 && value ==0){
PVPAsWantedManager.onDeleteList(args[1], "WantedList");
}
PlayerData.set("wanted.points", value);
PVPAsWantedManager.onSaveData(args[1], PlayerData);
sender.sendMessage(Message.getMsg("admin.EditPlayerDataMessage"));
}