Add /f status command, closes #70

This commit is contained in:
blha303 2014-10-16 00:45:16 +08:00 committed by drtshock
parent a170a0f4ad
commit 9baf297ff7
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,37 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
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()) {
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fp.getLastLoginTime(), true, true) + " ago";
String last = fp.isOnline() ? ChatColor.GREEN + "Online" : (System.currentTimeMillis() - fp.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
String power = ChatColor.YELLOW + String.valueOf(fp.getPowerRounded()) + " / " + String.valueOf(fp.getPowerMaxRounded()) + ChatColor.RESET;
ret.add(String.format("%s Power: %s Last Seen: %s", ChatColor.GOLD + fp.getRole().getPrefix() + fp.getName() + ChatColor.RESET, power, last).trim());
}
fme.sendMessage(ret);
}
}

View File

@ -45,6 +45,7 @@ public class FCmdRoot extends FCommand {
public CmdSaveAll cmdSaveAll = new CmdSaveAll(); public CmdSaveAll cmdSaveAll = new CmdSaveAll();
public CmdSethome cmdSethome = new CmdSethome(); public CmdSethome cmdSethome = new CmdSethome();
public CmdShow cmdShow = new CmdShow(); public CmdShow cmdShow = new CmdShow();
public CmdStatus cmdStatus = new CmdStatus();
public CmdTag cmdTag = new CmdTag(); public CmdTag cmdTag = new CmdTag();
public CmdTitle cmdTitle = new CmdTitle(); public CmdTitle cmdTitle = new CmdTitle();
public CmdUnclaim cmdUnclaim = new CmdUnclaim(); public CmdUnclaim cmdUnclaim = new CmdUnclaim();
@ -114,6 +115,7 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdSaveAll); this.addSubCommand(this.cmdSaveAll);
this.addSubCommand(this.cmdSethome); this.addSubCommand(this.cmdSethome);
this.addSubCommand(this.cmdShow); this.addSubCommand(this.cmdShow);
this.addSubCommand(this.cmdStatus);
this.addSubCommand(this.cmdTag); this.addSubCommand(this.cmdTag);
this.addSubCommand(this.cmdTitle); this.addSubCommand(this.cmdTitle);
this.addSubCommand(this.cmdUnclaim); this.addSubCommand(this.cmdUnclaim);

View File

@ -60,6 +60,7 @@ public enum Permission {
SETHOME("sethome"), SETHOME("sethome"),
SETHOME_ANY("sethome.any"), SETHOME_ANY("sethome.any"),
SHOW("show"), SHOW("show"),
STATUS("status"),
TAG("tag"), TAG("tag"),
TITLE("title"), TITLE("title"),
UNCLAIM("unclaim"), UNCLAIM("unclaim"),