Skip to content

Commit 6c62da0

Browse files
authored
Merge pull request #31 from AxolotlClient/1.19/separate-config
1.19/separate config (Release 2.2.0)
2 parents fe408d2 + 4072b59 commit 6c62da0

File tree

111 files changed

+1095
-3345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1095
-3345
lines changed

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ dependencies {
3333
modImplementation "org.quiltmc:quilt-loader:${project.loader_version}"
3434
modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${quilted_fabric_api_version}"
3535

36+
include(modImplementation "com.github.AxolotlClient:AxolotlClient-config:016b0d8")
37+
3638
modImplementation "com.terraformersmc:modmenu:4.0.5"
3739

3840
include( implementation('com.github.JnCrMx:discord-game-sdk4j:0.5.5'))

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ loader_version = 0.17.4
1111
quilted_fabric_api_version = 4.0.0-beta.9+0.60.0-1.19.2
1212

1313
# Mod Properties
14-
version = 2.1.8+1.19.2
14+
version = 2.2.0+1.19.2
1515
maven_group = io.github.axolotlclient
1616
archives_base_name = AxolotlClient

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

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package io.github.axolotlclient;
22

33
import com.mojang.blaze3d.systems.RenderSystem;
4+
import io.github.axolotlclient.AxolotlclientConfig.options.BooleanOption;
5+
import io.github.axolotlclient.AxolotlclientConfig.options.OptionCategory;
46
import io.github.axolotlclient.config.AxolotlClientConfig;
5-
import io.github.axolotlclient.config.Color;
67
import io.github.axolotlclient.config.ConfigManager;
7-
import io.github.axolotlclient.config.options.BooleanOption;
8-
import io.github.axolotlclient.config.options.OptionCategory;
98
import io.github.axolotlclient.modules.AbstractModule;
9+
import io.github.axolotlclient.modules.ModuleLoader;
1010
import io.github.axolotlclient.modules.freelook.Freelook;
1111
import io.github.axolotlclient.modules.hud.HudManager;
1212
import io.github.axolotlclient.modules.hypixel.HypixelMods;
@@ -16,9 +16,11 @@
1616
import io.github.axolotlclient.modules.rpc.DiscordRPC;
1717
import io.github.axolotlclient.modules.screenshotUtils.ScreenshotUtils;
1818
import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips;
19+
import io.github.axolotlclient.modules.sky.SkyResourceManager;
1920
import io.github.axolotlclient.modules.tnttime.TntTime;
2021
import io.github.axolotlclient.modules.zoom.Zoom;
2122
import io.github.axolotlclient.util.FeatureDisabler;
23+
import io.github.axolotlclient.util.Logger;
2224
import io.github.axolotlclient.util.UnsupportedMod;
2325
import io.github.axolotlclient.util.Util;
2426
import net.minecraft.client.MinecraftClient;
@@ -27,7 +29,6 @@
2729
import net.minecraft.entity.Entity;
2830
import net.minecraft.entity.player.PlayerEntity;
2931
import net.minecraft.resource.Resource;
30-
import net.minecraft.resource.pack.ResourcePack;
3132
import net.minecraft.scoreboard.Team;
3233
import net.minecraft.text.Text;
3334
import net.minecraft.util.Formatting;
@@ -38,8 +39,6 @@
3839
import org.quiltmc.qsl.lifecycle.api.client.event.ClientTickEvents;
3940
import org.quiltmc.qsl.resource.loader.api.ResourceLoader;
4041
import org.quiltmc.qsl.resource.loader.api.ResourcePackActivationType;
41-
import org.slf4j.Logger;
42-
import org.slf4j.LoggerFactory;
4342

4443
import java.util.ArrayList;
4544
import java.util.HashMap;
@@ -48,14 +47,12 @@
4847

4948

5049
public class AxolotlClient implements ClientModInitializer {
51-
52-
public static Logger LOGGER = LoggerFactory.getLogger("AxolotlClient");
50+
public static String modid = "AxolotlClient";
5351

5452
public static AxolotlClientConfig CONFIG;
55-
public static String onlinePlayers = "";
56-
public static String otherPlayers = "";
57-
58-
public static List<ResourcePack> packs = new ArrayList<>();
53+
public static io.github.axolotlclient.AxolotlclientConfig.ConfigManager configManager;
54+
public static HashMap<UUID, Boolean> playerCache = new HashMap<>();
55+
5956
public static HashMap<Identifier, Resource> runtimeResources = new HashMap<>();
6057

6158
public static final Identifier badgeIcon = new Identifier("axolotlclient", "textures/badge.png");
@@ -95,13 +92,14 @@ public void onInitializeClient(ModContainer container) {
9592
config.add(someNiceBackground);
9693

9794
getModules();
95+
addExternalModules();
9896
CONFIG.init();
9997
modules.forEach(AbstractModule::init);
10098

10199
CONFIG.config.addAll(CONFIG.getCategories());
102100
CONFIG.config.add(config);
103101

104-
ConfigManager.load();
102+
io.github.axolotlclient.AxolotlclientConfig.AxolotlClientConfigManager.registerConfig(modid, CONFIG, configManager = new ConfigManager());
105103

106104
modules.forEach(AbstractModule::lateInit);
107105

@@ -110,10 +108,13 @@ public void onInitializeClient(ModContainer container) {
110108

111109
FeatureDisabler.init();
112110

113-
LOGGER.info("AxolotlClient Initialized");
111+
Logger.debug("Debug Output activated, Logs will be more verbose!");
112+
113+
Logger.info("AxolotlClient Initialized");
114114
}
115115

116116
public static void getModules(){
117+
modules.add(SkyResourceManager.getInstance());
117118
modules.add(Zoom.getInstance());
118119
modules.add(HudManager.getInstance());
119120
modules.add(HypixelMods.getInstance());
@@ -126,6 +127,10 @@ public static void getModules(){
126127
modules.add(ScreenshotUtils.getInstance());
127128
}
128129

130+
private static void addExternalModules(){
131+
modules.addAll(ModuleLoader.loadExternalModules());
132+
}
133+
129134
public static boolean isUsingClient(UUID uuid){
130135
assert MinecraftClient.getInstance().player != null;
131136
if (uuid == MinecraftClient.getInstance().player.getUuid()){
@@ -135,16 +140,16 @@ public static boolean isUsingClient(UUID uuid){
135140
}
136141
}
137142

138-
139143
public static void tickClient(){
140144

141145
modules.forEach(AbstractModule::tick);
142-
Color.tickChroma();
143146

144147
if (tickTime >=6000){
145148

146149
//System.out.println("Cleared Cache of Other Players!");
147-
otherPlayers = "";
150+
if(playerCache.values().size()>500){
151+
playerCache.clear();
152+
}
148153
tickTime = 0;
149154
}
150155
tickTime++;

src/main/java/io/github/axolotlclient/NetworkHelper.java

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.axolotlclient;
22

3+
import io.github.axolotlclient.util.Logger;
34
import io.github.axolotlclient.util.ThreadExecuter;
45
import net.minecraft.client.MinecraftClient;
56
import org.apache.http.HttpResponse;
@@ -12,43 +13,48 @@
1213
import org.apache.http.util.EntityUtils;
1314

1415
import java.util.UUID;
16+
import java.util.concurrent.TimeUnit;
17+
import java.util.concurrent.atomic.AtomicInteger;
1518

1619

1720
public class NetworkHelper {
1821

1922
private static boolean loggedIn;
2023
private static UUID uuid;
2124

25+
private static final AtomicInteger concurrentCalls = new AtomicInteger(0);
26+
private static final int maxCalls = 3;
27+
2228
public static boolean getOnline(UUID uuid){
2329

24-
if (AxolotlClient.onlinePlayers.contains(uuid.toString())){
25-
return true;
26-
} else if (AxolotlClient.otherPlayers.contains(uuid.toString())){
27-
return false;
28-
}else {
29-
ThreadExecuter.scheduleTask(() -> getUser(uuid));
30-
return AxolotlClient.onlinePlayers.contains(uuid.toString());
30+
if (!AxolotlClient.playerCache.containsKey(uuid)) {
31+
if(concurrentCalls.get() <= maxCalls) {
32+
concurrentCalls.incrementAndGet();
33+
Runnable runnable = () -> getUser(uuid);
34+
ThreadExecuter.scheduleTask(runnable);
35+
ThreadExecuter.removeTask(runnable);
36+
ThreadExecuter.scheduleTask(concurrentCalls::decrementAndGet, 1, TimeUnit.MINUTES);
37+
}
3138
}
39+
return AxolotlClient.playerCache.get(uuid) != null ? AxolotlClient.playerCache.get(uuid): false;
3240
}
3341

3442
public static void getUser(UUID uuid){
3543
try{
36-
CloseableHttpClient client = HttpClients.custom().disableAutomaticRetries().build();
44+
CloseableHttpClient client = HttpClients.createMinimal();
3745
HttpGet get = new HttpGet("https://moehreag.duckdns.org/axolotlclient-api/?uuid="+uuid.toString());
3846
HttpResponse response= client.execute(get);
3947
String body = EntityUtils.toString(response.getEntity());
4048
client.close();
4149
if (body.contains("true")){
42-
AxolotlClient.onlinePlayers = AxolotlClient.onlinePlayers + " " + uuid;
50+
AxolotlClient.playerCache.put(uuid, true);
4351
} else {
44-
AxolotlClient.otherPlayers = AxolotlClient.otherPlayers + " " + uuid;
52+
AxolotlClient.playerCache.put(uuid, false);
4553
}
4654

4755
} catch (Exception ignored){
48-
AxolotlClient.otherPlayers = AxolotlClient.otherPlayers + " " + uuid;
56+
AxolotlClient.playerCache.put(uuid, false);
4957
}
50-
51-
5258
}
5359

5460
public static void setOnline() {
@@ -64,37 +70,37 @@ public static void setOnline() {
6470
HttpResponse response = client.execute(post);
6571
String body = EntityUtils.toString(response.getEntity());
6672
if(body.contains("Success!")){
67-
AxolotlClient.LOGGER.info("Sucessfully logged in at AxolotlClient!");
73+
Logger.info("Sucessfully logged in at AxolotlClient!");
6874
loggedIn=true;
6975
}
7076
client.close();
7177
} catch (Exception e) {
7278
e.printStackTrace();
73-
AxolotlClient.LOGGER.error("Error while logging in!");
79+
Logger.error("Error while logging in!");
7480
}
7581
}
7682

7783
public static void setOffline(){
7884

7985
if(loggedIn) {
8086
try {
81-
AxolotlClient.LOGGER.info("Logging off..");
87+
Logger.info("Logging off..");
8288
CloseableHttpClient client = HttpClients.createDefault();
8389
HttpDelete delete = new HttpDelete("https://moehreag.duckdns.org/axolotlclient-api/?uuid=" + uuid.toString());
8490
delete.setHeader("Accept", "application/json");
8591
delete.setHeader("Content-type", "application/json");
8692
HttpResponse response = client.execute(delete);
8793
String body = EntityUtils.toString(response.getEntity());
8894
if (body.contains("Success!")) {
89-
AxolotlClient.LOGGER.info("Successfully logged off!");
95+
Logger.info("Successfully logged off!");
9096
} else {
9197
throw new Exception("Error while logging off: " + body);
9298
}
9399
client.close();
94100

95101
} catch (Exception ex) {
96102
ex.printStackTrace();
97-
AxolotlClient.LOGGER.error("Error while logging off!");
103+
Logger.error("Error while logging off!");
98104
}
99105
}
100106
}
@@ -109,7 +115,7 @@ public static void setOffline(){
109115
110116
int status = response.getStatusLine().getStatusCode();
111117
if (status != 200) {
112-
AxolotlClient.LOGGER.warn("API request failed, status code " + status);
118+
Logger.warn("API request failed, status code " + status);
113119
return null;
114120
}
115121

src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package io.github.axolotlclient.config;
22

33
import io.github.axolotlclient.AxolotlClient;
4-
import io.github.axolotlclient.config.options.*;
4+
import io.github.axolotlclient.AxolotlclientConfig.AxolotlClientConfigConfig;
5+
import io.github.axolotlclient.AxolotlclientConfig.Color;
6+
import io.github.axolotlclient.AxolotlclientConfig.ConfigHolder;
7+
import io.github.axolotlclient.AxolotlclientConfig.options.*;
8+
import io.github.axolotlclient.config.screen.CreditsScreen;
9+
import net.minecraft.client.MinecraftClient;
510

611
import java.util.ArrayList;
712
import java.util.List;
813

9-
public class AxolotlClientConfig {
14+
public class AxolotlClientConfig extends ConfigHolder {
1015

1116
public final BooleanOption showOwnNametag = new BooleanOption("showOwnNametag", false);
1217
public final BooleanOption useShadows = new BooleanOption("useShadows", false);
@@ -22,13 +27,9 @@ public class AxolotlClientConfig {
2227
public final BooleanOption showSunMoon = new BooleanOption("showSunMoon", true);
2328
public final BooleanOption dynamicFOV = new BooleanOption("dynamicFov", true);
2429
public final BooleanOption fullBright = new BooleanOption("fullBright", false);
25-
public final IntegerOption chromaSpeed = new IntegerOption("chromaSpeed", 20, 10, 50);
2630
public final BooleanOption lowFire = new BooleanOption("lowFire", false);
2731
public final BooleanOption lowShield = new BooleanOption("lowShield", false);
2832

29-
public final BooleanOption showOptionTooltips = new BooleanOption("showOptionTooltips", true);
30-
public final BooleanOption showCategoryTooltips = new BooleanOption("showCategoryTooltips", false);
31-
public final BooleanOption quickToggles = new BooleanOption("quickToggles", false);
3233
public final ColorOption loadingScreenColor = new ColorOption("loadingBgColor", new Color(239, 50, 61, 255));
3334
public final BooleanOption nightMode = new BooleanOption("nightMode", false);
3435

@@ -38,13 +39,12 @@ public class AxolotlClientConfig {
3839
// If you find a reasonable (without rewriting a lot) way to implement this let me know!
3940
//public final DoubleOption outlineWidth = new DoubleOption("outlineWidth", 1, 1, 10);
4041

42+
public final GenericOption openCredits = new GenericOption("Credits", "Open Credits", (mouseX, mouseY)->
43+
MinecraftClient.getInstance().setScreen(new CreditsScreen(MinecraftClient.getInstance().currentScreen))
44+
);
45+
public final BooleanOption debugLogOutput = new BooleanOption("debugLogOutput", false);
4146
public final BooleanOption creditsBGM = new BooleanOption("creditsBGM", true);
4247

43-
public final BooleanOption searchForOptions = new BooleanOption("searchForOptions", false);
44-
public final BooleanOption searchIgnoreCase = new BooleanOption("searchIgnoreCase", true);
45-
public final BooleanOption searchSort = new BooleanOption("searchSort", true);
46-
public final EnumOption searchSortOrder = new EnumOption("searchSortOrder", new String[]{"ASCENDING", "DESCENDING"}, "ASCENDING");
47-
4848
public final OptionCategory general = new OptionCategory("general");
4949
public final OptionCategory nametagOptions = new OptionCategory( "nametagOptions");
5050
public final OptionCategory rendering = new OptionCategory("rendering");
@@ -94,16 +94,21 @@ public void init(){
9494

9595
general.add(loadingScreenColor);
9696
general.add(nightMode);
97-
general.add(quickToggles);
98-
general.add(showOptionTooltips);
99-
general.add(showCategoryTooltips);
100-
101-
searchFilters.add(searchIgnoreCase, searchForOptions, searchSort, searchSortOrder);
97+
general.add(AxolotlClientConfigConfig.showQuickToggles);
98+
general.add(AxolotlClientConfigConfig.showOptionTooltips);
99+
general.add(AxolotlClientConfigConfig.showCategoryTooltips);
100+
general.add(openCredits);
101+
general.add(debugLogOutput);
102+
103+
searchFilters.add(AxolotlClientConfigConfig.searchIgnoreCase,
104+
AxolotlClientConfigConfig.searchForOptions,
105+
AxolotlClientConfigConfig.searchSort,
106+
AxolotlClientConfigConfig.searchSortOrder);
102107
general.addSubCategory(searchFilters);
103108

104109
rendering.add(customSky);
105110
rendering.add(showSunMoon);
106-
rendering.add(chromaSpeed);
111+
rendering.add(AxolotlClientConfigConfig.chromaSpeed);
107112
rendering.add(dynamicFOV);
108113
rendering.add(fullBright);
109114
rendering.add(lowFire);

0 commit comments

Comments
 (0)