Map cursor colour

Discussion in 'Plugin Development' started by llamasaylol, Dec 1, 2012.

Thread Status:
Not open for further replies.
  1. Offline


    Basically I'm trying to change people's map cursor colour. I've seen thread of people asking this before, but none of them got very far.
    I've looked through the whole of the map sections in Bukkit and CraftBukkit. I know how the map rendering works, but I just can't seem to create a map then change the cursor colours.

    What I've currently got. (Code coppied from the CraftMapRenderer)
    public class MapWork extends MapRenderer {
        private WorldMap worldMap;
        public MapWork(WorldMap worldMap) {
            this.worldMap = worldMap;
        public void render(MapView mv, MapCanvas mc, Player player) {
            for (int x = 0; x < 128; ++x) {
                for (int y = 0; y < 128; ++y) {
                    mc.setPixel(x, y, worldMap.colors[y * 128 + x]);
            //Remove Cursors
            MapCursorCollection MCC = mc.getCursors();
            while (MCC.size() > 0) {
            //Add Cursors
            for (Player P : Bukkit.getOnlinePlayers()) {
                WorldMapDecoration decoration = (WorldMapDecoration) worldMap.g.get(P.getName());
                byte Pointer;
                try {
                    Pointer = Domination.getTeam(P.getName()).getPointerColour().getValue();
                } catch (NullPointerException ex) {
                    Pointer = MapCursor.Type.WHITE_POINTER.getValue();
                MCC.addCursor(decoration.locX, decoration.locY, (byte) (decoration.rotation & 15), Pointer);
    However calling it from
    public static void MapWorkM(ItemStack iss) {
        MapView MV = RramaGaming.MapInPlay.getMapView(); //A valid map view, that I created earlier in the code.
        for (MapRenderer MR : MV.getRenderers()) {
        MV.addRenderer(new MapWork(Item.MAP.getSavedMap((new CraftItemStack(iss)).getHandle(), ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle())));
    Does not work. I have tried other methord without passing the WorldMap, but then the map is blank. Also I'd preferably like the whole of the map to be visible.
    Thankyou for reading.
  2. Offline


    Hmm, correct me if im wrong but isn't the cursor client side?
  3. Offline


    Nope, I've been able to change the cursor colour and everything.
  4. Offline


    Bump - Really should be a way to do this easily or the so called "Amazing" (can't remember which staff said that) Map API is kinda floored.
  5. Code:java
    1. for (MapRenderer MR : MV.getRenderers()) {
    2. MV.removeRenderer(MR);
    3. }

    The above code is going to error because you're altering a collection while looping over it. This was taken from you're code
  6. Offline


    I agree it should cause a ConcurrentModificationException But it does not so I'ma keep it :)
  7. Offline


    I think you can even clear the list ;3. Btw, what does work and what does not work yet?
  8. Offline


    Don't think you can clear it, or at least I thought you couldn't when I tried this the first time. Also I just want an easy way to change everyone's map cursor to a chosen colour (Either red or blue depending which group they're in).
    Also, I'd like the whole map to be made visible if possible. I have tried overriding the actual CraftBukkit class for their MapRenderer so the WorldMap is public and that seems like the only way I can do it, but I'd prefer a better easier way to do this. If I can not
    Thank you.
Thread Status:
Not open for further replies.

Share This Page