Debug mode
This commit is contained in:
parent
cafa8adffd
commit
3fa30b7362
|
|
@ -25,10 +25,14 @@ public class AmbassadorConfig {
|
|||
@Expose
|
||||
private boolean bypassModCheck = false;
|
||||
|
||||
private AmbassadorConfig(boolean silenceWarnings, boolean bypassRegistryCheck, boolean bypassModCheck) {
|
||||
@Expose
|
||||
private boolean debugMode = false;
|
||||
|
||||
private AmbassadorConfig(boolean silenceWarnings, boolean bypassRegistryCheck, boolean bypassModCheck, boolean debugMode) {
|
||||
this.silenceWarnings = silenceWarnings;
|
||||
this.bypassRegistryCheck = bypassRegistryCheck;
|
||||
this.bypassModCheck = bypassModCheck;
|
||||
this.debugMode = debugMode;
|
||||
};
|
||||
|
||||
public static AmbassadorConfig read(Path path) throws IOException {
|
||||
|
|
@ -74,7 +78,9 @@ public class AmbassadorConfig {
|
|||
|
||||
boolean bypassModCheck = config.getOrElse("bypass-mod-checks", false);
|
||||
|
||||
return new AmbassadorConfig(bypassRegistryCheck, bypassModCheck, silenceWarnings);
|
||||
boolean debugMode = config.getOrElse("debug-mode", false);
|
||||
|
||||
return new AmbassadorConfig(bypassRegistryCheck, bypassModCheck, silenceWarnings, debugMode);
|
||||
}
|
||||
|
||||
public int getServerSwitchCancellationTime() {
|
||||
|
|
@ -92,4 +98,8 @@ public class AmbassadorConfig {
|
|||
public boolean isBypassModCheck() {
|
||||
return bypassModCheck;
|
||||
}
|
||||
|
||||
public boolean isDebugMode() {
|
||||
return debugMode;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import com.velocitypowered.proxy.network.Connections;
|
|||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.packet.AvailableCommands;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.adde0109.ambassador.Ambassador;
|
||||
import org.adde0109.ambassador.forge.packet.*;
|
||||
import org.adde0109.ambassador.forge.pipeline.CommandDecoderErrorCatcher;
|
||||
|
|
@ -85,6 +87,12 @@ public enum VelocityForgeBackendConnectionPhase implements BackendConnectionPhas
|
|||
} else {
|
||||
if (message instanceof ModListPacket modListPacket) {
|
||||
remainingRegistries = new CountDownLatch(modListPacket.getRegistries().size());
|
||||
|
||||
if (Ambassador.getInstance().config.isDebugMode())
|
||||
player.sendMessage(Component.text("Expecting " + modListPacket.getRegistries().size() +
|
||||
" packets from server " + server.getServer().getServerInfo().getName()));
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
remainingRegistries.await();
|
||||
|
|
@ -92,10 +100,20 @@ public enum VelocityForgeBackendConnectionPhase implements BackendConnectionPhas
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}).thenAcceptAsync((v) -> {
|
||||
|
||||
if(Ambassador.getInstance().config.isDebugMode()) {
|
||||
player.sendMessage(Component.text("Handshake took: " + (System.currentTimeMillis()-time)/1000 + " seconds"));
|
||||
player.sendMessage(Component.text("Avg packet time" +
|
||||
((System.currentTimeMillis()-time)/1000)/modListPacket.getRegistries().size() + " seconds"));
|
||||
}
|
||||
|
||||
if (Ambassador.getInstance().config.isBypassRegistryCheck() ||
|
||||
clientPhase.forgeHandshake.isCompatible(handshake)) {
|
||||
server.ensureConnected().write(clientPhase.forgeHandshake.getModListReplyPacket());
|
||||
} else {
|
||||
Ambassador.getInstance().logger.error("Unable to switch due to the registries of " +
|
||||
server.getServer().getServerInfo().getName() + " being different from the registries of " +
|
||||
player.getConnectedServer().getServer().getServerInfo().getName());
|
||||
server.disconnect();
|
||||
}
|
||||
}, server.ensureConnected().eventLoop());
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.velocitypowered.proxy.protocol.packet.LoginPluginMessage;
|
|||
import com.velocitypowered.proxy.protocol.packet.PluginMessage;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.adde0109.ambassador.Ambassador;
|
||||
import org.adde0109.ambassador.forge.packet.Context;
|
||||
import org.adde0109.ambassador.forge.packet.IForgeLoginWrapperPacket;
|
||||
|
|
@ -197,9 +198,17 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
|||
COMPLETE.onTransitionToNewPhase(player);
|
||||
COMPLETE.forgeHandshake = forgeHandshake;
|
||||
}
|
||||
|
||||
if (Ambassador.getInstance().config.isDebugMode()) {
|
||||
player.sendMessage(Component.text("Forge handshake complete"));
|
||||
player.sendMessage(Component.text(resettable ? "Resettable" : "Non-resettable"));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isResettable(ConnectedPlayer player) {
|
||||
if (Ambassador.getInstance().config.isDebugMode()) {
|
||||
player.sendMessage(Component.text("Scanning modlist for client reset mods"));
|
||||
}
|
||||
if (player.getModInfo().isPresent()) {
|
||||
return player.getModInfo().get().getMods().stream().anyMatch((mod -> mod.getId().equals("clientresetpacket")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,4 +15,7 @@ bypass-registry-checks = false
|
|||
|
||||
# Allow player to switch without reset when the server's mods don't match. Even more unstable than bypassRegistryCheck.
|
||||
# Warning: This is a safety measure for when bypassRegistryCheck is true. Setting this to also true can cause crashes.
|
||||
bypass-mod-checks = false
|
||||
bypass-mod-checks = false
|
||||
|
||||
#Only for debug/troubleshooting
|
||||
debug-mode = false
|
||||
Loading…
Reference in New Issue
Block a user