1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-11 11:51:54 +01:00
Jobs/com/gamingmesh/jobs/commands/list/fireall.java

50 lines
1.5 KiB
Java
Raw Normal View History

2016-03-30 15:42:36 +02:00
package com.gamingmesh.jobs.commands.list;
import java.util.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.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.ChatColor;
public class fireall implements Cmd {
2016-06-25 17:56:59 +02:00
@Override
2016-03-30 15:42:36 +02:00
@JobCommand(2000)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
2016-03-30 15:42:36 +02:00
if (args.length < 1) {
Jobs.getCommandManager().sendUsage(sender, "fireall");
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;
}
2016-03-30 15:42:36 +02:00
List<JobProgression> jobs = jPlayer.getJobProgression();
if (jobs.size() == 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.fireall.error.nojobs"));
return true;
}
try {
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
Player player = jPlayer.getPlayer();
2016-03-30 15:42:36 +02:00
if (player != null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.fireall.output.target"));
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success"));
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error"));
}
return true;
}
}