Archiviert
13
0
Dieser Commit ist enthalten in:
Yaruma3341 2020-01-19 19:44:38 +01:00
Ursprung 1ac73810e2
Commit ae45b24364

Datei anzeigen

@ -5,10 +5,7 @@ import de.steamwar.lobby.inventorys.LobbyInventory;
import de.steamwar.lobby.utils.LobbyPlayer; import de.steamwar.lobby.utils.LobbyPlayer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.EnderPearl; import org.bukkit.entity.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -16,6 +13,7 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.vehicle.VehicleCollisionEvent;
import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.event.vehicle.VehicleExitEvent;
public class EnderPearlListener implements Listener { public class EnderPearlListener implements Listener {
@ -66,17 +64,19 @@ public class EnderPearlListener implements Listener {
@EventHandler @EventHandler
public void handleProjectileHit(ProjectileHitEvent event) { public void handleProjectileHit(ProjectileHitEvent event) {
Bukkit.broadcastMessage("1"); Projectile projectile = event.getEntity();
Entity entity = event.getEntity(); if(projectile.getType() != EntityType.ENDER_PEARL)
if(entity.getType() != EntityType.ENDER_PEARL)
return; return;
Bukkit.broadcastMessage("2"); if(!(projectile.getShooter() instanceof Player))
if(!(entity.getPassenger() instanceof Player))
return; return;
Bukkit.broadcastMessage("3"); Player player = ((Player) projectile.getShooter()).getPlayer();
Player player = (Player) entity;
player.teleport(event.getHitBlock().getLocation().add(0.0D, 1.0D, 0.0D)); player.teleport(event.getHitBlock().getLocation().add(0.0D, 1.0D, 0.0D));
} }
@EventHandler
public void handleVehicleCollision(VehicleCollisionEvent event) {
event.getVehicle().getPassenger().teleport(event.getVehicle().getLocation().subtract(event.getVehicle().getVelocity()));
}
} }