Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.kyori.adventure.key.Key;
import net.minestom.server.tag.Tag;
import net.onelitefeather.cygnus.common.rank.RankTag;

import java.util.UUID;

Expand All @@ -18,6 +19,7 @@ public final class Tags {
public static final Tag<Byte> ITEM_TAG = Tag.Byte("itemTag");
public static final Tag<Key> TEAM_KEY = Tag.Transient("teamKey");
public static final Tag<Byte> HIDDEN = Tag.Byte("hidden");
public static final Tag<RankTag> ACTIVE_RANK_TAG = Tag.Transient("activeRankTag");

private Tags() {
// Nothing do to here
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package net.onelitefeather.cygnus.common.icon;

import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
//import net.onelitefeather.cygnus.common.rank.RankTag;

/**
* Represents custom game, role, and UI icons (Ghost, Flashlight, Pentagram, Clock, Page, Map, Builder)
* rendered using the {@code cygnus:icons} font.
*
* @author theEvilReaper
* @version 1.0.0
* @since 2.8.0
*/
public enum GameIcon {
GHOST("󰀀"),
PENTAGRAM("󰀅"),
CLOCK("󰀆"),
PAGE("󰀇"),
FLASHLIGHT("󰀊"),
MAP("󰀋"),
BUILDER("󰀌");

/**
* The font key for game and UI icons defined in the resource pack.
*/
public static final Key FONT = Key.key("cygnus", "icons");

// Standard role and UI mappings
public static final GameIcon SPECTATOR = GHOST;
public static final GameIcon SURVIVOR = FLASHLIGHT;
public static final GameIcon SLENDER = PENTAGRAM;
public static final GameIcon TIME = CLOCK;

private final String glyph;

GameIcon(String glyph) {
this.glyph = glyph;
}

/**
* Returns the unicode glyph representing this icon.
*
* @return the glyph string
*/
public String glyph() {
return this.glyph;
}

/**
* Returns the pre-built {@link Component} with the custom icon font.
*
* @return the component
*/
public Component asComponent() {
return Component.text(this.glyph).font(FONT);
}

/**
* Formats a component by prepending this icon and resetting the font for subsequent text.
*
* @param trailing the trailing component to append after the icon
* @return the combined component with default font reset
*/
public Component format(Component trailing) {
return Component.empty()
.append(asComponent())
//.append(Component.space().font(RankTag.DEFAULT_MINECRAFT_FONT))
.append(trailing);
}

/**
* Formats a text string by prepending this icon and resetting the font for subsequent text.
*
* @param text the text to append after the icon
* @return the combined component with default font reset
*/
public Component format(String text) {
return Component.empty();
/// return format(Component.text(text).font(RankTag.DEFAULT_MINECRAFT_FONT));
}

/**
* Formats multiple icons together, followed by the trailing component with default font reset.
*
* @param trailing the component to append after the icons
* @param icons the icons to prepend
* @return the combined component with default font reset
*/
public static Component formatMultiple(Component trailing, GameIcon... icons) {
Component result = Component.empty();
for (GameIcon icon : icons) {
result = result.append(icon.asComponent());
// .append(Component.space().font(RankTag.DEFAULT_MINECRAFT_FONT));
}
return result.append(trailing);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package net.onelitefeather.cygnus.common.rank;

import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;

import java.util.Objects;

/**
* Represents a graphical rank tag rendered with a custom font glyph.
*
* @param id the unique identifier of the rank tag
* @param glyph the character for the tag bitmap
* @param font the resource pack font key
* @param priority the priority used for resolution (higher priority takes precedence)
* @param asComponent the pre-built {@link Component} for rendering
* @author theEvilReaper
* @version 1.0.0
* @since 2.8.0
*/
public record RankTag(
String id,
String glyph,
Key font,
int priority,
Component asComponent
) implements Comparable<RankTag> {

/**
* The default font key for player rank tags defined in the resource pack.
*/
public static final Key DEFAULT_FONT = Key.key("olf", "rank_tags");

/**
* The Minecraft default font key used to reset typography after custom font glyphs.
*/
public static final Key DEFAULT_MINECRAFT_FONT = Key.key("minecraft", "default");

public static final RankTag ADMINISTRATOR = new RankTag("administrator", "󰆐", DEFAULT_FONT, 100);
public static final RankTag ASSISTENT = new RankTag("assistent", "󲆛", DEFAULT_FONT, 90);
public static final RankTag MOD = new RankTag("mod", "󱆛", DEFAULT_FONT, 80);
public static final RankTag CONTENT = new RankTag("content", "󲆐", DEFAULT_FONT, 70);
public static final RankTag MEDIA = new RankTag("media", "󲆕", DEFAULT_FONT, 60);
public static final RankTag LITE = new RankTag("lite", "󲆑", DEFAULT_FONT, 50);
public static final RankTag PLAYER = new RankTag("player", "󱆖", DEFAULT_FONT, 0);

/**
* Creates a new rank tag and builds the cached {@link Component}.
*
* @param id the unique identifier of the rank tag
* @param glyph the unicode character for the tag bitmap
* @param font the resource pack font key
* @param priority the priority used for resolution
*/
public RankTag(String id, String glyph, Key font, int priority) {
this(
Objects.requireNonNull(id, "id must not be null"),
Objects.requireNonNull(glyph, "glyph must not be null"),
Objects.requireNonNull(font, "font must not be null"),
priority,
Component.text(glyph).font(font)
);
}

/**
* Creates a new rank tag using {@link #DEFAULT_FONT}.
*
* @param id the unique identifier of the rank tag
* @param glyph the unicode character for the tag bitmap
* @param priority the priority used for resolution
*/
public RankTag(String id, String glyph, int priority) {
this(id, glyph, DEFAULT_FONT, priority);
}

@Override
public int compareTo(RankTag other) {
return Integer.compare(other.priority, this.priority);
}

/**
* Formats a component by prepending this rank tag and explicitly resetting the font for subsequent text.
*
* @param trailing the trailing component to append after the tag
* @return the combined component with the trailing font explicitly reset to default
*/
public Component format(Component trailing) {
return Component.empty()
.append(this.asComponent)
.append(Component.space().font(DEFAULT_MINECRAFT_FONT))
.append(trailing.font(DEFAULT_MINECRAFT_FONT));
}

/**
* Formats a text string by prepending this rank tag and explicitly resetting the font for subsequent text.
*
* @param text the text to append after the tag
* @return the combined component with default font
*/
public Component format(String text) {
return format(Component.text(text));
}
}
Loading
Loading