use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsCommands method fire.
@JobCommand
public boolean fire(CommandSender sender, String[] args) {
if (args.length < 2) {
sendUsage(sender, "fire");
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
if (!jPlayer.isInJob(job)) {
String message = ChatColor.RED + Language.getMessage("command.fire.error.nojob");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.RED);
sender.sendMessage(message);
return true;
}
try {
Jobs.getPlayerManager().leaveJob(jPlayer, job);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
String message = Language.getMessage("command.fire.output.target");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
player.sendMessage(message);
}
sender.sendMessage(Language.getMessage("command.admin.success"));
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
}
return true;
}
use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsCommands method removexp.
@JobCommand
public boolean removexp(CommandSender sender, String[] args) {
if (args.length < 3) {
sendUsage(sender, "removexp");
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
double xpLost;
try {
xpLost = Double.parseDouble(args[2]);
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
return true;
}
if (xpLost <= 0) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
return true;
}
// check if player already has the job
if (jPlayer.isInJob(job)) {
Jobs.getPlayerManager().removeExperience(jPlayer, job, xpLost);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
String message = Language.getMessage("command.removexp.output.target");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
message = message.replace("%xplost%", Double.valueOf(xpLost).toString());
player.sendMessage(message);
}
sender.sendMessage(Language.getMessage("command.admin.success"));
}
return true;
}
use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsCommands method leaveall.
@JobCommand
public boolean leaveall(CommandSender sender, String[] args) {
if (!(sender instanceof Player))
return false;
Player pSender = (Player) sender;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender);
List<JobProgression> jobs = jPlayer.getJobProgression();
if (jobs.size() == 0) {
sender.sendMessage(Language.getMessage("command.leaveall.error.nojobs"));
return true;
}
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
sender.sendMessage(Language.getMessage("command.leaveall.success"));
return true;
}
use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsCommands method employ.
@JobCommand
public boolean employ(CommandSender sender, String[] args) {
if (args.length < 2) {
sendUsage(sender, "employ");
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
if (jPlayer.isInJob(job)) {
// already in job message
String message = ChatColor.RED + Language.getMessage("command.employ.error.alreadyin");
message = message.replace("%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 = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
String message = Language.getMessage("command.employ.output.target");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
player.sendMessage(message);
}
sender.sendMessage(Language.getMessage("command.admin.success"));
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
}
return true;
}
use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsCommands method leave.
@JobCommand
public boolean leave(CommandSender sender, String[] args) {
if (!(sender instanceof Player))
return false;
if (args.length < 1) {
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 + Language.getMessage("command.error.job"));
return true;
}
Jobs.getPlayerManager().leaveJob(jPlayer, job);
String message = Language.getMessage("command.leave.success");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
sender.sendMessage(message);
return true;
}
Aggregations