Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
Cake.java
1 package org.bukkit.material;
2 
3 import org.bukkit.Material;
4 
5 public class Cake extends MaterialData {
6  public Cake() {
7  super(Material.CAKE_BLOCK);
8  }
9 
10  /**
11  *
12  * @deprecated Magic value
13  */
14  @Deprecated
15  public Cake(int type) {
16  super(type);
17  }
18 
19  public Cake(Material type) {
20  super(type);
21  }
22 
23  /**
24  *
25  * @deprecated Magic value
26  */
27  @Deprecated
28  public Cake(int type, byte data) {
29  super(type, data);
30  }
31 
32  /**
33  *
34  * @deprecated Magic value
35  */
36  @Deprecated
37  public Cake(Material type, byte data) {
38  super(type, data);
39  }
40 
41  /**
42  * Gets the number of slices eaten from this cake
43  *
44  * @return The number of slices eaten
45  */
46  public int getSlicesEaten() {
47  return getData();
48  }
49 
50  /**
51  * Gets the number of slices remaining on this cake
52  *
53  * @return The number of slices remaining
54  */
55  public int getSlicesRemaining() {
56  return 6 - getData();
57  }
58 
59  /**
60  * Sets the number of slices eaten from this cake
61  *
62  * @param n The number of slices eaten
63  */
64  public void setSlicesEaten(int n) {
65  if (n < 6) {
66  setData((byte) n);
67  } // TODO: else destroy the block? Probably not possible though
68  }
69 
70  /**
71  * Sets the number of slices remaining on this cake
72  *
73  * @param n The number of slices remaining
74  */
75  public void setSlicesRemaining(int n) {
76  if (n > 6) {
77  n = 6;
78  }
79  setData((byte) (6 - n));
80  }
81 
82  @Override
83  public String toString() {
84  return super.toString() + " " + getSlicesEaten() + "/" + getSlicesRemaining() + " slices eaten/remaining";
85  }
86 
87  @Override
88  public Cake clone() {
89  return (Cake) super.clone();
90  }
91 }
void setSlicesEaten(int n)
Definition: Cake.java:64
void setSlicesRemaining(int n)
Definition: Cake.java:75
Cake(Material type, byte data)
Definition: Cake.java:37
Cake(int type, byte data)
Definition: Cake.java:28