Skip to content

Commit

Permalink
Merge pull request BetonQuest#3077 from Wolf2323/chestput
Browse files Browse the repository at this point in the history
`chestput` objective caused that no chest could be opened on the server
  • Loading branch information
TheosRee authored Dec 18, 2024
2 parents b7628fe + cc88686 commit 05da80f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Fixed
- fixed NPC navigation by giving better error messages and handling the stuck action correctly
- custom sounds from resourcepacks could not be used in conversation start and end sound
- `chestput` objective caused that no chest could be opened on the server when `multipleaccess` was forbidden(default)
### Security

## [2.2.0] - 2024-12-01
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,17 @@ public ChestPutObjective(final Instruction instruction) throws InstructionParseE
*/
@EventHandler
public void onChestOpen(final InventoryOpenEvent event) {
final OnlineProfile onlineProfile = PlayerConverter.getID((Player) event.getPlayer());
try {
if (!checkIsInventory(loc.getValue(onlineProfile))) {
return;
}
} catch (final QuestRuntimeException e) {
log.warn(instruction.getPackage(), "Error while handling '" + instruction.getID() + "' objective: " + e.getMessage(), e);
}
if (!multipleAccess && !checkForNoOtherPlayer(event)) {
try {
Config.sendNotify(null, PlayerConverter.getID((Player) event.getPlayer()), "chest_occupied", null);
Config.sendNotify(null, onlineProfile, "chest_occupied", null);
} catch (final QuestRuntimeException e) {
log.warn("The notify system was unable to send the message for 'chest_occupied'. Error was: '"
+ e.getMessage() + "'", e);
Expand Down Expand Up @@ -113,7 +121,7 @@ public void onChestClose(final InventoryCloseEvent event) {
}
try {
final Location targetLocation = loc.getValue(onlineProfile);
if (isNotInventory(targetLocation)) {
if (!checkIsInventory(targetLocation)) {
return;
}

Expand Down Expand Up @@ -148,7 +156,7 @@ private void checkItems(final OnlineProfile onlineProfile) throws QuestRuntimeEx
}
}

private boolean isNotInventory(final Location targetChestLocation) {
private boolean checkIsInventory(final Location targetChestLocation) {
final Block block = targetChestLocation.getBlock();
if (!(block.getState() instanceof InventoryHolder)) {
final World world = targetChestLocation.getWorld();
Expand All @@ -159,9 +167,9 @@ private boolean isNotInventory(final Location targetChestLocation) {
targetChestLocation.getBlockY(),
targetChestLocation.getBlockZ(),
world == null ? "null" : world.getName()));
return true;
return false;
}
return false;
return true;
}

@Override
Expand Down

0 comments on commit 05da80f

Please sign in to comment.