Preventing users from teleporting on top of the nether?
I made you a plugin! (It teleports them to the nether spawn if they go above that height) https://www.mediafire.com/?0cux9xl73ty3f1c Make sure the spawn isn't in any lava, as it does not account for that.
Source code:
public class main extends JavaPlugin implements Listener
{
public static Bukkit plugin;
public void onEnable()
{
Bukkit.getServer().getPluginManager().registerEvents(this, this);
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "Enabled!");
}
public void onDisable()
{
getLogger();
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "Disabled!");
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event)
{
Player p = event.getPlayer();
{
if (event.getPlayer().getLocation().getWorld().getName().endsWith("_nether"))
{
if (event.getPlayer().getLocation().getY() > 127)
{
World nether = Bukkit.getWorld("world_nether");
p.teleport(nether.getSpawnLocation());
}
}
}
}
}
There's a relatively simple command block solution to this, which works in vanilla.
First, set up a scoreboard objective to detect players in the Nether
/scoreboard objectives add onNetherCeiling dummy
Create a clock (I suggest using a fill clock) in your spawnchunks (so that it is always loaded), hidden in a box of Bedrock, and add the following three command blocks, to be run in this order:
/scoreboard players set @a onNetherCeiling 0
/scoreboard players set @a[m=0,y=127,dy=128] onNetherCeiling 1 {Dimension:-1}
/effect @a[score_onNetherCeiling_min=1] 20 1 2 false
The first two commands will assign a score of 1 to every player in survival mode (m=0
), in dimension -1 (the Nether), with a y coordinate between 127 and 255.
The last command will hit the evildoers with 1 second of Wither II. You can do whatever you want here instead, just use @a[score_onNetherCeiling_min=1]
as your target and it works. If you prefer smiting them for their insolence, try
/execute @a[score_onNetherCeiling_min=1] ~ ~ ~ summon LightningBolt ~ ~ ~
There is a slight chance that this won't work with Bukkit/Spigot though, due to the way Bukkit treats the alternate dimensions. Assuming that does not affect NBT data (and I don't see any reason for that), you can place the command blocks on top of the Nether ceiling instead, but you will have to make sure the chunk they are in stays loaded.