From 84a31c395128b72883a14f24d2d041c44cec7037 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sat, 2 Apr 2011 16:42:12 -0700 Subject: [PATCH] Ton of Material extensions handling the meta-data of blocks. By: sunkid --- .../src/main/java/org/bukkit/Material.java | 38 ++--- .../java/org/bukkit/material/Attachable.java | 15 +- .../main/java/org/bukkit/material/Bed.java | 106 +++++++++++++ .../main/java/org/bukkit/material/Button.java | 66 ++++++-- .../main/java/org/bukkit/material/Cake.java | 9 ++ .../main/java/org/bukkit/material/Coal.java | 28 +++- .../main/java/org/bukkit/material/Crops.java | 37 +++++ .../main/java/org/bukkit/material/Diode.java | 57 ++++++- .../java/org/bukkit/material/Directional.java | 18 +++ .../java/org/bukkit/material/Dispenser.java | 37 +++++ .../main/java/org/bukkit/material/Door.java | 12 +- .../main/java/org/bukkit/material/Dye.java | 13 +- .../java/org/bukkit/material/Furnace.java | 41 +++++ .../bukkit/material/FurnaceAndDispenser.java | 66 ++++++++ .../java/org/bukkit/material/Jukebox.java | 21 ++- .../main/java/org/bukkit/material/Ladder.java | 50 ++++-- .../main/java/org/bukkit/material/Leaves.java | 14 ++ .../main/java/org/bukkit/material/Lever.java | 74 +++++++-- .../org/bukkit/material/MaterialData.java | 16 +- .../org/bukkit/material/PressurePlate.java | 39 +++++ .../java/org/bukkit/material/Pumpkin.java | 85 ++++++++++ .../main/java/org/bukkit/material/Rails.java | 87 ++++++++++ .../org/bukkit/material/RedstoneTorch.java | 9 ++ .../org/bukkit/material/RedstoneWire.java | 9 ++ .../main/java/org/bukkit/material/Sign.java | 150 ++++++++++++------ .../SimpleAttachableMaterialData.java | 48 ++++++ .../main/java/org/bukkit/material/Stairs.java | 90 +++++++++++ .../main/java/org/bukkit/material/Step.java | 23 ++- .../main/java/org/bukkit/material/Torch.java | 52 ++++-- .../main/java/org/bukkit/material/Tree.java | 14 ++ .../main/java/org/bukkit/material/Wool.java | 14 ++ 31 files changed, 1203 insertions(+), 135 deletions(-) create mode 100644 paper-api/src/main/java/org/bukkit/material/Bed.java create mode 100644 paper-api/src/main/java/org/bukkit/material/Directional.java create mode 100644 paper-api/src/main/java/org/bukkit/material/Dispenser.java create mode 100644 paper-api/src/main/java/org/bukkit/material/Furnace.java create mode 100644 paper-api/src/main/java/org/bukkit/material/FurnaceAndDispenser.java create mode 100644 paper-api/src/main/java/org/bukkit/material/PressurePlate.java create mode 100644 paper-api/src/main/java/org/bukkit/material/Pumpkin.java create mode 100644 paper-api/src/main/java/org/bukkit/material/Rails.java create mode 100644 paper-api/src/main/java/org/bukkit/material/SimpleAttachableMaterialData.java create mode 100644 paper-api/src/main/java/org/bukkit/material/Stairs.java diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index d43528a136..8830d199cd 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -18,12 +18,12 @@ public enum Material { DIRT(3), COBBLESTONE(4), WOOD(5), - SAPLING(6), + SAPLING(6, MaterialData.class), BEDROCK(7), - WATER(8), - STATIONARY_WATER(9), - LAVA(10), - STATIONARY_LAVA(11), + WATER(8, MaterialData.class), + STATIONARY_WATER(9, MaterialData.class), + LAVA(10, MaterialData.class), + STATIONARY_LAVA(11, MaterialData.class), SAND(12), GRAVEL(13), GOLD_ORE(14), @@ -35,10 +35,10 @@ public enum Material { GLASS(20), LAPIS_ORE(21), LAPIS_BLOCK(22), - DISPENSER(23), + DISPENSER(23, Dispenser.class), SANDSTONE(24), NOTE_BLOCK(25), - BED_BLOCK(26), + BED_BLOCK(26, Bed.class), WOOL(35, Wool.class), YELLOW_FLOWER(37), RED_ROSE(38), @@ -56,26 +56,26 @@ public enum Material { TORCH(50, Torch.class), FIRE(51), MOB_SPAWNER(52), - WOOD_STAIRS(53), + WOOD_STAIRS(53, Stairs.class), CHEST(54), REDSTONE_WIRE(55, RedstoneWire.class), DIAMOND_ORE(56), DIAMOND_BLOCK(57), WORKBENCH(58), CROPS(59, Crops.class), - SOIL(60), - FURNACE(61), - BURNING_FURNACE(62), + SOIL(60, MaterialData.class), + FURNACE(61, Furnace.class), + BURNING_FURNACE(62, Furnace.class), SIGN_POST(63, 1, Sign.class), WOODEN_DOOR(64, Door.class), LADDER(65, Ladder.class), - RAILS(66), - COBBLESTONE_STAIRS(67), + RAILS(66, Rails.class), + COBBLESTONE_STAIRS(67, Stairs.class), WALL_SIGN(68, 1, Sign.class), LEVER(69, Lever.class), - STONE_PLATE(70), + STONE_PLATE(70, PressurePlate.class), IRON_DOOR_BLOCK(71, Door.class), - WOOD_PLATE(72), + WOOD_PLATE(72, PressurePlate.class), REDSTONE_ORE(73), GLOWING_REDSTONE_ORE(74), REDSTONE_TORCH_OFF(75, RedstoneTorch.class), @@ -84,17 +84,17 @@ public enum Material { SNOW(78), ICE(79), SNOW_BLOCK(80), - CACTUS(81), + CACTUS(81, MaterialData.class), CLAY(82), - SUGAR_CANE_BLOCK(83), + SUGAR_CANE_BLOCK(83, MaterialData.class), JUKEBOX(84, Jukebox.class), FENCE(85), - PUMPKIN(86), + PUMPKIN(86, Pumpkin.class), NETHERRACK(87), SOUL_SAND(88), GLOWSTONE(89), PORTAL(90), - JACK_O_LANTERN(91), + JACK_O_LANTERN(91, Pumpkin.class), CAKE_BLOCK(92, 1, Cake.class), DIODE_BLOCK_OFF(93, Diode.class), DIODE_BLOCK_ON(94, Diode.class), diff --git a/paper-api/src/main/java/org/bukkit/material/Attachable.java b/paper-api/src/main/java/org/bukkit/material/Attachable.java index cab9be91b4..ea988bcabc 100644 --- a/paper-api/src/main/java/org/bukkit/material/Attachable.java +++ b/paper-api/src/main/java/org/bukkit/material/Attachable.java @@ -1,4 +1,3 @@ - package org.bukkit.material; import org.bukkit.block.BlockFace; @@ -6,11 +5,11 @@ import org.bukkit.block.BlockFace; /** * Indicates that a block can be attached to another block */ -public interface Attachable { - /** - * Gets the face that this block is attached on - * - * @return BlockFace attached to - */ - public BlockFace getAttachedFace(); +public interface Attachable extends Directional { + /** + * Gets the face that this block is attached on + * + * @return BlockFace attached to + */ + public BlockFace getAttachedFace(); } diff --git a/paper-api/src/main/java/org/bukkit/material/Bed.java b/paper-api/src/main/java/org/bukkit/material/Bed.java new file mode 100644 index 0000000000..948e1f7bf4 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/Bed.java @@ -0,0 +1,106 @@ +package org.bukkit.material; + +import org.bukkit.Material; +import org.bukkit.block.BlockFace; + +/** + * Represents a bed. + * + * @author sunkid + */ +public class Bed extends MaterialData implements Directional { + + /** + * Default constructor for a bed. + */ + public Bed() { + super(Material.BED_BLOCK); + } + + /** + * Instantiate a bed facing in a particular direction. + * @param direction the direction the bed's head is facing + */ + public Bed(BlockFace direction) { + this(); + setFacingDirection(direction); + } + + public Bed(final int type) { + super(type); + } + + public Bed(final Material type) { + super(type); + } + + public Bed(final int type, final byte data) { + super(type, data); + } + + public Bed(final Material type, final byte data) { + super(type, data); + } + + /** + * Determine if this block represents the head of the bed + * + * @return true if this is the head of the bed, false if it is the foot + */ + public boolean isHeadOfBed() { + return (getData() & 0x8) == 0x8; + } + + /** + * Set which direction the head of the bed is facing. Note that this will + * only affect one of the two blocks the bed is made of. + */ + public void setFacingDirection(BlockFace face) { + byte data; + switch (face) { + case WEST: + data = 0x0; + break; + case NORTH: + data = 0x1; + break; + case EAST: + data = 0x2; + break; + case SOUTH: + default: + data = 0x3; + } + + if (isHeadOfBed()) { + data |= 0x8; + } + + setData(data); + } + + /** + * Get the direction that this bed's head is facing toward + * + * @return the direction the head of the bed is facing + */ + public BlockFace getFacing() { + byte data = (byte) (getData() & 0x7); + switch (data) { + case 0x0: + return BlockFace.WEST; + case 0x1: + return BlockFace.NORTH; + case 0x2: + return BlockFace.EAST; + case 0x3: + default: + return BlockFace.SOUTH; + } + } + + @Override + public String toString() { + return (isHeadOfBed() ? "HEAD" : "FOOT") + " of " + super.toString() + " facing " + getFacing(); + } +} diff --git a/paper-api/src/main/java/org/bukkit/material/Button.java b/paper-api/src/main/java/org/bukkit/material/Button.java index c3c7abd8d0..7c7f96d543 100644 --- a/paper-api/src/main/java/org/bukkit/material/Button.java +++ b/paper-api/src/main/java/org/bukkit/material/Button.java @@ -6,7 +6,11 @@ import org.bukkit.Material; /** * Represents a button */ -public class Button extends MaterialData implements Redstone, Attachable { +public class Button extends SimpleAttachableMaterialData implements Redstone { + public Button() { + super(Material.STONE_BUTTON); + } + public Button(final int type) { super(type); } @@ -26,32 +30,72 @@ public class Button extends MaterialData implements Redstone, Attachable { /** * Gets the current state of this Material, indicating if it's powered or * unpowered - * + * * @return true if powered, otherwise false */ public boolean isPowered() { return (getData() & 0x8) == 0x8; } + /** + * Sets the current state of this button + * + * @param bool + * whether or not the button is powered + */ + public void setPowered(boolean bool) { + setData((byte) (bool ? (getData() | 0x8) : (getData() & ~0x8))); + } + /** * Gets the face that this block is attached on - * + * * @return BlockFace attached to */ public BlockFace getAttachedFace() { byte data = (byte) (getData() & 0x7); switch (data) { - case 0x1: - return BlockFace.NORTH; - case 0x2: - return BlockFace.SOUTH; - case 0x3: - return BlockFace.EAST; - case 0x4: - return BlockFace.WEST; + case 0x1: + return BlockFace.NORTH; + case 0x2: + return BlockFace.SOUTH; + case 0x3: + return BlockFace.EAST; + case 0x4: + return BlockFace.WEST; } return null; } + + /** + * Sets the direction this button is pointing toward + */ + public void setFacingDirection(BlockFace face) { + byte data = (byte) (getData() & 0x8); + + switch (face) { + case SOUTH: + data |= 0x1; + break; + case NORTH: + data |= 0x2; + break; + case WEST: + data |= 0x3; + break; + case EAST: + data |= 0x4; + break; + } + + setData(data); + } + + @Override + public String toString() { + return super.toString() + " " + (isPowered() ? "" : "NOT ") + "POWERED"; + } + } diff --git a/paper-api/src/main/java/org/bukkit/material/Cake.java b/paper-api/src/main/java/org/bukkit/material/Cake.java index 4b81031afb..86f3209645 100644 --- a/paper-api/src/main/java/org/bukkit/material/Cake.java +++ b/paper-api/src/main/java/org/bukkit/material/Cake.java @@ -3,6 +3,9 @@ package org.bukkit.material; import org.bukkit.Material; public class Cake extends MaterialData { + public Cake() { + super(Material.CAKE_BLOCK); + } public Cake(int type) { super(type); @@ -58,4 +61,10 @@ public class Cake extends MaterialData { if (n > 6) n = 6; setData((byte) (6 - n)); } + + @Override + public String toString() { + return super.toString() + " " + getSlicesEaten() + "/" + getSlicesRemaining() + " slices eaten/remaining"; + } + } diff --git a/paper-api/src/main/java/org/bukkit/material/Coal.java b/paper-api/src/main/java/org/bukkit/material/Coal.java index 25d43146e0..72aa7141b4 100644 --- a/paper-api/src/main/java/org/bukkit/material/Coal.java +++ b/paper-api/src/main/java/org/bukkit/material/Coal.java @@ -8,6 +8,15 @@ import org.bukkit.Material; * @author sunkid */ public class Coal extends MaterialData { + public Coal() { + super(Material.COAL); + } + + public Coal(CoalType type) { + this(); + setType(type); + } + public Coal(final int type) { super(type); } @@ -37,8 +46,25 @@ public class Coal extends MaterialData { * Sets the type of this coal * * @param type New type of this coal + * @deprecated use {@link #setType(CoalType)} instead */ + @Deprecated public void setSpecies(CoalType type) { - setData(type.getData()); + setType(type); } + + /** + * Sets the type of this coal + * + * @param type New type of this coal + */ + public void setType(CoalType type) { + setData(type.getData()); + } + + @Override + public String toString() { + return getType() + " " + super.toString(); + } + } diff --git a/paper-api/src/main/java/org/bukkit/material/Crops.java b/paper-api/src/main/java/org/bukkit/material/Crops.java index 0dacac6e2c..acbe21c43d 100644 --- a/paper-api/src/main/java/org/bukkit/material/Crops.java +++ b/paper-api/src/main/java/org/bukkit/material/Crops.java @@ -8,6 +8,15 @@ import org.bukkit.Material; * @author sunkid */ public class Crops extends MaterialData { + public Crops() { + super(Material.CROPS); + } + + public Crops(CropState state) { + this(); + setState(state); + } + public Crops(final int type) { super(type); } @@ -28,8 +37,19 @@ public class Crops extends MaterialData { * Gets the current growth state of this crop * * @return CropState of this leave + * @deprecated use {@link #getState()} instead */ + @Deprecated public CropState getSpecies() { + return getState(); + } + + /** + * Gets the current growth state of this crop + * + * @return CropState of this leave + */ + public CropState getState() { return CropState.getByData(getData()); } @@ -37,8 +57,25 @@ public class Crops extends MaterialData { * Sets the growth state of this crop * * @param state New growth state of this crop + * @deprecated use {@link #setState(CropState)} instead */ + @Deprecated public void setSpecies(CropState state) { + setState(state); + } + + /** + * Sets the growth state of this crop + * + * @param state New growth state of this crop + */ + public void setState(CropState state) { setData(state.getData()); } + + @Override + public String toString() { + return getState() + " " + super.toString(); + } + } diff --git a/paper-api/src/main/java/org/bukkit/material/Diode.java b/paper-api/src/main/java/org/bukkit/material/Diode.java index 1eeb849c65..4ffb650196 100644 --- a/paper-api/src/main/java/org/bukkit/material/Diode.java +++ b/paper-api/src/main/java/org/bukkit/material/Diode.java @@ -1,8 +1,12 @@ package org.bukkit.material; import org.bukkit.Material; +import org.bukkit.block.BlockFace; -public class Diode extends MaterialData { +public class Diode extends MaterialData implements Directional { + public Diode() { + super(Material.DIODE_BLOCK_ON); + } public Diode(int type) { super(type); @@ -23,21 +27,64 @@ public class Diode extends MaterialData { /** * Sets the delay of the repeater * - * @param delay The new delay (1-4) + * @param delay + * The new delay (1-4) */ public void setDelay(int delay) { if (delay > 4) delay = 4; if (delay < 1) delay = 1; byte newData = (byte) (getData() & 0x3); - setData((byte) (newData | (delay - 1))); + setData((byte) (newData | ((delay - 1) << 2))); } /** - * Gets the delay of the repeater + * Gets the delay of the repeater in ticks * * @return The delay (1-4) */ public int getDelay() { - return (getData() & 0xC) + 1; + return (getData() >> 2) + 1; + } + + public void setFacingDirection(BlockFace face) { + int delay = getDelay(); + byte data; + switch (face) { + case SOUTH: + data = 0x1; + break; + case WEST: + data = 0x2; + break; + case NORTH: + data = 0x3; + break; + case EAST: + default: + data = 0x0; + } + + setData(data); + setDelay(delay); + } + + public BlockFace getFacing() { + byte data = (byte) (getData() & 0x3); + switch (data) { + case 0x0: + default: + return BlockFace.EAST; + case 0x1: + return BlockFace.SOUTH; + case 0x2: + return BlockFace.WEST; + case 0x3: + return BlockFace.NORTH; + } + } + + @Override + public String toString() { + return super.toString() + " facing " + getFacing() + " with " + getDelay() + " ticks delay"; } } diff --git a/paper-api/src/main/java/org/bukkit/material/Directional.java b/paper-api/src/main/java/org/bukkit/material/Directional.java new file mode 100644 index 0000000000..ca8e805e61 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/Directional.java @@ -0,0 +1,18 @@ +package org.bukkit.material; + +import org.bukkit.block.BlockFace; + +public interface Directional { + + /** + * Sets the direction that this block is facing in + */ + public void setFacingDirection(BlockFace face); + + /** + * Gets the direction this block is facing + * + * @return the direction this block is facing + */ + public BlockFace getFacing(); +} diff --git a/paper-api/src/main/java/org/bukkit/material/Dispenser.java b/paper-api/src/main/java/org/bukkit/material/Dispenser.java new file mode 100644 index 0000000000..4ded9023f4 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/Dispenser.java @@ -0,0 +1,37 @@ +package org.bukkit.material; + +import org.bukkit.Material; +import org.bukkit.block.BlockFace; + +/** + * Represents a dispenser. + * + * @author sunkid + */ +public class Dispenser extends FurnaceAndDispenser { + + public Dispenser() { + super(Material.DISPENSER); + } + + public Dispenser(BlockFace direction) { + this(); + setFacingDirection(direction); + } + + public Dispenser(final int type) { + super(type); + } + + public Dispenser(final Material type) { + super(type); + } + + public Dispenser(final int type, final byte data) { + super(type, data); + } + + public Dispenser(final Material type, final byte data) { + super(type, data); + } +} diff --git a/paper-api/src/main/java/org/bukkit/material/Door.java b/paper-api/src/main/java/org/bukkit/material/Door.java index 8da166efe3..f2c827be50 100644 --- a/paper-api/src/main/java/org/bukkit/material/Door.java +++ b/paper-api/src/main/java/org/bukkit/material/Door.java @@ -4,10 +4,14 @@ import org.bukkit.Material; import org.bukkit.block.BlockFace; /** - * Represents the different types of coals. + * Represents a door. * @author sunkid */ public class Door extends MaterialData { + public Door() { + super(Material.WOODEN_DOOR); + } + public Door(final int type) { super(type); } @@ -54,4 +58,10 @@ public class Door extends MaterialData { return BlockFace.NORTH_EAST; } + + @Override + public String toString() { + return (isTopHalf() ? "TOP" : "BOTTOM") + " half of " + (isOpen() ? "an OPEN " : "a CLOSED ") + super.toString() + " with hinges " + getHingeCorner(); + } + } diff --git a/paper-api/src/main/java/org/bukkit/material/Dye.java b/paper-api/src/main/java/org/bukkit/material/Dye.java index aff7abdbf8..ccf5a633f5 100644 --- a/paper-api/src/main/java/org/bukkit/material/Dye.java +++ b/paper-api/src/main/java/org/bukkit/material/Dye.java @@ -8,6 +8,10 @@ import org.bukkit.Material; * Represents dye */ public class Dye extends MaterialData implements Colorable { + public Dye() { + super(Material.INK_SACK); + } + public Dye(final int type) { super(type); } @@ -30,7 +34,7 @@ public class Dye extends MaterialData implements Colorable { * @return DyeColor of this dye */ public DyeColor getColor() { - return DyeColor.getByData(getData()); + return DyeColor.getByData((byte) (15 - getData())); } /** @@ -39,6 +43,11 @@ public class Dye extends MaterialData implements Colorable { * @param color New color of this dye */ public void setColor(DyeColor color) { - setData(color.getData()); + setData((byte) (15 - color.getData())); + } + + @Override + public String toString() { + return getColor() + " DYE(" + getData() + ")"; } } diff --git a/paper-api/src/main/java/org/bukkit/material/Furnace.java b/paper-api/src/main/java/org/bukkit/material/Furnace.java new file mode 100644 index 0000000000..cdfe2a4395 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/Furnace.java @@ -0,0 +1,41 @@ +package org.bukkit.material; + +import org.bukkit.Material; +import org.bukkit.block.BlockFace; + +/** + * Represents a furnace. + * + * @author sunkid + */ +public class Furnace extends FurnaceAndDispenser { + + public Furnace() { + super(Material.FURNACE); + } + + /** + * Instantiate a furnace facing in a particular direction. + * @param direction the direction the furnace's "opening" is facing + */ + public Furnace(BlockFace direction) { + this(); + setFacingDirection(direction); + } + + public Furnace(final int type) { + super(type); + } + + public Furnace(final Material type) { + super(type); + } + + public Furnace(final int type, final byte data) { + super(type, data); + } + + public Furnace(final Material type, final byte data) { + super(type, data); + } +} diff --git a/paper-api/src/main/java/org/bukkit/material/FurnaceAndDispenser.java b/paper-api/src/main/java/org/bukkit/material/FurnaceAndDispenser.java new file mode 100644 index 0000000000..24cefbec15 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/FurnaceAndDispenser.java @@ -0,0 +1,66 @@ +package org.bukkit.material; + +import org.bukkit.Material; +import org.bukkit.block.BlockFace; + +/** + * Represents a furnace or a dispenser. + * @author sunkid + */ +public class FurnaceAndDispenser extends MaterialData implements Directional { + public FurnaceAndDispenser(final int type) { + super(type); + } + + public FurnaceAndDispenser(final Material type) { + super(type); + } + + public FurnaceAndDispenser(final int type, final byte data) { + super(type, data); + } + + public FurnaceAndDispenser(final Material type, final byte data) { + super(type, data); + } + + public void setFacingDirection(BlockFace face) { + byte data; + switch (face) { + case EAST: + data = 0x2; + break; + case WEST: + data = 0x3; + break; + case NORTH: + data = 0x4; + break; + case SOUTH: + default: + data = 0x5; + } + + setData(data); + } + + public BlockFace getFacing() { + byte data = getData(); + switch (data) { + case 0x2: + return BlockFace.EAST; + case 0x3: + return BlockFace.WEST; + case 0x4: + return BlockFace.NORTH; + case 0x5: + default: + return BlockFace.SOUTH; + } + } + + @Override + public String toString() { + return super.toString() + " facing " + getFacing(); + } +} diff --git a/paper-api/src/main/java/org/bukkit/material/Jukebox.java b/paper-api/src/main/java/org/bukkit/material/Jukebox.java index 49825dc9a7..a11f12aa18 100644 --- a/paper-api/src/main/java/org/bukkit/material/Jukebox.java +++ b/paper-api/src/main/java/org/bukkit/material/Jukebox.java @@ -1,15 +1,28 @@ package org.bukkit.material; +import java.util.HashSet; + import org.bukkit.Material; public class Jukebox extends MaterialData { + private static HashSet recordTypes = new HashSet(); + static { + recordTypes.add(Material.GOLD_RECORD); + recordTypes.add(Material.GREEN_RECORD); + } + + public Jukebox() { + super(Material.JUKEBOX); + } public Jukebox(int type) { super(type); } public Jukebox(Material type) { - super(type); + super((recordTypes.contains(type)) ? Material.JUKEBOX : type); + if(recordTypes.contains(type)) + setPlaying(type); } public Jukebox(int type, byte data) { @@ -55,4 +68,10 @@ public class Jukebox extends MaterialData { setData((byte) 0x0); } } + + @Override + public String toString() { + return super.toString() + " playing " + getPlaying(); + } + } diff --git a/paper-api/src/main/java/org/bukkit/material/Ladder.java b/paper-api/src/main/java/org/bukkit/material/Ladder.java index a5d5c20801..74bc74e568 100644 --- a/paper-api/src/main/java/org/bukkit/material/Ladder.java +++ b/paper-api/src/main/java/org/bukkit/material/Ladder.java @@ -1,4 +1,3 @@ - package org.bukkit.material; import org.bukkit.block.BlockFace; @@ -7,7 +6,11 @@ import org.bukkit.Material; /** * Represents Ladder data */ -public class Ladder extends MaterialData implements Attachable { +public class Ladder extends SimpleAttachableMaterialData { + public Ladder() { + super(Material.LADDER); + } + public Ladder(final int type) { super(type); } @@ -26,23 +29,48 @@ public class Ladder extends MaterialData implements Attachable { /** * Gets the face that this block is attached on - * + * * @return BlockFace attached to */ public BlockFace getAttachedFace() { byte data = getData(); switch (data) { - case 0x2: - return BlockFace.WEST; - case 0x3: - return BlockFace.EAST; - case 0x4: - return BlockFace.SOUTH; - case 0x5: - return BlockFace.NORTH; + case 0x2: + return BlockFace.WEST; + case 0x3: + return BlockFace.EAST; + case 0x4: + return BlockFace.SOUTH; + case 0x5: + return BlockFace.NORTH; } return null; } + + /** + * Sets the direction this ladder is facing + */ + public void setFacingDirection(BlockFace face) { + byte data = (byte) 0x0; + + switch (face) { + case WEST: + data = 0x2; + break; + case EAST: + data = 0x3; + break; + case SOUTH: + data = 0x4; + break; + case NORTH: + data = 0x5; + break; + } + + setData(data); + + } } \ No newline at end of file diff --git a/paper-api/src/main/java/org/bukkit/material/Leaves.java b/paper-api/src/main/java/org/bukkit/material/Leaves.java index 20c957c0e7..ec27d4a414 100644 --- a/paper-api/src/main/java/org/bukkit/material/Leaves.java +++ b/paper-api/src/main/java/org/bukkit/material/Leaves.java @@ -8,6 +8,15 @@ import org.bukkit.TreeSpecies; * @author sunkid */ public class Leaves extends MaterialData { + public Leaves() { + super(Material.LEAVES); + } + + public Leaves(TreeSpecies species) { + this(); + setSpecies(species); + } + public Leaves(final int type) { super(type); } @@ -41,4 +50,9 @@ public class Leaves extends MaterialData { public void setSpecies(TreeSpecies species) { setData(species.getData()); } + + @Override + public String toString() { + return getSpecies() + " " + super.toString(); + } } diff --git a/paper-api/src/main/java/org/bukkit/material/Lever.java b/paper-api/src/main/java/org/bukkit/material/Lever.java index 4d9742cab1..fa9a881717 100644 --- a/paper-api/src/main/java/org/bukkit/material/Lever.java +++ b/paper-api/src/main/java/org/bukkit/material/Lever.java @@ -6,7 +6,11 @@ import org.bukkit.Material; /** * Represents a lever */ -public class Lever extends MaterialData implements Redstone, Attachable { +public class Lever extends SimpleAttachableMaterialData implements Redstone { + public Lever() { + super(Material.LEVER); + } + public Lever(final int type) { super(type); } @@ -26,7 +30,7 @@ public class Lever extends MaterialData implements Redstone, Attachable { /** * Gets the current state of this Material, indicating if it's powered or * unpowered - * + * * @return true if powered, otherwise false */ public boolean isPowered() { @@ -35,26 +39,68 @@ public class Lever extends MaterialData implements Redstone, Attachable { /** * Gets the face that this block is attached on - * + * * @return BlockFace attached to */ public BlockFace getAttachedFace() { byte data = (byte) (getData() & 0x7); switch (data) { - case 0x1: - return BlockFace.NORTH; - case 0x2: - return BlockFace.SOUTH; - case 0x3: - return BlockFace.EAST; - case 0x4: - return BlockFace.WEST; - case 0x5: - case 0x6: - return BlockFace.DOWN; + case 0x1: + return BlockFace.NORTH; + case 0x2: + return BlockFace.SOUTH; + case 0x3: + return BlockFace.EAST; + case 0x4: + return BlockFace.WEST; + case 0x5: + case 0x6: + return BlockFace.DOWN; } return null; } + + /** + * Sets the direction this lever is pointing in + */ + public void setFacingDirection(BlockFace face) { + byte data = (byte) (getData() & 0x8); + + if (getAttachedFace() == BlockFace.DOWN) { + switch (face) { + case WEST: + case EAST: + data |= 0x5; + break; + case SOUTH: + case NORTH: + data |= 0x6; + break; + } + } else { + switch (face) { + case SOUTH: + data |= 0x1; + break; + case NORTH: + data |= 0x2; + break; + case WEST: + data |= 0x3; + break; + case EAST: + data |= 0x4; + break; + } + } + setData(data); + } + + @Override + public String toString() { + return super.toString() + " facing " + getFacing() + " " + (isPowered() ? "" : "NOT ") + "POWERED"; + } + } diff --git a/paper-api/src/main/java/org/bukkit/material/MaterialData.java b/paper-api/src/main/java/org/bukkit/material/MaterialData.java index 6de1730f7d..abbcb2336c 100644 --- a/paper-api/src/main/java/org/bukkit/material/MaterialData.java +++ b/paper-api/src/main/java/org/bukkit/material/MaterialData.java @@ -70,6 +70,20 @@ public class MaterialData { * @return New ItemStack containing a copy of this MaterialData */ public ItemStack toItemStack() { - return new ItemStack(type); + return new ItemStack(type, 0, data); + } + + /** + * Creates a new ItemStack based on this MaterialData + * + * @return New ItemStack containing a copy of this MaterialData + */ + public ItemStack toItemStack(int amount) { + return new ItemStack(type, amount, data); + } + + @Override + public String toString() { + return getItemType() + "(" + getData() + ")"; } } diff --git a/paper-api/src/main/java/org/bukkit/material/PressurePlate.java b/paper-api/src/main/java/org/bukkit/material/PressurePlate.java new file mode 100644 index 0000000000..bdcf0aa67b --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/PressurePlate.java @@ -0,0 +1,39 @@ +package org.bukkit.material; + +import org.bukkit.Material; + +/** + * Represents a pressure plate + * @author CelticMinstrel + * + */ +public class PressurePlate extends MaterialData { + public PressurePlate() { + super(Material.WOOD_PLATE); + } + + public PressurePlate(int type) { + super(type); + } + + public PressurePlate(Material type) { + super(type); + } + + public PressurePlate(int type, byte data) { + super(type, data); + } + + public PressurePlate(Material type, byte data) { + super(type, data); + } + + public boolean isPressed() { + return getData() == 0x1; + } + + @Override + public String toString() { + return super.toString() + (isPressed() ? " PRESSED" : ""); + } +} \ No newline at end of file diff --git a/paper-api/src/main/java/org/bukkit/material/Pumpkin.java b/paper-api/src/main/java/org/bukkit/material/Pumpkin.java new file mode 100644 index 0000000000..6550adcd3d --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/Pumpkin.java @@ -0,0 +1,85 @@ +package org.bukkit.material; + +import org.bukkit.Material; +import org.bukkit.block.BlockFace; + +/** + * Represents a pumpkin. + * + * @author sunkid + */ +public class Pumpkin extends MaterialData implements Directional { + + public Pumpkin() { + super(Material.PUMPKIN); + } + + /** + * Instantiate a pumpkin facing in a particular direction. + * @param direction the direction the pumkin's face is facing + */ + public Pumpkin(BlockFace direction) { + this(); + setFacingDirection(direction); + } + + public Pumpkin(final int type) { + super(type); + } + + public Pumpkin(final Material type) { + super(type); + } + + public Pumpkin(final int type, final byte data) { + super(type, data); + } + + public Pumpkin(final Material type, final byte data) { + super(type, data); + } + + public boolean isLit() { + return getItemType() == Material.JACK_O_LANTERN; + } + + public void setFacingDirection(BlockFace face) { + byte data; + switch (face) { + case EAST: + data = 0x0; + break; + case SOUTH: + data = 0x1; + break; + case WEST: + data = 0x2; + break; + case NORTH: + default: + data = 0x3; + } + + setData(data); + } + + public BlockFace getFacing() { + byte data = getData(); + switch (data) { + case 0x0: + return BlockFace.EAST; + case 0x1: + return BlockFace.SOUTH; + case 0x2: + return BlockFace.WEST; + case 0x3: + default: + return BlockFace.SOUTH; + } + } + + @Override + public String toString() { + return super.toString() + " facing " + getFacing() + " " + (isLit() ? "" : "NOT ") + "LIT"; + } +} diff --git a/paper-api/src/main/java/org/bukkit/material/Rails.java b/paper-api/src/main/java/org/bukkit/material/Rails.java new file mode 100644 index 0000000000..d58d8fc606 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/Rails.java @@ -0,0 +1,87 @@ +package org.bukkit.material; + +import org.bukkit.Material; +import org.bukkit.block.BlockFace; + +/** + * Represents minecart rails. + * + * @author sunkid + */ +public class Rails extends MaterialData { + + public Rails() { + super(Material.RAILS); + } + + public Rails(final int type) { + super(type); + } + + public Rails(final Material type) { + super(type); + } + + public Rails(final int type, final byte data) { + super(type, data); + } + + public Rails(final Material type, final byte data) { + super(type, data); + } + + /** + * @return the whether this track is set on a slope + */ + public boolean isOnSlope() { + byte d = getData(); + return (d == 0x2 || d == 0x3 || d == 0x4 || d == 0x5); + } + + /** + * @return the whether this track is set as a curve + */ + public boolean isCurve() { + byte d = getData(); + return (d == 0x6 || d == 0x7 || d == 0x8 || d == 0x9); + } + + /** + * @return the direction these tracks are set
+ * Note that tracks are bidirectional and that the direction + * returned is the ascending direction if the track is set on a + * slope. If it is set as a curve, the corner of the track is + * returned. + */ + public BlockFace getDirection() { + byte d = getData(); + switch (d) { + case 0x0: + default: + return BlockFace.WEST; + case 0x1: + return BlockFace.SOUTH; + case 0x2: + return BlockFace.SOUTH; + case 0x3: + return BlockFace.NORTH; + case 0x4: + return BlockFace.EAST; + case 0x5: + return BlockFace.WEST; + case 0x6: + return BlockFace.NORTH_EAST; + case 0x7: + return BlockFace.SOUTH_EAST; + case 0x8: + return BlockFace.SOUTH_WEST; + case 0x9: + return BlockFace.NORTH_WEST; + } + } + + @Override + public String toString() { + return super.toString() + " facing " + getDirection() + (isCurve() ? " on a curve" : (isOnSlope() ? " on a slope" : "")); + } +} diff --git a/paper-api/src/main/java/org/bukkit/material/RedstoneTorch.java b/paper-api/src/main/java/org/bukkit/material/RedstoneTorch.java index 04e5148dda..a10652048a 100644 --- a/paper-api/src/main/java/org/bukkit/material/RedstoneTorch.java +++ b/paper-api/src/main/java/org/bukkit/material/RedstoneTorch.java @@ -7,6 +7,10 @@ import org.bukkit.Material; * Represents a redstone torch */ public class RedstoneTorch extends Torch implements Redstone { + public RedstoneTorch() { + super(Material.REDSTONE_TORCH_ON); + } + public RedstoneTorch(final int type) { super(type); } @@ -32,4 +36,9 @@ public class RedstoneTorch extends Torch implements Redstone { public boolean isPowered() { return getItemType() == Material.REDSTONE_TORCH_ON; } + + @Override + public String toString() { + return super.toString() + " " + (isPowered() ? "" : "NOT ") + "POWERED"; + } } diff --git a/paper-api/src/main/java/org/bukkit/material/RedstoneWire.java b/paper-api/src/main/java/org/bukkit/material/RedstoneWire.java index f11c508cff..9e4594f0bb 100644 --- a/paper-api/src/main/java/org/bukkit/material/RedstoneWire.java +++ b/paper-api/src/main/java/org/bukkit/material/RedstoneWire.java @@ -7,6 +7,10 @@ import org.bukkit.Material; * Represents redstone wire */ public class RedstoneWire extends MaterialData implements Redstone { + public RedstoneWire() { + super(Material.REDSTONE_WIRE); + } + public RedstoneWire(final int type) { super(type); } @@ -32,4 +36,9 @@ public class RedstoneWire extends MaterialData implements Redstone { public boolean isPowered() { return getData() > 0; } + + @Override + public String toString() { + return super.toString() + " " + (isPowered() ? "" : "NOT ") + "POWERED"; + } } diff --git a/paper-api/src/main/java/org/bukkit/material/Sign.java b/paper-api/src/main/java/org/bukkit/material/Sign.java index 4d6f2a04ae..50ef8a0087 100644 --- a/paper-api/src/main/java/org/bukkit/material/Sign.java +++ b/paper-api/src/main/java/org/bukkit/material/Sign.java @@ -1,4 +1,3 @@ - package org.bukkit.material; import org.bukkit.block.BlockFace; @@ -8,6 +7,10 @@ import org.bukkit.Material; * MaterialData for signs */ public class Sign extends MaterialData implements Attachable { + public Sign() { + super(Material.SIGN_POST); + } + public Sign(final int type) { super(type); } @@ -24,24 +27,34 @@ public class Sign extends MaterialData implements Attachable { super(type, data); } + /** + * Check if this sign is attached to a wall + * + * @return true if this sign is attached to a wall, false if set on top of a + * block + */ + public boolean isWallSign() { + return getItemType() == Material.WALL_SIGN; + } + /** * Gets the face that this block is attached on - * + * * @return BlockFace attached to */ public BlockFace getAttachedFace() { - if (getItemType() == Material.WALL_SIGN) { + if (isWallSign()) { byte data = getData(); switch (data) { - case 0x2: - return BlockFace.WEST; - case 0x3: - return BlockFace.EAST; - case 0x4: - return BlockFace.SOUTH; - case 0x5: - return BlockFace.NORTH; + case 0x2: + return BlockFace.WEST; + case 0x3: + return BlockFace.EAST; + case 0x4: + return BlockFace.SOUTH; + case 0x5: + return BlockFace.NORTH; } return null; @@ -52,54 +65,97 @@ public class Sign extends MaterialData implements Attachable { /** * Gets the direction that this sign is currently facing - * + * * @return BlockFace indicating where this sign is facing */ public BlockFace getFacing() { byte data = getData(); - if (getAttachedFace() == BlockFace.DOWN) { + if (!isWallSign()) { switch (data) { - case 0x0: - case 0x1: - return BlockFace.WEST; - case 0x2: - case 0x3: - return BlockFace.NORTH_WEST; - case 0x4: - case 0x5: - return BlockFace.NORTH; - case 0x6: - case 0x7: - return BlockFace.NORTH_EAST; - case 0x8: - case 0x9: - return BlockFace.EAST; - case 0xA: - case 0xB: - return BlockFace.SOUTH_EAST; - case 0xC: - case 0xD: - return BlockFace.SOUTH; - case 0xE: - case 0xF: - return BlockFace.SOUTH_WEST; + case 0x0: + case 0x1: + return BlockFace.WEST; + case 0x2: + case 0x3: + return BlockFace.NORTH_WEST; + case 0x4: + case 0x5: + return BlockFace.NORTH; + case 0x6: + case 0x7: + return BlockFace.NORTH_EAST; + case 0x8: + case 0x9: + return BlockFace.EAST; + case 0xA: + case 0xB: + return BlockFace.SOUTH_EAST; + case 0xC: + case 0xD: + return BlockFace.SOUTH; + case 0xE: + case 0xF: + return BlockFace.SOUTH_WEST; } return null; } else { - switch (data) { - case 0x2: - return BlockFace.EAST; - case 0x3: - return BlockFace.WEST; - case 0x4: - return BlockFace.NORTH; - case 0x5: - return BlockFace.SOUTH; + return getAttachedFace().getOppositeFace(); + } + } + + public void setFacingDirection(BlockFace face) { + byte data; + if (isWallSign()) { + switch (face) { + case EAST: + data = 0x2; + break; + case WEST: + data = 0x3; + break; + case NORTH: + data = 0x4; + break; + case SOUTH: + default: + data = 0x5; + } + } else { + switch (face) { + case WEST: + data = 0x1; + break; + case NORTH_WEST: + data = 0x3; + break; + case NORTH: + data = 0x5; + break; + case NORTH_EAST: + data = 0x7; + break; + case EAST: + data = 0x9; + break; + case SOUTH_EAST: + data = 0xB; + break; + case SOUTH: + data = 0xD; + break; + case SOUTH_WEST: + default: + data = 0xF; } } - return null; + setData(data); + } + + @Override + public String toString() { + return super.toString() + " facing " + getFacing(); } } diff --git a/paper-api/src/main/java/org/bukkit/material/SimpleAttachableMaterialData.java b/paper-api/src/main/java/org/bukkit/material/SimpleAttachableMaterialData.java new file mode 100644 index 0000000000..3de02b943e --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/SimpleAttachableMaterialData.java @@ -0,0 +1,48 @@ +package org.bukkit.material; + +import org.bukkit.Material; +import org.bukkit.block.BlockFace; + +/** + * Simple utility class for attachable MaterialData subclasses + * @author sunkid + * + */ +public abstract class SimpleAttachableMaterialData extends MaterialData implements Attachable { + + public SimpleAttachableMaterialData(int type) { + super(type); + } + + public SimpleAttachableMaterialData(int type, BlockFace direction) { + this(type); + setFacingDirection(direction); + } + + public SimpleAttachableMaterialData(Material type, BlockFace direction) { + this(type); + setFacingDirection(direction); + } + + public SimpleAttachableMaterialData(Material type) { + super(type); + } + + public SimpleAttachableMaterialData(int type, byte data) { + super(type, data); + } + + public SimpleAttachableMaterialData(Material type, byte data) { + super(type, data); + } + + public BlockFace getFacing() { + return getAttachedFace().getOppositeFace(); + } + + @Override + public String toString() { + return super.toString() + " facing " + getFacing(); + } + +} diff --git a/paper-api/src/main/java/org/bukkit/material/Stairs.java b/paper-api/src/main/java/org/bukkit/material/Stairs.java new file mode 100644 index 0000000000..caeae3958c --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/material/Stairs.java @@ -0,0 +1,90 @@ +package org.bukkit.material; + +import org.bukkit.Material; +import org.bukkit.block.BlockFace; + +/** + * Represents stairs. + * + * @author sunkid + */ +public class Stairs extends MaterialData implements Directional { + + public Stairs(final int type) { + super(type); + } + + public Stairs(final Material type) { + super(type); + } + + public Stairs(final int type, final byte data) { + super(type, data); + } + + public Stairs(final Material type, final byte data) { + super(type, data); + } + + /** + * @return the direction the stairs ascend towards + */ + public BlockFace getAscendingDirection() { + byte data = getData(); + switch (data) { + case 0x0: + default: + return BlockFace.SOUTH; + case 0x1: + return BlockFace.NORTH; + case 0x2: + return BlockFace.WEST; + case 0x3: + return BlockFace.EAST; + } + } + + /** + * @return the direction the stairs descend towards + */ + public BlockFace getDescendingDirection() { + return getAscendingDirection().getOppositeFace(); + } + + /** + * Set the direction the stair part of the block is facing + */ + public void setFacingDirection(BlockFace face) { + byte data; + switch (face) { + case NORTH: + default: + data = 0x0; + break; + case SOUTH: + data = 0x1; + break; + case EAST: + data = 0x2; + break; + case WEST: + data = 0x3; + break; + } + + setData(data); + } + + /** + * @return the direction the stair part of the block is facing + */ + public BlockFace getFacing() { + return getDescendingDirection(); + } + + @Override + public String toString() { + return super.toString() + " facing " + getFacing(); + } + +} diff --git a/paper-api/src/main/java/org/bukkit/material/Step.java b/paper-api/src/main/java/org/bukkit/material/Step.java index be1be03e80..b0a177c7ca 100644 --- a/paper-api/src/main/java/org/bukkit/material/Step.java +++ b/paper-api/src/main/java/org/bukkit/material/Step.java @@ -1,5 +1,7 @@ package org.bukkit.material; +import java.util.HashSet; + import org.bukkit.Material; /** @@ -7,12 +9,26 @@ import org.bukkit.Material; * @author sunkid */ public class Step extends MaterialData { + private static HashSet stepTypes = new HashSet(); + 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(type); + super((stepTypes.contains(type)) ? Material.STEP : type); + if(stepTypes.contains(type)) + setMaterial(type); } public Step(final int type, final byte data) { @@ -63,4 +79,9 @@ public class Step extends MaterialData { setData((byte) 0x0); } } + + @Override + public String toString() { + return getMaterial() + " " + super.toString(); + } } diff --git a/paper-api/src/main/java/org/bukkit/material/Torch.java b/paper-api/src/main/java/org/bukkit/material/Torch.java index cef646fc0f..8e44073efb 100644 --- a/paper-api/src/main/java/org/bukkit/material/Torch.java +++ b/paper-api/src/main/java/org/bukkit/material/Torch.java @@ -1,4 +1,3 @@ - package org.bukkit.material; import org.bukkit.block.BlockFace; @@ -7,7 +6,11 @@ import org.bukkit.Material; /** * MaterialData for torches */ -public class Torch extends MaterialData implements Attachable { +public class Torch extends SimpleAttachableMaterialData { + public Torch() { + super(Material.TORCH); + } + public Torch(final int type) { super(type); } @@ -26,25 +29,48 @@ public class Torch extends MaterialData implements Attachable { /** * Gets the face that this block is attached on - * + * * @return BlockFace attached to */ public BlockFace getAttachedFace() { byte data = getData(); switch (data) { - case 0x1: - return BlockFace.NORTH; - case 0x2: - return BlockFace.SOUTH; - case 0x3: - return BlockFace.EAST; - case 0x4: - return BlockFace.WEST; - case 0x5: - return BlockFace.DOWN; + case 0x1: + return BlockFace.NORTH; + case 0x2: + return BlockFace.SOUTH; + case 0x3: + return BlockFace.EAST; + case 0x4: + return BlockFace.WEST; + case 0x5: + return BlockFace.DOWN; } return null; } + + public void setFacingDirection(BlockFace face) { + byte data; + switch (face) { + case SOUTH: + data = 0x1; + break; + case NORTH: + data = 0x2; + break; + case WEST: + data = 0x3; + break; + case EAST: + data = 0x4; + break; + case UP: + default: + data = 0x5; + } + + setData(data); + } } diff --git a/paper-api/src/main/java/org/bukkit/material/Tree.java b/paper-api/src/main/java/org/bukkit/material/Tree.java index c81e468e2b..540a1fec05 100644 --- a/paper-api/src/main/java/org/bukkit/material/Tree.java +++ b/paper-api/src/main/java/org/bukkit/material/Tree.java @@ -8,6 +8,15 @@ import org.bukkit.TreeSpecies; * @author sunkid */ public class Tree extends MaterialData { + public Tree() { + super(Material.LOG); + } + + public Tree(TreeSpecies species) { + this(); + setSpecies(species); + } + public Tree(final int type) { super(type); } @@ -41,4 +50,9 @@ public class Tree extends MaterialData { public void setSpecies(TreeSpecies species) { setData(species.getData()); } + + @Override + public String toString() { + return getSpecies() + " " + super.toString(); + } } diff --git a/paper-api/src/main/java/org/bukkit/material/Wool.java b/paper-api/src/main/java/org/bukkit/material/Wool.java index 98af83e40c..79f91235b3 100644 --- a/paper-api/src/main/java/org/bukkit/material/Wool.java +++ b/paper-api/src/main/java/org/bukkit/material/Wool.java @@ -8,6 +8,15 @@ import org.bukkit.Material; * Represents a Wool/Cloth block */ public class Wool extends MaterialData implements Colorable { + public Wool() { + super(Material.WOOL); + } + + public Wool(DyeColor color) { + this(); + setColor(color); + } + public Wool(final int type) { super(type); } @@ -41,4 +50,9 @@ public class Wool extends MaterialData implements Colorable { public void setColor(DyeColor color) { setData(color.getData()); } + + @Override + public String toString() { + return getColor() + " " + super.toString(); + } } \ No newline at end of file