2014-09-18 13:41:20 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.Perm;
|
2015-10-21 19:35:41 +02:00
|
|
|
import com.massivecraft.factions.cmd.type.TypeFaction;
|
2014-09-18 13:41:20 +02:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2014-10-02 14:02:07 +02:00
|
|
|
import com.massivecraft.factions.entity.MPerm;
|
2014-09-18 13:41:20 +02:00
|
|
|
import com.massivecraft.factions.event.EventFactionsHomeChange;
|
2015-02-12 12:00:55 +01:00
|
|
|
import com.massivecraft.massivecore.MassiveException;
|
2015-11-06 02:10:29 +01:00
|
|
|
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
2014-09-18 13:41:20 +02:00
|
|
|
|
|
|
|
public class CmdFactionsUnsethome extends FactionsCommandHome
|
|
|
|
{
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
public CmdFactionsUnsethome()
|
|
|
|
{
|
|
|
|
// Aliases
|
|
|
|
this.addAliases("unsethome");
|
|
|
|
|
2015-10-21 19:35:41 +02:00
|
|
|
// Parameters
|
|
|
|
this.addParameter(TypeFaction.get(), "faction", "you");
|
2014-09-18 13:41:20 +02:00
|
|
|
|
|
|
|
// Requirements
|
2015-11-06 02:10:29 +01:00
|
|
|
this.addRequirements(RequirementHasPerm.get(Perm.UNSETHOME.node));
|
2014-09-18 13:41:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
@Override
|
2015-02-12 12:00:55 +01:00
|
|
|
public void perform() throws MassiveException
|
2014-09-18 13:41:20 +02:00
|
|
|
{
|
|
|
|
// Args
|
2015-05-06 17:04:35 +02:00
|
|
|
Faction faction = this.readArg(msenderFaction);
|
2014-09-18 13:41:20 +02:00
|
|
|
|
2014-10-03 09:01:36 +02:00
|
|
|
// Any and MPerm
|
|
|
|
if ( ! MPerm.getPermSethome().has(msender, faction, true)) return;
|
2014-09-18 13:41:20 +02:00
|
|
|
|
|
|
|
// NoChange
|
|
|
|
if ( ! faction.hasHome())
|
|
|
|
{
|
|
|
|
msender.msg("<i>%s <i>does already not have a home.", faction.describeTo(msender));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event
|
|
|
|
EventFactionsHomeChange event = new EventFactionsHomeChange(sender, faction, null);
|
|
|
|
event.run();
|
|
|
|
if (event.isCancelled()) return;
|
|
|
|
|
|
|
|
// Apply
|
|
|
|
faction.setHome(null);
|
|
|
|
|
|
|
|
// Inform
|
|
|
|
faction.msg("%s<i> unset the home for your faction.", msender.describeTo(msenderFaction, true));
|
|
|
|
if (faction != msenderFaction)
|
|
|
|
{
|
|
|
|
msender.msg("<i>You have unset the home for " + faction.getName(msender) + "<i>.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|