parent
272e7cf8dc
commit
8f6319d979
@ -29,6 +29,7 @@ public class ConsoleShellFactory implements Factory<Command> {
|
||||
}
|
||||
|
||||
public static class ConsoleShell implements Command, Runnable {
|
||||
|
||||
private InputStream in;
|
||||
private OutputStream out;
|
||||
private OutputStream err;
|
||||
@ -101,14 +102,16 @@ public class ConsoleShellFactory implements Factory<Command> {
|
||||
while (true) {
|
||||
String command = consoleReader.readLine("\r>", null);
|
||||
if (command == null) continue;
|
||||
if (command.equals("exit")) break;
|
||||
if (command.equals("exit") || command.equals("quit")) break;
|
||||
Bukkit.getScheduler().runTask(SshdPlugin.instance, () -> {
|
||||
if (SshdPlugin.instance.getConfig().getString("mode").equals("RPC") && command.startsWith("rpc")) {
|
||||
if (SshdPlugin.instance.getConfig().getString("mode").equals("RPC") &&
|
||||
command.startsWith("rpc")) {
|
||||
//NO ECHO NO PREAMBLE AND SHIT
|
||||
String cmd = command.substring("rpc".length() + 1, command.length());
|
||||
Bukkit.dispatchCommand(sshdCommandSender, cmd);
|
||||
} else {
|
||||
SshdPlugin.instance.getLogger().info("<" + environment.getEnv().get(Environment.ENV_USER) + "> " + command);
|
||||
SshdPlugin.instance.getLogger()
|
||||
.info("<" + environment.getEnv().get(Environment.ENV_USER) + "> " + command);
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
});
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.ryanmichela.sshd;
|
||||
|
||||
import org.apache.sshd.common.SshException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@ -7,6 +9,7 @@ import java.io.OutputStream;
|
||||
* Copyright 2013 Ryan Michela
|
||||
*/
|
||||
public class FlushyOutputStream extends OutputStream {
|
||||
|
||||
private OutputStream base;
|
||||
private boolean isClosed = false;
|
||||
|
||||
@ -16,23 +19,27 @@ public class FlushyOutputStream extends OutputStream {
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
if(isClosed) return;
|
||||
if (isClosed) return;
|
||||
base.write(b);
|
||||
base.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
if(isClosed) return;
|
||||
if (isClosed) return;
|
||||
base.write(b);
|
||||
base.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
if(isClosed) return;
|
||||
base.write(b, off, len);
|
||||
base.flush();
|
||||
if (isClosed) return;
|
||||
try {
|
||||
base.write(b, off, len);
|
||||
base.flush();
|
||||
} catch (SshException e) {
|
||||
if (!e.getMessage().contains("channel already closed")) throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user