mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-21 11:45:11 +01:00
update vault impl
This commit is contained in:
parent
bbcb8f0c21
commit
20caac8347
@ -18,6 +18,7 @@ import com.badbones69.crazyauctions.currency.VaultSupport;
|
||||
import com.badbones69.crazyauctions.tasks.InventoryManager;
|
||||
import com.badbones69.crazyauctions.tasks.UserManager;
|
||||
import com.ryderbelserion.vital.paper.Vital;
|
||||
import com.ryderbelserion.vital.paper.api.enums.Support;
|
||||
import com.ryderbelserion.vital.paper.util.scheduler.FoliaRunnable;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@ -40,8 +41,18 @@ public class CrazyAuctions extends Vital {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (!getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||
getLogger().severe("Vault was not found so the plugin will now disable.");
|
||||
if (!Support.vault.isEnabled()) {
|
||||
getLogger().severe("Vault was not found, so the plugin will now disable.");
|
||||
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.support = new VaultSupport();
|
||||
|
||||
if (!this.support.setupEconomy()) {
|
||||
getLogger().severe("An economy provider was not found, so the plugin will disable.");
|
||||
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
|
||||
@ -57,12 +68,14 @@ public class CrazyAuctions extends Vital {
|
||||
|
||||
this.userManager = new UserManager();
|
||||
this.userManager.updateAuctionsCache();
|
||||
this.userManager.updateExpiredCache();
|
||||
|
||||
// we want to update this cache, after the cache above... because we will also calculate if items are expired!
|
||||
new FoliaRunnable(getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
userManager.updateAuctionsCache();
|
||||
userManager.updateExpiredCache();
|
||||
|
||||
for (final Player player : getServer().getOnlinePlayers()) {
|
||||
final Inventory inventory = player.getInventory();
|
||||
@ -103,9 +116,6 @@ public class CrazyAuctions extends Vital {
|
||||
}
|
||||
}
|
||||
|
||||
this.support = new VaultSupport();
|
||||
this.support.loadVault();
|
||||
|
||||
Messages.addMissingMessages();
|
||||
|
||||
new MetricsWrapper(this, 4624);
|
||||
|
@ -17,10 +17,12 @@ public class VaultSupport {
|
||||
return this.vault;
|
||||
}
|
||||
|
||||
public void loadVault() {
|
||||
public boolean setupEconomy() {
|
||||
RegisteredServiceProvider<Economy> serviceProvider = this.plugin.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
|
||||
if (serviceProvider != null) this.vault = serviceProvider.getProvider();
|
||||
|
||||
return this.vault != null;
|
||||
}
|
||||
|
||||
public long getMoney(@NotNull Player player) {
|
||||
|
Loading…
Reference in New Issue
Block a user