Fully ported lambda system to load & save settings

This commit is contained in:
ThisIsALegitUsername 2023-02-18 01:59:26 +00:00
parent fdefd9b446
commit fd24371748
4 changed files with 29454 additions and 29489 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,15 +1,11 @@
package dev.resent; package dev.resent;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import dev.resent.module.base.Mod;
import dev.resent.module.base.ModManager; import dev.resent.module.base.ModManager;
import dev.resent.module.base.RenderMod; import dev.resent.module.base.RenderMod;
import dev.resent.module.setting.BooleanSetting; import dev.resent.module.setting.BooleanSetting;
import dev.resent.module.setting.ModeSetting; import dev.resent.module.setting.ModeSetting;
import dev.resent.module.setting.Setting;
public class Resent { public class Resent {
@ -26,7 +22,6 @@ public class Resent {
} }
public void save(PrintWriter printwriter){ public void save(PrintWriter printwriter){
Resent.INSTANCE.modManager.modules.stream().forEach( m -> { Resent.INSTANCE.modManager.modules.stream().forEach( m -> {
printwriter.println(m.getName() + ":" + m.isEnabled()); printwriter.println(m.getName() + ":" + m.isEnabled());
if(m instanceof RenderMod){ if(m instanceof RenderMod){
@ -47,32 +42,28 @@ public class Resent {
} }
public void load(String[] astring){ public void load(String[] astring){
for (Mod m : Resent.INSTANCE.modManager.modules) {
Resent.INSTANCE.modManager.modules.stream().forEach(m -> {
if (astring[0].equals(m.getName())) { if (astring[0].equals(m.getName())) {
m.setEnabled(astring[1].equals("true")); m.setEnabled(astring[1].equals("true"));
} }
List<RenderMod> rmodules = new ArrayList<>();
if(m instanceof RenderMod){ if(m instanceof RenderMod){
rmodules.add((RenderMod) m); if (astring[0].equals(m.getName() + "_x")) {
((RenderMod)m).setX(Integer.parseInt(astring[1]));
} }
if (astring[0].equals(m.getName() + "_y")) {
for (RenderMod rmod : rmodules) { ((RenderMod)m).setY(Integer.parseInt(astring[1]));
if (astring[0].equals(rmod.getName() + "_x")) {
rmod.setX(Integer.parseInt(astring[1]));
} }
if (astring[0].equals(rmod.getName() + "_y")) { if (astring[0].equals(m.getName() + "_lastx")) {
rmod.setY(Integer.parseInt(astring[1])); ((RenderMod)m).lastX = Integer.parseInt(astring[1]);
} }
if (astring[0].equals(rmod.getName() + "_lastx")) { if (astring[0].equals(m.getName() + "_lasty")) {
rmod.lastX = Integer.parseInt(astring[1]); ((RenderMod)m).lastY = Integer.parseInt(astring[1]);
}
if (astring[0].equals(rmod.getName() + "_lasty")) {
rmod.lastY = Integer.parseInt(astring[1]);
} }
} }
for (Setting se : m.settings) { m.settings.stream().forEach(se ->{
if (se instanceof ModeSetting) { if (se instanceof ModeSetting) {
if (astring[0].equals(m.getName() + "_modesetting_" + se.name)) { if (astring[0].equals(m.getName() + "_modesetting_" + se.name)) {
((ModeSetting) se).setValue(astring[1]); ((ModeSetting) se).setValue(astring[1]);
@ -83,39 +74,14 @@ public class Resent {
((BooleanSetting) se).setValue(astring[1].equals("true")); ((BooleanSetting) se).setValue(astring[1].equals("true"));
} }
} }
} });
} });
} }
//Legacy code below. //Legacy code below.
//private ISound uwu; //private ISound uwu;
/*for (Mod m : Resent.INSTANCE.modManager.modules) {
printwriter.println(m.getName() + ":" + m.isEnabled());
List<RenderMod> rmodules = new ArrayList<>();
if (m instanceof RenderMod) {
rmodules.add((RenderMod) m);
}
for (RenderMod rmod : rmodules) {
printwriter.println(rmod.getName() + "_x:" + rmod.getX());
printwriter.println(rmod.getName() + "_y:" + rmod.getY());
printwriter.println(rmod.getName() + "_lastx:" + rmod.lastX);
printwriter.println(rmod.getName() + "_lastx:" + rmod.lastX);
}
for (Setting s : m.settings) {
if (s instanceof ModeSetting) {
printwriter.println(m.getName() + "_modesetting_" + s.name + ":" + ((ModeSetting) s).getValue());
}
if (s instanceof BooleanSetting) {
printwriter.println(m.getName() + "_boolsetting_" + s.name + ":" + ((BooleanSetting) s).getValue());
}
}
}*/
/*public void playMusic(ResourceLocation loc){ /*public void playMusic(ResourceLocation loc){
this.uwu = PositionedSoundRecord.create(loc); this.uwu = PositionedSoundRecord.create(loc);
if(uwu != null){ if(uwu != null){

View File

@ -4,13 +4,13 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EagRuntime; import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream; import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID; import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;