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 org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
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.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.vehicle.VehicleCollisionEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
public class EnderPearlListener implements Listener {
@ -66,17 +64,19 @@ public class EnderPearlListener implements Listener {
@EventHandler
public void handleProjectileHit(ProjectileHitEvent event) {
Bukkit.broadcastMessage("1");
Entity entity = event.getEntity();
if(entity.getType() != EntityType.ENDER_PEARL)
Projectile projectile = event.getEntity();
if(projectile.getType() != EntityType.ENDER_PEARL)
return;
Bukkit.broadcastMessage("2");
if(!(entity.getPassenger() instanceof Player))
if(!(projectile.getShooter() instanceof Player))
return;
Bukkit.broadcastMessage("3");
Player player = (Player) entity;
Player player = ((Player) projectile.getShooter()).getPlayer();
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()));
}
}