Search in sources :

Example 11 with JobProgression

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);
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) JobProgression(com.gamingmesh.jobs.container.JobProgression) Title(com.gamingmesh.jobs.container.Title)

Example 12 with JobProgression

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;
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) JobProgression(com.gamingmesh.jobs.container.JobProgression) OfflinePlayer(org.bukkit.OfflinePlayer) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer)

Aggregations

JobProgression (com.gamingmesh.jobs.container.JobProgression)12 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)7 Player (org.bukkit.entity.Player)6 OfflinePlayer (org.bukkit.OfflinePlayer)4 Job (com.gamingmesh.jobs.container.Job)3 JobInfo (com.gamingmesh.jobs.container.JobInfo)1 JobPermission (com.gamingmesh.jobs.container.JobPermission)1 Title (com.gamingmesh.jobs.container.Title)1 ChatColor (com.gamingmesh.jobs.util.ChatColor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 Permission (org.bukkit.permissions.Permission)1 PermissionAttachment (org.bukkit.permissions.PermissionAttachment)1 PermissionAttachmentInfo (org.bukkit.permissions.PermissionAttachmentInfo)1