mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-27 05:28:25 +01:00
fixed NPE when interacting with NPC's
This commit is contained in:
parent
15cb4d7aa2
commit
a9809dbccb
@ -883,6 +883,22 @@ public class PlayerData extends OfflinePlayerData {
|
||||
return MMOCore.plugin.dataProvider.getDataManager().get(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used to check if the player data is loaded for a
|
||||
* specific player. This might seem redundant because the given
|
||||
* Player instance is linked to an online player, and data
|
||||
* is always loaded for an online player.
|
||||
* <p>
|
||||
* In fact a Player instance can be attached to a Citizens NPC
|
||||
* which has no player data loaded hence this method
|
||||
*
|
||||
* @param player Either a real player or an NPC
|
||||
* @return If player data for that player is loaded
|
||||
*/
|
||||
public static boolean has(Player player) {
|
||||
return MMOCore.plugin.dataProvider.getDataManager().isLoaded(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static Collection<PlayerData> getAll() {
|
||||
return MMOCore.plugin.dataProvider.getDataManager().getLoaded();
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class MMOCoreTargetRestriction implements TargetRestriction {
|
||||
@Override
|
||||
public boolean canTarget(Player player, LivingEntity target, InteractionType interaction) {
|
||||
|
||||
if (interaction.isOffense() && target instanceof Player) {
|
||||
if (interaction.isOffense() && target instanceof Player && PlayerData.has((Player) target)) {
|
||||
PlayerData targetData = PlayerData.get(target.getUniqueId());
|
||||
|
||||
// Check for the same party
|
||||
|
Loading…
Reference in New Issue
Block a user