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

@ -45,6 +45,7 @@ Version 2.1.0
= (Skills) Tridents will no longer be considered unarmed
= (MySQL) You can now inspect offline players
= (MySQL) When converting from MySQL to flatfile mcMMO will now properly include all users in the conversion process
+ (Party) Parties can now have size limits (configurable in config.yml), party size is unlimited by default
! (Party) Party member list will only include members of the party that you can see (aren't vanished)
! (Skills) mcMMO skills will now be on a scale from 1-100 instead of 0-1000 (for existing mcMMO installs this is opt-in and off by default)
! (Skills) Skill Super Powers (Tree Feller, etc...) will now require level 10+ to use

View File

@ -6,6 +6,9 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.UUID;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@ -77,10 +80,47 @@ public final class PartyAPI {
*
* @param player The player to add to the party
* @param partyName The party to add the player to
* @deprecated parties can have limits, use the other method
*/
@Deprecated
public static void addToParty(Player player, String partyName) {
Party party = PartyManager.getParty(partyName);
if (party == null) {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
} else {
if(PartyManager.isPartyFull(player, party))
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", party.toString()));
return;
}
}
PartyManager.addToParty(UserManager.getPlayer(player), party);
}
/**
* The max party size of the server
* 0 or less for no size limit
* @return the max party size on this server
*/
public static int getMaxPartySize()
{
return Config.getInstance().getPartyMaxSize();
}
/**
* Add a player to a party.
* </br>
* This function is designed for API usage.
*
* @param player The player to add to the party
* @param partyName The party to add the player to
* @param bypassLimit if true bypasses party size limits
*/
public static void addToParty(Player player, String partyName, boolean bypassLimit) {
Party party = PartyManager.getParty(partyName);
if (party == null) {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
}

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -45,6 +46,13 @@ public class PartyInviteCommand implements CommandExecutor {
}
Party playerParty = mcMMOPlayer.getParty();
if(PartyManager.isPartyFull(target, playerParty))
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), Config.getInstance().getPartyMaxSize()));
return true;
}
mcMMOTarget.setPartyInvite(playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -55,6 +56,12 @@ public class PartyJoinCommand implements CommandExecutor {
return true;
}
if(PartyManager.isPartyFull(player, targetParty))
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
return true;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
PartyManager.addToParty(mcMMOPlayer, targetParty);
return true;

View File

@ -411,6 +411,7 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getLargeFireworks() { return config.getBoolean("Particles.LargeFireworks", true); }
/* PARTY SETTINGS */
public int getPartyMaxSize() {return config.getInt("Party.MaxSize", -1); }
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }

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.
*

View File

@ -200,6 +200,7 @@ public final class Permissions {
* PARTY
*/
public static boolean partySizeBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.partylimit" ); }
public static boolean party(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.party"); }
public static boolean partySubcommand(Permissible permissible, PartySubcommandType subcommand) { return permissible.hasPermission("mcmmo.commands.party." + subcommand.toString().toLowerCase()); }
public static boolean friendlyFire(Permissible permissible) { return permissible.hasPermission("mcmmo.party.friendlyfire"); }

View File

@ -242,6 +242,8 @@ Items:
# Settings for Parties
###
Party:
# Maximum size for a party, -1 for infinite
MaxSize: -1
# Amount of time (in hours) to wait between automatically kicking old party members
# To only run at server start, set to 0
# To never kick old users, set to -1

View File

@ -555,6 +555,8 @@ Commands.Party.Invite.1=[[YELLOW]]Type [[GREEN]]/party accept[[YELLOW]] to accep
Commands.Party.Invite=[[GREEN]]- Send party invite
Commands.Party.Invite.Accepted=[[GREEN]]Invite Accepted. You have joined party {0}
Commands.Party.Join=[[GRAY]]Joined Party: {0}
Commands.Party.PartyFull=[[GOLD]]{0}[[RED]] is full!
Commands.Party.PartyFull.Invite=[[RED]]You cannot invite [[YELLOW]]{0}[[RED]] to [[GREEN]]{1}[[RED]] because it already has [[DARK_AQUA]]{2}[[RED]] players in it!
Commands.Party.Create=[[GRAY]]Created Party: {0}
Commands.Party.Rename=[[GRAY]]Party name changed to: [[WHITE]]{0}
Commands.Party.SetSharing=[[GRAY]]Party {0} sharing set to: [[DARK_AQUA]]{1}

View File

@ -705,6 +705,7 @@ permissions:
default: false
description: Implies all bypass permissions.
children:
mcmmo.bypass.partylimit: true
mcmmo.bypass.arcanebypass: true
mcmmo.bypass.hardcoremode: true
mcmmo.bypass.kraken: true
@ -712,6 +713,9 @@ permissions:
mcmmo.commands.inspect.far: true
mcmmo.commands.inspect.hidden: true
mcmmo.commands.inspect.offline: true
mcmmo.bypass.partylimit:
default: false
description: Allows user to bypass party size limitations if present on the server
mcmmo.bypass.arcanebypass:
default: false
description: Allows user to bypass Arcane Repair so he will never lose enchantments