mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-05 00:43:44 +01:00
7c8bfda568
Preload all players data for faster use on players login. Basic code cleanup
44 lines
1.3 KiB
Java
44 lines
1.3 KiB
Java
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 leave implements Cmd {
|
|
|
|
@Override
|
|
@JobCommand(800)
|
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
|
if (!(sender instanceof Player))
|
|
return false;
|
|
|
|
if (args.length < 1) {
|
|
Jobs.getCommandManager().sendUsage(sender, "leave");
|
|
return true;
|
|
}
|
|
|
|
Player pSender = (Player) sender;
|
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
|
|
|
|
String jobName = args[0];
|
|
Job job = Jobs.getJob(jobName);
|
|
if (job == null) {
|
|
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job"));
|
|
return true;
|
|
}
|
|
|
|
if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) {
|
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE));
|
|
} else
|
|
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job"));
|
|
return true;
|
|
|
|
}
|
|
}
|