allowing warps to be replaced at max warps

This commit is contained in:
JamesFrowen-PC\JamesFrowen 2019-01-18 16:08:51 +00:00
parent a47e06a34e
commit ae61303a9b
1 changed files with 6 additions and 2 deletions

View File

@ -45,10 +45,15 @@ public class CmdSetFWarp extends FCommand {
return; return;
} }
} }
String warp = argAsString(0);
// Checks if warp with same name already exists and ignores maxWarp check if it does.
boolean warpExists = myFaction.isWarp(warp);
int maxWarps = SavageFactions.plugin.getConfig().getInt("max-warps", 5); int maxWarps = SavageFactions.plugin.getConfig().getInt("max-warps", 5);
if (maxWarps <= myFaction.getWarps().size()) { boolean tooManyWarps = maxWarps <= myFaction.getWarps().size();
if (tooManyWarps && !warpExists) {
fme.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps); fme.msg(TL.COMMAND_SETFWARP_LIMIT, maxWarps);
return; return;
} }
@ -57,7 +62,6 @@ public class CmdSetFWarp extends FCommand {
return; return;
} }
String warp = argAsString(0);
String password = argAsString(1); String password = argAsString(1);
LazyLocation loc = new LazyLocation(fme.getPlayer().getLocation()); LazyLocation loc = new LazyLocation(fme.getPlayer().getLocation());