Storing ArrayLists

Discussion in 'Plugin Development' started by Boobah, May 16, 2017.

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

    Boobah

    I'm trying to make a poll plugin but I don't know how to store arraylists for the poll name, id, answers, etc.

    Could anyone help? I have no code...
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Boobah config.set(path,list) ?
     
  3. Offline

    Boobah

    still no idea how to do it, i give up
     
  4. Offline

    timtower Administrator Administrator Moderator

    @Boobah Start with this: What are you trying to save? And where are you trying to do that? How long do you need to keep it saved?
     
  5. Offline

    Boobah

    @timtower So the player does /poll create <name> <question> and it saves the id (number of polls), name, and question to an arraylist.
    When a player does /poll list, it should list all the polls' names. When a player does /poll list <name>, it lists the question and answers (set through different command).
    this would be saved until the player does /poll remove <name>
     
  6. Offline

    Zombie_Striker

    @Boobah
    I would recommend doing the following:
    1. Create a hashmap. The keys will be Integers and the values will be the poll name/entry's name(most likely a string). This represents which IDs will be linked to which value.
    2. Create another hashmap, where both the keys and values are Integers. This represents how many votes one entry has.
    3. Create a boolean. This represents if there is a poll currently going on.
    4. When a player votes (I assume through a command), check if the boolean is true, and if so, add +1 to the entry they chose.
    5. When you want to start the poll, set the boolean to true, send the list of all the entries, and then set up a Delayed task that will set the boolean to false after ___ amount of time.
     
Thread Status:
Not open for further replies.

Share This Page