Skip to content

Commit 92e7ee2

Browse files
Merge pull request #80 from DiffuseHyperion/split-source
Update to Version 1.1.1
2 parents 7a07b6f + 41f85c4 commit 92e7ee2

63 files changed

Lines changed: 673 additions & 563 deletions

File tree

Some content is hidden

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

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dependencies {
4040

4141
implementation("com.google.code.gson:gson:2.13.1")
4242
include(implementation("io.hotmoka:toml4j:0.7.3"))
43-
include(modImplementation("me.lucko:fabric-permissions-api:0.4.0"))
43+
include(modImplementation("me.lucko:fabric-permissions-api:0.5.0"))
4444
}
4545

4646
processResources {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ loader_version=0.17.3
99
loom_version=1.11-SNAPSHOT
1010

1111
# Mod Properties
12-
mod_version = 1.1.0.4
12+
mod_version=1.1.1
1313
maven_group = com.diffusehyperion
1414
archives_base_name = InertiaAntiCheat
1515

src/main/java/com/diffusehyperion/inertiaanticheat/client/ClientLoginModlistTransferHandler.java renamed to src/client/java/com/diffusehyperion/inertiaanticheat/client/ClientLoginModlistTransferHandler.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.diffusehyperion.inertiaanticheat.client;
22

3-
import com.diffusehyperion.inertiaanticheat.InertiaAntiCheat;
4-
import com.diffusehyperion.inertiaanticheat.interfaces.UpgradedClientLoginNetworkHandler;
5-
import com.diffusehyperion.inertiaanticheat.networking.method.CheckingTypes;
6-
import com.diffusehyperion.inertiaanticheat.networking.method.TransferHandler;
7-
import com.diffusehyperion.inertiaanticheat.networking.method.data.ClientDataTransferHandler;
8-
import com.diffusehyperion.inertiaanticheat.networking.method.id.ClientIdTransferHandler;
9-
import com.diffusehyperion.inertiaanticheat.networking.method.name.ClientNameTransferHandler;
10-
import com.diffusehyperion.inertiaanticheat.util.InertiaAntiCheatConstants;
3+
import com.diffusehyperion.inertiaanticheat.client.networking.method.TransferHandler;
4+
import com.diffusehyperion.inertiaanticheat.client.networking.method.data.ClientDataTransferHandler;
5+
import com.diffusehyperion.inertiaanticheat.client.networking.method.id.ClientIdTransferHandler;
6+
import com.diffusehyperion.inertiaanticheat.client.networking.method.name.ClientNameTransferHandler;
7+
import com.diffusehyperion.inertiaanticheat.common.InertiaAntiCheat;
8+
import com.diffusehyperion.inertiaanticheat.common.interfaces.UpgradedClientLoginNetworkHandler;
9+
import com.diffusehyperion.inertiaanticheat.common.util.InertiaAntiCheatConstants;
10+
import com.diffusehyperion.inertiaanticheat.server.networking.method.CheckingTypes;
1111
import io.netty.channel.ChannelFutureListener;
1212
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginConnectionEvents;
1313
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking;
@@ -23,12 +23,15 @@
2323
import java.util.concurrent.CompletableFuture;
2424
import java.util.function.Consumer;
2525

26+
import static com.diffusehyperion.inertiaanticheat.client.InertiaAntiCheatClient.debugInfo;
27+
import static com.diffusehyperion.inertiaanticheat.client.InertiaAntiCheatClient.debugLine;
28+
2629
public class ClientLoginModlistTransferHandler {
2730
private PublicKey serverPublicKey;
2831
private KeyPair clientKeyPair;
2932

3033
public static void init() {
31-
InertiaAntiCheat.debugInfo("Creating mod transfer handler");
34+
debugInfo("Creating mod transfer handler");
3235
ClientLoginNetworking.registerGlobalReceiver(InertiaAntiCheatConstants.CHECK_CONNECTION, ClientLoginModlistTransferHandler::confirmConnection);
3336
}
3437

@@ -41,8 +44,8 @@ public static void init() {
4144
PacketByteBuf buf, Consumer<ChannelFutureListener> callbacksConsumer) {
4245
UpgradedClientLoginNetworkHandler upgradedHandler = (UpgradedClientLoginNetworkHandler) handler;
4346

44-
InertiaAntiCheat.debugLine();
45-
InertiaAntiCheat.debugInfo("Received request to start mod transfer");
47+
debugLine();
48+
debugInfo("Received request to start mod transfer");
4649

4750
upgradedHandler.inertiaAntiCheat$getSecondaryStatusConsumer().accept(Text.of("Preparing mod transfer..."));
4851

@@ -60,7 +63,7 @@ public static void init() {
6063
PacketByteBuf buf, Consumer<ChannelFutureListener> callbacksConsumer) {
6164
UpgradedClientLoginNetworkHandler upgradedHandler = (UpgradedClientLoginNetworkHandler) handler;
6265

63-
InertiaAntiCheat.debugInfo("Exchanging keys with server");
66+
debugInfo("Exchanging keys with server");
6467

6568
upgradedHandler.inertiaAntiCheat$getSecondaryStatusConsumer().accept(Text.of("Transferring keys..."));
6669

@@ -86,7 +89,7 @@ public static void init() {
8689

8790
int transferAdaptorIndex = buf.readInt();
8891
Consumer<Text> secondaryStatusConsumer = upgradedHandler.inertiaAntiCheat$getSecondaryStatusConsumer();
89-
InertiaAntiCheat.debugInfo("Received adapter index of " + transferAdaptorIndex);
92+
debugInfo("Received adapter index of " + transferAdaptorIndex);
9093

9194
CheckingTypes transferAdaptorType = CheckingTypes.values()[transferAdaptorIndex];
9295

@@ -98,8 +101,8 @@ public static void init() {
98101

99102
ClientLoginConnectionEvents.DISCONNECT.register(transferAdaptor::onDisconnect);
100103

101-
InertiaAntiCheat.debugInfo("Registered new handler for channel");
102-
InertiaAntiCheat.debugLine();
104+
debugInfo("Registered new handler for channel");
105+
debugLine();
103106

104107
return CompletableFuture.completedFuture(PacketByteBufs.empty());
105108
}

src/main/java/com/diffusehyperion/inertiaanticheat/client/InertiaAntiCheatClient.java renamed to src/client/java/com/diffusehyperion/inertiaanticheat/client/InertiaAntiCheatClient.java

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.diffusehyperion.inertiaanticheat.client;
22

3+
import com.diffusehyperion.inertiaanticheat.common.InertiaAntiCheat;
4+
import com.diffusehyperion.inertiaanticheat.common.util.InertiaAntiCheatConstants;
35
import com.google.gson.Gson;
46
import com.google.gson.JsonObject;
57
import com.moandjiezana.toml.Toml;
6-
import com.diffusehyperion.inertiaanticheat.InertiaAntiCheat;
7-
import com.diffusehyperion.inertiaanticheat.util.InertiaAntiCheatConstants;
88
import net.fabricmc.api.ClientModInitializer;
99
import net.fabricmc.loader.api.FabricLoader;
1010

@@ -19,6 +19,8 @@
1919
import java.util.jar.JarFile;
2020
import java.util.zip.ZipEntry;
2121

22+
import static com.diffusehyperion.inertiaanticheat.common.InertiaAntiCheat.*;
23+
2224
public class InertiaAntiCheatClient implements ClientModInitializer {
2325
public static Toml clientConfig;
2426
public static final List<String> allModNames = new ArrayList<>();
@@ -33,23 +35,57 @@ public void onInitializeClient() {
3335
ClientLoginModlistTransferHandler.init();
3436
}
3537

38+
public static void debugInfo(String info) {
39+
if (inDebug()) {
40+
info(info);
41+
}
42+
}
43+
44+
public static void debugWarn(String info) {
45+
if (inDebug()) {
46+
warn(info);
47+
}
48+
}
49+
50+
public static void debugError(String info) {
51+
if (inDebug()) {
52+
error(info);
53+
}
54+
}
55+
56+
public static void debugLine() {
57+
if (inDebug()) {
58+
info("--------------------"); // lol
59+
}
60+
}
61+
62+
public static void debugLine2() {
63+
if (inDebug()) {
64+
info("===================="); // lol 2
65+
}
66+
}
67+
68+
public static boolean inDebug() {
69+
return FabricLoader.getInstance().isDevelopmentEnvironment() || clientConfig.getBoolean("debug.debug");
70+
}
71+
3672
private void setupModlist() {
3773
File modDirectory = FabricLoader.getInstance().getGameDir().resolve("mods").toFile();
3874
for (File modFile : Objects.requireNonNull(modDirectory.listFiles())) {
39-
InertiaAntiCheat.debugInfo("Attempting to load mod " + modFile.getName());
75+
debugInfo("Attempting to load mod " + modFile.getName());
4076
if (modFile.isDirectory()) {
41-
InertiaAntiCheat.debugWarn("Skipping mod " + modFile.getName() + " as it is a directory");
77+
debugWarn("Skipping mod " + modFile.getName() + " as it is a directory");
4278
continue;
4379
}
4480
if (!modFile.getAbsolutePath().endsWith(".jar")) {
45-
InertiaAntiCheat.debugWarn("Skipping mod " + modFile.getName() + " as it does not end with .jar");
81+
debugWarn("Skipping mod " + modFile.getName() + " as it does not end with .jar");
4682
continue;
4783
}
4884

4985
try (JarFile jarFile = new JarFile(modFile)) {
5086
ZipEntry entry = jarFile.getEntry("fabric.mod.json");
5187
if (Objects.isNull(entry)) {
52-
InertiaAntiCheat.debugWarn("Skipping mod " + modFile.getName() + " as it does not contain \"fabric.mod.json\"");
88+
debugWarn("Skipping mod " + modFile.getName() + " as it does not contain \"fabric.mod.json\"");
5389
continue;
5490
}
5591

@@ -58,17 +94,17 @@ private void setupModlist() {
5894
JsonObject root = gson.fromJson(new InputStreamReader(input), JsonObject.class);
5995

6096
if (!root.has("id")) {
61-
InertiaAntiCheat.debugWarn("Skipping mod " + modFile.getName() + " as it does not contain a mod ID");
97+
debugWarn("Skipping mod " + modFile.getName() + " as it does not contain a mod ID");
6298
continue;
6399
}
64100

65101
InertiaAntiCheatClient.allModNames.add(modFile.getName());
66102
InertiaAntiCheatClient.allModPaths.add(modFile.toPath());
67103
InertiaAntiCheatClient.allModIds.add(root.get("id").getAsString());
68-
InertiaAntiCheat.debugInfo("Successfully loaded " + modFile.getName());
104+
debugInfo("Successfully loaded " + modFile.getName());
69105
}
70106
} catch (IOException e) {
71-
InertiaAntiCheat.debugWarn("Skipping mod " + modFile.getName() + " as it could not be read");
107+
debugWarn("Skipping mod " + modFile.getName() + " as it could not be read");
72108
}
73109
}
74110
InertiaAntiCheat.info("Loaded " + InertiaAntiCheatClient.allModNames.size() + " mods");

src/main/java/com/diffusehyperion/inertiaanticheat/interfaces/UpgradedClientCollection.java renamed to src/client/java/com/diffusehyperion/inertiaanticheat/client/interfaces/UpgradedClientCollection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package com.diffusehyperion.inertiaanticheat.interfaces;
1+
package com.diffusehyperion.inertiaanticheat.client.interfaces;
22

3-
import com.diffusehyperion.inertiaanticheat.networking.packets.UpgradedClientQueryPacketListener;
3+
import com.diffusehyperion.inertiaanticheat.common.networking.packets.UpgradedClientQueryPacketListener;
44

55
public interface UpgradedClientCollection {
66
void inertiaAntiCheat$connect(String string, int i, UpgradedClientQueryPacketListener clientUpgradedStatusPacketListener);

src/main/java/com/diffusehyperion/inertiaanticheat/networking/method/TransferHandler.java renamed to src/client/java/com/diffusehyperion/inertiaanticheat/client/networking/method/TransferHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.diffusehyperion.inertiaanticheat.networking.method;
1+
package com.diffusehyperion.inertiaanticheat.client.networking.method;
22

3-
import com.diffusehyperion.inertiaanticheat.InertiaAntiCheat;
4-
import com.diffusehyperion.inertiaanticheat.util.InertiaAntiCheatConstants;
3+
import com.diffusehyperion.inertiaanticheat.common.InertiaAntiCheat;
4+
import com.diffusehyperion.inertiaanticheat.common.util.InertiaAntiCheatConstants;
55
import io.netty.channel.ChannelFutureListener;
66
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking;
77
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;

src/main/java/com/diffusehyperion/inertiaanticheat/networking/method/data/ClientDataTransferHandler.java renamed to src/client/java/com/diffusehyperion/inertiaanticheat/client/networking/method/data/ClientDataTransferHandler.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package com.diffusehyperion.inertiaanticheat.networking.method.data;
1+
package com.diffusehyperion.inertiaanticheat.client.networking.method.data;
22

3-
import com.diffusehyperion.inertiaanticheat.InertiaAntiCheat;
43
import com.diffusehyperion.inertiaanticheat.client.InertiaAntiCheatClient;
5-
import com.diffusehyperion.inertiaanticheat.networking.method.TransferHandler;
6-
import com.diffusehyperion.inertiaanticheat.util.HashAlgorithm;
7-
import com.diffusehyperion.inertiaanticheat.util.InertiaAntiCheatConstants;
4+
import com.diffusehyperion.inertiaanticheat.client.networking.method.TransferHandler;
5+
import com.diffusehyperion.inertiaanticheat.common.InertiaAntiCheat;
6+
import com.diffusehyperion.inertiaanticheat.common.util.HashAlgorithm;
7+
import com.diffusehyperion.inertiaanticheat.common.util.InertiaAntiCheatConstants;
88
import io.netty.channel.ChannelFutureListener;
99
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking;
1010
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
@@ -18,10 +18,16 @@
1818
import java.nio.file.Files;
1919
import java.nio.file.Path;
2020
import java.security.PublicKey;
21-
import java.util.*;
21+
import java.util.ArrayDeque;
22+
import java.util.Arrays;
23+
import java.util.Deque;
24+
import java.util.Objects;
2225
import java.util.concurrent.CompletableFuture;
2326
import java.util.function.Consumer;
2427

28+
import static com.diffusehyperion.inertiaanticheat.client.InertiaAntiCheatClient.debugInfo;
29+
import static com.diffusehyperion.inertiaanticheat.client.InertiaAntiCheatClient.debugLine;
30+
2531
public class ClientDataTransferHandler extends TransferHandler {
2632

2733
private int allModPathsIndex;
@@ -35,7 +41,7 @@ public class ClientDataTransferHandler extends TransferHandler {
3541
public ClientDataTransferHandler(PublicKey publicKey, Identifier modTransferID, Consumer<Text> secondaryStatusConsumer) {
3642
super(publicKey, modTransferID, secondaryStatusConsumer, InertiaAntiCheatClient.allModPaths.size());
3743

38-
InertiaAntiCheat.debugInfo("Creating data transfer handler");
44+
debugInfo("Creating data transfer handler");
3945

4046
this.completed = false;
4147
this.loadedFiles = new ArrayDeque<>(MAX_LOADED_FILES);
@@ -49,8 +55,8 @@ public ClientDataTransferHandler(PublicKey publicKey, Identifier modTransferID,
4955
public CompletableFuture<PacketByteBuf> transferMod(MinecraftClient ignored1, ClientLoginNetworkHandler ignored2, PacketByteBuf ignored3, Consumer<ChannelFutureListener> ignored4) {
5056
if (this.completed && this.loadedFiles.isEmpty() && Objects.isNull(currentFile)) {
5157
// All files have been sent, returning null to signify goodbye
52-
InertiaAntiCheat.debugInfo("Sending final packet");
53-
InertiaAntiCheat.debugLine();
58+
debugInfo("Sending final packet");
59+
debugLine();
5460

5561
this.setCompleteTransferStatus();
5662

@@ -65,25 +71,25 @@ public CompletableFuture<PacketByteBuf> transferMod(MinecraftClient ignored1, Cl
6571
byte[] chunk;
6672

6773
if (this.currentFile.length > ClientDataTransferHandler.MAX_SIZE) {
68-
InertiaAntiCheat.debugInfo("Sending part of next file");
74+
debugInfo("Sending part of next file");
6975

7076
chunk = Arrays.copyOf(this.currentFile, ClientDataTransferHandler.MAX_SIZE);
71-
InertiaAntiCheat.debugInfo("Hash of chunk: " + InertiaAntiCheat.getHash(chunk, HashAlgorithm.MD5));
77+
debugInfo("Hash of chunk: " + InertiaAntiCheat.getHash(chunk, HashAlgorithm.MD5));
7278

7379
this.currentFile = Arrays.copyOfRange(this.currentFile, ClientDataTransferHandler.MAX_SIZE, this.currentFile.length);
7480
buf.writeBoolean(false);
7581
} else {
76-
InertiaAntiCheat.debugInfo("Sending entirety of next file");
82+
debugInfo("Sending entirety of next file");
7783

7884
chunk = this.currentFile;
79-
InertiaAntiCheat.debugInfo("Hash of chunk: " + InertiaAntiCheat.getHash(this.currentFile, HashAlgorithm.MD5));
85+
debugInfo("Hash of chunk: " + InertiaAntiCheat.getHash(this.currentFile, HashAlgorithm.MD5));
8086

8187
this.currentFile = null;
8288
buf.writeBoolean(true);
8389
}
8490
PacketByteBuf responseBuf = this.preparePacket(buf, chunk);
8591

86-
InertiaAntiCheat.debugLine();
92+
debugLine();
8793

8894
return CompletableFuture.completedFuture(responseBuf);
8995
}
@@ -100,7 +106,7 @@ private synchronized void fileLoaderThreadMethod() {
100106

101107
try {
102108
this.loadedFiles.addLast(Files.readAllBytes(path));
103-
InertiaAntiCheat.debugInfo("Loaded mod file: " + path);
109+
debugInfo("Loaded mod file: " + path);
104110
notifyAll();
105111
} catch (IOException e) {
106112
throw new RuntimeException("Could not read mod file at path: " + path, e);
@@ -109,7 +115,7 @@ private synchronized void fileLoaderThreadMethod() {
109115
}
110116
}
111117

112-
InertiaAntiCheat.debugInfo("Mod file loader thread cleaning up at index " + this.allModPathsIndex);
118+
debugInfo("Mod file loader thread cleaning up at index " + this.allModPathsIndex);
113119
this.completed = true;
114120
} catch (InterruptedException e) {
115121
Thread.currentThread().interrupt();
@@ -123,7 +129,7 @@ private synchronized byte[] stageNextFile() {
123129
}
124130

125131
byte[] loadedFile = this.loadedFiles.remove();
126-
InertiaAntiCheat.debugInfo("Staged mod file");
132+
debugInfo("Staged mod file");
127133
notifyAll();
128134
return loadedFile;
129135
} catch (InterruptedException e) {

src/main/java/com/diffusehyperion/inertiaanticheat/networking/method/id/ClientIdTransferHandler.java renamed to src/client/java/com/diffusehyperion/inertiaanticheat/client/networking/method/id/ClientIdTransferHandler.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
package com.diffusehyperion.inertiaanticheat.networking.method.id;
1+
package com.diffusehyperion.inertiaanticheat.client.networking.method.id;
22

3-
import com.diffusehyperion.inertiaanticheat.InertiaAntiCheat;
43
import com.diffusehyperion.inertiaanticheat.client.InertiaAntiCheatClient;
5-
import com.diffusehyperion.inertiaanticheat.networking.method.TransferHandler;
6-
import com.diffusehyperion.inertiaanticheat.util.InertiaAntiCheatConstants;
4+
import com.diffusehyperion.inertiaanticheat.client.networking.method.TransferHandler;
5+
import com.diffusehyperion.inertiaanticheat.common.util.InertiaAntiCheatConstants;
76
import io.netty.channel.ChannelFutureListener;
87
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginNetworking;
98
import net.minecraft.client.MinecraftClient;
@@ -17,27 +16,30 @@
1716
import java.util.concurrent.CompletableFuture;
1817
import java.util.function.Consumer;
1918

19+
import static com.diffusehyperion.inertiaanticheat.client.InertiaAntiCheatClient.debugInfo;
20+
import static com.diffusehyperion.inertiaanticheat.client.InertiaAntiCheatClient.debugLine;
21+
2022
public class ClientIdTransferHandler extends TransferHandler {
2123
private final int maxIndex;
2224
private int currentIndex;
2325

2426
public ClientIdTransferHandler(PublicKey publicKey, Identifier modTransferID, Consumer<Text> secondaryStatusConsumer) {
2527
super(publicKey, modTransferID, secondaryStatusConsumer, InertiaAntiCheatClient.allModIds.size());
2628

27-
InertiaAntiCheat.debugInfo("Creating id transfer handler");
29+
debugInfo("Creating id transfer handler");
2830

2931
this.maxIndex = InertiaAntiCheatClient.allModIds.size();
3032
this.currentIndex = 0;
3133
}
3234

3335
@Override
3436
public CompletableFuture<PacketByteBuf> transferMod(MinecraftClient client, ClientLoginNetworkHandler handler, PacketByteBuf buf, Consumer<ChannelFutureListener> callbacksConsumer) {
35-
InertiaAntiCheat.debugInfo("Sending mod ID " + this.currentIndex);
37+
debugInfo("Sending mod ID " + this.currentIndex);
3638

3739
if (this.currentIndex >= this.maxIndex) {
3840
// All files have been sent, returning null to signify goodbye
39-
InertiaAntiCheat.debugInfo("Sending final packet");
40-
InertiaAntiCheat.debugLine();
41+
debugInfo("Sending final packet");
42+
debugLine();
4143

4244
this.setCompleteTransferStatus();
4345

@@ -49,7 +51,7 @@ public CompletableFuture<PacketByteBuf> transferMod(MinecraftClient client, Clie
4951
this.increaseSentModsStatus();
5052
this.currentIndex++;
5153

52-
InertiaAntiCheat.debugLine();
54+
debugLine();
5355
return CompletableFuture.completedFuture(responseBuf);
5456
}
5557
}

0 commit comments

Comments
 (0)