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

60 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.cmd.type.TypeFaction;
2017-07-12 20:44:22 +02:00
import com.massivecraft.factions.cmd.type.TypeFactionNameLenient;
import com.massivecraft.factions.entity.Faction;
2013-04-22 09:37:53 +02:00
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.MPerm;
2014-06-04 16:47:01 +02:00
import com.massivecraft.factions.event.EventFactionsNameChange;
2011-10-09 18:35:39 +02:00
import com.massivecraft.factions.util.MiscUtil;
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.type.primitive.TypeString;
2011-04-08 15:51:07 +02:00
2017-03-24 13:05:58 +01:00
import java.util.ArrayList;
2014-09-18 13:41:20 +02:00
public class CmdFactionsName extends FactionsCommand
2011-10-09 18:35:39 +02:00
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsName()
2011-10-09 18:35:39 +02:00
{
// Parameters
2017-07-12 20:44:22 +02:00
this.addParameter(TypeFactionNameLenient.get(), "new name");
this.addParameter(TypeFaction.get(), "faction", "you");
}
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
2015-02-12 12:00:55 +01:00
public void perform() throws MassiveException
2011-10-09 18:35:39 +02:00
{
// Args
2015-05-06 17:04:35 +02:00
String newName = this.readArg();
Faction faction = this.readArg(msenderFaction);
// MPerm
if ( ! MPerm.getPermName().has(msender, faction, true)) return;
// Event
EventFactionsNameChange event = new EventFactionsNameChange(sender, faction, newName);
event.run();
if (event.isCancelled()) return;
newName = event.getNewName();
// Apply
faction.setName(newName);
// Inform
faction.msg("%s<i> changed your faction name to %s", msender.describeTo(faction, true), faction.getName(faction));
if (msenderFaction != faction)
{
msg("<i>You changed the faction name to %s", faction.getName(msender));
}
}
}