Recently I stumbled on a strange kind of griefing. Despite the fact that normal members do not have any build- or use permissions in the nether on our server (blocked via PEX & Modifyworld), one of them used beds in the Nether to systematicly destroy our VIPs structures there. Modifyworld blocks the normal usage of beds if no permission is granted, but this is obviously not sufficient to block triggering the explosion in the Nether. We do not use WorldGuard protections in the Nether (by purpose). So we are looking for a way to prevent players from exploiting this "feature" to harm others. Disabling "TNT explosion" via EssentialsProtect or WorldGuard does unfortunately not prevent beds to explode. Is there a plugin that can achieve this reliably, without using protection zones like WorldGuard does?
Do you want to prevent the player from right clicking the bed, or allow them to actually sleep in the bed? Something like this might work, havent tested it Code:JAVA @EventHandlerpublic void onInteract(PlayerInteractEvent e){ Player p = e.getPlayer(); if(e.getAction() == Action.RIGHT_CLICK_BLOCK){ if(e.getClickedBlock().equals(Material.BED)){ Block block = e.getClickedBlock(); if(block.getLocation().getWorld() == Bukkit.getWorld("nether")) { e.setCancelled(true); } }}}} EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Hmm, I tried the following, and even added some debug code to try and get some output from it, but nothing even happens :/ Code:JAVA @EventHandlerpublic void onInteract(PlayerInteractEvent e){Player p = e.getPlayer();p.sendMessage("You interacted!");if(e.getAction() == Action.RIGHT_CLICK_BLOCK){p.sendMessage("By right clicking!");if(e.getClickedBlock().equals(Material.BED_BLOCK) || e.getClickedBlock().equals(Material.BED)){p.sendMessage("A bed!");Block block = (Block) e.getClickedBlock();if(((org.bukkit.block.Block) block).getLocation().getWorld() == Bukkit.getWorld("nether")){p.sendMessage("In the nether!");p.sendMessage(ChatColor.YELLOW+"You are not allowed to use a bed in the Nether!");e.setCancelled(true);}else{p.sendMessage("In the "+((org.bukkit.block.Block) block).getLocation().getWorld().toString());}}}}
How far did you get with the debugging? 1st, or 2nd message? Did you register the events? Also, try ("world_nether)" instead of ("nether)"
Recommendation: A string list of world names found in config.yml, and check for those worlds. Names can vary a lot.
I tweaked it a little, and I now get to "You interacted!" "By right clicking!". I tried replacing Material.BED with Block.BED, and nothing. I cannot get past the first 2 debug lines.
Wow...this is sounding like the plugin development forum :S Anyway, why check if the name of the world is nether? Code: if(XX.getLocation().getWorld().getEnvironment() == Environment.NETHER) { getServer().broadcastMessage("We are never ever ever getting back together!"); }
Done coding it. You can place beds, but cannot "use" them (So you cannot explode them). Here you go. http://dl.dropbox.com/u/91960215/NoBedExplode.jar
Works. Thanks for that! But could you explain what you actually did? Because I'm curious why you can code this in a couple of minutes/hours(?), while a plugin like Modifyworld (which has a function to block this, according to the docs) does not do the trick. Also: Could you provide your source? I would like to maintain this plugin for our server, if it will ever break. (and I'll have to translate the message. )
Yeah, I used your code and modified it a bit. Making a GitHub repo now. Here you go, https://github.com/herpingdo/NoBedExplode Ignore all the Bukkit files, I accidentally ran the plugin from Eclipse. EDIT by Moderator: merged posts, please use the edit button instead of double posting.