Stopped being dumb and denying bukkit of it's precious invisible constraints for ConfigurationSerializable. Fixes #827.

This commit is contained in:
Jeremy Wood 2012-08-13 13:51:42 -04:00
parent eb1dc502cd
commit 29d97274fe
2 changed files with 16 additions and 13 deletions

View File

@ -456,8 +456,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
MultiverseCoreConfiguration wantedConfig = null; MultiverseCoreConfiguration wantedConfig = null;
try { try {
wantedConfig = (MultiverseCoreConfiguration) multiverseConfig.get("multiverse-configuration"); wantedConfig = (MultiverseCoreConfiguration) multiverseConfig.get("multiverse-configuration");
} catch (Exception e) { } catch (Exception ignore) {
// We're just thinking "no risk no fun" and therefore have to catch and forget this exception
} finally { } finally {
Thread thread = Thread.currentThread(); Thread thread = Thread.currentThread();
if (configLock.isLocked()) { if (configLock.isLocked()) {
@ -466,7 +465,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
configLock.lock(); configLock.lock();
try { try {
//log(Level.FINER, "Setting config on thread: " + thread); //log(Level.FINER, "Setting config on thread: " + thread);
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration(this) : wantedConfig); config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
} finally { } finally {
configLock.unlock(); configLock.unlock();
} }

View File

@ -63,20 +63,16 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
@Property @Property
private int teleportcooldown; private int teleportcooldown;
public MultiverseCoreConfiguration(MultiverseCore core) { public MultiverseCoreConfiguration() {
super(); super();
this.core = core;
MultiverseCoreConfiguration.setInstance(this); MultiverseCoreConfiguration.setInstance(this);
} }
public MultiverseCoreConfiguration(MultiverseCore core, Map<String, Object> values) { public MultiverseCoreConfiguration(Map<String, Object> values) {
super(values); super(values);
this.core = core;
MultiverseCoreConfiguration.setInstance(this); MultiverseCoreConfiguration.setInstance(this);
} }
private MultiverseCore core;
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -100,10 +96,18 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
*/ */
@Override @Override
public boolean setConfigProperty(String property, String value) { public boolean setConfigProperty(String property, String value) {
Thread thread = Thread.currentThread();
if (propertyLock.isLocked()) {
MultiverseCore.staticLog(Level.FINEST, "propertyLock is locked when attempting to set a config property on thread: " + thread);
}
propertyLock.lock();
try { try {
MultiverseCore.staticLog(Level.FINEST, "Setting a config proprerty on thread: " + thread);
return this.setProperty(property, value, true); return this.setProperty(property, value, true);
} catch (NoSuchPropertyException e) { } catch (NoSuchPropertyException e) {
return false; return false;
} finally {
propertyLock.unlock();
} }
} }
@ -132,11 +136,11 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
public boolean getPrefixChat() { public boolean getPrefixChat() {
Thread thread = Thread.currentThread(); Thread thread = Thread.currentThread();
if (propertyLock.isLocked()) { if (propertyLock.isLocked()) {
core.log(Level.FINEST, "propertyLock is locked when attempting to get prefixchat on thread: " + thread); MultiverseCore.staticLog(Level.FINEST, "propertyLock is locked when attempting to get prefixchat on thread: " + thread);
} }
propertyLock.lock(); propertyLock.lock();
try { try {
core.log(Level.FINEST, "Getting prefixchat on thread: " + thread); MultiverseCore.staticLog(Level.FINEST, "Getting prefixchat on thread: " + thread);
return this.prefixchat; return this.prefixchat;
} finally { } finally {
propertyLock.unlock(); propertyLock.unlock();
@ -150,11 +154,11 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
public void setPrefixChat(boolean prefixChat) { public void setPrefixChat(boolean prefixChat) {
Thread thread = Thread.currentThread(); Thread thread = Thread.currentThread();
if (propertyLock.isLocked()) { if (propertyLock.isLocked()) {
core.log(Level.FINEST, "propertyLock is locked when attempting to set prefixchat on thread: " + thread); MultiverseCore.staticLog(Level.FINEST, "propertyLock is locked when attempting to set prefixchat on thread: " + thread);
} }
propertyLock.lock(); propertyLock.lock();
try { try {
core.log(Level.FINEST, "Setting prefixchat on thread: " + thread); MultiverseCore.staticLog(Level.FINEST, "Setting prefixchat on thread: " + thread);
this.prefixchat = prefixChat; this.prefixchat = prefixChat;
} finally { } finally {
propertyLock.unlock(); propertyLock.unlock();