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;
|
|
|
|
|
|
|
|
|
2011-10-08 23:22:02 +02:00
|
|
|
public class FCommandPermanent extends FCommand {
|
2011-09-13 20:14:09 +02:00
|
|
|
|
|
|
|
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) {
|
2011-10-09 14:53:38 +02:00
|
|
|
fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" your faction.");
|
2011-09-13 20:14:09 +02:00
|
|
|
} else {
|
2011-10-09 14:53:38 +02:00
|
|
|
fplayer.sendMessage(fme.getNameAndRelevant(fplayer)+Conf.colorSystem+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
|
2011-09-13 20:14:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|