[INACTIVE][INFO] PlayerPositions [818]

Discussion in 'Inactive/Unsupported Plugins' started by Protected, Mar 11, 2011.

  1. PlayerPositions - Another solution to regularly output player positions
    Only version - Download JAR

    A few weeks ago I was having trouble with erratic behavior in MapMarkers and I couldn't quickly figure out why, so I ported this, which was my old homemade hMod solution for the same problem (outputting player coordinates for mapping use). It does pretty much the same thing. I figured it might be of use to people - if MapMarkers doesn't work for you or if you want something even simpler. Absolutely no support or upgrades will be provided, other than the absolutely necessary fixes for when Bukkit changes ;)

    • Plug and play! Everything works automatically. No dependencies.
    • No configurable filename! It's always players.json in your bukkit directory.
    • No configurable delay! The delay is 10 seconds. If you don't like it, don't use it!
    • No timestamps! Only player coordinates are saved. In JSON format.
    • No exact positions! This plugin outputs integer (block-aligned) positions, since it was written for annotating c10t (which has a 1 pixel per block scale).

    Place the jar file in the "plugins" directory.

    Source Code:

    Source code (open)
    package net.myshelter.minecraft;
    import java.io.File;
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.io.Writer;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.logging.Logger;
    import java.util.Arrays;
    import java.util.Timer;
    import java.util.TimerTask;
    import java.util.ArrayList;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    public class PlayerPositions extends JavaPlugin {
        protected static final Logger log = Logger.getLogger("Minecraft");
        private Timer saver = null;
        public void onLoad() {
        public void onEnable() {
            SavePositions sptt = new SavePositions();
            sptt.plugin = this;
            saver = new Timer();
            saver.schedule(sptt, 0, 10000);
            log.info("PlayerPositions is on!");
        public void onDisable() {
            if (saver != null) {
                saver = null;
            log.info("PlayerPositions is off...");
    class SavePositions extends TimerTask {
        public PlayerPositions plugin;
        public void run() {
            ArrayList<Player> playerList = new ArrayList<Player>(Arrays.asList(plugin.getServer().getOnlinePlayers()));
            Player p;
            Writer writer;
            try {
                writer = new BufferedWriter(new FileWriter(new File("players.json")));
                for (int i = 0; i < playerList.size(); i++) {
                    p = playerList.get(i);
                    if (p == null) continue;
                    writer.write("  {\"name\": \"" + p.getName() + "\", \"world\": \"" + p.getWorld().getName() + "\", \"x\": " + Math.round(p.getLocation().getX()) + ", \"y\": " + Math.round(p.getLocation().getY()) + ", \"z\": " + Math.round(p.getLocation().getZ()) + "}");
                    if (i < playerList.size() - 1) writer.write(",");
                if (writer != null) writer.close();
            catch (FileNotFoundException e) {}
            catch (IOException e) {}


    (2011/3/14) Now compatible with build 553 (no missing onLoad warning).
    (2011/4/8) Compiled against 670 (but probably still compatible with the past 300 builds or so), added world name! Wow!
  2. Offline


    I'm not getting player positions displaying on my Minecraft Overviewer map. Any idea what I could be doing wrong?
  3. Offline


    It's generating an empty json file in the minecraft directory? Is this broken?
  4. Offline


    Why can't we choose the output folder for the JSON file? surely everybody has this in random locations, e.g. the WebServer folder on our server is "/Library/WebServer/Documents/".

    On top of that the JSON file that gets dumped in the root of the Bukkit directory is totally blank.

    I'm lost as to how this plugin would ever work for anyone but yourself?
  5. It shouldn't be blank, and I have no idea why I haven't posted the souce code here. I don't exactly maintain this plugin or even visit this thread. I'll post the source code so you can modify it.
  6. Offline


    Thanks, I'll take a look
  7. Offline


    No multiworld support as in MapMarkers
  8. Hello. This is a minimalistic, highly specialized plugin that is not intended to compete with MapMarkers. I suggest you use MapMarkers if you need MapMarkers - It's even linked in the top post ;)
  9. Offline


    Sorry men, I was too rude, u r right it is minimalistic!

Share This Page