Skip to content
Merged

Fixes #562

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public void onPlayerDeath(PlayerDeathEvent e) {
DeathCause cause = FightUtil.convert(damageSource.getDamageType());
ffa.killPlayer(player, killer, cause.getMessage().replace("%killer%", killer != null ? killer.getName() : "Unknown"));

if (killer != null) {
if (killer != null && !killer.equals(player)) {
Statistic statistic = ffa.getStatistics().computeIfAbsent(
killer,
p -> new Statistic(ProfileManager.getInstance().getUuids().get(p))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void killPlayer(Player player, Player killer, String deathMessage) {
// check whether a recent attacker should be credited instead.
if (killer == null) {
Player lastAttacker = getLastAttacker(player);
if (lastAttacker != null && deathMessage != null
if (lastAttacker != null && !lastAttacker.equals(player) && deathMessage != null
&& deathMessage.equals(dev.nandi0813.practice.manager.fight.util.DeathCause.VOID.getMessage())) {
killer = lastAttacker;
deathMessage = dev.nandi0813.practice.manager.fight.util.DeathCause.VOID_BY_PLAYER
Expand All @@ -237,7 +237,7 @@ public void killPlayer(Player player, Player killer, String deathMessage) {
Profile deadProfile = fightPlayers.get(player).getProfile();
deadProfile.getStats().getLadderStat(players.get(player)).increaseDeaths();

if (killer != null) {
if (killer != null && !killer.equals(player)) {
Profile killerProfile = fightPlayers.get(killer).getProfile();
killerProfile.getStats().getLadderStat(players.get(killer)).increaseKills();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,13 @@ public void endMatch() {
removeSpectator(spectator);

// Reset the arena and only make it reusable after rollback completes.
resetMap(() -> this.arena.setAvailable(true));
// Also defer live-match removal to the rollback callback so block event listeners
// can still resolve this match via cuboid lookup during the multi-tick rollback,
// preventing untracked block changes from leaking into the next match.
resetMap(() -> {
MatchManager.getInstance().getLiveMatches().remove(this);
this.arena.setAvailable(true);
});

this.cancel();

Expand Down Expand Up @@ -422,7 +428,7 @@ public void addSpectator(Player player, Player target, boolean teleport, boolean
return;
}

if (this.status.equals(MatchStatus.OVER)) {
if (this.status.equals(MatchStatus.OVER) || this.players.isEmpty()) {
Common.sendMMMessage(player, LanguageManager.getString("SPECTATE.MATCH.MATCH-ENDED"));
return;
}
Expand Down Expand Up @@ -463,6 +469,7 @@ public void addSpectator(Player player, Player target, boolean teleport, boolean
}

Profile profile = ProfileManager.getInstance().getProfile(player);
profile.setStatus(ProfileStatus.SPECTATE);

if (profile.isStaffMode()) {
InventoryManager.getInstance().setStaffModeInventory(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ public void onMatchEnd(MatchEndEvent e) {
if (party != null)
party.setMatch(null);

MatchManager.getInstance().getLiveMatches().remove(match);
// Live match removal is deferred to after rollback completes in Match.endMatch().
// This ensures block event listeners can still resolve the match via cuboid lookup
// during the multi-tick rollback window, preventing untracked block changes.
// MatchManager.getInstance().getLiveMatches().remove(match);

// Update GUIs
if (match instanceof Duel && ((Duel) match).isRanked())
Expand Down