13
0
geforkt von Mirrors/Paper

Change inheritance for new MaterialData.

By: Wesley Wolfe <weswolf@aol.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2012-08-05 22:01:54 -05:00
Ursprung 5154864bbc
Commit d63210b3ec
4 geänderte Dateien mit 82 neuen und 53 gelöschten Zeilen

Datei anzeigen

@ -6,7 +6,7 @@ import org.bukkit.block.BlockFace;
/** /**
* Represents a chest * Represents a chest
*/ */
public class Chest extends FurnaceAndDispenser { public class Chest extends DirectionalContainer {
public Chest() { public Chest() {
super(Material.CHEST); super(Material.CHEST);

Datei anzeigen

@ -0,0 +1,78 @@
package org.bukkit.material;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
/**
* Represents a furnace or a dispenser.
*/
public class DirectionalContainer extends MaterialData implements Directional {
public DirectionalContainer(final int type) {
super(type);
}
public DirectionalContainer(final Material type) {
super(type);
}
public DirectionalContainer(final int type, final byte data) {
super(type, data);
}
public DirectionalContainer(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();
}
@Override
public DirectionalContainer clone() {
return (DirectionalContainer) super.clone();
}
}

Datei anzeigen

@ -6,7 +6,7 @@ import org.bukkit.block.BlockFace;
/** /**
* Represents an ender chest * Represents an ender chest
*/ */
public class EnderChest extends FurnaceAndDispenser { public class EnderChest extends DirectionalContainer {
public EnderChest() { public EnderChest() {
super(Material.ENDER_CHEST); super(Material.ENDER_CHEST);

Datei anzeigen

@ -1,12 +1,11 @@
package org.bukkit.material; package org.bukkit.material;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace;
/** /**
* Represents a furnace or a dispenser. * Represents a furnace or dispenser, two types of directional containers
*/ */
public class FurnaceAndDispenser extends MaterialData implements Directional { public class FurnaceAndDispenser extends DirectionalContainer {
public FurnaceAndDispenser(final int type) { public FurnaceAndDispenser(final int type) {
super(type); super(type);
} }
@ -23,54 +22,6 @@ public class FurnaceAndDispenser extends MaterialData implements Directional {
super(type, 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();
}
@Override @Override
public FurnaceAndDispenser clone() { public FurnaceAndDispenser clone() {
return (FurnaceAndDispenser) super.clone(); return (FurnaceAndDispenser) super.clone();