From e17403feb2e8bef41099421e46e00ee2acf9c04e Mon Sep 17 00:00:00 2001 From: RoboMWM Date: Fri, 17 Aug 2018 10:15:35 -0700 Subject: [PATCH] Perform sanity check on nextClaimID, closes #207 --- .../me/ryanhamshire/GriefPrevention/DataStore.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java b/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java index abf64a5..9920938 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java @@ -135,6 +135,18 @@ public abstract class DataStore void initialize() throws Exception { GriefPrevention.AddLogEntry(this.claims.size() + " total claims loaded."); + + //RoboMWM: ensure the nextClaimID is greater than any other claim ID. If not, data corruption occurred (out of storage space, usually). + for (Claim claim : this.claims) + { + if (claim.id >= nextClaimID) + { + instance.getLogger().severe("nextClaimID was lesser or equal to an already-existing claim ID!\n" + + "This usually happens if you ran out of storage space."); + instance.AddLogEntry("Changing nextClaimID from " + nextClaimID + " to " + claim.id, CustomLogEntryTypes.Debug, false); + nextClaimID = claim.id + 1; + } + } //ensure data folders exist File playerDataFolder = new File(playerDataFolderPath);