Merge remote-tracking branch 'origin/master'

Former-commit-id: 3fb994d1ca982e53b3cba33850f7ffca091c9002
This commit is contained in:
sandtechnology committed 2020-03-20 22:00:34 +08:00
commit 1163d1a196
1 file changed
+15 -3
@@ -62,7 +62,10 @@ public class ContainerShop implements Shop {
private volatile boolean isLoaded = false;
@EqualsAndHashCode.Exclude
private volatile boolean isDeleted= false;
private volatile boolean isDeleted = false;
@EqualsAndHashCode.Exclude
private volatile boolean createBackup = false;
private ShopModerator moderator;
@@ -928,6 +931,7 @@ public class ContainerShop implements Shop {
/**
* @return The chest this shop is based on.
*/
public @Nullable Inventory getInventory() {
try {
if (location.getBlock().getState().getType() == Material.ENDER_CHEST
@@ -949,8 +953,16 @@ public class ContainerShop implements Shop {
container = (InventoryHolder) this.location.getBlock().getState();
return container.getInventory();
} catch (Exception e) {
this.delete();
Util.debugLog("Inventory doesn't exist anymore: " + this + " shop was removed.");
if (!createBackup) {
createBackup = Util.backupDatabase();
if (createBackup) {
this.delete();
Util.debugLog("Inventory doesn't exist anymore: " + this + " shop was removed.");
}
} else {
this.delete();
Util.debugLog("Inventory doesn't exist anymore: " + this + " shop was removed.");
}
return null;
}
}