From ac92f8e7ed7e4d9636660410cdf898a6da3f5aab Mon Sep 17 00:00:00 2001 From: iiAhmedYT <61851106+iiAhmedYT@users.noreply.github.com> Date: Wed, 15 May 2024 13:13:59 +0300 Subject: [PATCH] Remove ASCII and fix bugs --- .../to/itsme/itsmyconfig/ItsMyConfig.java | 6 ++---- .../component/event/HoverEvent.java | 4 +++- .../to/itsme/itsmyconfig/util/Utilities.java | 21 +++++-------------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/main/java/to/itsme/itsmyconfig/ItsMyConfig.java b/src/main/java/to/itsme/itsmyconfig/ItsMyConfig.java index e575a64..9cd6755 100644 --- a/src/main/java/to/itsme/itsmyconfig/ItsMyConfig.java +++ b/src/main/java/to/itsme/itsmyconfig/ItsMyConfig.java @@ -20,7 +20,6 @@ import to.itsme.itsmyconfig.progress.ProgressBar; import to.itsme.itsmyconfig.progress.ProgressBarBucket; import to.itsme.itsmyconfig.requirement.RequirementManager; -import to.itsme.itsmyconfig.util.Utilities; /** * ItsMyConfig class represents the main configuration class for the plugin. @@ -30,7 +29,6 @@ public final class ItsMyConfig extends JavaPlugin { private static final boolean ALLOW_ITEM_EDITS = false; - private static final String HYPHEN = "#########################################################"; private static ItsMyConfig instance; private final PlaceholderManager placeholderManager = new PlaceholderManager(); @@ -46,7 +44,7 @@ public static ItsMyConfig getInstance() { @Override public void onEnable() { - this.getLogger().info("\n\n" + HYPHEN + "\n" + Utilities.getACSIIArt() + "\nLoading ItsMyConfig..."); + this.getLogger().info("Loading ItsMyConfig..."); final long start = System.currentTimeMillis(); instance = this; new DynamicPlaceHolder(this, progressBarBucket).register(); @@ -66,7 +64,7 @@ public void onEnable() { protocolManager.addPacketListener(new PacketItemListener(this)); } - this.getLogger().info("ItsMyConfig loaded in " + (System.currentTimeMillis() - start) + "ms\n" + HYPHEN + "\n\n"); + this.getLogger().info("ItsMyConfig loaded in " + (System.currentTimeMillis() - start) + "ms"); } /** diff --git a/src/main/java/to/itsme/itsmyconfig/component/event/HoverEvent.java b/src/main/java/to/itsme/itsmyconfig/component/event/HoverEvent.java index dc8a8b5..8dca7f3 100644 --- a/src/main/java/to/itsme/itsmyconfig/component/event/HoverEvent.java +++ b/src/main/java/to/itsme/itsmyconfig/component/event/HoverEvent.java @@ -132,7 +132,9 @@ public HoverEvent deserialize( default: if (element.isJsonPrimitive()) { event.value = new TextfulComponent(element.getAsString()); - } else if (element.isJsonArray() || element.isJsonObject()) { + } else if (element.isJsonArray()) { + event.value = context.deserialize(element.getAsJsonArray().get(0), TextfulComponent.class); + } else if (element.isJsonObject()) { event.value = context.deserialize(element, TextfulComponent.class); } return event; diff --git a/src/main/java/to/itsme/itsmyconfig/util/Utilities.java b/src/main/java/to/itsme/itsmyconfig/util/Utilities.java index a7ddca4..b129fe3 100644 --- a/src/main/java/to/itsme/itsmyconfig/util/Utilities.java +++ b/src/main/java/to/itsme/itsmyconfig/util/Utilities.java @@ -239,11 +239,16 @@ private static Component fixClickEvent(final Component component) { * @return A List of Integer containing the extracted integer arguments. */ public static List getArguments(final String string) { + if (string == null || string.isEmpty()) { + return Collections.emptyList(); + } + final List args = new ArrayList<>(); final Matcher matcher = ARGUMENT_PATTERN.matcher(string); while (matcher.find()) { args.add(Integer.parseInt(matcher.group(1))); } + return args; } @@ -529,22 +534,6 @@ public static String toString(final @NotNull List list) { return String.join(System.lineSeparator(), list.stream().map(Object::toString).toArray(String[]::new)); } - /** - * Retrieves ASCII art representing the text "ItsMyConfig". - * This method returns ASCII art as a string representing the text "ItsMyConfig" in a stylized format. - * - * @return a string containing ASCII art representing the text "ItsMyConfig". - */ - public static String getACSIIArt() { - return " ___ _ __ __ ____ __ _ \n" + - " |_ _| |_ ___| \\/ |_ _ / ___|___ _ __ / _(_) __ _ \n" + - " | || __/ __| |\\/| | | | | | / _ \\| '_ \\| |_| |/ _` |\n" + - " | || |_\\__ \\ | | | |_| | |__| (_) | | | | _| | (_| |\n" + - " |___|\\__|___/_| |_|\\__, |\\____\\___/|_| |_|_| |_|\\__, |\n" + - " |___/ |___/ \n" + - "\n"; - } - /** * Helper method to create Title times with optional values. *