From a13987cac903d744bf3520b9295cb86bc07afde3 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Thu, 5 May 2022 22:22:56 +0200 Subject: [PATCH] giveExperience does nothing if exp is negative --- src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java | 3 +++ .../java/net/Indyuce/mmocore/experience/PlayerProfessions.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 0fae0302..3827cad3 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -532,6 +532,9 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc * @param splitExp Should the exp be split among party members */ public void giveExperience(double value, EXPSource source, @Nullable Location hologramLocation, boolean splitExp) { + if (value <= 0) + return; + if (hasReachedMaxLevel()) { setExperience(0); return; diff --git a/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java b/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java index f7dd9963..1c84c39e 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java +++ b/src/main/java/net/Indyuce/mmocore/experience/PlayerProfessions.java @@ -157,6 +157,8 @@ public class PlayerProfessions { public void giveExperience(Profession profession, double value, EXPSource source, @Nullable Location hologramLocation) { Validate.isTrue(playerData.isOnline(), "Cannot give experience to offline player"); + if (value <= 0) + return; if (hasReachedMaxLevel(profession)) { setExperience(profession, 0);