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
This commit is contained in:
@ -2,6 +2,7 @@ package com.massivecraft.factions.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -89,9 +90,12 @@ public class FBaseCommand {
|
||||
}
|
||||
|
||||
// make sure player doesn't have their access to the command revoked
|
||||
if (Factions.isCommandDisabled(sender, aliases.get(0))) {
|
||||
sendMessage("You lack the permissions to "+this.helpDescription.toLowerCase()+".");
|
||||
return false;
|
||||
Iterator<String> iter = aliases.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (Factions.isCommandDisabled(sender, iter.next())) {
|
||||
sendMessage("You lack the permissions to "+this.helpDescription.toLowerCase()+".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (parameters.size() < requiredParameters.size()) {
|
||||
|
@ -92,10 +92,22 @@ public class FCommandHelp extends FBaseCommand {
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add( new FCommandMap().getUseageTemplate() );
|
||||
pageLines.add("");
|
||||
pageLines.add("");
|
||||
pageLines.add( new FCommandOwner().getUseageTemplate() );
|
||||
pageLines.add( new FCommandOwnerList().getUseageTemplate() );
|
||||
pageLines.add("");
|
||||
pageLines.add("Claimed land with ownership set is further protected so");
|
||||
pageLines.add("that only the owner(s), faction admin, and possibly the");
|
||||
pageLines.add("faction moderators have full access.");
|
||||
helpPages.add(pageLines);
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add( new FCommandRelationAlly().getUseageTemplate() );
|
||||
pageLines.add( new FCommandRelationNeutral().getUseageTemplate() );
|
||||
pageLines.add( new FCommandRelationEnemy().getUseageTemplate() );
|
||||
pageLines.add("");
|
||||
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("If BOTH factions choose \"ally\" you will be allies.");
|
||||
|
100
src/com/massivecraft/factions/commands/FCommandOwner.java
Normal file
100
src/com/massivecraft/factions/commands/FCommandOwner.java
Normal file
@ -0,0 +1,100 @@
|
||||
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.");
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.massivecraft.factions.commands;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.Iterator;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
public class FCommandOwnerList extends FBaseCommand {
|
||||
|
||||
public FCommandOwnerList() {
|
||||
aliases.add("ownerlist");
|
||||
|
||||
helpDescription = "list owner(s) of this claimed land";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
boolean hasBypass = Factions.hasPermAdminBypass(player);
|
||||
|
||||
if ( ! hasBypass && ! assertHasFaction()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! Conf.ownedAreasEnabled) {
|
||||
me.sendMessage("Owned areas are disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
FLocation flocation = new FLocation(me);
|
||||
|
||||
if (Board.getIdAt(flocation) != myFaction.getId()) {
|
||||
if (!hasBypass) {
|
||||
me.sendMessage("This land is not claimed by your faction.");
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction = Board.getFactionAt(flocation);
|
||||
if (!myFaction.isNormal()) {
|
||||
me.sendMessage("This land is not claimed by any faction, thus no owners.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String owners = myFaction.getOwnerListString(flocation);
|
||||
|
||||
if (owners == null || owners.isEmpty()) {
|
||||
me.sendMessage("No owners are set here; everyone in the faction has access.");
|
||||
return;
|
||||
}
|
||||
|
||||
me.sendMessage("Current owner(s) of this land: "+owners);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user