001    package org.bukkit.map;
002    
003    import java.util.ArrayList;
004    import java.util.List;
005    
006    /**
007     * Represents all the map cursors on a {@link MapCanvas}. Like MapCanvas, a
008     * MapCursorCollection is linked to a specific {@link MapRenderer}.
009     */
010    public final class MapCursorCollection {
011        private List<MapCursor> cursors = new ArrayList<MapCursor>();
012    
013        /**
014         * Get the amount of cursors in this collection.
015         *
016         * @return The size of this collection.
017         */
018        public int size() {
019            return cursors.size();
020        }
021    
022        /**
023         * Get a cursor from this collection.
024         *
025         * @param index The index of the cursor.
026         * @return The MapCursor.
027         */
028        public MapCursor getCursor(int index) {
029            return cursors.get(index);
030        }
031    
032        /**
033         * Remove a cursor from the collection.
034         *
035         * @param cursor The MapCursor to remove.
036         * @return Whether the cursor was removed successfully.
037         */
038        public boolean removeCursor(MapCursor cursor) {
039            return cursors.remove(cursor);
040        }
041    
042        /**
043         * Add a cursor to the collection.
044         *
045         * @param cursor The MapCursor to add.
046         * @return The MapCursor that was passed.
047         */
048        public MapCursor addCursor(MapCursor cursor) {
049            cursors.add(cursor);
050            return cursor;
051        }
052    
053        /**
054         * Add a cursor to the collection.
055         *
056         * @param x The x coordinate, from -128 to 127.
057         * @param y The y coordinate, from -128 to 127.
058         * @param direction The facing of the cursor, from 0 to 15.
059         * @return The newly added MapCursor.
060         */
061        public MapCursor addCursor(int x, int y, byte direction) {
062            return addCursor(x, y, direction, (byte) 0, true);
063        }
064    
065        /**
066         * Add a cursor to the collection.
067         *
068         * @param x The x coordinate, from -128 to 127.
069         * @param y The y coordinate, from -128 to 127.
070         * @param direction The facing of the cursor, from 0 to 15.
071         * @param type The type (color/style) of the map cursor.
072         * @return The newly added MapCursor.
073         * @deprecated Magic value
074         */
075        @Deprecated
076        public MapCursor addCursor(int x, int y, byte direction, byte type) {
077            return addCursor(x, y, direction, type, true);
078        }
079    
080        /**
081         * Add a cursor to the collection.
082         *
083         * @param x The x coordinate, from -128 to 127.
084         * @param y The y coordinate, from -128 to 127.
085         * @param direction The facing of the cursor, from 0 to 15.
086         * @param type The type (color/style) of the map cursor.
087         * @param visible Whether the cursor is visible.
088         * @return The newly added MapCursor.
089         * @deprecated Magic value
090         */
091        @Deprecated
092        public MapCursor addCursor(int x, int y, byte direction, byte type, boolean visible) {
093            return addCursor(new MapCursor((byte) x, (byte) y, direction, type, visible));
094        }
095    
096    }