Skip to content

Commit 0f4024d

Browse files
Use canonical participation revocation signal for bounds violations
1 parent eb8c1d8 commit 0f4024d

3 files changed

Lines changed: 8 additions & 18 deletions

File tree

src/main/java/io/github/legendaryforge/legendary/core/internal/legendary/arena/BoundsInvariant.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package io.github.legendaryforge.legendary.core.internal.legendary.arena;
22

33
import io.github.legendaryforge.legendary.core.api.event.EventBus;
4+
import io.github.legendaryforge.legendary.core.api.id.ResourceId;
45
import io.github.legendaryforge.legendary.core.internal.legendary.arena.event.ArenaBoundsViolatedEvent;
5-
import io.github.legendaryforge.legendary.core.internal.legendary.arena.event.ArenaParticipationRevokedEvent;
6+
import io.github.legendaryforge.legendary.core.internal.legendary.arena.event.ParticipationRevokedEvent;
67
import java.util.Map;
78
import java.util.Objects;
89
import java.util.Set;
@@ -16,6 +17,8 @@
1617
*/
1718
public final class BoundsInvariant implements ArenaInvariant {
1819

20+
private static final ResourceId OUT_OF_BOUNDS_REASON = new ResourceId("legendary", "out_of_bounds");
21+
1922
private final EventBus bus;
2023

2124
// Tracks whether the instance is currently ACTIVE.
@@ -37,7 +40,7 @@ private void onBoundsViolated(ArenaBoundsViolatedEvent event) {
3740
}
3841
Set<UUID> revokedPlayers = revoked.computeIfAbsent(instanceId, id -> ConcurrentHashMap.newKeySet());
3942
if (revokedPlayers.add(event.playerId())) {
40-
bus.post(new ArenaParticipationRevokedEvent(instanceId, event.playerId()));
43+
bus.post(new ParticipationRevokedEvent(instanceId, event.playerId(), OUT_OF_BOUNDS_REASON));
4144
}
4245
}
4346

src/main/java/io/github/legendaryforge/legendary/core/internal/legendary/arena/event/ArenaParticipationRevokedEvent.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/test/java/io/github/legendaryforge/legendary/core/internal/legendary/arena/BoundsInvariantTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io.github.legendaryforge.legendary.core.api.event.EventBus;
66
import io.github.legendaryforge.legendary.core.internal.event.SimpleEventBus;
77
import io.github.legendaryforge.legendary.core.internal.legendary.arena.event.ArenaBoundsViolatedEvent;
8-
import io.github.legendaryforge.legendary.core.internal.legendary.arena.event.ArenaParticipationRevokedEvent;
8+
import io.github.legendaryforge.legendary.core.internal.legendary.arena.event.ParticipationRevokedEvent;
99
import java.util.ArrayList;
1010
import java.util.List;
1111
import java.util.UUID;
@@ -21,8 +21,8 @@ void emitsRevokeOnlyWhenActiveAndOnlyOnce() {
2121
UUID instanceId = UUID.fromString("00000000-0000-0000-0000-000000000010");
2222
UUID playerId = UUID.fromString("00000000-0000-0000-0000-000000000011");
2323

24-
List<ArenaParticipationRevokedEvent> revoked = new ArrayList<>();
25-
bus.subscribe(ArenaParticipationRevokedEvent.class, revoked::add);
24+
List<ParticipationRevokedEvent> revoked = new ArrayList<>();
25+
bus.subscribe(ParticipationRevokedEvent.class, revoked::add);
2626

2727
// Not active yet -> no revoke
2828
bus.post(ArenaBoundsViolatedEvent.withoutPosition(instanceId, playerId));

0 commit comments

Comments
 (0)