Skip to content

Commit

Permalink
Null check after calling LivingEntity.getTargetBlockExact()
Browse files Browse the repository at this point in the history
  • Loading branch information
Deltik committed Nov 17, 2020
1 parent a956c74 commit 089c23b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v1.12.6 (2020-11-17)

### Fixed

* Regression from version `= 1.12.5` caused `Uncaught error: java.lang.NullPointerException` when trying to target air

## v1.12.5 (2020-11-17)

### Changed
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def name = 'SignEdit'
version '1.12.5'
version '1.12.6'

/*
* Copyright (C) 2017-2020 Deltik <https://www.deltik.org/>
Expand Down
5 changes: 4 additions & 1 deletion src/org/deltik/mc/signedit/commands/SignCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.deltik.mc.signedit.listeners.SignEditListener;
import org.deltik.mc.signedit.subcommands.SignSubcommand;
import org.deltik.mc.signedit.subcommands.SignSubcommandInjector;
import org.jetbrains.annotations.Nullable;

import javax.inject.Inject;
import javax.inject.Provider;
Expand Down Expand Up @@ -123,7 +124,8 @@ private void autointeract(Player player, SignEditInteraction interaction, ChatCo
if (interaction == null) return;

Block targetBlock = getTargetBlockOfPlayer(player);
BlockState targetBlockState = targetBlock.getState();
BlockState targetBlockState = null;
if (targetBlock != null) targetBlockState = targetBlock.getState();
if (shouldDoClickingMode(targetBlock)) {
listener.setPendingInteraction(player, interaction);
comms.tellPlayer(comms.t("right_click_sign_to_apply_action"));
Expand All @@ -134,6 +136,7 @@ private void autointeract(Player player, SignEditInteraction interaction, ChatCo
}
}

@Nullable
public static Block getTargetBlockOfPlayer(Player player) {
try {
Method method = Player.class.getMethod("getTargetBlockExact", int.class);
Expand Down

0 comments on commit 089c23b

Please sign in to comment.