Commits

Owen Nelson committed 9769649

cleaning up old classes used to prototype current functionality; removing old, uneeded imports.

Comments (0)

Files changed (3)

src/com/theomn/cartography/Cartography.java

 
     Logger log = Logger.getLogger("Minecraft");
     private final CartographyPlayerListener playerListener = new CartographyPlayerListener(this);
-//    private final CartographyWorldListener worldListener = new CartographyWorldListener(this);
 
 
     public void onEnable(){

src/com/theomn/cartography/CartographyPlayerListener.java

 package com.theomn.cartography;
 
-import org.bukkit.ChunkSnapshot;
 import org.bukkit.Location;
-import org.bukkit.World;
 import org.bukkit.entity.Player;
 import org.bukkit.event.player.PlayerListener;
 import org.bukkit.event.player.PlayerMoveEvent;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 import java.util.logging.Logger;
 
 public class CartographyPlayerListener extends PlayerListener {
     public static CartographyRelay relay;
     static Logger log = Logger.getLogger("Minecraft");
 
-    public final int radius = 128;   // how many blocks around the player to sample
-    public double threshold = 15.0;  // distance travelled since last sample
-
-    private Location previousLoc = null;
-
     public CartographyPlayerListener(Cartography instance) {
         plugin = instance;
         relay = new CartographyFileRelay();
     @Override
     public void onPlayerMove(PlayerMoveEvent event) {
 
+        // todo: cache tile.getName() for last tile emitted (per player).
+        // Need a static map to track the last tile emitted by each player, so we don't spam our end point.
+        // If the tile name hasn't changed, then don't emit!
+        // Might also want to add a time factor to prevent spamming when going back and fourth between two tiles.
+
         Player player = event.getPlayer();
         MapTile tile = new MapTile(player);
         this.log.info(tile.toString());
         this.relay.emit(tile);
 
-
-
-//        Location playerLoc = player.getLocation();
-//        World world = player.getWorld();
-//
-//        if (this.previousLoc == null) {
-//            this.previousLoc = playerLoc;
-//        }
-//
-//        int minX = playerLoc.getBlockX() - this.radius;
-//        int maxX = playerLoc.getBlockX() + this.radius;
-//
-//        int minZ = playerLoc.getBlockZ() - this.radius;
-//        int maxZ = playerLoc.getBlockZ() + this.radius;
-//
-//        List<Integer> bounds = new ArrayList<Integer>();
-//
-//        bounds.add(minX);
-//        bounds.add(maxX);
-//        bounds.add(minZ);
-//        bounds.add(maxZ);
-//
-//        if (this.previousLoc.distance(playerLoc) > this.threshold) {
-//            List<Integer> blocks = new ArrayList<Integer>();
-//
-//            for (int x = minX; x < maxX; x++) {
-//                for (int z = minZ; z < maxZ; z++) {
-//                    blocks.add(world.getBlockTypeIdAt(x, world.getHighestBlockYAt(x, z)-1, z));
-//                }
-//            }
-//
-//            Map<String,Object> payload = new HashMap<String,Object>();
-//            payload.put("bounds", bounds);
-//            payload.put("blocks", blocks);
-//            this.relay.emit(payload);
-//
-//        }
-
     }
 
 }

src/com/theomn/cartography/CartographyWorldListener.java

-package com.theomn.cartography;
-
-import org.bukkit.Chunk;
-import org.bukkit.ChunkSnapshot;
-import org.bukkit.Location;
-import org.bukkit.World;
-import org.bukkit.entity.Player;
-import org.bukkit.event.player.PlayerMoveEvent;
-import org.bukkit.event.world.ChunkLoadEvent;
-import org.bukkit.event.world.WorldListener;
-import sun.font.TrueTypeFont;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-public class CartographyWorldListener extends WorldListener {
-
-    public static Cartography plugin;
-    public static CartographyRelay relay;
-    static Logger log = Logger.getLogger("Minecraft");
-
-
-
-    public CartographyWorldListener(Cartography instance) {
-        plugin = instance;
-        relay = new CartographyFileRelay();
-    }
-
-    @Override
-    public void onChunkLoad(ChunkLoadEvent event) {
-
-        ChunkSnapshot snap = event.getChunk().getChunkSnapshot(true, false, false);
-
-        List<Integer> blocks = new ArrayList<Integer>();
-        List<Integer> bounds = new ArrayList<Integer>();
-
-        for (int x = 0; x < 16; x++) {
-            for (int z = 0; z < 16; z++) {
-                blocks.add(snap.getBlockTypeId(x, snap.getHighestBlockYAt(x, z) - 1, z));
-            }
-        }
-
-        bounds.add(event.getChunk().getBlock(0, 0, 0).getX());
-        bounds.add(event.getChunk().getBlock(0, 0, 0).getZ());
-
-        bounds.add(event.getChunk().getBlock(15, 0, 15).getX());
-        bounds.add(event.getChunk().getBlock(15, 0, 15).getZ());
-
-        Map<String,Object> payload = new HashMap<String,Object>();
-        payload.put("bounds", bounds);
-        payload.put("blocks", blocks);
-        payload.put("x", snap.getX());
-        payload.put("z", snap.getZ());
-        this.log.info("Chunk "+snap.getX()+","+snap.getZ()+":"+bounds.toString());
-//        this.relay.emit(payload);
-
-    }
-
-}
-