2014-10-15 18:45:16 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2014-10-15 18:45:16 +02:00
|
|
|
import org.apache.commons.lang.time.DurationFormatUtils;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
public class CmdStatus extends FCommand {
|
|
|
|
|
|
|
|
public CmdStatus() {
|
|
|
|
super();
|
|
|
|
this.aliases.add("status");
|
|
|
|
this.aliases.add("s");
|
|
|
|
|
|
|
|
this.permission = Permission.STATUS.node;
|
|
|
|
|
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = true;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeAdmin = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
|
|
|
ArrayList<String> ret = new ArrayList<String>();
|
|
|
|
for (FPlayer fp : myFaction.getFPlayers()) {
|
2014-12-08 00:12:52 +01:00
|
|
|
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX;
|
|
|
|
String last = fp.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
|
2014-10-15 18:45:16 +02:00
|
|
|
String power = ChatColor.YELLOW + String.valueOf(fp.getPowerRounded()) + " / " + String.valueOf(fp.getPowerMaxRounded()) + ChatColor.RESET;
|
2014-12-08 00:12:52 +01:00
|
|
|
ret.add(String.format(TL.COMMAND_STATUS_FORMAT.toString(), ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim());
|
2014-10-15 18:45:16 +02:00
|
|
|
}
|
|
|
|
fme.sendMessage(ret);
|
|
|
|
}
|
|
|
|
|
2015-01-22 00:58:33 +01:00
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_STATUS_DESCRIPTION;
|
|
|
|
}
|
|
|
|
|
2014-10-15 18:45:16 +02:00
|
|
|
}
|