Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit.material;
2
3import org.bukkit.Material;
4
5public class Cake extends MaterialData {
6 public Cake() {
7 super(Material.CAKE_BLOCK);
8 }
9
10 public Cake(int type) {
11 super(type);
12 }
13
14 public Cake(Material type) {
15 super(type);
16 }
17
18 public Cake(int type, byte data) {
19 super(type, data);
20 }
21
22 public Cake(Material type, byte data) {
23 super(type, data);
24 }
25
26 /**
27 * Gets the number of slices eaten from this cake
28 *
29 * @return The number of slices eaten
30 */
31 public int getSlicesEaten() {
32 return getData();
33 }
34
35 /**
36 * Gets the number of slices remaining on this cake
37 *
38 * @return The number of slices remaining
39 */
40 public int getSlicesRemaining() {
41 return 6 - getData();
42 }
43
44 /**
45 * Sets the number of slices eaten from this cake
46 *
47 * @param n The number of slices eaten
48 */
49 public void setSlicesEaten(int n) {
50 if (n < 6) {
51 setData((byte) n);
52 } // TODO: else destroy the block? Probably not possible though
53 }
54
55 /**
56 * Sets the number of slices remaining on this cake
57 *
58 * @param n The number of slices remaining
59 */
60 public void setSlicesRemaining(int n) {
61 if (n > 6) {
62 n = 6;
63 }
64 setData((byte) (6 - n));
65 }
66
67 @Override
68 public String toString() {
69 return super.toString() + " " + getSlicesEaten() + "/" + getSlicesRemaining() + " slices eaten/remaining";
70 }
71}