Check out example codes for "spigot run command as console". It will help you in understanding the concepts better.

Code Example 1

ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
String command = "/command";
Bukkit.dispatchCommand(console, command);

Learn ReactJs, React Native from akashmittal.com