moved Deathmessage to own class
All checks were successful
Gitea Actions Demo / Build-Gradle (push) Successful in 4m52s
All checks were successful
Gitea Actions Demo / Build-Gradle (push) Successful in 4m52s
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
//GPT'd
|
||||
package de.hessj.environmentex;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class DeathLoc implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity();
|
||||
Location deathLoc = player.getLocation();
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
player.spigot().respawn();
|
||||
|
||||
String coords = String.format("Todeskoordinaten: %d %d %d",
|
||||
deathLoc.getBlockX(),
|
||||
deathLoc.getBlockY(),
|
||||
deathLoc.getBlockZ());
|
||||
|
||||
player.sendMessage(coords);
|
||||
}
|
||||
}.runTaskLater(App.main, 1L);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user