aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/Config.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java1
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java31
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/hud/SingleTextHud.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/images/Image.java18
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/init/OneConfigInit.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/OneConfigTweaker.java1
9 files changed, 12 insertions, 54 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
index d297805..7ecd4d0 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/Config.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
@@ -21,6 +21,7 @@ import cc.polyfrost.oneconfig.internal.config.annotations.Option;
import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import cc.polyfrost.oneconfig.internal.config.core.KeyBindHandler;
import cc.polyfrost.oneconfig.utils.JsonUtils;
+import cc.polyfrost.oneconfig.utils.Multithreading;
import cc.polyfrost.oneconfig.utils.TickDelay;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
import com.google.gson.*;
@@ -52,7 +53,7 @@ public class Config {
*/
public Config(Mod modData, String configFile, boolean initialize) {
this.configFile = configFile;
- if (initialize) new TickDelay(() -> init(modData), 1); // wait one tick so every class in config gets initialized
+ Multithreading.runAsync(() -> init(modData)); // wait a bit to give everything time to initialize
}
/**
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java
index bfad00c..ad148df 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig.java
@@ -193,7 +193,6 @@ public class VigilanceConfig extends Config {
try {
this.color.set(parent, newColor);
} catch (IllegalAccessException ignored) {
-
}
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java b/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java
index 0066dd8..365ddb6 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/elements/OptionSubcategory.java
@@ -7,13 +7,15 @@ import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
public class OptionSubcategory {
private final String name;
public ArrayList<BasicOption> options = new ArrayList<>();
public ArrayList<ConfigPageButton> topButtons = new ArrayList<>();
public ArrayList<ConfigPageButton> bottomButtons = new ArrayList<>();
- private ArrayList<BasicOption> filteredOptions = new ArrayList<>();
+ private List<BasicOption> filteredOptions = new ArrayList<>();
private int drawLastY;
public OptionSubcategory(String name) {
@@ -22,25 +24,9 @@ public class OptionSubcategory {
public int draw(long vg, int x, int y) {
String filter = OneConfigGui.INSTANCE == null ? "" : OneConfigGui.INSTANCE.getSearchValue().toLowerCase().trim();
- filteredOptions = new ArrayList<>(options);
- ArrayList<ConfigPageButton> filteredTop = new ArrayList<>(topButtons);
- ArrayList<ConfigPageButton> filteredBottom = new ArrayList<>(bottomButtons);
- if (!filter.equals("") && !name.toLowerCase().contains(filter)) {
- filteredOptions.clear();
- filteredTop.clear();
- filteredBottom.clear();
- for (BasicOption option : options) {
- if (option.name.toLowerCase().contains(filter)) filteredOptions.add(option);
- }
- for (ConfigPageButton page : topButtons) {
- if (page.name.toLowerCase().contains(filter) || page.description.toLowerCase().contains(filter))
- filteredTop.add(page);
- }
- for (ConfigPageButton page : bottomButtons) {
- if (page.name.toLowerCase().contains(filter) || page.description.toLowerCase().contains(filter))
- filteredBottom.add(page);
- }
- }
+ filteredOptions = options.stream().filter(option -> !option.isHidden() && (filter.equals("") || name.toLowerCase().contains(filter) || option.name.toLowerCase().contains(filter))).collect(Collectors.toList());
+ List<ConfigPageButton> filteredTop = topButtons.stream().filter(page -> !page.isHidden() && (filter.equals("") || name.toLowerCase().contains(filter) || page.name.toLowerCase().contains(filter) || page.description.toLowerCase().contains(filter))).collect(Collectors.toList());
+ List<ConfigPageButton> filteredBottom = bottomButtons.stream().filter(page -> !page.isHidden() && (filter.equals("") || name.toLowerCase().contains(filter) || page.name.toLowerCase().contains(filter) || page.description.toLowerCase().contains(filter))).collect(Collectors.toList());
if (filteredOptions.size() == 0 && filteredTop.size() == 0 && filteredBottom.size() == 0) return 0;
int optionY = y;
if (!name.equals("")) {
@@ -49,7 +35,6 @@ public class OptionSubcategory {
}
for (ConfigPageButton page : filteredTop) {
- if (page.isHidden()) continue;
page.draw(vg, x, optionY);
optionY += page.getHeight() + 16;
}
@@ -58,7 +43,6 @@ public class OptionSubcategory {
int backgroundSize = 16;
for (int i = 0; i < filteredOptions.size(); i++) {
BasicOption option = filteredOptions.get(i);
- if (option.isHidden()) continue;
if (i + 1 < filteredOptions.size()) {
BasicOption nextOption = filteredOptions.get(i + 1);
if (option.size == 1 && nextOption.size == 1) {
@@ -77,7 +61,6 @@ public class OptionSubcategory {
if (filteredOptions.size() > 0) {
for (int i = 0; i < filteredOptions.size(); i++) {
BasicOption option = filteredOptions.get(i);
- if (option.isHidden()) continue;
option.draw(vg, x, optionY);
if (i + 1 < filteredOptions.size()) {
BasicOption nextOption = filteredOptions.get(i + 1);
@@ -94,7 +77,6 @@ public class OptionSubcategory {
}
for (ConfigPageButton page : filteredBottom) {
- if (page.isHidden()) continue;
page.draw(vg, x, optionY);
optionY += page.getHeight() + 16;
}
@@ -105,7 +87,6 @@ public class OptionSubcategory {
public void drawLast(long vg, int x) {
for (int i = 0; i < filteredOptions.size(); i++) {
BasicOption option = filteredOptions.get(i);
- if (option.isHidden()) continue;
option.drawLast(vg, x, drawLastY);
if (i + 1 < filteredOptions.size()) {
BasicOption nextOption = filteredOptions.get(i + 1);
diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/SingleTextHud.java b/src/main/java/cc/polyfrost/oneconfig/hud/SingleTextHud.java
index 4d11b1e..d3ce8f2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/hud/SingleTextHud.java
+++ b/src/main/java/cc/polyfrost/oneconfig/hud/SingleTextHud.java
@@ -53,7 +53,6 @@ public abstract class SingleTextHud extends TextHud {
@Override
protected void getLines(List<String> lines) {
- lines.clear();
lines.add(getCompleteText(getText()));
}
@@ -67,7 +66,6 @@ public abstract class SingleTextHud extends TextHud {
@Override
protected void getExampleLines(List<String> lines) {
- lines.clear();
lines.add(getCompleteText(getExampleText()));
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java b/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java
index 4a1a765..ab00139 100644
--- a/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java
+++ b/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java
@@ -42,7 +42,7 @@ public abstract class TextHud extends Hud {
/**
* This function is called every tick
*
- * @param lines The current lines of the hud
+ * @param lines Empty ArrayList to add your hud text too
*/
protected abstract void getLines(List<String> lines);
@@ -58,7 +58,7 @@ public abstract class TextHud extends Hud {
/**
* This function is called every tick in the move GUI
*
- * @param lines The current lines of the hud
+ * @param lines Empty ArrayList to add your hud text too
*/
protected void getExampleLines(List<String> lines) {
getLines(lines);
@@ -103,6 +103,7 @@ public abstract class TextHud extends Hud {
@Subscribe
private void onTick(TickEvent event) {
if (event.stage != Stage.START) return;
+ lines.clear();
if (!HudCore.editing) getLines(lines);
else getExampleLines(lines);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/images/Image.java b/src/main/java/cc/polyfrost/oneconfig/images/Image.java
index caae084..5e695e5 100644
--- a/src/main/java/cc/polyfrost/oneconfig/images/Image.java
+++ b/src/main/java/cc/polyfrost/oneconfig/images/Image.java
@@ -24,7 +24,6 @@ public class Image {
private Graphics2D graphics = null;
private final int width, height;
-
/**
* Create a new Image from the file. This can be as a resource location inside your JAR.
* @param filePath The path to the image file.
@@ -184,9 +183,6 @@ public class Image {
dispose();
}
-
-
-
// MASK METHODS
public void setBrightness(float brightness) {
maskColor(new Color(0f,0f,0f,brightness));
@@ -206,11 +202,6 @@ public class Image {
dispose();
}
-
-
-
-
-
// LINE METHODS
public void drawLine(Stroke stroke, int sx, int sy, int ex, int ey) {
Graphics2D g2d = getG2D();
@@ -223,10 +214,6 @@ public class Image {
drawLine(new BasicStroke(width), sx, sy, ex, ey);
}
-
-
-
-
// SHAPE METHODS
public void drawTexturedRect(TexturePaint paint, int x, int y, int width, int height) {
Graphics2D g2d = getG2D();
@@ -335,9 +322,4 @@ public class Image {
public void flipVertical() {
scale(1, -1);
}
-
-
-
-
-
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java
index c91b4e9..2a69cc5 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java
@@ -49,9 +49,6 @@ public class OneConfig {
isObfuscated = false;
} catch (Exception ignored) {
}
- if (!net.minecraft.launchwrapper.Launch.blackboard.containsKey("oneconfig.initialized")) {
- throw new RuntimeException("OneConfig has not been initialized! Please add the OneConfig tweaker or call OneConfigInit via an ITweaker or a FMLLoadingPlugin!");
- }
oneConfigDir.mkdirs();
new File(oneConfigDir, "profiles").mkdirs();
config = new OneConfigConfig();
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/init/OneConfigInit.java b/src/main/java/cc/polyfrost/oneconfig/internal/init/OneConfigInit.java
index 3d924ac..86fdb1f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/init/OneConfigInit.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/init/OneConfigInit.java
@@ -8,8 +8,6 @@ import org.spongepowered.asm.mixin.Mixins;
public class OneConfigInit {
public static void initialize(String[] args) {
- Launch.blackboard.put("oneconfig.initialized", true);
- MixinBootstrap.init();
Mixins.addConfiguration("mixins.oneconfig.json");
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/OneConfigTweaker.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/OneConfigTweaker.java
index 8b822de..d302b9d 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/OneConfigTweaker.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/OneConfigTweaker.java
@@ -71,6 +71,7 @@ public class OneConfigTweaker implements ITweaker {
@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
+ MixinBootstrap.init();
boolean captureNext = false;
for (String arg : args) {
if (captureNext) {