How to wait event ?

Discussion in 'Plugin Development' started by ralmn, Nov 15, 2011.

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

    ralmn

    Hello, I would like know how to for wait à player placed block after command ?
    Sorry for my english, I am french.

    French :
    Je voudrais savoir comment le plugin attende l'evenement block place après une commande
     
  2. Offline

    md_5

  3. Offline

    ralmn

    I want to know that after a player has put a block continues what to do
     
  4. Offline

    ItsHarry

    Put the code that you want to be executed when a user places a block in the listener
     
  5. Offline

    halley

    (1) In your plugin, keep a Set<String> called ready. Each String is a player name. A player is included in the set when the plugin is between the "command entered" and "block placed" conditions.

    (2) In your CommandExecutor method onCommand(), you mark the player as ready with ready.add(player.getName()).

    (3) In your BlockListener method onBlockPlace(), you see if the player is ready with ready.contains(player.getName()). If the player is in the set, then you can do your magic code here.

    (4) Also, when the effect wears off, you can remove the player from the set with ready.remove(player.getName()). This might be right after #3.

    If the effect should last for six blocks instead of one block, use a Map<String, Integer> instead. The Integer is a counter for how many more blocks are allowed, starting with 6 and counting down. Remove the player when it reaches zero.

    If the effect should last for ten minutes instead of one block, use a Map<String, Long> instead. The Long is a timestamp (System.getCurrentTimeMillis() + 10*60*1000) for when the effect expires. Remove the player when the current time is past the expiration time.

    Ma francais c'est tres mal; pardonnez moi pour le Anglais.
     
    rakiru likes this.
  6. Offline

    ralmn

    I would like if 3 block is place je command continue
     
  7.  
  8. Offline

    ralmn

    I don't understand
     
  9. http://download.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html
    You simply use the key for the player name and the value for a block counter. You put an entry into the map when the command executes, then, every time a block is placed, you count the value till you have it to your needs and if it's there you execute your code and remove the entry from the map.
     
  10. Offline

    ralmn

    I have my code of my command in a loop for() and the command continue ....
     
  11. Offline

    halley

    Your command in a for loop? Why?

    *sigh* Try to make it simple, and someone simpler comes along.
     
  12. Offline

    ralmn

    I create a plugins for a french game "Dé a coudre" and the players plays one has one
     
  13. Offline

    Taco

    I can't say I see any need for a for loop there.
     
  14. Offline

    ralmn

    I read the player name who a arraylist
     
  15. Offline

    Daniel Heppner

    I nominate you a moderator.
     
    rakiru likes this.
  16. Offline

    ralmn

    No help ?
     
  17. Offline

    Sleaker

    @ralmn - looks like people have tried, it's either an issue of language barrier or you simply don't understand java very well, (possibly both). It's nothing against you, but it seems like this may be something that is too difficult to accomplish.
     
  18. Offline

    ralmn

    [​IMG]

    The player name is in ArrayList

    I dont know if help you ?
     
Thread Status:
Not open for further replies.

Share This Page