2016-03-30 15:42:36 +02:00
|
|
|
package com.gamingmesh.jobs.commands.list;
|
|
|
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
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.container.JobsPlayer;
|
|
|
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
|
|
|
|
|
|
|
public class promote implements Cmd {
|
|
|
|
|
2016-06-25 17:56:59 +02:00
|
|
|
@Override
|
2016-03-30 15:42:36 +02:00
|
|
|
@JobCommand(1600)
|
2016-08-08 16:36:56 +02:00
|
|
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
2016-03-30 15:42:36 +02:00
|
|
|
if (args.length < 3) {
|
|
|
|
Jobs.getCommandManager().sendUsage(sender, "promote");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-09-21 16:18:08 +02:00
|
|
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
2016-03-30 15:42:36 +02:00
|
|
|
|
|
|
|
Job job = Jobs.getJob(args[1]);
|
|
|
|
if (job == null) {
|
|
|
|
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job"));
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-21 16:18:08 +02:00
|
|
|
if (jPlayer == null) {
|
|
|
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
|
|
|
|
return true;
|
|
|
|
}
|
2016-03-30 15:42:36 +02:00
|
|
|
try {
|
|
|
|
// check if player already has the job
|
|
|
|
if (jPlayer.isInJob(job)) {
|
|
|
|
Integer levelsGained = Integer.parseInt(args[2]);
|
|
|
|
Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained);
|
|
|
|
|
2016-09-21 16:18:08 +02:00
|
|
|
Player player = jPlayer.getPlayer();
|
2016-03-30 15:42:36 +02:00
|
|
|
if (player != null) {
|
|
|
|
player.sendMessage(Jobs.getLanguage().getMessage("command.promote.output.target",
|
|
|
|
"%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE,
|
|
|
|
"%levelsgained%", levelsGained));
|
|
|
|
}
|
|
|
|
|
|
|
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error"));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|