Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Util class:
- --------------------------------UTIL CLASS START-------------------------------------
- public static void runShellCommandAsync(CommandSender sender, String command)
- {
- new BukkitRunnable()
- {
- @Override
- public void run()
- {
- try {
- runShellCommand(sender, command);
- }
- catch(IOException ex) {
- LF_Log.severe(ex);
- sender.sendMessage("Invalid command");
- }
- catch(InterruptedException ex) {
- sender.sendMessage("Error, see logs for more details");
- LF_Log.severe(ex);
- }
- }
- }.runTaskAsynchronously(LFUtils.plugin);
- }
- public static void runShellCommand(CommandSender sender, String command) throws InterruptedException, IOException
- {
- Process proc = Runtime.getRuntime().exec(command);
- // Read the output
- BufferedReader reader
- = new BufferedReader(new InputStreamReader(proc.getInputStream()));
- String line = "";
- while ((line = reader.readLine()) != null)
- {
- sender.sendMessage(line);
- }
- proc.waitFor();
- }
- -------------- UTIL CLASS OVER ----------------------------
- Command:
- ----------------------- COMMAND START -------------------------
- if(args.length == 0) {
- return false;
- }
- runShellCommandAsync(sender, StringUtils.join(args, " "));
- return true;
- ----------------------COMMAND END-----------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement