Factions3/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java

75 lines
1.9 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
2013-04-25 16:54:55 +02:00
import org.bukkit.ChatColor;
import com.massivecraft.factions.Perm;
2014-09-17 13:29:58 +02:00
import com.massivecraft.factions.cmd.arg.ARMPlayer;
import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.factions.entity.MPlayer;
2014-06-04 16:47:01 +02:00
import com.massivecraft.factions.event.EventFactionsTitleChange;
2015-02-12 12:00:55 +01:00
import com.massivecraft.massivecore.MassiveException;
2014-06-04 14:02:23 +02:00
import com.massivecraft.massivecore.cmd.arg.ARString;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt;
2014-09-18 13:41:20 +02:00
public class CmdFactionsTitle extends FactionsCommand
2011-10-09 18:35:39 +02:00
{
2013-11-11 09:31:04 +01:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2013-04-10 13:12:22 +02:00
public CmdFactionsTitle()
2011-10-09 18:35:39 +02:00
{
2013-11-11 09:31:04 +01:00
// Aliases
2013-04-16 10:11:59 +02:00
this.addAliases("title");
2013-11-11 09:31:04 +01:00
// Args
2015-07-24 13:42:06 +02:00
this.addArg(ARMPlayer.get(), "player");
2015-05-06 17:04:35 +02:00
this.addArg(ARString.get(), "title", "", true);
2013-11-11 09:31:04 +01:00
// Requirements
2013-04-16 10:11:59 +02:00
this.addRequirements(ReqHasPerm.get(Perm.TITLE.node));
}
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
MPlayer you = this.readArg();
String newTitle = this.readArg("");
2013-04-25 16:54:55 +02:00
newTitle = Txt.parse(newTitle);
if (!Perm.TITLE_COLOR.has(sender, false))
{
newTitle = ChatColor.stripColor(newTitle);
}
// MPerm
if ( ! MPerm.getPermTitle().has(msender, you.getFaction(), true)) return;
2015-08-26 08:23:08 +02:00
// Rank Check
if (you.getRole().isMoreThan(msender.getRole()))
{
msg("<b>You can not edit titles for higher ranks.");
return;
}
// Event
2014-06-04 16:47:01 +02:00
EventFactionsTitleChange event = new EventFactionsTitleChange(sender, you, newTitle);
event.run();
if (event.isCancelled()) return;
newTitle = event.getNewTitle();
// Apply
you.setTitle(newTitle);
// Inform
2014-09-18 13:41:20 +02:00
msenderFaction.msg("%s<i> changed a title: %s", msender.describeTo(msenderFaction, true), you.describeTo(msenderFaction, true));
}
}