Java Code Examples for net.minecraft.command.ICommand

The following examples show how to use net.minecraft.command.ICommand. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: TickDynamic   Source File: CommandHandler.java    License: MIT License 6 votes vote down vote up
public CommandHandler(TickDynamicMod mod) {
	this.mod = mod;
	
	aliases = new ArrayList<String>();
	aliases.add("tickdynamic");
	aliases.add("td");
	
	subCommandHandlers = new HashMap<String, ICommand>();
	subCommandHandlers.put("reload", new CommandReload(mod));
	subCommandHandlers.put("reloadgroups", new CommandReloadGroups(mod));
	subCommandHandlers.put("listworlds", new CommandListWorlds(mod));
	subCommandHandlers.put("world", new CommandWorld(mod));
	subCommandHandlers.put("enabled", new CommandEnabled(mod));
	
	StringBuilder builderSubCommands = new StringBuilder();
	SubCommands[] subs = SubCommands.values();
	for(SubCommands command : subs) {
		builderSubCommands.append(command).append(", ");
	}
	builderSubCommands.delete(builderSubCommands.length()-2, builderSubCommands.length());
	listSubCommands = builderSubCommands.toString();
}
 
Example 2
Source Project: TickDynamic   Source File: CommandHandler.java    License: MIT License 6 votes vote down vote up
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] args) {
	if(args.length == 1)
	{
		List listOut = new LinkedList();
		String lastArg = args[args.length-1];
		SubCommands[] subCommands = SubCommands.values();
		for(SubCommands command : subCommands)
		{
			if(command.toString().contains(lastArg))
				listOut.add(command.toString());
		}
		
		return listOut;
	}
	else
	{
		//Send it over to subCommand handler
		ICommand subHandler = subCommandHandlers.get(args[0]);
		if(subHandler == null)
			return null;
		return subHandler.addTabCompletionOptions(sender, args);
	}
}
 
Example 3
Source Project: Kettle   Source File: CraftServer.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void setVanillaCommands(boolean first) {
    Map<String, ICommand> commands = console.getCommandManager().getCommands();
    for (ICommand cmd : commands.values()) {
        commandMap.register("minecraft",
                new VanillaCommandWrapper((CommandBase) cmd, I18n.translateToLocal(cmd.getUsage(null))));
    }
}
 
Example 4
Source Project: TickDynamic   Source File: CommandHandler.java    License: MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) {
	if(args.length == 0)
	{
		sender.addChatMessage(new ChatComponentText("Usage: " + getCommandUsage(sender)));
		return;
	}
	
	if(args[0].equals("tps"))
	{
		
		sender.addChatMessage(new ChatComponentText("Average TPS: " + getTPSFormatted(mod) + " TPS"));
		return;
	} else if(args[0].equals("identify")) {
		sender.addChatMessage(new ChatComponentText("Command not yet implemented! This will allow you to check what group a Tile or Entity belongs to by right clicking it.(And other info, like TPS)"));
		return;
	} else if(args[0].equals("help")) {
		sender.addChatMessage(new ChatComponentText("You can find the documentation over at http://mods.stjerncraft.com/tickdynamic"));
		return;
	}
	
	//Send it over to subCommand handler
	ICommand subHandler = subCommandHandlers.get(args[0]);
	if(subHandler == null)
	{
		sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "No handler for the command " + EnumChatFormatting.ITALIC + args[0]));
		return;
	}
	subHandler.processCommand(sender, args);
}
 
Example 5
Source Project: qcraft-mod   Source File: QCraftCommand.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int compareTo( Object o )
{
    if( o instanceof ICommand )
    {
        return ((ICommand)o).getCommandName().compareTo( getCommandName() );
    }
    return 0;
}
 
Example 6
@Override
public int compareTo(Object object) {
    if (object instanceof ICommand) {
        return this.compareTo((ICommand) object);
    } else {
        return 0;
    }
}
 
Example 7
Source Project: Kettle   Source File: CommandWrapper.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public int compareTo(ICommand o) {
    return 0;
}
 
Example 8
Source Project: youtube-chat-for-minecraft   Source File: YouTubeCommand.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compareTo(ICommand o) {
  return 0;
}
 
Example 9
@Override
public int compareTo(ICommand o) {
  return 0;
}
 
Example 10
Source Project: mobycraft   Source File: MainCommand.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int compareTo(ICommand command) {
	return 0;
}
 
Example 11
Source Project: AdvancedRocketry   Source File: WorldCommand.java    License: MIT License 4 votes vote down vote up
@Override
public int compareTo(ICommand arg0) {
	return this.getName().compareTo(arg0.getName());
}
 
Example 12
Source Project: AgriCraft   Source File: CommandNbt.java    License: MIT License 4 votes vote down vote up
@Override
public int compareTo(ICommand o) {
    return ComparisonChain.start()
            .compare(this.getName(), o.getName())
            .result();
}
 
Example 13
Source Project: AgriCraft   Source File: CommandStat.java    License: MIT License 4 votes vote down vote up
@Override
public int compareTo(ICommand o) {
    return ComparisonChain.start()
            .compare(this.getName(), o.getName())
            .result();
}
 
Example 14
Source Project: AgriCraft   Source File: IProxy.java    License: MIT License 4 votes vote down vote up
@Override
default void onServerStarting(FMLServerStartingEvent event) {
    // This is to be moved to infinity lib in a future version, I would expect.
    AgriCore.getLogger("agricraft").info("Registering AgriCraft Commands.");
    ReflectionHelper.forEachValueIn(AgriCraft.instance.getModCommandRegistry(), ICommand.class, event::registerServerCommand);
}
 
Example 15
Source Project: CodeChickenCore   Source File: CoreCommand.java    License: MIT License 4 votes vote down vote up
@Override
public int compareTo(Object o) {
    return getCommandName().compareTo(((ICommand) o).getCommandName());
}
 
Example 16
Source Project: OpenModsLib   Source File: SidedCommand.java    License: MIT License 4 votes vote down vote up
@Override
public int compareTo(ICommand o) {
	return name.compareTo(o.getName());
}
 
Example 17
Source Project: OpenModsLib   Source File: CommandCalc.java    License: MIT License 4 votes vote down vote up
@Override
public int compareTo(ICommand o) {
	return name.compareTo(o.getName());
}