summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/material/Door.java
blob: dcf2feacde7576804c796523d60c3830c5adac0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package org.bukkit.material;

import org.bukkit.Material;
import org.bukkit.block.BlockFace;

/**
 * Represents a door.
 *
 * @deprecated No longer functions. Do not use.
 */
@Deprecated
public class Door extends MaterialData implements Directional, Openable {
    public Door() {
        super(Material.WOODEN_DOOR);
    }

    public Door(final int type) {
        super(type);
    }

    public Door(final Material type) {
        super(type);
    }

    public Door(final int type, final byte data) {
        super(type, data);
    }

    public Door(final Material type, final byte data) {
        super(type, data);
    }

    /**
     * @deprecated Does not work (correctly) anymore
     */
    @Deprecated
    public boolean isOpen() {
        return ((getData() & 0x4) == 0x4);
    }

    /**
     * @deprecated Does not work (correctly) anymore
     */
    @Deprecated
    public void setOpen(boolean isOpen) {
        setData((byte) (isOpen ? (getData() | 0x4) : (getData() & ~0x4)));
    }

    /**
     * @return whether this is the top half of the door
     */
    public boolean isTopHalf() {
        return ((getData() & 0x8) == 0x8);
    }

    /**
     * Configure this part of the door to be either the top or the bottom half;
     *
     * @param isTopHalf True to make it the top half.
     * @deprecated Shouldn't be used anymore
     */
    @Deprecated
    public void setTopHalf(boolean isTopHalf) {
        setData((byte) (isTopHalf ? (getData() | 0x8) : (getData() & ~0x8)));
    }

    /**
     * @return BlockFace.SELF
     * @deprecated Does not work (correctly) anymore
     */
    @Deprecated
    public BlockFace getHingeCorner() {
        byte d = getData();

        if ((d & 0x3) == 0x3) {
            return BlockFace.NORTH_WEST;
        } else if ((d & 0x1) == 0x1) {
            return BlockFace.SOUTH_EAST;
        } else if ((d & 0x2) == 0x2) {
            return BlockFace.SOUTH_WEST;
        }

        return BlockFace.NORTH_EAST;
    }

    @Override
    public String toString() {
        return (isTopHalf() ? "TOP" : "BOTTOM") + " half of " + super.toString();
    }

    /**
     * Set the direction that this door should is facing.
     *
     * @param face the direction
     * @deprecated Does not work (correctly) anymore
     */
    @Deprecated
    public void setFacingDirection(BlockFace face) {
        byte data = (byte) (getData() & 0x12);
        switch (face) {
        case NORTH:
            data |= 0x1;
            break;

        case EAST:
            data |= 0x2;
            break;

        case SOUTH:
            data |= 0x3;
            break;
        }
        setData(data);
    }

    /**
     * Get the direction that this door is facing.
     *
     * @return the direction
     * @deprecated Does not work (correctly) anymore
     */
    @Deprecated
    public BlockFace getFacing() {
        byte data = (byte) (getData() & 0x3);
        switch (data) {
        case 0:
            return BlockFace.WEST;

        case 1:
            return BlockFace.NORTH;

        case 2:
            return BlockFace.EAST;

        case 3:
            return BlockFace.SOUTH;
        }
        return null; // shouldn't happen
    }

    @Override
    public Door clone() {
        return (Door) super.clone();
    }
}