Here's the code: Code: if (plugin.getServer().getWorld(world).getBlockAt(cx, 0, cz).getType() != Material.REDSTONE_BLOCK) { p.damage(999999.0D); p.isDead(); p.kickPlayer("You Died!"); } kick those who have died...
Wow okay let's fix this. p.damage(999999.0D); - This is honestly the worst way to do this. Besides bad practice this can cause a god mode glitch/bug. Do p.setHealth(0);. Also if you're kicking the player does he really have to be dead anyways? p.isDead(); - This returns a boolean and is useless. Remove it. p.kickPlayer("You Died!"); - This is good.
killing players - р.damage(999999.0D): Code: public class CheckLocation { static int num; static int x = 0; static int cx; static int cz; public static void checkLocation(Plugin plugin) { x = 0; String world = plugin.getConfig().getString("ejection.world"); plugin.getServer().getScheduler().cancelAllTasks(); for (Player p : Bukkit.getOnlinePlayers()) { cx = p.getLocation().getBlockX(); cz = p.getLocation().getBlockZ(); if (plugin.getServer().getWorld(world).getBlockAt(cx, 0, cz).getType() != Material.REDSTONE_BLOCK) { p.damage(999999.0D); p.isDead(); p.kickPlayer("You Died!");
@mortnaix I don't assume that the configs "ejection world" will change between the times this method will run, so you could save it outside of the method. You're asking for all the players online, but getting the block in the ejection world which the player might not be in. Unless you meant for this, I would think you wanted to use World.getPlayers. x is never set to anything besides 0, and never used. Why is it there? Also, you're not checking if that block is null, or if the world is null. There is not one null check in your code. As Jason pointed out, set their health to 0. The player's health could NEVER be over 20F, so why damage them with almost 10 million points of damage. p.isDead is a boolean. That line is useless unless you meant to use it as an If statement. And the close brackets (which I assume is already there)