Skip to content

Commit

Permalink
Add Version Property to @Mod Annotation (#5)
Browse files Browse the repository at this point in the history
* Update buildscript

* Remove dead code

* Add version property to Mod annotation

* Enable Jabel and generic injection
  • Loading branch information
glowredman authored Feb 14, 2024
1 parent ef27d3b commit 205d4fb
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 61 deletions.
19 changes: 10 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,37 @@ channel = stable
mappingsVersion = 12

# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/

# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
developmentEnvironmentUserName = "Developer"
developmentEnvironmentUserName = Developer

# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = false
enableModernJavaSyntax = true

# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
enableGenericInjection = true

# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass =
generateGradleTokenClass = com.sintinium.oauth.Tags

# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion =
gradleTokenVersion = VERSION

# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =

# [DEPRECATED] Mod name replacement token.
gradleTokenModName =

# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName =

# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
Expand Down Expand Up @@ -123,7 +126,7 @@ includeWellKnownRepositories = true
usesMavenPublishing = true

# Maven repository to publish the mod to.
# mavenPublishUrl = https://nexus.gtnewhorizons.com/repository/releases/
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/

# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
Expand Down Expand Up @@ -187,5 +190,3 @@ disableCheckstyle = true
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true

# Non-GTNH properties
gradleTokenGroupName =
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.8'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.14'
}


3 changes: 0 additions & 3 deletions src/main/java/com/sintinium/oauth/EncryptionUtil.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.sintinium.oauth;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;

import javax.crypto.Cipher;
Expand All @@ -15,12 +14,10 @@
public class EncryptionUtil {

private static Cipher cipher;
private static SecureRandom random;

static {
try {
cipher = Cipher.getInstance("AES/CTR/NoPadding");
random = SecureRandom.getInstance("SHA1PRNG");
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/sintinium/oauth/GuiEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public class GuiEventHandler {

private static TextWidget statusText = new TextWidget(10 + 66 + 3, 12, I18n.format("oauth.status.loading"));

@SuppressWarnings("unchecked")
@SubscribeEvent
public void multiplayerScreenOpen(GuiScreenEvent.InitGuiEvent.Post event) {
if (!(event.gui instanceof GuiMultiplayer)) return;
GuiMultiplayer multiplayerScreen = (GuiMultiplayer) event.gui;
try {
// Method addButtonMethod = ObfuscationReflectionHelper.findMethod(Screen.class, "addButton", Widget.class);
// Method addButtonMethod = ObfuscationReflectionHelper.findMethod(Screen.class, "func_230480_a_",
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/com/sintinium/oauth/OAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;

// The value here should match an entry in the META-INF/mods.toml file
@Mod(modid = "oauth", name = "OAuth", acceptableRemoteVersions = "*")
@Mod(
modid = "oauth",
name = "OAuth",
acceptableRemoteVersions = "*",
acceptedMinecraftVersions = "[1.7.10]",
version = Tags.VERSION)
public class OAuth {

// Directly reference a log4j logger.
private static final Logger LOGGER = LogManager.getLogger();

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
if (event.getSide().isClient()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ public class LoginLoadingScreen extends GuiScreenCustom {
private int dots = 0;
private String renderText = loadingText;

private GuiScreen multiplayerScreen;
private GuiScreen lastScreen;
private int tick = 0;
private Runnable onCancel;
private boolean isMicrosoft;
private String title = I18n.format("oauth.screen.title.microsoft");
private AtomicReference<String> updateText = new AtomicReference<>();

protected LoginLoadingScreen(GuiScreen multiplayerScreen, GuiScreen callingScreen, Runnable onCancel,
boolean isMicrosoft) {
this.multiplayerScreen = multiplayerScreen;
protected LoginLoadingScreen(GuiScreen callingScreen, Runnable onCancel, boolean isMicrosoft) {
this.lastScreen = callingScreen;
this.onCancel = onCancel;
this.isMicrosoft = isMicrosoft;
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/com/sintinium/oauth/gui/LoginScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,12 @@ public void initGui() {
20);
this.passwordWidget.setMaxStringLength(128);

this.usernameWidget = new UsernameFieldWidget(
this.usernameWidget = new GuiTextField(
this.fontRendererObj,
this.width / 2 - 100,
this.height / 2 - 60,
200,
20,
passwordWidget);
20);
this.usernameWidget.setFocused(true);
if (LoginUtil.lastMojangUsername != null) {
this.usernameWidget.setText(LoginUtil.lastMojangUsername);
Expand Down Expand Up @@ -172,10 +171,6 @@ private void removeLoginInfo() {
OAuthConfig.removeUsernamePassword();
}

private void onEdited(int id, String value) {
this.cleanUp();
}

private void updateLoginButton() {
if (this.passwordWidget.getText().isEmpty()) {
this.mojangLoginButton.displayString = I18n.format("btn.login.offline");
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/sintinium/oauth/gui/LoginTypeScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ public void initGui() {
I18n.format("oauth.btn.login.microsoft"),
() -> {
final MicrosoftLogin login = new MicrosoftLogin();
LoginLoadingScreen loadingScreen = new LoginLoadingScreen(
lastScreen,
this,
login::cancelLogin,
true);
LoginLoadingScreen loadingScreen = new LoginLoadingScreen(this, login::cancelLogin, true);
login.setUpdateStatusConsumer(loadingScreen::updateText);
Thread thread = new Thread(() -> login.login(() -> {
LoginUtil.updateOnlineStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class ResponsiveButton extends ActionButton {

private Runnable onHover;
private Runnable onUnhover;
private boolean wasHovered = false;

public ResponsiveButton(int buttonId, int x, int y, int width, int height, String text, Runnable onClick,
Runnable onHover, Runnable onUnhover) {
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/com/sintinium/oauth/gui/UsernameFieldWidget.java

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/java/com/sintinium/oauth/login/MicrosoftLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,9 @@ private JsonObject parseObject(String str) {
private static class MsToken {

public String accessToken;
public String refreshToken;

public MsToken(String accessToken, String refreshToken) {
this.accessToken = accessToken;
this.refreshToken = refreshToken;
}
}

Expand Down

0 comments on commit 205d4fb

Please sign in to comment.