Inactive [INFO] Uptime v0.5 - The Lightweight Original [#454-1337]

Discussion in 'Inactive/Unsupported Plugins' started by DiddiZ, Jan 23, 2011.

  1. Offline

    DiddiZ

    Uptime - The Lightweight Original
    Version: 0.5

    Description:
    Uptime adds a command that simply shows the current uptime in a format like: Uptime: 2d 17h 9m 52s There are some uptime plugins, but Uptime was the first Uptime plugin released for hMod. Others have features like overall uptime, but Uptime is intendet to be maximun lightweight. So it uses quick event handling, only one long variable to store the time and no file to write/read continuously.

    Features:
    • Command "/uptime" that shows the current uptime
    • Command "/sayuptime" that broadcasts the current uptime
    • Supports console commands
    Download and Details:

    [​IMG]http://www.diddiz.de/minecraft/uptime.php

    Source code:
    Show Spoiler
    Code:
    package de.diddiz.uptime;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Uptime extends JavaPlugin
    {
        private final long serverStart = System.currentTimeMillis();
     
        @Override
        public void onEnable() {
            getLogger().info("Uptime v" + getDescription().getVersion() + " by DiddiZ enabled");
        }
     
        @Override
        public void onDisable() {
            getLogger().info("Uptime disabled");
        }
     
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            final String commandName = cmd.getName().toLowerCase();
            final long diff = System.currentTimeMillis() - serverStart;
            final String msg = "Uptime: " + (int)(diff / 86400000) + "d " + (int)(diff / 3600000 % 24) + "h " + (int)(diff / 60000 % 60) + "m " + (int)(diff / 1000 % 60) + "s";
            if (commandName.equals("sayuptime"))
                if (sender.isOp()) {
                    getLogger().info("[CONSOLE] " + msg);
                    getServer().broadcastMessage(ChatColor.LIGHT_PURPLE + "[Server] " + msg);
                } else
                    sender.sendMessage(ChatColor.RED + "You aren't allowed to do this");
            else
                sender.sendMessage(msg);
            return true;
        }
    }
    


    Changelog:
    • Uptime v0.5 (Feb. 28, 2010)
      Requires CraftBukkit (tested with #465)
      • Updated commands hook
      • Readded console commands
    • Uptime v0.4b (Feb. 23, 2010)
      Requires CraftBukkit #45+
      • Removed that stupidly long plugin constructor
      • Minor code cleanup
    [​IMG][​IMG]
     
    xcession and ssechaud like this.
  2. Offline

    Kartus

    works great and it's soooo lightweight compared with others. good work, Thanks!
     
  3. Offline

    Palmitu

    Thanks for the plugin DiddiZ
     
  4. Offline

    Azraeil

    Great stuff!
     
  5. Offline

    Dustin

    is there a way I can make it display the uptime as part of the message of the day?
     
  6. Offline

    DiddiZ

    Not really, sorry
    I only coould catch the "/motd" command and append and hook on PLAYER_JOIN, but that would not be very reasonable. Is there any plugin, that provides a motd, that can call plugins for something to add on motd?
     
  7. Offline

    MatCat

    IS this working on b186?
     
  8. Offline

    DiddiZ

    Yes
     
  9. Offline

    EvilSeph

  10. Offline

    Azraeil

    Just wanted to say I love the plugin! It gives me good feelings about being my server's admin!
     
  11. Offline

    DiddiZ

    Removed TSLPC
    (That annoying message at server start)
     
  12. Offline

    Playingcs

    Could map so the Uptime counts when the server starts, not when plugins are being reloaded?
     
  13. Offline

    DiddiZ

    No, because when pluins are being reloaded, Uptime is also reloaded.
    --- merged: Feb 28, 2011 10:24 AM ---
    Updated to work after build #454
    Readded console commands
     
  14. Offline

    Duulicious

    Could you make it possible to display uptime on a sign?
     
  15. Offline

    DiddiZ

    Hypothetical yes, but I want to keep uptime as small as possible.
     
  16. Offline

    Duulicious

    You should make an additional plugin for that.
     
  17. Offline

    DiddiZ

    Hm, that would work. If LogBlock and AnyReg let me some time, I'll do that.
     
  18. Offline

    noahwhygodwhy

    Every time I reload the plugins it resets the time. Do you think you could stop that? or make it configurable? or maybe a total time as well?
     
  19. Offline

    DiddiZ

    Hm, when I finish the LB commands update, I'll try to add persistance against reloads.
     
  20. Thanks, also want it to ignore reload :)
     
  21. Offline

    kahlilnc

    Can this show percentage of how long its been up and down? or is that impossible.
     
  22. Offline

    dragos240

    Does this have permissions?
     
  23. Offline

    DiddiZ

    Hm, not atm.
    Nope, /uptime is for all and /sayuptime for ops
     
    kahlilnc likes this.
  24. Offline

    dragos240

    Is this uptime for the server? Or system uptime?
     
  25. Offline

    DiddiZ

    server ... but it's now more like time since last reload :(
     
  26. Offline

    dragos240

    Ah. Would be nice to get the system uptime displayed too sometime :)
     
  27. Offline

    DiddiZ

    um, not sure wether java provides that
     
  28. Offline

    dragos240

    You can do system calls. Plenty of sites with info on that. It's possible. But of course, you're the dev, not me :p
     
  29. Offline

    noahwhygodwhy

    i'm slightly familiar with java and i think there is a method or two that will call the system time in nanoseconds. Then all you have to do is convert it into easy to read time.
     
  30. Offline

    Tofun

    I would like to put the uptime the plugin returns into a JavaScript variable but I can't figure out how to do that again..
    It is something with getting strings into JS values or so..
    Is there anyone who could possibly do this for me?
    I only need plain JS, thanx!
     

Share This Page