Got Fabric in the Repo :D

Dieser Commit ist enthalten in:
Chaoscaot 2022-09-23 21:02:46 +02:00
Ursprung dfc561e17b
Commit 95ffafafe9
17 geänderte Dateien mit 343 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -12,10 +12,11 @@ plugins {
id 'application'
id 'com.github.johnrengelman.shadow' version '5.0.0'
id 'fabric-loom' version '1.0-SNAPSHOT' apply false
}
group 'de.lixfel'
version ''
version project.version
ext {
buildName = 'AltAuth'
@ -26,9 +27,6 @@ ext {
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.8
targetCompatibility = 1.8
mainClassName = ''
allprojects {
@ -39,11 +37,27 @@ allprojects {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url = uri('https://steamwar.de/maven') }
maven { url 'https://maven.fabricmc.net/' }
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
}
configurations {
compileClasspath
}
}
subprojects {
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.release = 8
}
}
dependencies {
implementation project(":bukkit")
implementation project(":bungee")
implementation project(":fabric")
implementation project(":common")
}

Datei anzeigen

@ -10,9 +10,6 @@ version ''
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
java {

Datei anzeigen

@ -10,9 +10,6 @@ version ''
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
java {

Datei anzeigen

@ -10,9 +10,6 @@ version ''
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
java {

43
fabric/build.gradle Normale Datei
Datei anzeigen

@ -0,0 +1,43 @@
plugins {
id 'fabric-loom'
}
tasks.withType(JavaCompile) {
options.release = 17
}
version = project.version
group = 'de.chaoscaot'
sourceSets {
main {
java {
srcDirs = ['src/']
}
resources {
srcDirs = ['src/']
exclude '**/*.java'
}
}
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modCompileOnly "net.fabricmc:fabric-loader:${project.loader_version}"
modCompileOnlyApi ("me.shedaniel.cloth:cloth-config-fabric:8.2.88") {
exclude(group: "net.fabricmc.fabric-api")
}
modCompileOnlyApi "com.terraformersmc:modmenu:4.0.6"
compileOnly project(":common")
}
processResources {
inputs.property "version", project.version
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

Datei anzeigen

@ -0,0 +1,15 @@
{
"required": true,
"minVersion": "0.8",
"package": "de.chaoscaot.altauth.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"client.LoginRequestMixin"
],
"server": [
"server.ServerIdMixin"
],
"injectors": {
"defaultRequire": 1
}
}

Datei anzeigen

@ -0,0 +1,18 @@
package de.chaoscaot.altauth;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.fabricmc.api.ModInitializer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class AltAuth implements ModInitializer {
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
public static final Logger LOGGER = LogManager.getLogger();
@Override
public void onInitialize() {
}
}

Datei anzeigen

@ -0,0 +1,10 @@
package de.chaoscaot.altauth;
import net.fabricmc.api.ClientModInitializer;
public class AltAuthClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
}
}

Datei anzeigen

@ -0,0 +1,10 @@
package de.chaoscaot.altauth;
import net.fabricmc.api.DedicatedServerModInitializer;
public class AltAuthServer implements DedicatedServerModInitializer {
@Override
public void onInitializeServer() {
}
}

Datei anzeigen

@ -0,0 +1,43 @@
package de.chaoscaot.altauth.config.client;
import de.chaoscaot.altauth.AltAuth;
import net.fabricmc.loader.api.FabricLoader;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
public class AltAuthClientConfig {
private static final String CONFIG_FILE_NAME = "altauth.client.json";
public static AltAuthClientConfig INSTANCE;
static {
if(!new File(FabricLoader.getInstance().getConfigDir().toFile(), CONFIG_FILE_NAME).exists()) {
INSTANCE = new AltAuthClientConfig();
} else {
try {
INSTANCE = AltAuth.GSON.fromJson(Files.readString(FabricLoader.getInstance().getConfigDir().resolve(CONFIG_FILE_NAME)), AltAuthClientConfig.class);
} catch (IOException e) {
AltAuth.LOGGER.error("AltauthClient: AltAuthClientConfig: Error while loading config", e);
AltAuth.LOGGER.info("Reset Config...");
INSTANCE = new AltAuthClientConfig();
INSTANCE.save();
}
}
}
public boolean enabled = true;
public List<String> allowedServers = new ArrayList<>();
public void save() {
try {
Files.writeString(FabricLoader.getInstance().getConfigDir().resolve(CONFIG_FILE_NAME), AltAuth.GSON.toJson(this));
} catch (IOException e) {
AltAuth.LOGGER.error("AltauthClient: AltAuthClientConfig: Error while saving config", e);
}
}
}

Datei anzeigen

@ -0,0 +1,44 @@
package de.chaoscaot.altauth.config.server;
import de.chaoscaot.altauth.AltAuth;
import net.fabricmc.loader.api.FabricLoader;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
public class AltAuthServerConfig {
private static final String CONFIG_FILE_NAME = "altauth.json";
public static AltAuthServerConfig INSTANCE;
static {
if(!new File(FabricLoader.getInstance().getConfigDir().toFile(), CONFIG_FILE_NAME).exists()) {
INSTANCE = new AltAuthServerConfig();
} else {
try {
INSTANCE = AltAuth.GSON.fromJson(Files.readString(FabricLoader.getInstance().getConfigDir().resolve(CONFIG_FILE_NAME)), AltAuthServerConfig.class);
if(INSTANCE.serverUrl.length() > 20) {
AltAuth.LOGGER.error("AltauthServer: AltAuthServerConfig: ServerUrl is too long. Max length is 20 characters");
INSTANCE.serverUrl = "";
}
} catch (IOException e) {
AltAuth.LOGGER.error("AltauthServer: AltAuthServerConfig: Error while loading config", e);
AltAuth.LOGGER.info("Reset Config...");
INSTANCE = new AltAuthServerConfig();
INSTANCE.save();
}
}
}
public String serverUrl = "EnterNameHere";
public void save() {
try {
Files.writeString(FabricLoader.getInstance().getConfigDir().resolve(CONFIG_FILE_NAME), AltAuth.GSON.toJson(this));
} catch (IOException e) {
AltAuth.LOGGER.error("AltauthServer: AltAuthServerConfig: Error while saving config", e);
}
}
}

Datei anzeigen

@ -0,0 +1,22 @@
package de.chaoscaot.altauth.gui;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.WarningScreen;
import net.minecraft.text.Text;
@Environment(EnvType.CLIENT)
public class ApproveServerScreen extends WarningScreen {
private static final Text TITLE = Text.of("Approve Server");
private static final Text MESSAGE = Text.of("Do you want to approve this server?");
private static final Text NARRATOR_MESSAGE = Text.of("Do you want to approve this server?");
public ApproveServerScreen(String serverAddress) {
super(TITLE, MESSAGE, NARRATOR_MESSAGE);
}
@Override
protected void initButtons(int yOffset) {
}
}

Datei anzeigen

@ -0,0 +1,52 @@
package de.chaoscaot.altauth.mixin.client;
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
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.network.ClientLoginNetworkHandler;
import net.minecraft.network.packet.s2c.login.LoginHelloS2CPacket;
import net.minecraft.text.Text;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.lang.reflect.Field;
import java.net.URL;
@Environment(EnvType.CLIENT)
@Mixin(ClientLoginNetworkHandler.class)
public class LoginRequestMixin {
@Shadow @Final private static Logger LOGGER;
private static final Class<YggdrasilMinecraftSessionService> YGGDRASIL_MINECRAFT_SESSION_SERVICE_CLASS = YggdrasilMinecraftSessionService.class;
private static final Field YGGDRASIL_MINECRAFT_SESSION_SERVICE_JOIN_URL;
static {
try {
YGGDRASIL_MINECRAFT_SESSION_SERVICE_JOIN_URL = YGGDRASIL_MINECRAFT_SESSION_SERVICE_CLASS.getDeclaredField("joinUrl");
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
}
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/login/LoginHelloS2CPacket;getServerId()Ljava/lang/String;"), method = "onHello")
public void onHello(LoginHelloS2CPacket packet, CallbackInfo ci) {
try {
if(packet.getServerId().contains(".")) {
LOGGER.info("AltauthClient: LoginRequestMixin: Server is running on a custom: {}", packet.getServerId());
YGGDRASIL_MINECRAFT_SESSION_SERVICE_JOIN_URL.set(MinecraftClient.getInstance().getSessionService(), new URL("https://" + packet.getServerId() + "/session/minecraft/join"));
} else {
LOGGER.info("AltauthClient: LoginRequestMixin: Server is running on mojang");
YGGDRASIL_MINECRAFT_SESSION_SERVICE_JOIN_URL.set(MinecraftClient.getInstance().getSessionService(), new URL("https://sessionserver.mojang.com/session/minecraft/join"));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

Datei anzeigen

@ -0,0 +1,20 @@
package de.chaoscaot.altauth.mixin.server;
import de.chaoscaot.altauth.config.server.AltAuthServerConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.login.LoginHelloS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Environment(EnvType.SERVER)
@Mixin(LoginHelloS2CPacket.class)
public class ServerIdMixin {
@Redirect(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;writeString(Ljava/lang/String;)Lnet/minecraft/network/PacketByteBuf;"))
public PacketByteBuf writeString(PacketByteBuf packetByteBuf, String string) {
return packetByteBuf.writeString(AltAuthServerConfig.INSTANCE.serverUrl);
}
}

29
fabric/src/fabric.mod.json Normale Datei
Datei anzeigen

@ -0,0 +1,29 @@
{
"schemaVersion": 1,
"id": "alt-auth-client",
"version": "${version}",
"name": "AltAuth",
"description": "Use AltAuth",
"authors": [],
"contact": {},
"license": "MIT",
"environment": "*",
"entrypoints": {
"main": [
"de.chaoscaot.altauth.AltAuth"
],
"client": [
"de.chaoscaot.altauth.AltAuthClient"
],
"server": [
"de.chaoscaot.altauth.AltAuthServer"
]
},
"mixins": [
"alt-auth.mixins.json"
],
"depends": {
"fabricloader": ">=0.13.3",
"minecraft": ">=1.18.2"
}
}

8
gradle.properties Normale Datei
Datei anzeigen

@ -0,0 +1,8 @@
org.gradle.jvmargs=-Xmx1G
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.4
loader_version=0.14.9
version=1.0.0

Datei anzeigen

@ -1,7 +1,18 @@
// SPDX-License-Identifier: MIT
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}
rootProject.name = 'AltAuth'
include 'bukkit'
include 'bungee'
include 'common'
include 'fabric'