Factions/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java

58 lines
1.7 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
2013-04-25 13:25:15 +02:00
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.event.FactionsEventDescriptionChange;
2014-06-04 14:02:23 +02:00
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.mixin.Mixin;
2013-04-10 13:12:22 +02:00
public class CmdFactionsDescription extends FCommand
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2013-04-10 13:12:22 +02:00
public CmdFactionsDescription()
{
2013-11-11 09:31:04 +01:00
// Aliases
2013-04-16 10:11:59 +02:00
this.addAliases("desc");
2013-11-11 09:31:04 +01:00
// Args
this.addRequiredArg("desc");
this.setErrorOnToManyArgs(false);
2013-11-11 09:31:04 +01:00
// Requirements
2013-04-25 13:25:15 +02:00
this.addRequirements(ReqFactionsEnabled.get());
2013-04-16 10:11:59 +02:00
this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node));
this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
2013-04-25 13:25:15 +02:00
{
// Args
2013-04-25 12:04:01 +02:00
String newDescription = this.argConcatFrom(0);
// Event
FactionsEventDescriptionChange event = new FactionsEventDescriptionChange(sender, usenderFaction, newDescription);
event.run();
if (event.isCancelled()) return;
newDescription = event.getNewDescription();
// Apply
2013-04-25 12:04:01 +02:00
usenderFaction.setDescription(newDescription);
// Inform
usenderFaction.msg("<i>%s <i>set your faction description to:\n%s", Mixin.getDisplayName(sender), usenderFaction.getDescription());
}
}