From ab2dd02145d5f89455a74605dd953888761d0ddb Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Fri, 27 May 2022 21:31:59 +0700 Subject: javadoc a lot of stuff + reorganize --- .../config/annotations/VigilanceName.java | 2 + .../config/compatibility/VigilanceConfig.java | 8 ++- .../config/compatibility/VigilantAccessor.java | 4 ++ .../polyfrost/oneconfig/config/core/OneColor.java | 74 ++++++++++++++-------- .../oneconfig/config/data/OptionCategory.java | 4 -- .../oneconfig/config/data/OptionType.java | 2 +- .../oneconfig/config/interfaces/Config.java | 5 +- .../oneconfig/config/profiles/Profiles.java | 2 +- 8 files changed, 65 insertions(+), 36 deletions(-) (limited to 'src/main/java/cc/polyfrost/oneconfig/config') 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. + *
Not recommended for non-internal OneConfig usage, as Systemless will get really angry at us
+ */ 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. *
*
* 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