Compare commits

...

2 Commits

Author SHA1 Message Date
tastybento 69a22e917e Fix MythicMobs test 2024-04-14 22:11:41 -07:00
tastybento ffb955b22b Fix bug with MythicMobs changes #2340 2024-04-14 22:00:37 -07:00
3 changed files with 17 additions and 1 deletions

View File

@ -286,6 +286,9 @@ public class BlueprintEntity {
* @return the mythicMobsRecord * @return the mythicMobsRecord
*/ */
public MythicMobRecord getMythicMobsRecord() { public MythicMobRecord getMythicMobsRecord() {
if (this.MMtype == null || this.MMLevel == null || this.MMpower == null || this.MMStance == null) {
return null;
}
return new MythicMobRecord(this.MMtype, this.getCustomName(), this.MMLevel, this.MMpower, this.MMStance); return new MythicMobRecord(this.MMtype, this.getCustomName(), this.MMLevel, this.MMpower, this.MMStance);
} }

View File

@ -55,6 +55,9 @@ public class MythicMobsHook extends Hook {
* @return true if spawn is successful * @return true if spawn is successful
*/ */
public boolean spawnMythicMob(MythicMobRecord mmr, Location spawnLocation) { public boolean spawnMythicMob(MythicMobRecord mmr, Location spawnLocation) {
if (!this.isPluginAvailable()) {
return false;
}
return MythicBukkit.inst().getMobManager().getMythicMob(mmr.type()).map(mob -> { return MythicBukkit.inst().getMobManager().getMythicMob(mmr.type()).map(mob -> {
// A delay is required before spawning, I assume because the blocks are pasted using NMS // A delay is required before spawning, I assume because the blocks are pasted using NMS
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> { Bukkit.getScheduler().runTaskLater(getPlugin(), () -> {

View File

@ -156,7 +156,17 @@ public class MythicMobsHookTest {
* Test method for {@link world.bentobox.bentobox.hooks.MythicMobsHook#spawnMythicMob(world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity.MythicMobRecord, org.bukkit.Location)}. * Test method for {@link world.bentobox.bentobox.hooks.MythicMobsHook#spawnMythicMob(world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity.MythicMobRecord, org.bukkit.Location)}.
*/ */
@Test @Test
public void testSpawnMythicMob() { public void testSpawnMythicMobNoPLugin() {
MythicMobRecord mmr = hook.getMythicMob(entity);
assertFalse(hook.spawnMythicMob(mmr, location));
}
/**
* Test method for {@link world.bentobox.bentobox.hooks.MythicMobsHook#spawnMythicMob(world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity.MythicMobRecord, org.bukkit.Location)}.
*/
@Test
public void testSpawnMythicMobHasPlugin() {
when(mythicMobs.isEnabled()).thenReturn(true);
MythicMobRecord mmr = hook.getMythicMob(entity); MythicMobRecord mmr = hook.getMythicMob(entity);
assertTrue(hook.spawnMythicMob(mmr, location)); assertTrue(hook.spawnMythicMob(mmr, location));
verify(mm).getMythicMob("GIANT"); verify(mm).getMythicMob("GIANT");