Synchronized world properties required by Async chat event.

This commit is contained in:
Jeremy Wood 2012-08-05 00:11:13 -04:00
parent b2f3b74062
commit d05e2b500f
1 changed files with 53 additions and 39 deletions

View File

@ -60,7 +60,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
private static final int SPAWN_LOCATION_SEARCH_TOLERANCE = 16;
private static final int SPAWN_LOCATION_SEARCH_RADIUS = 16;
private static Map<String, String> propertyAliases;
private static final Map<String, String> propertyAliases;
static {
propertyAliases = new HashMap<String, String>();
@ -350,6 +350,8 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
}
}
private final Object propertyLock = new Object();
// --------------------------------------------------------------
// Begin properties
@Property(description = "Sorry, 'hidden' must either be: true or false.")
@ -637,6 +639,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
*/
@Override
protected void setDefaults() {
synchronized (propertyLock) {
this.hidden = false;
this.alias = new String();
this.color = EnglishChatColor.WHITE;
@ -657,6 +660,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
this.worldBlacklist = new ArrayList<String>();
this.generator = null;
}
}
/**
* getAliases().
@ -713,6 +717,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
*/
@Override
public String getColoredWorldString() {
synchronized (propertyLock) {
if (alias.length() == 0) {
alias = this.getName();
}
@ -728,6 +733,7 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
return nameBuilder.toString();
}
}
/**
* {@inheritDoc}
@ -937,11 +943,13 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
*/
@Override
public String getAlias() {
synchronized (propertyLock) {
if (this.alias == null || this.alias.length() == 0) {
return this.name;
}
return this.alias;
}
}
/**
* {@inheritDoc}
@ -1022,8 +1030,10 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
*/
@Override
public boolean isHidden() {
synchronized (propertyLock) {
return this.hidden;
}
}
/**
* {@inheritDoc}
@ -1081,8 +1091,10 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
*/
@Override
public ChatColor getColor() {
synchronized (propertyLock) {
return this.color.getColor();
}
}
/**
* {@inheritDoc}
@ -1385,8 +1397,10 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
*/
@Override
public ChatColor getStyle() {
synchronized (propertyLock) {
return style.getColor();
}
}
/**
* {@inheritDoc}