diff --git a/pom.xml b/pom.xml
index ffd6dc80..1826a065 100644
--- a/pom.xml
+++ b/pom.xml
@@ -197,7 +197,7 @@
CMILib
latest
system
- ${basedir}/libs/CMILib1.1.2.3.jar
+ ${basedir}/libs/CMILib1.2.3.3.jar
diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/exp.java b/src/main/java/com/gamingmesh/jobs/commands/list/exp.java
index 457f8928..312b7b5f 100644
--- a/src/main/java/com/gamingmesh/jobs/commands/list/exp.java
+++ b/src/main/java/com/gamingmesh/jobs/commands/list/exp.java
@@ -9,86 +9,127 @@ import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
+import java.util.Random;
+
public class exp implements Cmd {
private enum Action {
- Set, Add, Take
+ Set, Add, Take
}
@Override
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
- if (args.length < 4) {
- Jobs.getCommandManager().sendUsage(sender, "exp");
- return true;
- }
+ if (args.length < 4) {
+ Jobs.getCommandManager().sendUsage(sender, "exp");
+ return true;
+ }
- JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
- if (jPlayer == null) {
- sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
- return true;
- }
+ JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
+ if (jPlayer == null) {
+ sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
+ return true;
+ }
- Job job = Jobs.getJob(args[1]);
- if (job == null) {
- sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
- return true;
- }
+ Job job = Jobs.getJob(args[1]);
+ if (job == null) {
+ sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
+ return true;
+ }
- Action action = Action.Add;
+ Action action = Action.Add;
- switch (args[2].toLowerCase()) {
- case "add":
- action = Action.Add;
- break;
- case "set":
- action = Action.Set;
- break;
- case "take":
- action = Action.Take;
- break;
- default:
- break;
- }
+ switch (args[2].toLowerCase()) {
+ case "add":
+ action = Action.Add;
+ break;
+ case "set":
+ action = Action.Set;
+ break;
+ case "take":
+ action = Action.Take;
+ break;
+ default:
+ break;
+ }
- double amount = 0.0;
- try {
- amount = Double.parseDouble(args[3]);
- } catch (NumberFormatException e) {
- sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
- return true;
- }
+ double amount = 0.0;
- try {
- // check if player already has the job
- if (jPlayer.isInJob(job)) {
- JobProgression prog = jPlayer.getJobProgression(job);
+ /* Add random argument, ex: rand_5-10 */
+ if (args[3].startsWith("rand_")) {
+ String data = args[3].split("(?i)rand_")[1];
+ String[] arr = data.split("-");
- switch (action) {
- case Add:
- int oldLevel = prog.getLevel();
- if (prog.addExperience(amount))
- Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel);
- break;
- case Set:
- prog.setExperience(amount);
- break;
- case Take:
- prog.takeExperience(amount);
- break;
- default:
- break;
- }
+ int amountMin = Integer.parseInt(arr[0]);
+ int amountMax = Integer.parseInt(arr[1]);
- Player player = jPlayer.getPlayer();
- if (player != null)
- player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog
- .getExperience()));
- sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
- } else
- sender.sendMessage(Jobs.getLanguage().getMessage("command.exp.error.nojob"));
- } catch (Exception e) {
- sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
- }
- return true;
+ if (amountMin <= amountMax) {
+ amount = amountMin + new Random().nextDouble() * (amountMax - amountMin);
+ } else {
+ amount = amountMax;
+ }
+
+ } else {
+ try {
+ amount = Double.parseDouble(args[3]);
+ } catch (NumberFormatException e) {
+ sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
+ return true;
+ }
+ }
+
+ try {
+ // check if player already has the job
+ if (jPlayer.isInJob(job)) {
+ JobProgression prog = jPlayer.getJobProgression(job);
+
+ switch (action) {
+ case Add:
+ int oldLevel = prog.getLevel();
+ if (prog.addExperience(amount))
+ Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel);
+ break;
+ case Set:
+ prog.setExperience(amount);
+ break;
+ case Take:
+ prog.takeExperience(amount);
+ break;
+ default:
+ break;
+ }
+
+ Player player = jPlayer.getPlayer();
+ boolean isSilent = false;
+ boolean isSilentAdmin = false;
+ if (player != null) {
+ for (String one : args) {
+ if (one.equalsIgnoreCase("-s")) {
+ isSilent = true;
+ break;
+ }
+ }
+ if (!isSilent) {
+ player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog
+ .getExperience()));
+ }
+ for (String one : args) {
+ if (one.equalsIgnoreCase("-sa")) {
+ isSilentAdmin = true;
+ break;
+ }
+ }
+ if (!isSilentAdmin) {
+ sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
+ }
+ } else {
+ sender.sendMessage(Jobs.getLanguage().getMessage("general.give.output.notonline"));
+ }
+ } else {
+ sender.sendMessage(Jobs.getLanguage().getMessage("command.exp.error.nojob"));
+ }
+ } catch (Exception e) {
+ sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
+ }
+ return true;
}
}