mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 03:49:14 +00:00
Loosen up ServerChatEvent to support IChatComponent Closes #1893
This commit is contained in:
1 parent
8d7b999506
commit
df5e594e95
2 files changed
+22
-5
No files matched your search
@@ -130,17 +130,19 @@
|
||||
{
|
||||
this.func_147359_a(new S2FPacketSetSlot(this.field_147369_b.field_71070_bA.field_75152_c, slot.field_75222_d, this.field_147369_b.field_71071_by.func_70448_g()));
|
||||
}
|
||||
@@ -764,7 +792,9 @@
|
||||
@@ -764,8 +792,10 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
- ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("chat.type.text", new Object[] {this.field_147369_b.func_145748_c_(), s});
|
||||
- this.field_147367_d.func_71203_ab().func_148544_a(chatcomponenttranslation1, false);
|
||||
+ ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("chat.type.text", this.field_147369_b.func_145748_c_(), ForgeHooks.newChatWithLinks(s));
|
||||
+ chatcomponenttranslation1 = ForgeHooks.onServerChatEvent(this, s, chatcomponenttranslation1);
|
||||
+ if (chatcomponenttranslation1 == null) return;
|
||||
this.field_147367_d.func_71203_ab().func_148544_a(chatcomponenttranslation1, false);
|
||||
+ IChatComponent chat = ForgeHooks.onServerChatEvent(this, s, chatcomponenttranslation1);
|
||||
+ if (chat == null) return;
|
||||
+ this.field_147367_d.func_71203_ab().func_148544_a(chat, false);
|
||||
}
|
||||
|
||||
this.field_147374_l += 20;
|
||||
@@ -907,7 +937,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
/**
|
||||
* ServerChatEvent is fired whenever a C01PacketChatMessage is processed. <br>
|
||||
* This event is fired via {@link ForgeHooks#onServerChatEvent(net.minecraft.network.NetHandlerPlayServer, String, ChatComponentTranslation)},
|
||||
* This event is fired via {@link ForgeHooks#onServerChatEvent(net.minecraft.network.NetHandlerPlayServer, String, ChatComponentTranslation)},
|
||||
* which is executed by the NetHandlerPlayServer#processChatMessage(net.minecraft.network.play.client.C01PacketChatMessage)<br>
|
||||
* <br>
|
||||
* {@link #username} contains the username of the player sending the chat message.<br>
|
||||
@@ -27,6 +28,7 @@ public class ServerChatEvent extends Event
|
||||
{
|
||||
public final String message, username;
|
||||
public final EntityPlayerMP player;
|
||||
@Deprecated //Use methods below
|
||||
public ChatComponentTranslation component;
|
||||
public ServerChatEvent(EntityPlayerMP player, String message, ChatComponentTranslation component)
|
||||
{
|
||||
@@ -36,4 +38,17 @@ public class ServerChatEvent extends Event
|
||||
this.username = player.getGameProfile().getName();
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public void setComponent(IChatComponent e)
|
||||
{
|
||||
if (e instanceof ChatComponentTranslation)
|
||||
this.component = (ChatComponentTranslation)e;
|
||||
else
|
||||
this.component = new ChatComponentTranslation("%s", e);
|
||||
}
|
||||
|
||||
public IChatComponent getComponent()
|
||||
{
|
||||
return this.component;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user