Added optional faction tag entry to /f sethome command to set the home of any faction, which is only allowed if the user has adminBypass permission
This commit is contained in:
		@@ -2,6 +2,7 @@ package com.massivecraft.factions.commands;
 | 
			
		||||
 | 
			
		||||
import com.massivecraft.factions.Conf;
 | 
			
		||||
import com.massivecraft.factions.Faction;
 | 
			
		||||
import com.massivecraft.factions.Factions;
 | 
			
		||||
import com.massivecraft.factions.struct.Role;
 | 
			
		||||
 | 
			
		||||
public class FCommandSethome extends FBaseCommand {
 | 
			
		||||
@@ -9,6 +10,8 @@ public class FCommandSethome extends FBaseCommand {
 | 
			
		||||
	public FCommandSethome() {
 | 
			
		||||
		aliases.add("sethome");
 | 
			
		||||
		
 | 
			
		||||
		optionalParameters.add("faction tag");
 | 
			
		||||
		
 | 
			
		||||
		helpDescription = "Set the faction home";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -32,16 +35,34 @@ public class FCommandSethome extends FBaseCommand {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (Conf.homesMustBeInClaimedTerritory && !me.isInOwnTerritory()) {
 | 
			
		||||
		Faction myFaction = me.getFaction();
 | 
			
		||||
		
 | 
			
		||||
		if (parameters.size() > 0) {
 | 
			
		||||
			if (!Factions.hasPermAdminBypass(player)) {
 | 
			
		||||
				me.sendMessage("You cannot set the home of another faction without adminBypass permission.");
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			myFaction = findFaction(parameters.get(0), true);
 | 
			
		||||
			
 | 
			
		||||
			if (myFaction == null) {
 | 
			
		||||
				me.sendMessage("No such faction seems to exist.");
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (Conf.homesMustBeInClaimedTerritory && !me.isInOwnTerritory() && !Factions.hasPermAdminBypass(player)) {
 | 
			
		||||
			me.sendMessage("Sorry, your faction home can only be set inside your own claimed territory.");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		Faction myFaction = me.getFaction();
 | 
			
		||||
		myFaction.setHome(player.getLocation());
 | 
			
		||||
		
 | 
			
		||||
		myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:");
 | 
			
		||||
		myFaction.sendMessage(new FCommandHome().getUseageTemplate());
 | 
			
		||||
		if (myFaction != me.getFaction()) {
 | 
			
		||||
			me.sendMessage("You have set the home for the "+myFaction.getTag(me)+Conf.colorSystem+" faction.");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user