mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 08:24:46 +00:00
Don't save current PlayerData if we're modifying it within a Profile
This commit is contained in:
1 parent
19a1b629c8
commit
cd3514aa73
2 files changed
+27
-15
No files matched your search
@@ -150,22 +150,25 @@ public class ProfileController {
|
||||
|
||||
// Offline save (synchronous) when no EntityPlayer is available.
|
||||
public static synchronized void saveOffline(Profile profile, UUID uuid) {
|
||||
final NBTTagCompound compound = profile.writeToNBT();
|
||||
final String filename = uuid.toString() + ".dat";
|
||||
try {
|
||||
File saveDir = getProfileDir();
|
||||
File fileNew = new File(saveDir, filename + "_new");
|
||||
File fileOld = new File(saveDir, filename);
|
||||
CompressedStreamTools.writeCompressed(compound, new FileOutputStream(fileNew));
|
||||
if(fileOld.exists()){
|
||||
fileOld.delete();
|
||||
profile.locked = true;
|
||||
CustomNPCsThreader.customNPCThread.execute(() -> {
|
||||
final NBTTagCompound compound = profile.writeToNBT();
|
||||
final String filename = uuid.toString() + ".dat";
|
||||
try {
|
||||
File saveDir = getProfileDir();
|
||||
File fileNew = new File(saveDir, filename + "_new");
|
||||
File fileOld = new File(saveDir, filename);
|
||||
CompressedStreamTools.writeCompressed(compound, new FileOutputStream(fileNew));
|
||||
if(fileOld.exists()){
|
||||
fileOld.delete();
|
||||
}
|
||||
fileNew.renameTo(fileOld);
|
||||
// Also backup if allowed.
|
||||
backupProfile(uuid, compound);
|
||||
} catch (Exception e) {
|
||||
LogWriter.except(e);
|
||||
}
|
||||
fileNew.renameTo(fileOld);
|
||||
// Also backup if allowed.
|
||||
backupProfile(uuid, compound);
|
||||
} catch (Exception e) {
|
||||
LogWriter.except(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Save for online players (asynchronous).
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import kamkeel.npcs.addon.DBCAddon;
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import kamkeel.npcs.controllers.data.Profile;
|
||||
import kamkeel.npcs.network.packets.data.AchievementPacket;
|
||||
import kamkeel.npcs.network.packets.data.ChatAlertPacket;
|
||||
import kamkeel.npcs.network.packets.request.party.PartyInvitePacket;
|
||||
@@ -373,6 +375,13 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
}
|
||||
|
||||
public synchronized void save() {
|
||||
// Don't Save this is a Modification of a Profile's PlayerData
|
||||
Profile profile = ProfileController.getProfile(UUID.fromString(uuid));
|
||||
if(profile != null && profile.currentID != this.profileSlot){
|
||||
ProfileController.saveOffline(profile, UUID.fromString(uuid));
|
||||
return;
|
||||
}
|
||||
|
||||
final NBTTagCompound compound = getNBT();
|
||||
final String filename;
|
||||
if(ConfigMain.DatFormat){
|
||||
|
||||
Reference in new issue
Block a user