blob: 8add570cdf04f6f1c5ed42e3c4142c8df283d0f4 (
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
97
98
99
100
101
102
103
104
105
106
107
108
109
|
package com.earth2me.essentials.listener;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IReload;
import com.earth2me.essentials.api.ISettings;
import com.earth2me.essentials.perm.GMGroups;
import com.earth2me.essentials.perm.VaultGroups;
import com.earth2me.essentials.settings.General;
import com.earth2me.essentials.settings.GroupsHolder;
import java.util.logging.Level;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
public class EssentialsPluginListener implements Listener, IReload
{
private final transient IEssentials ess;
public EssentialsPluginListener(final IEssentials ess)
{
super();
this.ess = ess;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(final PluginEnableEvent event)
{
checkGroups();
//ess.getPermissionsHandler().checkPermissions();
ess.getCommandHandler().addPlugin(event.getPlugin());
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
{
ess.getLogger().log(Level.INFO, "Payment method found ({0} version: {1})", new Object[]
{
ess.getPaymentMethod().getMethod().getName(), ess.getPaymentMethod().getMethod().getVersion()
});
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(final PluginDisableEvent event)
{
checkGroups();
//ess.getPermissionsHandler().checkPermissions();
ess.getCommandHandler().removePlugin(event.getPlugin());
// Check to see if the plugin thats being disabled is the one we are using
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
{
ess.getPaymentMethod().reset();
ess.getLogger().log(Level.INFO, "Payment method was disabled. No longer accepting payments.");
}
}
@Override
public void onReload()
{
//ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
}
private void checkGroups()
{
ISettings settings = ess.getSettings();
settings.acquireReadLock();
General.GroupStorage storage = General.GroupStorage.FILE;
try
{
storage = settings.getData().getGeneral().getGroupStorage();
}
finally
{
settings.unlock();
}
if (storage == General.GroupStorage.GROUPMANAGER)
{
Plugin groupManager = ess.getServer().getPluginManager().getPlugin("GroupManager");
if (groupManager != null && groupManager.isEnabled() && !(ess.getGroups() instanceof GMGroups))
{
if (ess.getGroups() instanceof GroupsHolder)
{
ess.removeReloadListener((GroupsHolder)ess.getGroups());
}
ess.setGroups(new GMGroups(ess, groupManager));
return;
}
}
if (storage == General.GroupStorage.VAULT)
{
Plugin vault = ess.getServer().getPluginManager().getPlugin("Vault");
if (vault != null && vault.isEnabled() && !(ess.getGroups() instanceof VaultGroups))
{
if (ess.getGroups() instanceof GroupsHolder)
{
ess.removeReloadListener((GroupsHolder)ess.getGroups());
}
ess.setGroups(new VaultGroups(ess));
return;
}
}
if (!(ess.getGroups() instanceof GroupsHolder))
{
ess.setGroups(new GroupsHolder(ess));
ess.addReloadListener((GroupsHolder)ess.getGroups());
}
}
}
|