seen not working properly

Discussion in 'Spigot Plugin Development' started by Aurorion, May 5, 2015.

  1. Hi!
    So I'm making this /seen command and something doesn't work that well.
    Here is the code.
    Code (Text):
    if(cmd.getName().equalsIgnoreCase("seen")){
                Player player = (Player) sender;
                if(Bukkit.getOfflinePlayer(args[0]).isOnline()){
                    player.sendMessage(plugin.prefix + "Speler is §aOnline");
                    return true;
                }
                if(!Bukkit.getOfflinePlayer(args[0]).isOnline()){
                    long timeLast = System.currentTimeMillis() - settings.getData().getLong(args[0]);
                    long days = timeLast / 86400000L;
                    timeLast %= 86400000L;
                    long hours = timeLast / 3600000L;
                    timeLast %= 3600000L;
                    long minutes = timeLast / 60000L;
                    timeLast %= 60000L;
                    long seconds = timeLast / 1000L;
                    if(days > 0L){
                        player.sendMessage(plugin.prefix + "§6" + args[0] + "§f is als laats gezien §e" + days + "§f dagen en §e" + hours + "§f uur geleden");
                    }
                    if(days == 0L && hours > 0L){
                        player.sendMessage(plugin.prefix + "§6" + args[0] + "§f is als laats gezien §e" + hours + "§f uur en §e" + minutes + "§f minuten geleden");
                    }
                    if(days == 0L && hours == 0L && minutes > 0L){
                        player.sendMessage(plugin.prefix + "§6" + args[0] + "§f is als laats gezien §e" + minutes + "§f minuten en §e" + seconds + "§f seconden geleden");
                    }
                }
            }
    So the problem is that it doesn't do System.currentTimeMillis() - settings.getData().getLong(args[0]) and I'm not sure why.
    English is not my native language and I have a hard time explaining things, but if you need more info I will do my best.

    Thank in advance!
     
  2. Nederlands nice nice. But how do you mean it doesn't do etc. Are u getting a error or something ?
     
  3. Not getting any errors but shows things like "last seen 16560 days ago" etc, while it has been like 10 minutes ago.
     
  4. You should look into using the lastPlayed method, just convert the ticks to seconds, minutes, hours and days.
     
    • Useful Useful x 1
  5. nah the code was fine. Just didn't looked up the right section of my data folder