mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2024-12-31 18:17:49 +01:00
Bugfix
This commit is contained in:
parent
a7c12782d5
commit
7fe9445360
@ -120,10 +120,14 @@ public void getBackpack(final OfflinePlayer player, final Callback<Backpack> cal
|
||||
@Override
|
||||
public void onResult(Backpack backpack)
|
||||
{
|
||||
if(backpack == null)
|
||||
{
|
||||
backpack = new Backpack(player);
|
||||
}
|
||||
backpacks.put(player, backpack);
|
||||
callback.onResult(backpack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail()
|
||||
{
|
||||
Backpack backpack = new Backpack(player);
|
||||
backpacks.put(player, backpack);
|
||||
callback.onResult(backpack);
|
||||
}
|
||||
@ -149,12 +153,14 @@ public void asyncLoadBackpack(final OfflinePlayer player)
|
||||
@Override
|
||||
public void onResult(Backpack backpack)
|
||||
{
|
||||
if(backpack == null)
|
||||
{
|
||||
backpack = new Backpack(player);
|
||||
}
|
||||
backpacks.put(player, backpack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail()
|
||||
{
|
||||
backpacks.put(player, new Backpack(player));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -176,11 +182,21 @@ public void saveBackpack(Backpack backpack) {}
|
||||
|
||||
protected void loadBackpack(final OfflinePlayer player, final Callback<Backpack> callback)
|
||||
{
|
||||
callback.onResult(loadBackpack(player));
|
||||
Backpack loadedBackpack = loadBackpack(player);
|
||||
if(loadedBackpack == null)
|
||||
{
|
||||
callback.onFail();
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.onResult(loadedBackpack);
|
||||
}
|
||||
}
|
||||
|
||||
public interface Callback<T>
|
||||
{
|
||||
void onResult(T done);
|
||||
|
||||
void onFail();
|
||||
}
|
||||
}
|
@ -215,7 +215,14 @@ public void run()
|
||||
public void run()
|
||||
{
|
||||
ItemStack[] its = (data != null) ? itsSerializer.deserialize(data, version) : null;
|
||||
callback.onResult((its != null) ? new Backpack(player, its, bpID) : null);
|
||||
if(its != null)
|
||||
{
|
||||
callback.onResult(new Backpack(player, its, bpID));
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.onFail();
|
||||
}
|
||||
}
|
||||
});
|
||||
rs.close();
|
||||
|
@ -60,6 +60,7 @@ protected void updateQuerysForDialect()
|
||||
}
|
||||
Query_DeleteOldBackpacks = "DELETE FROM `{TableBackpacks}` WHERE `{FieldBPLastUpdate}` < DATE('now', '-{VarMaxAge} days')";
|
||||
Query_UpdateBP = Query_UpdateBP.replaceAll("\\{NOW\\}", "DATE('now')");
|
||||
Query_UpdatePlayerAdd = Query_UpdatePlayerAdd.replaceAll("INSERT IGNORE INTO", "INSERT OR IGNORE INTO");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,6 +69,12 @@ public void onResult(Backpack backpack)
|
||||
}
|
||||
backpack.save(); // We have to save it now!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail()
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,12 @@ public void onResult(Backpack backpack)
|
||||
{
|
||||
openBackpack(opener, backpack, editable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail()
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,12 @@ public void onResult(Backpack backpack)
|
||||
player.sendMessage(plugin.Message_InvalidBackpack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail()
|
||||
{
|
||||
player.sendMessage(plugin.Message_InvalidBackpack);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user