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

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

  1. Offline

    DiddiZ

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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:
    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]

    This post has been edited 2 times. It was last edited by DiddiZ Apr 17, 2012.
    xcession and ssechaud like this.
  2. Offline

    Kartus

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    works great and it's soooo lightweight compared with others. good work, Thanks!
  3. Offline

    Palmitu

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thanks for the plugin DiddiZ
  4. Offline

    Azraeil

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Great stuff!
  5. Offline

    Dustin

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    is there a way I can make it display the uptime as part of the message of the day?
  6. Offline

    DiddiZ

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    IS this working on b186?
  8. Offline

    DiddiZ

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Yes
  9. Offline

    EvilSeph Bukkit Team Member Administrator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  10. Offline

    Azraeil

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Just wanted to say I love the plugin! It gives me good feelings about being my server's admin!
  11. Offline

    DiddiZ

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Removed TSLPC
    (That annoying message at server start)
  12. Offline

    Playingcs

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Could map so the Uptime counts when the server starts, not when plugins are being reloaded?
  13. Offline

    DiddiZ

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Could you make it possible to display uptime on a sign?
  15. Offline

    DiddiZ

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hypothetical yes, but I want to keep uptime as small as possible.
  16. Offline

    Duulicious

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    You should make an additional plugin for that.
  17. Offline

    DiddiZ

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hm, that would work. If LogBlock and AnyReg let me some time, I'll do that.
  18. Offline

    noahwhygodwhy

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hm, when I finish the LB commands update, I'll try to add persistance against reloads.
  20. Offline

    Sorken

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thanks, also want it to ignore reload :)
  21. Offline

    kahlilnc

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Can this show percentage of how long its been up and down? or is that impossible.
  22. Offline

    dragos240

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Does this have permissions?
  23. Offline

    DiddiZ

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hm, not atm.
    Nope, /uptime is for all and /sayuptime for ops
    kahlilnc likes this.
  24. Offline

    dragos240

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Is this uptime for the server? Or system uptime?
  25. Offline

    DiddiZ

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    server ... but it's now more like time since last reload :(
  26. Offline

    dragos240

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Ah. Would be nice to get the system uptime displayed too sometime :)
  27. Offline

    DiddiZ

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    um, not sure wether java provides that
  28. Offline

    dragos240

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    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