1- package com .diffusehyperion .inertiaanticheat .networking .method .data ;
1+ package com .diffusehyperion .inertiaanticheat .client . networking .method .data ;
22
3- import com .diffusehyperion .inertiaanticheat .InertiaAntiCheat ;
43import 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 ;
88import io .netty .channel .ChannelFutureListener ;
99import net .fabricmc .fabric .api .client .networking .v1 .ClientLoginNetworking ;
1010import net .fabricmc .fabric .api .networking .v1 .PacketByteBufs ;
1818import java .nio .file .Files ;
1919import java .nio .file .Path ;
2020import 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 ;
2225import java .util .concurrent .CompletableFuture ;
2326import java .util .function .Consumer ;
2427
28+ import static com .diffusehyperion .inertiaanticheat .client .InertiaAntiCheatClient .debugInfo ;
29+ import static com .diffusehyperion .inertiaanticheat .client .InertiaAntiCheatClient .debugLine ;
30+
2531public 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 ) {
0 commit comments