2011-09-13 20:14:09 +02:00
|
|
|
package com.massivecraft.factions.commands;
|
|
|
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.Conf;
|
|
|
|
import com.massivecraft.factions.Faction;
|
2011-10-08 22:03:44 +02:00
|
|
|
import com.massivecraft.factions.P;
|
2011-09-13 20:14:09 +02:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
|
|
|
|
|
|
|
|
public class FCommandPermanent extends FBaseCommand {
|
|
|
|
|
|
|
|
public FCommandPermanent() {
|
|
|
|
aliases.add("permanent");
|
|
|
|
|
|
|
|
senderMustBePlayer = false;
|
|
|
|
|
|
|
|
requiredParameters.add("faction tag");
|
|
|
|
|
|
|
|
helpDescription = "Designate a faction as permanent";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasPermission(CommandSender sender) {
|
2011-10-08 22:03:44 +02:00
|
|
|
return P.hasPermSetPermanent(sender);
|
2011-09-13 20:14:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
|
|
|
if( parameters.size() > 0) {
|
|
|
|
Faction faction = Faction.findByTag(parameters.get(0));
|
|
|
|
|
|
|
|
if (faction == null) {
|
|
|
|
sendMessage("No faction found with the tag \"" + parameters.get(0) + "\"");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String change;
|
|
|
|
if(faction.isPermanent()) {
|
|
|
|
change = "removed permanent status from";
|
|
|
|
faction.setPermanent(false);
|
|
|
|
} else {
|
|
|
|
change = "added permanent status to";
|
|
|
|
faction.setPermanent(true);
|
|
|
|
}
|
|
|
|
// Inform all players
|
|
|
|
for (FPlayer fplayer : FPlayer.getAllOnline()) {
|
|
|
|
if (fplayer.getFaction() == faction) {
|
|
|
|
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction.");
|
|
|
|
} else {
|
|
|
|
fplayer.sendMessage(me.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|