diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2012-01-14 01:46:22 +0000 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2012-01-14 01:46:22 +0000 |
commit | 9ac06e7720d4bd6b013f96876b18c7332c2d5a1a (patch) | |
tree | 3848416d3c5b3d8d5653f42743d83f3dfefdd473 /src/main/java | |
parent | 4dc2065f54896de666acdc178dc780f86076c8de (diff) | |
download | craftbukkit-9ac06e7720d4bd6b013f96876b18c7332c2d5a1a.tar craftbukkit-9ac06e7720d4bd6b013f96876b18c7332c2d5a1a.tar.gz craftbukkit-9ac06e7720d4bd6b013f96876b18c7332c2d5a1a.tar.lz craftbukkit-9ac06e7720d4bd6b013f96876b18c7332c2d5a1a.tar.xz craftbukkit-9ac06e7720d4bd6b013f96876b18c7332c2d5a1a.zip |
Fixed informing players of supported Plugin Channels
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/net/minecraft/server/NetLoginHandler.java | 1 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/NetLoginHandler.java b/src/main/java/net/minecraft/server/NetLoginHandler.java index 9ed3b298..6abfe146 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 e6e233f0..1b965f0d 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<String> getListeningPluginChannels() { return ImmutableSet.copyOf(channels); } + + public void sendSupportedChannels() { + Set<String> 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); + } + } } |