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;
|
2011-07-20 22:42:51 +02:00
|
|
|
import com.massivecraft.factions.Factions;
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.struct.Role;
|
2011-03-23 17:39:56 +01:00
|
|
|
|
|
|
|
public class FCommandSethome extends FBaseCommand {
|
|
|
|
|
|
|
|
public FCommandSethome() {
|
|
|
|
aliases.add("sethome");
|
|
|
|
|
2011-07-20 22:42:51 +02:00
|
|
|
optionalParameters.add("faction tag");
|
|
|
|
|
2011-03-23 17:39:56 +01:00
|
|
|
helpDescription = "Set the faction home";
|
|
|
|
}
|
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-03-23 17:39:56 +01:00
|
|
|
public void perform() {
|
|
|
|
if ( ! assertHasFaction()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-08 17:16:43 +02:00
|
|
|
if( isLocked() ) {
|
|
|
|
sendLockMessage();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-23 17:39:56 +01:00
|
|
|
if ( ! assertMinRole(Role.MODERATOR)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! Conf.homesEnabled) {
|
|
|
|
me.sendMessage("Sorry, Faction homes are disabled on this server.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-07-20 22:42:51 +02:00
|
|
|
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)) {
|
2011-06-19 10:56:21 +02:00
|
|
|
me.sendMessage("Sorry, your faction home can only be set inside your own claimed territory.");
|
|
|
|
return;
|
|
|
|
}
|
2011-03-23 17:39:56 +01:00
|
|
|
|
|
|
|
myFaction.setHome(player.getLocation());
|
|
|
|
|
|
|
|
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:");
|
2011-04-08 16:03:04 +02:00
|
|
|
myFaction.sendMessage(new FCommandHome().getUseageTemplate());
|
2011-07-20 22:42:51 +02:00
|
|
|
if (myFaction != me.getFaction()) {
|
|
|
|
me.sendMessage("You have set the home for the "+myFaction.getTag(me)+Conf.colorSystem+" faction.");
|
|
|
|
}
|
2011-03-23 17:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|