mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-28 03:57:35 +01:00
Don't fail to spawn if a trait has an exception when onSpawn() is called
This commit is contained in:
parent
e370fedd3c
commit
7f6251b709
@ -210,8 +210,14 @@ public class CitizensNPC extends AbstractNPC {
|
||||
|
||||
navigator.onSpawn();
|
||||
// Modify NPC using traits after the entity has been created
|
||||
for (Trait trait : traits.values())
|
||||
trait.onSpawn();
|
||||
for (Trait trait : traits.values()) {
|
||||
try {
|
||||
trait.onSpawn();
|
||||
} catch (Exception ex) {
|
||||
Messaging.severeTr(Messages.TRAIT_ONSPAWN_FAILED, trait.getName(), getId());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
getBukkitEntity().setRemoveWhenFarAway(false);
|
||||
getBukkitEntity().setCustomName(getFullName());
|
||||
return true;
|
||||
|
@ -64,7 +64,7 @@ public class Messages {
|
||||
public static final String ERROR_STOPPING_NETWORK_THREADS = "citizens.nms-errors.stopping-network-threads";
|
||||
public static final String ERROR_UPDATING_NAVIGATION_WORLD = "citizens.nms-errors.updating-navigation-world";
|
||||
public static final String ERROR_UPDATING_PATHFINDING_RANGE = "citizens.nms-errors.updating-pathfinding-range";
|
||||
public static final String ERROR_UPDATING_SPEED = "citizens.nms-erorrs.updating-land-modifier";
|
||||
public static final String ERROR_UPDATING_SPEED = "citizens.nms-errors.updating-land-modifier";
|
||||
public static final String EXCEPTION_UPDATING_NPC = "citizens.notifications.exception-updating-npc";
|
||||
public static final String FAILED_LOAD_SAVES = "citizens.saves.load-failed";
|
||||
public static final String FAILED_TO_MOUNT_NPC = "citizens.commands.npc.mount.failed";
|
||||
@ -190,6 +190,7 @@ public class Messages {
|
||||
public static final String TRAIT_NOT_CONFIGURABLE = "citizens.commands.traitc.not-configurable";
|
||||
public static final String TRAIT_NOT_FOUND = "citizens.commands.traitc.missing";
|
||||
public static final String TRAIT_NOT_FOUND_ON_NPC = "citizens.commands.traitc.not-on-npc";
|
||||
public static final String TRAIT_ONSPAWN_FAILED = "citizens.notifications.trait-onspawn-failed";
|
||||
public static final String TRAITS_ADDED = "citizens.commands.trait.added";
|
||||
public static final String TRAITS_FAILED_TO_ADD = "citizens.commands.trait.failed-to-add";
|
||||
public static final String TRAITS_FAILED_TO_CHANGE = "citizens.commands.trait.failed-to-change";
|
||||
|
@ -207,6 +207,7 @@ citizens.notifications.saving=Saving Citizens...
|
||||
citizens.notifications.skipping-broken-trait=Skipped broken or missing trait {0} while loading ID {1}. Has the name changed?
|
||||
citizens.notifications.skipping-invalid-pose=Skipping pose {0} - invalid yaw/pitch ({1}).
|
||||
citizens.notifications.trait-load-failed=The trait {0} failed to load for NPC ID: {1}.
|
||||
citizens.notifications.trait-onspawn-failed=An exception occurred while the trait {0} was spawning for NPC ID {1}.
|
||||
citizens.notifications.unknown-npc-type=NPC type {0} was not recognized. Did you spell it correctly?
|
||||
citizens.saves.load-failed=Unable to load saves, disabling...
|
||||
citizens.settings.writing-default=Writing default setting: {0}
|
||||
|
Loading…
Reference in New Issue
Block a user