001    /**
002     * Sign.java - Interface to signs
003     * 
004     * @author James
005     */
006    public class Sign implements ComplexBlock {
007        private lv sign;
008    
009        /**
010         * Creates a sign interface
011         * 
012         * @param localav
013         */
014        public Sign(lv localay) {
015            this.sign = localay;
016        }
017    
018        /**
019         * Sets the line of text at specified index
020         * 
021         * @param index
022         *            line
023         * @param text
024         *            text
025         */
026        public void setText(int index, String text) {
027            if (index >= 0 && sign.e.length > index) {
028                sign.e[index] = text;
029            }
030        }
031    
032        /**
033         * Returns the line of text
034         * 
035         * @param index
036         *            line of text
037         * @return text
038         */
039        public String getText(int index) {
040            if (index >= 0 && sign.e.length > index) {
041                return sign.e[index];
042            }
043            return "";
044        }
045    
046        public int getX() {
047            return sign.b;
048        }
049    
050        public int getY() {
051            return sign.c;
052        }
053    
054        public int getZ() {
055            return sign.d;
056        }
057    
058        public Block getBlock() {
059            return etc.getServer().getBlockAt(getX(), getY(), getZ());
060        }
061    
062        public void update() {
063            sign.d();
064        }
065    
066        /**
067         * Returns a String value representing this Block
068         *
069         * @return String representation of this block
070         */
071        @Override
072        public String toString() {
073            return String.format("Sign [x=%d, y=%d, z=%d]", getX(), getY(), getZ());
074        }
075    
076        /**
077         * Tests the given object to see if it equals this object
078         *
079         * @param obj the object to test
080         * @return true if the two objects match
081         */
082        @Override
083        public boolean equals(Object obj) {
084            if (obj == null) {
085                return false;
086            }
087            if (getClass() != obj.getClass()) {
088                return false;
089            }
090            final Sign other = (Sign) obj;
091            if (this.getX() != other.getX()) {
092                return false;
093            }
094            if (this.getY() != other.getY()) {
095                return false;
096            }
097            if (this.getZ() != other.getZ()) {
098                return false;
099            }
100            return true;
101        }
102    
103        /**
104         * Returns a semi-unique hashcode for this block
105         *
106         * @return hashcode
107         */
108        @Override
109        public int hashCode() {
110            int hash = 7;
111            hash = 97 * hash + this.getX();
112            hash = 97 * hash + this.getY();
113            hash = 97 * hash + this.getZ();
114            return hash;
115        }
116    }