NPE fix for combat on unloaded profiles

This commit is contained in:
nossr50 2020-01-14 19:44:17 -08:00
parent 41bdca948a
commit 24b3bf1100
5 changed files with 27 additions and 8 deletions

View File

@ -1,6 +1,8 @@
Version 2.1.112
Correct locale usage for enum access, now enforces using the english locale to prevent issues with oddball locales for configs/commands
Don't cache names in mob health updater task, also; Don't schedule if the entity is already dead
Fixed a NPE that can occur if a player engages in combat with specific skills before their profile is loaded
mcMMO is now more compatible with certain mob stacking plugins
Improved behaviour for mob health bars
Version 2.1.111
mcMMO is compatible with the following versions of MC: 1.15 / 1.14.4 / 1.14.3 / 1.14.2 / 1.14.1 / 1.14 / 1.13.2

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.WorldBlacklist;
@ -44,7 +43,6 @@ import org.bukkit.metadata.MetadataValue;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class BlockListener implements Listener {
private final mcMMO plugin;

View File

@ -7,8 +7,6 @@ import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.EntityType;
import java.util.Locale;
public class StringUtils {
/**

View File

@ -39,8 +39,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
public final class CombatUtils {
private CombatUtils() {}
@ -50,6 +48,12 @@ public final class CombatUtils {
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Make sure the profiles been loaded
if(mcMMOPlayer == null) {
return;
}
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
double initialDamage = event.getDamage();
double finalDamage = initialDamage;
@ -96,6 +100,12 @@ public final class CombatUtils {
Map<DamageModifier, Double> modifiers = getModifiers(event);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Make sure the profiles been loaded
if(mcMMOPlayer == null) {
return;
}
AxesManager axesManager = mcMMOPlayer.getAxesManager();
if (axesManager.canActivateAbility()) {
@ -139,6 +149,12 @@ public final class CombatUtils {
double finalDamage = initialDamage;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Make sure the profiles been loaded
if(mcMMOPlayer == null) {
return;
}
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
if (unarmedManager.canActivateAbility()) {
@ -209,6 +225,12 @@ public final class CombatUtils {
double initialDamage = event.getDamage();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//Make sure the profiles been loaded
if(mcMMOPlayer == null) {
return;
}
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
double finalDamage = event.getDamage();

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.worldguard;
import com.gmail.nossr50.mcMMO;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldguard.WorldGuard;