Adding in the pow command again. It should be noted that the whole information display system needs a rewrite. Perhaps one command for player and a few for faction?

This commit is contained in:
Olof Larsson 2013-04-25 17:17:23 +02:00
parent 21c7742dcb
commit 71bf3e9f72
5 changed files with 61 additions and 0 deletions

View File

@ -45,6 +45,8 @@ permissions:
factions.officer.any: {description: set officers for another faction, default: false} factions.officer.any: {description: set officers for another faction, default: false}
factions.open: {description: set if invitation is required to join, default: false} factions.open: {description: set if invitation is required to join, default: false}
factions.perm: {description: change faction permissions, default: false} factions.perm: {description: change faction permissions, default: false}
factions.power: {description: show player power}
factions.power.any: {description: show another players power}
factions.powerboost: {description: set powerboost, default: false} factions.powerboost: {description: set powerboost, default: false}
factions.promote: {description: promote lesser members in your faction, default: false} factions.promote: {description: promote lesser members in your faction, default: false}
factions.relation: {description: set relation wish to another faction, default: false} factions.relation: {description: set relation wish to another faction, default: false}
@ -91,6 +93,8 @@ permissions:
factions.officer.any: true factions.officer.any: true
factions.open: true factions.open: true
factions.perm: true factions.perm: true
factions.power: true
factions.power.any: true
factions.powerboost: true factions.powerboost: true
factions.promote: true factions.promote: true
factions.relation: true factions.relation: true
@ -163,6 +167,8 @@ permissions:
factions.money.*: true factions.money.*: true
factions.open: true factions.open: true
factions.perm: true factions.perm: true
factions.power: true
factions.power.any: true
factions.promote: true factions.promote: true
factions.relation: true factions.relation: true
factions.seechunk: true factions.seechunk: true

View File

@ -45,6 +45,8 @@ public enum Perm
OFFICER_ANY("officer.any"), OFFICER_ANY("officer.any"),
OPEN("open"), OPEN("open"),
PERM("perm"), PERM("perm"),
POWER("power"),
POWER_ANY("power.any"),
POWERBOOST("powerboost"), POWERBOOST("powerboost"),
PROMOTE("promote"), PROMOTE("promote"),
RELATION("relation"), RELATION("relation"),

View File

@ -31,6 +31,7 @@ public class CmdFactions extends FCommand
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney(); public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
public CmdFactionsOpen cmdFactionsOpen = new CmdFactionsOpen(); public CmdFactionsOpen cmdFactionsOpen = new CmdFactionsOpen();
public CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm(); public CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm();
public CmdFactionsPower cmdFactionsPower = new CmdFactionsPower();
public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost(); public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost();
public CmdFactionsPromote cmdFactionsPromote = new CmdFactionsPromote(); public CmdFactionsPromote cmdFactionsPromote = new CmdFactionsPromote();
public CmdFactionsRelationAlly cmdFactionsRelationAlly = new CmdFactionsRelationAlly(); public CmdFactionsRelationAlly cmdFactionsRelationAlly = new CmdFactionsRelationAlly();
@ -61,6 +62,7 @@ public class CmdFactions extends FCommand
this.addSubCommand(HelpCommand.get()); this.addSubCommand(HelpCommand.get());
this.addSubCommand(this.cmdFactionsList); this.addSubCommand(this.cmdFactionsList);
this.addSubCommand(this.cmdFactionsShow); this.addSubCommand(this.cmdFactionsShow);
this.addSubCommand(this.cmdFactionsPower);
this.addSubCommand(this.cmdFactionsJoin); this.addSubCommand(this.cmdFactionsJoin);
this.addSubCommand(this.cmdFactionsLeave); this.addSubCommand(this.cmdFactionsLeave);
this.addSubCommand(this.cmdFactionsHome); this.addSubCommand(this.cmdFactionsHome);

View File

@ -0,0 +1,36 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsPower extends FCommand
{
public CmdFactionsPower()
{
this.addAliases("power", "pow");
this.addOptionalArg("player", "you");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.POWER.node));
}
@Override
public void perform()
{
// Args
UPlayer target = this.arg(0, ARUPlayer.getStartAny(sender), usender);
if (target == null) return;
// Perm
if (target != usender && ! Perm.POWER_ANY.has(sender, true)) return;
double powerBoost = target.getPowerBoost();
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
msg("%s<a> - Power / Maxpower: <i>%.2f / %.2f %s", target.describeTo(usender, true), target.getPower(), target.getPowerMax(), boost);
}
}

View File

@ -373,6 +373,21 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
return power; return power;
} }
public int getPowerMaxRounded()
{
return (int) Math.round(this.getPowerMax());
}
public int getPowerMinRounded()
{
return (int) Math.round(this.getPowerMin());
}
public int getPowerMaxUniversalRounded()
{
return (int) Math.round(this.getPowerMaxUniversal());
}
// RAW // RAW
public double getDefaultPower() public double getDefaultPower()