Factions/src/com/massivecraft/factions/commands/FCommandTitle.java

62 lines
1.4 KiB
Java
Raw Normal View History

2011-07-18 22:06:02 +02:00
package com.massivecraft.factions.commands;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.integration.SpoutFeatures;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.util.TextUtil;
2011-10-08 23:22:02 +02:00
public class FCommandTitle extends FCommand {
public FCommandTitle() {
aliases.add("title");
requiredParameters.add("player name");
2011-03-23 17:39:56 +01:00
optionalParameters.add("title");
helpDescription = "Set or remove a players title";
}
@Override
public void perform() {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
sendLockMessage();
return;
}
String playerName = parameters.get(0);
parameters.remove(0);
String title = TextUtil.implode(parameters);
FPlayer you = findFPlayer(playerName, false);
if (you == null) {
return;
}
if ( ! canIAdministerYou(me, you)) {
return;
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if (!payForCommand(Conf.econCostTitle)) {
return;
}
you.setTitle(title);
// Inform
Faction myFaction = me.getFaction();
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed a title: "+you.getNameAndRelevant(myFaction));
if (Conf.spoutFactionTitlesOverNames) {
2011-10-08 23:22:02 +02:00
SpoutFeatures.updateAppearances(me);
}
}
}