* @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 {