mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-24 00:51:40 +01:00
Implemented Vault support 🎉
This commit is contained in:
parent
c236e1a3bc
commit
0c75e556b2
11
pom.xml
11
pom.xml
@ -56,6 +56,10 @@
|
|||||||
<id>bstats-repo</id>
|
<id>bstats-repo</id>
|
||||||
<url>http://repo.bstats.org/content/repositories/releases/</url>
|
<url>http://repo.bstats.org/content/repositories/releases/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>vault-repo</id>
|
||||||
|
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -97,6 +101,13 @@
|
|||||||
<artifactId>mongodb-driver</artifactId>
|
<artifactId>mongodb-driver</artifactId>
|
||||||
<version>3.8.0</version>
|
<version>3.8.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Vault -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -10,6 +10,7 @@ import world.bentobox.bentobox.api.configuration.WorldSettings;
|
|||||||
import world.bentobox.bentobox.api.events.BentoBoxReadyEvent;
|
import world.bentobox.bentobox.api.events.BentoBoxReadyEvent;
|
||||||
import world.bentobox.bentobox.api.user.Notifier;
|
import world.bentobox.bentobox.api.user.Notifier;
|
||||||
import world.bentobox.bentobox.commands.BentoBoxCommand;
|
import world.bentobox.bentobox.commands.BentoBoxCommand;
|
||||||
|
import world.bentobox.bentobox.hooks.VaultHook;
|
||||||
import world.bentobox.bentobox.listeners.BannedVisitorCommands;
|
import world.bentobox.bentobox.listeners.BannedVisitorCommands;
|
||||||
import world.bentobox.bentobox.listeners.BlockEndDragon;
|
import world.bentobox.bentobox.listeners.BlockEndDragon;
|
||||||
import world.bentobox.bentobox.listeners.DeathListener;
|
import world.bentobox.bentobox.listeners.DeathListener;
|
||||||
@ -135,6 +136,7 @@ public class BentoBox extends JavaPlugin {
|
|||||||
|
|
||||||
// Load hooks
|
// Load hooks
|
||||||
hooksManager = new HooksManager(this);
|
hooksManager = new HooksManager(this);
|
||||||
|
hooksManager.registerHook(new VaultHook());
|
||||||
|
|
||||||
// Fire plugin ready event
|
// Fire plugin ready event
|
||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
@ -322,4 +324,12 @@ public class BentoBox extends JavaPlugin {
|
|||||||
return hooksManager;
|
return hooksManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method to get the VaultHook.
|
||||||
|
* @return the Vault hook
|
||||||
|
*/
|
||||||
|
public Optional<VaultHook> getVault() {
|
||||||
|
return Optional.ofNullable((VaultHook) hooksManager.getHook("Vault").orElse(null));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
37
src/main/java/world/bentobox/bentobox/hooks/VaultHook.java
Normal file
37
src/main/java/world/bentobox/bentobox/hooks/VaultHook.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package world.bentobox.bentobox.hooks;
|
||||||
|
|
||||||
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import world.bentobox.bentobox.api.hooks.Hook;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Poslovitch
|
||||||
|
*/
|
||||||
|
public class VaultHook extends Hook {
|
||||||
|
|
||||||
|
private Economy economy;
|
||||||
|
|
||||||
|
public VaultHook() {
|
||||||
|
super("Vault");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hook() {
|
||||||
|
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
|
if (rsp == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
economy = rsp.getProvider();
|
||||||
|
return economy != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFailureCause() {
|
||||||
|
return "no plugin supporting economy has been found";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Economy getEconomy() {
|
||||||
|
return economy;
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ api-version: 1.13
|
|||||||
|
|
||||||
authors: [tastybento, Poslovitch]
|
authors: [tastybento, Poslovitch]
|
||||||
|
|
||||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI]
|
softdepend: [Vault, PlaceholderAPI, MVdWPlaceholderAPI]
|
||||||
|
|
||||||
loadbefore: [Multiverse-Core]
|
loadbefore: [Multiverse-Core]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user