1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 22:13:25 +01:00
Jobs/com/gamingmesh/jobs/HookEconomyTask.java

66 lines
2.6 KiB
Java
Raw Normal View History

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.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import com.gamingmesh.jobs.economy.BlackholeEconomy;
import com.gamingmesh.jobs.economy.VaultEconomy;
public class HookEconomyTask implements Runnable {
2015-11-25 16:14:48 +01:00
private JobsPlugin plugin;
2015-08-21 15:10:08 +02:00
2015-11-25 16:14:48 +01:00
public HookEconomyTask(JobsPlugin plugin) {
this.plugin = plugin;
}
2015-08-21 15:10:08 +02:00
2015-11-25 16:14:48 +01:00
public void run() {
Plugin eco = Bukkit.getServer().getPluginManager().getPlugin("Vault");
if (eco != null) {
RegisteredServiceProvider<Economy> provider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (provider != null) {
Economy economy = provider.getProvider();
if (economy != null) {
2016-06-25 14:51:21 +02:00
Jobs.setEconomy(this.plugin, new VaultEconomy(economy));
String message = ChatColor.translateAlternateColorCodes('&', "&e[" + this.plugin.getDescription().getName() + "] Successfully linked with Vault.");
2015-11-25 16:14:48 +01:00
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
console.sendMessage(message);
return;
2015-08-21 15:10:08 +02:00
}
2015-11-25 16:14:48 +01:00
}
2015-08-21 15:10:08 +02:00
}
2015-11-25 16:14:48 +01:00
// no Vault found
2016-06-25 14:51:21 +02:00
Jobs.setEconomy(this.plugin, new BlackholeEconomy());
Bukkit.getServer().getLogger().severe("==================== " + this.plugin.getDescription().getName() + " ====================");
2015-11-25 16:14:48 +01:00
Bukkit.getServer().getLogger().severe("Vault is required by this plugin for economy support!");
Bukkit.getServer().getLogger().severe("Please install Vault and economy manager first!");
2015-11-25 16:14:48 +01:00
Bukkit.getServer().getLogger().severe("You can find the latest version here:");
2016-03-30 15:42:36 +02:00
Bukkit.getServer().getLogger().severe("http://dev.bukkit.org/bukkit-plugins/vault/");
2015-11-25 16:14:48 +01:00
Bukkit.getServer().getLogger().severe("==============================================");
}
2015-08-21 15:10:08 +02:00
}