Java 类net.minecraft.util.ChatComponentProcessor 实例源码
项目:DecompiledMinecraft
文件:CommandMessageRaw.java
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(sender, args[0]);
String s = buildString(args, 1);
try
{
IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
entityplayer.addChatMessage(ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayer));
}
catch (JsonParseException jsonparseexception)
{
Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
}
}
}
项目:DecompiledMinecraft
文件:CommandMessageRaw.java
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(sender, args[0]);
String s = buildString(args, 1);
try
{
IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
entityplayer.addChatMessage(ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayer));
}
catch (JsonParseException jsonparseexception)
{
Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
}
}
}
项目:BaseClient
文件:CommandMessageRaw.java
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(sender, args[0]);
String s = buildString(args, 1);
try
{
IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
entityplayer.addChatMessage(ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayer));
}
catch (JsonParseException jsonparseexception)
{
Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
}
}
}
项目:BaseClient
文件:CommandMessageRaw.java
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(sender, args[0]);
String s = buildString(args, 1);
try
{
IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
entityplayer.addChatMessage(ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayer));
}
catch (JsonParseException jsonparseexception)
{
Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
}
}
}
项目:Alagaesias-Ancient-Language
文件:Spellbook.java
private void resolveContents(ItemStack stack, EntityPlayer player) {
if (stack != null && stack.getTagCompound() != null) {
NBTTagCompound nbttagcompound = stack.getTagCompound();
if (!nbttagcompound.getBoolean("resolved")) {
nbttagcompound.setBoolean("resolved", true);
if (validBookTagContents(nbttagcompound)) {
NBTTagList nbttaglist = nbttagcompound.getTagList("pages", 8);
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
String s = nbttaglist.getStringTagAt(i);
Object object;
try {
IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
object = ChatComponentProcessor.func_179985_a(player, ichatcomponent, player);
} catch (Exception exception) {
object = new ChatComponentText(s);
}
nbttaglist.set(i,
new NBTTagString(IChatComponent.Serializer.componentToJson((IChatComponent) object)));
}
nbttagcompound.setTag("pages", nbttaglist);
if (player instanceof EntityPlayerMP && player.getCurrentEquippedItem() == stack) {
Slot slot = player.openContainer.getSlotFromInventory(player.inventory,
player.inventory.currentItem);
((EntityPlayerMP) player).playerNetServerHandler
.sendPacket(new S2FPacketSetSlot(0, slot.slotNumber, stack));
}
}
}
}
}
项目:DecompiledMinecraft
文件:TileEntitySign.java
public void readFromNBT(NBTTagCompound compound)
{
this.isEditable = false;
super.readFromNBT(compound);
ICommandSender icommandsender = new ICommandSender()
{
public String getName()
{
return "Sign";
}
public IChatComponent getDisplayName()
{
return new ChatComponentText(this.getName());
}
public void addChatMessage(IChatComponent component)
{
}
public boolean canCommandSenderUseCommand(int permLevel, String commandName)
{
return true;
}
public BlockPos getPosition()
{
return TileEntitySign.this.pos;
}
public Vec3 getPositionVector()
{
return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
}
public World getEntityWorld()
{
return TileEntitySign.this.worldObj;
}
public Entity getCommandSenderEntity()
{
return null;
}
public boolean sendCommandFeedback()
{
return false;
}
public void setCommandStat(CommandResultStats.Type type, int amount)
{
}
};
for (int i = 0; i < 4; ++i)
{
String s = compound.getString("Text" + (i + 1));
try
{
IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
try
{
this.signText[i] = ChatComponentProcessor.processComponent(icommandsender, ichatcomponent, (Entity)null);
}
catch (CommandException var7)
{
this.signText[i] = ichatcomponent;
}
}
catch (JsonParseException var8)
{
this.signText[i] = new ChatComponentText(s);
}
}
this.stats.readStatsFromNBT(compound);
}
项目:DecompiledMinecraft
文件:CommandTitle.java
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
if (args.length < 3)
{
if ("title".equals(args[1]) || "subtitle".equals(args[1]))
{
throw new WrongUsageException("commands.title.usage.title", new Object[0]);
}
if ("times".equals(args[1]))
{
throw new WrongUsageException("commands.title.usage.times", new Object[0]);
}
}
EntityPlayerMP entityplayermp = getPlayer(sender, args[0]);
S45PacketTitle.Type s45packettitle$type = S45PacketTitle.Type.byName(args[1]);
if (s45packettitle$type != S45PacketTitle.Type.CLEAR && s45packettitle$type != S45PacketTitle.Type.RESET)
{
if (s45packettitle$type == S45PacketTitle.Type.TIMES)
{
if (args.length != 5)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
int i = parseInt(args[2]);
int j = parseInt(args[3]);
int k = parseInt(args[4]);
S45PacketTitle s45packettitle2 = new S45PacketTitle(i, j, k);
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle2);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
else if (args.length < 3)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
String s = buildString(args, 2);
IChatComponent ichatcomponent;
try
{
ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
}
catch (JsonParseException jsonparseexception)
{
Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
}
S45PacketTitle s45packettitle1 = new S45PacketTitle(s45packettitle$type, ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayermp));
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle1);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
else if (args.length != 2)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
S45PacketTitle s45packettitle = new S45PacketTitle(s45packettitle$type, (IChatComponent)null);
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
}
项目:DecompiledMinecraft
文件:TileEntitySign.java
public void readFromNBT(NBTTagCompound compound)
{
this.isEditable = false;
super.readFromNBT(compound);
ICommandSender icommandsender = new ICommandSender()
{
public String getName()
{
return "Sign";
}
public IChatComponent getDisplayName()
{
return new ChatComponentText(this.getName());
}
public void addChatMessage(IChatComponent component)
{
}
public boolean canCommandSenderUseCommand(int permLevel, String commandName)
{
return true;
}
public BlockPos getPosition()
{
return TileEntitySign.this.pos;
}
public Vec3 getPositionVector()
{
return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
}
public World getEntityWorld()
{
return TileEntitySign.this.worldObj;
}
public Entity getCommandSenderEntity()
{
return null;
}
public boolean sendCommandFeedback()
{
return false;
}
public void setCommandStat(CommandResultStats.Type type, int amount)
{
}
};
for (int i = 0; i < 4; ++i)
{
String s = compound.getString("Text" + (i + 1));
try
{
IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
try
{
this.signText[i] = ChatComponentProcessor.processComponent(icommandsender, ichatcomponent, (Entity)null);
}
catch (CommandException var7)
{
this.signText[i] = ichatcomponent;
}
}
catch (JsonParseException var8)
{
this.signText[i] = new ChatComponentText(s);
}
}
this.stats.readStatsFromNBT(compound);
}
项目:DecompiledMinecraft
文件:CommandTitle.java
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
if (args.length < 3)
{
if ("title".equals(args[1]) || "subtitle".equals(args[1]))
{
throw new WrongUsageException("commands.title.usage.title", new Object[0]);
}
if ("times".equals(args[1]))
{
throw new WrongUsageException("commands.title.usage.times", new Object[0]);
}
}
EntityPlayerMP entityplayermp = getPlayer(sender, args[0]);
S45PacketTitle.Type s45packettitle$type = S45PacketTitle.Type.byName(args[1]);
if (s45packettitle$type != S45PacketTitle.Type.CLEAR && s45packettitle$type != S45PacketTitle.Type.RESET)
{
if (s45packettitle$type == S45PacketTitle.Type.TIMES)
{
if (args.length != 5)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
int i = parseInt(args[2]);
int j = parseInt(args[3]);
int k = parseInt(args[4]);
S45PacketTitle s45packettitle2 = new S45PacketTitle(i, j, k);
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle2);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
else if (args.length < 3)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
String s = buildString(args, 2);
IChatComponent ichatcomponent;
try
{
ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
}
catch (JsonParseException jsonparseexception)
{
Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
}
S45PacketTitle s45packettitle1 = new S45PacketTitle(s45packettitle$type, ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayermp));
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle1);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
else if (args.length != 2)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
S45PacketTitle s45packettitle = new S45PacketTitle(s45packettitle$type, (IChatComponent)null);
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
}
项目:BaseClient
文件:TileEntitySign.java
public void readFromNBT(NBTTagCompound compound)
{
this.isEditable = false;
super.readFromNBT(compound);
ICommandSender icommandsender = new ICommandSender()
{
public String getName()
{
return "Sign";
}
public IChatComponent getDisplayName()
{
return new ChatComponentText(this.getName());
}
public void addChatMessage(IChatComponent component)
{
}
public boolean canCommandSenderUseCommand(int permLevel, String commandName)
{
return true;
}
public BlockPos getPosition()
{
return TileEntitySign.this.pos;
}
public Vec3 getPositionVector()
{
return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
}
public World getEntityWorld()
{
return TileEntitySign.this.worldObj;
}
public Entity getCommandSenderEntity()
{
return null;
}
public boolean sendCommandFeedback()
{
return false;
}
public void setCommandStat(CommandResultStats.Type type, int amount)
{
}
};
for (int i = 0; i < 4; ++i)
{
String s = compound.getString("Text" + (i + 1));
try
{
IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
try
{
this.signText[i] = ChatComponentProcessor.processComponent(icommandsender, ichatcomponent, (Entity)null);
}
catch (CommandException var7)
{
this.signText[i] = ichatcomponent;
}
}
catch (JsonParseException var8)
{
this.signText[i] = new ChatComponentText(s);
}
}
this.stats.readStatsFromNBT(compound);
}
项目:BaseClient
文件:CommandTitle.java
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
if (args.length < 3)
{
if ("title".equals(args[1]) || "subtitle".equals(args[1]))
{
throw new WrongUsageException("commands.title.usage.title", new Object[0]);
}
if ("times".equals(args[1]))
{
throw new WrongUsageException("commands.title.usage.times", new Object[0]);
}
}
EntityPlayerMP entityplayermp = getPlayer(sender, args[0]);
S45PacketTitle.Type s45packettitle$type = S45PacketTitle.Type.byName(args[1]);
if (s45packettitle$type != S45PacketTitle.Type.CLEAR && s45packettitle$type != S45PacketTitle.Type.RESET)
{
if (s45packettitle$type == S45PacketTitle.Type.TIMES)
{
if (args.length != 5)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
int i = parseInt(args[2]);
int j = parseInt(args[3]);
int k = parseInt(args[4]);
S45PacketTitle s45packettitle2 = new S45PacketTitle(i, j, k);
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle2);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
else if (args.length < 3)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
String s = buildString(args, 2);
IChatComponent ichatcomponent;
try
{
ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
}
catch (JsonParseException jsonparseexception)
{
Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
}
S45PacketTitle s45packettitle1 = new S45PacketTitle(s45packettitle$type, ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayermp));
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle1);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
else if (args.length != 2)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
S45PacketTitle s45packettitle = new S45PacketTitle(s45packettitle$type, (IChatComponent)null);
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
}
项目:BaseClient
文件:TileEntitySign.java
public void readFromNBT(NBTTagCompound compound)
{
this.isEditable = false;
super.readFromNBT(compound);
ICommandSender icommandsender = new ICommandSender()
{
public String getName()
{
return "Sign";
}
public IChatComponent getDisplayName()
{
return new ChatComponentText(this.getName());
}
public void addChatMessage(IChatComponent component)
{
}
public boolean canCommandSenderUseCommand(int permLevel, String commandName)
{
return true;
}
public BlockPos getPosition()
{
return TileEntitySign.this.pos;
}
public Vec3 getPositionVector()
{
return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
}
public World getEntityWorld()
{
return TileEntitySign.this.worldObj;
}
public Entity getCommandSenderEntity()
{
return null;
}
public boolean sendCommandFeedback()
{
return false;
}
public void setCommandStat(CommandResultStats.Type type, int amount)
{
}
};
for (int i = 0; i < 4; ++i)
{
String s = compound.getString("Text" + (i + 1));
try
{
IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
try
{
this.signText[i] = ChatComponentProcessor.processComponent(icommandsender, ichatcomponent, (Entity)null);
}
catch (CommandException var7)
{
this.signText[i] = ichatcomponent;
}
}
catch (JsonParseException var8)
{
this.signText[i] = new ChatComponentText(s);
}
}
this.stats.readStatsFromNBT(compound);
}
项目:BaseClient
文件:CommandTitle.java
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
if (args.length < 3)
{
if ("title".equals(args[1]) || "subtitle".equals(args[1]))
{
throw new WrongUsageException("commands.title.usage.title", new Object[0]);
}
if ("times".equals(args[1]))
{
throw new WrongUsageException("commands.title.usage.times", new Object[0]);
}
}
EntityPlayerMP entityplayermp = getPlayer(sender, args[0]);
S45PacketTitle.Type s45packettitle$type = S45PacketTitle.Type.byName(args[1]);
if (s45packettitle$type != S45PacketTitle.Type.CLEAR && s45packettitle$type != S45PacketTitle.Type.RESET)
{
if (s45packettitle$type == S45PacketTitle.Type.TIMES)
{
if (args.length != 5)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
int i = parseInt(args[2]);
int j = parseInt(args[3]);
int k = parseInt(args[4]);
S45PacketTitle s45packettitle2 = new S45PacketTitle(i, j, k);
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle2);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
else if (args.length < 3)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
String s = buildString(args, 2);
IChatComponent ichatcomponent;
try
{
ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
}
catch (JsonParseException jsonparseexception)
{
Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
}
S45PacketTitle s45packettitle1 = new S45PacketTitle(s45packettitle$type, ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayermp));
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle1);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
else if (args.length != 2)
{
throw new WrongUsageException("commands.title.usage", new Object[0]);
}
else
{
S45PacketTitle s45packettitle = new S45PacketTitle(s45packettitle$type, (IChatComponent)null);
entityplayermp.playerNetServerHandler.sendPacket(s45packettitle);
notifyOperators(sender, this, "commands.title.success", new Object[0]);
}
}
}