From 84220d46061c8cafdaf0a6d4b0dc3bf98daa44c8 Mon Sep 17 00:00:00 2001 From: Snabeldier <79211348+Snabeldier@users.noreply.github.com> Date: Fri, 24 Jan 2025 05:39:24 +0100 Subject: [PATCH] chore: rework message types and custom characters --- .../core/api/enums/CustomCharacter.java | 99 ++++++++++--------- .../api/messaging/types/ActionBarType.java | 30 ++++-- .../core/api/messaging/types/MessageType.java | 41 ++++++-- 3 files changed, 108 insertions(+), 62 deletions(-) diff --git a/src/main/java/minevalley/core/api/enums/CustomCharacter.java b/src/main/java/minevalley/core/api/enums/CustomCharacter.java index 4e399624..4d49943e 100644 --- a/src/main/java/minevalley/core/api/enums/CustomCharacter.java +++ b/src/main/java/minevalley/core/api/enums/CustomCharacter.java @@ -6,64 +6,67 @@ @RequiredArgsConstructor(access = AccessLevel.PRIVATE) public enum CustomCharacter { - MV('\uef00'), - MV_BW('\uef01'), - SUPPORT_QUESTION_MARK('\uef02'), - HELP_QUESTION_MARK('\uef03'), - TEAM('\uef04'), + EMOJI_HEART('\ue000'), + EMOJI_LAUGH('\ue001'), + EMOJI_SMILE('\ue002'), + EMOJI_GRIN('\ue003'), + EMOJI_WINK('\ue004'), + EMOJI_WINKING_WITH_TONGUE('\ue005'), + EMOJI_KISSES('\ue006'), + EMOJI_SHOCK('\ue007'), + EMOJI_BIG_SHOCK('\ue008'), + EMOJI_PAIN('\ue009'), + EMOJI_ANNOYED('\ue010'), + EMOJI_CRYING('\ue011'), - SUPPORT_QUESTION_MARK_TRANSPARENT('\uef05'), + RADIO('\uea00'), + SHOUT('\uea01'), + EXCLAMATION_MARK('\uea02'), + CROSS('\uea03'), + CHECKMARK('\uea04'), + LOG('\uea05'), + BUG('\uea06'), + EYE('\uea07'), + WRENCH('\uea08'), + CIRCLE('\uea09'), + HOUSE('\uea10'), + EURO_NOTES('\uea11'), + DRIFTING_CAR('\uea12'), - MEDICS('\uef06'), - COPS('\uef07'), - MAIL('\uef08'), - DISPOSAL('\uef09'), - HANDCUFFS('\uef10'), + BELL('\ueb00'), + PHONE('\ueb01'), - MEDICS_TRANSPARENT('\uef11'), - COPS_TRANSPARENT('\uef12'), - MAIL_TRANSPARENT('\uef13'), - DISPOSAL_TRANSPARENT('\uef14'), - HANDCUFFS_TRANSPARENT('\uef15'), + MV('\uec00'), + MV_BW('\uec01'), - EURO_NOTES('\uef16'), - BELL('\uef17'), - DRIFTING_CAR('\uef18'), - PHONE('\uef19'), + HELP_QUESTION_MARK('\ued00'), + TEAM('\ued01'), + MEDICS('\uee00'), + COPS('\uee01'), + MAIL('\uee02'), + DISPOSAL('\uee03'), + HANDCUFFS('\uee04'), + PREMIUM('\uee05'), + SUPPORT_QUESTION_MARK('\uee06'), - EMOJI_HEART('\uef20'), - EMOJI_LAUGH('\uef21'), - EMOJI_SMILE('\uef22'), - EMOJI_GRIN('\uef23'), - EMOJI_WINK('\uef24'), - EMOJI_WINKING_WITH_TONGUE('\uef25'), - EMOJI_KISSES('\uef26'), - EMOJI_SHOCK('\uef27'), - EMOJI_BIG_SHOCK('\uef28'), - EMOJI_PAIN('\uef29'), - EMOJI_ANNOYED('\uef30'), - EMOJI_CRYING('\uef31'), + MEDICS_TRANSPARENT('\uef00'), + COPS_TRANSPARENT('\uef01'), + MAIL_TRANSPARENT('\uef02'), + DISPOSAL_TRANSPARENT('\uef03'), + HANDCUFFS_TRANSPARENT('\uef04'), + PREMIUM_TRANSPARENT('\uef05'), + SUPPORT_QUESTION_MARK_TRANSPARENT('\uef06'), - PREMIUM('\uef32'), - - RADIO('\uef33'), - SHOUT('\uef34'), - CROSS('\uef35'), - CHECKMARK('\uef36'), - LOG('\uef37'), - BUG('\uef38'), - EYE('\uef39'), - WRENCH('\uef40'), - CIRCLE('\uef41'), - HOUSE('\uef42'), - - PREMIUM_TRANSPARENT('\uef43'), - - SINGLE_WHITE_SPACE('\uef44'); + SINGLE_WHITE_SPACE('\ueeee'); private final char c; + @SuppressWarnings("unused") + public char getChar() { + return c; + } + @Override public String toString() { return Character.toString(c); diff --git a/src/main/java/minevalley/core/api/messaging/types/ActionBarType.java b/src/main/java/minevalley/core/api/messaging/types/ActionBarType.java index c4a82d01..164ae1f3 100644 --- a/src/main/java/minevalley/core/api/messaging/types/ActionBarType.java +++ b/src/main/java/minevalley/core/api/messaging/types/ActionBarType.java @@ -3,20 +3,38 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; +import minevalley.core.api.enums.CustomCharacter; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.format.NamedTextColor; -@Getter +import javax.annotation.Nonnull; + +import static minevalley.core.api.enums.CustomCharacter.CHECKMARK; +import static minevalley.core.api.enums.CustomCharacter.CROSS; +import static net.kyori.adventure.text.format.NamedTextColor.*; + +@Getter(onMethod_ = @Nonnull) @RequiredArgsConstructor(access = AccessLevel.PRIVATE) public enum ActionBarType { /** - * Used to signal the success of a process or action, by using the action-bar. + * Used to signal the failure of a process or an action. */ - SUCCESS("§a✔§8 ━ §7"), + ERROR(CROSS, RED), /** - * Used to signal the failure of a process or action, by using the action-bar. + * Used to signal the success of a process or action. */ - ERROR("§c✘§8 ━ §7"); + SUCCESS(CHECKMARK, GREEN); + + private final @Nonnull CustomCharacter symbol; + private final @Nonnull NamedTextColor color; - private final String prefix; + @SuppressWarnings("unused") + public TextComponent getPrefix() { + return Component.space() + .append(Component.text(symbol.getChar(), color)) + .append(Component.text(" ━ ", DARK_GRAY)); + } } \ No newline at end of file diff --git a/src/main/java/minevalley/core/api/messaging/types/MessageType.java b/src/main/java/minevalley/core/api/messaging/types/MessageType.java index f0486aab..e26efb30 100644 --- a/src/main/java/minevalley/core/api/messaging/types/MessageType.java +++ b/src/main/java/minevalley/core/api/messaging/types/MessageType.java @@ -4,26 +4,51 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; import minevalley.core.api.enums.CustomCharacter; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.format.NamedTextColor; -@Getter +import javax.annotation.Nonnull; + +import static minevalley.core.api.enums.CustomCharacter.*; +import static net.kyori.adventure.text.format.NamedTextColor.*; + +@Getter(onMethod_ = @Nonnull) @RequiredArgsConstructor(access = AccessLevel.PRIVATE) public enum MessageType { /** - * Used to signal the success of a process or action. + * Used to signal a warning. */ - SUCCESS(" §a✔§8 ━ §7"), + WARNING(EXCLAMATION_MARK, YELLOW), /** * Used to signal the failure of a process or an action. */ - ERROR(" §c§l!§8 ━ §7"), + ERROR(CROSS, RED), - INFO(" §f" + CustomCharacter.MV + " §8━ §7"), + /** + * Used to signal the success of a process or action. + */ + SUCCESS(CHECKMARK, GREEN), - INFO_BW(" §f" + CustomCharacter.MV_BW + " §8━ §7"), + /** + * Used to signal an information. + */ + INFO(MV, WHITE), + + /** + * Used to signal an information in black and white. + */ + INFO_BW(MV_BW, WHITE); - WARNING(" §e§l! §8━ §7"); + private final @Nonnull CustomCharacter symbol; + private final @Nonnull NamedTextColor color; - private final String prefix; + @SuppressWarnings("unused") + public TextComponent getPrefix() { + return Component.space() + .append(Component.text(symbol.getChar(), color)) + .append(Component.text(" ━ ", DARK_GRAY)); + } } \ No newline at end of file