fixed npe with new flag containers
This commit is contained in:
1 parent
4d8cd430b7
commit
0ff24627ca
8 files changed
+115
-52
No files matched your search
@@ -120,7 +120,7 @@ public class ApplicableRegionSet {
|
||||
if (flag instanceof BooleanRegionFlag) {
|
||||
return (BooleanRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
return new BooleanRegionFlag();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class ApplicableRegionSet {
|
||||
if (flag instanceof StateRegionFlag) {
|
||||
return (StateRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
return new StateRegionFlag();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class ApplicableRegionSet {
|
||||
if (flag instanceof IntegerRegionFlag) {
|
||||
return (IntegerRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
return new IntegerRegionFlag();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class ApplicableRegionSet {
|
||||
if (flag instanceof DoubleRegionFlag) {
|
||||
return (DoubleRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
return new DoubleRegionFlag();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ApplicableRegionSet {
|
||||
if (flag instanceof StringRegionFlag) {
|
||||
return (StringRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
return new StringRegionFlag();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public class ApplicableRegionSet {
|
||||
if (flag instanceof RegionGroupRegionFlag) {
|
||||
return (RegionGroupRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
return new RegionGroupRegionFlag();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class ApplicableRegionSet {
|
||||
if (flag instanceof LocationRegionFlag) {
|
||||
return (LocationRegionFlag) flag;
|
||||
} else {
|
||||
return null;
|
||||
return new LocationRegionFlag();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,13 @@ public final class BooleanRegionFlag extends RegionFlag {
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public BooleanRegionFlag() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
public void setValue(Boolean newValue) {
|
||||
this.value = newValue;
|
||||
this.container.internalSetValue(info.name, newValue != null ? newValue.toString() : null);
|
||||
this.updataContainer();
|
||||
}
|
||||
|
||||
public Boolean getValue() {
|
||||
@@ -50,16 +54,22 @@ public final class BooleanRegionFlag extends RegionFlag {
|
||||
this.value = null;
|
||||
} else {
|
||||
newValue = newValue.toLowerCase();
|
||||
if(newValue.equals("on") || newValue.equals("allow") || newValue.equals("1"))
|
||||
{
|
||||
if (newValue.equals("on") || newValue.equals("allow") || newValue.equals("1")) {
|
||||
newValue = "true";
|
||||
}
|
||||
this.value = Boolean.valueOf(newValue);
|
||||
}
|
||||
|
||||
this.updataContainer();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updataContainer() {
|
||||
if (this.container != null) {
|
||||
this.container.internalSetValue(info.name, this.value != null ? this.value.toString() : null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue() {
|
||||
return this.value != null;
|
||||
@@ -67,12 +77,9 @@ public final class BooleanRegionFlag extends RegionFlag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(this.value != null)
|
||||
{
|
||||
if (this.value != null) {
|
||||
return this.value.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,13 @@ public final class DoubleRegionFlag extends RegionFlag {
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public DoubleRegionFlag() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
public void setValue(Double newValue) {
|
||||
this.value = newValue;
|
||||
this.container.internalSetValue(info.name, newValue != null ? newValue.toString() : null);
|
||||
this.updataContainer();
|
||||
}
|
||||
|
||||
public Double getValue() {
|
||||
@@ -52,13 +56,20 @@ public final class DoubleRegionFlag extends RegionFlag {
|
||||
this.value = Double.valueOf(newValue);
|
||||
} catch (Exception e) {
|
||||
this.value = null;
|
||||
this.updataContainer();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.updataContainer();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updataContainer() {
|
||||
if (this.container != null) {
|
||||
this.container.internalSetValue(info.name, this.value != null ? this.value.toString() : null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue() {
|
||||
return this.value != null;
|
||||
@@ -66,12 +77,9 @@ public final class DoubleRegionFlag extends RegionFlag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(this.value != null)
|
||||
{
|
||||
if (this.value != null) {
|
||||
return this.value.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,13 @@ public final class IntegerRegionFlag extends RegionFlag {
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public IntegerRegionFlag() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
public void setValue(Integer newValue) {
|
||||
this.value = newValue;
|
||||
this.container.internalSetValue(info.name, newValue != null ? newValue.toString() : null);
|
||||
this.updataContainer();
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
@@ -52,13 +56,21 @@ public final class IntegerRegionFlag extends RegionFlag {
|
||||
this.value = Integer.valueOf(newValue);
|
||||
} catch (Exception e) {
|
||||
this.value = null;
|
||||
this.updataContainer();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.updataContainer();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updataContainer() {
|
||||
if (this.container != null) {
|
||||
this.container.internalSetValue(info.name, this.value != null ? this.value.toString() : null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue() {
|
||||
return this.value != null;
|
||||
@@ -66,12 +78,9 @@ public final class IntegerRegionFlag extends RegionFlag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(this.value != null)
|
||||
{
|
||||
if (this.value != null) {
|
||||
return this.value.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,10 @@ public final class LocationRegionFlag extends RegionFlag {
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public LocationRegionFlag() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
public void setValue(Location newValue) {
|
||||
if (newValue == null) {
|
||||
this.worldName = null;
|
||||
@@ -48,19 +52,11 @@ public final class LocationRegionFlag extends RegionFlag {
|
||||
this.pitch = newValue.getPitch();
|
||||
}
|
||||
|
||||
String stringVal;
|
||||
if (newValue == null) {
|
||||
stringVal = null;
|
||||
} else {
|
||||
stringVal = newValue.getWorld().getName() + ";" + newValue.getBlockX() + ";"
|
||||
+ newValue.getBlockY() + ";" + newValue.getBlockZ() + ";" + newValue.getYaw()
|
||||
+ ";" + newValue.getPitch();
|
||||
}
|
||||
this.container.internalSetValue(info.name, stringVal);
|
||||
this.updataContainer();
|
||||
}
|
||||
|
||||
public Location getValue(Server server) {
|
||||
|
||||
|
||||
if (this.worldName == null) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -97,25 +93,38 @@ public final class LocationRegionFlag extends RegionFlag {
|
||||
|
||||
} catch (Exception e) {
|
||||
this.worldName = null;
|
||||
this.updataContainer();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.updataContainer();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updataContainer() {
|
||||
if (this.container != null) {
|
||||
String stringVal;
|
||||
if (this.worldName == null) {
|
||||
stringVal = null;
|
||||
} else {
|
||||
stringVal = this.worldName + ";" + this.x + ";" + this.y + ";" + this.z
|
||||
+ ";" + this.yaw + ";" + this.pitch;
|
||||
}
|
||||
this.container.internalSetValue(info.name, stringVal);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue() {
|
||||
return this.worldName != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(this.worldName != null)
|
||||
{
|
||||
if (this.worldName != null) {
|
||||
return this.worldName + "(" + Math.round(this.x) + "," + Math.round(this.y) + "," + Math.round(this.z) + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,13 @@ public final class RegionGroupRegionFlag extends RegionFlag {
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public RegionGroupRegionFlag() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
public void setValue(RegionGroup newValue) {
|
||||
this.value = newValue;
|
||||
this.container.internalSetValue(info.name, newValue != null ? newValue.toString() : null);
|
||||
this.updataContainer();
|
||||
}
|
||||
|
||||
public RegionGroup getValue() {
|
||||
@@ -52,13 +56,21 @@ public final class RegionGroupRegionFlag extends RegionFlag {
|
||||
this.value = RegionGroup.valueOf(newValue);
|
||||
} catch (Exception e) {
|
||||
this.value = null;
|
||||
this.updataContainer();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.updataContainer();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void updataContainer() {
|
||||
if (this.container != null) {
|
||||
this.container.internalSetValue(info.name, this.value != null ? this.value.toString() : null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue() {
|
||||
return this.value != null;
|
||||
|
||||
@@ -31,9 +31,13 @@ public final class StateRegionFlag extends RegionFlag {
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public StateRegionFlag() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
public void setValue(State newValue) {
|
||||
this.value = newValue;
|
||||
this.container.internalSetValue(info.name, newValue != null ? newValue.toString() : null);
|
||||
this.updataContainer();
|
||||
}
|
||||
|
||||
public State getValue() {
|
||||
@@ -53,13 +57,21 @@ public final class StateRegionFlag extends RegionFlag {
|
||||
this.value = State.valueOf(newValue);
|
||||
} catch (Exception e) {
|
||||
this.value = null;
|
||||
this.updataContainer();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.updataContainer();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updataContainer() {
|
||||
if (this.container != null) {
|
||||
this.container.internalSetValue(info.name, this.value != null ? this.value.toString() : null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue() {
|
||||
return this.value != null;
|
||||
@@ -67,12 +79,9 @@ public final class StateRegionFlag extends RegionFlag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(this.value != null)
|
||||
{
|
||||
if (this.value != null) {
|
||||
return this.value.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,13 @@ public class StringRegionFlag extends RegionFlag {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public StringRegionFlag() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
public boolean setValue(String newValue) {
|
||||
this.value = newValue;
|
||||
this.container.internalSetValue(info.name, newValue);
|
||||
this.updataContainer();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,6 +50,11 @@ public class StringRegionFlag extends RegionFlag {
|
||||
return this.value != null ? this.value : def;
|
||||
}
|
||||
|
||||
private void updataContainer() {
|
||||
if (this.container != null) {
|
||||
this.container.internalSetValue(info.name, this.value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue() {
|
||||
|
||||
Reference in new issue
Block a user