feat: Improve playerlimit checking

This commit is contained in:
Ben Woo 2023-02-10 16:15:21 +08:00
parent 05c5cd8d66
commit 418146e14c
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8
2 changed files with 5 additions and 1 deletions

View File

@ -23,6 +23,7 @@ public enum ActionCheckResult implements ActionResult {
CANNOT_PAY_ENTRY_FEE(false),
FREE_ENTRY(true),
NO_PLAYERLIMIT(true),
WITHIN_PLAYERLIMIT(true),
EXCEED_PLAYERLIMIT(false),
BYPASS_PLAYERLIMIT(true),

View File

@ -152,7 +152,10 @@ public class PlayerActionChecker {
}
public ActionCheckResult isWithinPlayerLimit(@NotNull CommandSender sender, @NotNull MVWorld toWorld) {
if (toWorld.getPlayerLimit() < 0 || toWorld.getCBWorld().getPlayers().size() <= toWorld.getPlayerLimit()) {
if (toWorld.getPlayerLimit() <= -1) {
return ActionCheckResult.NO_PLAYERLIMIT;
}
if (toWorld.getPlayerLimit() > toWorld.getCBWorld().getPlayers().size()) {
return ActionCheckResult.WITHIN_PLAYERLIMIT;
}
return permissionsTool.hasBypassPlayerLimit(sender, toWorld)