Listen for Player attempting to break block in adventure mode

Discussion in 'Plugin Development' started by Codisimus, Aug 3, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Codisimus

    I know that adventure mode was just introduced but I need to know if a Player is trying to break a block while in adventure mode. Basically I want to check if they are still holding down the mouse button after x milliseconds so I can send another arm swing animation. I don't think that this will be possible but maybe someone could confirm it. Thanks a lot!

    Additional Info:
    * I want players to be able to place/break a certain type of Block while in adventure mode
    * I already coded placing the Block without any problems
    * I don't want the block to be broken instantly, they must hack away at it like in survival mode


    EDIT:
    I noticed that the left click action does not trigger a PlayerInteractEvent so this isn't looking too promising...
     
  2. Wouldn't be easier to just use survival mode and restrict some features that would seem like adventure mode but allow what you want instead of simulating block breaking and placement ?
     
  3. Offline

    Codisimus

    Yes of course it would, and that is how I had it before. However, in survival mode you can easily glitch to jump over walls which are normally too high. If that is the only option then I am fine with that but I would rather do it this way. Thanks for the input
     
  4. Offline

    Kaikz

    BlockDamageEvent, then just check the player's gamemode?
     
  5. Offline

    Codisimus

    I noticed that adventure mode prevents the blockdamage and playerinteract event from triggering so that wouldn't work. Looking at the source code it seems that the only way I could do this is if I modify the craftbukkit source myself so it is something like
    Code:
    if (!this.gamemode.isAdventure() || block.getTypeId == 54)
    but that doesn't help if I want to make this public. It looks like I will have to do wut Digi suggested. Too bad, I was excited about adventure mode.
     
  6. You can also prevent the glitches by setting player's velocity to 0 or downwards when player tries to place a block he can't.
    Or you could listen for jumps and record last on-ground position and teleport player back there if he tries to place a block he can't while mid air.
     
  7. Offline

    Codisimus

    Thanks, that's good to know. I guess that was the only reason why I wanted to use adventure mode (besides that it would look better)

    you would be able to place certain blocks but not break them...

    you can do wut Digi was explaining earlier, I can make a simple plugin that does that.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  8. Offline

    darth2499

    If it would prevent players jumping over blocks or fences. That would be nice :)
     
  9. Offline

    Codisimus

    here is a dev build of the plugin. If you wish to help me test it I need to be sure that it is only triggering when the player attempts the glitch. It will print a message in the console when someone tries to do it and also sets their velocity to downward.

    EDIT: hmm... seems to kick the user for hacking if they try to do it.

    EDIT: seems to work great now! (same link) I might make a bukkit dev page for it later
     
  10. Offline

    darth2499

    Works great! Tried on 1.2.5-R5.0 but 1.3.1-R0.1 does not work. But there are still ways to glitch using this plugin. If you need help I can make a video.
     
  11. Offline

    Codisimus

    I actually only tested it on 1.3.1 and it worked fine for me, wut didn't work about it?
     
  12. Offline

    darth2499

    Ill try with the latest Dev release But there are still ways to glitch using this plugin. If you need help I can make a video.

    EDIT

    Ok, works with 1.3.1 but there are glitches for this plugin to jump over fences.
     
  13. Offline

    Codisimus

    a video would be great, Ik of one other way that I was going to attempt to prevent
     
  14. Offline

    darth2499

    ok gimme a couple mins



    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  15. Offline

    Codisimus

    ok, here is an update. Try to glitch over a wall with that.
     
  16. Codisimus
    I had a look at the code just out of curiosity... and I noticed something:
    - Why do you make a new instance of the main class for the listener, why not just use "this" for both arguments when registering the events ?
    - You can set build number in the plugin.yml's version directly.
    - Your enabled message says [ItemDegrader] :p you shouldn't add any enabled messages because Bukkit already does that.
    - You're only checking a few block types, you should remove the check just for testing, expecially since the player in the video used ore.
     
  17. Offline

    darth2499

    Fixed jumping over fence but not from the side.
     
  18. Offline

    Codisimus

    Good point, I use to have it as two separate classes but decided to merge them.
    I went the build number to increment automatically and I am not sure how to modify a .yml from the build.xml, so I used .properties instead because I am more familiar with it.
    I fixed the message to say the right plugin name (I copied/pasted and missed changing that). Bukkit does not add an enabled message, the only add an enabling message. I like to post that the plugin is enabled because if there are errors I sometimes disable the plugin on startup.
    The blocks I am checking for are fence blocks, I want to see if they are standing next to a fence (a block that is 1.5 blocks in height yet doesn't take up the whole width of the block. I don't bother checking which kind of block they place.

    not sure what you mean by from the side. All the testing I did kept me from getting over the fence. perhaps another video would help.
     
  19. It's still pointless info, you don't need to know if it's enabled, you need to assume it did if no errors/warnings/etc appear.
    Do you own a server, do you know the feeling when your console is spitting message after message for each plugin ? It's ugly to show more than 1 line if it's unrequired :}
     
  20. Offline

    Codisimus

    it makes it easier for me to help admins who use my plugin. Besides, bukkit does tell the build number when enabling. Will it if I move that to the plugin.yml?
     
  21. Offline

    Truckermouse

    I was bored so I figured out a way to get over the fence while having your plugin installed, here's a video:

     
  22. Offline

    Codisimus

    wut build is this? was the message posted?
     
  23. Offline

    Truckermouse

    Yes the message was posted. Build 1.2.5 R4.

    But I found a way to do it without triggering your plugins message
     
  24. Offline

    Codisimus

    try this and let me know if you can still get over without triggering the message.
     
  25. Offline

    Truckermouse

    This version was a lot better! It fixed the way I did it. Although it was still possible to get over the fence, it was impossible to do it without triggering the message
    But again, I found a way to do it without triggering it. This time with serverconsole :D. That way only works (obviously) on 1 1/2 high blocks.
    Video:
     
  26. Offline

    Codisimus

    Not sure I will be able to make it any better... right now I am looking into modifying the craftbukkit source to allow breaking certain blocks in adventure mode
     
  27. Offline

    darth2499

    That would be nice :). Fixes all the problems.
     
  28. Offline

    Codisimus

    except that I would not be able to distribute it, you would have to make the modifications yourself and compile your new craftbukkit jar
     
  29. Offline

    darth2499

    as long as users connecting to the server doesnt need to install anything, that would be fine
     
  30. Offline

    Codisimus

    do you know how to download the craftbukkit source, modify it, and then compile it using maven?
     
Thread Status:
Not open for further replies.

Share This Page