2016-03-02 21:28:13 +00:00
|
|
|
From 24e6c6941fbbb67401365dea9f85460add367e33 Mon Sep 17 00:00:00 2001
|
2014-12-14 21:54:10 +00:00
|
|
|
From: md_5 <git@md-5.net>
|
|
|
|
Date: Sat, 13 Dec 2014 13:06:05 +1100
|
|
|
|
Subject: [PATCH] BungeeCord Chat API
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutChat.java b/src/main/java/net/minecraft/server/PacketPlayOutChat.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index c5147b6..c0e1199 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutChat.java
|
2014-12-14 21:54:10 +00:00
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutChat.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -5,6 +5,7 @@ import java.io.IOException;
|
|
|
|
public class PacketPlayOutChat implements Packet<PacketListenerPlayOut> {
|
|
|
|
|
|
|
|
private IChatBaseComponent a;
|
2014-12-14 21:54:10 +00:00
|
|
|
+ public net.md_5.bungee.api.chat.BaseComponent[] components; // Spigot
|
2016-02-29 21:33:06 +00:00
|
|
|
private byte b;
|
|
|
|
|
|
|
|
public PacketPlayOutChat() {}
|
|
|
|
@@ -24,7 +25,13 @@ public class PacketPlayOutChat implements Packet<PacketListenerPlayOut> {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
|
|
|
- packetdataserializer.a(this.a);
|
2014-12-14 21:54:10 +00:00
|
|
|
+ // Spigot start
|
|
|
|
+ if (components != null) {
|
|
|
|
+ packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(components));
|
|
|
|
+ } else {
|
|
|
|
+ packetdataserializer.a(this.a);
|
|
|
|
+ }
|
|
|
|
+ // Spigot end
|
2016-02-29 21:33:06 +00:00
|
|
|
packetdataserializer.writeByte(this.b);
|
|
|
|
}
|
|
|
|
|
2014-12-14 21:54:10 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index cabb3e5..7831a12 100644
|
2014-12-14 21:54:10 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -126,6 +126,7 @@ import io.netty.buffer.ByteBufOutputStream;
|
2014-12-14 21:54:10 +00:00
|
|
|
import io.netty.buffer.Unpooled;
|
|
|
|
import io.netty.handler.codec.base64.Base64;
|
|
|
|
import jline.console.ConsoleReader;
|
|
|
|
+import net.md_5.bungee.api.chat.BaseComponent;
|
|
|
|
|
|
|
|
public final class CraftServer implements Server {
|
|
|
|
private static final Player[] EMPTY_PLAYER_ARRAY = new Player[0];
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -1721,6 +1722,20 @@ public final class CraftServer implements Server {
|
2015-07-13 09:12:24 +00:00
|
|
|
public void restart() {
|
|
|
|
org.spigotmc.RestartCommand.restart();
|
2014-12-14 21:54:10 +00:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void broadcast(BaseComponent component) {
|
|
|
|
+ for (Player player : getOnlinePlayers()) {
|
|
|
|
+ player.spigot().sendMessage(component);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void broadcast(BaseComponent... components) {
|
|
|
|
+ for (Player player : getOnlinePlayers()) {
|
|
|
|
+ player.spigot().sendMessage(components);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
};
|
|
|
|
|
|
|
|
public Spigot spigot()
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2016-03-02 21:28:13 +00:00
|
|
|
index 8fefb1f..250f112 100644
|
2014-12-14 21:54:10 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2015-06-08 23:16:01 +00:00
|
|
|
@@ -19,6 +19,7 @@ import java.util.Set;
|
2014-12-14 21:54:10 +00:00
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
+import net.md_5.bungee.api.chat.BaseComponent;
|
|
|
|
|
|
|
|
import net.minecraft.server.*;
|
2015-07-10 12:33:16 +00:00
|
|
|
import net.minecraft.server.PacketPlayOutTitle.EnumTitleAction;
|
2016-03-02 21:28:13 +00:00
|
|
|
@@ -1517,6 +1518,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2014-12-14 21:54:10 +00:00
|
|
|
|
|
|
|
return java.util.Collections.unmodifiableSet( ret );
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void sendMessage(BaseComponent component) {
|
|
|
|
+ sendMessage( new BaseComponent[] { component } );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void sendMessage(BaseComponent... components) {
|
|
|
|
+ if ( getHandle().playerConnection == null ) return;
|
|
|
|
+
|
|
|
|
+ PacketPlayOutChat packet = new PacketPlayOutChat();
|
|
|
|
+ packet.components = components;
|
|
|
|
+ getHandle().playerConnection.sendPacket(packet);
|
|
|
|
+ }
|
|
|
|
};
|
|
|
|
|
|
|
|
public Player.Spigot spigot()
|
|
|
|
--
|
2016-02-29 21:33:06 +00:00
|
|
|
2.5.0
|
2014-12-14 21:54:10 +00:00
|
|
|
|