Saber-Factions/src/com/massivecraft/factions/commands/FCommandSethome.java

74 lines
1.9 KiB
Java
Raw Normal View History

2011-07-18 22:06:02 +02:00
package com.massivecraft.factions.commands;
2011-03-23 17:39:56 +01:00
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.struct.Role;
2011-03-23 17:39:56 +01:00
2011-10-08 23:22:02 +02:00
public class FCommandSethome extends FCommand {
2011-03-23 17:39:56 +01:00
public FCommandSethome() {
aliases.add("sethome");
optionalParameters.add("faction tag");
2011-03-23 17:39:56 +01:00
helpDescription = "Set the faction home";
}
@Override
2011-03-23 17:39:56 +01:00
public void perform() {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
sendLockMessage();
return;
}
2011-03-23 17:39:56 +01:00
if ( ! assertMinRole(Role.MODERATOR)) {
return;
}
if ( ! Conf.homesEnabled) {
fme.sendMessage("Sorry, Faction homes are disabled on this server.");
2011-03-23 17:39:56 +01:00
return;
}
Faction myFaction = fme.getFaction();
if (parameters.size() > 0) {
if (!P.hasPermAdminBypass(fme)) {
fme.sendMessage("You cannot set the home of another faction without adminBypass permission.");
return;
}
myFaction = findFaction(parameters.get(0), true);
if (myFaction == null) {
fme.sendMessage("No such faction seems to exist.");
return;
}
}
if (Conf.homesMustBeInClaimedTerritory && !fme.isInOwnTerritory() && !P.hasPermAdminBypass(fme)) {
fme.sendMessage("Sorry, your faction home can only be set inside your own claimed territory.");
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostSethome)) {
return;
}
myFaction.setHome(fme.getLocation());
2011-03-23 17:39:56 +01:00
myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:");
myFaction.sendMessage(new FCommandHome().getUseageTemplate());
if (myFaction != fme.getFaction()) {
fme.sendMessage("You have set the home for the "+myFaction.getTag(fme)+Conf.colorSystem+" faction.");
}
2011-03-23 17:39:56 +01:00
}
}