001    package org.bukkit.material;
002    
003    import org.bukkit.Material;
004    import org.bukkit.block.BlockFace;
005    
006    /**
007     * Represents a door.
008     *
009     * @deprecated No longer functions. Do not use.
010     */
011    @Deprecated
012    public class Door extends MaterialData implements Directional, Openable {
013        public Door() {
014            super(Material.WOODEN_DOOR);
015        }
016    
017        /**
018         *
019         * @deprecated Magic value
020         */
021        @Deprecated
022        public Door(final int type) {
023            super(type);
024        }
025    
026        public Door(final Material type) {
027            super(type);
028        }
029    
030        /**
031         *
032         * @deprecated Magic value
033         */
034        @Deprecated
035        public Door(final int type, final byte data) {
036            super(type, data);
037        }
038    
039        /**
040         *
041         * @deprecated Magic value
042         */
043        @Deprecated
044        public Door(final Material type, final byte data) {
045            super(type, data);
046        }
047    
048        /**
049         * @deprecated Does not work (correctly) anymore
050         */
051        @Deprecated
052        public boolean isOpen() {
053            return ((getData() & 0x4) == 0x4);
054        }
055    
056        /**
057         * @deprecated Does not work (correctly) anymore
058         */
059        @Deprecated
060        public void setOpen(boolean isOpen) {
061            setData((byte) (isOpen ? (getData() | 0x4) : (getData() & ~0x4)));
062        }
063    
064        /**
065         * @return whether this is the top half of the door
066         */
067        public boolean isTopHalf() {
068            return ((getData() & 0x8) == 0x8);
069        }
070    
071        /**
072         * Configure this part of the door to be either the top or the bottom half
073         *
074         * @param isTopHalf True to make it the top half.
075         * @deprecated Shouldn't be used anymore
076         */
077        @Deprecated
078        public void setTopHalf(boolean isTopHalf) {
079            setData((byte) (isTopHalf ? (getData() | 0x8) : (getData() & ~0x8)));
080        }
081    
082        /**
083         * @return BlockFace.SELF
084         * @deprecated Does not work (correctly) anymore
085         */
086        @Deprecated
087        public BlockFace getHingeCorner() {
088            byte d = getData();
089    
090            if ((d & 0x3) == 0x3) {
091                return BlockFace.NORTH_WEST;
092            } else if ((d & 0x1) == 0x1) {
093                return BlockFace.SOUTH_EAST;
094            } else if ((d & 0x2) == 0x2) {
095                return BlockFace.SOUTH_WEST;
096            }
097    
098            return BlockFace.NORTH_EAST;
099        }
100    
101        @Override
102        public String toString() {
103            return (isTopHalf() ? "TOP" : "BOTTOM") + " half of " + super.toString();
104        }
105    
106        /**
107         * Set the direction that this door should is facing.
108         *
109         * @param face the direction
110         * @deprecated Does not work (correctly) anymore
111         */
112        @Deprecated
113        public void setFacingDirection(BlockFace face) {
114            byte data = (byte) (getData() & 0x12);
115            switch (face) {
116            case NORTH:
117                data |= 0x1;
118                break;
119    
120            case EAST:
121                data |= 0x2;
122                break;
123    
124            case SOUTH:
125                data |= 0x3;
126                break;
127            }
128            setData(data);
129        }
130    
131        /**
132         * Get the direction that this door is facing.
133         *
134         * @return the direction
135         * @deprecated Does not work (correctly) anymore
136         */
137        @Deprecated
138        public BlockFace getFacing() {
139            byte data = (byte) (getData() & 0x3);
140            switch (data) {
141            case 0:
142                return BlockFace.WEST;
143    
144            case 1:
145                return BlockFace.NORTH;
146    
147            case 2:
148                return BlockFace.EAST;
149    
150            case 3:
151                return BlockFace.SOUTH;
152            }
153            return null; // shouldn't happen
154        }
155    
156        @Override
157        public Door clone() {
158            return (Door) super.clone();
159        }
160    }