Skip to content

Commit 6a56030

Browse files
authored
Make ExploitPreventer optional (#532)
1 parent c359082 commit 6a56030

4 files changed

Lines changed: 60 additions & 19 deletions

File tree

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ dependencies {
6262
implementation (include('com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:2.10.1')) {transitive = false}
6363
// implementation (include('com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:master-SNAPSHOT')) {transitive = false}
6464

65-
// Exploit Preventer
66-
modImplementation("com.nikoverflow:exploit-preventer-api:0.0.1")
65+
// Exploit Preventer (optional)
66+
modCompileOnly("com.nikoverflow:exploit-preventer-api:0.0.1")
6767

6868
configurations.implementation.extendsFrom(configurations.extraLibs)
6969
}
Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
package 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;
54
import meteordevelopment.meteorclient.settings.BoolSetting;
65
import meteordevelopment.meteorclient.settings.Setting;
76
import meteordevelopment.meteorclient.settings.SettingGroup;
87
import meteordevelopment.meteorclient.systems.modules.Category;
98
import meteordevelopment.meteorclient.systems.modules.Module;
109
import meteordevelopment.meteorclient.systems.modules.misc.ServerSpoof;
10+
import net.fabricmc.loader.api.FabricLoader;
1111
import org.spongepowered.asm.mixin.Mixin;
1212
import org.spongepowered.asm.mixin.injection.At;
1313
import org.spongepowered.asm.mixin.injection.Inject;
1414
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1515

1616
@Mixin(value = ServerSpoof.class, remap = false)
1717
public 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
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package anticope.rejects.utils;
2+
3+
import com.nikoverflow.exploitpreventer.ExploitPreventer;
4+
import com.nikoverflow.exploitpreventer.module.Modules;
5+
6+
public class ExploitPreventerCompat {
7+
public static void applyTranslationKey(boolean enabled) {
8+
apply(Modules.TRANSLATION_KEY, enabled);
9+
}
10+
11+
public static void applyFingerprinting(boolean enabled) {
12+
apply(Modules.FINGERPRINTING, enabled);
13+
}
14+
15+
public static void applyLocalHTTPRequest(boolean enabled) {
16+
apply(Modules.LOCAL_HTTP_REQUEST, enabled);
17+
}
18+
19+
public static void applyAll(boolean translationKey, boolean fingerprinting, boolean localHTTPRequest) {
20+
apply(Modules.TRANSLATION_KEY, translationKey);
21+
apply(Modules.FINGERPRINTING, fingerprinting);
22+
apply(Modules.LOCAL_HTTP_REQUEST, localHTTPRequest);
23+
}
24+
25+
public static void disableAll() {
26+
apply(Modules.TRANSLATION_KEY, false);
27+
apply(Modules.FINGERPRINTING, false);
28+
apply(Modules.LOCAL_HTTP_REQUEST, false);
29+
}
30+
31+
private static void apply(Modules module, boolean enabled) {
32+
if (ExploitPreventer.getAPI() == null) return;
33+
ExploitPreventer.getAPI().getModuleManager().getModule(module).setEnabled(enabled);
34+
}
35+
}

src/main/resources/fabric.mod.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@
3939
"java": ">=21",
4040
"minecraft": "~${mc_version}",
4141
"meteor-client": "*"
42+
},
43+
"suggests": {
44+
"exploitpreventer": "*"
4245
}
4346
}

0 commit comments

Comments
 (0)