mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-01 23:13:48 +01:00
Improving boost command handling
This commit is contained in:
parent
3b0cfc662f
commit
55a0705826
@ -6,7 +6,8 @@ import com.gamingmesh.jobs.Jobs;
|
|||||||
import com.gamingmesh.jobs.commands.Cmd;
|
import com.gamingmesh.jobs.commands.Cmd;
|
||||||
import com.gamingmesh.jobs.container.CurrencyType;
|
import com.gamingmesh.jobs.container.CurrencyType;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.stuff.Util;
|
|
||||||
|
import net.Zrips.CMILib.Time.timeModifier;
|
||||||
|
|
||||||
public class expboost implements Cmd {
|
public class expboost implements Cmd {
|
||||||
|
|
||||||
@ -17,35 +18,67 @@ public class expboost implements Cmd {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double rate = 1.0;
|
Double rate = null;
|
||||||
if (args[0].equalsIgnoreCase("all")) {
|
Long timeDuration = null;
|
||||||
|
String jobName = null;
|
||||||
|
boolean reset = false;
|
||||||
|
|
||||||
|
for (String one : args) {
|
||||||
|
if (one.equalsIgnoreCase("reset")) {
|
||||||
|
reset = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jobName == null) {
|
||||||
|
jobName = one;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rate == null) {
|
||||||
|
try {
|
||||||
|
rate = Double.parseDouble(one);
|
||||||
|
continue;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
Long t = timeModifier.getTimeRangeFromString(one);
|
||||||
} catch (NumberFormatException e) {
|
if (t != null)
|
||||||
Jobs.getCommandManager().sendUsage(sender, "expboost");
|
timeDuration = t;
|
||||||
return true;
|
continue;
|
||||||
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int[] times = Util.parseTime(args);
|
if (!reset && rate == null || jobName == null) {
|
||||||
|
Jobs.getCommandManager().sendUsage(sender, "expboost");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rate == null)
|
||||||
|
rate = 1D;
|
||||||
|
|
||||||
|
if (timeDuration == null)
|
||||||
|
timeDuration = 0L;
|
||||||
|
|
||||||
|
if (!reset && jobName.equalsIgnoreCase("all")) {
|
||||||
for (Job job : Jobs.getJobs()) {
|
for (Job job : Jobs.getJobs()) {
|
||||||
job.addBoost(CurrencyType.EXP, rate, times);
|
job.addBoost(CurrencyType.EXP, rate, timeDuration);
|
||||||
}
|
}
|
||||||
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate));
|
||||||
sender.sendMessage(
|
|
||||||
Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("reset")) {
|
if (reset) {
|
||||||
if (args[1].equalsIgnoreCase("all")) {
|
if (jobName.equalsIgnoreCase("all")) {
|
||||||
for (Job one : Jobs.getJobs()) {
|
for (Job one : Jobs.getJobs()) {
|
||||||
one.addBoost(CurrencyType.EXP, 1.0);
|
one.addBoost(CurrencyType.EXP, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset"));
|
||||||
} else if (args.length > 1) {
|
} else if (args.length > 1) {
|
||||||
Job job = Jobs.getJob(args[1]);
|
Job job = Jobs.getJob(jobName);
|
||||||
if (job == null) {
|
if (job == null) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||||
return true;
|
return true;
|
||||||
@ -53,27 +86,19 @@ public class expboost implements Cmd {
|
|||||||
|
|
||||||
job.addBoost(CurrencyType.EXP, 1.0);
|
job.addBoost(CurrencyType.EXP, 1.0);
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset",
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset", "%jobname%", job.getName()));
|
||||||
"%jobname%", job.getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Job job = Jobs.getJob(args[0]);
|
Job job = Jobs.getJob(jobName);
|
||||||
if (job == null) {
|
if (job == null) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
job.addBoost(CurrencyType.EXP, rate, timeDuration);
|
||||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Jobs.getCommandManager().sendUsage(sender, "expboost");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
job.addBoost(CurrencyType.EXP, rate, Util.parseTime(args));
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate,
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate,
|
||||||
"%jobname%", job.getName()));
|
"%jobname%", job.getName()));
|
||||||
return true;
|
return true;
|
||||||
|
@ -6,7 +6,8 @@ import com.gamingmesh.jobs.Jobs;
|
|||||||
import com.gamingmesh.jobs.commands.Cmd;
|
import com.gamingmesh.jobs.commands.Cmd;
|
||||||
import com.gamingmesh.jobs.container.CurrencyType;
|
import com.gamingmesh.jobs.container.CurrencyType;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.stuff.Util;
|
|
||||||
|
import net.Zrips.CMILib.Time.timeModifier;
|
||||||
|
|
||||||
public class moneyboost implements Cmd {
|
public class moneyboost implements Cmd {
|
||||||
|
|
||||||
@ -17,35 +18,67 @@ public class moneyboost implements Cmd {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double rate = 1.0;
|
Double rate = null;
|
||||||
if (args[0].equalsIgnoreCase("all")) {
|
Long timeDuration = null;
|
||||||
|
String jobName = null;
|
||||||
|
boolean reset = false;
|
||||||
|
|
||||||
|
for (String one : args) {
|
||||||
|
if (one.equalsIgnoreCase("reset")) {
|
||||||
|
reset = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jobName == null) {
|
||||||
|
jobName = one;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rate == null) {
|
||||||
|
try {
|
||||||
|
rate = Double.parseDouble(one);
|
||||||
|
continue;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
Long t = timeModifier.getTimeRangeFromString(one);
|
||||||
} catch (NumberFormatException e) {
|
if (t != null)
|
||||||
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
|
timeDuration = t;
|
||||||
return true;
|
continue;
|
||||||
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int[] times = Util.parseTime(args);
|
if (!reset && rate == null || jobName == null) {
|
||||||
|
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rate == null)
|
||||||
|
rate = 1D;
|
||||||
|
|
||||||
|
if (timeDuration == null)
|
||||||
|
timeDuration = 0L;
|
||||||
|
|
||||||
|
if (!reset && jobName.equalsIgnoreCase("all")) {
|
||||||
for (Job job : Jobs.getJobs()) {
|
for (Job job : Jobs.getJobs()) {
|
||||||
job.addBoost(CurrencyType.MONEY, rate, times);
|
job.addBoost(CurrencyType.MONEY, rate, 0L);
|
||||||
}
|
}
|
||||||
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
|
||||||
sender.sendMessage(
|
|
||||||
Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("reset")) {
|
if (reset) {
|
||||||
if (args[1].equalsIgnoreCase("all")) {
|
if (jobName.equalsIgnoreCase("all")) {
|
||||||
for (Job one : Jobs.getJobs()) {
|
for (Job one : Jobs.getJobs()) {
|
||||||
one.addBoost(CurrencyType.MONEY, 1.0);
|
one.addBoost(CurrencyType.MONEY, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset"));
|
||||||
} else if (args.length > 1) {
|
} else if (args.length > 1) {
|
||||||
Job job = Jobs.getJob(args[1]);
|
Job job = Jobs.getJob(jobName);
|
||||||
if (job == null) {
|
if (job == null) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||||
return true;
|
return true;
|
||||||
@ -53,30 +86,21 @@ public class moneyboost implements Cmd {
|
|||||||
|
|
||||||
job.addBoost(CurrencyType.MONEY, 1.0);
|
job.addBoost(CurrencyType.MONEY, 1.0);
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset",
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset", "%jobname%", job.getName()));
|
||||||
"%jobname%", job.getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Job job = Jobs.getJob(args[0]);
|
Job job = Jobs.getJob(jobName);
|
||||||
if (job == null) {
|
if (job == null) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
job.addBoost(CurrencyType.MONEY, rate, timeDuration);
|
||||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
job.addBoost(CurrencyType.MONEY, rate, Util.parseTime(args));
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate,
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate,
|
||||||
"%jobname%", job.getName()));
|
"%jobname%", job.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,8 @@ import com.gamingmesh.jobs.Jobs;
|
|||||||
import com.gamingmesh.jobs.commands.Cmd;
|
import com.gamingmesh.jobs.commands.Cmd;
|
||||||
import com.gamingmesh.jobs.container.CurrencyType;
|
import com.gamingmesh.jobs.container.CurrencyType;
|
||||||
import com.gamingmesh.jobs.container.Job;
|
import com.gamingmesh.jobs.container.Job;
|
||||||
import com.gamingmesh.jobs.stuff.Util;
|
|
||||||
|
import net.Zrips.CMILib.Time.timeModifier;
|
||||||
|
|
||||||
public class pointboost implements Cmd {
|
public class pointboost implements Cmd {
|
||||||
|
|
||||||
@ -17,35 +18,67 @@ public class pointboost implements Cmd {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double rate = 1.0;
|
Double rate = null;
|
||||||
if (args[0].equalsIgnoreCase("all")) {
|
Long timeDuration = null;
|
||||||
|
String jobName = null;
|
||||||
|
boolean reset = false;
|
||||||
|
|
||||||
|
for (String one : args) {
|
||||||
|
if (one.equalsIgnoreCase("reset")) {
|
||||||
|
reset = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jobName == null) {
|
||||||
|
jobName = one;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rate == null) {
|
||||||
|
try {
|
||||||
|
rate = Double.parseDouble(one);
|
||||||
|
continue;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
Long t = timeModifier.getTimeRangeFromString(one);
|
||||||
} catch (NumberFormatException e) {
|
if (t != null)
|
||||||
Jobs.getCommandManager().sendUsage(sender, "pointboost");
|
timeDuration = t;
|
||||||
return true;
|
continue;
|
||||||
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int[] times = Util.parseTime(args);
|
if (!reset && rate == null || jobName == null) {
|
||||||
|
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rate == null)
|
||||||
|
rate = 1D;
|
||||||
|
|
||||||
|
if (timeDuration == null)
|
||||||
|
timeDuration = 0L;
|
||||||
|
|
||||||
|
if (!reset && jobName.equalsIgnoreCase("all")) {
|
||||||
for (Job job : Jobs.getJobs()) {
|
for (Job job : Jobs.getJobs()) {
|
||||||
job.addBoost(CurrencyType.POINTS, rate, times);
|
job.addBoost(CurrencyType.POINTS, rate, 0L);
|
||||||
}
|
}
|
||||||
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate));
|
||||||
sender.sendMessage(
|
|
||||||
Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("reset")) {
|
if (reset) {
|
||||||
if (args[1].equalsIgnoreCase("all")) {
|
if (jobName.equalsIgnoreCase("all")) {
|
||||||
for (Job one : Jobs.getJobs()) {
|
for (Job one : Jobs.getJobs()) {
|
||||||
one.addBoost(CurrencyType.POINTS, 1.0);
|
one.addBoost(CurrencyType.POINTS, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.allreset"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.allreset"));
|
||||||
} else if (args.length > 1) {
|
} else if (args.length > 1) {
|
||||||
Job job = Jobs.getJob(args[1]);
|
Job job = Jobs.getJob(jobName);
|
||||||
if (job == null) {
|
if (job == null) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||||
return true;
|
return true;
|
||||||
@ -53,27 +86,19 @@ public class pointboost implements Cmd {
|
|||||||
|
|
||||||
job.addBoost(CurrencyType.POINTS, 1.0);
|
job.addBoost(CurrencyType.POINTS, 1.0);
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset",
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset", "%jobname%", job.getName()));
|
||||||
"%jobname%", job.getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Job job = Jobs.getJob(args[0]);
|
Job job = Jobs.getJob(jobName);
|
||||||
if (job == null) {
|
if (job == null) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
job.addBoost(CurrencyType.POINTS, rate, timeDuration);
|
||||||
rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Jobs.getCommandManager().sendUsage(sender, "pointboost");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
job.addBoost(CurrencyType.POINTS, rate, Util.parseTime(args));
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", rate,
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", rate,
|
||||||
"%jobname%", job.getName()));
|
"%jobname%", job.getName()));
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user