Fix shops not being shown after re-join

This commit is contained in:
Eric 2018-07-29 14:20:16 +02:00
parent 09fef5b38c
commit 0a06a69e65

View File

@ -23,16 +23,24 @@ public class ShopUpdateListener implements Listener {
@EventHandler @EventHandler
public void onPlayerLeave(PlayerQuitEvent e) { public void onPlayerLeave(PlayerQuitEvent e) {
for (Shop shop : plugin.getShopUtils().getShops()) { // If done without delay, Bukkit#getOnlinePlayers() would still
if (shop.hasItem()) { // contain the player even though he left, so the shop updater
shop.getItem().resetVisible(e.getPlayer()); // would show the shop again.
} new BukkitRunnable(){
if (shop.hasHologram()) { @Override
shop.getHologram().resetVisible(e.getPlayer()); public void run() {
} for (Shop shop : plugin.getShopUtils().getShops()) {
} if (shop.hasItem()) {
shop.getItem().resetVisible(e.getPlayer());
}
if (shop.hasHologram()) {
shop.getHologram().resetVisible(e.getPlayer());
}
}
plugin.getShopUtils().resetPlayerLocation(e.getPlayer()); plugin.getShopUtils().resetPlayerLocation(e.getPlayer());
}
}.runTaskLater(plugin, 1L);
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)