1.8.8 Scanner input is not correct on response

Discussion in 'Spigot Plugin Development' started by zt38475tz, Mar 12, 2020.

  1. Hello guys,
    I am trying to get the input from the console with a scanner but when the scanner starts and I am able to type it is very slowly and when I hit enter the my input is wrong shown in the response (my input in the console is not shown):

    Code (Text):
    Scanner scanner = new Scanner(System.in);

    System.out.println(scanner.nextLine());
     
  2. Not sure why you need this for a plugin, but can you tell us how it doesn't do what do you expect?
     
  3. @Plochem For example: i type the word hello. While typing my input is not shown in the input field of the console. When I hit enter I need sometimes several times until my message was sent to the console and the System.out.println(scanner.nextLine()); returns online some chars of my message.
     
  4. Works just fine for me. Are you using eclipse? Try building the application and running it from a normal command line instead, as the console in eclipse is a little iffy.
     
  5. @kumpelblase2 I am using IntelliJ and with console I associate the spigot server console
     
  6. Wait what are you trying to do? Why not use commands?
     
    • Agree Agree x 1
  7. The minecraft server already has a reader attached to the console, which causes things to interfere with another. If you want to get input, use a command instead; I don't think you can have direct access to to the console to read input.
     
    • Agree Agree x 2
  8. Is it somehow possible to gain access to the console input scanner?
     
  9. I'm fairly certain you can just use System.in, but you shouldn't. In a plugin, you should use commands to detect when somebody puts something in console.

    I can't think of a reason to use java.util.Scanner in a plugin over the bukkit/spigot command system.
     
  10. There probably is some hacky way to do it.

    http://xyproblem.info/
    What do you actually want to achieve?
     
  11. I do not.

    Again,
     
    • Agree Agree x 1
  12. There is no need to tell you:
    1.: I am doing it differently now
    2.: It wouldn't have changed anything because I wanted to do it like this even if there are some problems but now I found a second way doing it
     
  13. If you want help, there is need to tell us.

    Mark this thread as solved if you found a solution.
     
    • Agree Agree x 1