mirror of
https://github.com/ViaVersion/ViaForge.git
synced 2024-11-22 12:05:23 +01:00
Some clean up, added f3 debug hud
This commit is contained in:
parent
fd1b080728
commit
3cf92fa69f
@ -11,15 +11,15 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class ViaForgeConfig extends Config {
|
public class ViaForgeConfig extends Config {
|
||||||
public final static String CLIENT_SIDE_VERSION = "client-side-version";
|
public final static String CLIENT_SIDE_VERSION = "client-side-version";
|
||||||
|
public final static String VERIFY_SESSION_IN_OLD_VERSIONS = "verify-session-in-old-versions";
|
||||||
|
public final static String ALLOW_BETACRAFT_AUTHENTICATION = "allow-betacraft-authentication";
|
||||||
|
public final static String SHOW_PROTOCOL_VERSION_IN_F3 = "show-protocol-version-in-f3";
|
||||||
|
|
||||||
public final static String SHOW_MAIN_MENU_BUTTON = "show-main-menu-button";
|
public final static String SHOW_MAIN_MENU_BUTTON = "show-main-menu-button";
|
||||||
public final static String SHOW_MULTIPLAYER_BUTTON = "show-multiplayer-button";
|
public final static String SHOW_MULTIPLAYER_BUTTON = "show-multiplayer-button";
|
||||||
public final static String SHOW_DIRECT_CONNECT_BUTTON = "show-direct-connect-button";
|
public final static String SHOW_DIRECT_CONNECT_BUTTON = "show-direct-connect-button";
|
||||||
public final static String SHOW_ADD_SERVER_BUTTON = "show-add-server-button";
|
public final static String SHOW_ADD_SERVER_BUTTON = "show-add-server-button";
|
||||||
|
|
||||||
public final static String VERIFY_SESSION_IN_OLD_VERSIONS = "verify-session-in-old-versions";
|
|
||||||
public final static String ALLOW_BETACRAFT_AUTHENTICATION = "allow-betacraft-authentication";
|
|
||||||
|
|
||||||
public final static String VIA_FORGE_BUTTON_POSITION = "via-forge-button-position";
|
public final static String VIA_FORGE_BUTTON_POSITION = "via-forge-button-position";
|
||||||
public final static String ADD_SERVER_SCREEN_BUTTON_POSITION = "add-server-screen-button-position";
|
public final static String ADD_SERVER_SCREEN_BUTTON_POSITION = "add-server-screen-button-position";
|
||||||
|
|
||||||
@ -59,6 +59,18 @@ public class ViaForgeConfig extends Config {
|
|||||||
set(CLIENT_SIDE_VERSION, version);
|
set(CLIENT_SIDE_VERSION, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isVerifySessionInOldVersions() {
|
||||||
|
return getBoolean(VERIFY_SESSION_IN_OLD_VERSIONS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAllowBetacraftAuthentication() {
|
||||||
|
return getBoolean(ALLOW_BETACRAFT_AUTHENTICATION, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowProtocolVersionInF3() {
|
||||||
|
return getBoolean(SHOW_PROTOCOL_VERSION_IN_F3, true);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isShowMainMenuButton() {
|
public boolean isShowMainMenuButton() {
|
||||||
return getBoolean(SHOW_MAIN_MENU_BUTTON, true);
|
return getBoolean(SHOW_MAIN_MENU_BUTTON, true);
|
||||||
}
|
}
|
||||||
@ -75,14 +87,6 @@ public class ViaForgeConfig extends Config {
|
|||||||
return getBoolean(SHOW_ADD_SERVER_BUTTON, true);
|
return getBoolean(SHOW_ADD_SERVER_BUTTON, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVerifySessionInOldVersions() {
|
|
||||||
return getBoolean(VERIFY_SESSION_IN_OLD_VERSIONS, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAllowBetacraftAuthentication() {
|
|
||||||
return getBoolean(ALLOW_BETACRAFT_AUTHENTICATION, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ButtonPosition getViaForgeButtonPosition() {
|
public ButtonPosition getViaForgeButtonPosition() {
|
||||||
return ButtonPosition.valueOf(getString(VIA_FORGE_BUTTON_POSITION, ButtonPosition.TOP_LEFT.name()));
|
return ButtonPosition.valueOf(getString(VIA_FORGE_BUTTON_POSITION, ButtonPosition.TOP_LEFT.name()));
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,15 @@ public interface VFNetworkManager {
|
|||||||
*/
|
*/
|
||||||
void viaforge_setupPreNettyDecryption();
|
void viaforge_setupPreNettyDecryption();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the target version of the connection
|
||||||
|
*/
|
||||||
VersionEnum viaforge_getTrackedVersion();
|
VersionEnum viaforge_getTrackedVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the target version of the connection.
|
||||||
|
*
|
||||||
|
* @param version the target version
|
||||||
|
*/
|
||||||
void viaforge_setTrackedVersion(final VersionEnum version);
|
void viaforge_setTrackedVersion(final VersionEnum version);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@ verify-session-in-old-versions: true
|
|||||||
# Allow ViaForge to authenticate with BetaCraft's MP-Pass system for <= c0.30 servers.
|
# Allow ViaForge to authenticate with BetaCraft's MP-Pass system for <= c0.30 servers.
|
||||||
allow-betacraft-authentication: true
|
allow-betacraft-authentication: true
|
||||||
#
|
#
|
||||||
|
# If enabled, ViaForge will show the current protocol version in the F3 menu.
|
||||||
|
show-protocol-version-in-f3: true
|
||||||
|
#
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# GUI OPTIONS #
|
# GUI OPTIONS #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -36,6 +36,7 @@ import java.util.concurrent.ExecutionException;
|
|||||||
public class GuiProtocolSelector extends GuiScreen {
|
public class GuiProtocolSelector extends GuiScreen {
|
||||||
|
|
||||||
private final GuiScreen parent;
|
private final GuiScreen parent;
|
||||||
|
private final boolean simple;
|
||||||
private final FinishedCallback finishedCallback;
|
private final FinishedCallback finishedCallback;
|
||||||
|
|
||||||
private SlotList list;
|
private SlotList list;
|
||||||
@ -44,14 +45,15 @@ public class GuiProtocolSelector extends GuiScreen {
|
|||||||
private long time;
|
private long time;
|
||||||
|
|
||||||
public GuiProtocolSelector(final GuiScreen parent) {
|
public GuiProtocolSelector(final GuiScreen parent) {
|
||||||
this(parent, (version, unused) -> {
|
this(parent, false, (version, unused) -> {
|
||||||
// Default action is to set the target version and go back to the parent screen.
|
// Default action is to set the target version and go back to the parent screen.
|
||||||
ViaForgeCommon.getManager().setTargetVersion(version);
|
ViaForgeCommon.getManager().setTargetVersion(version);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiProtocolSelector(final GuiScreen parent, final FinishedCallback finishedCallback) {
|
public GuiProtocolSelector(final GuiScreen parent, final boolean simple, final FinishedCallback finishedCallback) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
this.simple = simple;
|
||||||
this.finishedCallback = finishedCallback;
|
this.finishedCallback = finishedCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +61,10 @@ public class GuiProtocolSelector extends GuiScreen {
|
|||||||
public void initGui() {
|
public void initGui() {
|
||||||
super.initGui();
|
super.initGui();
|
||||||
buttonList.add(new GuiButton(1, 5, height - 25, 20, 20, "<-"));
|
buttonList.add(new GuiButton(1, 5, height - 25, 20, 20, "<-"));
|
||||||
buttonList.add(new GuiButton(2, width - 105, 5, 100, 20, "Create dump"));
|
if (!this.simple) {
|
||||||
buttonList.add(new GuiButton(3, width - 105, height - 25, 100, 20, "Reload configs"));
|
buttonList.add(new GuiButton(2, width - 105, 5, 100, 20, "Create dump"));
|
||||||
|
buttonList.add(new GuiButton(3, width - 105, height - 25, 100, 20, "Reload configs"));
|
||||||
|
}
|
||||||
|
|
||||||
list = new SlotList(mc, width, height, 3 + 3 /* start offset */ + (fontRenderer.FONT_HEIGHT + 2) * 3 /* title is 2 */, height - 30, fontRenderer.FONT_HEIGHT + 2);
|
list = new SlotList(mc, width, height, 3 + 3 /* start offset */ + (fontRenderer.FONT_HEIGHT + 2) * 3 /* title is 2 */, height - 30, fontRenderer.FONT_HEIGHT + 2);
|
||||||
}
|
}
|
||||||
@ -151,7 +155,14 @@ public class GuiProtocolSelector extends GuiScreen {
|
|||||||
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
final VersionEnum targetVersion = ViaForgeCommon.getManager().getTargetVersion();
|
||||||
final VersionEnum version = VersionEnum.SORTED_VERSIONS.get(index);
|
final VersionEnum version = VersionEnum.SORTED_VERSIONS.get(index);
|
||||||
|
|
||||||
drawCenteredString(mc.fontRenderer,(targetVersion == version ? ChatFormatting.GREEN.toString() : ChatFormatting.DARK_RED.toString()) + version.getName(), width / 2, y, -1);
|
String color;
|
||||||
|
if (targetVersion == version) {
|
||||||
|
color = GuiProtocolSelector.this.simple ? ChatFormatting.GOLD.toString() : ChatFormatting.GREEN.toString();
|
||||||
|
} else {
|
||||||
|
color = GuiProtocolSelector.this.simple ? ChatFormatting.WHITE.toString() : ChatFormatting.DARK_RED.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
drawCenteredString(mc.fontRenderer,(color) + version.getName(), width / 2, y, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,9 +34,6 @@ public class MixinGuiMultiplayer extends GuiScreen {
|
|||||||
|
|
||||||
@Inject(method = "initGui", at = @At("RETURN"))
|
@Inject(method = "initGui", at = @At("RETURN"))
|
||||||
public void hookViaForgeButton(CallbackInfo ci) {
|
public void hookViaForgeButton(CallbackInfo ci) {
|
||||||
// If the previous server forced a version, we need to restore the version to the default one.
|
|
||||||
ViaForgeCommon.getManager().restoreVersion();
|
|
||||||
|
|
||||||
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
|
final ViaForgeConfig config = ViaForgeCommon.getManager().getConfig();
|
||||||
if (config.isShowMultiplayerButton()) {
|
if (config.isShowMultiplayerButton()) {
|
||||||
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);
|
final Pair<Integer, Integer> pos = config.getViaForgeButtonPosition().getPosition(this.width, this.height);
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package de.florianmichael.viaforge.mixin.impl;
|
||||||
|
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import net.minecraft.client.gui.GuiOverlayDebug;
|
||||||
|
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||||
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(GuiOverlayDebug.class)
|
||||||
|
public class MixinGuiOverlayDebug {
|
||||||
|
|
||||||
|
@Inject(method = "getDebugInfoRight", at = @At(value = "TAIL"))
|
||||||
|
public void addViaForgeVersion(CallbackInfoReturnable<List<String>> cir) {
|
||||||
|
final ViaForgeCommon common = ViaForgeCommon.getManager();
|
||||||
|
final VersionEnum version = ViaForgeCommon.getManager().getTargetVersion();
|
||||||
|
|
||||||
|
if (common.getConfig().isShowProtocolVersionInF3() && version != common.getNativeVersion() && !common.getPlatform().isSingleplayer().get()) {
|
||||||
|
cir.getReturnValue().add("");
|
||||||
|
|
||||||
|
int protocolVersion = version.getVersion();
|
||||||
|
if (version.isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
|
||||||
|
// Older versions (<= 1.6.4) are using fake ids in ViaLegacy to prevent version duplications / mismatches
|
||||||
|
// So we need to unmap the version to get the real protocol version id
|
||||||
|
protocolVersion = LegacyProtocolVersion.getRealProtocolVersion(protocolVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
cir.getReturnValue().add("ViaForge: " + version.getName() + " (" + protocolVersion + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -55,7 +55,7 @@ public class MixinGuiScreenAddServer extends GuiScreen {
|
|||||||
public void actionPerformed(GuiButton button, CallbackInfo ci) {
|
public void actionPerformed(GuiButton button, CallbackInfo ci) {
|
||||||
if (ViaForgeCommon.getManager().getConfig().isShowAddServerButton()) {
|
if (ViaForgeCommon.getManager().getConfig().isShowAddServerButton()) {
|
||||||
if (button.id == 1_000_000_000) {
|
if (button.id == 1_000_000_000) {
|
||||||
mc.displayGuiScreen(new GuiProtocolSelector(this, (version, parent) -> {
|
mc.displayGuiScreen(new GuiProtocolSelector(this, true, (version, parent) -> {
|
||||||
// Set version and go back to the parent screen.
|
// Set version and go back to the parent screen.
|
||||||
((ExtendedServerData) serverData).viaforge_setVersion(version);
|
((ExtendedServerData) serverData).viaforge_setVersion(version);
|
||||||
mc.displayGuiScreen(parent);
|
mc.displayGuiScreen(parent);
|
||||||
|
@ -20,12 +20,12 @@ package de.florianmichael.viaforge.mixin.impl;
|
|||||||
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
import de.florianmichael.viaforge.common.protocolhack.netty.VFNetworkManager;
|
import de.florianmichael.viaforge.common.protocolhack.netty.VFNetworkManager;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import net.minecraft.network.NettyEncryptingDecoder;
|
import net.minecraft.network.NettyEncryptingDecoder;
|
||||||
import net.minecraft.network.NettyEncryptingEncoder;
|
import net.minecraft.network.NettyEncryptingEncoder;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.util.CryptManager;
|
import net.minecraft.util.CryptManager;
|
||||||
import net.minecraft.util.LazyLoadBase;
|
import net.minecraft.util.LazyLoadBase;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
import net.raphimc.vialoader.netty.VLLegacyPipeline;
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@ -49,6 +49,9 @@ public class MixinNetworkManager implements VFNetworkManager {
|
|||||||
@Unique
|
@Unique
|
||||||
private Cipher viaforge_decryptionCipher;
|
private Cipher viaforge_decryptionCipher;
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private VersionEnum viaforge_targetVersion;
|
||||||
|
|
||||||
@Inject(method = "createNetworkManagerAndConnect", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
@Inject(method = "createNetworkManagerAndConnect", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||||
private static void trackSelfTarget(InetAddress address, int serverPort, boolean useNativeTransport, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyLoadBase lazyloadbase) {
|
private static void trackSelfTarget(InetAddress address, int serverPort, boolean useNativeTransport, CallbackInfoReturnable<NetworkManager> cir, NetworkManager networkmanager, Class oclass, LazyLoadBase lazyloadbase) {
|
||||||
// The connecting screen and server pinger are setting the main target version when a specific version for a server is set,
|
// The connecting screen and server pinger are setting the main target version when a specific version for a server is set,
|
||||||
@ -74,6 +77,12 @@ public class MixinNetworkManager implements VFNetworkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "closeChannel", at = @At("HEAD"))
|
||||||
|
public void restoreTargetVersion(ITextComponent message, CallbackInfo ci) {
|
||||||
|
// If the previous server forced a version, we need to restore the version to the default one.
|
||||||
|
ViaForgeCommon.getManager().restoreVersion();
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
|
@Inject(method = "setCompressionThreshold", at = @At("RETURN"))
|
||||||
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
public void reorderPipeline(int p_setCompressionTreshold_1_, CallbackInfo ci) {
|
||||||
ViaForgeCommon.getManager().reorderCompression(channel);
|
ViaForgeCommon.getManager().reorderCompression(channel);
|
||||||
@ -85,9 +94,6 @@ public class MixinNetworkManager implements VFNetworkManager {
|
|||||||
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaforge_decryptionCipher));
|
this.channel.pipeline().addBefore(VLLegacyPipeline.VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, "decrypt", new NettyEncryptingDecoder(this.viaforge_decryptionCipher));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Unique
|
|
||||||
private VersionEnum viaforge_targetVersion;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VersionEnum viaforge_getTrackedVersion() {
|
public VersionEnum viaforge_getTrackedVersion() {
|
||||||
return viaforge_targetVersion;
|
return viaforge_targetVersion;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
"MixinGuiConnecting_1",
|
"MixinGuiConnecting_1",
|
||||||
"MixinGuiMainMenu",
|
"MixinGuiMainMenu",
|
||||||
"MixinGuiMultiplayer",
|
"MixinGuiMultiplayer",
|
||||||
|
"MixinGuiOverlayDebug",
|
||||||
"MixinGuiScreenAddServer",
|
"MixinGuiScreenAddServer",
|
||||||
"MixinGuiScreenServerList",
|
"MixinGuiScreenServerList",
|
||||||
"MixinNetHandlerLoginClient",
|
"MixinNetHandlerLoginClient",
|
||||||
|
Loading…
Reference in New Issue
Block a user