public
Created

The TeleportListener class from the Telejecter project.

  • Download Gist
TeleportListener.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
package com.me.rmsy.telejecter;
 
import org.bukkit.Location;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
 
public class TeleportListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerTeleport(PlayerTeleportEvent event) {
Player player = event.getPlayer();
if(player.isInsideVehicle()){
Location xyz = event.getTo();
event.setCancelled(true);
player.eject();
player.teleport(xyz);
}
}
}

java public void playerTeleport(PlayerTeleportEvent event) {
shouldn't be
java public void onPlayerTeleport(PlayerTeleportEvent event) {

@SuperSpyTX Thanks, broskies :beer:

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.