2013-04-25 17:17:23 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2013-04-26 17:54:06 +02:00
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
2013-04-25 17:17:23 +02:00
|
|
|
import com.massivecraft.factions.Perm;
|
|
|
|
import com.massivecraft.factions.cmd.arg.ARUPlayer;
|
2014-09-17 13:17:33 +02:00
|
|
|
import com.massivecraft.factions.entity.MPlayer;
|
2014-06-04 14:02:23 +02:00
|
|
|
import com.massivecraft.massivecore.Progressbar;
|
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
|
|
|
import com.massivecraft.massivecore.util.TimeDiffUtil;
|
|
|
|
import com.massivecraft.massivecore.util.TimeUnit;
|
|
|
|
import com.massivecraft.massivecore.util.Txt;
|
2013-04-25 17:17:23 +02:00
|
|
|
|
2013-04-26 14:01:28 +02:00
|
|
|
public class CmdFactionsPlayer extends FCommand
|
2013-04-25 17:17:23 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-26 14:01:28 +02:00
|
|
|
public CmdFactionsPlayer()
|
2013-04-25 17:17:23 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// Aliases
|
2013-04-26 14:01:28 +02:00
|
|
|
this.addAliases("p", "player");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Args
|
2013-04-25 17:17:23 +02:00
|
|
|
this.addOptionalArg("player", "you");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Requirements
|
2013-04-26 14:01:28 +02:00
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.PLAYER.node));
|
2013-04-25 17:17:23 +02:00
|
|
|
}
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
2013-04-25 17:17:23 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform()
|
|
|
|
{
|
|
|
|
// Args
|
2014-09-17 13:17:33 +02:00
|
|
|
MPlayer uplayer = this.arg(0, ARUPlayer.getAny(), usender);
|
2013-04-26 17:54:06 +02:00
|
|
|
if (uplayer == null) return;
|
2013-04-25 17:17:23 +02:00
|
|
|
|
2013-04-26 17:54:06 +02:00
|
|
|
// INFO: Title
|
|
|
|
msg(Txt.titleize(Txt.upperCaseFirst(uplayer.getUniverse()) + " Player " + uplayer.describeTo(usender)));
|
|
|
|
|
|
|
|
// INFO: Power (as progress bar)
|
|
|
|
double progressbarQuota = uplayer.getPower() / uplayer.getPowerMax();
|
|
|
|
int progressbarWidth = (int) Math.round(uplayer.getPowerMax() / uplayer.getPowerMaxUniversal() * 100);
|
|
|
|
msg("<k>Power: <v>%s", Progressbar.HEALTHBAR_CLASSIC.withQuota(progressbarQuota).withWidth(progressbarWidth).render());
|
|
|
|
|
|
|
|
// INFO: Power (as digits)
|
|
|
|
msg("<k>Power: <v>%.2f / %.2f", uplayer.getPower(), uplayer.getPowerMax());
|
|
|
|
|
|
|
|
// INFO: Power Boost
|
|
|
|
if (uplayer.hasPowerBoost())
|
|
|
|
{
|
|
|
|
double powerBoost = uplayer.getPowerBoost();
|
|
|
|
String powerBoostType = (powerBoost > 0 ? "bonus" : "penalty");
|
|
|
|
msg("<k>Power Boost: <v>%f <i>(a manually granted %s)", powerBoost, powerBoostType);
|
|
|
|
}
|
|
|
|
|
|
|
|
// INFO: Power per Hour
|
|
|
|
// If the player is not at maximum we wan't to display how much time left.
|
|
|
|
|
|
|
|
String stringTillMax = "";
|
|
|
|
double powerTillMax = uplayer.getPowerMax() - uplayer.getPower();
|
|
|
|
if (powerTillMax > 0)
|
|
|
|
{
|
|
|
|
long millisTillMax = (long) (powerTillMax * TimeUnit.MILLIS_PER_HOUR / uplayer.getPowerPerHour());
|
|
|
|
LinkedHashMap<TimeUnit, Long> unitcountsTillMax = TimeDiffUtil.unitcounts(millisTillMax, TimeUnit.getAllButMillis());
|
|
|
|
unitcountsTillMax = TimeDiffUtil.limit(unitcountsTillMax, 2);
|
|
|
|
String unitcountsTillMaxFormated = TimeDiffUtil.formatedVerboose(unitcountsTillMax, "<i>");
|
|
|
|
stringTillMax = Txt.parse(" <i>(%s <i>left till max)", unitcountsTillMaxFormated);
|
|
|
|
}
|
|
|
|
|
|
|
|
msg("<k>Power per Hour: <v>%.2f%s", uplayer.getPowerPerHour(), stringTillMax);
|
|
|
|
|
|
|
|
// INFO: Power per Death
|
|
|
|
msg("<k>Power per Death: <v>%.2f", uplayer.getPowerPerDeath());
|
2013-04-25 17:17:23 +02:00
|
|
|
|
|
|
|
}
|
2013-11-11 09:31:04 +01:00
|
|
|
|
2013-04-25 17:17:23 +02:00
|
|
|
}
|