I want to make a Spigot Plugin that kills a Player if he is over 24 Blocks. I already made a code but it doesn't work Here is the full code, I don't need to register a new class because I wrote the event in the main class
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class MainFFA extends JavaPlugin implements Listener{
@Override
public void onEnable() {
getServer().getConsoleSender().sendMessage("_____________START_____________");
getServer().getConsoleSender().sendMessage("_____________START_____________");
getServer().getConsoleSender().sendMessage("_____________START_____________");
getServer().getConsoleSender().sendMessage("_____________START_____________");
super.onEnable();
}
@Override
public void onDisable() {
getServer().getConsoleSender().sendMessage("_________STOP_________-");
super.onDisable();
}
@EventHandler
public void onPlayerDead(PlayerMoveEvent event) {
Player p = event.getPlayer();
if(p.getLocation().getBlockY() > 80) {
p.setHealth(0);
}
else {
p.sendMessage("Wenn du das siehst dann bist du unter 80 blöcken hoch");
}
}
}
To solve this issue, you must remember to register your listeners, or else bukkit will never see them.
Add that line to the
onEnable
method, and you should be fine