Parties can now have max size limits (configurable), by default party sizes are unlimited.

This commit is contained in:
nossr50
2019-01-11 06:17:07 -08:00
parent c7a49dd283
commit 19c38f0cb1
10 changed files with 78 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
@ -51,6 +52,17 @@ public final class PartyManager {
return true;
}
/**
* Checks if the player can join a party, parties can have a size limit, although there is a permission to bypass this
* @param player player who is attempting to join the party
* @param targetParty the target party
* @return true if party is full and cannot be joined
*/
public static boolean isPartyFull(Player player, Party targetParty)
{
return !Permissions.partySizeBypass(player) && Config.getInstance().getPartyMaxSize() >= 1 && targetParty.getOnlineMembers().size() >= Config.getInstance().getPartyMaxSize();
}
/**
* Attempt to change parties or join a new party.
*