Charge money/give money when buying/selling
This commit is contained in:
1 parent
4b5e09c553
commit
5ce955d6ee
4 files changed
+54
-10
No files matched your search
@@ -8,16 +8,23 @@ import com.alttd.config.VillagerConfig;
|
||||
import com.alttd.config.WorthConfig;
|
||||
import com.alttd.events.VillagerInteract;
|
||||
import com.alttd.util.Logger;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class VillagerUI extends JavaPlugin {
|
||||
|
||||
public static VillagerUI instance;
|
||||
private static Economy econ = null;
|
||||
|
||||
public static VillagerUI getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static Economy getEcon() {
|
||||
return econ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
instance = this;
|
||||
@@ -30,6 +37,11 @@ public class VillagerUI extends JavaPlugin {
|
||||
Config.reload();
|
||||
VillagerConfig.reload();
|
||||
WorthConfig.reload();
|
||||
if (!setupEconomy()) {
|
||||
Logger.severe("% - Unable to find vault", getDescription().getName());
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
Database.init();
|
||||
Logger.info("--------------------------------------------------");
|
||||
Logger.info("Villager UI started");
|
||||
@@ -41,4 +53,13 @@ public class VillagerUI extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new VillagerInteract(), this);
|
||||
}
|
||||
|
||||
private boolean setupEconomy() {
|
||||
if (getServer().getPluginManager().getPlugin("Vault") == null) return false;
|
||||
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp == null) return false;
|
||||
econ = rsp.getProvider();
|
||||
|
||||
return econ != null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user