Fixed informing players of supported Plugin Channels

This commit is contained in:
Nathan Adams 2012-01-14 01:46:22 +00:00
parent 4dc2065f54
commit 9ac06e7720
2 changed files with 30 additions and 0 deletions

View File

@ -105,6 +105,7 @@ public class NetLoginHandler extends NetHandler {
maxPlayers = 60; 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)); 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 // CraftBukkit end
netserverhandler.sendPacket(new Packet6SpawnPosition(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z)); netserverhandler.sendPacket(new Packet6SpawnPosition(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z));

View File

@ -1,12 +1,16 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityPlayer;
import net.minecraft.server.NBTTagCompound; import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.Packet131ItemData; import net.minecraft.server.Packet131ItemData;
@ -645,4 +649,29 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public Set<String> getListeningPluginChannels() { public Set<String> getListeningPluginChannels() {
return ImmutableSet.copyOf(channels); 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);
}
}
} }