mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2024-11-28 13:15:23 +01:00
Entity-Riding and safe teleports (#126)
* Fixed dismount being blocked * Added safe teleports for flying and entity-riding * Cancel move event on teleport
This commit is contained in:
parent
c1acd88667
commit
27c4b80954
@ -120,6 +120,7 @@ public boolean onEntityMove(MoveEntityEvent event, Location<World> 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<World> 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<World> 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<World> 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<World> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user