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

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