Skip to content

Commit e6ea905

Browse files
committed
Gotta make sure special formatting is kept for Discord
1 parent e6f68cf commit e6ea905

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

common/src/main/java/net/stonebound/simpleircbridge/simpleircbridge/GameEventHandler.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,27 @@ public void playerLoggedOut(ServerPlayer e) {
5555
// }
5656
// }
5757

58-
public void serverChat(ServerPlayer player, ChatEvent.ChatComponent component) {
58+
public void formatServerChat(ServerPlayer player, ChatEvent.ChatComponent component) {
5959
Component chatComponent = component.get().copy();
6060
String content = SIBUtil.getRawText(chatComponent);
6161
component.set(SimpleIRCBridgeCommon.newChatWithLinks(content, false));
62-
if (player != null) {
63-
String playername = player.getName().getString();
62+
}
63+
64+
public EventResult livingDeath(LivingEntity livingEntity, DamageSource damageSource) {
65+
if (livingEntity instanceof ServerPlayer) {
66+
toIrc(String.format(FORMAT1_MC_DEATH, damageSource.getLocalizedDeathMessage(livingEntity).getString().replace(livingEntity.getName().toString(), SIBUtil.mangle(livingEntity.getName().toString())) ));
67+
}
68+
return EventResult.pass();
69+
}
70+
71+
private void toIrc(String s) {
72+
this.bridge.sendToIrc(s);
73+
}
74+
75+
public EventResult serverChat(ServerPlayer serverPlayer, Component component) {
76+
String content = SIBUtil.getRawText(component);
77+
if (serverPlayer != null) {
78+
String playername = SIBUtil.mangle(serverPlayer.getName().getString());
6479
if (Config.ircFormatting) {
6580
content = IRCMinecraftConverter.convMinecraftToIRC(content);
6681
}
@@ -71,16 +86,7 @@ public void serverChat(ServerPlayer player, ChatEvent.ChatComponent component) {
7186
}
7287
toIrc(String.format(FORMAT2_MC_CHAT, "Server", content));
7388
}
74-
}
7589

76-
public EventResult livingDeath(LivingEntity livingEntity, DamageSource damageSource) {
77-
if (livingEntity instanceof ServerPlayer) {
78-
toIrc(String.format(FORMAT1_MC_DEATH, damageSource.getLocalizedDeathMessage(livingEntity).getString().replace(livingEntity.getName().toString(), SIBUtil.mangle(livingEntity.getName().toString())) ));
79-
}
8090
return EventResult.pass();
8191
}
82-
83-
private void toIrc(String s) {
84-
this.bridge.sendToIrc(s);
85-
}
8692
}

common/src/main/java/net/stonebound/simpleircbridge/simpleircbridge/SIBConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class SIBConstants {
99
public static final String FORMAT1_MC_LOGIN = "> %s joined the game";
1010
public static final String FORMAT1_MC_LOGOUT = "< %s left the game";
1111
public static final String FORMAT1_MC_DEATH = "%s";
12-
public static final String FORMAT1_MC_LOGOUT_STOP = ">>>%s was still online when time came to a halt<<<";
12+
public static final String FORMAT1_MC_LOGOUT_STOP = "< %s left the game when time came to a halt";
1313

1414
/* == MC FORMATS, 2 PARAMETERS == */
1515
public static final String FORMAT2_MC_EMOTE = "* %s %s";

common/src/main/java/net/stonebound/simpleircbridge/simpleircbridge/SimpleIRCBridgeCommon.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public SimpleIRCBridgeCommon() {
3434
PlayerEvent.PLAYER_QUIT.register((Playerquit) -> eventHandler.playerLoggedOut(Playerquit));
3535
EntityEvent.LIVING_DEATH.register(eventHandler::livingDeath);
3636

37-
ChatEvent.DECORATE.register(eventHandler::serverChat);
37+
ChatEvent.DECORATE.register(eventHandler::formatServerChat);
38+
ChatEvent.RECEIVED.register(eventHandler::serverChat);
3839

3940
LifecycleEvent.SERVER_STARTING.register(Config::serverStarting);
4041
LifecycleEvent.SERVER_STOPPING.register(Config::serverStopping);
@@ -55,7 +56,7 @@ public void serverStopping(MinecraftServer instance) {
5556
if (this.mcServer != null && Config.timestop) {
5657
this.mcServer.getPlayerList()
5758
.getPlayers()
58-
.forEach(player -> sendToIrc(MircColors.BOLD + MircColors.LIGHT_RED + String.format(FORMAT1_MC_LOGOUT_STOP, SIBUtil.mangle(player.getName().getString()))));
59+
.forEach(player -> sendToIrc(String.format(FORMAT1_MC_LOGOUT_STOP, SIBUtil.mangle(player.getName().getString()))));
5960
}
6061
if (this.bot != null) {
6162
this.bot.disconnect();

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx2G
33
org.gradle.parallel=true
44

55
# Mod properties
6-
mod_version = 1.1.1
6+
mod_version = 1.1.3
77
maven_group = net.stonebound.simpleircbridge
88
archives_name = simpleircbridge
99
enabled_platforms = fabric,neoforge

0 commit comments

Comments
 (0)