1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 15:03:36 +01:00

We don't need to check by offline player and properly update cache on

player logout
This commit is contained in:
Zrips 2016-09-21 17:18:08 +03:00
parent 558f775b2b
commit 81a02dbbe0
21 changed files with 67 additions and 122 deletions

View File

@ -1,6 +1,6 @@
/HookEconomyTask.class /HookEconomyTask.class
/Jobs.class /Jobs.class
/JobsPlugin.class /Jobs.class
/PermissionHandler.class /PermissionHandler.class
/PlayerManager.class /PlayerManager.class
/Jobs$1.class /Jobs$1.class

View File

@ -28,7 +28,6 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -141,14 +140,14 @@ public class PlayerManager {
* @param playername * @param playername
*/ */
public void playerQuit(Player player) { public void playerQuit(Player player) {
JobsPlayer jPlayer = this.players.remove(player.getName().toLowerCase());
playersCache.put(player.getName().toLowerCase(), jPlayer);
if (Jobs.getGCManager().saveOnDisconnect()) { if (Jobs.getGCManager().saveOnDisconnect()) {
JobsPlayer jPlayer = this.players.remove(player.getName().toLowerCase());
if (jPlayer != null) { if (jPlayer != null) {
jPlayer.save(); jPlayer.save();
jPlayer.onDisconnect(); jPlayer.onDisconnect();
} }
} else { } else {
JobsPlayer jPlayer = this.players.get(player.getName().toLowerCase());
if (jPlayer != null) { if (jPlayer != null) {
jPlayer.onDisconnect(); jPlayer.onDisconnect();
} }
@ -196,53 +195,10 @@ public class PlayerManager {
* @return the player job info of the player * @return the player job info of the player
*/ */
public JobsPlayer getJobsPlayer(String playerName) { public JobsPlayer getJobsPlayer(String playerName) {
return this.playersCache.get(playerName.toLowerCase()); JobsPlayer jPlayer = this.players.get(playerName.toLowerCase());
}
public JobsPlayer getJobsPlayerOffline(OfflinePlayer player) {
return getJobsPlayerOffline(player.getName());
}
/**
* Get the player job info for specific player
* @param player - the player who's job you're getting
* @return the player job info of the player
*/
public JobsPlayer getJobsPlayerOffline(String playerName) {
JobsPlayer jPlayer = this.playersCache.get(playerName.toLowerCase());
if (jPlayer != null) if (jPlayer != null)
return jPlayer; return jPlayer;
return this.playersCache.get(playerName.toLowerCase());
Entry<String, PlayerInfo> info = getPlayerInfoByName(playerName);
if (info == null)
return null;
if (info.getValue().getName() == null)
return null;
jPlayer = new JobsPlayer(info.getValue().getName(), null);
jPlayer.setPlayerUUID(UUID.fromString(info.getKey()));
jPlayer.setUserId(info.getValue().getID());
List<JobsDAOData> list = Jobs.getJobsDAO().getAllJobs(info.getValue().getName(), UUID.fromString(info.getKey()));
for (JobsDAOData jobdata : list) {
if (Jobs.getJob(jobdata.getJobName()) == null)
continue;
Job job = Jobs.getJob(jobdata.getJobName());
if (job == null)
continue;
JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience());
jPlayer.progression.add(jobProgression);
jPlayer.reloadMaxExperience();
jPlayer.reloadLimits();
}
Jobs.getJobsDAO().loadPoints(jPlayer);
jPlayer.loadLogFromDao();
return jPlayer;
} }
/** /**

View File

@ -46,3 +46,4 @@
/blockinfo.class /blockinfo.class
/test.class /test.class
/purge.class /purge.class
/saveall.class

View File

@ -2,8 +2,6 @@ package com.gamingmesh.jobs.commands.list;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -24,9 +22,7 @@ public class archive implements Cmd {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission")); sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission"));
return true; return true;
} }
@SuppressWarnings("deprecation") jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
} else if (sender instanceof Player) { } else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);

View File

@ -1,7 +1,6 @@
package com.gamingmesh.jobs.commands.list; package com.gamingmesh.jobs.commands.list;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -22,22 +21,26 @@ public class demote implements Cmd {
return true; return true;
} }
@SuppressWarnings("deprecation") JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job"));
return true; return true;
} }
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
try { try {
// check if player already has the job // check if player already has the job
if (jPlayer.isInJob(job)) { if (jPlayer.isInJob(job)) {
Integer levelsLost = Integer.parseInt(args[2]); Integer levelsLost = Integer.parseInt(args[2]);
Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost); Jobs.getPlayerManager().demoteJob(jPlayer, job, levelsLost);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); Player player = Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID());
if (player != null) { if (player != null) {
String message = Jobs.getLanguage().getMessage("command.demote.output.target", String message = Jobs.getLanguage().getMessage("command.demote.output.target",
"%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE, "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE,

View File

@ -19,8 +19,6 @@ public class editpoints implements Cmd {
} }
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[1]); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[1]);
if (jPlayer == null)
jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(args[1]);
if (jPlayer == null) { if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[1])); sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[1]));

View File

@ -22,15 +22,19 @@ public class employ implements Cmd {
return true; return true;
} }
@SuppressWarnings("deprecation") JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job"));
return true; return true;
} }
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
if (jPlayer.isInJob(job)) { if (jPlayer.isInJob(job)) {
// already in job message // already in job message
String message = ChatColor.RED + Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getChatColor() + job.getName() String message = ChatColor.RED + Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getChatColor() + job.getName()
@ -41,7 +45,7 @@ public class employ implements Cmd {
try { try {
// check if player already has the job // check if player already has the job
Jobs.getPlayerManager().joinJob(jPlayer, job); Jobs.getPlayerManager().joinJob(jPlayer, job);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); Player player = jPlayer.getPlayer();
if (player != null) if (player != null)
player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE)); player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE));

View File

@ -22,21 +22,19 @@ public class fire implements Cmd {
return true; return true;
} }
@SuppressWarnings("deprecation") JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job"));
return true; return true;
} }
if (jPlayer == null){ if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true; return true;
} }
if (!jPlayer.isInJob(job)) { if (!jPlayer.isInJob(job)) {
String message = ChatColor.RED + Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getChatColor() + job.getName() + ChatColor.RED); String message = ChatColor.RED + Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getChatColor() + job.getName() + ChatColor.RED);
sender.sendMessage(message); sender.sendMessage(message);
@ -44,7 +42,7 @@ public class fire implements Cmd {
} }
try { try {
Jobs.getPlayerManager().leaveJob(jPlayer, job); Jobs.getPlayerManager().leaveJob(jPlayer, job);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); Player player = jPlayer.getPlayer();
if (player != null) { if (player != null) {
String message = Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE); String message = Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE);
player.sendMessage(message); player.sendMessage(message);

View File

@ -2,8 +2,6 @@ package com.gamingmesh.jobs.commands.list;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -24,10 +22,11 @@ public class fireall implements Cmd {
return true; return true;
} }
@SuppressWarnings("deprecation") JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); if (jPlayer == null) {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
List<JobProgression> jobs = jPlayer.getJobProgression(); List<JobProgression> jobs = jPlayer.getJobProgression();
if (jobs.size() == 0) { if (jobs.size() == 0) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.fireall.error.nojobs")); sender.sendMessage(Jobs.getLanguage().getMessage("command.fireall.error.nojobs"));
@ -36,7 +35,7 @@ public class fireall implements Cmd {
try { try {
Jobs.getPlayerManager().leaveAllJobs(jPlayer); Jobs.getPlayerManager().leaveAllJobs(jPlayer);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); Player player = jPlayer.getPlayer();
if (player != null) { if (player != null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.fireall.output.target")); player.sendMessage(Jobs.getLanguage().getMessage("command.fireall.output.target"));
} }

View File

@ -47,9 +47,6 @@ public class glog implements Cmd {
continue; continue;
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(name); JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(name);
if (JPlayer == null) {
JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(name);
}
if (JPlayer == null) if (JPlayer == null)
continue; continue;

View File

@ -1,8 +1,6 @@
package com.gamingmesh.jobs.commands.list; package com.gamingmesh.jobs.commands.list;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -23,9 +21,7 @@ public class grantxp implements Cmd {
return true; return true;
} }
@SuppressWarnings("deprecation") JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
@ -43,11 +39,17 @@ public class grantxp implements Cmd {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error")); sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.admin.error"));
return true; return true;
} }
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
// check if player already has the job // check if player already has the job
if (jPlayer.isInJob(job)) { if (jPlayer.isInJob(job)) {
Jobs.getPlayerManager().addExperience(jPlayer, job, xpGained); Jobs.getPlayerManager().addExperience(jPlayer, job, xpGained);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); Player player = jPlayer.getPlayer();
if (player != null) { if (player != null) {
String message = Jobs.getLanguage().getMessage("command.grantxp.output.target", String message = Jobs.getLanguage().getMessage("command.grantxp.output.target",
"%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE, "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE,

View File

@ -40,8 +40,6 @@ public class log implements Cmd {
return true; return true;
} }
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (JPlayer == null)
JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(args[0]);
} }
if (JPlayer == null) { if (JPlayer == null) {

View File

@ -1,7 +1,5 @@
package com.gamingmesh.jobs.commands.list; package com.gamingmesh.jobs.commands.list;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Jobs;
@ -22,9 +20,7 @@ public class playerinfo implements Cmd {
return true; return true;
} }
@SuppressWarnings("deprecation") JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
String jobName = args[1]; String jobName = args[1];
Job job = Jobs.getJob(jobName); Job job = Jobs.getJob(jobName);

View File

@ -28,8 +28,6 @@ public class points implements Cmd {
return true; return true;
} }
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null)
jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(args[0]);
} else if (sender instanceof Player) { } else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
} }

View File

@ -1,7 +1,5 @@
package com.gamingmesh.jobs.commands.list; package com.gamingmesh.jobs.commands.list;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -22,22 +20,24 @@ public class promote implements Cmd {
return true; return true;
} }
@SuppressWarnings("deprecation") JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer);
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job")); sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.job"));
return true; return true;
} }
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
try { try {
// check if player already has the job // check if player already has the job
if (jPlayer.isInJob(job)) { if (jPlayer.isInJob(job)) {
Integer levelsGained = Integer.parseInt(args[2]); Integer levelsGained = Integer.parseInt(args[2]);
Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained); Jobs.getPlayerManager().promoteJob(jPlayer, job, levelsGained);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); Player player = jPlayer.getPlayer();
if (player != null) { if (player != null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.promote.output.target", player.sendMessage(Jobs.getLanguage().getMessage("command.promote.output.target",
"%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE, "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE,

View File

@ -1,8 +1,6 @@
package com.gamingmesh.jobs.commands.list; package com.gamingmesh.jobs.commands.list;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -23,9 +21,12 @@ public class removexp implements Cmd {
return true; return true;
} }
@SuppressWarnings("deprecation") JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
Job job = Jobs.getJob(args[1]); Job job = Jobs.getJob(args[1]);
if (job == null) { if (job == null) {
@ -47,7 +48,7 @@ public class removexp implements Cmd {
if (jPlayer.isInJob(job)) { if (jPlayer.isInJob(job)) {
Jobs.getPlayerManager().removeExperience(jPlayer, job, xpLost); Jobs.getPlayerManager().removeExperience(jPlayer, job, xpLost);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); Player player = jPlayer.getPlayer();
if (player != null) { if (player != null) {
player.sendMessage(Jobs.getLanguage().getMessage("command.removexp.output.target", player.sendMessage(Jobs.getLanguage().getMessage("command.removexp.output.target",
"%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE, "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE,

View File

@ -22,8 +22,6 @@ public class stats implements Cmd {
return true; return true;
} }
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null)
jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(args[0]);
} else if (sender instanceof Player) { } else if (sender instanceof Player) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
} }

View File

@ -1,8 +1,6 @@
package com.gamingmesh.jobs.commands.list; package com.gamingmesh.jobs.commands.list;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -23,10 +21,11 @@ public class transfer implements Cmd {
return true; return true;
} }
@SuppressWarnings("deprecation") JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(args[0]); if (jPlayer == null) {
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(offlinePlayer); sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
Job oldjob = Jobs.getJob(args[1]); Job oldjob = Jobs.getJob(args[1]);
Job newjob = Jobs.getJob(args[2]); Job newjob = Jobs.getJob(args[2]);
if (oldjob == null) { if (oldjob == null) {
@ -41,7 +40,7 @@ public class transfer implements Cmd {
if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) { if (jPlayer.isInJob(oldjob) && !jPlayer.isInJob(newjob)) {
Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob); Jobs.getPlayerManager().transferJob(jPlayer, oldjob, newjob);
Player player = Bukkit.getServer().getPlayer(offlinePlayer.getUniqueId()); Player player = jPlayer.getPlayer();
if (player != null) { if (player != null) {
String message = Jobs.getLanguage().getMessage("command.transfer.output.target", String message = Jobs.getLanguage().getMessage("command.transfer.output.target",
"%oldjobname%", oldjob.getChatColor() + oldjob.getName() + ChatColor.WHITE, "%oldjobname%", oldjob.getChatColor() + oldjob.getName() + ChatColor.WHITE,

View File

@ -36,3 +36,4 @@
/BoostType.class /BoostType.class
/McmmoSkill.class /McmmoSkill.class
/FastPayment.class /FastPayment.class
/TempJobProgression.class

View File

@ -118,9 +118,9 @@ public class JobsPlayer {
* @return the player * @return the player
*/ */
public Player getPlayer() { public Player getPlayer() {
if (this.player != null) if (this.playerUUID != null)
return this.player; this.player = Bukkit.getPlayer(this.playerUUID);
return Bukkit.getPlayer(this.playerUUID); return this.player;
} }
/** /**

View File

@ -1,7 +1,7 @@
name: Jobs name: Jobs
description: Jobs Plugin for the BukkitAPI description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.Jobs main: com.gamingmesh.jobs.Jobs
version: 3.5.6 version: 3.5.7
author: phrstbrn author: phrstbrn
depend: [Vault] depend: [Vault]
softdepend: [CoreProtect, MythicMobs, McMMO] softdepend: [CoreProtect, MythicMobs, McMMO]