package NET.worlds.scape; import NET.worlds.console.Main; public class Property { protected Properties owner; public static final int BOOL_TYPE = 0; public static final int INT_TYPE = 1; public static final int FLOAT_TYPE = 2; public static final int STRING_TYPE = 3; public static final int COLOR_TYPE = 4; public static final int ENUM_TYPE = 5; public static final int FLOAT_ARRAY_TYPE = 6; public static final int POINT2_TYPE = 7; public static final int POINT3_TYPE = 8; public static final int TRANSFORM_TYPE = 9; public static final int URL_TYPE = 10; protected int index; protected String name; protected int propertyType = 3; protected PropEditor editor; public boolean helpExists = false; protected boolean canSetNull = false; public Property(Properties owner, int index, String name) { this.owner = owner; this.index = index; this.name = name; } public Property(Properties owner, int index, String name, boolean haveHelp) { this.owner = owner; this.index = index; this.name = name; this.helpExists = haveHelp; } Property setEditor(PropEditor editor) { this.editor = editor; return this; } public PropEditor getEditor() { return this.editor; } public Property allowSetNull() { this.canSetNull = true; return this; } public boolean canSetNull() { return this.canSetNull; } public String getName() { return this.name; } public int getIndex() { return this.index; } public Properties getOwner() { return this.owner; } public Object get() { return this.operate(1, null); } public Object set(Object obj) { return this.operate(2, obj); } @Override public boolean equals(Object obj) { return obj instanceof Property && ((Property)obj).owner == this.owner && ((Property)obj).index == this.index; } @Override public int hashCode() { return this.owner.hashCode() ^ this.index; } protected Object operate(int func, Object value) { return Main.isMainThread() ? this.safeOperate(func, value) : new CallbackPropertyOperator(this, func, value).getValue(); } Object safeOperate(int func, Object value) { try { Object ret = this.owner.properties(this.index, 0, func, value); if (func > 1 && func < 5 && this.owner instanceof SuperRoot) { ((SuperRoot)this.owner).markEdited(); } return ret; } catch (NoSuchPropertyException var4) { assert false; return null; } } @Override public String toString() { return this.getName(); } public void setPropertyType(int type) { this.propertyType = type; } public String getPropertyType() { String retVal; switch (this.propertyType) { case 0: retVal = "Boolean"; break; case 1: retVal = "Integer"; break; case 2: retVal = "Float"; break; case 3: retVal = "String"; break; case 4: retVal = "Color"; break; case 5: retVal = "Enumeration"; break; case 6: retVal = "Float Array"; break; case 7: retVal = "2D Point"; break; case 8: retVal = "3D Point"; break; case 9: retVal = "Transform"; break; default: retVal = "URL"; } return retVal; } }