1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-11 03:44:18 +01:00
Jobs/com/gamingmesh/jobs/commands/list/employ.java

57 lines
1.9 KiB
Java
Raw Normal View History

2016-09-23 14:07:35 +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 employ implements Cmd {
@Override
@JobCommand(1800)
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length < 2) {
Jobs.getCommandManager().sendUsage(sender, "employ");
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
if (jPlayer.isInJob(job)) {
// already in job message
String message = ChatColor.RED + Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getChatColor() + job.getName()
+ ChatColor.RED);
sender.sendMessage(message);
return true;
}
try {
// check if player already has the job
Jobs.getPlayerManager().joinJob(jPlayer, job);
Player player = jPlayer.getPlayer();
if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE));
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
}
}