mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-12 13:41:06 +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.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) {
|
||||||
Bukkit.getPluginManager().callEvent(new ShopUpdateEvent());
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Bukkit.getPluginManager().callEvent(new ShopUpdateEvent());
|
||||||
|
}
|
||||||
|
}.runTask(plugin);
|
||||||
lastTime = timeNow;
|
lastTime = timeNow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user