Skip to content

Commit 0c6e070

Browse files
author
xnrand
committed
Eclipse [Source] -> [Clean Up...]
1 parent 7ea25e4 commit 0c6e070

5 files changed

Lines changed: 75 additions & 76 deletions

File tree

src/main/java/com/michealharker/saraswati/irc/MircColors.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ private MircColors() {
3131
public static final String BOLD = "\u0002";
3232
public static final String NORMAL = "\u000f";
3333
public static final String UNDERLINE = "\u001f";
34-
34+
3535
public static final String ITALIC = "\u001d";
3636
public static final String INVERSE = "\u0016";
37-
37+
3838
}

src/main/java/simpleircbridge/BridgeIRCBot.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,31 @@ protected void onJoin(String channel, String sender) {
3434

3535
@Override
3636
protected void onPart(String channel, String sender, String reason) {
37-
if(bridge.getSibConf().mcFormatting)
38-
{
37+
if (this.bridge.getSibConf().mcFormatting) {
3938
reason = IRCMinecraftConverter.convIRCtoMinecraft(reason);
4039
}
4140
toMc(String.format(FORMAT2_IRC_PART, sender, reason));
4241
}
4342

4443
@Override
4544
protected void onQuit(String sender, String reason) {
46-
if(bridge.getSibConf().mcFormatting)
47-
{
45+
if (this.bridge.getSibConf().mcFormatting) {
4846
reason = IRCMinecraftConverter.convIRCtoMinecraft(reason);
4947
}
5048
toMc(String.format(FORMAT2_IRC_QUIT, sender, reason));
5149
}
5250

5351
@Override
5452
protected void onKick(String channel, String opsender, String victim, String reason) {
55-
if(bridge.getSibConf().mcFormatting)
56-
{
53+
if (this.bridge.getSibConf().mcFormatting) {
5754
reason = IRCMinecraftConverter.convIRCtoMinecraft(reason);
5855
}
5956
toMc(String.format(FORMAT3_IRC_KICK, victim, opsender, reason));
6057
}
6158

6259
@Override
6360
protected void onMessage(String channel, String sender, String message) {
64-
if(bridge.getSibConf().mcFormatting)
65-
{
61+
if (this.bridge.getSibConf().mcFormatting) {
6662
message = IRCMinecraftConverter.convIRCtoMinecraft(message);
6763
}
6864
toMc(String.format(FORMAT2_IRC_CHAT, sender, message));
@@ -71,8 +67,7 @@ protected void onMessage(String channel, String sender, String message) {
7167

7268
@Override
7369
protected void onAction(String channel, String sender, String action) {
74-
if(bridge.getSibConf().mcFormatting)
75-
{
70+
if (this.bridge.getSibConf().mcFormatting) {
7671
action = IRCMinecraftConverter.convIRCtoMinecraft(action);
7772
}
7873
toMc(String.format(FORMAT2_IRC_EMOTE, sender, action));

src/main/java/simpleircbridge/GameEventHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ public void command(CommandEvent e) {
3939
* However, some mods insist on overriding commands with their own wrappers
4040
* (looking at you, FTBUtilities) so we're checking the names here.
4141
*/
42-
42+
4343
String content = SIBUtil.join(" ", e.getParameters());
44-
44+
4545
if ("say".equals(e.getCommand().getName())) {
46-
if(bridge.getSibConf().ircFormatting) {
46+
if (this.bridge.getSibConf().ircFormatting) {
4747
content = IRCMinecraftConverter.convMinecraftToIRC(content);
4848
}
4949
toIrc(String.format(FORMAT2_MC_BROADCAST, nickname, content));
50-
50+
5151
} else if ("me".equals(e.getCommand().getName())) {
52-
if(bridge.getSibConf().ircFormatting) {
52+
if (this.bridge.getSibConf().ircFormatting) {
5353
content = IRCMinecraftConverter.convMinecraftToIRC(content);
5454
}
5555
toIrc(String.format(FORMAT2_MC_EMOTE, nickname, content));
@@ -59,7 +59,7 @@ public void command(CommandEvent e) {
5959
@SubscribeEvent
6060
public void serverChat(ServerChatEvent e) {
6161
String content = e.getMessage();
62-
if(bridge.getSibConf().ircFormatting) {
62+
if (this.bridge.getSibConf().ircFormatting) {
6363
content = IRCMinecraftConverter.convMinecraftToIRC(content);
6464
}
6565
toIrc(String.format(FORMAT2_MC_CHAT, SIBUtil.mangle(e.getPlayer().getDisplayNameString()), content));

src/main/java/simpleircbridge/SIBConfig.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,16 @@ public class SIBConfig {
4747
private final static String COMMENT_ircTLS = "Whether TLS/SSL is enabled. Set to 'false' for a plaintext connection";
4848
/* package */ final boolean ircTLS;
4949
private final static boolean DEFAULT_ircTLS = true;
50-
50+
5151
private final static String KEY_ircFormatting = "ircFormatting";
5252
private final static String COMMENT_ircFormatting = "Whether minecraft formatting should be converted to IRC formatting.";
5353
/* package */ final boolean ircFormatting;
5454
private final static boolean DEFAULT_ircFormatting = true;
55-
55+
5656
private final static String KEY_mcFormatting = "mcFormatting";
5757
private final static String COMMENT_mcFormatting = "Whether IRC formatting should be converted to Minecraft formatting.";
5858
/* package */ final boolean mcFormatting;
5959
private final static boolean DEFAULT_mcFormatting = true;
60-
6160

6261
/** gets all SIB properties. load/save is needs to be handled by caller */
6362
public SIBConfig(Configuration conf) {

src/main/java/utils/IRCMinecraftConverter.java

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,69 @@
33
import 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
*/
1112
public 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

Comments
 (0)