1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-03-12 14:49:37 +01:00

Fix NPE when the jobs player are null during exploring chunks

This commit is contained in:
montlikadani 2020-03-15 14:36:52 +01:00
parent 15f72e6b38
commit f9f745e63a
5 changed files with 16 additions and 26 deletions

View File

@ -387,7 +387,7 @@ public class Jobs extends JavaPlugin {
*/
public static SignUtil getSignUtil() {
if (signManager == null) {
signManager = new SignUtil(getInstance());
signManager = new SignUtil();
}
return signManager;

View File

@ -91,6 +91,10 @@ public class PlayerManager {
return Jobs.getPointsData();
}
public String getMobSpawnerMetadata() {
return mobSpawnerMetadata;
}
public int getMapSize() {
return PlayerUUIDMap.size();
}
@ -1062,8 +1066,4 @@ public class PlayerManager {
}
}, Jobs.getGCManager().AutoJobJoinDelay * 20L);
}
public String getMobSpawnerMetadata() {
return mobSpawnerMetadata;
}
}

View File

@ -28,12 +28,6 @@ public class SignUtil {
private HashMap<String, HashMap<String, jobsSign>> SignsByType = new HashMap<String, HashMap<String, jobsSign>>();
private HashMap<String, jobsSign> SignsByLocation = new HashMap<String, jobsSign>();
private Jobs plugin;
public SignUtil(Jobs plugin) {
this.plugin = plugin;
}
public HashMap<String, HashMap<String, jobsSign>> getSigns() {
return SignsByType;
}
@ -73,7 +67,6 @@ public class SignUtil {
old.put(loc, jSign);
}
// Sign file
public void LoadSigns() {
if (!Jobs.getGCManager().SignsEnabled)
return;
@ -353,7 +346,7 @@ public class SignUtil {
if (directionFacing != null && (block == null || !(block.getState() instanceof Skull)))
loc.add(directionFacing.getOppositeFace().getModX(), 0, directionFacing.getOppositeFace().getModZ());
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Jobs.getInstance(), new Runnable() {
@Override
public void run() {
Block b = loc.getBlock();

View File

@ -1134,8 +1134,8 @@ public class JobsPaymentListener implements Listener {
return;
if (Jobs.getGCManager().MythicMobsEnabled && HookManager.getMythicManager() != null
&& HookManager.getMythicManager().isMythicMob(lVictim)) {
return;
&& HookManager.getMythicManager().isMythicMob(lVictim)) {
return;
}
// mob spawner, no payment or experience
@ -1742,10 +1742,6 @@ public class JobsPaymentListener implements Listener {
&& !Jobs.getGCManager().payExploringWhenGliding && player.isGliding())
return;
ExploreRespond respond = Jobs.getExplore().ChunkRespond(Jobs.getPlayerManager().getJobsPlayer(player).getUserId(), event.getNewChunk());
if (!respond.isNewChunk())
return;
// check if in creative
if (!payIfCreative(player))
return;
@ -1757,6 +1753,10 @@ public class JobsPaymentListener implements Listener {
if (jPlayer == null)
return;
ExploreRespond respond = Jobs.getExplore().ChunkRespond(jPlayer.getUserId(), event.getNewChunk());
if (!respond.isNewChunk())
return;
Jobs.action(jPlayer, new ExploreActionInfo(String.valueOf(respond.getCount()), ActionType.EXPLORE));
}
@ -1771,7 +1771,7 @@ public class JobsPaymentListener implements Listener {
private static boolean payForItemDurabilityLoss(Player p) {
ItemStack hand = Jobs.getNms().getItemInMainHand(p);
if (!Jobs.getGCManager().payItemDurabilityLoss && hand != null && !hand.getType().equals(Material.AIR)
if (!Jobs.getGCManager().payItemDurabilityLoss && !hand.getType().equals(Material.AIR)
&& hand.getType().getMaxDurability() - Jobs.getNms().getDurability(hand) != hand.getType().getMaxDurability()) {
for (String whiteList : Jobs.getGCManager().WhiteListedItems) {
String item = whiteList.contains("=") ? whiteList.split("=")[0] : whiteList;

View File

@ -53,9 +53,7 @@ public class Util {
}
public static World getWorld(String name) {
World w = null;
w = Bukkit.getWorld(name);
World w = Bukkit.getWorld(name);
if (w != null)
return w;
@ -63,9 +61,8 @@ public class Util {
for (World one : Bukkit.getWorlds()) {
String n = one.getName().replace("_", "").replace(".", "").replace("-", "");
if (!n.equalsIgnoreCase(name))
continue;
return one;
if (n.equalsIgnoreCase(name))
return one;
}
return null;