3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-17 05:20:05 +01:00

Fixed informing players of supported Plugin Channels

Dieser Commit ist enthalten in:
Nathan Adams 2012-01-14 01:46:22 +00:00
Ursprung 4dc2065f54
Commit 9ac06e7720
2 geänderte Dateien mit 30 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -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));

Datei anzeigen

@ -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);
}
}
} }