2011-08-05 10:50:47 +02:00
|
|
|
package com.massivecraft.factions.commands;
|
|
|
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
|
2011-08-20 03:36:23 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
2011-08-05 10:50:47 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
2011-10-08 22:03:44 +02:00
|
|
|
import com.massivecraft.factions.P;
|
2011-08-20 03:36:23 +02:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
2011-10-05 12:13:54 +02:00
|
|
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
2011-08-05 10:50:47 +02:00
|
|
|
|
|
|
|
public class FCommandPeaceful extends FBaseCommand {
|
|
|
|
|
|
|
|
public FCommandPeaceful() {
|
|
|
|
aliases.add("peaceful");
|
|
|
|
|
|
|
|
senderMustBePlayer = false;
|
|
|
|
|
|
|
|
requiredParameters.add("faction tag");
|
|
|
|
|
|
|
|
helpDescription = "Designate a faction as peaceful";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasPermission(CommandSender sender) {
|
2011-10-08 22:03:44 +02:00
|
|
|
return P.hasPermSetPeaceful(sender);
|
2011-08-05 10:50:47 +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;
|
|
|
|
}
|
|
|
|
|
2011-08-20 03:36:23 +02:00
|
|
|
String change;
|
|
|
|
if(faction.isPeaceful()) {
|
|
|
|
change = "removed peaceful status from";
|
2011-08-05 10:50:47 +02:00
|
|
|
faction.setPeaceful(false);
|
|
|
|
} else {
|
2011-08-20 03:36:23 +02:00
|
|
|
change = "granted peaceful status to";
|
2011-08-05 10:50:47 +02:00
|
|
|
faction.setPeaceful(true);
|
|
|
|
}
|
2011-08-20 03:36:23 +02:00
|
|
|
// 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) + "\".");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SpoutFeatures.updateAppearances(faction);
|
2011-08-05 10:50:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|