Saber-Factions/src/main/java/com/massivecraft/factions/cmd/CmdOpen.java

64 lines
1.8 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
2019-06-29 03:49:46 +02:00
import com.massivecraft.factions.SaberFactions;
2011-10-09 18:35:39 +02:00
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
2014-04-04 20:55:21 +02:00
public class CmdOpen extends FCommand {
public CmdOpen() {
super();
this.aliases.add("open");
//this.requiredArgs.add("");
this.optionalArgs.put("yes/no", "flip");
this.permission = Permission.OPEN.node;
this.disableOnLock = false;
2019-06-02 20:28:42 +02:00
this.disableOnSpam = true;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeColeader = true;
senderMustBeAdmin = false;
}
@Override
public void perform() {
// 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, TL.COMMAND_OPEN_TOOPEN, TL.COMMAND_OPEN_FOROPEN)) {
return;
}
2019-06-02 20:28:42 +02:00
if (!fme.isCooldownEnded("open")) {
fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("open"));
return;
}
myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen()));
String open = myFaction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
// Inform
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
if (fplayer.getFactionId().equals(myFaction.getId())) {
fplayer.msg(TL.COMMAND_OPEN_CHANGES, fme.getName(), open);
continue;
}
fplayer.msg(TL.COMMAND_OPEN_CHANGED, myFaction.getTag(fplayer.getFaction()), open);
}
2019-06-29 03:49:46 +02:00
fme.setCooldown("open", System.currentTimeMillis() + (SaberFactions.plugin.getConfig().getInt("fcooldowns.f-open") * 1000));
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_OPEN_DESCRIPTION;
}
}