use of com.gamingmesh.jobs.container.JobProgression in project Jobs by GamingMesh.
the class PlayerManager method performLevelUp.
/**
* Broadcasts level up about a player
* @param jPlayer
* @param job
* @param oldLevel
*/
public void performLevelUp(JobsPlayer jPlayer, Job job, int oldLevel) {
Player player = Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID());
JobProgression prog = jPlayer.getJobProgression(job);
if (prog == null)
return;
String message;
if (ConfigManager.getJobsConfiguration().isBroadcastingLevelups()) {
message = Language.getMessage("message.levelup.broadcast");
} else {
message = Language.getMessage("message.levelup.nobroadcast");
}
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
Title oldTitle = ConfigManager.getJobsConfiguration().getTitleForLevel(oldLevel);
if (oldTitle != null) {
message = message.replace("%titlename%", oldTitle.getChatColor() + oldTitle.getName() + ChatColor.WHITE);
}
if (player != null) {
message = message.replace("%playername%", player.getDisplayName());
} else {
message = message.replace("%playername%", jPlayer.getUserName());
}
message = message.replace("%joblevel%", "" + prog.getLevel());
for (String line : message.split("\n")) {
if (ConfigManager.getJobsConfiguration().isBroadcastingLevelups()) {
Bukkit.getServer().broadcastMessage(line);
} else if (player != null) {
player.sendMessage(line);
}
}
Title newTitle = ConfigManager.getJobsConfiguration().getTitleForLevel(prog.getLevel());
if (newTitle != null && !newTitle.equals(oldTitle)) {
// user would skill up
if (ConfigManager.getJobsConfiguration().isBroadcastingSkillups()) {
message = Language.getMessage("message.skillup.broadcast");
} else {
message = Language.getMessage("message.skillup.nobroadcast");
}
if (player != null) {
message = message.replace("%playername%", player.getDisplayName());
} else {
message = message.replace("%playername%", jPlayer.getUserName());
}
message = message.replace("%titlename%", newTitle.getChatColor() + newTitle.getName() + ChatColor.WHITE);
message = message.replace("%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
for (String line : message.split("\n")) {
if (ConfigManager.getJobsConfiguration().isBroadcastingLevelups()) {
Bukkit.getServer().broadcastMessage(line);
} else if (player != null) {
player.sendMessage(line);
}
}
}
jPlayer.reloadHonorific();
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
}
use of com.gamingmesh.jobs.container.JobProgression 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;
}
Aggregations