Fix a bug where the items from the backpack could be dropped on the wrong location with a very very slow database

This commit is contained in:
GeorgH93 2017-02-15 00:09:26 +01:00
parent f8dd837012
commit c96e7a4b59

View File

@ -21,6 +21,8 @@
import at.pcgamingfreaks.Minepacks.Bukkit.Backpack;
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
@ -40,6 +42,8 @@ public void onDeath(PlayerDeathEvent event)
final Player player = event.getEntity();
if (!player.hasPermission("backpack.keepOnDeath"))
{
final World world = player.getWorld();
final Location location = player.getLocation();
plugin.getBackpack(player, new Callback<Backpack>()
{
@Override
@ -50,7 +54,7 @@ public void onResult(Backpack backpack)
{
if(i != null)
{
player.getWorld().dropItemNaturally(player.getLocation(), i);
world.dropItemNaturally(location, i);
backpackInventory.remove(i);
backpack.setChanged();
}