2017-01-04 17:07:00 +01:00
|
|
|
package de.epiceric.shopchest.listeners;
|
|
|
|
|
|
|
|
import de.epiceric.shopchest.ShopChest;
|
2017-04-10 20:05:31 +02:00
|
|
|
import de.epiceric.shopchest.utils.Callback;
|
2017-01-04 17:07:00 +01:00
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.Listener;
|
2017-04-10 20:05:31 +02:00
|
|
|
import org.bukkit.event.world.WorldLoadEvent;
|
2017-01-04 17:07:00 +01:00
|
|
|
|
|
|
|
public class ShopUpdateListener implements Listener {
|
|
|
|
|
|
|
|
private ShopChest plugin;
|
|
|
|
|
|
|
|
public ShopUpdateListener(ShopChest plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
|
|
|
|
2017-04-10 20:05:31 +02:00
|
|
|
@EventHandler
|
|
|
|
public void onWorldLoad(WorldLoadEvent e) {
|
|
|
|
final String worldName = e.getWorld().getName();
|
|
|
|
|
|
|
|
plugin.getShopUtils().reloadShops(false, false, new Callback(plugin) {
|
|
|
|
@Override
|
|
|
|
public void onResult(Object result) {
|
|
|
|
int amount = -1;
|
|
|
|
if (result instanceof Integer) {
|
|
|
|
amount = (int) result;
|
|
|
|
}
|
|
|
|
plugin.getLogger().info(String.format("Reloaded %d shops because a new world '%s' was loaded", amount, worldName));
|
|
|
|
plugin.debug(String.format("Reloaded %d shops because a new world '%s' was loaded", amount, worldName));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-01-04 17:07:00 +01:00
|
|
|
}
|