/** * Broadcasts level up about a player * * @param jPlayer * @param job */ public void performLevelUp(JobsPlayer jPlayer, Job job) { Player player = plugin.getServer().getPlayer(jPlayer.getName()); JobProgression prog = jPlayer.getJobProgression(job); if (prog == null) return; String message; if (plugin.getJobsConfiguration().isBroadcastingLevelups()) { message = plugin.getMessageConfig().getMessage("level-up-broadcast"); } else { message = plugin.getMessageConfig().getMessage("level-up-no-broadcast"); } message = message.replace("%jobname%", job.getName()); message = message.replace("%jobcolour%", job.getChatColour().toString()); if (prog.getTitle() != null) { message = message.replace("%titlename%", prog.getTitle().getName()); message = message.replace("%titlecolour%", prog.getTitle().getChatColor().toString()); } message = message.replace("%playername%", jPlayer.getName()); if (player == null) { message = message.replace("%playerdisplayname%", jPlayer.getName()); } else { message = message.replace("%playerdisplayname%", player.getDisplayName()); } message = message.replace("%joblevel%", "" + prog.getLevel()); for (String line : message.split("\n")) { if (plugin.getJobsConfiguration().isBroadcastingLevelups()) { plugin.getServer().broadcastMessage(line); } else if (player != null) { player.sendMessage(line); } } Title levelTitle = plugin.getJobsConfiguration().getTitleForLevel(prog.getLevel()); if (levelTitle != null && !levelTitle.equals(prog.getTitle())) { // user would skill up if (plugin.getJobsConfiguration().isBroadcastingSkillups()) { message = plugin.getMessageConfig().getMessage("skill-up-broadcast"); } else { message = plugin.getMessageConfig().getMessage("skill-up-no-broadcast"); } message = message.replace("%playername%", jPlayer.getName()); message = message.replace("%titlecolour%", levelTitle.getChatColor().toString()); message = message.replace("%titlename%", levelTitle.getName()); message = message.replace("%jobcolour%", job.getChatColour().toString()); message = message.replace("%jobname%", job.getName()); for (String line : message.split("\n")) { if (plugin.getJobsConfiguration().isBroadcastingLevelups()) { plugin.getServer().broadcastMessage(line); } else if (player != null) { player.sendMessage(line); } } } prog.setTitle(levelTitle); jPlayer.reloadHonorific(); jPlayer.recalculatePermissions(); }
/** * Handles join of new player * * @param playername */ public void playerJoin(String playername) { synchronized (players) { JobsPlayer jPlayer = players.get(playername); if (jPlayer == null) { jPlayer = new JobsPlayer(plugin, playername); jPlayer.loadDAOData(plugin.getJobsCore().getJobsDAO().getAllJobs(jPlayer)); players.put(playername, jPlayer); } jPlayer.onConnect(); jPlayer.reloadHonorific(); jPlayer.recalculatePermissions(); } }