New command /f power [player name] to check either your own power (if no name is specified) or another player's power (if a player name is specified). The ability for a player to view their own power is based on the standard factions.participate permission, but to check the power of other players, the new permission node factions.viewAnyPower needs to be granted. If you aren't using a Permissions plugin (instead defaulting to the built-in Bukkit permission system), the factions.viewAnyPower permission is granted by default. Otherwise, you'll need to configure your Permissions plugin to grant the new permission as needed.

This commit is contained in:
Brettflan 2011-07-25 13:16:14 -05:00
parent b97eaf175e
commit 080ea3363b
4 changed files with 66 additions and 2 deletions

View File

@ -94,6 +94,7 @@ public class Factions extends JavaPlugin {
commands.add(new FCommandMap());
commands.add(new FCommandMod());
commands.add(new FCommandOpen());
commands.add(new FCommandPower());
commands.add(new FCommandRelationAlly());
commands.add(new FCommandRelationEnemy());
commands.add(new FCommandRelationNeutral());
@ -353,6 +354,10 @@ public class Factions extends JavaPlugin {
return hasPerm(sender, "factions.worldOptions");
}
public static boolean hasPermViewAnyPower(CommandSender sender) {
return hasPerm(sender, "factions.viewAnyPower");
}
public static boolean isCommandDisabled(CommandSender sender, String command) {
return (hasPerm(sender, "factions.commandDisable."+command) && !hasPerm(sender, "factions.commandDisable.none"));
}

View File

@ -58,7 +58,7 @@ public class FCommandHelp extends FBaseCommand {
pageLines.add( new FCommandHelp().getUseageTemplate() );
pageLines.add( new FCommandList().getUseageTemplate() );
pageLines.add( new FCommandShow().getUseageTemplate() );
pageLines.add( new FCommandMap().getUseageTemplate() );
pageLines.add( new FCommandPower().getUseageTemplate() );
pageLines.add( new FCommandJoin().getUseageTemplate() );
pageLines.add( new FCommandLeave().getUseageTemplate() );
pageLines.add( new FCommandChat().getUseageTemplate() );
@ -91,13 +91,13 @@ public class FCommandHelp extends FBaseCommand {
helpPages.add(pageLines);
pageLines = new ArrayList<String>();
pageLines.add( new FCommandMap().getUseageTemplate() );
pageLines.add( new FCommandRelationAlly().getUseageTemplate() );
pageLines.add( new FCommandRelationNeutral().getUseageTemplate() );
pageLines.add( new FCommandRelationEnemy().getUseageTemplate() );
pageLines.add("");
pageLines.add("Set the relation you WISH to have with another faction.");
pageLines.add("Your default relation with other factions will be neutral.");
pageLines.add("");
pageLines.add("If BOTH factions choose \"ally\" you will be allies.");
pageLines.add("If ONE faction chooses \"enemy\" you will be enemies.");
helpPages.add(pageLines);

View File

@ -0,0 +1,52 @@
package com.massivecraft.factions.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.FPlayer;
public class FCommandPower extends FBaseCommand {
public FCommandPower() {
aliases.add("power");
aliases.add("pow");
senderMustBePlayer = false;
optionalParameters.add("player name");
helpDescription = "show player power info";
}
@Override
public boolean hasPermission(CommandSender sender) {
return true;
}
@Override
public void perform() {
FPlayer target;
if (parameters.size() > 0) {
if (!Factions.hasPermViewAnyPower(player)) {
me.sendMessage("You do not have the appropriate permission to view another player's power level.");
return;
}
target = findFPlayer(parameters.get(0), false);
} else if (!(sender instanceof Player)) {
sendMessage("From the command line, you must specify a player (f power <player name>).");
return;
} else {
target = me;
}
if (target == null) {
return;
}
sendMessage(target.getNameAndRelevant(me)+Conf.colorChrome+" - Power / Maxpower: "+Conf.colorSystem+target.getPowerRounded()+" / "+target.getPowerMaxRounded());
}
}

View File

@ -18,6 +18,7 @@ permissions:
children:
factions.participate: true
factions.create: true
factions.viewAnyPower: true
factions.manageSafeZone: true
factions.manageWarZone: true
factions.adminBypass: true
@ -34,6 +35,9 @@ permissions:
factions.create:
description: Allows the player to create a new faction
default: true
factions.viewAnyPower:
description: Allows the player to view the power level of anyone else
default: true
factions.manageSafeZone:
description: Allows the player to claim land as a safe zone, and to build/destroy within safe zones
default: op
@ -130,6 +134,9 @@ permissions:
factions.commandDisable.open:
description: open command disabled
default: false
factions.commandDisable.power:
description: power command disabled
default: false
factions.commandDisable.ally:
description: ally command disabled
default: false