aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-05-28 23:11:16 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-05-28 23:11:16 +0700
commita112193704fce1dc704aa58a51fdf30f55f32a9c (patch)
tree0676f9f084e0be4861e8a5d27857d450dd772c81
parent4df2a5f6c815b0dd8cc8b68aaf164a40e63fa57d (diff)
downloadOneConfig-a112193704fce1dc704aa58a51fdf30f55f32a9c.tar.gz
OneConfig-a112193704fce1dc704aa58a51fdf30f55f32a9c.tar.bz2
OneConfig-a112193704fce1dc704aa58a51fdf30f55f32a9c.zip
migrate OneConfigCommand to new command util
make classes that end with `_Test` be excluded from non-sourcejar jars javadoc some more stuff
-rw-r--r--build.gradle.kts5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/OneConfig.java18
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java69
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/init/OneConfigInit.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/TestCommand_Test.java (renamed from src/main/java/cc/polyfrost/oneconfig/test/TestCommand.java)2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java (renamed from src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui.java)2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/package-info.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Command.java2
8 files changed, 50 insertions, 58 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index 27245ec..4cb1101 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -213,6 +213,10 @@ tasks {
exclude("mcmod.info")
}
}
+ if (!name.contains("sourcesjar", ignoreCase = true) || !name.contains("dokka", ignoreCase = true)) {
+ exclude("**/**_Test.**")
+ exclude("**/**_Test$**.**")
+ }
}
named<ShadowJar>("shadowJar") {
archiveClassifier.set("dev")
@@ -246,6 +250,7 @@ tasks {
dokkaSourceSets {
configureEach {
jdkVersion.set(8)
+ //reportUndocumented.set(true)
}
}
doLast {
diff --git a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
index c1301d3..6f579a3 100644
--- a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
@@ -11,12 +11,10 @@ import cc.polyfrost.oneconfig.lwjgl.BlurHandler;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
-import cc.polyfrost.oneconfig.test.TestCommand;
import cc.polyfrost.oneconfig.test.TestConfig;
import cc.polyfrost.oneconfig.utils.commands.CommandManager;
import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils;
import net.minecraft.launchwrapper.Launch;
-import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
@@ -27,24 +25,23 @@ import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
+/**
+ * The main class of OneConfig.
+ */
@net.minecraftforge.fml.common.Mod(modid = "@ID@", name = "@NAME@", version = "@VER@")
public class OneConfig {
- public static File jarFile;
- public static File oneConfigDir = new File("./OneConfig");
- public static File themesDir = new File(oneConfigDir, "themes");
+ public static final File oneConfigDir = new File("./OneConfig");
public static OneConfigConfig config;
public static TestConfig testConfig;
- public static List<Mod> loadedMods = new ArrayList<>();
- public static List<ModMetadata> loadedOtherMods = new ArrayList<>();
+ public static final List<Mod> loadedMods = new ArrayList<>();
+ public static final List<ModMetadata> loadedOtherMods = new ArrayList<>();
@net.minecraftforge.fml.common.Mod.EventHandler
public void onPreFMLInit(net.minecraftforge.fml.common.event.FMLPreInitializationEvent event) {
if (!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!");
}
- jarFile = event.getSourceFile();
oneConfigDir.mkdirs();
- themesDir.mkdirs();
config = new OneConfigConfig();
}
@@ -52,8 +49,7 @@ public class OneConfig {
public void onFMLInitialization(net.minecraftforge.fml.common.event.FMLInitializationEvent event) {
BlurHandler.INSTANCE.load();
testConfig = new TestConfig();
- CommandManager.registerCommand(new TestCommand());
- ClientCommandHandler.instance.registerCommand(new OneConfigCommand());
+ CommandManager.registerCommand(new OneConfigCommand());
EventManager.INSTANCE.register(new HudCore());
EventManager.INSTANCE.register(HypixelUtils.INSTANCE);
RenderManager.setupAndDraw((vg) -> {
diff --git a/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java b/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java
index 0743b54..ab2c403 100644
--- a/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java
+++ b/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java
@@ -2,54 +2,35 @@ package cc.polyfrost.oneconfig.command;
import cc.polyfrost.oneconfig.gui.HudGui;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
-import cc.polyfrost.oneconfig.test.TestNanoVGGui;
import cc.polyfrost.oneconfig.utils.GuiUtils;
-import net.minecraft.command.CommandBase;
-import net.minecraft.command.ICommandSender;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class OneConfigCommand extends CommandBase {
-
- @Override
- public String getCommandName() {
- return "oneconfig";
- }
-
- @Override
- public String getCommandUsage(ICommandSender sender) {
- return "oneconfig <>";
- }
-
- @Override
- public List<String> getCommandAliases() {
- return new ArrayList<String>() {{
- add("oneconfig");
- add("ocfg");
- }};
+import cc.polyfrost.oneconfig.utils.commands.annotations.Command;
+import cc.polyfrost.oneconfig.utils.commands.annotations.Main;
+import cc.polyfrost.oneconfig.utils.commands.annotations.SubCommand;
+
+/**
+ * The main OneConfig command.
+ */
+@Command(value = "oneconfig", aliases = {"ocfg", "oneconfig"}, description = "Access the OneConfig GUI.")
+public class OneConfigCommand {
+
+ @Main
+ private static void main() {
+ GuiUtils.displayScreen(OneConfigGui.create());
}
- @Override
- public void processCommand(ICommandSender sender, String[] args) {
- if (args.length == 0) GuiUtils.displayScreen(OneConfigGui.create());
- else {
- switch (args[0]) {
- case "hud":
- GuiUtils.displayScreen(new HudGui());
- break;
- case "lwjgl":
- GuiUtils.displayScreen(new TestNanoVGGui());
- break;
- case "destroy":
- OneConfigGui.instanceToRestore = null;
- break;
- }
+ @SubCommand(value = "hud", description = "Open the OneConfig HUD config.")
+ private static class HUDSubCommand {
+ @Main
+ private static void main() {
+ GuiUtils.displayScreen(new HudGui());
}
}
- @Override
- public int getRequiredPermissionLevel() {
- return -1;
+ @SubCommand(value = "destory", description = "Destroy the cached OneConfig GUI.")
+ private static class DestroySubCommand {
+ @Main
+ private static void main() {
+ OneConfigGui.instanceToRestore = null;
+ }
}
-}
+} \ No newline at end of file
diff --git a/src/main/java/cc/polyfrost/oneconfig/init/OneConfigInit.java b/src/main/java/cc/polyfrost/oneconfig/init/OneConfigInit.java
index 33b13d5..6e0bab3 100644
--- a/src/main/java/cc/polyfrost/oneconfig/init/OneConfigInit.java
+++ b/src/main/java/cc/polyfrost/oneconfig/init/OneConfigInit.java
@@ -10,6 +10,11 @@ import org.spongepowered.asm.mixin.Mixins;
*/
@SuppressWarnings("unused")
public class OneConfigInit {
+
+ /**
+ * Initializes the OneConfig mod.
+ * @param args The arguments passed to the mod.
+ */
public static void initialize(String[] args) {
Launch.blackboard.put("oneconfig.initialized", true);
MixinBootstrap.init();
diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestCommand.java b/src/main/java/cc/polyfrost/oneconfig/test/TestCommand_Test.java
index 753c353..d8c37f0 100644
--- a/src/main/java/cc/polyfrost/oneconfig/test/TestCommand.java
+++ b/src/main/java/cc/polyfrost/oneconfig/test/TestCommand_Test.java
@@ -7,7 +7,7 @@ import cc.polyfrost.oneconfig.utils.commands.annotations.Name;
import cc.polyfrost.oneconfig.utils.commands.annotations.SubCommand;
@Command(value = "test", aliases = {"t"})
-public class TestCommand {
+public class TestCommand_Test {
@Main
private static void main() { // /test
diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui.java b/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java
index b309429..614d138 100644
--- a/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
import java.awt.*;
-public class TestNanoVGGui extends UScreen {
+public class TestNanoVGGui_Test extends UScreen {
@Override
public void onDrawScreen(@NotNull UMatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/test/package-info.java b/src/main/java/cc/polyfrost/oneconfig/test/package-info.java
new file mode 100644
index 0000000..ef38b37
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/test/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * Test package for the OneConfig library.
+ * Classes in this package that end with {@code _Test} are excluded from actual builds.
+ */
+package cc.polyfrost.oneconfig.test; \ No newline at end of file
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Command.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Command.java
index 7717d46..b1a4ce5 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Command.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Command.java
@@ -80,7 +80,7 @@ import java.lang.annotation.Target;
* Note: if you're viewing this in IntelliJ or just see the @literal tag everywhere, please ignore that.
* </p>
*
- * @see cc.polyfrost.oneconfig.test.TestCommand
+ * @see cc.polyfrost.oneconfig.command.OneConfigCommand
* @see Main
* @see CommandManager
*/