Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 93 lines 2.8 kB view raw
1package org.bukkit.map; 2 3import java.util.ArrayList; 4import java.util.List; 5 6/** 7 * Represents all the map cursors on a {@link MapCanvas}. Like MapCanvas, a 8 * MapCursorCollection is linked to a specific {@link MapRenderer}. 9 */ 10public final class MapCursorCollection { 11 12 private List<MapCursor> cursors = new ArrayList<MapCursor>(); 13 14 /** 15 * Get the amount of cursors in this collection. 16 * 17 * @return The size of this collection. 18 */ 19 public int size() { 20 return cursors.size(); 21 } 22 23 /** 24 * Get a cursor from this collection. 25 * 26 * @param index The index of the cursor. 27 * @return The MapCursor. 28 */ 29 public MapCursor getCursor(int index) { 30 return cursors.get(index); 31 } 32 33 /** 34 * Remove a cursor from the collection. 35 * 36 * @param cursor The MapCursor to remove. 37 * @return Whether the cursor was removed successfully. 38 */ 39 public boolean removeCursor(MapCursor cursor) { 40 return cursors.remove(cursor); 41 } 42 43 /** 44 * Add a cursor to the collection. 45 * 46 * @param cursor The MapCursor to add. 47 * @return The MapCursor that was passed. 48 */ 49 public MapCursor addCursor(MapCursor cursor) { 50 cursors.add(cursor); 51 return cursor; 52 } 53 54 /** 55 * Add a cursor to the collection. 56 * 57 * @param x The x coordinate, from -128 to 127. 58 * @param y The y coordinate, from -128 to 127. 59 * @param direction The facing of the cursor, from 0 to 15. 60 * @return The newly added MapCursor. 61 */ 62 public MapCursor addCursor(int x, int y, byte direction) { 63 return addCursor(x, y, direction, (byte) 0, true); 64 } 65 66 /** 67 * Add a cursor to the collection. 68 * 69 * @param x The x coordinate, from -128 to 127. 70 * @param y The y coordinate, from -128 to 127. 71 * @param direction The facing of the cursor, from 0 to 15. 72 * @param type The type (color/style) of the map cursor. 73 * @return The newly added MapCursor. 74 */ 75 public MapCursor addCursor(int x, int y, byte direction, byte type) { 76 return addCursor(x, y, direction, type, true); 77 } 78 79 /** 80 * Add a cursor to the collection. 81 * 82 * @param x The x coordinate, from -128 to 127. 83 * @param y The y coordinate, from -128 to 127. 84 * @param direction The facing of the cursor, from 0 to 15. 85 * @param type The type (color/style) of the map cursor. 86 * @param visible Whether the cursor is visible. 87 * @return The newly added MapCursor. 88 */ 89 public MapCursor addCursor(int x, int y, byte direction, byte type, boolean visible) { 90 return addCursor(new MapCursor((byte) x, (byte) y, direction, type, visible)); 91 } 92 93}