diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java index f9de8d7dde..7850653bb0 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/EntityTag.java @@ -725,8 +725,6 @@ else if (entity != null && isUnique()) { } else { - org.bukkit.entity.Entity ent; - if (entity_type.getName().equals("PLAYER")) { if (Depends.citizens == null) { Debug.echoError("Cannot spawn entity of type PLAYER!"); @@ -791,14 +789,12 @@ else if (entity_type.getName().equals("FALLING_BLOCK")) { } // This is currently the only way to spawn a falling block - ent = location.getWorld().spawnFallingBlock(location, material, materialData); - entity = ent; + entity = location.getWorld().spawnFallingBlock(location, material, materialData); uuid = entity.getUniqueId(); } else { - ent = entity_type.spawnNewEntity(location, mechanisms, entityScript); - entity = ent; + entity = entity_type.spawnNewEntity(location, mechanisms, entityScript); if (entity == null) { if (Debug.verbose) { Debug.echoError("Failed to spawn entity of type " + entity_type.getName()); diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/SpawnCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/SpawnCommand.java index b0f465accf..16dd63847f 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/SpawnCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/SpawnCommand.java @@ -34,10 +34,11 @@ public SpawnCommand() { // @Group entity // // @Description - // Spawn an entity or list of entities at the specified location. Accepts the 'target:' argument which - // will cause all spawned entities to follow and attack the targeted entity. - // If the persistent argument is present, the entity will not despawn when no players are within range, causing - // the entity to remain until killed. + // Spawn an entity or list of entities at the specified location. + // + // Accepts the 'target:' argument which will cause all spawned entities to follow and attack the targeted entity. + // + // If the persistent argument is present, the entity will not despawn when no players are within range, causing the entity to remain until killed. // // @Tags // @@ -146,12 +147,16 @@ public void execute(final ScriptEntry scriptEntry) { entityList.addObject(entity); - if (persistent && entity.isLivingEntity()) { - entity.getLivingEntity().setRemoveWhenFarAway(false); + if (!entity.isSpawned()) { + Debug.echoDebug(scriptEntry, "Failed to spawn " + entity + " (blocked by other plugin, script, or gamerule?)."); } - - if (target != null && target.isLivingEntity()) { - entity.target(target.getLivingEntity()); + else { + if (persistent && entity.isLivingEntity()) { + entity.getLivingEntity().setRemoveWhenFarAway(false); + } + if (target != null && target.isLivingEntity()) { + entity.target(target.getLivingEntity()); + } } }