This commit is contained in:
ZX夏夜之风 2025-11-09 04:27:00 +00:00 committed by GitHub
commit d457b29b3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 22 additions and 10 deletions

@ -1 +1 @@
Subproject commit c3583e182ca6585e40d1eef0da8c18547c0b1bc1
Subproject commit b6b6b20fe97cd9cb0d6b4e817d3e7db72aca2d8d

View File

@ -37,3 +37,8 @@ tasks {
archiveBaseName.set("Ambassador-Velocity")
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -1,5 +1,7 @@
package org.adde0109.ambassador;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.inject.Inject;
import com.velocitypowered.api.event.PostOrder;
import com.velocitypowered.api.event.Subscribe;
@ -14,8 +16,10 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.MinecraftConnection;
@ -50,7 +54,7 @@ import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdenti
public class Ambassador {
//Don't forget to update checkCompatibleVersion() when changing this value
private static final String minVelocityVersion = "velocity-3.3.0-SNAPSHOT-330";
private static final String minVelocityVersion = "velocity-3.3.0-SNAPSHOT-490";
public ProxyServer server;
public final Logger logger;
@ -79,11 +83,11 @@ public class Ambassador {
boolean checkCompatibleVersion() {
//Update this when changing minVelocityVersion
try {
Class.forName("com.velocitypowered.proxy.protocol.packet.DisconnectPacket");
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
ConnectedPlayer.class.getMethod("getClientsideChannels");
} catch (NoSuchMethodException e) {
return false;
}
return true;
return true;
}
@Subscribe(order = PostOrder.LAST)

View File

@ -198,8 +198,8 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
if (player.getModInfo().get().getMods().stream().anyMatch((mod -> mod.getId().equals("clientresetpacket")))) {
return ClientResetType.CRP;
} else if (Ambassador.getInstance().config.getServerSwitchCancellationTime() >= 0 &&
player.getModInfo().get().getMods().stream().anyMatch((mod -> mod.getId().equals("serverredirect")
|| mod.getId().equals("srvredirect:red")))
(player.getModInfo().get().getMods().stream().anyMatch((mod -> mod.getId().equals("serverredirect")))
|| player.getClientsideChannels().stream().anyMatch(identifier -> identifier.getId().equals("srvredirect:red")))
&& player.getVirtualHost().isPresent()) {
return ClientResetType.SR;
}

View File

@ -3,6 +3,7 @@ package org.adde0109.ambassador.velocity;
import com.velocitypowered.api.event.Continuation;
import com.velocitypowered.api.event.PostOrder;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.event.player.*;
import com.velocitypowered.api.proxy.server.RegisteredServer;
@ -68,9 +69,12 @@ public class VelocityEventHandler {
if (!(player.getConnection().getType() instanceof ForgeFMLConnectionType)) {
return;
}
// Do not overwrite the mod info stored by the proxy or the server redirect based on Client Reset Packet will stop working
/*
player.setModInfo(new ModInfo("Channels", event.getChannels().stream().map((id) -> {
return new ModInfo.Mod(id.getId(), "");
}).toList()));
*/
VelocityForgeClientConnectionPhase clientPhase = (VelocityForgeClientConnectionPhase) player.getPhase();
//If reset typ is still unknown, set it!
@ -78,5 +82,4 @@ public class VelocityEventHandler {
clientPhase.updateResetType(player);
}
}
}