2014-11-07 18:49:54 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2014-11-11 16:28:53 +01:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
2014-11-07 18:49:54 +01:00
|
|
|
import com.massivecraft.factions.P;
|
2014-11-11 16:28:53 +01:00
|
|
|
import com.massivecraft.factions.integration.Econ;
|
2014-11-07 18:49:54 +01:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
|
|
|
import com.massivecraft.factions.struct.Relation;
|
|
|
|
import com.massivecraft.factions.util.LazyLocation;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2014-11-07 18:49:54 +01:00
|
|
|
|
|
|
|
public class CmdSetFWarp extends FCommand {
|
|
|
|
|
|
|
|
public CmdSetFWarp() {
|
|
|
|
super();
|
|
|
|
this.aliases.add("setwarp");
|
|
|
|
this.aliases.add("sw");
|
|
|
|
this.requiredArgs.add("warp name");
|
|
|
|
this.senderMustBeMember = true;
|
|
|
|
this.senderMustBeModerator = true;
|
|
|
|
this.senderMustBePlayer = true;
|
|
|
|
this.permission = Permission.SETWARP.node;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
|
|
|
if (!(fme.getRelationToLocation() == Relation.MEMBER)) {
|
2014-12-08 00:12:52 +01:00
|
|
|
fme.msg(TL.COMMAND_SETFWARP_NOTCLAIMED);
|
2014-11-07 18:49:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int maxWarps = P.p.getConfig().getInt("max-warps", 5);
|
|
|
|
if (maxWarps <= myFaction.getWarps().size()) {
|
2014-12-08 00:12:52 +01:00
|
|
|
fme.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps);
|
2014-11-07 18:49:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-11 16:28:53 +01:00
|
|
|
if (!transact(fme)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-07 18:49:54 +01:00
|
|
|
String warp = argAsString(0);
|
|
|
|
LazyLocation loc = new LazyLocation(fme.getPlayer().getLocation());
|
|
|
|
myFaction.setWarp(warp, loc);
|
2014-12-08 00:12:52 +01:00
|
|
|
fme.msg(TL.COMMAND_SETFWARP_SET, warp);
|
2014-11-07 18:49:54 +01:00
|
|
|
}
|
2014-11-11 16:28:53 +01:00
|
|
|
|
|
|
|
private boolean transact(FPlayer player) {
|
2014-12-08 00:12:52 +01:00
|
|
|
return P.p.getConfig().getBoolean("warp-cost.enabled", false) && !player.isAdminBypassing() && Econ.modifyMoney(player, P.p.getConfig().getDouble("warp-cost.setwarp", 5), TL.COMMAND_SETFWARP_TOSET.toString() , TL.COMMAND_SETFWARP_FORSET.toString());
|
2014-11-11 16:28:53 +01:00
|
|
|
}
|
2014-11-07 18:49:54 +01:00
|
|
|
}
|