Deserialize the backpack async

this should fix the lag caused by the plugin on MC 1.14, quick testing showed no problems caused by this
This commit is contained in:
GeorgH93 2019-04-26 02:51:29 +02:00
parent a4fd00f687
commit 7349727cdc
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2018 GeorgH93
* Copyright (C) 2019 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -371,11 +371,13 @@ protected void loadBackpack(final OfflinePlayer player, final Callback<Backpack>
data = null;
}
}
ItemStack[] its = itsSerializer.deserialize(data, version);
final Backpack backpack = (its != null) ? new Backpack(player, its, bpID) : null;
plugin.getServer().getScheduler().runTask(plugin, () -> {
ItemStack[] its = itsSerializer.deserialize(data, version);
if(its != null)
if(backpack != null)
{
callback.onResult(new Backpack(player, its, bpID));
callback.onResult(backpack);
}
else
{