Call ShopUpdateEvent synchronously

This commit is contained in:
Eric 2017-01-05 14:13:07 +01:00
parent 4194c72bd4
commit 4c5ec37588

View File

@ -3,14 +3,18 @@ package de.epiceric.shopchest.utils;
import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.event.ShopUpdateEvent; import de.epiceric.shopchest.event.ShopUpdateEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
public class ShopUpdater extends Thread { public class ShopUpdater extends Thread {
private ShopChest plugin;
private boolean running; private boolean running;
private long maxDelta; private long maxDelta;
private long lastTime; private long lastTime;
public ShopUpdater(ShopChest plugin) { public ShopUpdater(ShopChest plugin) {
this.plugin = plugin;
setMaxDelta(plugin.getShopChestConfig().update_quality.getTime()); setMaxDelta(plugin.getShopChestConfig().update_quality.getTime());
} }
@ -37,7 +41,12 @@ public class ShopUpdater extends Thread {
long timeElapsed = timeNow - lastTime; long timeElapsed = timeNow - lastTime;
if (timeElapsed >= maxDelta) { if (timeElapsed >= maxDelta) {
new BukkitRunnable() {
@Override
public void run() {
Bukkit.getPluginManager().callEvent(new ShopUpdateEvent()); Bukkit.getPluginManager().callEvent(new ShopUpdateEvent());
}
}.runTask(plugin);
lastTime = timeNow; lastTime = timeNow;
} }
} }