[QUESTION] How did they do it?

Discussion in 'Plugin Development' started by iCeTeaNL, Feb 20, 2014.

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

    iCeTeaNL

    Hey,

    Do you know how they did that on the playerdeathevent that gold dropping is not going in a stack?

    Show Spoiler
    [​IMG]


    Greets,

    Fabio
     
  2. Offline

    Ironraptor3

    iCeTeaNL just shoot some metadata into it with a for loop

    Example:

    Code:java
    1. Item i = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.GOLD_INGOT));
    2. i.setMetadata(Integer.toString(count), new FixedMetadataValue(Main.plugin, true));
     
    reider45 likes this.
  3. Offline

    Rocoty

    Cool. My plugin is on the forums.
     
    joeygallegos and Europia79 like this.
  4. Offline

    calebbfmv

    Rocoty
    I love that feeling :)
     
    Rocoty likes this.
  5. Offline

    ImDeJay

  6. Offline

    Rocoty

    ImDeJay That's RedstonePVP

    iCeTeaNL Use a repeating task and drop one gold ingot per execution of the task. Couldn't be simpler.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  7. Offline

    calebbfmv

    Rocoty
    Or, to save CPU, use System.currentTimeMills() / 1000 and compare that to a another time and have a while loop. But you know, simplicity.
     
  8. Offline

    Ironraptor3

    Rocoty why would you do it every tick if you want it all at once? And he wanted them not to combine into one stack on the ground when the player died. Therefore you need to use some form of data insertion, and use a simple loop. calebbfmv lol that works too XD
     
  9. Offline

    calebbfmv

  10. Offline

    Ironraptor3

    calebbfmv
    Really? That seems pretty confident. Whatever you say… using a while loop that runs through as MANY times as it can in those milliseconds
     
  11. Offline

    calebbfmv

  12. Offline

    Rocoty

    Ironraptor3 If he wants it just like they have it on RedstonePVP, then a repeating task is what he should use. They don't come all at once on RedstonePVP.

    calebbfmv What are you on about with the while loop? Can you elaborate please? I fail to understand how that would work. A while loop runs all in one tick, meaning if it runs for too long, the server would lag...
     
  13. Offline

    RawCode

    you can just set stackable flag on items...
     
  14. Offline

    Ironraptor3

    Rocoty sorry, I was not familiar with that server. From the pictures, it looked like it was all at once.
    calebbfmv he said what I was going to say. It wouldn't be an infinite loop, but it would go through as many times as it could until the server lagged until it met the milliseconds limit
     
  15. Offline

    calebbfmv

    Ironraptor3
    Don't worry about it, its what I believe to be better than a runnable. Maybe not the while loop without some protection, but is how I do all my stuff.
     
  16. Offline

    Ironraptor3

    calebbfmv
    how is it better? I mean if you seriously want to use time in milliseconds, just run the time check IN a runnable. Runnables can be customized with how long per cycle, delay, and cause a hellofalot less lag, just sayin'
     
  17. Offline

    Rocoty

    And it's easier. Simplicity above all else.
     
  18. Offline

    calebbfmv

    Ironraptor3
    You do understand System.currentTimeMills / 1000 right?
     
  19. Offline

    Garris0n

    If you run it in a while loop it will hang up the server thread until it's done. That's why schedulers exist.
     
  20. Offline

    calebbfmv

  21. Offline

    Garris0n

    Which is why you shouldn't do that...it doesn't make sense. If you did it for long enough the keepalives would expire and the players would disconnect...
     
  22. Offline

    Ironraptor3

    calebbfmv I may be somewhat noobish when it comes to coding (4 months experience so far), but seriously. Don't tell me how while loops work, I know how they do. I use System.currentTimeMillis() in many classes I have in my unreleased plugins as well. I also know how to divide things. However, I still don't understand your reasoning for that loop, because as everyone else is saying, it would crash the server, and its completely pointless.
     
  23. Offline

    Garris0n

    It wouldn't crash the server, it would hang up the server, mess up a ton of stuff related to any plugins trying to do precise timing or tps (NoCheatPlus wouldn't be happy, for example), and if you run it for long enough the keepalive packet sent to the player would expire and they would automatically disconnect.
     
    calebbfmv and Rocoty like this.
  24. Offline

    calebbfmv

    Garris0n
    Holy crap, I did say while loop, didn't I? My bad, did NOT mean to say that. That would crash anything
     
  25. Offline

    Garris0n

    ...what did you mean to say?
     
  26. Offline

    calebbfmv

    Garris0n
    While a runnable with the System millis time, not just a while.....
     
  27. Offline

    maxben34

    Or you could just admit that you were wrong.
     
  28. Offline

    Ironraptor3


    calebbfmv Just read those in order please. Last thing I'm gonna say.
     
  29. Offline

    calebbfmv

    Ironraptor3
    .......... I clearly misspoke. I admit I am wrong.
     
  30. Offline

    Garris0n

Thread Status:
Not open for further replies.

Share This Page