summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-03-28 14:54:48 +0100
committerKHobbits <rob@khobbits.co.uk>2012-03-28 15:03:18 +0100
commit9d545dcbf1fb95b6c2185de6f40e72708bdc53cd (patch)
tree21927c5b65e01947e5a7c9bda202a1db31007c77
parent5b626614048a7aed902b3ea3a3834c54447cbd27 (diff)
downloadEssentials-9d545dcbf1fb95b6c2185de6f40e72708bdc53cd.tar
Essentials-9d545dcbf1fb95b6c2185de6f40e72708bdc53cd.tar.gz
Essentials-9d545dcbf1fb95b6c2185de6f40e72708bdc53cd.tar.lz
Essentials-9d545dcbf1fb95b6c2185de6f40e72708bdc53cd.tar.xz
Essentials-9d545dcbf1fb95b6c2185de6f40e72708bdc53cd.zip
Don't register jail listeners, if no jails are set.
-rw-r--r--Essentials/src/com/earth2me/essentials/Jails.java21
-rw-r--r--Essentials/src/com/earth2me/essentials/storage/AsyncStorageObjectHolder.java8
2 files changed, 27 insertions, 2 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Jails.java b/Essentials/src/com/earth2me/essentials/Jails.java
index 65f486f42..00c9d8999 100644
--- a/Essentials/src/com/earth2me/essentials/Jails.java
+++ b/Essentials/src/com/earth2me/essentials/Jails.java
@@ -26,16 +26,17 @@ import org.bukkit.plugin.PluginManager;
public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Jails> implements IJails
{
private static final transient Logger LOGGER = Bukkit.getLogger();
+ private static transient boolean enabled = false;
public Jails(final IEssentials ess)
{
super(ess, com.earth2me.essentials.settings.Jails.class);
reloadConfig();
- registerListeners();
}
private void registerListeners()
{
+ enabled = true;
final PluginManager pluginManager = ess.getServer().getPluginManager();
final JailBlockListener blockListener = new JailBlockListener();
final JailPlayerListener playerListener = new JailPlayerListener();
@@ -50,6 +51,24 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
@Override
+ public void finishRead()
+ {
+ if (enabled == false && getCount() > 0)
+ {
+ registerListeners();
+ }
+ }
+
+ @Override
+ public void finishWrite()
+ {
+ if (enabled == false)
+ {
+ registerListeners();
+ }
+ }
+
+ @Override
public Location getJail(final String jailName) throws Exception
{
acquireReadLock();
diff --git a/Essentials/src/com/earth2me/essentials/storage/AsyncStorageObjectHolder.java b/Essentials/src/com/earth2me/essentials/storage/AsyncStorageObjectHolder.java
index 31c61a63f..b651dd40b 100644
--- a/Essentials/src/com/earth2me/essentials/storage/AsyncStorageObjectHolder.java
+++ b/Essentials/src/com/earth2me/essentials/storage/AsyncStorageObjectHolder.java
@@ -79,7 +79,11 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
{
new StorageObjectDataReader();
}
-
+
+ public abstract void finishRead();
+
+ public abstract void finishWrite();
+
public abstract File getStorageFile();
@@ -101,6 +105,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
public void onFinish()
{
unlock();
+ finishWrite();
}
}
@@ -126,6 +131,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
data = object;
}
rwl.writeLock().unlock();
+ finishRead();
}
@Override