giveExperience does nothing if exp is negative

This commit is contained in:
Indyuce 2022-05-05 22:22:56 +02:00
parent 1765b15707
commit a13987cac9
2 changed files with 5 additions and 0 deletions

View File

@ -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;

View File

@ -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);