1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-05 00:43:44 +01:00
Jobs/com/gamingmesh/jobs/commands/list/moneyboost.java

80 lines
2.3 KiB
Java
Raw Normal View History

2016-03-30 15:42:36 +02:00
package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.stuff.ChatColor;
public class moneyboost implements Cmd {
2016-06-25 17:56:59 +02:00
@Override
2016-03-30 15:42:36 +02:00
@JobCommand(2400)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
2016-03-30 15:42:36 +02:00
if (args.length > 2 || args.length <= 1) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
double rate = 1.0;
if (!args[1].equalsIgnoreCase("all") && !args[0].equalsIgnoreCase("reset"))
try {
rate = Double.parseDouble(args[1]);
} catch (NumberFormatException e) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
String PlayerName = sender.getName();
String jobName = args[0];
Job job = Jobs.getJob(jobName);
if (PlayerName == null) {
Jobs.getCommandManager().sendUsage(sender, "moneyboost");
return true;
}
if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.setMoneyBoost(1.0);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.allreset"));
return true;
} else if (args[0].equalsIgnoreCase("reset")) {
boolean found = false;
for (Job one : Jobs.getJobs()) {
if (one.getName().equalsIgnoreCase(args[1])) {
one.setMoneyBoost(1.0);
found = true;
break;
}
}
if (found) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset", "%jobname%", job.getName()));
return true;
}
}
if (args[0].equalsIgnoreCase("all")) {
for (Job one : Jobs.getJobs()) {
one.setMoneyBoost(rate);
}
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate));
return true;
2016-06-25 15:27:01 +02:00
}
if (job == null) {
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("general.error.job"));
2016-03-30 15:42:36 +02:00
return true;
}
2016-06-25 15:27:01 +02:00
job.setMoneyBoost(rate);
sender.sendMessage(ChatColor.GREEN + Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName()));
return true;
2016-03-30 15:42:36 +02:00
}
}