2015-05-29 09:35:21 +00:00
|
|
|
From 3dbfff07a5322402f177060407459795ef407a96 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
|
|
|
|
new file mode 100644
|
2015-02-28 11:36:22 +00:00
|
|
|
index 0000000..6cd5df2
|
2014-12-14 21:54:10 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutChat.java
|
2015-02-28 11:36:22 +00:00
|
|
|
@@ -0,0 +1,45 @@
|
2014-12-14 21:54:10 +00:00
|
|
|
+package net.minecraft.server;
|
|
|
|
+
|
2015-02-28 11:36:22 +00:00
|
|
|
+import java.io.IOException;
|
|
|
|
+
|
|
|
|
+public class PacketPlayOutChat implements Packet<PacketListenerPlayOut> {
|
2014-12-14 21:54:10 +00:00
|
|
|
+
|
|
|
|
+ private IChatBaseComponent a;
|
|
|
|
+ public net.md_5.bungee.api.chat.BaseComponent[] components; // Spigot
|
|
|
|
+ private byte b;
|
|
|
|
+
|
|
|
|
+ public PacketPlayOutChat() {}
|
|
|
|
+
|
|
|
|
+ public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent) {
|
|
|
|
+ this(ichatbasecomponent, (byte) 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent, byte b0) {
|
|
|
|
+ this.a = ichatbasecomponent;
|
|
|
|
+ this.b = b0;
|
|
|
|
+ }
|
|
|
|
+
|
2015-02-28 11:36:22 +00:00
|
|
|
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
|
2014-12-14 21:54:10 +00:00
|
|
|
+ this.a = packetdataserializer.d();
|
|
|
|
+ this.b = packetdataserializer.readByte();
|
|
|
|
+ }
|
|
|
|
+
|
2015-02-28 11:36:22 +00:00
|
|
|
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
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
|
|
|
|
+ packetdataserializer.writeByte(this.b);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void a(PacketListenerPlayOut packetlistenerplayout) {
|
|
|
|
+ packetlistenerplayout.a(this);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public boolean b() {
|
|
|
|
+ return this.b == 1 || this.b == 2;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2015-05-29 09:35:21 +00:00
|
|
|
index 10fc305..15aa1b7 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
|
|
|
|
@@ -121,6 +121,7 @@ import io.netty.buffer.ByteBufOutputStream;
|
|
|
|
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];
|
2015-02-28 11:36:22 +00:00
|
|
|
@@ -1705,6 +1706,20 @@ public final class CraftServer implements Server {
|
2014-12-14 21:54:10 +00:00
|
|
|
{
|
|
|
|
return org.spigotmc.SpigotConfig.config;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @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
|
2015-05-09 20:23:26 +00:00
|
|
|
index 50761d7..40ee4d3 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
|
|
|
|
@@ -18,6 +18,7 @@ import java.util.Set;
|
|
|
|
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.*;
|
|
|
|
|
2014-12-21 01:09:49 +00:00
|
|
|
@@ -1428,6 +1429,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()
|
|
|
|
--
|
2015-05-09 20:23:26 +00:00
|
|
|
2.1.4
|
2014-12-14 21:54:10 +00:00
|
|
|
|