Skip to content

Commit

Permalink
spawn command: better message on spawning failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 4, 2020
1 parent 81e16af commit 97c8f24
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
Expand Up @@ -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!");
Expand Down Expand Up @@ -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());
Expand Down
Expand Up @@ -34,10 +34,11 @@ public SpawnCommand() {
// @Group entity
//
// @Description
// Spawn an entity or list of entities at the specified location. Accepts the 'target:<entity>' 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:<entity>' 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
// <EntityTag.is_spawned>
Expand Down Expand Up @@ -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());
}
}
}

Expand Down

0 comments on commit 97c8f24

Please sign in to comment.