Preventing users from teleporting on top of the nether?

I have users repeatedly using ender pearls to get on the roof of the nether (128 blocks+) and build up there. I want to avoid this. Currently, the only way I could think of is blacklisting ender pearls in the nether, but if possible, I want to keep the pearls and prevent it otherwise.

What I have checked already:

  • Full-height nether: I could not find a generator that would do that.
  • Worldguard regions: I was not able to create a really large region, nevermind and endless one. I could do this only for a certain area (around the nether spawn), but I would prefer to have a solution that covers the whole nether
  • Worldborder: I submitted a feature request for Worldborder since it currently only supports x/z coordinates, not y.
  • Plugins: I could not find any plugins that are half way up to date doing this.

Any other ideas? Running latest version of Spigot.


Solution 1:

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());  
                }
            }
        }
    }
}

Solution 2:

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.