diff --git a/src/main/java/net/minecraft/server/NetLoginHandler.java b/src/main/java/net/minecraft/server/NetLoginHandler.java index 9ed3b29863..6abfe1469e 100644 --- a/src/main/java/net/minecraft/server/NetLoginHandler.java +++ b/src/main/java/net/minecraft/server/NetLoginHandler.java @@ -105,6 +105,7 @@ public class NetLoginHandler extends NetHandler { maxPlayers = 60; } netserverhandler.sendPacket(new Packet1Login("", entityplayer.id, worldserver.getSeed(), worldserver.getWorldData().getType(), entityplayer.itemInWorldManager.getGameMode(), (byte) worldserver.worldProvider.dimension, (byte) worldserver.difficulty, (byte) worldserver.height, (byte) maxPlayers)); + entityplayer.getPlayer().sendSupportedChannels(); // CraftBukkit end netserverhandler.sendPacket(new Packet6SpawnPosition(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z)); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index e6e233f031..1b965f0d02 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1,12 +1,16 @@ package org.bukkit.craftbukkit.entity; import com.google.common.collect.ImmutableSet; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import net.minecraft.server.EntityPlayer; import net.minecraft.server.NBTTagCompound; import net.minecraft.server.Packet131ItemData; @@ -645,4 +649,29 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public Set getListeningPluginChannels() { return ImmutableSet.copyOf(channels); } + + public void sendSupportedChannels() { + Set listening = server.getMessenger().getIncomingChannels(); + + if (!listening.isEmpty()) { + Packet250CustomPayload packet = new Packet250CustomPayload(); + + packet.tag = "REGISTER"; + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + + for (String channel : listening) { + try { + stream.write(channel.getBytes("UTF8")); + stream.write((byte)0); + } catch (IOException ex) { + Logger.getLogger(CraftPlayer.class.getName()).log(Level.SEVERE, "Could not send Plugin Channel REGISTER to " + getName(), ex); + } + } + + packet.data = stream.toByteArray(); + packet.length = packet.data.length; + + getHandle().netServerHandler.sendPacket(packet); + } + } }