geforkt von Mirrors/Velocity
Fix server-sent plugin message channels, fixing WDLCompanion and similar
Closes #203
Dieser Commit ist enthalten in:
Ursprung
5f0470fb0b
Commit
adfb33ad21
@ -260,7 +260,7 @@ public class VelocityCommand implements Command {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSource source, String @NonNull [] args) {
|
||||
return source.getPermissionValue("velocity.command.plugins") == Tristate.TRUE;
|
||||
return source.getPermissionValue("velocity.command.plugins").asBoolean();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,10 +86,19 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
|
||||
@Override
|
||||
public boolean handle(PluginMessage packet) {
|
||||
if (!serverConn.getPlayer().canForwardPluginMessage(packet)) {
|
||||
if (!serverConn.getPlayer().canForwardPluginMessage(serverConn.ensureConnected()
|
||||
.getProtocolVersion(), packet)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We need to specially handle REGISTER and UNREGISTER packets. Later on, we'll write them to
|
||||
// the client.
|
||||
if (PluginMessageUtil.isRegister(packet)) {
|
||||
serverConn.getPlayer().getKnownChannels().addAll(PluginMessageUtil.getChannels(packet));
|
||||
} else if (PluginMessageUtil.isUnregister(packet)) {
|
||||
serverConn.getPlayer().getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
|
||||
}
|
||||
|
||||
if (PluginMessageUtil.isMcBrand(packet)) {
|
||||
PluginMessage rewritten = PluginMessageUtil.rewriteMinecraftBrand(packet,
|
||||
server.getVersion());
|
||||
|
@ -131,15 +131,16 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
|
||||
|
||||
@Override
|
||||
public boolean handle(PluginMessage packet) {
|
||||
if (!serverConn.getPlayer().canForwardPluginMessage(packet)) {
|
||||
if (!serverConn.getPlayer().canForwardPluginMessage(serverConn.ensureConnected()
|
||||
.getProtocolVersion(), packet)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We need to specially handle REGISTER and UNREGISTER packets. Later on, we'll write them to
|
||||
// the client.
|
||||
if (PluginMessageUtil.isRegister(packet)) {
|
||||
System.out.println("[TSH] I CAN HAZ REGISTER: " + PluginMessageUtil.getChannels(packet));
|
||||
serverConn.getPlayer().getKnownChannels().addAll(PluginMessageUtil.getChannels(packet));
|
||||
} else if (PluginMessageUtil.isUnregister(packet)) {
|
||||
System.out.println("[TSH] I CAN HAZ UNREGISTER: " + PluginMessageUtil.getChannels(packet));
|
||||
serverConn.getPlayer().getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ import com.velocitypowered.proxy.protocol.packet.KeepAlive;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
||||
import com.velocitypowered.proxy.protocol.packet.ResourcePackRequest;
|
||||
import com.velocitypowered.proxy.protocol.packet.TitlePacket;
|
||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||
import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
||||
import com.velocitypowered.proxy.tablist.VelocityTabList;
|
||||
import com.velocitypowered.proxy.util.VelocityMessages;
|
||||
@ -650,16 +651,18 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
|
||||
/**
|
||||
* Determines whether or not we can forward a plugin message onto the client.
|
||||
* @param version the Minecraft protocol version
|
||||
* @param message the plugin message to forward to the client
|
||||
* @return {@code true} if the message can be forwarded, {@code false} otherwise
|
||||
*/
|
||||
public boolean canForwardPluginMessage(PluginMessage message) {
|
||||
// If we're forwarding a plugin message onto the client, that implies that we have a backend
|
||||
// connection already.
|
||||
MinecraftConnection mc = ensureBackendConnection();
|
||||
|
||||
public boolean canForwardPluginMessage(ProtocolVersion version, PluginMessage message) {
|
||||
boolean minecraftOrFmlMessage;
|
||||
if (mc.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_12_2) <= 0) {
|
||||
|
||||
if (PluginMessageUtil.isRegister(message) || PluginMessageUtil.isUnregister(message)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_12_2) <= 0) {
|
||||
String channel = message.getChannel();
|
||||
minecraftOrFmlMessage = channel.startsWith("MC|") || channel
|
||||
.startsWith(LegacyForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL);
|
||||
|
@ -15,7 +15,6 @@ import io.netty.handler.ssl.SslContextBuilder;
|
||||
import io.netty.handler.ssl.SslHandler;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren