Drop Delay (using Q button) (not with the death event!) [URGENT]

Discussion in 'Archived: Plugin Requests' started by zecheesy, Aug 17, 2012.

  1. Offline

    zecheesy

    Nodus people on my server dropped stacks of crap everywhere.
    So
    I thought of the drop delay!
    1 second between each drop. This includes dragging out of inventory and pressing the Q button.

    Please do not interfere with kill/death event drops or chest drops.

    bypass.dropdelay
    ^ bypasses dropdelay
    (I have PEX and VAULT)

    STUFF I FOUND:
    http://jd.bukkit.org/doxygen/dd/d60..._1event_1_1player_1_1PlayerDropItemEvent.html

    I think you use PlayerDropItemEvent (final Player player, final Item drop)
    then setCancelled (boolean cancel) if drops faster than 1 sec

    I don't know so it would be awesome if you could post the source code too!
     
  2. Offline

    np98765

    You can use NCP in general to limit the amount of drops per second.
     
  3. Offline

    zecheesy

  4. Offline

    JayzaSapphire

    Last edited by a moderator: May 27, 2016
    zecheesy likes this.
  5. Offline

    p000ison

    Hmm in pretty surr this will cause more lag than it prevents, if this is the goal of this plugin.
     
  6. Offline

    Major

    Nice work!

    Two things:
    There's no point in having methods that you aren't using:

    Code:
        public void onDisable() {
     
            }
    Java conventions say you should always use braces. The following confused me at first because I expected the return statement to be below.

    Code:
        if (event.isCancelled() || event.getPlayer().hasPermission("dropdelay.bypass")) return;
    Also, even though it's a small plugin you should probably use separate classes for the listener and the main class.

    Edit: And why does the task have to be asynchronous?

    I don't think that's the aim, but the lag will be negligible anyway.
     
  7. Offline

    JayzaSapphire

    Major
    I like to keep the onDisable method there even if i'm not using it, makes no difference anyways. There is also no need to use seperate classes if you don't want to, it also makes no difference. And that is the only time that i actually don't use braces. And i never said it had to be Asynchronous, i just don't use the main thread.
     
  8. Offline

    Major

    That was what I meant... I was just asking why you do that.
     
  9. Offline

    Deathmarine

  10. Offline

    JayzaSapphire

    Do you mean why do i use a Asynchronous task?
     
  11. Offline

    Major

    Yes.
     
  12. Offline

    JayzaSapphire

    To put the 1 second timer on dropping the item.
     
  13. Offline

    Major

    But why the asynchronous task not synchronous?
     
    Orcem12 likes this.
  14. Offline

    Orcem12

    An asynchronous uses a disgusting amount of process if you use it for events that aren't approved for it. World Generation I believe is one of them, see here. What your going to do as have a task created after every single time a drop is well, dropped. So say 6 people dropped each a stack of CobbleStone (64) that's 384 tasks your plugin just created to begin after every second the server ticks. Synchronous tasks count with the server currently ticking. Therefore the main thread will cover your one second delay.
     
  15. Offline

    Major

    Also, an asynchronous task that is calling methods which are not thread-safe can result in some very horrible issues, such as deadlock (although probably not in this case specifically).
     

Share This Page