Config properties now volatile instead of using thread lock.
This commit is contained in:
parent
9196973d1c
commit
d40e67b47d
|
@ -6,8 +6,6 @@ import me.main__.util.SerializationConfig.Property;
|
||||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Our configuration.
|
* Our configuration.
|
||||||
|
@ -40,30 +38,30 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ReentrantLock propertyLock = new ReentrantLock();
|
//private final ReentrantLock propertyLock = new ReentrantLock();
|
||||||
|
|
||||||
@Property
|
@Property
|
||||||
private boolean enforceaccess;
|
private volatile boolean enforceaccess;
|
||||||
@Property
|
@Property
|
||||||
private boolean prefixchat;
|
private volatile boolean prefixchat;
|
||||||
@Property
|
@Property
|
||||||
private boolean useasyncchat;
|
private volatile boolean useasyncchat;
|
||||||
@Property
|
@Property
|
||||||
private boolean teleportintercept;
|
private volatile boolean teleportintercept;
|
||||||
@Property
|
@Property
|
||||||
private boolean firstspawnoverride;
|
private volatile boolean firstspawnoverride;
|
||||||
@Property
|
@Property
|
||||||
private boolean displaypermerrors;
|
private volatile boolean displaypermerrors;
|
||||||
@Property
|
@Property
|
||||||
private int globaldebug;
|
private volatile int globaldebug;
|
||||||
@Property
|
@Property
|
||||||
private int messagecooldown;
|
private volatile int messagecooldown;
|
||||||
@Property
|
@Property
|
||||||
private double version;
|
private volatile double version;
|
||||||
@Property
|
@Property
|
||||||
private String firstspawnworld;
|
private volatile String firstspawnworld;
|
||||||
@Property
|
@Property
|
||||||
private int teleportcooldown;
|
private volatile int teleportcooldown;
|
||||||
|
|
||||||
public MultiverseCoreConfiguration() {
|
public MultiverseCoreConfiguration() {
|
||||||
super();
|
super();
|
||||||
|
@ -99,18 +97,10 @@ 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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,17 +127,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean getPrefixChat() {
|
public boolean getPrefixChat() {
|
||||||
Thread thread = Thread.currentThread();
|
return this.prefixchat;
|
||||||
if (propertyLock.isLocked()) {
|
|
||||||
MultiverseCore.staticLog(Level.FINEST, "propertyLock is locked when attempting to get prefixchat on thread: " + thread);
|
|
||||||
}
|
|
||||||
propertyLock.lock();
|
|
||||||
try {
|
|
||||||
MultiverseCore.staticLog(Level.FINEST, "Getting prefixchat on thread: " + thread);
|
|
||||||
return this.prefixchat;
|
|
||||||
} finally {
|
|
||||||
propertyLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,17 +135,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setPrefixChat(boolean prefixChat) {
|
public void setPrefixChat(boolean prefixChat) {
|
||||||
Thread thread = Thread.currentThread();
|
this.prefixchat = prefixChat;
|
||||||
if (propertyLock.isLocked()) {
|
|
||||||
MultiverseCore.staticLog(Level.FINEST, "propertyLock is locked when attempting to set prefixchat on thread: " + thread);
|
|
||||||
}
|
|
||||||
propertyLock.lock();
|
|
||||||
try {
|
|
||||||
MultiverseCore.staticLog(Level.FINEST, "Setting prefixchat on thread: " + thread);
|
|
||||||
this.prefixchat = prefixChat;
|
|
||||||
} finally {
|
|
||||||
propertyLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue