1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 22:13:25 +01:00

Lets perform correct level actions when adding exp

This commit is contained in:
Zrips 2020-04-25 15:51:18 +03:00
parent d47c059ef1
commit d967985325
2 changed files with 19 additions and 16 deletions

View File

@ -39,17 +39,17 @@ public class exp implements Cmd {
Action action = Action.Add; Action action = Action.Add;
switch (args[2].toLowerCase()) { switch (args[2].toLowerCase()) {
case "add": case "add":
action = Action.Add; action = Action.Add;
break; break;
case "set": case "set":
action = Action.Set; action = Action.Set;
break; break;
case "take": case "take":
action = Action.Take; action = Action.Take;
break; break;
default: default:
break; break;
} }
double amount = 0.0; double amount = 0.0;
@ -67,7 +67,9 @@ public class exp implements Cmd {
switch (action) { switch (action) {
case Add: case Add:
prog.addExperience(amount); int oldLevel = prog.getLevel();
if (prog.addExperience(amount))
Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel);
break; break;
case Set: case Set:
prog.setExperience(amount); prog.setExperience(amount);
@ -81,11 +83,11 @@ public class exp implements Cmd {
Player player = jPlayer.getPlayer(); Player player = jPlayer.getPlayer();
if (player != null) if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getChatColor() + job.getName(), "%level%", prog.getLevel(), "%exp%", prog.getExperience())); player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getChatColor() + job.getName(), "%level%", prog.getLevel(), "%exp%", prog
.getExperience()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
} else } else
sender.sendMessage(Jobs.getLanguage().getMessage("command.exp.error.nojob")); sender.sendMessage(Jobs.getLanguage().getMessage("command.exp.error.nojob"));
} catch (Throwable e) { } catch (Throwable e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
} }

View File

@ -7,6 +7,7 @@ import org.bukkit.Bukkit;
import org.bukkit.event.server.ServerCommandEvent; import org.bukkit.event.server.ServerCommandEvent;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.stuff.Debug;
public class QuestProgression { public class QuestProgression {