當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。