net.minecraft.command.PlayerNotFoundException Java Examples

The following examples show how to use net.minecraft.command.PlayerNotFoundException. 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: DebugCommand.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] params)
{
	EntityPlayerMP player;
	try {
		player = getCommandSenderAsPlayer(sender);
	} catch (PlayerNotFoundException e) {
		return;
	}
	WorldServer world = server.worldServerForDimension(player.getEntityWorld().provider.getDimension());

	if(params.length == 1 && params[0].equalsIgnoreCase("report"))
	{
		int xM =player.getPosition().getX() >> 12;
		int zM =player.getPosition().getZ() >> 12;
		String out = "World Seed: [" + world.getSeed() + "] | IslandMap: [" +xM + "," + zM + "] | PlayerPos: [" + player.getPosition().toString() + "]";
		StringSelection selection = new StringSelection(out);
		Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
		if(clipboard != null)
			clipboard.setContents(selection, selection);

	}
}
 
Example #2
Source File: BuildContainerCommands.java    From mobycraft with Apache License 2.0 5 votes vote down vote up
@Override
public void teleport() throws PlayerNotFoundException {
	if (!(sender instanceof EntityPlayer)) {
		return;
	}

	if (boxContainers.size() < 1) {
		refreshAndBuildContainers();
		if (boxContainers.size() < 1) {
			sendErrorMessage("No containers currently existing!");
		}
	}

	if (Utils.checkIfArgIsNull(args, 0)) {
		sendErrorMessage("Container name not specified! Command is used as /docker rm <name> .");
		return;
	}

	Container container = listCommands.getFromAllWithName("/" + arg1);

	if (container == null) {
		sendErrorMessage("No container exists with the name \"" + arg1
				+ "\"");
	}

	BoxContainer boxContainer = listCommands
			.getBoxContainerWithID(container.getId());

	BlockPos pos = boxContainer.getPosition();

	getCommandSenderAsPlayer(sender).playerNetServerHandler
			.setPlayerLocation(pos.getX() + 0.5, pos.getY() + 0.5,
					pos.getZ() - 0.5, 0, 0);
}
 
Example #3
Source File: BuildContainerCommands.java    From mobycraft with Apache License 2.0 5 votes vote down vote up
@Override
public EntityPlayerMP getCommandSenderAsPlayer(ICommandSender sender)
		throws PlayerNotFoundException {
	if (sender instanceof EntityPlayerMP) {
		return (EntityPlayerMP) sender;
	} else {
		throw new PlayerNotFoundException(
				"You must specify which player you wish to perform this action on.",
				new Object[0]);
	}
}
 
Example #4
Source File: CommandBaseAdv.java    From LookingGlass with GNU General Public License v3.0 5 votes vote down vote up
public static EntityPlayerMP getTargetPlayer(ICommandSender sender, String target) {
	EntityPlayerMP entityplayermp = PlayerSelector.matchOnePlayer(sender, target);

	if (entityplayermp == null) {
		entityplayermp = MinecraftServer.getServer().getConfigurationManager().func_152612_a(target);
	}
	if (entityplayermp == null) { throw new PlayerNotFoundException(); }
	return entityplayermp;
}
 
Example #5
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 #6
Source File: MobycraftBuildContainerCommands.java    From mobycraft with Apache License 2.0 4 votes vote down vote up
public EntityPlayerMP getCommandSenderAsPlayer(ICommandSender sender)
throws PlayerNotFoundException;
 
Example #7
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 #8
Source File: CommandBaseAdv.java    From LookingGlass with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the player for a username as an Entity or throws an exception.
 */
public static Entity parsePlayerByName(String name) throws PlayerNotFoundException {
	EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(name);
	if (player != null) { return player; }
	throw new PlayerNotFoundException("lookingglass.commands.generic.player.notfound", new Object[] { name });
}
 
Example #9
Source File: TeleportInIslandCommand.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] params)
{
	EntityPlayerMP player = null;
	try {
		player = getCommandSenderAsPlayer(sender);
	} catch (PlayerNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	WorldServer world = server.worldServerForDimension(player.getEntityWorld().provider.getDimension());

	if(!player.isCreative())
		return;

	if(params.length == 3)
	{
		int x = (int)Math.floor(player.posX);
		int y = (int)Math.floor(player.posY);
		int z = (int)Math.floor(player.posZ);
		int mX = x >> 12;
		int mZ = z >> 12;

		int inX = Integer.parseInt(params[0]);
		int inY = Integer.parseInt(params[1]);
		int inZ = Integer.parseInt(params[2]);

		Point p = new Point(x, z);

		if(params[0].contains("+") || params[0].contains("-"))
			x += inX;
		else
			x = mX*4096+inX;

		if(params[1].contains("+") || params[1].contains("-"))
			y += inY;
		else
			y = inY;

		if(params[2].contains("+") || params[2].contains("-"))
			z += inZ;
		else
			z = mZ*4096+inZ;

		player.setPositionAndUpdate(x, y, z);
	}
}
 
Example #10
Source File: RegenChunkCommand.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] params)
{
	EntityPlayerMP player;
	try {
		player = getCommandSenderAsPlayer(sender);
	} catch (PlayerNotFoundException e) {
		return;
	}

	if(!player.isCreative())
		return;

	WorldServer world = server.worldServerForDimension(player.getEntityWorld().provider.getDimension());

	if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 1)
	{
		int radius = Integer.parseInt(params[0]);

		for(int i = -radius; i <= radius; i++)
		{
			for(int k = -radius; k <= radius; k++)
			{
				int x = (((int)player.posX+i*16) >> 4);
				int z = (((int)player.posZ+k*16) >> 4);

				ChunkProviderServer cps = world.getChunkProvider();

				Chunk c = cps.chunkGenerator.provideChunk(x, z);
				Chunk old = world.getChunkProvider().provideChunk(x, z);
				old.setStorageArrays(c.getBlockStorageArray());
				c.setTerrainPopulated(false);
				c.onChunkLoad();
				c.setChunkModified();
				c.checkLight();
				cps.chunkGenerator.populate(c.xPosition, c.zPosition);
				net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider());
				c.setChunkModified();
				player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff));
			}
		}

		/*for(int i = -radius; i <= radius; i++)
		{
			for(int k = -radius; k <= radius; k++)
			{
				int x = (((int)player.posX+i*16) >> 4);
				int z = (((int)player.posZ+k*16) >> 4);

				ChunkProviderServer cps = world.getChunkProvider();

				Chunk c = cps.chunkGenerator.provideChunk(x, z);
				Chunk old = world.getChunkProvider().provideChunk(x, z);
				old.populateChunk(cps, cps.chunkGenerator);

				if (c.isTerrainPopulated())
				{
					if (cps.chunkGenerator.generateStructures(c, c.xPosition, c.zPosition))
					{
						c.setChunkModified();
					}
				}
				else
				{
					c.checkLight();
					cps.chunkGenerator.populate(c.xPosition, c.zPosition);
					net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider());
					c.setChunkModified();
				}

				player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff));
			}
		}*/
	}
	else if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 2 && params[1].equalsIgnoreCase("hex"))
	{
		execute(server, sender, new String[] {params[0]});
		IslandMap map = Core.getMapForWorld(world, player.getPosition());
		HexGenRegistry.generate(Core.getMapForWorld(world, player.getPosition()), map.getClosestCenter(player.getPosition()), world);
	}
}
 
Example #11
Source File: MobycraftBuildContainerCommands.java    From mobycraft with Apache License 2.0 votes vote down vote up
public void teleport() throws PlayerNotFoundException;