Factions3/src/com/massivecraft/factions/commands/FCommandOpen.java

54 lines
1.2 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.Faction;
import com.massivecraft.factions.struct.Role;
2011-10-08 23:22:02 +02:00
public class FCommandOpen extends FCommand {
public FCommandOpen() {
aliases.add("open");
aliases.add("close");
helpDescription = "Switch if invitation is required to join";
}
@Override
public void perform() {
if ( ! assertHasFaction()) {
return;
}
if( isLocked() ) {
sendLockMessage();
return;
}
if ( ! assertMinRole(Role.MODERATOR))
{
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.econCostOpen))
{
return;
}
Faction myFaction = fme.getFaction();
myFaction.setOpen( ! fme.getFaction().getOpen());
String open = myFaction.getOpen() ? "open" : "closed";
// Inform
myFaction.sendMessage(fme.getNameAndRelevant(myFaction)+Conf.colorSystem+" changed the faction to "+open);
for (Faction faction : Faction.getAll()) {
if (faction == fme.getFaction()) {
continue;
}
faction.sendMessage(Conf.colorSystem+"The faction "+myFaction.getTag(faction)+Conf.colorSystem+" is now "+open);
}
}
}