How would I do this?

Discussion in 'Plugin Development' started by DominicGamesHD, Jun 5, 2016.

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


    I want to make it so when I do different combination on the mouse (Example: Left - Right -Left) it will do different things.
    NOTE: An example piece of code helps me learn
  2. Offline


    But we don't spoonfeed here, sorry :D

    Use a PlayerInteractEvent to get if the player left or right clicked and then save it I think it was called a round robin database/array which only saves the last for example three entries and pushes the others back when adding another one and then you just need to check if the array for a specific player contains a left a right and another left value and then execute you code.
    Oh and maybe clear the last element if its more than ~5 seconds old..
  3. Offline


    You call it spoonfeeding but I find its the best way for me to learn but I guess its worth ago
  4. Offline


    Well we just don't spoonfeed because a lot of people coming here knowing nothing or only a really tiny bit about programming, some think they can make Bukkit plugins just because they know Java...
    And in your case, I don't want to spend 1+ hours making and of course testing this because for this to work you need to write a whole event listener writing the results into a round robin kind of array for every player and then another task for checking this array and because I don't really like hacking something together, I would probably spend at least 1 more hour cleaning it up, making it compatible with an unlimited amount of codes and so on..
  5. Offline


    As @Kage0x3B said, no one here will spoonfeed you code. You can read why Here and Here.

    Here is how you would create what you want:
    1. Create an object to hold the past three actions a player has done.
    2. Inside the main class, create a map that stores each player value as a Key, and the object above as the value. This means that every player has their own "action store".
    3. Every time a player leftclicks/rightclicks, add the action to their action store.
    4. Check if the past three actions match a mouse combination you're looking for.
    5. If so, do stuff. After that, clear the action store.
    Last edited: Jun 5, 2016
  6. Offline


    Zombie_Striker likes this.
Thread Status:
Not open for further replies.

Share This Page