summaryrefslogtreecommitdiffstats
path: root/Register/src/com/essentials/register/payment/Methods.java
blob: f47eecb55528e48daf9ed72a29ea425e24fd2ddd (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
package com.essentials.register.payment;

import com.iConomy.iConomy;
import cosine.boseconomy.BOSEconomy;

import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.PluginDescriptionFile;

public class Methods {
    private Method Method = null;
    public Plugin method = null;
    
    public boolean setMethod(Plugin method) {
        PluginManager loader = method.getServer().getPluginManager();

        if(method.isEnabled()) {
            PluginDescriptionFile info = method.getDescription();
            String name = info.getName();

            if(name.equalsIgnoreCase("iconomy")) {
                if(method.getClass().getName().equals("com.iConomy.iConomy"))
                    Method = new MethodiCo5((iConomy)method);
                else { Method = new MethodiCo4((com.nijiko.coelho.iConomy.iConomy)method); }
            } else if(name.equalsIgnoreCase("boseconomy")) {
                Method = new MethodBOSEconomy((BOSEconomy)method);
            } 
        }
        
        if(!hasMethod()) {
            if(loader.getPlugin("iConomy") != null) {
                method =  loader.getPlugin("iConomy");
                if(method.getClass().getName().equals("com.iConomy.iConomy"))
                    Method = new MethodiCo5((iConomy)method);
                else { Method = new MethodiCo4((com.nijiko.coelho.iConomy.iConomy)method); }
            } else if(loader.getPlugin("BOSEconomy") != null) {
                method = loader.getPlugin("BOSEconomy");
                Method = new MethodBOSEconomy((BOSEconomy)method);
            }
        }
        
        return hasMethod();
    }

    public boolean checkDisabled(Plugin method) {
        PluginDescriptionFile info = method.getDescription();
        String name = info.getName();

        if(name.equalsIgnoreCase("iconomy")) {
            if(method.getClass().getName().equals("com.iConomy.iConomy"))
                Method = null;
            else { Method = null; }
        } else if(name.equalsIgnoreCase("boseconomy")) {
            Method = null;
        } else if(name.equalsIgnoreCase("essentials")) {
            Method = null;
        }

        return (Method == null);
    }

    public boolean hasMethod() {
        return (Method != null);
    }

    public Method getMethod() {
        return Method;
    }

}