Skip to content

Commit e6a8d1f

Browse files
committed
Test task dismount behavior
1 parent f4d5e5b commit e6a8d1f

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

core/src/main/java/dev/geco/gsit/event/PlayerEventHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.bukkit.event.EventPriority;
1212
import org.bukkit.event.Listener;
1313
import org.bukkit.event.entity.EntityDamageEvent;
14+
import org.bukkit.event.entity.PlayerDeathEvent;
1415
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
1516
import org.bukkit.event.player.PlayerJoinEvent;
1617
import org.bukkit.event.player.PlayerQuitEvent;
@@ -46,6 +47,9 @@ public void playerQuitEvent(PlayerQuitEvent event) {
4647
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
4748
public void playerTeleportEvent(PlayerTeleportEvent event) { stopActions(event.getPlayer(), GStopReason.TELEPORT, false); }
4849

50+
@EventHandler(priority = EventPriority.LOWEST)
51+
public void playerDeathEvent(PlayerDeathEvent event) { stopActions(event.getPlayer(), GStopReason.DEATH, false); }
52+
4953
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
5054
public void entityDamageEvent(EntityDamageEvent event) {
5155
Entity entity = event.getEntity();

core/src/main/java/dev/geco/gsit/service/SitService.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,16 @@ public void handleSafeSeatDismount(GSeat seat) {
147147
Location upLocation = seat.getLocation().add(0d, baseOffset + (Tag.STAIRS.isTagged(blockType) ? STAIR_Y_OFFSET : 0d) - gSitMain.getConfigService().S_SITMATERIALS.getOrDefault(blockType, 0d), 0d);
148148

149149
Location returnLocation = gSitMain.getConfigService().GET_UP_RETURN ? seat.getReturnLocation() : upLocation;
150-
Location entityLocation = entity.getLocation();
151150

152-
returnLocation.setYaw(entityLocation.getYaw());
153-
returnLocation.setPitch(entityLocation.getPitch());
151+
gSitMain.getTaskService().runDelayed(() -> {
152+
Location entityLocation = entity.getLocation();
154153

155-
if(seat.getSeatEntity().isValid()) gSitMain.getEntityUtil().setEntityLocation(seat.getSeatEntity(), returnLocation);
156-
if(entity.isValid()) gSitMain.getEntityUtil().setEntityLocation(entity, returnLocation);
154+
returnLocation.setYaw(entityLocation.getYaw());
155+
returnLocation.setPitch(entityLocation.getPitch());
156+
157+
if(seat.getSeatEntity().isValid()) gSitMain.getEntityUtil().setEntityLocation(seat.getSeatEntity(), returnLocation);
158+
if(entity.isValid()) gSitMain.getEntityUtil().setEntityLocation(entity, returnLocation);
159+
}, 0);
157160
}
158161

159162
public GSeat createStairSeatForEntity(Block block, LivingEntity entity) {

0 commit comments

Comments
 (0)