2015-08-21 15:10:08 +02:00
|
|
|
/**
|
|
|
|
* Jobs Plugin for Bukkit
|
|
|
|
* Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.gamingmesh.jobs;
|
|
|
|
|
|
|
|
import net.milkbowl.vault.economy.Economy;
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
|
|
|
|
|
|
import com.gamingmesh.jobs.economy.BlackholeEconomy;
|
|
|
|
import com.gamingmesh.jobs.economy.VaultEconomy;
|
2016-11-20 10:53:19 +01:00
|
|
|
import com.gamingmesh.jobs.economy.IConomyAdapter;
|
2015-08-21 15:10:08 +02:00
|
|
|
|
|
|
|
public class HookEconomyTask implements Runnable {
|
2016-08-08 16:36:56 +02:00
|
|
|
private Jobs plugin;
|
2015-08-21 15:10:08 +02:00
|
|
|
|
2016-08-08 16:36:56 +02:00
|
|
|
public HookEconomyTask(Jobs plugin) {
|
2015-11-25 16:14:48 +01:00
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
2015-08-21 15:10:08 +02:00
|
|
|
|
2016-06-25 17:56:59 +02:00
|
|
|
@Override
|
2015-11-25 16:14:48 +01:00
|
|
|
public void run() {
|
2015-08-21 15:10:08 +02:00
|
|
|
|
2016-11-19 12:11:04 +01:00
|
|
|
if (setVault())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (setIConomy())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// no Economy found
|
2016-06-25 14:51:21 +02:00
|
|
|
Jobs.setEconomy(this.plugin, new BlackholeEconomy());
|
|
|
|
Bukkit.getServer().getLogger().severe("==================== " + this.plugin.getDescription().getName() + " ====================");
|
2016-11-19 12:11:04 +01:00
|
|
|
Bukkit.getServer().getLogger().severe("Vault or Iconomy is required by this plugin for economy support!");
|
|
|
|
Bukkit.getServer().getLogger().severe("Please install them first!");
|
|
|
|
Bukkit.getServer().getLogger().severe("You can find the latest versions here:");
|
2016-03-30 15:42:36 +02:00
|
|
|
Bukkit.getServer().getLogger().severe("http://dev.bukkit.org/bukkit-plugins/vault/");
|
2016-11-19 12:11:04 +01:00
|
|
|
Bukkit.getServer().getLogger().severe("https://dev.bukkit.org/bukkit-plugins/iconomy-7/");
|
2015-11-25 16:14:48 +01:00
|
|
|
Bukkit.getServer().getLogger().severe("==============================================");
|
|
|
|
}
|
2016-12-02 14:00:58 +01:00
|
|
|
|
2016-11-19 12:11:04 +01:00
|
|
|
private boolean setVault() {
|
|
|
|
Plugin eco = Bukkit.getServer().getPluginManager().getPlugin("Vault");
|
|
|
|
if (eco == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
RegisteredServiceProvider<Economy> provider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
|
|
|
if (provider == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Economy economy = provider.getProvider();
|
|
|
|
if (economy == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Jobs.setEconomy(this.plugin, new VaultEconomy(economy));
|
|
|
|
Jobs.consoleMsg("&e[" + this.plugin.getDescription().getName() + "] Successfully linked with Vault.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean setIConomy() {
|
|
|
|
Plugin p = Bukkit.getServer().getPluginManager().getPlugin("iConomy");
|
|
|
|
if (p == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
try {
|
2016-11-20 10:53:19 +01:00
|
|
|
Jobs.setEconomy(this.plugin, new IConomyAdapter((com.iCo6.iConomy) p));
|
2016-11-19 12:11:04 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
Jobs.consoleMsg("&e[" + this.plugin.getDescription().getName() + "] UNKNOWN iConomy version.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Jobs.consoleMsg("&e[" + this.plugin.getDescription().getName() + "] Successfully linked with iConomy! Version: " + p.getDescription().getVersion());
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-08-21 15:10:08 +02:00
|
|
|
}
|