More of that some™ tested code and contact infos

Dieser Commit ist enthalten in:
Chaoscaot 2022-09-25 12:15:31 +02:00
Ursprung c64008f2f2
Commit 886a0b795f
13 geänderte Dateien mit 123 neuen und 75 gelöschten Zeilen

Datei anzeigen

@ -2,4 +2,5 @@ accessWidener v1 named
mutable field net/minecraft/server/MinecraftServer apiServices Lnet/minecraft/util/ApiServices;
accessible field net/minecraft/client/gui/screen/ConnectScreen connection Lnet/minecraft/network/ClientConnection;
accessible field net/minecraft/client/gui/screen/ConnectScreen connectingCancelled Z
accessible field net/minecraft/client/gui/screen/ConnectScreen parent Lnet/minecraft/client/gui/screen/Screen;
accessible field net/minecraft/client/gui/screen/ConnectScreen parent Lnet/minecraft/client/gui/screen/Screen;
accessible field net/minecraft/client/gui/screen/ConnectScreen status Lnet/minecraft/text/Text;

Datei anzeigen

@ -0,0 +1,10 @@
{
"gui.altauth.confirm.title": "%s §rmöchte '%s' als AltAuth server nutzen",
"gui.altauth.confirm.text": "Willst du\n'%s'\nals Authentication Server vertrauen?\n\n§4§lACHTUNG: §rDieser Server ist nicht von Mojang und kann unsicher sein!\nJemand bösartiges kann mit den gesendeten Information sich in deinen Minecraft Account einloggen und ihn auf §4§lJEDEM§r Server benutzen!\n\nWenn du dir nicht sicher bist, klicke auf 'Abbrechen'.",
"gui.altauth.connecting": "Verbinden mit AltAuth '%s'...",
"gui.altauth.error": "AltAuth Fehler!",
"config.altauth.title": "AltAuth Client Config",
"config.altauth.general": "Allgemein",
"config.altauth.enabled": "AltAuth Benutzen",
"config.altauth.servers": "Vertraute AltAuth Server"
}

Datei anzeigen

@ -0,0 +1,10 @@
{
"gui.altauth.confirm.title": "%s wants to use '%s' as AltAuth Server",
"gui.altauth.confirm.text": "Do you want to trust\n'%s'\nas an Authentication server?\n\n§4§lWARNING: §rThe Authentication server is not provided by Mojang and can be unsafe!\nA Malicious actor can use the info send to this Server to login and use your Minecraft Account on §4§lANY§r server!\n\nMake sure that you trust this Server!",
"gui.altauth.connecting": "Connecting with AltAuth '%s'...",
"gui.altauth.error": "AltAuth error",
"config.altauth.title": "AltAuth Client Config",
"config.altauth.general": "General",
"config.altauth.enabled": "AltAuth Enabled",
"config.altauth.servers": "Trusted AltAuth Servers"
}

Datei anzeigen

@ -16,6 +16,4 @@ public class AltAuth {
public static final Logger LOGGER = LogManager.getLogger();
public static ServerAddress address;
public static boolean trustOnce = false;
}

Datei anzeigen

@ -1,49 +0,0 @@
// SPDX-License-Identifier: MIT
package de.chaoscaot.altauth.fabric;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.WarningScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.text.Text;
@Environment(EnvType.CLIENT)
public class TrustServerScreen extends WarningScreen {
private static final Text MESSAGE = Text.of("Do you want to trust this server?");
private final String serverId;
private final Screen parent;
public TrustServerScreen(String serverAddress, Screen parent) {
super(Text.of("Trust '" + serverAddress + "'"), MESSAGE, Text.of("Do you want to Trust '" + serverAddress + "'?"));
this.serverId = serverAddress;
this.parent = null;
}
@Override
protected void initButtons(int yOffset) {
// Yes, Once, Cancel
addDrawableChild(new ButtonWidget(width / 2 - 155, height / 6 + 96 + yOffset, 150, 20, Text.of("Yes"), (buttonWidget) -> {
ClientConfig.INSTANCE.allowedServers.add(serverId);
ClientConfig.INSTANCE.save();
ConnectScreen.connect(parent, client, AltAuth.address, null);
}));
addDrawableChild(new ButtonWidget(width / 2 - 155 + 160, height / 6 + 96 + yOffset + 30, 150, 20, Text.of("Once"), (buttonWidget) -> {
AltAuth.trustOnce = true;
ConnectScreen.connect(parent, client, AltAuth.address, null);
}));
addDrawableChild(new ButtonWidget(width / 2 - 155 + 160, height / 6 + 96 + yOffset + 60, 150, 20, Text.of("Cancel"), (buttonWidget) -> {
client.setScreen(parent);
}));
}
}

Datei anzeigen

@ -1,8 +1,11 @@
// SPDX-License-Identifier: MIT
package de.chaoscaot.altauth.fabric;
package de.chaoscaot.altauth.fabric.config;
import com.google.gson.JsonSyntaxException;
import de.chaoscaot.altauth.fabric.AltAuth;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
import java.io.File;
@ -11,6 +14,7 @@ import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
@Environment(EnvType.CLIENT)
public class ClientConfig {
private static final String CONFIG_FILE_NAME = "altauth.client.json";

Datei anzeigen

@ -0,0 +1,42 @@
// SPDX-License-Identifier: MIT
package de.chaoscaot.altauth.fabric.config;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import me.shedaniel.clothconfig2.api.ConfigBuilder;
import me.shedaniel.clothconfig2.api.ConfigCategory;
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import java.util.ArrayList;
@Environment(EnvType.CLIENT)
public class ModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> {
ConfigBuilder builder = ConfigBuilder.create()
.setParentScreen(parent)
.setTitle(Text.translatable("config.altauth.title"));
builder.setSavingRunnable(ClientConfig.INSTANCE::save);
ConfigEntryBuilder entryBuilder = builder.entryBuilder();
ConfigCategory general = builder.getOrCreateCategory(Text.translatable("config.altauth.general"));
general.addEntry(entryBuilder.startBooleanToggle(Text.translatable("config.altauth.enabled"), ClientConfig.INSTANCE.enabled)
.setDefaultValue(true)
.setSaveConsumer(value -> ClientConfig.INSTANCE.enabled = value)
.build());
general.addEntry(entryBuilder.startStrList(Text.translatable("config.altauth.servers"), ClientConfig.INSTANCE.allowedServers)
.setDefaultValue(new ArrayList<>())
.setSaveConsumer(list -> ClientConfig.INSTANCE.allowedServers = list)
.build());
return builder.build();
};
}
}

Datei anzeigen

@ -1,14 +1,18 @@
// SPDX-License-Identifier: MIT
package de.chaoscaot.altauth.fabric;
package de.chaoscaot.altauth.fabric.config;
import com.google.gson.JsonSyntaxException;
import de.chaoscaot.altauth.fabric.AltAuth;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@Environment(EnvType.SERVER)
public class ServerConfig {
private static final String CONFIG_FILE_NAME = "altauth.json";

Datei anzeigen

@ -1,7 +1,6 @@
package de.chaoscaot.altauth.fabric.mixin;
import de.chaoscaot.altauth.fabric.AltAuth;
import de.chaoscaot.altauth.fabric.TrustServerScreen;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.network.ServerAddress;
import org.spongepowered.asm.mixin.Mixin;

Datei anzeigen

@ -2,17 +2,17 @@
package de.chaoscaot.altauth.fabric.mixin;
import com.mojang.authlib.yggdrasil.YggdrasilEnvironment;
import de.chaoscaot.altauth.fabric.AltAuth;
import de.chaoscaot.altauth.fabric.ClientConfig;
import de.chaoscaot.altauth.fabric.TrustServerScreen;
import de.chaoscaot.altauth.fabric.config.ClientConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConfirmScreen;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.DisconnectedScreen;
import net.minecraft.client.network.ClientLoginNetworkHandler;
import net.minecraft.network.packet.s2c.login.LoginHelloS2CPacket;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import org.joor.Reflect;
import org.slf4j.Logger;
@ -30,34 +30,49 @@ import java.net.URL;
public class LoginRequestMixin {
@Shadow @Final private static Logger LOGGER;
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/login/LoginHelloS2CPacket;getServerId()Ljava/lang/String;"), method = "onHello")
@Shadow @Final private MinecraftClient client;
@Inject(at = @At("HEAD"), method = "onHello", cancellable = true)
public void onHello(LoginHelloS2CPacket packet, CallbackInfo ci) {
String server = "chaoscaot.de";//packet.getServerId();
try {
if(packet.getServerId().contains(".")) {
LOGGER.info("AltauthClient: LoginRequestMixin: Server is running on a custom: {}", packet.getServerId());
if(ClientConfig.INSTANCE.allowedServers.contains(packet.getServerId()) || AltAuth.trustOnce) {
AltAuth.trustOnce = false;
URL url = new URL("https://" + packet.getServerId() + "/session/minecraft/join");
//if(packet.getServerId().contains(".")) {
LOGGER.info("AltauthClient: LoginRequestMixin: Server is running on a custom: {}", server);
if(ClientConfig.INSTANCE.allowedServers.contains(server)) {
if(MinecraftClient.getInstance().currentScreen instanceof ConnectScreen cs) {
cs.status = Text.translatable("gui.altauth.connecting", server);
}
URL url = new URL("https://" + server + "/session/minecraft/join");
Reflect.on(MinecraftClient.getInstance().getSessionService()).set("joinUrl", url);
} else {
if(MinecraftClient.getInstance().currentScreen instanceof ConnectScreen cs) {
ci.cancel();
cs.connectingCancelled = true;
if( cs.connection != null) {
cs.connection.disconnect(Text.translatable("connect.aborted"));
}
MinecraftClient.getInstance().setScreen(new TrustServerScreen(packet.getServerId(), cs.parent));
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new ConfirmScreen(t -> {
if(t) {
ClientConfig.INSTANCE.allowedServers.add(server);
ClientConfig.INSTANCE.save();
ConnectScreen.connect(cs.parent, client, AltAuth.address, null);
} else {
client.setScreen(cs.parent);
}
}, Text.translatable("gui.altauth.confirm.title", AltAuth.address.getAddress(), server), Text.translatable("gui.altauth.confirm.text", server), ScreenTexts.YES, ScreenTexts.CANCEL)));
}
}
} else {
/*} else {
LOGGER.info("AltauthClient: LoginRequestMixin: Server is running on mojang");
URL url = new URL(YggdrasilEnvironment.PROD.getEnvironment().getSessionHost() + "/session/minecraft/join");
Reflect.on(MinecraftClient.getInstance().getSessionService()).set("joinUrl", url);
}
}*/
} catch (Exception e) {
e.printStackTrace();
if(MinecraftClient.getInstance().currentScreen instanceof ConnectScreen cs) {
MinecraftClient.getInstance().setScreen(new DisconnectedScreen(cs.parent, Text.of("AltAuth error"), Text.of(e.getMessage())));
client.execute(() -> MinecraftClient.getInstance().setScreen(new DisconnectedScreen(cs.parent, Text.translatable("gui.altauth.error"), Text.of(e.getMessage()))));
}
}
}

Datei anzeigen

@ -1,7 +1,7 @@
package de.chaoscaot.altauth.fabric.mixin;
import de.chaoscaot.altauth.fabric.AltAuth;
import de.chaoscaot.altauth.fabric.ServerConfig;
import de.chaoscaot.altauth.fabric.config.ServerConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;

Datei anzeigen

@ -2,7 +2,7 @@
package de.chaoscaot.altauth.fabric.mixin;
import de.chaoscaot.altauth.fabric.ServerConfig;
import de.chaoscaot.altauth.fabric.config.ServerConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.network.PacketByteBuf;

Datei anzeigen

@ -1,11 +1,16 @@
{
"schemaVersion": 1,
"id": "alt-auth-client",
"id": "altauth",
"version": "${version}",
"name": "AltAuth",
"description": "Use AltAuth",
"authors": [],
"contact": {},
"description": "AltAuth in your Game",
"authors": ["Chaoscaot <chaoscaot@zohomail.eu>", "Lixfel"],
"contact": {
"email": "chaoscaot@zohomail.eu",
"sources": "https://steamwar.de/devlabs/Lixfel/AltAuth",
"homepage": "https://steamwar.de/devlabs/Lixfel/AltAuth",
"issues": "https://steamwar.de/devlabs/Lixfel/AltAuth/issues"
},
"license": "MIT",
"environment": "*",
"mixins": [
@ -15,5 +20,14 @@
"fabricloader": ">=0.13.3",
"minecraft": ">=1.18.2"
},
"accessWidener": "altauth.accesswidener"
"recommends": {
"modmenu": "*",
"cloth-config": "*"
},
"accessWidener": "altauth.accesswidener",
"entrypoints": {
"modmenu": [
"de.chaoscaot.altauth.fabric.config.ModMenuIntegration"
]
}
}