Updated ServerRedirekt mechanism to support newer Velocity

This commit is contained in:
Adrian Bergqvist 2023-09-02 00:48:24 +02:00
parent 652a16ea32
commit e7fd073652
No known key found for this signature in database
GPG Key ID: FAE7D8EDE225E686
4 changed files with 10 additions and 3 deletions

View File

@ -5,7 +5,7 @@ plugins {
} }
group = "org.adde0109" group = "org.adde0109"
version = "1.4.0" version = "1.4.1"
repositories { repositories {
mavenCentral() mavenCentral()

View File

@ -39,7 +39,7 @@ import java.util.concurrent.TimeUnit;
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19; import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19;
import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.mapSet; import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.mapSet;
@Plugin(id = "ambassador", name = "Ambassador", version = "1.4.0", authors = {"adde0109"}) @Plugin(id = "ambassador", name = "Ambassador", version = "1.4.1", authors = {"adde0109"})
public class Ambassador { public class Ambassador {
public ProxyServer server; public ProxyServer server;

View File

@ -68,6 +68,11 @@ public enum VelocityForgeBackendConnectionPhase implements BackendConnectionPhas
VelocityForgeClientConnectionPhase clientPhase = (VelocityForgeClientConnectionPhase) player.getPhase(); VelocityForgeClientConnectionPhase clientPhase = (VelocityForgeClientConnectionPhase) player.getPhase();
if (clientPhase != VelocityForgeClientConnectionPhase.NOT_STARTED) { if (clientPhase != VelocityForgeClientConnectionPhase.NOT_STARTED) {
clientPhase.resetConnectionPhase(player); clientPhase.resetConnectionPhase(player);
if (clientPhase == VelocityForgeClientConnectionPhase.COMPLETE)
{
//Do not continue if the client can't reset.
return;
}
} }
message.retain(); message.retain();
player.getConnection().write(message); player.getConnection().write(message);

View File

@ -127,7 +127,9 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
Ambassador.getTemporaryForced().put(player.getUsername(), player.getConnectionInFlight().getServer(), Ambassador.getTemporaryForced().put(player.getUsername(), player.getConnectionInFlight().getServer(),
Ambassador.getInstance().config.getServerSwitchCancellationTime(), TimeUnit.SECONDS); Ambassador.getInstance().config.getServerSwitchCancellationTime(), TimeUnit.SECONDS);
//Disconnect - Reset //Disconnect - Reset
if(player.getKnownChannels().contains("srvredirect:red") && player.getVirtualHost().isPresent()) { if(player.getModInfo().isPresent()
&& player.getModInfo().get().getMods().stream().anyMatch((mod -> mod.getId().equals("serverredirect")))
&& player.getVirtualHost().isPresent()) {
ByteBuf buf = Unpooled.buffer(); ByteBuf buf = Unpooled.buffer();
ProtocolUtils.writeVarInt(buf, 0); ProtocolUtils.writeVarInt(buf, 0);
buf.writeBytes((player.getVirtualHost().get().getHostName() + ":" buf.writeBytes((player.getVirtualHost().get().getHostName() + ":"