package com.massivecraft.factions.cmd; import com.massivecraft.factions.cmd.type.TypeFaction; import com.massivecraft.factions.cmd.type.TypeFactionNameLenient; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.event.EventFactionsNameChange; import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.type.primitive.TypeString; import java.util.ArrayList; public class CmdFactionsName extends FactionsCommand { // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // public CmdFactionsName() { // Parameters this.addParameter(TypeFactionNameLenient.get(), "new name"); this.addParameter(TypeFaction.get(), "faction", "you"); } // -------------------------------------------- // // OVERRIDE // -------------------------------------------- // @Override public void perform() throws MassiveException { // Args 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 changed your faction name to %s", msender.describeTo(faction, true), faction.getName(faction)); if (msenderFaction != faction) { msg("You changed the faction name to %s", faction.getName(msender)); } } }