summaryrefslogtreecommitdiffstats
path: root/EssentialsiConomyBridge5/src/com/iConomy/iConomy.java
blob: 6cf7eb6d8085699ca6a7e6f2465978172a66a4ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.iConomy;

import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.api.Economy;
import com.iConomy.system.Account;
import org.bukkit.plugin.java.JavaPlugin;
import com.iConomy.system.Bank;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;


/**
 * This is not iConomy and I take NO credit for iConomy!
 * This is FayConomy, a iConomy Essentials Eco bridge!
 * @author Xeology
 */
public class iConomy extends JavaPlugin
{
	public static Bank Bank = null;
	public static boolean Banking = true;
	public static boolean BankingMultiple = true;
	private static final Logger logger = Logger.getLogger("Minecraft");

	@Override
	public void onDisable()
	{
	}

	@Override
	public void onEnable()
	{
		Bank = new Bank("hello");
		PluginManager pm = this.getServer().getPluginManager();
		Plugin p = pm.getPlugin("Essentials");
		if (p != null)
		{
			if (!pm.isPluginEnabled(p))
			{
				pm.enablePlugin(p);
			}
		}

		String version = this.getDescription().getDescription().replaceAll(".*: ", "");
		if (!version.equals(Essentials.getStatic().getDescription().getVersion()))
		{
			logger.log(Level.WARNING, "Version mismatch! Please update all Essentials jars to the same version.");
		}
		Essentials.getStatic().setIConomyFallback(false);



		logger.info("Loaded " + this.getDescription().getDescription() + " by " + Essentials.AUTHORS);
		logger.info("Make sure you don't have iConomy installed, if you use this.");
	}

	//Fake bank
	public static Bank getBank()
	{
		return Bank;
	}

	public static String format(double amount)
	{
		return Economy.format(amount);
	}

	public static String format(String account)
	{
		return getAccount(account).getHoldings().toString();
	}

	public static String format(String bank, String account)
	{
		return (new Bank(bank)).getAccount(account).getHoldings().toString();
	}

	public static Account getAccount(String name)
	{
		return Bank.getAccount(name);

	}

	public static boolean hasAccount(String name)
	{
		if (!existCheck.exist(name))
		{
			if (!Economy.accountExist(name))
			{
				Economy.newAccount(name);
			}
		}
		return true;
	}
}