From 71bf3e9f72c3112253b7448f19ee567e20f1d84a Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Thu, 25 Apr 2013 17:17:23 +0200 Subject: [PATCH] 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? --- plugin.yml | 6 ++++ src/com/massivecraft/factions/Perm.java | 2 ++ .../factions/cmd/CmdFactions.java | 2 ++ .../factions/cmd/CmdFactionsPower.java | 36 +++++++++++++++++++ .../massivecraft/factions/entity/UPlayer.java | 15 ++++++++ 5 files changed, 61 insertions(+) create mode 100644 src/com/massivecraft/factions/cmd/CmdFactionsPower.java diff --git a/plugin.yml b/plugin.yml index 554476fe..9be9ac73 100644 --- a/plugin.yml +++ b/plugin.yml @@ -45,6 +45,8 @@ permissions: factions.officer.any: {description: set officers for another faction, default: false} factions.open: {description: set if invitation is required to join, 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.promote: {description: promote lesser members in your faction, default: false} factions.relation: {description: set relation wish to another faction, default: false} @@ -91,6 +93,8 @@ permissions: factions.officer.any: true factions.open: true factions.perm: true + factions.power: true + factions.power.any: true factions.powerboost: true factions.promote: true factions.relation: true @@ -163,6 +167,8 @@ permissions: factions.money.*: true factions.open: true factions.perm: true + factions.power: true + factions.power.any: true factions.promote: true factions.relation: true factions.seechunk: true diff --git a/src/com/massivecraft/factions/Perm.java b/src/com/massivecraft/factions/Perm.java index 117a496d..240c50b3 100644 --- a/src/com/massivecraft/factions/Perm.java +++ b/src/com/massivecraft/factions/Perm.java @@ -45,6 +45,8 @@ public enum Perm OFFICER_ANY("officer.any"), OPEN("open"), PERM("perm"), + POWER("power"), + POWER_ANY("power.any"), POWERBOOST("powerboost"), PROMOTE("promote"), RELATION("relation"), diff --git a/src/com/massivecraft/factions/cmd/CmdFactions.java b/src/com/massivecraft/factions/cmd/CmdFactions.java index 14b95ad8..4d99a7d9 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactions.java +++ b/src/com/massivecraft/factions/cmd/CmdFactions.java @@ -31,6 +31,7 @@ public class CmdFactions extends FCommand public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney(); public CmdFactionsOpen cmdFactionsOpen = new CmdFactionsOpen(); public CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm(); + public CmdFactionsPower cmdFactionsPower = new CmdFactionsPower(); public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost(); public CmdFactionsPromote cmdFactionsPromote = new CmdFactionsPromote(); public CmdFactionsRelationAlly cmdFactionsRelationAlly = new CmdFactionsRelationAlly(); @@ -61,6 +62,7 @@ public class CmdFactions extends FCommand this.addSubCommand(HelpCommand.get()); this.addSubCommand(this.cmdFactionsList); this.addSubCommand(this.cmdFactionsShow); + this.addSubCommand(this.cmdFactionsPower); this.addSubCommand(this.cmdFactionsJoin); this.addSubCommand(this.cmdFactionsLeave); this.addSubCommand(this.cmdFactionsHome); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPower.java b/src/com/massivecraft/factions/cmd/CmdFactionsPower.java new file mode 100644 index 00000000..2f67d31b --- /dev/null +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPower.java @@ -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 - Power / Maxpower: %.2f / %.2f %s", target.describeTo(usender, true), target.getPower(), target.getPowerMax(), boost); + } +} \ No newline at end of file diff --git a/src/com/massivecraft/factions/entity/UPlayer.java b/src/com/massivecraft/factions/entity/UPlayer.java index b5bffe03..a6099678 100644 --- a/src/com/massivecraft/factions/entity/UPlayer.java +++ b/src/com/massivecraft/factions/entity/UPlayer.java @@ -373,6 +373,21 @@ public class UPlayer extends SenderEntity implements EconomyParticipato 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 public double getDefaultPower()