Skip to content

Commit

Permalink
kick allay from vehicle on item pickup or drop
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Aug 14, 2024
1 parent a1357a5 commit 7d01642
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDropItemEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;

public class AllayDupe extends AEFModule implements Listener {
Expand Down Expand Up @@ -38,4 +40,24 @@ private void onVehicleEnter(VehicleEnterEvent event) {
event.setCancelled(true);
}
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onEntityPickupItem(EntityPickupItemEvent event) {
if (event.getEntityType() != XEntityType.ALLAY.get()) return;

if (event.getEntity().isInsideVehicle()) {
event.setCancelled(true);
event.getEntity().leaveVehicle();
}
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onEntityDropItem(EntityDropItemEvent event) {
if (event.getEntityType() != XEntityType.ALLAY.get()) return;

if (event.getEntity().isInsideVehicle()) {
event.setCancelled(true);
event.getEntity().leaveVehicle();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;

public class AllayDupe extends AEFModule implements Listener {
Expand Down Expand Up @@ -38,4 +39,15 @@ private void onVehicleEnter(VehicleEnterEvent event) {
event.setCancelled(true);
}
}


@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onEntityPickupItem(EntityPickupItemEvent event) {
if (event.getEntityType() != XEntityType.ALLAY.get()) return;

if (event.getEntity().isInsideVehicle()) {
event.setCancelled(true);
event.getEntity().leaveVehicle();
}
}
}

0 comments on commit 7d01642

Please sign in to comment.