Getting informations from chat

Discussion in 'Spigot Plugin Development' started by eaglez, Oct 12, 2019.

  1. Hello,
    I'm making a plugin and i want to know what is the best way to get informations from chat from a specific player
    Like i want to ask a player multiple questions and store those questions, but i don't know what is the most efficient way to do it like without making 20 lists or maps x)

    Thank you;
  2. You don't have to make 20 list, you can just make one and store every question in it. Check if its the player, then log it into an list, then clear the list when you're no longer using it for the next player.
  3. i don't get it ...
    Like let's say i have a CreatorManager class & a listener class
    in the CreatorManager class i have a list

    and i won't to store like 8 questions ...
  4. I also don't get what you said.

    -> if the chatsender is in "question" -> add message to one list -> when the "questioning" is done clear the list
  5. so i have a create(Player) method it will add player's uuid to a list
    then i will check if player is in the list (async chat event) if so add the value to another list
    the only thing is i have multiple questions so i need multiple lists
  6. Map the player uuid to a list of strings which contains their answers
  7. I would create a class called Question with 2 fields, one with the question and one with the answer. Then create a class called Quiz or something that holds a List of Questions and store everything for each player in a map like Map<UUID,Quiz> or Map<UUID,List<Question>> if you want to skip creating a Quiz class.
    Not sure if that's what you were asking but this would allow you to store and retrieve answers and questions for any player.
  8. Let me explain more like i'm making a Generator plugin and i want the owner to be able to create generators from chat
    using these questions

    Code (YAML):
       type: "§7» §fWhat is the type of the generator &8(command or item)"
    : "§7» §fWhat is the delay of the generator &8(1 -> {max})"
    : "§7» §fDo you want {name} generator to be linkable ? &8(yes/no)"
    : "§7» §fUse your held item or a custom ? &8(yes/no)"
    : "§7» §fType name of the material to spawn &7(ex: STONE or LIME_WOOL)"
    : "§7» &fType the name of the command to generate &7(ex: mobcoins give {player})"
    and i have a CustomType class

    Code (Text):
    public class CustomType {

        private String name, command, type;
        private List<String> lore;
        private boolean canLink, glow;
        private ItemStack item;
        private int delay;

        public CustomType(String name) {
   = name;

        public int getDelay() {
            return delay;

        public String getType() {
            return type;

        public String getName() {

        public List<String> getLore() {

        public boolean canLink() {
            return canLink;

        public boolean isGlow() {
            return glow;

        public ItemStack getItem() {
            return item;

        public String getCommand() {
            return command;

        public void setLore(List<String> lore) {
            this.lore = lore;

        public void setCanLink(boolean canLink) {
            this.canLink = canLink;

        public void setItem(ItemStack item) {
            this.item = item;

        public void setCommand(String command) {
            this.command = command;

        public void setType(String type) {
            this.type = type;

        public void setDelay(int delay) {
            this.delay = delay;
    but how to keep asking player questions and set data to the custom type player is creating

    like /generator create then a CustomType is created and stored in a hashmap with the player uuid
    i check if the player is in the map in async chat event
    then how to keep asking player and cancel when all is done