diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 63894e16..890f9dfa 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -60,6 +60,7 @@ import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; import java.util.*; import java.util.logging.Level; +import java.util.stream.Collectors; public class PlayerData extends OfflinePlayerData implements Closable, ExperienceTableClaimer { @@ -786,19 +787,26 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc if (value <= 0) return; - if (hasReachedMaxLevel()) { - setExperience(0); - return; - } - // Splitting exp through party members AbstractParty party; if (splitExp && (party = getParty()) != null) { - List onlineMembers = party.getOnlineMembers(); - value /= onlineMembers.size(); - for (PlayerData member : onlineMembers) - if (!equals(member)) - member.giveExperience(value, source, null, false); + final List nearbyMembers = party.getOnlineMembers().stream() + .filter(pd -> { + if (equals(pd) || pd.hasReachedMaxLevel()) + return false; + + final double maxDis = MMOCore.plugin.configManager.partyMaxExpSplitRange; + return maxDis <= 0 || pd.getPlayer().getLocation().distanceSquared(getPlayer().getLocation()) < maxDis * maxDis; + }).collect(Collectors.toList()); + value /= (nearbyMembers.size() + 1); + for (PlayerData member : nearbyMembers) + member.giveExperience(value, source, null, false); + } + + // Must be placed after exp splitting + if (hasReachedMaxLevel()) { + setExperience(0); + return; } // Apply buffs AFTER splitting exp diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java index 92bbfcbe..babc8ded 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/ConfigManager.java @@ -27,7 +27,7 @@ public class ConfigManager { public ChatColor staminaFull, staminaHalf, staminaEmpty; public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown; public double lootChestsChanceWeight,dropItemsChanceWeight, fishingDropsChanceWeight, partyMaxExpSplitRange; - public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills, waypointWarpTime; + public int maxPartyLevelDifference, maxBoundActiveSkills, maxBoundPassiveSkills; private final FileConfiguration messages; @@ -82,8 +82,6 @@ public class ConfigManager { loadDefaultFile("skill-trees","rogue-marksman.yml"); loadDefaultFile("skill-trees","warrior-paladin.yml"); loadDefaultFile("skill-trees","general.yml"); - - } loadDefaultFile("attributes.yml");