Skip to content

Commit

Permalink
teleport command really doesn't need "spawnAt"
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 6, 2022
1 parent 0570d2b commit 97a40d3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
Expand Up @@ -775,26 +775,7 @@ public void spawnAt(Location location, TeleportCause cause) {
return;
}
// If the entity is already spawned, teleport it.
if (isCitizensNPC()) {
if (getDenizenNPC().getCitizen().isSpawned()) {
getDenizenNPC().getCitizen().teleport(location, cause);
}
else {
if (getDenizenNPC().getCitizen().spawn(location)) {
entity = getDenizenNPC().getCitizen().getEntity();
uuid = getDenizenNPC().getCitizen().getEntity().getUniqueId();
}
else {
if (new LocationTag(location).isChunkLoaded()) {
Debug.echoError("Error spawning NPC - tried to spawn in an unloaded chunk.");
}
else {
Debug.echoError("Error spawning NPC - blocked by plugin");
}
}
}
}
else if (isUnique() && entity != null) {
if (isCitizensNPC() || (isUnique() && entity != null)) {
teleport(location, cause);
}
else {
Expand Down Expand Up @@ -980,8 +961,28 @@ public void teleport(Location location) {
}

public void teleport(Location location, TeleportCause cause) {
if (location.getWorld() == null) {
Debug.echoError("Cannot teleport or spawn entity at location '" + new LocationTag(location) + "' because it is missing a world.");
return;
}
if (isCitizensNPC()) {
getDenizenNPC().getCitizen().teleport(location, cause);
if (getDenizenNPC().getCitizen().isSpawned()) {
getDenizenNPC().getCitizen().teleport(location, cause);
}
else {
if (getDenizenNPC().getCitizen().spawn(location)) {
entity = getDenizenNPC().getCitizen().getEntity();
uuid = getDenizenNPC().getCitizen().getEntity().getUniqueId();
}
else {
if (new LocationTag(location).isChunkLoaded()) {
Debug.echoError("Error spawning NPC - tried to spawn in an unloaded chunk.");
}
else {
Debug.echoError("Error spawning NPC - blocked by plugin");
}
}
}
}
else if (isFake) {
NMSHandler.getEntityHelper().snapPositionTo(entity, location.toVector());
Expand Down
Expand Up @@ -123,7 +123,7 @@ public void execute(final ScriptEntry scriptEntry) {
NMSHandler.getEntityHelper().look(entity.getBukkitEntity(), location.getYaw(), location.getPitch());
return;
}
entity.spawnAt(location, causeEnum);
entity.teleport(location, causeEnum);
}
}
}

0 comments on commit 97a40d3

Please sign in to comment.