diff --git a/sponge/src/main/java/com/griefdefender/listener/CommonEntityEventHandler.java b/sponge/src/main/java/com/griefdefender/listener/CommonEntityEventHandler.java index e708592..47ae8da 100644 --- a/sponge/src/main/java/com/griefdefender/listener/CommonEntityEventHandler.java +++ b/sponge/src/main/java/com/griefdefender/listener/CommonEntityEventHandler.java @@ -120,6 +120,7 @@ public boolean onEntityMove(MoveEntityEvent event, Location fromLocation, GDTimings.ENTITY_MOVE_EVENT.startTimingIfSync(); Player player = null; GDPermissionUser user = null; + boolean onMount = false; if (targetEntity instanceof Player) { player = (Player) targetEntity; user = PermissionHolderCache.getInstance().getOrCreateUser(player); @@ -128,6 +129,7 @@ public boolean onEntityMove(MoveEntityEvent event, Location fromLocation, if (controller != null && controller instanceof Player) { player = (Player) controller; user = PermissionHolderCache.getInstance().getOrCreateUser(player); + onMount = true; } else { user = PermissionHolderCache.getInstance().getOrCreateUser(targetEntity.getCreator().orElse(null)); } @@ -328,6 +330,21 @@ public boolean onEntityMove(MoveEntityEvent event, Location fromLocation, } if (player != null) { + if (GDFlags.ENTITY_RIDING && onMount) { + if (GDPermissionManager.getInstance().getFinalPermission(event, targetEntity.getLocation(), toClaim, Flags.ENTITY_RIDING, player, targetEntity, player, TrustTypes.ACCESSOR, true) == Tristate.FALSE) { + event.setCancelled(true); + Location safeLocation = Sponge.getGame().getTeleportHelper() + .getSafeLocation(fromLocation, 80, 0) + .orElseGet(() -> Sponge.getGame().getTeleportHelper() + .getSafeLocation(fromLocation, 80, 6) + .orElse(world.getSpawnLocation()) + ); + targetEntity.getBaseVehicle().clearPassengers(); + player.setTransform(player.getTransform().setLocation(safeLocation)); + GDTimings.ENTITY_MOVE_EVENT.stopTimingIfSync(); + return false; + } + } final GDPlayerData playerData = user.getInternalPlayerData(); final boolean showGpPrefix = GriefDefenderPlugin.getGlobalConfig().getConfig().message.enterExitShowGdPrefix; playerData.lastClaim = new WeakReference<>(toClaim); @@ -482,6 +499,13 @@ private void checkPlayerFlight(GDPermissionUser user, GDClaim fromClaim, GDClaim player.offer(Keys.CAN_FLY, false); player.offer(Keys.IS_FLYING, false); playerData.ignoreFallDamage = true; + Location safeLocation = Sponge.getGame().getTeleportHelper() + .getSafeLocation(player.getLocation(), 80, 0) + .orElseGet(() -> Sponge.getGame().getTeleportHelper() + .getSafeLocation(player.getLocation(), 80, 6) + .orElse(player.getWorld().getSpawnLocation()) + ); + player.setTransform(player.getTransform().setLocation(safeLocation)); GriefDefenderPlugin.sendMessage(player, MessageCache.getInstance().OPTION_APPLY_PLAYER_DENY_FLIGHT); } } @@ -615,4 +639,4 @@ public void sendInteractEntityDenyMessage(ItemStack playerItem, Entity entity, G GriefDefenderPlugin.sendClaimDenyMessage(claim, player, message); } } -} \ No newline at end of file +} diff --git a/sponge/src/main/java/com/griefdefender/listener/EntityEventHandler.java b/sponge/src/main/java/com/griefdefender/listener/EntityEventHandler.java index f6d5201..ff04368 100644 --- a/sponge/src/main/java/com/griefdefender/listener/EntityEventHandler.java +++ b/sponge/src/main/java/com/griefdefender/listener/EntityEventHandler.java @@ -919,7 +919,7 @@ public void onProjectileImpactEntity(CollideEntityEvent.Impact event) { } @Listener(order = Order.FIRST, beforeModifications = true) - public void onEntityMount(RideEntityEvent event) { + public void onEntityMount(RideEntityEvent.Mount event) { if (!GDFlags.ENTITY_RIDING) { return; }