aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/config')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/VigilanceName.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilantAccessor.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/core/OneColor.java74
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/data/OptionCategory.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/data/OptionType.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java2
8 files changed, 65 insertions, 36 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/VigilanceName.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/VigilanceName.java
index 03e94af..e4b042a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/VigilanceName.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/VigilanceName.java
@@ -9,6 +9,8 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
public @interface VigilanceName {
String name();
+
String category();
+
String subcategory();
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java
index f31b609..0fbfa62 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java
@@ -20,6 +20,10 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Objects;
+/**
+ * This class is used to convert the Vigilance config to the new config system.
+ * It is not meant to be used outside the config system.
+ */
public class VigilanceConfig extends Config {
public final Vigilant vigilant;
@@ -133,7 +137,7 @@ public class VigilanceConfig extends Config {
PropertyAttributesExt.class.getDeclaredField("i18nName").setAccessible(true);
return I18n.format((String) PropertyAttributesExt.class.getDeclaredField("i18nName").get(ext));
} catch (IllegalAccessException | NoSuchFieldException e) {
- return ext.getName();
+ return ext.getName();
}
}
@@ -151,7 +155,7 @@ public class VigilanceConfig extends Config {
PropertyAttributesExt.class.getDeclaredField("i18nSubcategory").setAccessible(true);
return I18n.format((String) PropertyAttributesExt.class.getDeclaredField("i18nSubcategory").get(ext));
} catch (IllegalAccessException | NoSuchFieldException e) {
- return ext.getSubcategory();
+ return ext.getSubcategory();
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilantAccessor.java b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilantAccessor.java
index 4c79a21..ca2b1da 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilantAccessor.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilantAccessor.java
@@ -2,6 +2,10 @@ package cc.polyfrost.oneconfig.config.compatibility;
import gg.essential.vigilance.data.PropertyCollector;
+/**
+ * Interface for accessing the {@link PropertyCollector} in a Vigilant config.
+ * <p>Not recommended for non-internal OneConfig usage, as Systemless will get really angry at us</p>
+ */
public interface VigilantAccessor {
PropertyCollector getPropertyCollector();
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/core/OneColor.java b/src/main/java/cc/polyfrost/oneconfig/config/core/OneColor.java
index 3f6289e..8135ac0 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/core/OneColor.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/core/OneColor.java
@@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
import java.awt.*;
/**
- * OneColor is a class for storing Colors in HSBA format. This format is used to allow the color selectors to work correctly.
+ * OneColor is a class for storing colors in HSBA format. This format is used to allow the color selectors to work correctly.
* <p>
* <code>
* short[0] = hue (0-360)
@@ -71,11 +71,14 @@ public final class OneColor {
}
// chroma constructors
- /** Create a new Chroma OneColor. The speed should be a max of 30s and a min of 1s. */
+
+ /**
+ * Create a new Chroma OneColor. The speed should be a max of 30s and a min of 1s.
+ */
public OneColor(int saturation, int brightness, int alpha, float chromaSpeed) {
this(System.currentTimeMillis() % (int) chromaSpeed / chromaSpeed, saturation, brightness, alpha);
- if(chromaSpeed < 1) chromaSpeed = 1;
- if(chromaSpeed > 30) chromaSpeed = 30;
+ if (chromaSpeed < 1) chromaSpeed = 1;
+ if (chromaSpeed > 30) chromaSpeed = 30;
this.dataBit = (int) chromaSpeed;
}
@@ -92,58 +95,79 @@ public final class OneColor {
// accessors
- /** Get the red value of the color (0-255). */
+
+ /**
+ * Get the red value of the color (0-255).
+ */
public int getRed() {
return rgba >> 16 & 255;
}
- /** Get the green value of the color (0-255). */
+ /**
+ * Get the green value of the color (0-255).
+ */
public int getGreen() {
return rgba >> 8 & 255;
}
- /** Get the blue value of the color (0-255). */
+ /**
+ * Get the blue value of the color (0-255).
+ */
public int getBlue() {
return rgba & 255;
}
- /** Get the hue value of the color (0-360). */
+ /**
+ * Get the hue value of the color (0-360).
+ */
public int getHue() {
return hsba[0];
}
- /** Get the saturation value of the color (0-100). */
+ /**
+ * Get the saturation value of the color (0-100).
+ */
public int getSaturation() {
return hsba[1];
}
- /** Get the brightness value of the color (0-100). */
+ /**
+ * Get the brightness value of the color (0-100).
+ */
public int getBrightness() {
return hsba[2];
}
- /** Get the alpha value of the color (0-255). */
+ /**
+ * Get the alpha value of the color (0-255).
+ */
public int getAlpha() {
return hsba[3];
}
- /** Get the chroma speed of the color (1s-30s). */
+ /**
+ * Get the chroma speed of the color (1s-30s).
+ */
public int getDataBit() {
return dataBit == -1 ? -1 : dataBit / 1000;
}
- /** Set the current chroma speed of the color. -1 to disable. */
+ /**
+ * Set the current chroma speed of the color. -1 to disable.
+ */
public void setChromaSpeed(int speed) {
- if(speed == -1) {
+ if (speed == -1) {
this.dataBit = -1;
return;
}
- if(speed < 1) speed = 1;
- if(speed > 30) speed = 30;
+ if (speed < 1) speed = 1;
+ if (speed > 30) speed = 30;
this.dataBit = speed * 1000;
}
- /** Set the HSBA values of the color. */
+ /**
+ * Set the HSBA values of the color.
+ */
public void setHSBA(int hue, int saturation, int brightness, int alpha) {
this.hsba[0] = (short) hue;
this.hsba[1] = (short) saturation;
@@ -217,16 +241,16 @@ public final class OneColor {
public void setColorFromHex(String hex) {
hex = hex.replace("#", "");
- if(hex.length() > 6) {
+ if (hex.length() > 6) {
hex = hex.substring(0, 6);
}
- if(hex.length() == 3) {
+ if (hex.length() == 3) {
hex = charsToString(hex.charAt(0), hex.charAt(0), hex.charAt(1), hex.charAt(1), hex.charAt(2), hex.charAt(2));
}
- if(hex.length() == 1) {
+ if (hex.length() == 1) {
hex = charsToString(hex.charAt(0), hex.charAt(0), hex.charAt(0), hex.charAt(0), hex.charAt(0), hex.charAt(0));
}
- if(hex.length() == 2 && hex.charAt(1) == hex.charAt(0)) {
+ if (hex.length() == 2 && hex.charAt(1) == hex.charAt(0)) {
hex = charsToString(hex.charAt(0), hex.charAt(0), hex.charAt(0), hex.charAt(0), hex.charAt(0), hex.charAt(0));
}
StringBuilder hexBuilder = new StringBuilder(hex);
@@ -235,9 +259,9 @@ public final class OneColor {
}
hex = hexBuilder.toString();
//System.out.println(hex);
- int r = Integer.valueOf(hex.substring( 0, 2 ), 16);
- int g = Integer.valueOf( hex.substring( 2, 4 ), 16);
- int b = Integer.valueOf( hex.substring( 4, 6 ), 16);
+ int r = Integer.valueOf(hex.substring(0, 2), 16);
+ int g = Integer.valueOf(hex.substring(2, 4), 16);
+ int b = Integer.valueOf(hex.substring(4, 6), 16);
this.rgba = ((getAlpha() & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | ((b & 0xFF));
hsba = RGBAtoHSBA(rgba);
}
@@ -249,7 +273,7 @@ public final class OneColor {
private String charsToString(char... chars) {
StringBuilder sb = new StringBuilder();
- for(char c : chars) {
+ for (char c : chars) {
sb.append(c);
}
return sb.toString();
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionCategory.java b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionCategory.java
index 363cfda..76b2b34 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionCategory.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionCategory.java
@@ -1,10 +1,6 @@
package cc.polyfrost.oneconfig.config.data;
-import cc.polyfrost.oneconfig.config.interfaces.BasicOption;
-import cc.polyfrost.oneconfig.gui.elements.config.ConfigPageButton;
-
import java.util.ArrayList;
-import java.util.LinkedHashMap;
public class OptionCategory {
public final ArrayList<OptionSubcategory> subcategories = new ArrayList<>();
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionType.java b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionType.java
index 519e890..10c9a6b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionType.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionType.java
@@ -48,7 +48,7 @@ public enum OptionType {
BUTTON,
/**
* Type: OneKeyBind
- */
+ */
KEYBIND,
/**
* Type: ? extends BasicHud
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java
index a9d1d1e..f495ecd 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java
@@ -4,15 +4,14 @@ import cc.polyfrost.oneconfig.config.annotations.ConfigPage;
import cc.polyfrost.oneconfig.config.annotations.Option;
import cc.polyfrost.oneconfig.config.core.ConfigCore;
import cc.polyfrost.oneconfig.config.data.*;
-import cc.polyfrost.oneconfig.config.migration.Migrator;
import cc.polyfrost.oneconfig.config.profiles.Profiles;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.elements.config.*;
import cc.polyfrost.oneconfig.gui.pages.ModConfigPage;
import cc.polyfrost.oneconfig.hud.BasicHud;
import cc.polyfrost.oneconfig.hud.HudCore;
+import cc.polyfrost.oneconfig.utils.GuiUtils;
import com.google.gson.*;
-import cc.polyfrost.oneconfig.libs.universal.UScreen;
import java.io.*;
import java.lang.reflect.Field;
@@ -247,7 +246,7 @@ public class Config {
*/
public void openGui() {
if (mod == null) return;
- UScreen.displayScreen(new OneConfigGui(new ModConfigPage(mod.defaultPage)));
+ GuiUtils.displayScreen(new OneConfigGui(new ModConfigPage(mod.defaultPage)));
}
/**
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java b/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java
index 4eafd6d..dfc5e16 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/profiles/Profiles.java
@@ -1,7 +1,7 @@
package cc.polyfrost.oneconfig.config.profiles;
-import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.OneConfig;
+import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.config.core.ConfigCore;
import org.apache.commons.io.FileUtils;