mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 10:22:29 +00:00
Call ShopUpdateEvent synchronously
This commit is contained in:
parent
4194c72bd4
commit
4c5ec37588
@ -3,14 +3,18 @@ package de.epiceric.shopchest.utils;
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.event.ShopUpdateEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class ShopUpdater extends Thread {
|
||||
|
||||
private ShopChest plugin;
|
||||
|
||||
private boolean running;
|
||||
private long maxDelta;
|
||||
private long lastTime;
|
||||
|
||||
public ShopUpdater(ShopChest plugin) {
|
||||
this.plugin = plugin;
|
||||
setMaxDelta(plugin.getShopChestConfig().update_quality.getTime());
|
||||
}
|
||||
|
||||
@ -37,7 +41,12 @@ public class ShopUpdater extends Thread {
|
||||
long timeElapsed = timeNow - lastTime;
|
||||
|
||||
if (timeElapsed >= maxDelta) {
|
||||
Bukkit.getPluginManager().callEvent(new ShopUpdateEvent());
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getPluginManager().callEvent(new ShopUpdateEvent());
|
||||
}
|
||||
}.runTask(plugin);
|
||||
lastTime = timeNow;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user