13
0
geforkt von Mirrors/Paper

Fix Wood(plank) and add Sandstone MaterialData; addresses BUKKIT-1384

By: Wesley Wolfe <weswolf@aol.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2012-03-31 08:35:59 -05:00
Ursprung e2137d9470
Commit f5c68c57d0
3 geänderte Dateien mit 112 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -23,7 +23,7 @@ public enum Material {
GRASS(2),
DIRT(3),
COBBLESTONE(4),
WOOD(5),
WOOD(5, Tree.class),
SAPLING(6, Tree.class),
BEDROCK(7),
WATER(8, MaterialData.class),
@ -42,7 +42,7 @@ public enum Material {
LAPIS_ORE(21),
LAPIS_BLOCK(22),
DISPENSER(23, Dispenser.class),
SANDSTONE(24),
SANDSTONE(24, Sandstone.class),
NOTE_BLOCK(25),
BED_BLOCK(26, Bed.class),
POWERED_RAIL(27, PoweredRail.class),

Datei anzeigen

@ -0,0 +1,48 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
/**
* Represents the three different types of Sandstone
*/
public enum SandstoneType {
CRACKED(0x0),
GLYPHED(0x1),
SMOOTH(0x2);
private final byte data;
private final static Map<Byte, SandstoneType> BY_DATA = Maps.newHashMap();
private SandstoneType(final int data) {
this.data = (byte) data;
}
/**
* Gets the associated data value representing this type of sandstone
*
* @return A byte containing the data value of this sandstone type
*/
public byte getData() {
return data;
}
/**
* Gets the type of sandstone with the given data value
*
* @param data
* Data value to fetch
* @return The {@link SandstoneType} representing the given value, or null if
* it doesn't exist
*/
public static SandstoneType getByData(final byte data) {
return BY_DATA.get(data);
}
static {
for (SandstoneType type : values()) {
BY_DATA.put(type.data, type);
}
}
}

Datei anzeigen

@ -0,0 +1,62 @@
package org.bukkit.material;
import org.bukkit.Material;
import org.bukkit.SandstoneType;
/**
* Represents the different types of sandstone.
*/
public class Sandstone extends MaterialData {
public Sandstone() {
super(Material.SANDSTONE);
}
public Sandstone(SandstoneType type) {
this();
setType(type);
}
public Sandstone(final int type) {
super(type);
}
public Sandstone(final Material type) {
super(type);
}
public Sandstone(final int type, final byte data) {
super(type, data);
}
public Sandstone(final Material type, final byte data) {
super(type, data);
}
/**
* Gets the current type of this sandstone
*
* @return SandstoneType of this sandstone
*/
public SandstoneType getType() {
return SandstoneType.getByData(getData());
}
/**
* Sets the type of this sandstone
*
* @param type New type of this sandstone
*/
public void setType(SandstoneType type) {
setData(type.getData());
}
@Override
public String toString() {
return getType() + " " + super.toString();
}
@Override
public Sandstone clone() {
return (Sandstone) super.clone();
}
}