Saber-Factions/src/com/massivecraft/factions/commands/FCommandOwner.java
Brettflan 508f953ce9 Faction admins can now mark already claimed areas as owned by specific faction members. Ownership can include multiple members. New command /f owner *[player name], to set/remove ownership. This command is only available to the faction admin and optionally the faction moderators. If no player name is specified, it will either set ownership to the player running the command (if no owner is currently set) or completely clear ownership of the territory. New command /f ownerlist, to view a list of owners for the current area. Only works inside your own faction's territory. New conf.json options "ownedAreasEnabled", "ownedAreasModeratorsCanSet", "ownedAreaModeratorsBypass", "ownedAreaDenyBuild", "ownedAreaProtectMaterials", and "ownedAreaDenyUseage" (all defaulting to true) to determine whether faction moderators can set or bypass ownership (faction admin always can), and what sort of protection these owned areas have against normal members of the faction (members other than the owner(s), faction admin, and probably faction moderators). New conf.json option "ownedAreasLimitPerFaction" to limit how many owned areas can be set. New permission node "factions.ownershipBypass" which allows a player to bypass ownership protection, but only within the person's own faction.
various little tweaks and improvements to other code
moderate speed boost to FLocation code
made commandDisable permissions work for any command alias of a command, instead of just the first one
2011-07-30 20:17:00 -05:00

101 lines
2.7 KiB
Java

package com.massivecraft.factions.commands;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Role;
public class FCommandOwner extends FBaseCommand {
public FCommandOwner() {
aliases.add("owner");
optionalParameters.add("player name");
helpDescription = "set ownership of claimed land";
}
@Override
public void perform() {
boolean hasBypass = Factions.hasPermAdminBypass(player);
if ( ! hasBypass && ! assertHasFaction()) {
return;
}
if( isLocked() ) {
sendLockMessage();
return;
}
if ( ! Conf.ownedAreasEnabled) {
me.sendMessage("Sorry, but owned areas are disabled on this server.");
return;
}
Faction myFaction = me.getFaction();
if (!hasBypass && Conf.ownedAreasLimitPerFaction > 0 && myFaction.getCountOfClaimsWithOwners() >= Conf.ownedAreasLimitPerFaction) {
me.sendMessage("Sorry, but you have reached the server's limit of "+Conf.ownedAreasLimitPerFaction+" owned areas per faction.");
return;
}
if (!hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN)) {
return;
}
FLocation flocation = new FLocation(me);
if (Board.getIdAt(flocation) != myFaction.getId()) {
if (!hasBypass) {
me.sendMessage("This land is not claimed by your faction, so you can't set ownership of it.");
return;
}
myFaction = Board.getFactionAt(flocation);
if (!myFaction.isNormal()) {
me.sendMessage("This land is not claimed by a faction. Ownership is not possible.");
return;
}
}
FPlayer target;
if (parameters.size() > 0) {
target = findFPlayer(parameters.get(0), false);
} else {
target = me;
}
if (target == null) {
return;
}
String playerName = target.getName();
if (target.getFaction().getId() != myFaction.getId()) {
me.sendMessage(playerName + " is not a member of this faction.");
return;
}
// if no player name was passed, and this claim does already have owners set, clear them
if (parameters.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) {
myFaction.clearClaimOwnership(flocation);
me.sendMessage("You have cleared ownership for this claimed area.");
return;
}
if (myFaction.isPlayerInOwnerList(playerName, flocation)) {
myFaction.removePlayerAsOwner(playerName, flocation);
me.sendMessage("You have removed ownership of this claimed land from "+playerName+".");
return;
}
myFaction.setPlayerAsOwner(playerName, flocation);
me.sendMessage("You have added "+playerName+" to the owner list for this claimed land.");
}
}