修复了玩家坐椅子时可能会卡在地下的问题
All checks were successful
Java CI-CD with Maven / build (push) Successful in 38m55s

This commit is contained in:
zhangyuheng 2024-04-26 22:35:33 +08:00
parent 75dbefb02a
commit 76f06d4e99
2 changed files with 35 additions and 1 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId>
<artifactId>EssentialsD</artifactId>
<version>1.17.2</version>
<version>1.17.4</version>
<packaging>jar</packaging>
<name>EssentialsD</name>

View File

@ -17,7 +17,9 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.util.Vector;
import org.spigotmc.event.entity.EntityDismountEvent;
public class ChairEvent implements Listener {
@ -104,6 +106,38 @@ public class ChairEvent implements Listener {
event.setUseInteractedBlock(Event.Result.DENY);
}
@EventHandler
public void onPassengerLeave(EntityDismountEvent event) {
if (!EssentialsD.config.getChairEnable()) {
return;
}
Entity vehicle = event.getDismounted();
Entity passenger = event.getEntity();
if (!(vehicle instanceof ArmorStand)) {
return;
}
if (!(passenger instanceof Player)) {
return;
}
vehicle.remove();
passenger.teleportAsync(passenger.getLocation().add(0, EssentialsD.config.getChairSitHeight() * -1, 0));
}
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
if (!EssentialsD.config.getChairEnable()) {
return;
}
Entity vehicle = event.getPlayer().getVehicle();
if (vehicle == null) {
return;
}
if (!(vehicle instanceof ArmorStand)) {
return;
}
event.setTo(event.getTo().add(0, EssentialsD.config.getChairSitHeight() * -1, 0));
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if (!EssentialsD.config.getChairEnable()) {