Skip to content

Commit bd99164

Browse files
authored
Merge pull request #30 from AxolotlClient/1.8/separate-config
1.8/separate config (Release 2.2.0)
2 parents 7d25cf3 + c18043c commit bd99164

File tree

120 files changed

+1037
-3628
lines changed

Some content is hidden

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

120 files changed

+1037
-3628
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) 2020 moehreag + Contributors
1+
Copyright (C) 2021-present moehreag + Contributors
22

33
GNU LESSER GENERAL PUBLIC LICENSE
44
Version 3, 29 June 2007

build.gradle

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ plugins {
44
id 'maven-publish'
55
}
66

7-
sourceCompatibility = JavaVersion.VERSION_1_8
8-
targetCompatibility = JavaVersion.VERSION_1_8
9-
10-
archivesBaseName = project.archives_base_name
117
version = project.mod_version
128
group = project.maven_group
139

@@ -17,10 +13,11 @@ repositories {
1713
url = "https://maven.legacyfabric.net"
1814
}
1915

20-
maven { url 'https://jitpack.io' }
2116
maven {
2217
url 'https://repo.hypixel.net/repository/Hypixel/'
2318
}
19+
20+
maven { url 'https://jitpack.io' }
2421
mavenCentral()
2522
}
2623

@@ -56,19 +53,21 @@ dependencies {
5653
exclude group: "org.apache.httpcomponents", module: "httpclient"
5754
})
5855

59-
//modImplementation files("libs/legacy-modmenu-1.1.1-dev.jar") // Uncomment if you want modmenu in the dev env
56+
// modImplementation files("libs/legacy-modmenu-1.1.1-dev.jar") // Uncomment if you want modmenu in the dev env
6057

61-
implementation('org.apache.logging.log4j:log4j-core:2.18.0')
58+
implementation('org.apache.logging.log4j:log4j-core:2.19.0')
6259

60+
modImplementation include("com.github.moehreag:search-in-resources:1.0.2")
61+
modImplementation include('com.github.AxolotlClient:AxolotlClient-config:9453a14')
6362
}
6463

6564
// More hacks that make mac os work
6665
if (System.getProperty("os.name").toLowerCase().contains("mac")) {
6766
configurations.all {
6867
resolutionStrategy {
6968
dependencySubstitution {
70-
substitute module('org.lwjgl.lwjgl:lwjgl_util:2.9.2-nightly-201408222') with module('org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209')
71-
substitute module('org.lwjgl.lwjgl:lwjgl:2.9.2-nightly-201408222') with module('org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209')
69+
substitute module('org.lwjgl.lwjgl:lwjgl_util:2.9.2-nightly-201408222') using module('org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209')
70+
substitute module('org.lwjgl.lwjgl:lwjgl:2.9.2-nightly-201408222') using module('org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209')
7271
}
7372
force 'org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209'
7473
}
@@ -79,7 +78,7 @@ if (System.getProperty("os.name").toLowerCase().contains("mac")) {
7978
configurations.all {
8079
resolutionStrategy {
8180
dependencySubstitution {
82-
substitute module('io.netty:netty-all:4.0.23.Final') with module('io.netty:netty-all:4.0.25.Final')
81+
substitute module('io.netty:netty-all:4.0.23.Final') using module('io.netty:netty-all:4.0.25.Final')
8382
}
8483
force 'io.netty:netty-all:4.0.25.Final'
8584
}

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
55
minecraft_version = 1.8.9
6-
yarn_mappings = 1.8.9+build.385
6+
yarn_mappings = 1.8.9+build.420
77
loader_version = 0.14.9
88

99
# Mod Properties
10-
mod_version = 2.1.8+1.8.9
10+
mod_version = 2.2.0+1.8.9
1111
maven_group = io.github.axolotlclient
1212
archives_base_name = AxolotlClient
1313

1414
# Dependencies
15-
fabric_version = 1.7.1+1.8.9
15+
fabric_version = 1.8.0+1.8.9

settings.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,5 @@ pluginManagement {
55
url = 'https://maven.fabricmc.net/'
66
}
77
gradlePluginPortal()
8-
maven {
9-
name = 'Jitpack'
10-
url = 'https://jitpack.io'
11-
}
128
}
139
}

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

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

33
import com.mojang.blaze3d.platform.GlStateManager;
4+
import io.github.axolotlclient.AxolotlclientConfig.ConfigManager;
5+
import io.github.axolotlclient.AxolotlclientConfig.options.BooleanOption;
6+
import io.github.axolotlclient.AxolotlclientConfig.options.OptionCategory;
47
import io.github.axolotlclient.config.AxolotlClientConfig;
5-
import io.github.axolotlclient.config.Color;
6-
import io.github.axolotlclient.config.ConfigManager;
7-
import io.github.axolotlclient.config.options.BooleanOption;
8-
import io.github.axolotlclient.config.options.OptionCategory;
8+
import io.github.axolotlclient.config.AxolotlClientConfigManager;
99
import io.github.axolotlclient.modules.AbstractModule;
10+
import io.github.axolotlclient.modules.ModuleLoader;
1011
import io.github.axolotlclient.modules.freelook.Freelook;
1112
import io.github.axolotlclient.modules.hud.HudManager;
1213
import io.github.axolotlclient.modules.hypixel.HypixelMods;
@@ -16,38 +17,35 @@
1617
import io.github.axolotlclient.modules.rpc.DiscordRPC;
1718
import io.github.axolotlclient.modules.screenshotUtils.ScreenshotUtils;
1819
import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips;
20+
import io.github.axolotlclient.modules.sky.SkyResourceManager;
1921
import io.github.axolotlclient.modules.tnttime.TntTime;
2022
import io.github.axolotlclient.modules.zoom.Zoom;
2123
import io.github.axolotlclient.util.FeatureDisabler;
24+
import io.github.axolotlclient.util.Logger;
2225
import net.fabricmc.api.ClientModInitializer;
2326
import net.fabricmc.loader.api.FabricLoader;
27+
import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
2428
import net.minecraft.client.MinecraftClient;
2529
import net.minecraft.client.gui.DrawableHelper;
2630
import net.minecraft.entity.Entity;
2731
import net.minecraft.entity.player.PlayerEntity;
2832
import net.minecraft.resource.Resource;
29-
import net.minecraft.resource.ResourcePack;
3033
import net.minecraft.util.Identifier;
31-
import org.apache.logging.log4j.LogManager;
32-
import org.apache.logging.log4j.Logger;
3334

3435
import java.nio.file.Path;
3536
import java.util.*;
3637

3738

3839
public class AxolotlClient implements ClientModInitializer {
3940

40-
public static Logger LOGGER = LogManager.getLogger("AxolotlClient");
41+
public static String modid = "AxolotlClient";
4142

4243
public static AxolotlClientConfig CONFIG;
43-
public static String onlinePlayers = "";
44-
public static String otherPlayers = "";
44+
public static ConfigManager configManager;
45+
public static HashMap<UUID, Boolean> playerCache = new HashMap<>();
4546

46-
public static List<ResourcePack> packs = new ArrayList<>();
4747
public static HashMap<Identifier, Resource> runtimeResources = new HashMap<>();
4848

49-
public static boolean initalized = false;
50-
5149
public static final Identifier badgeIcon = new Identifier("axolotlclient", "textures/badge.png");
5250

5351
public static final OptionCategory config = new OptionCategory("storedOptions");
@@ -60,16 +58,16 @@ public class AxolotlClient implements ClientModInitializer {
6058
public void onInitializeClient() {
6159
CONFIG = new AxolotlClientConfig();
6260
config.add(someNiceBackground);
63-
config.add(CONFIG.rotateWorld);
6461

6562
getModules();
63+
addExternalModules();
6664
CONFIG.init();
6765
modules.forEach(AbstractModule::init);
6866

6967
CONFIG.config.addAll(CONFIG.getCategories());
7068
CONFIG.config.add(config);
7169

72-
ConfigManager.load();
70+
io.github.axolotlclient.AxolotlclientConfig.AxolotlClientConfigManager.registerConfig(modid, CONFIG, configManager = new AxolotlClientConfigManager());
7371

7472
modules.forEach(AbstractModule::lateInit);
7573

@@ -78,12 +76,19 @@ public void onInitializeClient() {
7876
optional.ifPresent(path -> MinecraftClient.getInstance().getResourcePackLoader().method_10366(path.toFile()));
7977
});
8078

79+
ClientTickEvents.END_CLIENT_TICK.register(client -> tickClient());
80+
8181
FeatureDisabler.init();
8282

83-
LOGGER.info("AxolotlClient Initialized");
83+
if(CONFIG.debugLogOutput.get()){
84+
Logger.debug("Debug Output enabled, Logs will be quite verbose!");
85+
}
86+
87+
Logger.info("AxolotlClient Initialized");
8488
}
8589

86-
public static void getModules(){
90+
private static void getModules(){
91+
modules.add(SkyResourceManager.getInstance());
8792
modules.add(Zoom.getInstance());
8893
modules.add(HudManager.getInstance());
8994
modules.add(HypixelMods.getInstance());
@@ -96,7 +101,15 @@ public static void getModules(){
96101
modules.add(ScreenshotUtils.getInstance());
97102
}
98103

104+
private static void addExternalModules(){
105+
modules.addAll(ModuleLoader.loadExternalModules());
106+
}
107+
99108
public static boolean isUsingClient(UUID uuid){
109+
if(uuid==null){
110+
return false;
111+
}
112+
100113
assert MinecraftClient.getInstance().player != null;
101114
if (uuid == MinecraftClient.getInstance().player.getUuid()){
102115
return true;
@@ -105,16 +118,15 @@ public static boolean isUsingClient(UUID uuid){
105118
}
106119
}
107120

108-
109121
public static void tickClient(){
110122
modules.forEach(AbstractModule::tick);
111123

112-
Color.tickChroma();
113-
114124
if (tickTime >=6000){
115125

116126
//System.out.println("Cleared Cache of Other Players!");
117-
otherPlayers = "";
127+
if(playerCache.values().size()>500){
128+
playerCache.clear();
129+
}
118130
tickTime = 0;
119131
}
120132
tickTime++;
@@ -132,8 +144,8 @@ public static void addBadge(Entity entity){
132144

133145
int x = -(MinecraftClient.getInstance().textRenderer.getStringWidth(
134146
entity.getUuid() == MinecraftClient.getInstance().player.getUuid()?
135-
(NickHider.Instance.hideOwnName.get() ? NickHider.Instance.hiddenNameSelf.get(): entity.method_6344().asFormattedString()):
136-
(NickHider.Instance.hideOtherNames.get() ? NickHider.Instance.hiddenNameOthers.get(): entity.method_6344().asFormattedString())
147+
(NickHider.Instance.hideOwnName.get() ? NickHider.Instance.hiddenNameSelf.get(): entity.getName().asFormattedString()):
148+
(NickHider.Instance.hideOtherNames.get() ? NickHider.Instance.hiddenNameOthers.get(): entity.getName().asFormattedString())
137149
)/2 + (AxolotlClient.CONFIG.customBadge.get() ? MinecraftClient.getInstance().textRenderer.getStringWidth(" "+AxolotlClient.CONFIG.badgeText.get()): 10));
138150

139151
GlStateManager.color4f(1, 1, 1, 1);

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

0 commit comments

Comments
 (0)