Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 38 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
plugins {
id 'fabric-loom' version '0.4-SNAPSHOT'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name
version = project.mod_version

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.

maven {
name = "CottonMC"
url = "https://server.bbkr.space/artifactory/libs-release"
}

maven {
url "https://maven.shedaniel.me/"
}

maven {
url "https://maven.terraformersmc.com/releases/"
}
}

dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand All @@ -18,9 +39,10 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modApi "me.sargunvohra.mcmods:autoconfig1u:3.2.0-unstable"
modImplementation "io.github.prospector:modmenu:1.14.6+build.31"
modApi ("me.shedaniel.cloth:config-2:4.7.0-unstable") {
//modApi "me.sargunvohra.mcmods:autoconfig1u:3.2.0-unstable"
//modImplementation "io.github.prospector:modmenu:1.14.6+build.31"
modImplementation "com.terraformersmc:modmenu:2.0.2"
modApi("me.shedaniel.cloth:cloth-config-fabric:5.0.34") {
exclude(group: "net.fabricmc.fabric-api")
}
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
Expand All @@ -30,13 +52,17 @@ dependencies {
processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
expand "version": project.version
}
//from(sourceSets.main.resources.srcDirs) {
// include "fabric.mod.json"
// expand "version": project.version
//}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
//from(sourceSets.main.resources.srcDirs) {
// exclude "fabric.mod.json"
//}

filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.2
yarn_mappings=1.16.2+build.1
loader_version=0.9.1+build.205
minecraft_version=1.17
yarn_mappings=1.17+build.1
loader_version=0.11.3

# Mod Properties
mod_version = 3.9.3
archives_base_name = ReAuth-1.16-Fabric
mod_version = 3.9.4
archives_base_name = ReAuth-1.17-Fabric

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.19.0+build.398-1.16
fabric_version=0.34.9+1.17
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ pluginManagement {
}
}

rootProject.name='ReAuth Fabric 1.16'
rootProject.name='ReAuth Fabric 1.17'
12 changes: 6 additions & 6 deletions src/main/java/technicianlp/reauth/ConfigWrapper.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package technicianlp.reauth;

import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.ConfigHolder;
import me.sargunvohra.mcmods.autoconfig1u.ConfigManager;
import me.sargunvohra.mcmods.autoconfig1u.serializer.Toml4jConfigSerializer;
import net.fabricmc.loader.api.FabricLoader;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.util.Base64;

import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.ConfigHolder;
import me.shedaniel.autoconfig.ConfigManager;
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
import net.fabricmc.loader.api.FabricLoader;

public final class ConfigWrapper {

public static final String CONFIG_NAME = "../reauth";
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/technicianlp/reauth/Configuration.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package technicianlp.reauth;

import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
import me.shedaniel.autoconfig.annotation.ConfigEntry;
import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.Comment;

@Config(name = ConfigWrapper.CONFIG_NAME)
public final class Configuration implements ConfigData {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/technicianlp/reauth/gui/AuthScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,30 @@ public void init() {
this.username = new TextFieldWidget(this.textRenderer, this.width / 2 - 155, this.baseY + 15, 2 * 155, 20, new TranslatableText("reauth.gui.auth.username"));
this.username.setMaxLength(512);
this.username.setText(ReAuth.config.getUsername());
addButton(username);
addDrawableChild(username);

this.pw = new PasswordFieldWidget(this.textRenderer, this.width / 2 - 155, this.baseY + 60, 2 * 155, 20, new TranslatableText("reauth.gui.auth.password"));
this.pw.setMaxLength(Short.MAX_VALUE);
this.pw.setText(ReAuth.config.getPassword());
addButton(this.pw);
addDrawableChild(this.pw);

setInitialFocus(username.getText().isEmpty() ? username : pw);

this.save = new CheckboxWidget(this.width / 2 - 155, this.baseY + 85, 2 * 155, 20, new TranslatableText("reauth.gui.auth.checkbox"), !pw.getText().isEmpty());
if (ReAuth.config.hasCrypto()) {
addButton(this.save);
addDrawableChild(this.save);
}

this.confirm = new ButtonWidget(this.width / 2 - 155, this.baseY + 110, 153, 20, LiteralText.EMPTY, b -> doLogin());
addButton(confirm);
addDrawableChild(confirm);
this.cancel = new ButtonWidget(this.width / 2 + 2, this.baseY + 110, 155, 20, new TranslatableText("gui.cancel"), b -> this.client.openScreen(prev));
addButton(cancel);
addDrawableChild(cancel);

this.config = new ButtonWidget(this.width - 80, this.height - 25, 75, 20, new TranslatableText("reauth.gui.auth.config"), b -> {
this.client.openScreen(ClothConfigIntegration.getConfigScreen(this));
});
if (ClothConfigIntegration.isAvailable()) {
addButton(config);
addDrawableChild(config);
}

if (message.isEmpty() && ReAuth.versionCheck.getStatus() == VersionChecker.Status.OUTDATED) {
Expand Down Expand Up @@ -115,9 +115,9 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTi
private void focus(TextFieldWidget widget) {
Element old = getFocused();
if (old instanceof TextFieldWidget)
((TextFieldWidget) old).setSelected(false);
((TextFieldWidget) old).setTextFieldFocused(false);
if (widget != null)
widget.setSelected(true);
widget.setTextFieldFocused(true);
focusOn(widget);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package technicianlp.reauth.integration;


import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.gui.screen.Screen;
import technicianlp.reauth.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.shedaniel.autoconfig.AutoConfig;
import technicianlp.reauth.Configuration;

public final class ModMenuIntegration implements ModMenuApi {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package technicianlp.reauth.mixin;

import static technicianlp.reauth.mixinUtil.DisconnectUtil.getTranslationKey;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.DisconnectedScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import technicianlp.reauth.ReAuth;
import technicianlp.reauth.gui.AuthScreen;
import technicianlp.reauth.mixinUtil.DisconnectUtil;
import technicianlp.reauth.mixinUtil.DisconnectedScreenDuck;

import static technicianlp.reauth.mixinUtil.DisconnectUtil.getTranslationKey;

@Mixin(DisconnectedScreen.class)
public abstract class DisconnectedScreenMixin extends Screen implements DisconnectedScreenDuck {
protected DisconnectedScreenMixin() {
Expand All @@ -38,7 +38,7 @@ protected DisconnectedScreenMixin() {
private void reauthInit(CallbackInfo info) {
if ("connect.failed".equals(getTranslationKey(this.getTitle()))) {
if (getTranslationKey(reauthGetReason()).startsWith("disconnect.loginFailed")) {
AbstractButtonWidget menu = this.buttons.get(0);
ButtonWidget menu = (ButtonWidget) this.children().get(0);

String key = DisconnectUtil.canRetryLogin() ? "reauth.retry" : "reauth.retry.disabled";
Text retryText = new TranslatableText(key, ReAuth.config.getProfile());
Expand All @@ -48,8 +48,8 @@ private void reauthInit(CallbackInfo info) {
if (!DisconnectUtil.canRetryLogin()) {
retryButton.active = false;
}
this.addButton(retryButton);
this.addButton(new ButtonWidget(menu.x, menu.y + 50, 200, 20, new TranslatableText("reauth.open"), b -> {
this.addDrawableChild(retryButton);
this.addDrawableChild(new ButtonWidget(menu.x, menu.y + 50, 200, 20, new TranslatableText("reauth.open"), b -> {
MinecraftClient.getInstance().openScreen(new AuthScreen(reauthGetParent()));
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private void reauthInit(CallbackInfo info) {
if(Screen.hasShiftDown()) {
ReAuth.auth.getSessionStatus(true);
}
addButton(new ButtonWidget(5, 5, 100, 20, new TranslatableText("reauth.gui.button"),
addDrawableChild(new ButtonWidget(5, 5, 100, 20, new TranslatableText("reauth.gui.button"),
b -> MinecraftClient.getInstance().openScreen(new AuthScreen(this))));
}

Expand Down
10 changes: 6 additions & 4 deletions src/main/java/technicianlp/reauth/mixinUtil/DisconnectUtil.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package technicianlp.reauth.mixinUtil;

import java.net.InetSocketAddress;
import java.net.SocketAddress;

import com.mojang.authlib.exceptions.AuthenticationException;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.text.TranslatableText;
import technicianlp.reauth.ReAuth;
import technicianlp.reauth.gui.AuthScreen;

import java.net.InetSocketAddress;
import java.net.SocketAddress;

public class DisconnectUtil {
private static ConnectScreenDuck screen;

Expand All @@ -38,7 +40,7 @@ public static void retryLogin() {
if (add instanceof InetSocketAddress) {
InetSocketAddress address = (InetSocketAddress) add;
MinecraftClient client = MinecraftClient.getInstance();
client.openScreen(new ConnectScreen(screen.reauthGetParent(), client, address.getHostString(), address.getPort()));
ConnectScreen.connect(screen.reauthGetParent(), client, new ServerAddress(address.getHostString(), address.getPort()), null);
}
}
} catch (AuthenticationException exception) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"minecraft": "1.16.*",
"autoconfig1u": "*"
"minecraft": "1.17.*"
},
"recommends": {
"cloth-config2": "*",
Expand Down