Skip to content

Commit

Permalink
Add death message spam
Browse files Browse the repository at this point in the history
  • Loading branch information
phit committed Aug 25, 2024
1 parent f1c1e42 commit 104c2e6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package net.stonebound.simpleircbridge.simpleircbridge;

import dev.architectury.event.EventResult;
import dev.architectury.event.events.common.ChatEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
import net.stonebound.simpleircbridge.utils.IRCMinecraftConverter;

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

// @SubscribeEvent
// public void livingDeath(LivingDeathEvent e) {
// if (e.getEntityLiving() instanceof PlayerEntity) {
// toIrc(String.format(FORMAT1_MC_DEATH,
// e.getSource().getDeathMessage(e.getEntityLiving()).getString()));
// }
// }
public EventResult livingDeath(LivingEntity livingEntity, DamageSource damageSource) {
if (livingEntity instanceof ServerPlayer) {
toIrc(String.format(FORMAT1_MC_DEATH, damageSource.getLocalizedDeathMessage(livingEntity).getString().replace(livingEntity.getName().toString(), SIBUtil.mangle(livingEntity.getName().toString())) ));
}
return EventResult.pass();
}

private void toIrc(String s) {
this.bridge.sendToIrc(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class SIBConstants {
/* == MC FORMATS, 1 PARAMETER == */
public static final String FORMAT1_MC_LOGIN = "> %s joined the game";
public static final String FORMAT1_MC_LOGOUT = "< %s left the game";
public static final String FORMAT1_MC_DEATH = "RIP: %s";
public static final String FORMAT1_MC_DEATH = "%s";
public static final String FORMAT1_MC_LOGOUT_STOP = ">>>%s was still online when time came to a halt<<<";

/* == MC FORMATS, 2 PARAMETERS == */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.logging.LogUtils;
import dev.architectury.event.events.common.ChatEvent;
import dev.architectury.event.events.common.EntityEvent;
import dev.architectury.event.events.common.LifecycleEvent;
import dev.architectury.event.events.common.PlayerEvent;
import net.minecraft.ChatFormatting;
Expand Down Expand Up @@ -31,6 +32,7 @@ public SimpleIRCBridgeCommon() {
eventHandler = new GameEventHandler(this);
PlayerEvent.PLAYER_JOIN.register((Playerjoin) -> eventHandler.playerLoggedIn(Playerjoin));
PlayerEvent.PLAYER_QUIT.register((Playerquit) -> eventHandler.playerLoggedOut(Playerquit));
EntityEvent.LIVING_DEATH.register(eventHandler::livingDeath);

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

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true

# Mod properties
mod_version = 1.1.0
mod_version = 1.1.1
maven_group = net.stonebound.simpleircbridge
archives_name = simpleircbridge
enabled_platforms = fabric,neoforge
Expand Down

0 comments on commit 104c2e6

Please sign in to comment.