Skip to content

Commit

Permalink
Fix NPE when restarting the server when no shops exist
Browse files Browse the repository at this point in the history
  • Loading branch information
weaves7 committed Mar 29, 2020
1 parent ed05d88 commit 38c3d6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private Storage(File ymlFile) {
if(!ymlFile.exists()) {
try {
ymlFile.createNewFile();
Save();
} catch(IOException ex) {
SignShop.log("Could not create sellers.yml", Level.WARNING);
}
Expand Down Expand Up @@ -276,11 +277,13 @@ public final void Save() {
Map<String, Object> tempSellers = new HashMap<>();
FileConfiguration config = new YamlConfiguration();

for(Seller seller : Storage.sellers.values()) {
// YML Parser really does not like dots in the name
String signLocation = signshopUtil.convertLocationToString(seller.getSignLocation()).replace(".", "");
if (sellers != null) {
for(Seller seller : Storage.sellers.values()) {
// YML Parser really does not like dots in the name
String signLocation = signshopUtil.convertLocationToString(seller.getSignLocation()).replace(".", "");

tempSellers.put(signLocation, seller.getSerializedData());
tempSellers.put(signLocation, seller.getSerializedData());
}
}

config.set("sellers", tempSellers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ private static void convertData(FileConfiguration sellers) {
}
sellers.set(miscPath.toString(), newMisc);
}
sellers.set("DataVersion", SignShop.DATA_VERSION);
sellers.save(sellersFile);
}
sellers.set("DataVersion", SignShop.DATA_VERSION);
sellers.save(sellersFile);
SignShop.log("Data conversion of " + shops.size() + " shops has finished.", Level.INFO);
} catch (IOException e) {
SignShop.log("Error converting data!", Level.WARNING);
Expand Down

0 comments on commit 38c3d6f

Please sign in to comment.