Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated getPassenger #6370

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ public void onEntityInteract(EntityInteractEvent event) {
*
* @param event - onEntityChangeBlockEvent
*/
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
if (plugin.isError()) {
Expand Down Expand Up @@ -507,8 +506,10 @@ public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
case BOAT, CHEST_BOAT -> {
if (!event.getBlock().getType().equals(Material.LILY_PAD))
return;
Boat boat = (Boat) event.getEntity();
if (boat.getPassenger() != null && boat.getPassenger() instanceof Player player)

final List<Entity> passengers = event.getEntity().getPassengers();

if (!passengers.isEmpty() && passengers.get(0) instanceof Player player)
// Test if the player can break here.
event.setCancelled(!TownyActionEventExecutor.canDestroy(player, event.getBlock()));
else if (!TownyAPI.getInstance().isWilderness(event.getBlock()))
Expand Down