1616import java .util .*;
1717
1818/**
19- * Client-side mod initializer for the Minecraft mod "Spooncraft Name Link".
19+ * Client-side mod initializer for the mod "Spooncraft Name Link".
2020 */
2121public class SCNicknamerClient implements ClientModInitializer {
2222
2323 // The mod ID as used in logging
24- static final String MOD_ID = "scnamelink " ;
24+ static final String MOD_ID = "scnicknamer " ;
2525
2626 // Logger for outputting information to the console and log files
2727 static final Logger LOGGER = LoggerFactory .getLogger (MOD_ID );
@@ -32,16 +32,16 @@ public class SCNicknamerClient implements ClientModInitializer {
3232 private static List <DisplayMapping > mappings = new ArrayList <>();
3333
3434 /**
35- * Retrieves a mapping matching either the UUID or the name of the Minecraft player.
35+ * Retrieves a mapping matching either the UUID or the name of the player.
3636 *
37- * @param uuid The {@code UUID} of the Minecraft player
38- * @param name The in-game name of the Minecraft player
37+ * @param uuid The {@code UUID} of the player
38+ * @param name The in-game name of the player
3939 * @return The {@code DisplayMapping} object if found, otherwise null
4040 */
4141 public static DisplayMapping getMapping (UUID uuid , String name ) {
4242 // Iterate over the mappings to find the correct match based on UUID or Minecraft name
4343 for (DisplayMapping mapping : mappings ) {
44- if (Objects .equals (mapping .mc_uuid , uuid ) || Objects .equals (mapping .mc_name , name )) {
44+ if (Objects .equals (mapping .mc_uuid () , uuid ) || Objects .equals (mapping .mc_name () , name )) {
4545 return mapping ;
4646 }
4747 }
@@ -71,14 +71,14 @@ static MutableText applyMapping(Text message, DisplayMapping mapping,
7171 Style replacedStyle = style ;
7272
7373 // Apply the mapping
74- if (replacedText .contains (mapping .mc_name )) {
74+ if (replacedText .contains (mapping .mc_name () )) {
7575 // Replace the string
76- if (mapping .discord_nick != null && replaceName ) {
77- replacedText = replacedText .replace (mapping .mc_name , mapping .discord_nick );
76+ if (mapping .discord_nick () != null && replaceName ) {
77+ replacedText = replacedText .replace (mapping .mc_name () , mapping .discord_nick () );
7878 }
7979 // Apply color if specified
80- if (mapping .colour != null && replaceColour ) {
81- replacedStyle = replacedStyle .withColor (Integer .parseInt (mapping .colour , 16 ));
80+ if (mapping .colour () != null && replaceColour ) {
81+ replacedStyle = replacedStyle .withColor (Integer .parseInt (mapping .colour () , 16 ));
8282 }
8383 }
8484
@@ -109,10 +109,9 @@ static MutableText applyMapping(Text message, DisplayMapping mapping,
109109 public static Text getStyledName (Text displayName , UUID uuid , String name , boolean replaceName ,
110110 boolean replaceColour ) {
111111 DisplayMapping mapping = getMapping (uuid , name );
112- if (mapping != null ) {
113- return applyMapping (displayName , mapping , replaceName , replaceColour );
114- }
115- return displayName ;
112+ return (mapping != null )
113+ ? applyMapping (displayName , mapping , replaceName , replaceColour )
114+ : displayName ;
116115 }
117116
118117 /**
@@ -149,16 +148,12 @@ public static Text getStyledChat(Text message, boolean replaceName, boolean repl
149148 MutableText newText = Text .literal (text ).setStyle (style );
150149
151150 HoverEvent event = style .getHoverEvent ();
152- if (event != null ) {
153-
154- if (event .getAction () == HoverEvent .Action .SHOW_ENTITY ) {
155- HoverEvent .EntityContent entity = ((HoverEvent .ShowEntity ) event ).entity ();
156-
157- newText = (MutableText ) getStyledName (newText , entity .uuid ,
158- String .valueOf (entity .name ),
159- replaceName , replaceColour );
160- newText .setStyle (newText .getStyle ().withHoverEvent (event ));
161- }
151+ if (event != null && event .getAction () == HoverEvent .Action .SHOW_ENTITY ) {
152+ HoverEvent .EntityContent entity = ((HoverEvent .ShowEntity ) event ).entity ();
153+ newText = (MutableText ) getStyledName (newText , entity .uuid ,
154+ String .valueOf (entity .name ),
155+ replaceName , replaceColour );
156+ newText .setStyle (newText .getStyle ().withHoverEvent (event ));
162157 }
163158
164159 outputMessage .append (newText );
@@ -177,7 +172,9 @@ public static Text getStyledChat(Text message, boolean replaceName, boolean repl
177172 * @return The number of mappings retrieved.
178173 */
179174 public static int getMappings (String source ) {
180- String s = (source == null || source .isEmpty ()) ? "https://gwaff.uqcloud.net/api/spooncraft" : source ;
175+ String s = (source == null || source .isEmpty ())
176+ ? "https://gwaff.uqcloud.net/scnicknamer"
177+ : source ;
181178 mappings = NameLinkAPI .getMappings (s );
182179 return mappings .size ();
183180 }
@@ -188,12 +185,11 @@ public static int getMappings(String source) {
188185 * @return A Text object containing the status of the mod
189186 */
190187 public static Text getStatusString () {
191- String status = NameLinkAPI .getStatus ();
192- return switch (status ) {
193- case "Success" -> Text .translatable ("text.scnamelink.status.success" ).formatted (Formatting .WHITE );
194- case "Working" -> Text .translatable ("text.scnamelink.status.working" ).formatted (Formatting .YELLOW );
195- case "Fallback" -> Text .translatable ("text.scnamelink.status.fallback" ).formatted (Formatting .RED );
196- case "Failure" -> Text .translatable ("text.scnamelink.status.failure" ).formatted (Formatting .RED , Formatting .BOLD );
188+ return switch (NameLinkAPI .getStatus ()) {
189+ case "Success" -> Text .translatable ("text.scnicknamer.status.success" ).formatted (Formatting .WHITE );
190+ case "Working" -> Text .translatable ("text.scnicknamer.status.working" ).formatted (Formatting .YELLOW );
191+ case "Fallback" -> Text .translatable ("text.scnicknamer.status.fallback" ).formatted (Formatting .RED );
192+ case "Failure" -> Text .translatable ("text.scnicknamer.status.failure" ).formatted (Formatting .RED , Formatting .BOLD );
197193 default -> Text .of (NameLinkAPI .getStatus ());
198194 };
199195 }
0 commit comments