Merging branches 1 new mission type
This commit is contained in:
@@ -3,8 +3,8 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdOpen extends FCommand {
|
||||
@@ -12,47 +12,34 @@ 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;
|
||||
this.disableOnSpam = true;
|
||||
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = true;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.OPEN)
|
||||
.withRole(Role.COLEADER)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
public void perform(CommandContext context) {
|
||||
// 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)) {
|
||||
if (!context.payForCommand(Conf.econCostOpen, TL.COMMAND_OPEN_TOOPEN, TL.COMMAND_OPEN_FOROPEN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fme.isCooldownEnded("open")) {
|
||||
fme.msg(TL.COMMAND_ONCOOOLDOWN, fme.getCooldown("open"));
|
||||
return;
|
||||
}
|
||||
context.faction.setOpen(context.argAsBool(0, !context.faction.getOpen()));
|
||||
|
||||
myFaction.setOpen(this.argAsBool(0, !myFaction.getOpen()));
|
||||
|
||||
String open = myFaction.getOpen() ? TL.COMMAND_OPEN_OPEN.toString() : TL.COMMAND_OPEN_CLOSED.toString();
|
||||
String open = context.faction.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);
|
||||
if (fplayer.getFactionId().equals(context.faction.getId())) {
|
||||
fplayer.msg(TL.COMMAND_OPEN_CHANGES, context.fPlayer.getName(), open);
|
||||
continue;
|
||||
}
|
||||
fplayer.msg(TL.COMMAND_OPEN_CHANGED, myFaction.getTag(fplayer.getFaction()), open);
|
||||
fplayer.msg(TL.COMMAND_OPEN_CHANGED, context.faction.getTag(fplayer.getFaction()), open);
|
||||
}
|
||||
fme.setCooldown("open", System.currentTimeMillis() + (P.p.getConfig().getInt("fcooldowns.f-open") * 1000));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user