summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/material/Step.java
blob: b0a177c7ca37dd20914475a1c22d370e2e74e7c6 (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
package org.bukkit.material;

import java.util.HashSet;

import org.bukkit.Material;

/**
 * Represents the different types of steps.
 * @author sunkid
 */
public class Step extends MaterialData {
    private static HashSet<Material> stepTypes = new HashSet<Material>();
    static {
        stepTypes.add(Material.SANDSTONE);
        stepTypes.add(Material.WOOD);
        stepTypes.add(Material.COBBLESTONE);
        stepTypes.add(Material.STONE);
    }
    
    public Step() {
        super(Material.STEP);
    }
    
    public Step(final int type) {
        super(type);
    }

    public Step(final Material type) {
        super((stepTypes.contains(type)) ? Material.STEP : type);
        if(stepTypes.contains(type))
            setMaterial(type);
    }

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

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

    /**
     * Gets the current Material this step is made of
     *
     * @return Material of this step
     */
    public Material getMaterial() {
        switch ((int) getData()) {
        case 1:
            return Material.SANDSTONE;
        case 2:
            return Material.WOOD;
        case 3:
            return Material.COBBLESTONE;
        case 0:
        default:
            return Material.STONE;
        }
    }

    /**
     * Sets the material this step is made of
     *
     * @param material New material of this step
     */
    public void setMaterial(Material material) {
        switch (material) {
        case SANDSTONE:
            setData((byte) 0x1);
            break;
        case WOOD:
            setData((byte) 0x2);
            break;
        case COBBLESTONE:
            setData((byte) 0x3);
            break;
        case STONE:
        default:
            setData((byte) 0x0);
        }
    }
    
    @Override
    public String toString() {
        return getMaterial() + " " + super.toString();
    }
}