|
4 | 4 | import com.google.gson.JsonParser; |
5 | 5 | import com.zaxxer.hikari.HikariConfig; |
6 | 6 | import com.zaxxer.hikari.HikariDataSource; |
7 | | -import net.milkbowl.vault.economy.Economy; |
8 | 7 | import org.bukkit.NamespacedKey; |
9 | 8 | import org.bukkit.OfflinePlayer; |
10 | 9 | import org.bukkit.command.CommandExecutor; |
11 | 10 | import org.bukkit.command.CommandSender; |
12 | 11 | import org.bukkit.command.PluginCommand; |
13 | 12 | import org.bukkit.event.Listener; |
14 | | -import org.bukkit.plugin.RegisteredServiceProvider; |
15 | | -import org.bukkit.plugin.ServicePriority; |
16 | 13 | import org.bukkit.plugin.java.JavaPlugin; |
17 | 14 | import org.bukkit.scheduler.BukkitTask; |
18 | 15 | import org.jetbrains.annotations.NotNull; |
@@ -64,50 +61,6 @@ public final class BankAccounts extends JavaPlugin { |
64 | 61 | return dbSource; |
65 | 62 | } |
66 | 63 |
|
67 | | - /** |
68 | | - * Check if vault plugin is present |
69 | | - */ |
70 | | - public boolean vaultEnabled() { |
71 | | - return config().integrationsVaultEnabled() && getServer().getPluginManager().getPlugin("Vault") != null; |
72 | | - } |
73 | | - |
74 | | - private @Nullable Economy economy; |
75 | | - |
76 | | - public boolean hasEconomy() { |
77 | | - return economy != null; |
78 | | - } |
79 | | - |
80 | | - public @NotNull Economy getEconomy() { |
81 | | - if (!hasEconomy()) throw new IllegalStateException("Vault is not initialized"); |
82 | | - if (!vaultEnabled()) throw new IllegalStateException("Vault integration is not enabled"); |
83 | | - return economy; |
84 | | - } |
85 | | - |
86 | | - public void setupVault() { |
87 | | - if (!vaultEnabled()) { |
88 | | - getLogger().log(Level.WARNING, "Vault not found or not enabled, Vault integration will not work."); |
89 | | - return; |
90 | | - } |
91 | | - |
92 | | - final @NotNull Optional<@NotNull RegisteredServiceProvider<@NotNull Economy>> rsp = Optional.ofNullable(getServer().getServicesManager().getRegistration(Economy.class)); |
93 | | - if (rsp.isPresent()) { |
94 | | - final @NotNull Economy foreignEconomy = rsp.get().getProvider(); |
95 | | - getLogger().log(Level.WARNING, "Economy already registered by " + rsp.get().getPlugin().getName()); |
96 | | - getServer().getServicesManager().unregister(foreignEconomy); |
97 | | - getLogger().log(Level.WARNING, "Unregistered economy provider " + rsp.get().getPlugin().getName()); |
98 | | - } |
99 | | - |
100 | | - try { |
101 | | - getLogger().log(Level.INFO, "Vault found. Enabling integration."); |
102 | | - this.economy = new VaultIntegration(); |
103 | | - getServer().getServicesManager().register(Economy.class, getEconomy(), this, ServicePriority.Normal); |
104 | | - } |
105 | | - catch (final @NotNull Exception e) { |
106 | | - getLogger().log(Level.WARNING, "Failed to register vault economy.", e); |
107 | | - } |
108 | | - |
109 | | - } |
110 | | - |
111 | 64 | @Override |
112 | 65 | public void onEnable() { |
113 | 66 | saveDefaultConfig(); |
@@ -146,11 +99,7 @@ public void onEnable() { |
146 | 99 | getLogger().log(Level.INFO, "PlaceholderAPI not found. Skipping integration."); |
147 | 100 | } |
148 | 101 |
|
149 | | - |
150 | | - if (getInstance().vaultEnabled()) |
151 | | - getServer().getScheduler().scheduleSyncDelayedTask(this, () -> { |
152 | | - getInstance().setupVault(); |
153 | | - }); |
| 102 | + VaultIntegration.setup(); |
154 | 103 | } |
155 | 104 |
|
156 | 105 | @Override |
|
0 commit comments