Saves NPCs immediately after they are changed

Additionally:
Updates Citizens dependency to the newest version
Removes some redundancy in NPC settings' path
This commit is contained in:
2022-10-07 17:14:58 +02:00
parent fb483a4c2a
commit 907389f978
5 changed files with 43 additions and 39 deletions

View File

@@ -39,7 +39,7 @@ public class BlackSmithEditCommand implements CommandExecutor {
return false;
}
BlacksmithTrait blacksmithTrait = npc.getTrait(BlacksmithTrait.class);
BlacksmithTrait blacksmithTrait = npc.getTraitNullable(BlacksmithTrait.class);
for (NPCSetting npcSetting : NPCSetting.values()) {
String commandName = npcSetting.getCommandName();
@@ -87,6 +87,8 @@ public class BlackSmithEditCommand implements CommandExecutor {
ChatColor.translateAlternateColorCodes('&', newValue);
blacksmithTrait.getSettings().changeSetting(npcSetting, nullCheckedValue);
displaySuccessMessage(sender, TranslatableMessage.getValueChangedMessage(npcSetting.getNodeName(), newValue));
//Save the changes immediately to prevent data loss on server crash
CitizensAPI.getNPCRegistry().saveToStore();
return true;
} else {
return false;