Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 286f4b6

Browse files
committed
add button for data exports
1 parent f0b2e85 commit 286f4b6

File tree

17 files changed

+203
-29
lines changed

17 files changed

+203
-29
lines changed

1.16_combat-6/src/main/java/io/github/axolotlclient/AxolotlClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import io.github.axolotlclient.util.LoggerImpl;
5757
import io.github.axolotlclient.util.notifications.Notifications;
5858
import net.fabricmc.api.ClientModInitializer;
59+
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
5960
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
6061
import net.fabricmc.loader.api.FabricLoader;
6162
import net.minecraft.client.resource.language.I18n;
@@ -120,6 +121,7 @@ public void onInitializeClient() {
120121

121122
new AxolotlClientCommon(LOGGER, () -> configManager);
122123
new API(LOGGER, Notifications.getInstance(), I18n::translate, new StatusUpdateProviderImpl(), APIOptions.getInstance());
124+
ClientLifecycleEvents.CLIENT_STOPPING.register(c -> API.getInstance().shutdown());
123125

124126
modules.forEach(Module::init);
125127

1.16_combat-6/src/main/java/io/github/axolotlclient/api/APIOptions.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,30 @@
2222

2323
package io.github.axolotlclient.api;
2424

25+
import java.nio.file.Path;
2526
import java.util.function.Consumer;
27+
import java.util.function.Function;
2628

2729
import io.github.axolotlclient.AxolotlClient;
2830
import io.github.axolotlclient.AxolotlClientConfig.api.ui.screen.ConfigScreen;
2931
import io.github.axolotlclient.api.chat.ChannelInvitesScreen;
3032
import io.github.axolotlclient.api.chat.ChatListScreen;
33+
import io.github.axolotlclient.api.requests.AccountDataRequest;
3134
import io.github.axolotlclient.api.requests.AccountSettingsRequest;
35+
import io.github.axolotlclient.util.ThreadExecuter;
3236
import io.github.axolotlclient.util.options.GenericOption;
3337
import lombok.Getter;
3438
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
3539
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
40+
import net.fabricmc.loader.api.FabricLoader;
3641
import net.minecraft.client.MinecraftClient;
3742
import net.minecraft.client.gui.screen.ConfirmScreen;
3843
import net.minecraft.client.gui.screen.Screen;
3944
import net.minecraft.client.options.KeyBinding;
4045
import net.minecraft.text.TranslatableText;
4146
import org.lwjgl.glfw.GLFW;
47+
import org.lwjgl.system.MemoryStack;
48+
import org.lwjgl.util.tinyfd.TinyFileDialogs;
4249

4350
public class APIOptions extends Options {
4451

@@ -67,6 +74,18 @@ public void init() {
6774
() -> client.openScreen(new ChannelInvitesScreen(client.currentScreen))));
6875
account.add(new GenericOption("api.account.usernames", "clickToOpen",
6976
() -> client.openScreen(new UsernameManagementScreen(client.currentScreen))));
77+
account.add(new GenericOption("api.account.export", "api.account.export_data", () -> ThreadExecuter.scheduleTask(() -> {
78+
Function<String, String> translate = API.getInstance().getTranslationProvider()::translate;
79+
try (MemoryStack stack = MemoryStack.stackPush()) {
80+
var pointers = stack.mallocPointer(1);
81+
pointers.put(stack.UTF8("*.json"));
82+
pointers.flip();
83+
var result = TinyFileDialogs.tinyfd_saveFileDialog(translate.apply("api.account.export.dialog_title"), FabricLoader.getInstance().getGameDir().toString(), pointers, null);
84+
if (result != null) {
85+
AccountDataRequest.get(Path.of(result));
86+
}
87+
}
88+
})));
7089
account.add(new GenericOption("api.account.delete", "api.account.delete_account", () -> {
7190
Screen previous = client.currentScreen;
7291
client.openScreen(new ConfirmScreen(b -> {

1.20/src/main/java/io/github/axolotlclient/AxolotlClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import io.github.axolotlclient.util.LoggerImpl;
5858
import io.github.axolotlclient.util.notifications.Notifications;
5959
import net.fabricmc.api.ClientModInitializer;
60+
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
6061
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
6162
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
6263
import net.fabricmc.loader.api.FabricLoader;
@@ -121,6 +122,7 @@ public void onInitializeClient() {
121122

122123
new AxolotlClientCommon(LOGGER, () -> configManager);
123124
new API(LOGGER, Notifications.getInstance(), I18n::translate, new StatusUpdateProviderImpl(), APIOptions.getInstance());
125+
ClientLifecycleEvents.CLIENT_STOPPING.register(c -> API.getInstance().shutdown());
124126

125127
modules.forEach(Module::init);
126128

1.20/src/main/java/io/github/axolotlclient/api/APIOptions.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,29 @@
2222

2323
package io.github.axolotlclient.api;
2424

25+
import java.nio.file.Path;
2526
import java.util.function.Consumer;
27+
import java.util.function.Function;
2628

2729
import com.mojang.blaze3d.platform.InputUtil;
2830
import io.github.axolotlclient.AxolotlClient;
2931
import io.github.axolotlclient.AxolotlClientConfig.api.ui.screen.ConfigScreen;
3032
import io.github.axolotlclient.api.chat.ChannelInvitesScreen;
3133
import io.github.axolotlclient.api.chat.ChatListScreen;
34+
import io.github.axolotlclient.api.requests.AccountDataRequest;
3235
import io.github.axolotlclient.api.requests.AccountSettingsRequest;
36+
import io.github.axolotlclient.util.ThreadExecuter;
3337
import io.github.axolotlclient.util.keybinds.KeyBinds;
3438
import io.github.axolotlclient.util.options.GenericOption;
3539
import lombok.Getter;
40+
import net.fabricmc.loader.api.FabricLoader;
3641
import net.minecraft.client.MinecraftClient;
3742
import net.minecraft.client.gui.screen.ConfirmScreen;
3843
import net.minecraft.client.gui.screen.Screen;
3944
import net.minecraft.client.option.KeyBind;
4045
import net.minecraft.text.Text;
46+
import org.lwjgl.system.MemoryStack;
47+
import org.lwjgl.util.tinyfd.TinyFileDialogs;
4148

4249
public class APIOptions extends Options {
4350

@@ -66,6 +73,18 @@ public void init() {
6673
() -> client.setScreen(new ChannelInvitesScreen(client.currentScreen))));
6774
account.add(new GenericOption("api.account.usernames", "clickToOpen",
6875
() -> client.setScreen(new UsernameManagementScreen(client.currentScreen))));
76+
account.add(new GenericOption("api.account.export", "api.account.export_data", () -> ThreadExecuter.scheduleTask(() -> {
77+
Function<String, String> translate = API.getInstance().getTranslationProvider()::translate;
78+
try (MemoryStack stack = MemoryStack.stackPush()) {
79+
var pointers = stack.mallocPointer(1);
80+
pointers.put(stack.UTF8("*.json"));
81+
pointers.flip();
82+
var result = TinyFileDialogs.tinyfd_saveFileDialog(translate.apply("api.account.export.dialog_title"), FabricLoader.getInstance().getGameDir().toString(), pointers, null);
83+
if (result != null) {
84+
AccountDataRequest.get(Path.of(result));
85+
}
86+
}
87+
})));
6988
account.add(new GenericOption("api.account.delete", "api.account.delete_account", () -> {
7089
Screen previous = client.currentScreen;
7190
client.setScreen(new ConfirmScreen(b -> {

1.21.4/src/main/java/io/github/axolotlclient/AxolotlClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import io.github.axolotlclient.util.LoggerImpl;
5656
import io.github.axolotlclient.util.notifications.Notifications;
5757
import net.fabricmc.api.ClientModInitializer;
58+
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
5859
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
5960
import net.fabricmc.loader.api.FabricLoader;
6061
import net.minecraft.client.resources.language.I18n;
@@ -119,6 +120,7 @@ public void onInitializeClient() {
119120
new API(LOGGER, Notifications.getInstance(), I18n::get, new StatusUpdateProviderImpl(),
120121
APIOptions.getInstance()
121122
);
123+
ClientLifecycleEvents.CLIENT_STOPPING.register(c -> API.getInstance().shutdown());
122124

123125
modules.forEach(Module::init);
124126

1.21.4/src/main/java/io/github/axolotlclient/api/APIOptions.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,34 @@
2222

2323
package io.github.axolotlclient.api;
2424

25+
import java.nio.file.Path;
2526
import java.util.function.Consumer;
27+
import java.util.function.Function;
2628

2729
import com.mojang.blaze3d.platform.InputConstants;
2830
import io.github.axolotlclient.AxolotlClient;
2931
import io.github.axolotlclient.AxolotlClientConfig.api.ui.screen.ConfigScreen;
3032
import io.github.axolotlclient.api.chat.ChannelInvitesScreen;
3133
import io.github.axolotlclient.api.chat.ChatListScreen;
34+
import io.github.axolotlclient.api.requests.AccountDataRequest;
3235
import io.github.axolotlclient.api.requests.AccountSettingsRequest;
36+
import io.github.axolotlclient.util.ThreadExecuter;
3337
import io.github.axolotlclient.util.keybinds.KeyBinds;
3438
import io.github.axolotlclient.util.options.GenericOption;
3539
import lombok.Getter;
40+
import net.fabricmc.loader.api.FabricLoader;
3641
import net.minecraft.client.KeyMapping;
3742
import net.minecraft.client.Minecraft;
3843
import net.minecraft.client.gui.screens.ConfirmScreen;
3944
import net.minecraft.client.gui.screens.Screen;
4045
import net.minecraft.network.chat.Component;
46+
import org.lwjgl.system.MemoryStack;
47+
import org.lwjgl.util.tinyfd.TinyFileDialogs;
4148

4249
public class APIOptions extends Options {
4350

44-
@Getter private static final Options Instance = new APIOptions();
51+
@Getter
52+
private static final Options Instance = new APIOptions();
4553

4654
@Override
4755
public void init() {
@@ -61,8 +69,20 @@ public void init() {
6169
new GenericOption("viewChats", "clickToOpen", () -> client.setScreen(new ChatListScreen(client.screen))));
6270
category.add(new GenericOption("api.channels.invites.view", "clickToOpen", () -> client.setScreen(new ChannelInvitesScreen(client.screen))));
6371
account.add(new GenericOption("api.account.usernames", "clickToOpen",
64-
() -> client.setScreen(new UsernameManagementScreen(client.screen))
72+
() -> client.setScreen(new UsernameManagementScreen(client.screen))
6573
));
74+
account.add(new GenericOption("api.account.export", "api.account.export_data", () -> ThreadExecuter.scheduleTask(() -> {
75+
Function<String, String> translate = API.getInstance().getTranslationProvider()::translate;
76+
try (MemoryStack stack = MemoryStack.stackPush()) {
77+
var pointers = stack.mallocPointer(1);
78+
pointers.put(stack.UTF8("*.json"));
79+
pointers.flip();
80+
var result = TinyFileDialogs.tinyfd_saveFileDialog(translate.apply("api.account.export.dialog_title"), FabricLoader.getInstance().getGameDir().toString(), pointers, null);
81+
if (result != null) {
82+
AccountDataRequest.get(Path.of(result));
83+
}
84+
}
85+
})));
6686
account.add(new GenericOption("api.account.delete", "api.account.delete_account", () -> {
6787
Screen previous = client.screen;
6888
client.setScreen(new ConfirmScreen(b -> {
@@ -80,7 +100,7 @@ public void init() {
80100
}
81101
client.setScreen(previous);
82102
}, Component.translatable("api.account.confirm_deletion"),
83-
Component.translatable("api.account.confirm_deletion.desc")
103+
Component.translatable("api.account.confirm_deletion.desc")
84104
));
85105
}));
86106
Consumer<Boolean> consumer = settingUpdated;

1.21/src/main/java/io/github/axolotlclient/AxolotlClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import io.github.axolotlclient.util.LoggerImpl;
5757
import io.github.axolotlclient.util.notifications.Notifications;
5858
import net.fabricmc.api.ClientModInitializer;
59+
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
5960
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
6061
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
6162
import net.fabricmc.loader.api.FabricLoader;
@@ -119,6 +120,7 @@ public void onInitializeClient() {
119120

120121
new AxolotlClientCommon(LOGGER, () -> configManager);
121122
new API(LOGGER, Notifications.getInstance(), I18n::translate, new StatusUpdateProviderImpl(), APIOptions.getInstance());
123+
ClientLifecycleEvents.CLIENT_STOPPING.register(c -> API.getInstance().shutdown());
122124

123125
modules.forEach(Module::init);
124126

1.21/src/main/java/io/github/axolotlclient/api/APIOptions.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,29 @@
2222

2323
package io.github.axolotlclient.api;
2424

25+
import java.nio.file.Path;
2526
import java.util.function.Consumer;
27+
import java.util.function.Function;
2628

2729
import com.mojang.blaze3d.platform.InputUtil;
2830
import io.github.axolotlclient.AxolotlClient;
2931
import io.github.axolotlclient.AxolotlClientConfig.api.ui.screen.ConfigScreen;
3032
import io.github.axolotlclient.api.chat.ChannelInvitesScreen;
3133
import io.github.axolotlclient.api.chat.ChatListScreen;
34+
import io.github.axolotlclient.api.requests.AccountDataRequest;
3235
import io.github.axolotlclient.api.requests.AccountSettingsRequest;
36+
import io.github.axolotlclient.util.ThreadExecuter;
3337
import io.github.axolotlclient.util.keybinds.KeyBinds;
3438
import io.github.axolotlclient.util.options.GenericOption;
3539
import lombok.Getter;
40+
import net.fabricmc.loader.api.FabricLoader;
3641
import net.minecraft.client.MinecraftClient;
3742
import net.minecraft.client.gui.screen.ConfirmScreen;
3843
import net.minecraft.client.gui.screen.Screen;
3944
import net.minecraft.client.option.KeyBind;
4045
import net.minecraft.text.Text;
46+
import org.lwjgl.system.MemoryStack;
47+
import org.lwjgl.util.tinyfd.TinyFileDialogs;
4148

4249
public class APIOptions extends Options {
4350

@@ -66,6 +73,18 @@ public void init() {
6673
() -> client.setScreen(new ChannelInvitesScreen(client.currentScreen))));
6774
account.add(new GenericOption("api.account.usernames", "clickToOpen",
6875
() -> client.setScreen(new UsernameManagementScreen(client.currentScreen))));
76+
account.add(new GenericOption("api.account.export", "api.account.export_data", () -> ThreadExecuter.scheduleTask(() -> {
77+
Function<String, String> translate = API.getInstance().getTranslationProvider()::translate;
78+
try (MemoryStack stack = MemoryStack.stackPush()) {
79+
var pointers = stack.mallocPointer(1);
80+
pointers.put(stack.UTF8("*.json"));
81+
pointers.flip();
82+
var result = TinyFileDialogs.tinyfd_saveFileDialog(translate.apply("api.account.export.dialog_title"), FabricLoader.getInstance().getGameDir().toString(), pointers, null);
83+
if (result != null) {
84+
AccountDataRequest.get(Path.of(result));
85+
}
86+
}
87+
})));
6988
account.add(new GenericOption("api.account.delete", "api.account.delete_account", () -> {
7089
Screen previous = client.currentScreen;
7190
client.setScreen(new ConfirmScreen(b -> {

1.8.9/build.gradle.kts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,29 @@ dependencies {
5959
localRuntime("org.slf4j:slf4j-jdk14:1.7.36")
6060

6161
modCompileOnly("io.github.moehreag:legacy-lwjgl3:${project.property("legacy_lwgjl3")}") {
62-
exclude(group = "org.lwjgl", module= "lwjgl-glfw")
63-
exclude(group = "org.lwjgl", module= "lwjgl-openal")
64-
exclude(group = "org.lwjgl", module= "lwjgl-opengl")
65-
exclude(group = "org.lwjgl", module= "lwjgl")
62+
exclude(group = "org.lwjgl", module = "lwjgl-glfw")
63+
exclude(group = "org.lwjgl", module = "lwjgl-openal")
64+
exclude(group = "org.lwjgl", module = "lwjgl-opengl")
65+
exclude(group = "org.lwjgl", module = "lwjgl")
6666
exclude(group = "net.fabricmc")
6767
exclude(group = "org.javassist")
6868
}
6969
modLocalRuntime("io.github.moehreag:legacy-lwjgl3:${project.property("legacy_lwgjl3")}:all-remapped") {
70-
exclude(group= "org.lwjgl", module= "lwjgl-glfw")
71-
exclude(group= "org.lwjgl", module= "lwjgl-openal")
72-
exclude(group= "org.lwjgl", module= "lwjgl-opengl")
73-
exclude(group= "org.lwjgl", module= "lwjgl")
74-
exclude(group= "net.fabricmc")
75-
exclude(group= "org.javassist")
70+
exclude(group = "org.lwjgl", module = "lwjgl-glfw")
71+
exclude(group = "org.lwjgl", module = "lwjgl-openal")
72+
exclude(group = "org.lwjgl", module = "lwjgl-opengl")
73+
exclude(group = "org.lwjgl", module = "lwjgl")
74+
exclude(group = "net.fabricmc")
75+
exclude(group = "org.javassist")
7676
}
77+
78+
implementation("org.lwjgl", "lwjgl-tinyfd", "3.3.5")
79+
include(runtimeOnly("org.lwjgl", "lwjgl-tinyfd", "3.3.5", classifier = "natives-linux"))
80+
include(runtimeOnly("org.lwjgl", "lwjgl-tinyfd", "3.3.5", classifier = "natives-windows"))
81+
include(runtimeOnly("org.lwjgl", "lwjgl-tinyfd", "3.3.5", classifier = "natives-macos"))
82+
include(runtimeOnly("org.lwjgl", "lwjgl-tinyfd", "3.3.5", classifier = "natives-linux-arm64"))
83+
include(runtimeOnly("org.lwjgl", "lwjgl-tinyfd", "3.3.5", classifier = "natives-windows-arm64"))
84+
include(runtimeOnly("org.lwjgl", "lwjgl-tinyfd", "3.3.5", classifier = "natives-macos-arm64"))
7785
}
7886

7987
configurations.configureEach {
@@ -123,7 +131,9 @@ publishing {
123131
repositories {
124132
maven {
125133
name = "owlMaven"
126-
val repository = if (project.version.toString().contains("beta") || project.version.toString().contains("alpha")) "snapshots" else "releases"
134+
val repository = if (project.version.toString().contains("beta") || project.version.toString()
135+
.contains("alpha")
136+
) "snapshots" else "releases"
127137
url = uri("https://moehreag.duckdns.org/maven/$repository")
128138
credentials(PasswordCredentials::class)
129139
authentication {
@@ -150,7 +160,8 @@ modrinth {
150160
// https://github.com/LambdAurora/LambDynamicLights/blob/1ef85f486084873b5d97b8a08df72f57859a3295/build.gradle#L145
151161
// License: MIT
152162
val changelogText = file("../CHANGELOG.md").readText()
153-
val regexVersion = ((project.version) as String).split("\\+")[0].replace("\\.".toRegex(), "/\\./").replace("\\+".toRegex(), "\\+")
163+
val regexVersion =
164+
((project.version) as String).split("\\+")[0].replace("\\.".toRegex(), "/\\./").replace("\\+".toRegex(), "\\+")
154165
val changelogRegex = "###? ${regexVersion}\\n\\n(( *- .+\\n)+)".toRegex()
155166
val matcher = changelogRegex.find(changelogText)
156167

@@ -159,7 +170,7 @@ modrinth {
159170

160171
val changelogLines = changelogText.split("\n")
161172
val linkRefRegex = "^\\[([A-z0-9 _\\-/+.]+)]: ".toRegex()
162-
for (i in (changelogLines.size -1)..0 step -1) {
173+
for (i in (changelogLines.size - 1)..0 step -1) {
163174
val line = changelogLines[i]
164175
if ((linkRefRegex.matches(line)))
165176
changelogContent += "\n" + line
@@ -168,7 +179,7 @@ modrinth {
168179
changelog = changelogContent
169180
} else {
170181
afterEvaluate {
171-
tasks.modrinth.configure {isEnabled = false }
182+
tasks.modrinth.configure { isEnabled = false }
172183
}
173184
}
174185
}

1.8.9/src/main/java/io/github/axolotlclient/AxolotlClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public void onInitializeClient() {
119119

120120
new AxolotlClientCommon(LOGGER, () -> configManager);
121121
new API(LOGGER, Notifications.getInstance(), I18n::translate, new StatusUpdateProviderImpl(), APIOptions.getInstance());
122+
MinecraftClientEvents.STOP.register(c -> API.getInstance().shutdown());
122123

123124
modules.forEach(Module::init);
124125

0 commit comments

Comments
 (0)