Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
MapCursor.java
1 package org.bukkit.map;
2 
3 /**
4  * Represents a cursor on a map.
5  */
6 public final class MapCursor {
7  private byte x, y;
8  private byte direction, type;
9  private boolean visible;
10 
11  /**
12  * Initialize the map cursor.
13  *
14  * @param x The x coordinate, from -128 to 127.
15  * @param y The y coordinate, from -128 to 127.
16  * @param direction The facing of the cursor, from 0 to 15.
17  * @param type The type (color/style) of the map cursor.
18  * @param visible Whether the cursor is visible by default.
19  * @deprecated Magic value
20  */
21  @Deprecated
22  public MapCursor(byte x, byte y, byte direction, byte type, boolean visible) {
23  this.x = x;
24  this.y = y;
25  setDirection(direction);
26  setRawType(type);
27  this.visible = visible;
28  }
29 
30  /**
31  * Get the X position of this cursor.
32  *
33  * @return The X coordinate.
34  */
35  public byte getX() {
36  return x;
37  }
38 
39  /**
40  * Get the Y position of this cursor.
41  *
42  * @return The Y coordinate.
43  */
44  public byte getY() {
45  return y;
46  }
47 
48  /**
49  * Get the direction of this cursor.
50  *
51  * @return The facing of the cursor, from 0 to 15.
52  */
53  public byte getDirection() {
54  return direction;
55  }
56 
57  /**
58  * Get the type of this cursor.
59  *
60  * @return The type (color/style) of the map cursor.
61  */
62  public Type getType() {
63  return Type.byValue(type);
64  }
65 
66  /**
67  * Get the type of this cursor.
68  *
69  * @return The type (color/style) of the map cursor.
70  * @deprecated Magic value
71  */
72  @Deprecated
73  public byte getRawType() {
74  return type;
75  }
76 
77  /**
78  * Get the visibility status of this cursor.
79  *
80  * @return True if visible, false otherwise.
81  */
82  public boolean isVisible() {
83  return visible;
84  }
85 
86  /**
87  * Set the X position of this cursor.
88  *
89  * @param x The X coordinate.
90  */
91  public void setX(byte x) {
92  this.x = x;
93  }
94 
95  /**
96  * Set the Y position of this cursor.
97  *
98  * @param y The Y coordinate.
99  */
100  public void setY(byte y) {
101  this.y = y;
102  }
103 
104  /**
105  * Set the direction of this cursor.
106  *
107  * @param direction The facing of the cursor, from 0 to 15.
108  */
109  public void setDirection(byte direction) {
110  if (direction < 0 || direction > 15) {
111  throw new IllegalArgumentException("Direction must be in the range 0-15");
112  }
113  this.direction = direction;
114  }
115 
116  /**
117  * Set the type of this cursor.
118  *
119  * @param type The type (color/style) of the map cursor.
120  */
121  public void setType(Type type) {
122  setRawType(type.value);
123  }
124 
125  /**
126  * Set the type of this cursor.
127  *
128  * @param type The type (color/style) of the map cursor.
129  * @deprecated Magic value
130  */
131  @Deprecated
132  public void setRawType(byte type) {
133  if (type < 0 || type > 15) {
134  throw new IllegalArgumentException("Type must be in the range 0-15");
135  }
136  this.type = type;
137  }
138 
139  /**
140  * Set the visibility status of this cursor.
141  *
142  * @param visible True if visible.
143  */
144  public void setVisible(boolean visible) {
145  this.visible = visible;
146  }
147 
148  /**
149  * Represents the standard types of map cursors. More may be made
150  * available by texture packs - the value is used by the client as an
151  * index in the file './misc/mapicons.png' from minecraft.jar or from a
152  * texture pack.
153  */
154  public enum Type {
155  WHITE_POINTER(0),
156  GREEN_POINTER(1),
157  RED_POINTER(2),
158  BLUE_POINTER(3),
159  WHITE_CROSS(4);
160 
161  private byte value;
162 
163  private Type(int value) {
164  this.value = (byte) value;
165  }
166 
167  /**
168  *
169  * @deprecated Magic value
170  */
171  @Deprecated
172  public byte getValue() {
173  return value;
174  }
175 
176  /**
177  *
178  * @deprecated Magic value
179  */
180  @Deprecated
181  public static Type byValue(byte value) {
182  for (Type t : values()) {
183  if (t.value == value) return t;
184  }
185  return null;
186  }
187  }
188 
189 }
MapCursor(byte x, byte y, byte direction, byte type, boolean visible)
Definition: MapCursor.java:22
void setDirection(byte direction)
Definition: MapCursor.java:109
void setRawType(byte type)
Definition: MapCursor.java:132
void setType(Type type)
Definition: MapCursor.java:121
void setVisible(boolean visible)
Definition: MapCursor.java:144
static Type byValue(byte value)
Definition: MapCursor.java:181