Skip to content

Commit 104c2e6

Browse files
committed
Add death message spam
1 parent f1c1e42 commit 104c2e6

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package net.stonebound.simpleircbridge.simpleircbridge;
22

3+
import dev.architectury.event.EventResult;
34
import dev.architectury.event.events.common.ChatEvent;
45
import net.minecraft.network.chat.Component;
56
import net.minecraft.server.level.ServerPlayer;
7+
import net.minecraft.world.damagesource.DamageSource;
8+
import net.minecraft.world.entity.LivingEntity;
69
import net.stonebound.simpleircbridge.utils.IRCMinecraftConverter;
710

811
import static net.stonebound.simpleircbridge.simpleircbridge.SIBConstants.*;
@@ -70,13 +73,12 @@ public void serverChat(ServerPlayer player, ChatEvent.ChatComponent component) {
7073
}
7174
}
7275

73-
// @SubscribeEvent
74-
// public void livingDeath(LivingDeathEvent e) {
75-
// if (e.getEntityLiving() instanceof PlayerEntity) {
76-
// toIrc(String.format(FORMAT1_MC_DEATH,
77-
// e.getSource().getDeathMessage(e.getEntityLiving()).getString()));
78-
// }
79-
// }
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+
}
80+
return EventResult.pass();
81+
}
8082

8183
private void toIrc(String s) {
8284
this.bridge.sendToIrc(s);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class SIBConstants {
88
/* == MC FORMATS, 1 PARAMETER == */
99
public static final String FORMAT1_MC_LOGIN = "> %s joined the game";
1010
public static final String FORMAT1_MC_LOGOUT = "< %s left the game";
11-
public static final String FORMAT1_MC_DEATH = "RIP: %s";
11+
public static final String FORMAT1_MC_DEATH = "%s";
1212
public static final String FORMAT1_MC_LOGOUT_STOP = ">>>%s was still online when time came to a halt<<<";
1313

1414
/* == MC FORMATS, 2 PARAMETERS == */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.mojang.logging.LogUtils;
44
import dev.architectury.event.events.common.ChatEvent;
5+
import dev.architectury.event.events.common.EntityEvent;
56
import dev.architectury.event.events.common.LifecycleEvent;
67
import dev.architectury.event.events.common.PlayerEvent;
78
import net.minecraft.ChatFormatting;
@@ -31,6 +32,7 @@ public SimpleIRCBridgeCommon() {
3132
eventHandler = new GameEventHandler(this);
3233
PlayerEvent.PLAYER_JOIN.register((Playerjoin) -> eventHandler.playerLoggedIn(Playerjoin));
3334
PlayerEvent.PLAYER_QUIT.register((Playerquit) -> eventHandler.playerLoggedOut(Playerquit));
35+
EntityEvent.LIVING_DEATH.register(eventHandler::livingDeath);
3436

3537
ChatEvent.DECORATE.register(eventHandler::serverChat);
3638

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.0
6+
mod_version = 1.1.1
77
maven_group = net.stonebound.simpleircbridge
88
archives_name = simpleircbridge
99
enabled_platforms = fabric,neoforge

0 commit comments

Comments
 (0)