Fixed PK news announcement breaking due to incorrect time processing

This commit is contained in:
damighty
2025-08-18 14:39:38 +03:00
committed by Ryan
parent 80b1b4b01e
commit 891cdf7de1
@@ -617,10 +617,13 @@ public class Player extends Entity {
if (this.isArtificial() && killer instanceof NPC) { if (this.isArtificial() && killer instanceof NPC) {
return; return;
} }
if (killer instanceof Player && killer.getName() != getName() /* happens if you died via typeless damage from an external cause, e.g. bugs in a dark cave without a light source */ && getWorldTicks() - killer.getAttribute("/save:last-murder-news", 0) >= 500) { if (killer instanceof Player && killer.getName() != getName()) { // the latter happens if you died via typeless damage from an external cause, e.g. bugs in a dark cave without a light source
Item wep = getItemFromEquipment((Player) killer, EquipmentSlot.WEAPON); long unixSeconds = System.currentTimeMillis() / 1000L;
sendNews(killer.getUsername() + " has murdered " + getUsername() + " with " + (wep == null ? "their fists." : (StringUtils.isPlusN(wep.getName()) ? "an " : "a ") + wep.getName())); if (unixSeconds - killer.getAttribute("/save:last-murder-news", 0L) >= 300) {
killer.setAttribute("/save:last-murder-news", getWorldTicks()); Item wep = getItemFromEquipment((Player) killer, EquipmentSlot.WEAPON);
sendNews(killer.getUsername() + " has murdered " + getUsername() + " with " + (wep == null ? "their fists." : (StringUtils.isPlusN(wep.getName()) ? "an " : "a ") + wep.getName()));
killer.setAttribute("/save:last-murder-news", unixSeconds);
}
} }
getPacketDispatch().sendMessage("Oh dear, you are dead!"); getPacketDispatch().sendMessage("Oh dear, you are dead!");
incrementAttribute("/save:"+STATS_BASE+":"+STATS_DEATHS); incrementAttribute("/save:"+STATS_BASE+":"+STATS_DEATHS);