Backup backpacks that failed to load
This commit is contained in:
parent
dd6d439dc1
commit
8fe2365929
|
@ -133,7 +133,7 @@ public abstract class Database implements Listener
|
|||
writeBackup(backpack.getOwner().getName(), getPlayerFormattedUUID(backpack.getOwner()), itsSerializer.getUsedSerializer(), itsSerializer.serialize(backpack.getInventory()));
|
||||
}
|
||||
|
||||
protected void writeBackup(@Nullable String userName, @NotNull String userIdentifier, final int usedSerializer, final @NotNull byte[] data)
|
||||
protected void writeBackup(@Nullable String userName, @NotNull String userIdentifier, final int usedSerializer, final byte[] data)
|
||||
{
|
||||
if(userIdentifier.equalsIgnoreCase(userName)) userName = null;
|
||||
if(userName != null) userIdentifier = userName + "_" + userIdentifier;
|
||||
|
|
|
@ -249,7 +249,8 @@ public abstract class SQL extends Database
|
|||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
try(Connection conn = getConnection(); PreparedStatement ps = conn.prepareStatement(queryGetBP))
|
||||
{
|
||||
ps.setString(1, getPlayerFormattedUUID(player));
|
||||
final String playerUUID = getPlayerFormattedUUID(player);
|
||||
ps.setString(1, fieldPlayerUUID);
|
||||
final int bpID, version;
|
||||
final byte[] data;
|
||||
try(ResultSet rs = ps.executeQuery())
|
||||
|
@ -269,6 +270,10 @@ public abstract class SQL extends Database
|
|||
}
|
||||
|
||||
ItemStack[] its = itsSerializer.deserialize(data, version);
|
||||
if (data != null && data.length != 0 && its == null)
|
||||
{
|
||||
writeBackup(player.getName(), playerUUID, version, data);
|
||||
}
|
||||
final Backpack backpack = (its != null) ? new Backpack(player, its, bpID) : null;
|
||||
plugin.getServer().getScheduler().runTask(plugin, () -> {
|
||||
if(backpack != null)
|
||||
|
|
Loading…
Reference in New Issue