From 087f5404658a1543834f16a89e3436f8399297f6 Mon Sep 17 00:00:00 2001 From: nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> Date: Sun, 5 Jun 2022 10:36:43 +0100 Subject: Reformat code and OC-38 --- .../java/cc/polyfrost/oneconfig/utils/GuiUtils.java | 9 ++++++--- .../cc/polyfrost/oneconfig/utils/InputUtils.java | 15 ++++++++------- .../java/cc/polyfrost/oneconfig/utils/JsonUtils.java | 2 +- .../cc/polyfrost/oneconfig/utils/Multithreading.java | 4 ++-- .../cc/polyfrost/oneconfig/utils/NetworkUtils.java | 20 ++++++++++++-------- .../java/cc/polyfrost/oneconfig/utils/TextUtils.java | 14 ++++++++------ .../polyfrost/oneconfig/utils/color/ColorUtils.java | 2 +- .../oneconfig/utils/commands/CommandManager.java | 1 - .../utils/commands/annotations/Command.java | 2 +- .../oneconfig/utils/commands/annotations/Main.java | 1 + .../oneconfig/utils/commands/annotations/Name.java | 1 + .../utils/commands/annotations/SubCommand.java | 3 +++ .../utils/commands/arguments/ArgumentParser.java | 4 +++- .../oneconfig/utils/hypixel/HypixelUtils.java | 3 +++ 14 files changed, 50 insertions(+), 31 deletions(-) (limited to 'src/main/java/cc/polyfrost/oneconfig/utils') diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/GuiUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/GuiUtils.java index c6afb00..fa2a6ea 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/GuiUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/GuiUtils.java @@ -15,6 +15,7 @@ public final class GuiUtils { static { EventManager.INSTANCE.register(new GuiUtils()); } + private static long time = -1L; private static long deltaTime = 17L; @@ -27,7 +28,9 @@ public final class GuiUtils { new TickDelay(() -> UScreen.displayScreen(screen), 1); } - /** Close the current open GUI screen. */ + /** + * Close the current open GUI screen. + */ public static void closeScreen() { UScreen.displayScreen(null); } @@ -35,8 +38,8 @@ public final class GuiUtils { /** * Gets the delta time (in milliseconds) between frames. *

- * Not to be confused with Minecraft deltaTicks / renderPartialTicks, which can be gotten via - * {@link cc.polyfrost.oneconfig.events.event.TimerUpdateEvent} + * Not to be confused with Minecraft deltaTicks / renderPartialTicks, which can be gotten via + * {@link cc.polyfrost.oneconfig.events.event.TimerUpdateEvent} *

* * @return the delta time. diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java index 0ba4c00..0f50a33 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java @@ -28,10 +28,10 @@ public final class InputUtils { /** * Checks whether the mouse is currently over a specific region and clicked. * - * @param x the x position of the region - * @param y the y position of the region - * @param width the width of the region - * @param height the height of the region + * @param x the x position of the region + * @param y the y position of the region + * @param width the width of the region + * @param height the height of the region * @param ignoreBlock if true, will ignore {@link InputUtils#blockClicks(boolean)} * @return true if the mouse is clicked and is over the region, false if not * @see InputUtils#isAreaHovered(int, int, int, int) @@ -43,9 +43,9 @@ public final class InputUtils { /** * Checks whether the mouse is currently over a specific region and clicked. * - * @param x the x position of the region - * @param y the y position of the region - * @param width the width of the region + * @param x the x position of the region + * @param y the y position of the region + * @param width the width of the region * @param height the height of the region * @return true if the mouse is clicked and is over the region, false if not * @see InputUtils#isAreaClicked(int, int, int, int, boolean) @@ -111,6 +111,7 @@ public final class InputUtils { /** * Whether clicks are blocked + * * @return true if clicks are blocked, false if not */ public static boolean isBlockingClicks() { diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/JsonUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/JsonUtils.java index 67881e9..320b630 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/JsonUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/JsonUtils.java @@ -16,7 +16,7 @@ public final class JsonUtils { /** * Parses a string into a {@link JsonElement}. * - * @param string The string to parse. + * @param string The string to parse. * @param catchExceptions Whether to catch exceptions. * @return The {@link JsonElement}. * @see JsonParser#parse(String) diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/Multithreading.java b/src/main/java/cc/polyfrost/oneconfig/utils/Multithreading.java index 518d699..745ded8 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/Multithreading.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/Multithreading.java @@ -52,7 +52,7 @@ public class Multithreading { * Schedules the runnable to run asynchronously after the specified delay. * * @param runnable The runnable to run. - * @param delay The delay before the runnable is run. + * @param delay The delay before the runnable is run. * @param timeUnit The {@link TimeUnit} of the delay. * @see Multithreading#submitScheduled(Runnable, long, TimeUnit) */ @@ -64,7 +64,7 @@ public class Multithreading { * Submits the Runnable to the executor after a delay, making it run asynchronously. * * @param runnable The runnable to run. - * @param delay The delay before the runnable is run. + * @param delay The delay before the runnable is run. * @param timeUnit The {@link TimeUnit} of the delay. * @return The future representing the submitted runnable. * @see ScheduledExecutorService#schedule(Runnable, long, TimeUnit) diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java index 767f36f..aea7812 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/NetworkUtils.java @@ -18,9 +18,10 @@ public final class NetworkUtils { /** * Gets the contents of a URL as a String. - * @param url The URL to read. + * + * @param url The URL to read. * @param userAgent The user agent to use. - * @param timeout The timeout in milliseconds. + * @param timeout The timeout in milliseconds. * @param useCaches Whether to use caches. * @return The contents of the URL. */ @@ -47,9 +48,9 @@ public final class NetworkUtils { /** * Gets the contents of a URL as a JsonElement. * - * @param url The URL to read. + * @param url The URL to read. * @param userAgent The user agent to use. - * @param timeout The timeout in milliseconds. + * @param timeout The timeout in milliseconds. * @param useCaches Whether to use caches. * @return The contents of the URL. * @see NetworkUtils#getString(String, String, int, boolean) @@ -72,10 +73,11 @@ public final class NetworkUtils { /** * Downloads a file from a URL. - * @param url The URL to download from. - * @param file The file to download to. + * + * @param url The URL to download from. + * @param file The file to download to. * @param userAgent The user agent to use. - * @param timeout The timeout in milliseconds. + * @param timeout The timeout in milliseconds. * @param useCaches Whether to use caches. * @return Whether the download was successful. */ @@ -92,7 +94,8 @@ public final class NetworkUtils { /** * Downloads a file from a URL. - * @param url The URL to download from. + * + * @param url The URL to download from. * @param file The file to download to. * @return Whether the download was successful. * @see NetworkUtils#downloadFile(String, File, String, int, boolean) @@ -103,6 +106,7 @@ public final class NetworkUtils { /** * Gets the SHA-256 hash of a file. + * * @param file The file to hash. * @return The SHA-256 hash of the file. */ diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java index 4fa5125..df37aae 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java @@ -13,11 +13,12 @@ public final class TextUtils { /** * Wraps a string into an array of lines. - * @param vg The NanoVG context. - * @param text The text to wrap. + * + * @param vg The NanoVG context. + * @param text The text to wrap. * @param maxWidth The maximum width of each line. * @param fontSize The font size. - * @param font The font to use. + * @param font The font to use. * @return The array of lines. */ public static ArrayList wrapText(long vg, String text, float maxWidth, float fontSize, Fonts font) { @@ -26,11 +27,12 @@ public final class TextUtils { /** * Wraps a string into an array of lines. - * @param vg The NanoVG context. - * @param text The text to wrap. + * + * @param vg The NanoVG context. + * @param text The text to wrap. * @param maxWidth The maximum width of each line. * @param fontSize The font size. - * @param font The font to use. + * @param font The font to use. * @return The array of lines. */ public static ArrayList wrapText(long vg, String text, float maxWidth, float fontSize, Font font) { diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorUtils.java index ebf0100..efadc51 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorUtils.java @@ -54,7 +54,7 @@ public final class ColorUtils { * @return the RGB color. */ public static int getColor(float red, float green, float blue, float alpha) { - return getColor((int) red * 255, (int) green * 255, (int) blue * 255, (int) alpha * 255); + return getColor((int) (red * 255f), (int) (green * 255f), (int) (blue * 255f), (int) (alpha * 255f)); } /** diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java index 913ee73..4a008d3 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandManager.java @@ -6,7 +6,6 @@ import cc.polyfrost.oneconfig.utils.commands.annotations.*; import cc.polyfrost.oneconfig.utils.commands.arguments.*; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; -import net.minecraft.util.BlockPos; import net.minecraftforge.client.ClientCommandHandler; import java.lang.reflect.InvocationTargetException; 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 b1a4ce5..89b5227 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 @@ -72,7 +72,7 @@ import java.lang.annotation.Target; * } * } *

- * + *

* To register commands, either extend {@link CommandHelper} and run {@link CommandHelper#preload()} (which does nothing, * just makes loading look nicer lol), or use {@link CommandManager#registerCommand(Object)}. * diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Main.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Main.java index 3c105c7..9b49fb4 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Main.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Main.java @@ -16,5 +16,6 @@ import java.lang.annotation.Target; @Target({ElementType.METHOD}) public @interface Main { String description() default ""; + int priority() default 1000; } diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Name.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Name.java index ef178a0..f802697 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Name.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/Name.java @@ -16,6 +16,7 @@ import java.lang.annotation.Target; public @interface Name { /** * The name of the parameter. + * * @return The name of the parameter. */ String value(); diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/SubCommand.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/SubCommand.java index b1cf035..1bfbd53 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/SubCommand.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/commands/annotations/SubCommand.java @@ -16,18 +16,21 @@ import java.lang.annotation.Target; public @interface SubCommand { /** * The name of the command. + * * @return The name of the command. */ String value(); /** * The aliases of the command. + * * @return The aliases of the command. */ String[] aliases() default {}; /** * The description of the command. + * * @return The description of the command. */ String description() default ""; diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/arguments/ArgumentParser.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/arguments/ArgumentParser.java index d9d51b0..61d1e07 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/arguments/ArgumentParser.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/commands/arguments/ArgumentParser.java @@ -5,8 +5,10 @@ import org.jetbrains.annotations.Nullable; @SuppressWarnings("unstable") public abstract class ArgumentParser { - private final TypeToken type = new TypeToken(getClass()) {}; + private final TypeToken type = new TypeToken(getClass()) { + }; public final Class typeClass = type.getRawType(); + @Nullable public abstract T parse(Arguments arguments); } diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java index d7a9b0d..c890939 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/hypixel/HypixelUtils.java @@ -133,6 +133,7 @@ public class HypixelUtils { /** * Returns whether the player is in game. + * * @return Whether the player is in game. */ public boolean isInGame() { @@ -141,6 +142,7 @@ public class HypixelUtils { /** * Returns the current {@link LocrawInfo}. + * * @return The current {@link LocrawInfo}. * @see LocrawInfo */ @@ -150,6 +152,7 @@ public class HypixelUtils { /** * Returns the previous {@link LocrawInfo}. + * * @return The previous {@link LocrawInfo}. * @see LocrawInfo */ -- cgit