Search in sources :

Example 36 with OfflinePlayer

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

Example 37 with OfflinePlayer

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;
}
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) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 38 with OfflinePlayer

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

Example 39 with OfflinePlayer

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;
}
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)

Example 40 with OfflinePlayer

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

Aggregations

OfflinePlayer (org.bukkit.OfflinePlayer)55 Player (org.bukkit.entity.Player)21 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)10 Job (com.gamingmesh.jobs.container.Job)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 ArrayList (java.util.ArrayList)6 File (java.io.File)5 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 IOException (java.io.IOException)4 World (org.bukkit.World)4 CommandSender (org.bukkit.command.CommandSender)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 UUID (java.util.UUID)3 Location (org.bukkit.Location)3 JobProgression (com.gamingmesh.jobs.container.JobProgression)2 Island (com.wasteofplastic.acidisland.Island)2 List (java.util.List)2 Set (java.util.Set)2 net.aufdemrand.denizen.objects.dWorld (net.aufdemrand.denizen.objects.dWorld)2