3838import com .plotsquared .core .plot .flag .implementations .PveFlag ;
3939import com .plotsquared .core .plot .flag .implementations .PvpFlag ;
4040import com .plotsquared .core .plot .flag .implementations .TamedAttackFlag ;
41+ import com .plotsquared .core .plot .flag .implementations .VehicleBreakFlag ;
4142import com .plotsquared .core .plot .flag .implementations .VehicleCapFlag ;
4243import com .plotsquared .core .util .EntityUtil ;
44+ import com .plotsquared .core .util .PlotFlagUtil ;
4345import com .plotsquared .core .util .entity .EntityCategories ;
4446import com .sk89q .worldedit .bukkit .BukkitAdapter ;
4547import net .kyori .adventure .text .Component ;
@@ -311,6 +313,51 @@ public static boolean entityDamage(Entity damager, Entity victim, EntityDamageEv
311313 }
312314 } else if (EntityCategories .VEHICLE
313315 .contains (entityType )) { // Vehicles are managed in vehicle destroy event
316+ // Fire damage (e.g. from Fire Aspect swords) needs to be checked here as it bypasses VehicleDestroyEvent
317+ if (cause == EntityDamageEvent .DamageCause .FIRE_TICK ) {
318+ if (isPlot ) {
319+ if (!plot .hasOwner ()) {
320+ if (!plotPlayer .hasPermission (Permission .PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED )) {
321+ plotPlayer .sendMessage (
322+ TranslatableCaption .of ("permission.no_permission_event" ),
323+ TagResolver .resolver (
324+ "node" ,
325+ Tag .inserting (Permission .PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED )
326+ )
327+ );
328+ return false ;
329+ }
330+ return true ;
331+ }
332+ if (plot .getFlag (VehicleBreakFlag .class ) || plot .isAdded (plotPlayer .getUUID ())) {
333+ return true ;
334+ }
335+ if (!plotPlayer .hasPermission (Permission .PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER )) {
336+ plotPlayer .sendMessage (
337+ TranslatableCaption .of ("permission.no_permission_event" ),
338+ TagResolver .resolver (
339+ "node" ,
340+ Tag .inserting (Permission .PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER )
341+ )
342+ );
343+ plot .debug (player .getName () + " could not set vehicle on fire because vehicle-break = false" );
344+ return false ;
345+ }
346+ } else {
347+ // Road
348+ if (!PlotFlagUtil .isAreaRoadFlagsAndFlagEquals (area , VehicleBreakFlag .class , true )
349+ && !plotPlayer .hasPermission (Permission .PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD )) {
350+ plotPlayer .sendMessage (
351+ TranslatableCaption .of ("permission.no_permission_event" ),
352+ TagResolver .resolver (
353+ "node" ,
354+ Tag .inserting (Permission .PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD )
355+ )
356+ );
357+ return false ;
358+ }
359+ }
360+ }
314361 return true ;
315362 } else { // victim is something else
316363 if (isPlot ) {
@@ -372,7 +419,8 @@ public static boolean checkEntity(EntityType type, Plot plot) {
372419
373420 if (EntityCategories .PROJECTILE .contains (entityType ) || EntityCategories .OTHER
374421 .contains (entityType ) || EntityCategories .HANGING .contains (entityType )) {
375- return EntityUtil .checkEntity (plot , EntityCapFlag .ENTITY_CAP_UNLIMITED ,
422+ return EntityUtil .checkEntity (
423+ plot , EntityCapFlag .ENTITY_CAP_UNLIMITED ,
376424 MiscCapFlag .MISC_CAP_UNLIMITED
377425 );
378426 }
@@ -382,20 +430,23 @@ public static boolean checkEntity(EntityType type, Plot plot) {
382430 if (EntityCategories .ANIMAL .contains (entityType ) || EntityCategories .VILLAGER
383431 .contains (entityType ) || EntityCategories .TAMEABLE .contains (entityType )) {
384432 return EntityUtil
385- .checkEntity (plot , EntityCapFlag .ENTITY_CAP_UNLIMITED , MobCapFlag .MOB_CAP_UNLIMITED ,
433+ .checkEntity (
434+ plot , EntityCapFlag .ENTITY_CAP_UNLIMITED , MobCapFlag .MOB_CAP_UNLIMITED ,
386435 AnimalCapFlag .ANIMAL_CAP_UNLIMITED
387436 );
388437 }
389438
390439 if (EntityCategories .HOSTILE .contains (entityType )) {
391440 return EntityUtil
392- .checkEntity (plot , EntityCapFlag .ENTITY_CAP_UNLIMITED , MobCapFlag .MOB_CAP_UNLIMITED ,
441+ .checkEntity (
442+ plot , EntityCapFlag .ENTITY_CAP_UNLIMITED , MobCapFlag .MOB_CAP_UNLIMITED ,
393443 HostileCapFlag .HOSTILE_CAP_UNLIMITED
394444 );
395445 }
396446
397447 if (EntityCategories .VEHICLE .contains (entityType )) {
398- return EntityUtil .checkEntity (plot , EntityCapFlag .ENTITY_CAP_UNLIMITED ,
448+ return EntityUtil .checkEntity (
449+ plot , EntityCapFlag .ENTITY_CAP_UNLIMITED ,
399450 VehicleCapFlag .VEHICLE_CAP_UNLIMITED
400451 );
401452 }
0 commit comments