Some of my closed PRs (#172)
* update * fix * make duplicateModuleNames default False
This commit is contained in:
@@ -78,6 +78,8 @@
|
|||||||
- `disableToasts`
|
- `disableToasts`
|
||||||
- Flight
|
- Flight
|
||||||
- `stopMomentum`
|
- `stopMomentum`
|
||||||
|
- Module
|
||||||
|
- `Duplicate names`
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
- `.center`
|
- `.center`
|
||||||
@@ -108,5 +110,7 @@
|
|||||||
- Radar HUD
|
- Radar HUD
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
- `Http Allowed` - modify what http requests can be made with Meteor's http api
|
- `Http Allowed` - Modify what http requests can be made with Meteor's http api
|
||||||
- `Hidden Modules` - hide modules from module gui. **requires restart when unhiding**
|
- `Hidden Modules` - Hide modules from module gui. **requires restart when unhiding**
|
||||||
|
- `Load system fonts` - Disabling this for faster launch. You can put font into meteor-client/fonts folder. **requires restart to take effect**
|
||||||
|
- `Duplicate module names` - Allow duplicate module names. Best for addon compatibility.
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package anticope.rejects.mixin.meteor;
|
||||||
|
|
||||||
|
import anticope.rejects.utils.RejectsConfig;
|
||||||
|
import meteordevelopment.meteorclient.MeteorClient;
|
||||||
|
import meteordevelopment.meteorclient.utils.render.FontUtils;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Mixin(FontUtils.class)
|
||||||
|
public class FontUtilsMixin {
|
||||||
|
@Inject(method = "getSearchPaths", at = @At("HEAD"), cancellable = true, remap = false)
|
||||||
|
private static void onGetSearchPaths(CallbackInfoReturnable<Set<String>> info) {
|
||||||
|
if (!RejectsConfig.get().loadSystemFonts) {
|
||||||
|
File dir = new File(MeteorClient.FOLDER, "fonts");
|
||||||
|
info.setReturnValue(!dir.mkdirs() ? Collections.singleton(dir.getAbsolutePath()) : new HashSet<>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
src/main/java/anticope/rejects/mixin/meteor/ModuleMixin.java
Normal file
28
src/main/java/anticope/rejects/mixin/meteor/ModuleMixin.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package anticope.rejects.mixin.meteor;
|
||||||
|
|
||||||
|
import anticope.rejects.utils.RejectsConfig;
|
||||||
|
import anticope.rejects.utils.RejectsUtils;
|
||||||
|
import meteordevelopment.meteorclient.systems.modules.Category;
|
||||||
|
import meteordevelopment.meteorclient.systems.modules.Module;
|
||||||
|
import meteordevelopment.meteorclient.utils.Utils;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Mutable;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(Module.class)
|
||||||
|
public class ModuleMixin {
|
||||||
|
@Mutable @Shadow public String name;
|
||||||
|
|
||||||
|
@Mutable @Shadow public String title;
|
||||||
|
|
||||||
|
@Inject(method = "<init>", at = @At("TAIL"), remap = false)
|
||||||
|
private void onInit(Category category, String name, String description, CallbackInfo info) {
|
||||||
|
if (RejectsConfig.get().duplicateModuleNames) {
|
||||||
|
this.name = RejectsUtils.getModuleName(name);
|
||||||
|
this.title = Utils.nameToTitle(this.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,9 @@
|
|||||||
package anticope.rejects.utils;
|
package anticope.rejects.utils;
|
||||||
|
|
||||||
import meteordevelopment.meteorclient.settings.EnumSetting;
|
import meteordevelopment.meteorclient.settings.*;
|
||||||
import meteordevelopment.meteorclient.settings.ModuleListSetting;
|
|
||||||
import meteordevelopment.meteorclient.settings.Setting;
|
|
||||||
import meteordevelopment.meteorclient.settings.SettingGroup;
|
|
||||||
import meteordevelopment.meteorclient.systems.config.Config;
|
import meteordevelopment.meteorclient.systems.config.Config;
|
||||||
import meteordevelopment.meteorclient.systems.modules.Module;
|
import meteordevelopment.meteorclient.systems.modules.Module;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ConfigModifier {
|
public class ConfigModifier {
|
||||||
@@ -27,12 +23,30 @@ public class ConfigModifier {
|
|||||||
public final Setting<List<Module>> hiddenModules = sgRejects.add(new ModuleListSetting.Builder()
|
public final Setting<List<Module>> hiddenModules = sgRejects.add(new ModuleListSetting.Builder()
|
||||||
.name("hidden-modules")
|
.name("hidden-modules")
|
||||||
.description("Which modules to hide.")
|
.description("Which modules to hide.")
|
||||||
.defaultValue(Arrays.asList())
|
.defaultValue(List.of())
|
||||||
.defaultValue(RejectsConfig.get().getHiddenModules())
|
.defaultValue(RejectsConfig.get().getHiddenModules())
|
||||||
.onChanged(v -> RejectsConfig.get().setHiddenModules(v))
|
.onChanged(v -> RejectsConfig.get().setHiddenModules(v))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public final Setting<Boolean> loadSystemFonts = sgRejects.add(new BoolSetting.Builder()
|
||||||
|
.name("load-system-fonts")
|
||||||
|
.description("Disabling this for faster launch. You can put font into meteor-client/fonts folder. Restart to take effect.")
|
||||||
|
.defaultValue(true)
|
||||||
|
.defaultValue(RejectsConfig.get().loadSystemFonts)
|
||||||
|
.onChanged(v -> RejectsConfig.get().loadSystemFonts = v)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
|
public final Setting<Boolean> duplicateModuleNames = sgRejects.add(new BoolSetting.Builder()
|
||||||
|
.name("duplicate-module-names")
|
||||||
|
.description("Allow duplicate module names. Best for addon compatibility.")
|
||||||
|
.defaultValue(false)
|
||||||
|
.defaultValue(RejectsConfig.get().duplicateModuleNames)
|
||||||
|
.onChanged(v -> RejectsConfig.get().duplicateModuleNames = v)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
public static ConfigModifier get() {
|
public static ConfigModifier get() {
|
||||||
if (INSTANCE == null) INSTANCE = new ConfigModifier();
|
if (INSTANCE == null) INSTANCE = new ConfigModifier();
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
package anticope.rejects.utils;
|
package anticope.rejects.utils;
|
||||||
|
|
||||||
|
import meteordevelopment.meteorclient.MeteorClient;
|
||||||
import meteordevelopment.meteorclient.systems.System;
|
import meteordevelopment.meteorclient.systems.System;
|
||||||
import meteordevelopment.meteorclient.systems.modules.Module;
|
import meteordevelopment.meteorclient.systems.modules.Module;
|
||||||
import meteordevelopment.meteorclient.systems.modules.Modules;
|
import meteordevelopment.meteorclient.systems.modules.Modules;
|
||||||
import meteordevelopment.meteorclient.MeteorClient;
|
|
||||||
import meteordevelopment.meteorclient.utils.render.prompts.OkPrompt;
|
import meteordevelopment.meteorclient.utils.render.prompts.OkPrompt;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.nbt.NbtElement;
|
import net.minecraft.nbt.NbtElement;
|
||||||
import net.minecraft.nbt.NbtList;
|
import net.minecraft.nbt.NbtList;
|
||||||
import net.minecraft.nbt.NbtString;
|
import net.minecraft.nbt.NbtString;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class RejectsConfig extends System<RejectsConfig> {
|
public class RejectsConfig extends System<RejectsConfig> {
|
||||||
private static final RejectsConfig INSTANCE = new RejectsConfig();
|
private static final RejectsConfig INSTANCE = new RejectsConfig();
|
||||||
|
|
||||||
@@ -28,7 +26,9 @@ public class RejectsConfig extends System<RejectsConfig> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HttpAllowed httpAllowed = HttpAllowed.Everything;
|
public HttpAllowed httpAllowed = HttpAllowed.Everything;
|
||||||
public Set<String> hiddenModules = new HashSet<String>();
|
public Set<String> hiddenModules = new HashSet<>();
|
||||||
|
public boolean loadSystemFonts = true;
|
||||||
|
public boolean duplicateModuleNames = false;
|
||||||
|
|
||||||
public RejectsConfig() {
|
public RejectsConfig() {
|
||||||
super("rejects-config");
|
super("rejects-config");
|
||||||
@@ -43,10 +43,10 @@ public class RejectsConfig extends System<RejectsConfig> {
|
|||||||
public void setHiddenModules(List<Module> newList) {
|
public void setHiddenModules(List<Module> newList) {
|
||||||
if (newList.size() < hiddenModules.size()) {
|
if (newList.size() < hiddenModules.size()) {
|
||||||
OkPrompt.create()
|
OkPrompt.create()
|
||||||
.title("Hidden Modules")
|
.title("Hidden Modules")
|
||||||
.message("In order to see the modules you have removed from the list you need to restart Minecraft.")
|
.message("In order to see the modules you have removed from the list you need to restart Minecraft.")
|
||||||
.id("hidden-modules-unhide")
|
.id("hidden-modules-unhide")
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
hiddenModules.clear();
|
hiddenModules.clear();
|
||||||
for (Module module : newList) {
|
for (Module module : newList) {
|
||||||
@@ -58,7 +58,7 @@ public class RejectsConfig extends System<RejectsConfig> {
|
|||||||
|
|
||||||
public List<Module> getHiddenModules() {
|
public List<Module> getHiddenModules() {
|
||||||
Modules modules = Modules.get();
|
Modules modules = Modules.get();
|
||||||
if (modules == null) return Arrays.asList();
|
if (modules == null) return List.of();
|
||||||
return hiddenModules.stream().map(modules::get).collect(Collectors.toList());
|
return hiddenModules.stream().map(modules::get).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +66,8 @@ public class RejectsConfig extends System<RejectsConfig> {
|
|||||||
public NbtCompound toTag() {
|
public NbtCompound toTag() {
|
||||||
NbtCompound tag = new NbtCompound();
|
NbtCompound tag = new NbtCompound();
|
||||||
tag.putString("httpAllowed", httpAllowed.toString());
|
tag.putString("httpAllowed", httpAllowed.toString());
|
||||||
|
tag.putBoolean("loadSystemFonts", loadSystemFonts);
|
||||||
|
tag.putBoolean("duplicateModuleNames", duplicateModuleNames);
|
||||||
|
|
||||||
NbtList modulesTag = new NbtList();
|
NbtList modulesTag = new NbtList();
|
||||||
for (String module : hiddenModules) modulesTag.add(NbtString.of(module));
|
for (String module : hiddenModules) modulesTag.add(NbtString.of(module));
|
||||||
@@ -77,6 +79,8 @@ public class RejectsConfig extends System<RejectsConfig> {
|
|||||||
@Override
|
@Override
|
||||||
public RejectsConfig fromTag(NbtCompound tag) {
|
public RejectsConfig fromTag(NbtCompound tag) {
|
||||||
httpAllowed = HttpAllowed.valueOf(tag.getString("httpAllowed"));
|
httpAllowed = HttpAllowed.valueOf(tag.getString("httpAllowed"));
|
||||||
|
loadSystemFonts = tag.getBoolean("loadSystemFonts");
|
||||||
|
duplicateModuleNames = tag.getBoolean("duplicateModuleNames");
|
||||||
|
|
||||||
NbtList valueTag = tag.getList("hiddenModules", 8);
|
NbtList valueTag = tag.getList("hiddenModules", 8);
|
||||||
for (NbtElement tagI : valueTag) {
|
for (NbtElement tagI : valueTag) {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package anticope.rejects.utils;
|
|||||||
|
|
||||||
import anticope.rejects.utils.seeds.Seeds;
|
import anticope.rejects.utils.seeds.Seeds;
|
||||||
import meteordevelopment.meteorclient.MeteorClient;
|
import meteordevelopment.meteorclient.MeteorClient;
|
||||||
|
import meteordevelopment.meteorclient.systems.modules.Module;
|
||||||
|
import meteordevelopment.meteorclient.systems.modules.Modules;
|
||||||
import meteordevelopment.meteorclient.utils.PostInit;
|
import meteordevelopment.meteorclient.utils.PostInit;
|
||||||
public class RejectsUtils {
|
public class RejectsUtils {
|
||||||
|
|
||||||
@@ -13,4 +15,15 @@ public class RejectsUtils {
|
|||||||
Seeds.get().save(MeteorClient.FOLDER);
|
Seeds.get().save(MeteorClient.FOLDER);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getModuleName(String name) {
|
||||||
|
int dupe = 0;
|
||||||
|
for (Module module : Modules.get().getAll()) {
|
||||||
|
if (module.name.equals(name)) {
|
||||||
|
dupe++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dupe == 0 ? name : getModuleName(name + "*".repeat(dupe));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,9 @@
|
|||||||
"ConfigTabMixin",
|
"ConfigTabMixin",
|
||||||
"GuiRendererAccessor",
|
"GuiRendererAccessor",
|
||||||
"HttpMixin",
|
"HttpMixin",
|
||||||
|
"ModuleMixin",
|
||||||
"ModulesMixin",
|
"ModulesMixin",
|
||||||
|
"FontUtilsMixin",
|
||||||
"modules.FlightMixin",
|
"modules.FlightMixin",
|
||||||
"modules.NoRenderAccessor"
|
"modules.NoRenderAccessor"
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user