From 23f8272a702389aa5dc212b77ae34373696f6c50 Mon Sep 17 00:00:00 2001 From: Joshua Reetz Date: Thu, 11 Sep 2014 19:53:39 -0600 Subject: [PATCH] Added in compatibility with newest beta build's data format by skipping any lines with UUIDs in them. --- .../GriefPrevention/FlatFileDataStore.java | 10 ++++++++++ .../ryanhamshire/GriefPrevention/GriefPrevention.java | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/me/ryanhamshire/GriefPrevention/FlatFileDataStore.java b/src/me/ryanhamshire/GriefPrevention/FlatFileDataStore.java index 164e7d1..9d6ed6c 100644 --- a/src/me/ryanhamshire/GriefPrevention/FlatFileDataStore.java +++ b/src/me/ryanhamshire/GriefPrevention/FlatFileDataStore.java @@ -23,6 +23,8 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.bukkit.*; @@ -32,6 +34,8 @@ public class FlatFileDataStore extends DataStore private final static String playerDataFolderPath = dataLayerFolderPath + File.separator + "PlayerData"; private final static String claimDataFolderPath = dataLayerFolderPath + File.separator + "ClaimData"; private final static String nextClaimIdFilePath = claimDataFolderPath + File.separator + "_nextClaimID"; + + private final static Pattern uuidpattern = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"); static boolean hasData() { @@ -155,6 +159,12 @@ public class FlatFileDataStore extends DataStore while(line != null) { + //Let's skip the UUID lines from previous versions + Matcher match = uuidpattern.matcher(line.trim()); + if(match.find()) { + inStream.readLine(); + } + //first line is lesser boundary corner location Location lesserBoundaryCorner = this.locationFromString(line); diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 5676948..14a4949 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -689,6 +689,16 @@ public class GriefPrevention extends JavaPlugin //this is the preferred method, as it's simpler than the database scenario if(this.dataStore == null) { + File oldclaimdata = new File(getDataFolder(), "ClaimData"); + if(oldclaimdata.exists()) { + if(!FlatFileDataStore.hasData()) { + File claimdata = new File("plugins" + File.separator + "GriefPreventionData" + File.separator + "ClaimData"); + oldclaimdata.renameTo(claimdata); + File oldplayerdata = new File(getDataFolder(), "PlayerData"); + File playerdata = new File("plugins" + File.separator + "GriefPreventionData" + File.separator + "PlayerData"); + oldplayerdata.renameTo(playerdata); + } + } try { this.dataStore = new FlatFileDataStore();