From e52e95484357ccef3165efc97205549c75c8e3ad Mon Sep 17 00:00:00 2001 From: montlikadani Date: Mon, 31 Aug 2020 20:08:56 +0200 Subject: [PATCH] Have some idiot who gives 99999... (lots of 9 numbers) --- src/main/java/com/gamingmesh/jobs/PlayerManager.java | 6 ++++-- .../java/com/gamingmesh/jobs/commands/list/removexp.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index 353f6945..ac775972 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -495,8 +495,9 @@ public class PlayerManager { */ public void addExperience(JobsPlayer jPlayer, Job job, double experience) { JobProgression prog = jPlayer.getJobProgression(job); - if (prog == null) + if (prog == null || experience > Double.MAX_VALUE) return; + int oldLevel = prog.getLevel(); if (prog.addExperience(experience)) { performLevelUp(jPlayer, job, oldLevel); @@ -514,8 +515,9 @@ public class PlayerManager { */ public void removeExperience(JobsPlayer jPlayer, Job job, double experience) { JobProgression prog = jPlayer.getJobProgression(job); - if (prog == null) + if (prog == null || experience > Double.MAX_VALUE) return; + prog.addExperience(-experience); jPlayer.save(); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java b/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java index 1be3e013..315ff04f 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java @@ -32,14 +32,14 @@ public class removexp implements Cmd { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); return true; } - double xpLost; + double xpLost = 0D; try { xpLost = Double.parseDouble(args[2]); } catch (Throwable e) { sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); return true; } - if (xpLost <= 0) { + if (xpLost <= 0 || xpLost > Double.MAX_VALUE) { sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); return true; }