Map editing

Discussion in 'Plugin Development' started by Jnorr44, Aug 11, 2012.

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

    Jnorr44

    I am working on a plugin that adds a player-tracking function to maps. I have however, run into 2 problems.

    *The movement leaves a trail
    *Players that are in un-explored areas of your map make trails in those areas (when I solve the first problem, this will probably reveal the map which can't happen)

    So far my code is this:

    Code:
    package com.github.JamesNorris.MapEdit.Visual;
     
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    import org.bukkit.map.MapCanvas;
    import org.bukkit.map.MapRenderer;
    import org.bukkit.map.MapView;
     
    import com.github.JamesNorris.MapEdit.Core.MapEdit;
     
    public class PlayerTracking extends MapRenderer {
        public PlayerTracking(Runnable runnable) {}
     
        @Override public void render(MapView map, MapCanvas canvas, Player player) {
            if (MapEdit.a){
                for (Entity entity : player.getWorld().getLivingEntities()) {
                    if (entity instanceof Player) {
                        if (((Player) entity).hasPermission("mapedit.seen")){
                       
                        int color = 48;
                       
                        if (((Player) entity).hasPermission("mapedit.color.blue")){color = 48;}
                        if (((Player) entity).hasPermission("mapedit.color.red")){color = 16;}
                        if (((Player) entity).hasPermission("mapedit.color.green")){color = 4;}
                       
                        int x = entity.getLocation().getBlockX()
                                - player.getLocation().getBlockX() + 64;
                        int z = entity.getLocation().getBlockZ()
                                - player.getLocation().getBlockZ() + 64;
     
                        if (x >= 1 && x <= 126 && z >= 1 && z <= 126) {
                           
                            //BASE
                            canvas.setPixel(z, z, (byte) color);
                           
                            //OUTLINE
                            canvas.setPixel(x - 1, z - 1, (byte) 44);
                            canvas.setPixel(x, z - 1, (byte) 44);
                            canvas.setPixel(x + 1, z - 1, (byte) 44);
                            canvas.setPixel(x - 1, z, (byte) 44);
                            canvas.setPixel(x + 1, z, (byte) 44);
                            canvas.setPixel(x - 1, z + 1, (byte) 44);
                            canvas.setPixel(x, z + 1, (byte) 44);
                            canvas.setPixel(x + 1, z + 1, (byte) 44);
                            player.sendMap(map);
                        }
                        }
     
                    }
     
                }
            }
        }
    }
    and I know this doesnt do NE,SE,NW,SW yet, but it will soon.

    Can anyone answer this question? I know some of you have worked with maps before.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  2. Offline

    hammale

  3. Offline

    Jnorr44

    Nice ostrich XD, still nothing?
     
Thread Status:
Not open for further replies.

Share This Page