Skip to content

Commit

Permalink
Rewrite place listener
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerS1066 committed Jun 1, 2024
1 parent 6a3073a commit e546510
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,16 @@ public void onBlockPlace(BlockPlaceEvent e) {
if (!Settings.ProtectPilotedCrafts)
return;

Player p = e.getPlayer();

MovecraftLocation placedLocation = MathUtils.bukkit2MovecraftLoc(e.getBlockAgainst().getLocation());
for (Craft craft : CraftManager.getInstance().getCraftsInWorld(e.getBlock().getWorld())) {
if (craft == null || craft.getDisabled())
continue;
MovecraftLocation loc = MathUtils.bukkit2MovecraftLoc(e.getBlockAgainst().getLocation());
Craft craft = MathUtils.fastNearestCraftToLoc(CraftManager.getInstance().getCrafts(), e.getBlockAgainst().getLocation());
if (craft == null || !craft.getHitBox().contains(loc) || craft.getDisabled() || !(craft instanceof PilotedCraft))
return;

if(!(craft instanceof PilotedCraft)) {
continue;
}
if (((PilotedCraft) craft).getPilot() == p) {
continue;
}
Player p = e.getPlayer();
if (((PilotedCraft) craft).getPilot() == p)
return;

if (craft.getHitBox().contains(placedLocation)) {
e.setCancelled(true);
return;
}
}
e.setCancelled(true);
}

// prevent items from dropping from moving crafts
Expand Down

0 comments on commit e546510

Please sign in to comment.