Got Fabric in the Repo :D #1
22
build.gradle
22
build.gradle
@ -12,10 +12,11 @@ plugins {
|
|||||||
id 'application'
|
id 'application'
|
||||||
|
|
||||||
id 'com.github.johnrengelman.shadow' version '5.0.0'
|
id 'com.github.johnrengelman.shadow' version '5.0.0'
|
||||||
|
id 'fabric-loom' version '1.0-SNAPSHOT' apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'de.lixfel'
|
group 'de.lixfel'
|
||||||
version ''
|
version project.version
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
buildName = 'AltAuth'
|
buildName = 'AltAuth'
|
||||||
@ -26,9 +27,6 @@ ext {
|
|||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
targetCompatibility = 1.8
|
|
||||||
|
|
||||||
mainClassName = ''
|
mainClassName = ''
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
@ -39,11 +37,27 @@ allprojects {
|
|||||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
|
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
|
||||||
|
|
||||||
maven { url = uri('https://steamwar.de/maven') }
|
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 {
|
dependencies {
|
||||||
implementation project(":bukkit")
|
implementation project(":bukkit")
|
||||||
implementation project(":bungee")
|
implementation project(":bungee")
|
||||||
|
implementation project(":fabric")
|
||||||
implementation project(":common")
|
implementation project(":common")
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,6 @@ version ''
|
|||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
targetCompatibility = 1.8
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
java {
|
java {
|
||||||
|
@ -10,9 +10,6 @@ version ''
|
|||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
targetCompatibility = 1.8
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
java {
|
java {
|
||||||
|
@ -10,9 +10,6 @@ version ''
|
|||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
targetCompatibility = 1.8
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
java {
|
java {
|
||||||
|
47
fabric/build.gradle
Normale Datei
47
fabric/build.gradle
Normale Datei
@ -0,0 +1,47 @@
|
|||||||
|
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")
|
||||||
|
|
||||||
|
// Used to Override 'private final'
|
||||||
|
implementation 'org.jooq:joor:0.9.14'
|
||||||
|
include 'org.jooq:joor:0.9.14'
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property "version", project.version
|
||||||
|
filteringCharset "UTF-8"
|
||||||
|
|
||||||
|
filesMatching("fabric.mod.json") {
|
||||||
|
expand "version": project.version
|
||||||
|
}
|
||||||
|
}
|
15
fabric/src/alt-auth.mixins.json
Normale Datei
15
fabric/src/alt-auth.mixins.json
Normale Datei
@ -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
|
||||||
|
}
|
||||||
|
}
|
18
fabric/src/de/chaoscaot/altauth/AltAuth.java
Normale Datei
18
fabric/src/de/chaoscaot/altauth/AltAuth.java
Normale Datei
@ -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() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
10
fabric/src/de/chaoscaot/altauth/AltAuthClient.java
Normale Datei
10
fabric/src/de/chaoscaot/altauth/AltAuthClient.java
Normale Datei
@ -0,0 +1,10 @@
|
|||||||
|
package de.chaoscaot.altauth;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
|
||||||
|
public class AltAuthClient implements ClientModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
10
fabric/src/de/chaoscaot/altauth/AltAuthServer.java
Normale Datei
10
fabric/src/de/chaoscaot/altauth/AltAuthServer.java
Normale Datei
@ -0,0 +1,10 @@
|
|||||||
|
package de.chaoscaot.altauth;
|
||||||
|
|
||||||
|
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||||
|
|
||||||
|
public class AltAuthServer implements DedicatedServerModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitializeServer() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
fabric/src/de/chaoscaot/altauth/gui/ApproveServerScreen.java
Normale Datei
22
fabric/src/de/chaoscaot/altauth/gui/ApproveServerScreen.java
Normale Datei
@ -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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
42
fabric/src/de/chaoscaot/altauth/mixin/client/LoginRequestMixin.java
Normale Datei
42
fabric/src/de/chaoscaot/altauth/mixin/client/LoginRequestMixin.java
Normale Datei
@ -0,0 +1,42 @@
|
|||||||
|
package de.chaoscaot.altauth.mixin.client;
|
||||||
|
|
||||||
|
import com.mojang.authlib.yggdrasil.YggdrasilEnvironment;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.ClientLoginNetworkHandler;
|
||||||
|
import net.minecraft.network.packet.s2c.login.LoginHelloS2CPacket;
|
||||||
|
import org.joor.Reflect;
|
||||||
|
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.net.URL;
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
@Mixin(ClientLoginNetworkHandler.class)
|
||||||
|
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")
|
||||||
|
public void onHello(LoginHelloS2CPacket packet, CallbackInfo ci) {
|
||||||
|
try {
|
||||||
|
if(packet.getServerId().contains(".")) {
|
||||||
|
LOGGER.info("AltauthClient: LoginRequestMixin: Server is running on a custom: {}", packet.getServerId());
|
||||||
|
URL url = new URL("https://" + packet.getServerId() + "/session/minecraft/join");
|
||||||
|
Reflect.on(MinecraftClient.getInstance().getSessionService()).set("joinUrl", url);
|
||||||
|
} 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();
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
fabric/src/de/chaoscaot/altauth/mixin/server/ServerIdMixin.java
Normale Datei
20
fabric/src/de/chaoscaot/altauth/mixin/server/ServerIdMixin.java
Normale Datei
@ -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
29
fabric/src/fabric.mod.json
Normale Datei
@ -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
8
gradle.properties
Normale Datei
@ -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
|
||||||
|
|
@ -1,7 +1,18 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = 'Fabric'
|
||||||
|
url = 'https://maven.fabricmc.net/'
|
||||||
|
}
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rootProject.name = 'AltAuth'
|
rootProject.name = 'AltAuth'
|
||||||
|
|
||||||
include 'bukkit'
|
include 'bukkit'
|
||||||
include 'bungee'
|
include 'bungee'
|
||||||
include 'common'
|
include 'common'
|
||||||
|
include 'fabric'
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren