Plugin to prevent exploiting "exploding Beds" in the Nether

Discussion in 'Archived: Plugin Requests' started by CubieX, Oct 19, 2012.

  1. Offline

    CubieX

    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?
     
  2. Offline

    Woobie

    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
    1. @EventHandler
    2. public void onInteract(PlayerInteractEvent e){
    3. Player p = e.getPlayer();
    4. if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
    5. if(e.getClickedBlock().equals(Material.BED)){
    6. Block block = e.getClickedBlock();
    7. if(block.getLocation().getWorld() == Bukkit.getWorld("nether")) {
    8. e.setCancelled(true);
    9. }
    10. }
    11. }
    12. }
    13. }
    14.  
    15. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  3. Offline

    Necrodoom

    the bed explodes when you place it, so what you suggest doesnt work.
     
  4. Offline

    Woobie

    Really? I always thought that it explodes only when you sleep in it :D
     
  5. Offline

    lol768 Retired Staff

    If not, blockplaceevent and check the current dimension?
     
  6. Offline

    chakyl

    I think you might be referring to the Aether modification.
     
  7. Offline

    Necrodoom

  8. Offline

    herpingdo

    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
    1. @EventHandler
    2. public void onInteract(PlayerInteractEvent e)
    3. {
    4. Player p = e.getPlayer();
    5. p.sendMessage("You interacted!");
    6. if(e.getAction() == Action.RIGHT_CLICK_BLOCK)
    7. {
    8. p.sendMessage("By right clicking!");
    9. if(e.getClickedBlock().equals(Material.BED_BLOCK) || e.getClickedBlock().equals(Material.BED))
    10. {
    11. p.sendMessage("A bed!");
    12. Block block = (Block) e.getClickedBlock();
    13. if(((org.bukkit.block.Block) block).getLocation().getWorld() == Bukkit.getWorld("nether"))
    14. {
    15. p.sendMessage("In the nether!");
    16. p.sendMessage(ChatColor.YELLOW+"You are not allowed to use a bed in the Nether!");
    17. e.setCancelled(true);
    18. }
    19. else
    20. {
    21. p.sendMessage("In the "+((org.bukkit.block.Block) block).getLocation().getWorld().toString());
    22. }
    23. }
    24. }
    25. }
     
  9. Offline

    Woobie

    How far did you get with the debugging? 1st, or 2nd message?
    Did you register the events?
    Also, try ("world_nether)" instead of ("nether)"
     
  10. Offline

    hakelimopu

    Recommendation:

    A string list of world names found in config.yml, and check for those worlds. Names can vary a lot.
     
  11. Offline

    herpingdo

    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.
     
  12. Offline

    Woobie

    Wait.. Whats the difference between this, and my code? Except unneeded stuff.
     
  13. Offline

    JazzaG

    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!");
    }
    
     
    Garris0n and Woobie like this.
  14. Offline

    Woobie

    Loving the message.
     
  15. Offline

    JazzaG

    Also, why no love for PlayerEnterBedEvent? (I would link the JavaDoc page if I could connect to it)
     
  16. Offline

    Woobie

    Does it count as "entering bed"?:eek:
     
  17. Offline

    JazzaG

    Um, yes?
     
  18. Offline

    seiterseiter1

    Wait how do the beds explode in the nether!
     
  19. If you place a bed in the nether and sleep in it then it's going to act like a ghast and explode it
     
  20. Offline

    herpingdo

    CubieX likes this.
  21. Offline

    CubieX

    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. ;))
     
  22. Offline

    Woobie

  23. Offline

    herpingdo

    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.
     
    Last edited by a moderator: May 29, 2016

Share This Page