Added ability to disable Meteor's API

This commit is contained in:
Cloudburst
2021-07-23 13:52:31 +02:00
parent a1d8e3d567
commit de891d6c6d
5 changed files with 100 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
package cloudburst.rejects.utils;
import meteordevelopment.meteorclient.systems.System;
import meteordevelopment.meteorclient.MeteorClient;
import net.minecraft.nbt.NbtCompound;
public class RejectsConfig extends System<RejectsConfig> {
private static final RejectsConfig rejectsConfig = new RejectsConfig();
public enum HttpAllowed {
Everything,
NotMeteorApi,
NotMeteorPing,
Nothing
}
public HttpAllowed httpAllowed = HttpAllowed.Everything;
public RejectsConfig() {
super("rejects-config");
init();
load(MeteorClient.FOLDER);
}
public static RejectsConfig get() {
return rejectsConfig;
}
@Override
public NbtCompound toTag() {
NbtCompound tag = new NbtCompound();
tag.putString("httpAllowed", httpAllowed.toString());
return tag;
}
@Override
public RejectsConfig fromTag(NbtCompound tag) {
httpAllowed = HttpAllowed.valueOf(tag.getString("httpAllowed"));
return this;
}
}

View File

@@ -1,5 +1,7 @@
package cloudburst.rejects.utils;
import meteordevelopment.meteorclient.MeteorClient;
import java.util.Timer;
import java.util.TimerTask;
@@ -7,6 +9,10 @@ public class RejectsUtils {
public static int CPS = 0;
public static void init() {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
RejectsConfig.get().save(MeteorClient.FOLDER);
}));
new Timer().scheduleAtFixedRate(newTimerTaskFromLambda(() -> CPS = 0), 0, 1000);
}