2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
2014-10-19 07:37:25 +02:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.FPlayers;
|
2011-10-09 18:35:39 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public class CmdOpen extends FCommand {
|
2014-08-05 17:17:27 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public CmdOpen() {
|
2014-07-01 22:10:18 +02:00
|
|
|
super();
|
|
|
|
this.aliases.add("open");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
//this.requiredArgs.add("");
|
|
|
|
this.optionalArgs.put("yes/no", "flip");
|
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
this.permission = Permission.OPEN.node;
|
|
|
|
this.disableOnLock = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = true;
|
|
|
|
senderMustBeAdmin = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
2014-12-08 00:12:52 +01:00
|
|
|
if (!payForCommand(Conf.econCostOpen, TL.COMMAND_OPEN_TOOPEN, TL.COMMAND_OPEN_FOROPEN)) {
|
2014-04-04 20:55:21 +02:00
|
|
|
return;
|
2014-07-01 21:49:42 +02:00
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen()));
|
|
|
|
|
2014-12-08 00:12:52 +01:00
|
|
|
String open = myFaction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
// Inform
|
2014-10-19 07:37:25 +02:00
|
|
|
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
2014-11-02 07:08:32 +01:00
|
|
|
if (fplayer.getFactionId().equals(myFaction.getId())) {
|
2014-12-08 00:12:52 +01:00
|
|
|
fplayer.msg(TL.COMMAND_OPEN_CHANGES, fme.getName(), open);
|
2014-04-04 20:55:21 +02:00
|
|
|
continue;
|
2014-07-01 22:10:18 +02:00
|
|
|
}
|
2014-12-08 00:12:52 +01:00
|
|
|
fplayer.msg(TL.COMMAND_OPEN_CHANGED, myFaction.getTag(fplayer.getFaction()), open);
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|