aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/internal/command
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-08-10 10:15:01 +0200
committerGitHub <noreply@github.com>2022-08-10 17:15:01 +0900
commit091ce4c72c123f43f317c097818ace15f3a085fa (patch)
tree9a151e29494ef2683b2bff59fec19b56d4a05fb0 /src/main/java/cc/polyfrost/oneconfig/internal/command
parent799c389fdb993e363d71d268e0df9ae9f0a0c8a1 (diff)
downloadOneConfig-091ce4c72c123f43f317c097818ace15f3a085fa.tar.gz
OneConfig-091ce4c72c123f43f317c097818ace15f3a085fa.tar.bz2
OneConfig-091ce4c72c123f43f317c097818ace15f3a085fa.zip
Profile command (#88)
* e * omg finish profile shit * api and fix 1.12.2 preprocess * fix class names
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/internal/command')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/command/OneConfigCommand.java82
1 files changed, 78 insertions, 4 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/command/OneConfigCommand.java b/src/main/java/cc/polyfrost/oneconfig/internal/command/OneConfigCommand.java
index c93831b..3c1aebb 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/command/OneConfigCommand.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/command/OneConfigCommand.java
@@ -26,13 +26,15 @@
package cc.polyfrost.oneconfig.internal.command;
+import cc.polyfrost.oneconfig.internal.config.OneConfigConfig;
+import cc.polyfrost.oneconfig.internal.config.profiles.Profiles;
import cc.polyfrost.oneconfig.internal.gui.HudGui;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
+import cc.polyfrost.oneconfig.libs.universal.ChatColor;
+import cc.polyfrost.oneconfig.libs.universal.UChat;
+import cc.polyfrost.oneconfig.utils.commands.annotations.*;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
import cc.polyfrost.oneconfig.utils.InputUtils;
-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.
@@ -57,8 +59,80 @@ public class OneConfigCommand {
private static class DestroySubCommand {
@Main
private static void main() {
- OneConfigGui.instanceToRestore = null;
+ OneConfigGui.INSTANCE = null;
InputUtils.stopBlockingInput();
}
}
+
+ @SubCommand(value = "profile", description = "Actions related to profiles.", aliases = {"profiles"})
+ private static class ProfileSubCommand {
+ @SubCommand(value = "list", description = "View all profiles", aliases = {"view"})
+ private static class List {
+ @Main
+ private static void main() {
+ StringBuilder builder = new StringBuilder()
+ .append(ChatColor.GOLD).append("Available profiles:");
+ for (String profile : Profiles.getProfiles()) {
+ builder.append("\n");
+ if (OneConfigConfig.currentProfile.equals(profile)) builder.append(ChatColor.GREEN);
+ else builder.append(ChatColor.RED);
+ builder.append(profile);
+ }
+ UChat.chat(builder.toString());
+ }
+ }
+
+ @SubCommand(value = "switch", description = "Switch to a profile", aliases = {"enable", "set", "load"})
+ private static class SwitchProfile {
+ @Main
+ private static void main(@Name("profile") @Greedy String profile) {
+ if (!Profiles.doesProfileExist(profile)) {
+ UChat.chat(ChatColor.RED + "The profile \"" + profile + "\" does not exist!");
+ } else {
+ Profiles.loadProfile(profile);
+ UChat.chat(ChatColor.GREEN + "Switched to the \"" + profile + "\" profile.");
+ }
+ }
+ }
+
+ @SubCommand(value = "create", description = "Create a new profile", aliases = {"make"})
+ private static class Create {
+ @Main
+ private static void main(@Name("profile") @Greedy String profile) {
+ if (Profiles.doesProfileExist(profile)) {
+ UChat.chat(ChatColor.RED + "The profile \"" + profile + "\" already exists!");
+ } else {
+ Profiles.createProfile(profile);
+ if (Profiles.doesProfileExist(profile)) Profiles.loadProfile(profile);
+ UChat.chat(ChatColor.GREEN + "Created the \"" + profile + "\" profile.");
+ }
+ }
+ }
+
+ @SubCommand(value = "rename", description = "Rename a profile")
+ private static class Rename {
+ @Main
+ private static void main(@Name("Old Name") String profile, @Name("New Name") @Greedy String newName) {
+ if (!Profiles.doesProfileExist(profile)) {
+ UChat.chat(ChatColor.RED + "The profile \"" + profile + "\" does not exist!");
+ } else {
+ Profiles.renameProfile(profile, newName);
+ UChat.chat(ChatColor.GREEN + "Renamed the \"" + profile + "\" profile to \" " + newName + "\".");
+ }
+ }
+ }
+
+ @SubCommand(value = "delete", description = "Delete a profile", aliases = {"remove", "destroy"})
+ private static class Delete {
+ @Main
+ private static void main(@Name("profile") @Greedy String profile) {
+ if (!Profiles.doesProfileExist(profile)) {
+ UChat.chat(ChatColor.RED + "The profile \"" + profile + "\" does not exist!");
+ } else {
+ Profiles.deleteProfile(profile);
+ UChat.chat(ChatColor.GREEN + "Deleted the \"" + profile + "\" profile.");
+ }
+ }
+ }
+ }
} \ No newline at end of file