use of org.bukkit.OfflinePlayer in project Jobs by GamingMesh.
the class JobsCommands method transfer.
@JobCommand
public boolean transfer(CommandSender sender, String[] args) {
if (args.length < 3) {
sendUsage(sender, "transfer");
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job oldjob = Jobs.getJob(args[1]);
Job newjob = Jobs.getJob(args[2]);
if (oldjob == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
if (newjob == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
try {
if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) {
Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
String message = Language.getMessage("command.transfer.output.target");
message = message.replace("%oldjobname%", oldjob.getChatColor() + oldjob.getName() + ChatColor.WHITE);
message = message.replace("%newjobname%", newjob.getChatColor() + newjob.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 org.bukkit.OfflinePlayer in project Jobs by GamingMesh.
the class JobsCommands method fireall.
@JobCommand
public boolean fireall(CommandSender sender, String[] args) {
if (args.length < 1) {
sendUsage(sender, "fireall");
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
List<JobProgression> jobs = jPlayer.getJobProgression();
if (jobs.size() == 0) {
sender.sendMessage(Language.getMessage("command.fireall.error.nojobs"));
return true;
}
try {
Jobs.getPlayerManager().leaveAllJobs(jPlayer);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
player.sendMessage(Language.getMessage("command.fireall.output.target"));
}
sender.sendMessage(Language.getMessage("command.admin.success"));
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
}
return true;
}
use of org.bukkit.OfflinePlayer in project Jobs by GamingMesh.
the class JobsCommands method playerinfo.
@JobCommand
public boolean playerinfo(CommandSender sender, String[] args) {
if (args.length < 2) {
sendUsage(sender, "playerinfo");
sendValidActions(sender);
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
String jobName = args[1];
Job job = Jobs.getJob(jobName);
if (job == null) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.job"));
return true;
}
String type = "";
if (args.length >= 3) {
type = args[2];
}
sender.sendMessage(jobInfoMessage(jPlayer, job, type).split("\n"));
return true;
}
use of org.bukkit.OfflinePlayer in project Jobs by GamingMesh.
the class JobsCommands method stats.
@JobCommand
public boolean stats(CommandSender sender, String[] args) {
JobsPlayer jPlayer = null;
if (args.length >= 1) {
if (!sender.hasPermission("jobs.command.admin.stats")) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.error.permission"));
return true;
}
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
} else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
}
if (jPlayer == null) {
sendUsage(sender, "stats");
return true;
}
if (jPlayer.getJobProgression().size() == 0) {
sender.sendMessage(Language.getMessage("command.stats.error.nojob"));
return true;
}
for (JobProgression jobProg : jPlayer.getJobProgression()) {
sender.sendMessage(jobStatsMessage(jobProg).split("\n"));
}
return true;
}
use of org.bukkit.OfflinePlayer in project Jobs by GamingMesh.
the class JobsCommands method promote.
@JobCommand
public boolean promote(CommandSender sender, String[] args) {
if (args.length < 3) {
sendUsage(sender, "promote");
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;
}
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {
Integer levelsGained = Integer.parseInt(args[2]);
Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId());
if (player != null) {
String message = Language.getMessage("command.promote.output.target");
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
message = message.replace("%levelsgained%", Integer.valueOf(levelsGained).toString());
player.sendMessage(message);
}
sender.sendMessage(Language.getMessage("command.admin.success"));
}
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + Language.getMessage("command.admin.error"));
}
return true;
}
Aggregations