11package anticope .rejects .mixin .meteor .modules ;
22
3- import com .nikoverflow .exploitpreventer .ExploitPreventer ;
4- import com .nikoverflow .exploitpreventer .module .Modules ;
3+ import anticope .rejects .utils .ExploitPreventerCompat ;
54import meteordevelopment .meteorclient .settings .BoolSetting ;
65import meteordevelopment .meteorclient .settings .Setting ;
76import meteordevelopment .meteorclient .settings .SettingGroup ;
87import meteordevelopment .meteorclient .systems .modules .Category ;
98import meteordevelopment .meteorclient .systems .modules .Module ;
109import meteordevelopment .meteorclient .systems .modules .misc .ServerSpoof ;
10+ import net .fabricmc .loader .api .FabricLoader ;
1111import org .spongepowered .asm .mixin .Mixin ;
1212import org .spongepowered .asm .mixin .injection .At ;
1313import org .spongepowered .asm .mixin .injection .Inject ;
1414import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
1515
1616@ Mixin (value = ServerSpoof .class , remap = false )
1717public class ServerSpoofMixin extends Module {
18+ private static final boolean EP_LOADED = FabricLoader .getInstance ().isModLoaded ("exploitpreventer" );
1819
1920 private SettingGroup sgExploitPreventer ;
2021 private Setting <Boolean > translationKey ;
@@ -33,43 +34,45 @@ private void onInit(CallbackInfo ci) {
3334 .name ("translation-key-prevention" )
3435 .description ("Prevents the server from detecting installed mods via translation keys." )
3536 .defaultValue (false )
36- .onChanged (val -> applyModule (Modules .TRANSLATION_KEY , val ))
37+ .onChanged (val -> {
38+ if (!EP_LOADED ) { if (val ) warning ("ExploitPreventer is not installed." ); return ; }
39+ ExploitPreventerCompat .applyTranslationKey (val );
40+ })
3741 .build ()
3842 );
3943
4044 fingerprinting = sgExploitPreventer .add (new BoolSetting .Builder ()
4145 .name ("fingerprint-prevention" )
4246 .description ("Stops servers from using resource packs to uniquely identify your client." )
4347 .defaultValue (false )
44- .onChanged (val -> applyModule (Modules .FINGERPRINTING , val ))
48+ .onChanged (val -> {
49+ if (!EP_LOADED ) { if (val ) warning ("ExploitPreventer is not installed." ); return ; }
50+ ExploitPreventerCompat .applyFingerprinting (val );
51+ })
4552 .build ()
4653 );
4754
4855 localHTTPRequest = sgExploitPreventer .add (new BoolSetting .Builder ()
4956 .name ("local-HTTP-request-prevention" )
5057 .description ("Blocks resource pack URLs that point to local IP addresses, prevents detection of locally running services." )
5158 .defaultValue (false )
52- .onChanged (val -> applyModule (Modules .LOCAL_HTTP_REQUEST , val ))
59+ .onChanged (val -> {
60+ if (!EP_LOADED ) { if (val ) warning ("ExploitPreventer is not installed." ); return ; }
61+ ExploitPreventerCompat .applyLocalHTTPRequest (val );
62+ })
5363 .build ()
5464 );
5565 }
5666
5767 @ Inject (method = "onActivate" , at = @ At ("TAIL" ))
5868 private void onActivate (CallbackInfo ci ) {
59- applyModule (Modules .TRANSLATION_KEY , translationKey .get ());
60- applyModule (Modules .FINGERPRINTING , fingerprinting .get ());
61- applyModule (Modules .LOCAL_HTTP_REQUEST , localHTTPRequest .get ());
69+ if (!EP_LOADED ) return ;
70+ ExploitPreventerCompat .applyAll (translationKey .get (), fingerprinting .get (), localHTTPRequest .get ());
6271 }
6372
64- @ Inject (method = "onDeactivate" , at = @ At ("TAIL" ), remap = false )
73+ @ Inject (method = "onDeactivate" , at = @ At ("TAIL" ), remap = false )
6574 private void onDeactivate (CallbackInfo ci ) {
66- applyModule (Modules .TRANSLATION_KEY , false );
67- applyModule (Modules .FINGERPRINTING , false );
68- applyModule (Modules .LOCAL_HTTP_REQUEST , false );
69- }
70-
71- private void applyModule (Modules module , boolean enabled ) {
72- if (ExploitPreventer .getAPI () == null ) return ;
73- ExploitPreventer .getAPI ().getModuleManager ().getModule (module ).setEnabled (enabled );
75+ if (!EP_LOADED ) return ;
76+ ExploitPreventerCompat .disableAll ();
7477 }
7578}
0 commit comments