mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2024-11-12 10:44:42 +01:00
sponge: Fix NPE in pet owner check.
This commit is contained in:
parent
89e57c17ba
commit
cb69fab753
@ -459,6 +459,7 @@ public boolean protectEntity(Event event, Entity targetEntity, Cause cause, Dama
|
|||||||
}
|
}
|
||||||
if (targetEntity instanceof Living && targetEntity.get(Keys.TAMED_OWNER).isPresent()) {
|
if (targetEntity instanceof Living && targetEntity.get(Keys.TAMED_OWNER).isPresent()) {
|
||||||
final UUID ownerID = targetEntity.get(Keys.TAMED_OWNER).get().orElse(null);
|
final UUID ownerID = targetEntity.get(Keys.TAMED_OWNER).get().orElse(null);
|
||||||
|
if (ownerID != null) {
|
||||||
// always allow owner to interact with their pets
|
// always allow owner to interact with their pets
|
||||||
if (player.getUniqueId().equals(ownerID)) {
|
if (player.getUniqueId().equals(ownerID)) {
|
||||||
return false;
|
return false;
|
||||||
@ -475,6 +476,7 @@ public boolean protectEntity(Event event, Entity targetEntity, Cause cause, Dama
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (GriefDefenderPlugin.isSourceIdBlacklisted(Flags.ENTITY_DAMAGE.getName(), source, targetEntity.getWorld().getProperties())) {
|
if (GriefDefenderPlugin.isSourceIdBlacklisted(Flags.ENTITY_DAMAGE.getName(), source, targetEntity.getWorld().getProperties())) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -701,6 +701,7 @@ public void onPlayerInteractEntity(InteractEntityEvent.Primary event, @First Pla
|
|||||||
}
|
}
|
||||||
if (targetEntity instanceof Living && targetEntity.get(Keys.TAMED_OWNER).isPresent()) {
|
if (targetEntity instanceof Living && targetEntity.get(Keys.TAMED_OWNER).isPresent()) {
|
||||||
final UUID ownerID = targetEntity.get(Keys.TAMED_OWNER).get().orElse(null);
|
final UUID ownerID = targetEntity.get(Keys.TAMED_OWNER).get().orElse(null);
|
||||||
|
if (ownerID != null) {
|
||||||
// always allow owner to interact with their pets
|
// always allow owner to interact with their pets
|
||||||
if (player.getUniqueId().equals(ownerID)) {
|
if (player.getUniqueId().equals(ownerID)) {
|
||||||
GDTimings.PLAYER_INTERACT_ENTITY_PRIMARY_EVENT.stopTimingIfSync();
|
GDTimings.PLAYER_INTERACT_ENTITY_PRIMARY_EVENT.stopTimingIfSync();
|
||||||
@ -718,6 +719,7 @@ public void onPlayerInteractEntity(InteractEntityEvent.Primary event, @First Pla
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Location<World> location = targetEntity.getLocation();
|
Location<World> location = targetEntity.getLocation();
|
||||||
GDClaim claim = this.dataStore.getClaimAt(location);
|
GDClaim claim = this.dataStore.getClaimAt(location);
|
||||||
@ -760,6 +762,7 @@ public void onPlayerInteractEntity(InteractEntityEvent.Secondary event, @First P
|
|||||||
final GDPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
|
final GDPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
|
||||||
if (targetEntity instanceof Living && targetEntity.get(Keys.TAMED_OWNER).isPresent()) {
|
if (targetEntity instanceof Living && targetEntity.get(Keys.TAMED_OWNER).isPresent()) {
|
||||||
final UUID ownerID = targetEntity.get(Keys.TAMED_OWNER).get().orElse(null);
|
final UUID ownerID = targetEntity.get(Keys.TAMED_OWNER).get().orElse(null);
|
||||||
|
if (ownerID != null) {
|
||||||
// always allow owner to interact with their pets
|
// always allow owner to interact with their pets
|
||||||
if (player.getUniqueId().equals(ownerID) || playerData.canIgnoreClaim(claim)) {
|
if (player.getUniqueId().equals(ownerID) || playerData.canIgnoreClaim(claim)) {
|
||||||
if (playerData.petRecipientUniqueId != null) {
|
if (playerData.petRecipientUniqueId != null) {
|
||||||
@ -783,6 +786,7 @@ public void onPlayerInteractEntity(InteractEntityEvent.Secondary event, @First P
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (playerData.canIgnoreClaim(claim)) {
|
if (playerData.canIgnoreClaim(claim)) {
|
||||||
GDTimings.PLAYER_INTERACT_ENTITY_SECONDARY_EVENT.stopTimingIfSync();
|
GDTimings.PLAYER_INTERACT_ENTITY_SECONDARY_EVENT.stopTimingIfSync();
|
||||||
|
Loading…
Reference in New Issue
Block a user