All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minecraft.server.CommandTellRaw Maven / Gradle / Ivy

package net.minecraft.server;

import com.google.gson.JsonParseException;
import org.apache.commons.lang3.exception.ExceptionUtils;

import java.util.List;

public class CommandTellRaw extends CommandAbstract {
	
	public CommandTellRaw() {
	}
	
	public String getCommand() {
		return "tellraw";
	}
	
	public int a() {
		return 2;
	}
	
	public String getUsage(ICommandListener icommandlistener) {
		return "commands.tellraw.usage";
	}
	
	public void execute(ICommandListener icommandlistener, String[] astring) throws CommandException {
		if (astring.length < 2) {
			throw new ExceptionUsage("commands.tellraw.usage");
		} else {
			EntityPlayer entityplayer = a(icommandlistener, astring[0]);
			String s = a(astring, 1);
			
			try {
				IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s);
				
				entityplayer.sendMessage(ChatComponentUtils.filterForDisplay(icommandlistener, ichatbasecomponent, entityplayer));
			} catch (JsonParseException jsonparseexception) {
				Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
				
				throw new ExceptionInvalidSyntax("commands.tellraw.jsonException", throwable == null ? "" : throwable.getMessage());
			}
		}
	}
	
	public List tabComplete(ICommandListener icommandlistener, String[] astring, BlockPosition blockposition) {
		return astring.length == 1 ? a(astring, MinecraftServer.getServer().getPlayers()) : null;
	}
	
	public boolean isListStart(String[] astring, int i) {
		return i == 0;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy