当前位置: 首页>>代码示例>>Java>>正文


Java Command类代码示例

本文整理汇总了Java中org.bukkit.command.Command的典型用法代码示例。如果您正苦于以下问题:Java Command类的具体用法?Java Command怎么用?Java Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Command类属于org.bukkit.command包,在下文中一共展示了Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCommand

import org.bukkit.command.Command; //导入依赖的package包/类
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
    if (command.getName().equals("luaplugins")) {
        if (!commandSender.hasPermission("lukkitplus.listpl")) {
            commandSender.sendMessage(ChatColor.RED + "Sorry, you don't have permission.");
            return true;
        }
        StringBuilder pluginSentence = new StringBuilder();
        int index = 0;
        for (LuaPlugin plugin : Environment.PLUGINS) {
            if (index != (Environment.PLUGINS.size() - 1)) {
                pluginSentence.append(plugin.getName() + ", ");
            } else {
                pluginSentence.append(plugin.getName() + "");
            }
            index++;
        }
        commandSender.sendMessage("Plugins: " + ChatColor.GREEN + pluginSentence.toString());
        return true;
    }
    return false;
}
 
开发者ID:LukkitPlus,项目名称:Lukkit,代码行数:23,代码来源:CommandPluginList.java

示例2: onCommand

import org.bukkit.command.Command; //导入依赖的package包/类
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
    if (args.length < 1) {
        sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playerName>");
        return true;
    }
    final OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[0] + ChatColor.GOLD + "' not found.");
        return true;
    }
    final UUID targetUUID = target.getUniqueId();
    final FactionUser factionTarget = HCF.getPlugin().getUserManager().getUser(targetUUID);
    final Deathban deathban = factionTarget.getDeathban();
    if (deathban == null || !deathban.isActive()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned.");
        return true;
    }
    factionTarget.removeDeathban();
    Command.broadcastCommandMessage(sender, ChatColor.LIGHT_PURPLE + "A staff has revived " + target.getName() + ".");
    return false;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:22,代码来源:ReviveCommand.java

示例3: onTabComplete

import org.bukkit.command.Command; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
    if (args.length != 2) {
        return Collections.emptyList();
    }

    List<String> results = new ArrayList<>();
    Collection<FactionUser> factionUsers = plugin.getUserManager().getUsers().values();
    for (FactionUser factionUser : factionUsers) {
        Deathban deathban = factionUser.getDeathban();
        if (deathban == null || !deathban.isActive())
            continue;

        OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID());
        String offlineName = offlinePlayer.getName();
        if (offlineName != null) {
            results.add(offlinePlayer.getName());
        }
    }

    return results;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:23,代码来源:LivesReviveArgument.java

示例4: onTabComplete

import org.bukkit.command.Command; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
    if (args.length != 2 || !(sender instanceof Player)) {
        return Collections.emptyList();
    }

    Player player = (Player) sender;
    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
    if (playerFaction == null) {
        return Collections.emptyList();
    }

    List<String> results = new ArrayList<>();
    for (Player target : Bukkit.getOnlinePlayers()) {
        if (!target.equals(player) && player.canSee(target) && !results.contains(target.getName())) {
            Faction targetFaction = plugin.getFactionManager().getPlayerFaction(target);
            if (targetFaction != null && playerFaction != targetFaction) {
                if (playerFaction.getRequestedRelations().get(targetFaction.getUniqueID()) != RELATION && playerFaction.getRelations().get(targetFaction.getUniqueID()) != RELATION) {
                    results.add(targetFaction.getName());
                }
            }
        }
    }

    return results;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:27,代码来源:FactionAllyArgument.java

示例5: onCommand

import org.bukkit.command.Command; //导入依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	if (args.length == 0) return false;
	
	String recipeType = args[0];
	List<? extends Recipe> recipes = recipesByTypeMapper.apply(recipeType);
	
	if (recipes == null) {
		sender.sendMessage(ChatColor.RED + "Unknown recipe type: " + recipeType);
		return true;
	} else if (recipes.isEmpty()) {
		sender.sendMessage(ChatColor.RED + "No recipes found for type: " + recipeType);
		return true;
	}
	
	return sender instanceof Player ? listPlayer((Player) sender, recipeType, recipes) : listSender(sender, recipeType, recipes);
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:18,代码来源:ListRecipesCommandExecutor.java

示例6: onTabComplete

import org.bukkit.command.Command; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
    if (args.length != 1) {
        return Collections.emptyList();
    }

    List<String> results = new ArrayList<>();
    for (FactionUser factionUser : plugin.getUserManager().getUsers().values()) {
        Deathban deathban = factionUser.getDeathban();
        if (deathban != null && deathban.isActive()) {
            OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID());
            String name = offlinePlayer.getName();
            if (name != null) {
                results.add(name);
            }
        }
    }

    return BukkitUtils.getCompletions(args, results);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:21,代码来源:StaffReviveCommand.java

示例7: onCommand

import org.bukkit.command.Command; //导入依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
	if (!sender.hasPermission("protocolsupport.admin")) {
		sender.sendMessage(ChatColor.DARK_RED + "You have no power here!");
		return true;
	}
	if (args.length == 0) {
		sender.sendMessage(ChatColor.DARK_PURPLE + "ProtocolSupportPocketStuff");
		sender.sendMessage(ChatColor.GRAY + "/psps reloadpacks");
		return true;
	}
	SubCommand subcommand = subcommands.get(args[0]);
	if (subcommand == null) {
		return false;
	}
	String[] subcommandargs = Arrays.copyOfRange(args, 1, args.length);
	if (subcommandargs.length < subcommand.getMinArgs()) {
		sender.sendMessage(ChatColor.DARK_RED + "Not enough args");
		return true;
	}
	return subcommand.handle(sender, subcommandargs);
}
 
开发者ID:ProtocolSupport,项目名称:ProtocolSupportPocketStuff,代码行数:23,代码来源:CommandHandler.java

示例8: onTabComplete

import org.bukkit.command.Command; //导入依赖的package包/类
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) {
    if (args.length != 1) {
        return Collections.emptyList();
    }
    final List<String> results = new ArrayList<String>();
    for (final FactionUser factionUser : this.plugin.getUserManager().getUsers().values()) {
        final Deathban deathban = factionUser.getDeathban();
        if (deathban != null && deathban.isActive()) {
            final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID());
            final String name = offlinePlayer.getName();
            if (name == null) {
                continue;
            }
            results.add(name);
        }
    }
    return BukkitUtils.getCompletions(args, results);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:19,代码来源:ReviveCommand.java

示例9: getCommandTimingsByPlugin

import org.bukkit.command.Command; //导入依赖的package包/类
public static Map<String, MonitorRecord> getCommandTimingsByPlugin(Plugin plg) {
	Map<String, MonitorRecord> record = new HashMap<>();
	if (plg == null) {
		return record;
	}
	try {
		SimpleCommandMap simpleCommandMap = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(Bukkit.getPluginManager());
		for (Command command : simpleCommandMap.getCommands()) {
			if (command instanceof PluginCommand) {
				PluginCommand pluginCommand = (PluginCommand) command;
				if (plg.equals(pluginCommand.getPlugin())) {
					FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class, "executor", CommandExecutor.class);
					CommandExecutor executor = commandField.get(pluginCommand);
					if (executor instanceof CommandInjector) {
						CommandInjector commandInjector = (CommandInjector) executor;
						record = mergeRecordMap(record, commandInjector.getMonitorRecordMap());
					}

				}
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return record;
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:27,代码来源:MonitorUtils.java

示例10: onCommand

import org.bukkit.command.Command; //导入依赖的package包/类
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
 {
  Player p = (Player) sender;
  if(label.equalsIgnoreCase("stats")){
   if (args.length == 0)
   {
   openStatsGUI(p);
   
   }else if(args.length == 1){
   	Player playerStat = (Player) Bukkit.getPlayer(args[0]);
   	if(playerStat != null){
   		// openStatsGUIOtherPlayer(playerStat, p);
   	}else{
   		p.sendMessage(ChatColor.RED + args[0] + " is not a valid player. You can only view stats of online players.");
   	}
   }
return false;
     
  }
return false;
 }
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:22,代码来源:StatsGUI.java

示例11: onTabComplete

import org.bukkit.command.Command; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
	List<String> options = new ArrayList<>();
	
	// Before completion: "/dragontemplate "
	if (args.length == 1) {
		options.add("list");
		plugin.getDEDManager().getDragonTemplates().stream().map(DragonTemplate::getIdentifier).forEach(t -> options.add(t));
	}
	
	// Before completion: "/dragontemplate <template> "
	else if (args.length == 2) {
		options.add("view");
		options.add("edit");
	}
	
	else if (args.length == 3) {
		// Before completion: "/dragontemplate <template> edit "
		if (args[1].equalsIgnoreCase("edit")) {
			options.add("addloot");
			options.add("set");
		}
	}
	
	return options;
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:27,代码来源:DragonTemplateCmd.java

示例12: onCommand

import org.bukkit.command.Command; //导入依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
    Plugin plugin = getServer().getPluginManager().getPlugin("MeerChat");
    Player senderPlayer = getServer().getPlayer(sender.getName());

    // If the command was completed by the user.
    if (senderPlayer != null) {
        senderPlayer.sendMessage("§o[MeerChat is being reloaded - " + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()) + "]§o");

        restartPlugin(plugin);

        senderPlayer.sendMessage("§o[MeerChat has been reloaded - " + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()) + "]§o");
    }

    // If the command was completed by the console.
    else {
        Bukkit.broadcastMessage("[Server] §o[MeerChat is being reloaded - " + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()) + "]§o");

        restartPlugin(plugin);

        Bukkit.broadcastMessage("[Server] §o[MeerChat has been reloaded - " + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()) + "]§o");
    }

    return true;
}
 
开发者ID:maxwenger,项目名称:MeerChat,代码行数:26,代码来源:PlayerCommandListener.java

示例13: onCommand

import org.bukkit.command.Command; //导入依赖的package包/类
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
    if(s.equalsIgnoreCase("spec")) {
        if(!(commandSender instanceof Player)) {
            commandSender.sendMessage(ChatColor.RED + "You must be a player to execute this command.");
            return false;
        }
        Player player = (Player) commandSender;
        ArcadiaAPI api = Arcadia.getPlugin(Arcadia.class).getAPI();
        api.getGameManager().setSpectating(player, !api.getGameManager().isSpectating(player));
        if(api.getGameManager().isSpectating(player)) {
            api.getTranslationManager().sendTranslation("command.spec.enabled", player);
        } else {
            api.getTranslationManager().sendTranslation("command.spec.disabled", player);
        }
        if(api.getGameManager().getCurrentGame() != null) {
            if(!api.getGameManager().getCurrentGame().spectatorCache.contains(player)) {
                api.getGameManager().getCurrentGame().spectatorCache.add(player);
            }
        }
    }
    return false;
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:24,代码来源:SpectateCommand.java

示例14: onCommand

import org.bukkit.command.Command; //导入依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	Player p = (Player)sender;
	if(p.hasPermission("automessagedisplayer.setrandom")||p.isOp()) {
		if(args.length >= 1) {
			Boolean randomEnabled = Boolean.parseBoolean(args[0]);
			plugin.getConfig().set(RANDOM_CONFIG, randomEnabled);
			if(randomEnabled) {
				p.sendMessage("�2Random enabled. Do /reload");
			} else {
				p.sendMessage("�4Random disabled. Do /reload");
			}
			plugin.saveConfig();
			plugin.reloadConfig();
			return true;
		}
	}

	return false;
}
 
开发者ID:LotuxPunk,项目名称:AutoMessageDisplayer,代码行数:21,代码来源:CommandAmdRandom.java

示例15: onCommand

import org.bukkit.command.Command; //导入依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
        return true;
    }

    Faction faction = plugin.getFactionManager().getFaction(args[1]);

    if (!(faction instanceof EventFaction)) {
        sender.sendMessage(ChatColor.RED + "There is not an event faction named '" + args[1] + "'.");
        return true;
    }

    if (plugin.getTimerManager().getEventTimer().tryContesting(((EventFaction) faction), sender)) {
        sender.sendMessage(ChatColor.YELLOW + "Successfully contested " + faction.getName() + '.');
    }

    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:21,代码来源:EventStartArgument.java


注:本文中的org.bukkit.command.Command类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。