net.minecraft.command.CommandBase Java Examples

The following examples show how to use net.minecraft.command.CommandBase. 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 check out the related API usage on the sidebar.
Example #1
Source File: HyperiumCommandHandler.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @author Forge
 */
private List<String> getTabCompletionOptions(String input) {
    String[] astring = input.split(" ", -1);
    String s = astring[0];

    if (astring.length == 1) {
        return commands.keySet().stream().filter(baseCommand ->
            CommandBase.doesStringStartWith(s, baseCommand)).collect(Collectors.toList());
    } else {
        BaseCommand command = commands.get(s);

        return command != null ? command.onTabComplete(dropFirstString(astring)) : null;
    }
}
 
Example #2
Source File: CraftServer.java    From Kettle with 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 #3
Source File: KettleCommand.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException {
    if (args.length <= 1) {
        return CommandBase.getListOfStringsMatchingLastWord(args, "mods", "playermods");
    }
    return Collections.emptyList();
}
 
Example #4
Source File: CommandASHelp.java    From archimedes-ships with MIT License 5 votes vote down vote up
@Override
public void processCommand(ICommandSender icommandsender, String[] astring)
{
	icommandsender.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA.toString() + "Archimedes' Ships mod commands:"));
	for (CommandBase cb : asCommands)
	{
		icommandsender.addChatMessage(new ChatComponentText(cb.getCommandUsage(icommandsender)));
	}
}
 
Example #5
Source File: CommandRouteBiome.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute(ICommandContext context, List<String> args) {
	
	ArgumentParser ap = new ArgumentParser(args);
	
	IWorldEditor editor = context.createEditor();
	Coord pos;
	if(!ap.hasEntry(0)){
		pos = context.getPos();
	} else {
		int x; int z;
		try {
			x = CommandBase.parseInt(ap.get(0));
			z = CommandBase.parseInt(ap.get(1));
		} catch (NumberInvalidException e) {
			context.sendMessage("Failure: Invalid Coords: X Z", MessageType.ERROR);
			return;
		}
		pos = new Coord(x, 0, z);
	}
	
	context.sendMessage("Biome Information for " + pos.toString(), MessageType.SPECIAL);
	
	Biome biome = editor.getInfo(pos).getBiome();
	context.sendMessage(biome.getBiomeName(), MessageType.SPECIAL);
	
	Set<BiomeDictionary.Type> biomeTypes = BiomeDictionary.getTypes(biome);
	String types = "";
	for(BiomeDictionary.Type type : biomeTypes){
		types += type.getName() + " ";
	}
	
	context.sendMessage(types, MessageType.SPECIAL);
	return;
}
 
Example #6
Source File: CommandRouteDungeon.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
public static Coord getLocation(ICommandContext context, List<String> args) throws NumberInvalidException, PlayerNotFoundException{
	ArgumentParser ap = new ArgumentParser(args);

	Coord pos = context.getPos();
	
	if(ap.match(0, "here") || ap.match(0, "nearby")){
		return new Coord((int) pos.getX(), 0, (int) pos.getZ());
	} else {
		try {
			int x = CommandBase.parseInt(ap.get(0));
			int z = CommandBase.parseInt(ap.get(1));
			return new Coord(x, 0, z);
		} catch (NumberInvalidException e) {
			context.sendMessage("Failure: Invalid Coords: X Z", MessageType.ERROR);
			throw(e);
		}
	}
}
 
Example #7
Source File: CommandRouteBase.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
protected List<String> getListTabOptions(String name, Collection<String> possibilities){
	List<String> options = new ArrayList<String>();
	for(String item : possibilities){
		if(CommandBase.doesStringStartWith(name, item)){
			options.add(item);
		}
	}
	
	return options;
}
 
Example #8
Source File: MyEntityPlayers.java    From pycode-minecraft with MIT License 4 votes vote down vote up
public MyEntityPlayer get(MinecraftServer server, ICommandSender sender, String target) throws PlayerNotFoundException {
    return new MyEntityPlayer(CommandBase.getPlayer(server, sender, target));
}
 
Example #9
Source File: PlatformCommand.java    From YUNoMakeGoodMap with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 1)
        throw new WrongUsageException(getUsage(sender));

    String cmd = args[0].toLowerCase(Locale.ENGLISH);
    if ("list".equals(cmd))
    {
        sender.sendMessage(new TextComponentString("Known Platforms:"));
        for (ResourceLocation rl : getPlatforms())
        {
            sender.sendMessage(new TextComponentString("  " + rl.toString()));
        }
    }
    else if ("spawn".equals(cmd) || "preview".equals(cmd))
    {
        if (args.length < 2)
            throw new WrongUsageException(getUsage(sender));

        Entity ent = sender.getCommandSenderEntity();
        PlacementSettings settings = new PlacementSettings();
        WorldServer world = (WorldServer)sender.getEntityWorld();

        if (args.length >= 3)
        {
            //TODO: Preview doesnt quite work correctly with rotations....
            String rot = args[2].toLowerCase(Locale.ENGLISH);
            if ("0".equals(rot) || "none".equals(rot))
                settings.setRotation(Rotation.NONE);
            else if ("90".equals(rot))
                settings.setRotation(Rotation.CLOCKWISE_90);
            else if ("180".equals(rot))
                settings.setRotation(Rotation.CLOCKWISE_180);
            else if ("270".equals(rot))
                settings.setRotation(Rotation.COUNTERCLOCKWISE_90);
            else
                throw new WrongUsageException("Only rotations none, 0, 90, 180, and 270 allowed.");
        }

        BlockPos pos;
        if (args.length >= 6)
            pos = CommandBase.parseBlockPos(sender, args, 3, false);
        else if (ent != null)
            pos = ent.getPosition();
        else
            throw new WrongUsageException("Must specify a position if the command sender is not an entity");

        Template temp = StructureUtil.loadTemplate(new ResourceLocation(args[1]), world, true);

        BlockPos spawn = StructureUtil.findSpawn(temp, settings);
        if (spawn != null)
            pos = pos.subtract(spawn);

        if ("spawn".equals(cmd))
        {
            sender.sendMessage(new TextComponentString("Building \"" + args[1] +"\" at " + pos.toString()));
            temp.addBlocksToWorld(world, pos, settings, 2); //Push to world, with no neighbor notifications!
            world.getPendingBlockUpdates(new StructureBoundingBox(pos, pos.add(temp.getSize())), true); //Remove block updates, so that sand doesn't fall!
        }
        else
        {
            BlockPos tpos = pos.down();
            if (spawn != null)
                tpos = tpos.add(spawn);
            sender.sendMessage(new TextComponentString("Previewing \"" + args[1] +"\" at " + pos.toString()));
            world.setBlockState(tpos, Blocks.STRUCTURE_BLOCK.getDefaultState().withProperty(BlockStructure.MODE, TileEntityStructure.Mode.LOAD));
            TileEntityStructure te = (TileEntityStructure)world.getTileEntity(tpos);
            if (spawn != null)
                te.setPosition(te.getPosition().subtract(spawn));
            te.setSize(temp.getSize());
            te.setMode(Mode.LOAD);
            te.markDirty();
        }
    }
    else
        throw new WrongUsageException(getUsage(sender));
}
 
Example #10
Source File: ArchimedesShipMod.java    From archimedes-ships with MIT License 4 votes vote down vote up
private void registerASCommand(FMLServerStartingEvent event, CommandBase commandbase)
{
	event.registerServerCommand(commandbase);
	CommandASHelp.asCommands.add(commandbase);
}