Improvements to info commands.

This commit is contained in:
Olof Larsson 2013-04-26 17:54:06 +02:00
parent 1609a7cfea
commit 3d50e84360
3 changed files with 49 additions and 9 deletions

View File

@ -48,8 +48,10 @@ public class CmdFactionsFaction extends FCommand
//boolean none = faction.isNone(); //boolean none = faction.isNone();
boolean normal = faction.isNormal(); boolean normal = faction.isNormal();
// INFO: Title
msg(Txt.titleize(Txt.upperCaseFirst(faction.getUniverse()) + " Faction " + faction.getName(usender)));
// INFO: Description // INFO: Description
msg(Txt.titleize(faction.getName(usender)));
msg("<a>Description: <i>%s", faction.getDescription()); msg("<a>Description: <i>%s", faction.getDescription());
if (normal) if (normal)

View File

@ -1,10 +1,16 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import java.util.LinkedHashMap;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.mcore.Progressbar;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.util.TimeDiffUtil;
import com.massivecraft.mcore.util.TimeUnit;
import com.massivecraft.mcore.util.Txt;
public class CmdFactionsPlayer extends FCommand public class CmdFactionsPlayer extends FCommand
{ {
@ -22,14 +28,46 @@ public class CmdFactionsPlayer extends FCommand
public void perform() public void perform()
{ {
// Args // Args
UPlayer target = this.arg(0, ARUPlayer.getStartAny(sender), usender); UPlayer uplayer = this.arg(0, ARUPlayer.getStartAny(sender), usender);
if (target == null) return; if (uplayer == null) return;
// TODO: Print info // INFO: Title
msg(Txt.titleize(Txt.upperCaseFirst(uplayer.getUniverse()) + " Player " + uplayer.describeTo(usender)));
double powerBoost = target.getPowerBoost(); // INFO: Power (as progress bar)
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")"; 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());
msg("%s<a> - Power / Maxpower: <i>%.2f / %.2f %s", target.describeTo(usender, true), target.getPower(), target.getPowerMax(), boost);
} }
} }

View File

@ -31,7 +31,7 @@ public class PowerMixinDefault implements PowerMixin
@Override @Override
public double getMin(UPlayer uplayer) public double getMin(UPlayer uplayer)
{ {
return UConf.get(uplayer).powerMin + uplayer.getPowerBoost(); return UConf.get(uplayer).powerMin;
} }
@Override @Override