Use arena slugs in arena sign update handler.
The arena signs predate the use of arena slugs everywhere, so something slipped through the cracks in this regard. Incidentally, the handler for arena updates is one of the few classes in the signs package that has no unit tests, probably due to it being "obvious implementation". Not so obvious after all, it seems, so now we have a basic test for it. Fixes #705
This commit is contained in:
@@ -31,6 +31,7 @@ These changes will (most likely) be included in the next version.
|
||||
- Zombies, husks, drowned, zombie villagers, piglins, hoglins, and zoglins without the `baby` prefix are now forced into adulthood to prevent them from occasionally spawning as babies.
|
||||
- Reward groups with `nothing` in them no longer cause errors when earned/granted.
|
||||
- The title-based announcer and the title-based boss health bar have been fixed to work with the breaking change to the Title API in Spigot 1.17.
|
||||
- Arena Signs now correctly update for arenas that don't have `kebab-case` names in the config-file.
|
||||
|
||||
## [0.106] - 2021-05-09
|
||||
### Added
|
||||
|
||||
@@ -71,7 +71,7 @@ class HandlesArenaUpdates implements Listener {
|
||||
|
||||
private void handle(Arena arena) {
|
||||
scheduler.runTask(plugin, () -> {
|
||||
List<ArenaSign> signs = signStore.findByArenaId(arena.configName());
|
||||
List<ArenaSign> signs = signStore.findByArenaId(arena.getSlug());
|
||||
signs.forEach(signRenderer::render);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.garbagemule.MobArena.signs;
|
||||
|
||||
import com.garbagemule.MobArena.MobArena;
|
||||
import com.garbagemule.MobArena.events.ArenaPlayerJoinEvent;
|
||||
import com.garbagemule.MobArena.framework.Arena;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@RunWith(MockitoJUnitRunner.StrictStubs.class)
|
||||
public class HandlesArenaUpdatesTest {
|
||||
|
||||
SignStore signStore;
|
||||
SignRenderer signRenderer;
|
||||
BukkitScheduler scheduler;
|
||||
|
||||
HandlesArenaUpdates subject;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
signStore = mock(SignStore.class);
|
||||
signRenderer = mock(SignRenderer.class);
|
||||
scheduler = mock(BukkitScheduler.class);
|
||||
|
||||
MobArena plugin = mock(MobArena.class);
|
||||
Server server = mock(Server.class);
|
||||
when(plugin.getServer()).thenReturn(server);
|
||||
when(server.getScheduler()).thenReturn(scheduler);
|
||||
|
||||
subject = new HandlesArenaUpdates(signStore, signRenderer, plugin);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usesArenaSlugForLookups() {
|
||||
String slug = "angry-dingo";
|
||||
Arena arena = mock(Arena.class);
|
||||
ArenaSign sign = new ArenaSign(null, "cool-sign", slug, "info");
|
||||
when(scheduler.runTask(any(), any(Runnable.class))).thenAnswer(i -> {
|
||||
Runnable task = i.getArgument(1);
|
||||
task.run();
|
||||
return null;
|
||||
});
|
||||
when(arena.getSlug()).thenReturn(slug);
|
||||
when(signStore.findByArenaId(slug)).thenReturn(Collections.singletonList(sign));
|
||||
ArenaPlayerJoinEvent event = new ArenaPlayerJoinEvent(null, arena);
|
||||
|
||||
subject.on(event);
|
||||
|
||||
verify(signRenderer).render(sign);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user