summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java
blob: 7115bb04ca7598bb503be214bb68bda9d4c98698 (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
package com.nijikokun.bukkit.Permissions;

import com.nijiko.permissions.PermissionHandler;
import java.util.logging.Logger;
//import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.permissions.NijikoPermissionsProxy;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;


public class Permissions extends JavaPlugin
{
	public static final Logger log = Logger.getLogger("Fake Permissions");
	public static String name = "Permissions";
	public static String codename = "Hacked Permissions by AnjoCaido";
	public static String version = "2.0";
	public static PermissionHandler Security = null;

	@Override
	public void onDisable()
	{
		PluginDescriptionFile pdfFile = this.getDescription();
		System.out.println("Fake " + pdfFile.getName() + " version " + pdfFile.getVersion() + " is disabled!");
	}

	@Override
	public void onEnable()
	{
		PluginDescriptionFile pdfFile = this.getDescription();

		if (Security == null)
		{
			//make sure we have only one instance
			Security = new NijikoPermissionsProxy(null);
		}

		Plugin p = (this.getServer() == null) ? null : this.getServer().getPluginManager().getPlugin("GroupManager");
		if (p != null)
		{
			if (p.isEnabled())
			{
				setGM(p);
			}
			else
			{
				if (this.getServer() != null)
				{
					this.getServer().getPluginManager().registerEvents(new OverrideListener(this), this);
				}
			}
		}
		else
		{
			System.err.println("OOOPS! Fake " + pdfFile.getName() + " version " + pdfFile.getVersion() + " couldn't find GroupManager!");
			this.getPluginLoader().disablePlugin(this);
		}

		if (pdfFile != null)
		{
			System.out.println("Fake " + pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
		}
	}

	public void setGM(final Plugin p)
	{
		//GroupManager groupManager = (GroupManager) p;
		((NijikoPermissionsProxy)Security).setGM(p);
	}

	public PermissionHandler getHandler()
	{
		if (Security == null)
		{
			Security = new NijikoPermissionsProxy(null);
		}
		return Security;
	}

	public void setupPermissions()
	{
		if (Security == null)
		{
			Security = new NijikoPermissionsProxy(null);
		}
	}
}