Don't repeat command.

Discussion in 'Plugin Development' started by ProMCKingz, Dec 11, 2014.

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

    ProMCKingz

    Hey, I wanted to know how to make some way in order to stop the user from repeating the command "/pigquest join" when the player has already done it before. Of course I will then need a way to then re enable it when a player does "/pigquest leave" or at the end of the mingame.
    Thanks,
    ProMCKingz
     
  2. Offline

    leon3001

    @ProMCKingz Add them, or preferably their UUID, to a Set and check if they are in there when they are doing the command again.
     
  3. Offline

    ProMCKingz

    @leon3001
    Any other way, than trying to check for the area?
     
  4. Offline

    leon3001

    Area …? Not sure if that's slang or something but you don't check for the area. Of course, you could save their UUID in any other kind of collection. But you will have to save them somewhere. :)
     
  5. Offline

    ProMCKingz

    @leon3001
    So how do I store them? E.g for spawns you store them like this:
    Code:
    settings.getData().set("lobbyZ", p.getLocation().getZ());
                            settings.saveData();
    How would I store this?
    settings is my settingsmanager class instance
     
  6. Offline

    Skionz

    @ProMCKingz Use a Map or some way to store data. There are plenty of options.
     
  7. Offline

    ProMCKingz

    @Skionz
    Is it not possible with files?
     
  8. Offline

    leon3001

    @ProMCKingz Do you have basic Java knowledge? Or only Bukkit experiences?
     
  9. Offline

    Skionz

    @ProMCKingz
     
    leon3001 likes this.
  10. Offline

    mythbusterma

    @ProMCKingz

    Yes, there is a way. Why does that make any sense at all? Judging by the command you mentioned, the Players would be in some sort of arena, which (at least, it seems to me) is something that wouldn't be preserved between server updates. So there is absolutely no reason to waste time saving it to a file.
     
  11. Offline

    stoneminer02

    you only need 1 arraylist for it all.
    1. if check to check if in the list.
    2. If true, deny access, else accept him and add him to the ArrayList(I would do ArrayList<Player> if its all on the same server.
    3. You can use a Map<Player, Integer> for several servers.
     
Thread Status:
Not open for further replies.

Share This Page