Option to prevent high party level difference

This commit is contained in:
Jules 2022-06-18 12:35:26 +02:00
parent 0b344e7704
commit 1aa7d96347
5 changed files with 34 additions and 3 deletions

View File

@ -172,6 +172,13 @@ public class EditablePartyView extends EditableInventory {
return;
}
if (Math.abs(targetData.getLevel() - party.getLevel()) > MMOCore.plugin.configManager.maxPartyLevelDifference) {
MMOCore.plugin.configManager.getSimpleMessage("high-level-difference", "player", target.getName()).send(player);
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1);
open();
return;
}
party.sendInvite(playerData, targetData);
MMOCore.plugin.configManager.getSimpleMessage("sent-party-invite", "player", target.getName()).send(player);
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);

View File

@ -99,7 +99,6 @@ public class ConfigManager {
globalSkillCooldown = MMOCore.plugin.getConfig().getLong("global-skill-cooldown") * 50;
noSkillBoundPlaceholder = getSimpleMessage("no-skill-placeholder").message();
lootChestsChanceWeight = MMOCore.plugin.getConfig().getDouble("chance-stat-weight.loot-chests");
attributesAsClassInfo = MMOCore.plugin.getConfig().getBoolean("attributes-as-class-info");
staminaFull = getColorOrDefault("stamina-whole", ChatColor.GREEN);
staminaHalf = getColorOrDefault("stamina-half", ChatColor.DARK_GREEN);

View File

@ -9,6 +9,7 @@ import net.Indyuce.mmocore.gui.social.party.EditablePartyView.PartyViewInventory
import net.Indyuce.mmocore.manager.InventoryManager;
import net.Indyuce.mmocore.party.AbstractParty;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.function.Consumer;
@ -25,13 +26,21 @@ public class Party implements AbstractParty {
/**
* Owner has to change when previous owner leaves party
*/
@NotNull
private PlayerData owner;
/**
* If the difference between a player level and the party
* level is too high then players cannot join the party.
*/
private final int partyLevel;
private final MMOCorePartyModule module;
public Party(MMOCorePartyModule module, PlayerData owner) {
this.owner = owner;
this.module = module;
this.partyLevel = owner.getLevel();
addMember(owner);
}
@ -59,6 +68,10 @@ public class Party implements AbstractParty {
return online;
}
public int getLevel() {
return partyLevel;
}
@Override
public int countMembers() {
return members.size();

View File

@ -143,10 +143,21 @@ party:
# to talk in the party chat.
chat-prefix: '@'
# The max players that can be in
# any given party. Between 2-8.
# The max amount of players in a party
# Has to be higher than 2
max-players: 8
# If the difference between a player's level and the
# initial party owner's level is higher that this
# value, then that player can't join the party.
#
# This prevents low level players from joining
# high level players and earning tons of EXP.
#
# Set to the max level possible if you want to disable
# that feature.
max-level-difference: 3
# Redirects vanilla experience obtained to MMOCore
# class experience. You can define the % of the vanilla
# experience that is being transfered as MMOCore exp.

View File

@ -118,6 +118,7 @@ party-joined-other: '&6{player}&e joined your party!'
transfer-party-ownership: '&eYou were transfered the party ownership.'
kick-from-party: '&eYou successfully kicked &6{player}&e.'
party-invite-cooldown: '&cPlease wait {cooldown} before inviting {player}.'
high-level-difference: '&cYou cannot invite {player} as the level difference is too high.'
# Guilds
guild-chat: '&a[{tag}] {player}: {message}'