33import com .michealharker .saraswati .irc .MircColors ;
44
55/**
6- * Helper class to convert messages (colours and formatting)
7- * between (m)IRC and Minecraft.
6+ * Helper class to convert messages (colours and formatting) between (m)IRC and
7+ * Minecraft.
8+ *
89 * @author Fuchs
910 *
1011 */
1112public class IRCMinecraftConverter {
12-
13+
1314 /**
14- * Converts an IRC message to Minecraft by replacing formatting
15- * with the corresponding (m)IRC variant. The non existing
16- * k (garbage) and m (strikethrough) are marked.
17- * @param message message to be converted
15+ * Converts an IRC message to Minecraft by replacing formatting with the
16+ * corresponding (m)IRC variant. The non existing k (garbage) and m
17+ * (strikethrough) are marked.
18+ *
19+ * @param message
20+ * message to be converted
1821 * @return original message with colours replaced
1922 */
2023 public static String convIRCtoMinecraft (String message ) {
21-
22- if (message != null ) {
24+
25+ if (message != null ) {
2326 message = escapeMinecraftColour (message );
2427 message = mIRCtoMinecraftColourify (message );
2528 }
26-
29+
2730 return message ;
28-
31+
2932 }
30-
33+
3134 /**
32- * Converts a Minecraft message to IRC by replacing formatting
33- * with the corresponding Minecraft variant. The non-printable
34- * § character is replaced with the look-alike ⨕ to preserve
35- * meaning as good as possible.
36- * @param message message to be converted
35+ * Converts a Minecraft message to IRC by replacing formatting with the
36+ * corresponding Minecraft variant. The non-printable § character is replaced
37+ * with the look-alike ⨕ to preserve meaning as good as possible.
38+ *
39+ * @param message
40+ * message to be converted
3741 * @return original message with colours replaced
3842 */
3943 public static String convMinecraftToIRC (String message ) {
40-
41- if (message != null ) {
44+
45+ if (message != null ) {
4246 // IRC colours don't have to be stripped as they can't be typed anyway
4347 message = minecraftTomIRCcolourify (message );
4448 }
45-
49+
4650 return message ;
4751 }
48-
49- /**if(message == null) {
50- return message;
51- }
52- * Helper method to replace Minecraft colours with (m)IRC colours,
53- * taken from com.michealharker.saraswati.irc
54- * @param message message to convert
52+
53+ /**
54+ * if(message == null) { return message; } Helper method to replace Minecraft
55+ * colours with (m)IRC colours, taken from com.michealharker.saraswati.irc
56+ *
57+ * @param message
58+ * message to convert
5559 * @return message with (m)IRC Colours
5660 */
5761 public static String minecraftTomIRCcolourify (String message ) {
58-
59- // TODO: Do some state tracking
62+
63+ // TODO: Do some state tracking
6064 // The marks for non-existing IRC modes are not perfect,
61- // as they would only last until the next reset, §r.
65+ // as they would only last until the next reset, §r.
6266 // To catch that, regex instead of a simple replace would
63- // be needed, which is not warranted at this point.
64-
67+ // be needed, which is not warranted at this point.
68+
6569 return message //
6670 .replace ("§0" , MircColors .BLACK )//
6771 .replace ("§1" , MircColors .BLUE )//
@@ -83,28 +87,29 @@ public static String minecraftTomIRCcolourify(String message) {
8387 .replace ("§n" , MircColors .UNDERLINE )//
8488 .replace ("§o" , MircColors .ITALIC )//
8589 .replace ("§r" , MircColors .NORMAL )//
86- .replace ("§k" , "-§k-" ) // mark random garbage
90+ .replace ("§k" , "-§k-" ) // mark random garbage
8791 .replace ("§m" , "-§m-" ); // mark strikethrough
8892 }
89-
90-
93+
9194 /**
92- * Helper method to replace (m)IRC colours with Minecraft colours,
93- * modified from com.michealharker.saraswati.irc
94- * @param message message to convert
95+ * Helper method to replace (m)IRC colours with Minecraft colours, modified from
96+ * com.michealharker.saraswati.irc
97+ *
98+ * @param message
99+ * message to convert
95100 * @return message with (m)IRC colours
96101 */
97102 public static String mIRCtoMinecraftColourify (String message ) {
98-
99- // TODO: Do some state tracking
103+
104+ // TODO: Do some state tracking
100105 // In Minecraft if a colour code is used after formatting,
101- // the formatting code will be disabled after the colour code point.
106+ // the formatting code will be disabled after the colour code point.
102107 // Therefore, when using a colour code together with formatting,
103- // it has to be ensured the colour code is used first
104- // and to reuse the formatting code when changing colours.
105- // Also (m)IRC resets a format on using it twice, e.g. %Bbold%B normal,
108+ // it has to be ensured the colour code is used first
109+ // and to reuse the formatting code when changing colours.
110+ // Also (m)IRC resets a format on using it twice, e.g. %Bbold%B normal,
106111 // whilst Minecraft in this case just continues in bold.
107-
112+
108113 return message //
109114 .replace (MircColors .WHITE , "§f" )//
110115 .replace (MircColors .BLACK , "§0" )//
@@ -124,22 +129,22 @@ public static String mIRCtoMinecraftColourify(String message) {
124129 .replace (MircColors .YELLOW , "§e" )//
125130 .replace (MircColors .BOLD , "§l" )//
126131 .replace (MircColors .UNDERLINE , "§n" )//
127- .replace (MircColors .ITALIC , "§o" )
128- .replace (MircColors .NORMAL , "§r" );
132+ .replace (MircColors .ITALIC , "§o" ).replace (MircColors .NORMAL , "§r" );
129133 }
130-
134+
131135 /***
132- * Helper message to replace the non-valid § in minecraft
133- * with the look-alike ⨕ character to preserve meaning.
134- * Might be extended in the future for other things that are valid on IRC
135- * but not in Minecraft.
136- * @param message Message to escape
136+ * Helper message to replace the non-valid § in minecraft with the look-alike ⨕
137+ * character to preserve meaning. Might be extended in the future for other
138+ * things that are valid on IRC but not in Minecraft.
139+ *
140+ * @param message
141+ * Message to escape
137142 * @return message with replaced § characters.
138143 */
139144 public static String escapeMinecraftColour (String message ) {
140145 // Closest lookalike accepted by Minecraft
141146 // and unlikely to be used, integral around point.
142- return message .replace ("§" , "⨕" );
147+ return message .replace ("§" , "⨕" );
143148 }
144-
149+
145150}
0 commit comments