From 396351771c0f6e2b10c2ec34d50c126ea8356dab Mon Sep 17 00:00:00 2001 From: toxuin Date: Mon, 13 Nov 2017 17:32:30 +0300 Subject: [PATCH] Builds and runs. --- pom.xml | 44 +++++++++++++++++-- .../ryanmichela/sshd/ConsoleShellFactory.java | 7 ++- .../ryanmichela/sshd/FlushyStreamHandler.java | 1 + .../java/com/ryanmichela/sshd/PemDecoder.java | 2 +- .../com/ryanmichela/sshd/ReflectionUtil.java | 4 +- .../sshd/StreamHandlerAppender.java | 6 +-- .../org/slf4j/impl/PluginSlf4jFactory.java | 7 +-- 7 files changed, 53 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 572d927..536214e 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,7 @@ jar ${basedir}/bukkit-build/bukkit.jar + org.apache.sshd sshd-core @@ -42,16 +43,52 @@ compile jar + + + org.apache.mina + mina-core + 2.0.16 + + + + org.slf4j + slf4j-api + 1.7.25 + + + + org.slf4j + slf4j-jdk14 + 1.7.25 + + + + maven-assembly-plugin + + + package + + single + + + + + + jar-with-dependencies + + + + - + --> + org.apache.maven.plugins diff --git a/src/main/java/com/ryanmichela/sshd/ConsoleShellFactory.java b/src/main/java/com/ryanmichela/sshd/ConsoleShellFactory.java index 3257771..2f8e875 100644 --- a/src/main/java/com/ryanmichela/sshd/ConsoleShellFactory.java +++ b/src/main/java/com/ryanmichela/sshd/ConsoleShellFactory.java @@ -15,6 +15,9 @@ import java.io.OutputStream; import java.util.logging.StreamHandler; public class ConsoleShellFactory implements Factory { + public Command get() { + return this.create(); + } public Command create() { return new ConsoleShell(); @@ -92,7 +95,7 @@ public class ConsoleShellFactory implements Factory { String command; try { printPreamble(consoleReader); - while(true) { + while (true) { command = consoleReader.readLine("\r>", null); if (command != null) { if (command.equals("exit")) { @@ -109,7 +112,7 @@ public class ConsoleShellFactory implements Factory { } } - private void printPreamble(ConsoleReader consoleReader) throws IOException{ + private void printPreamble(ConsoleReader consoleReader) throws IOException { consoleReader.println(" _____ _____ _ _ _____"); consoleReader.println(" / ____/ ____| | | | __ \\"); consoleReader.println("| (___| (___ | |__| | | | |"); diff --git a/src/main/java/com/ryanmichela/sshd/FlushyStreamHandler.java b/src/main/java/com/ryanmichela/sshd/FlushyStreamHandler.java index 8c900f2..cb924f0 100644 --- a/src/main/java/com/ryanmichela/sshd/FlushyStreamHandler.java +++ b/src/main/java/com/ryanmichela/sshd/FlushyStreamHandler.java @@ -3,6 +3,7 @@ package com.ryanmichela.sshd; import org.apache.sshd.common.SshException; import org.bukkit.craftbukkit.libs.jline.console.ConsoleReader; + import java.io.IOException; import java.io.OutputStream; import java.util.logging.*; diff --git a/src/main/java/com/ryanmichela/sshd/PemDecoder.java b/src/main/java/com/ryanmichela/sshd/PemDecoder.java index cb368c0..8051119 100644 --- a/src/main/java/com/ryanmichela/sshd/PemDecoder.java +++ b/src/main/java/com/ryanmichela/sshd/PemDecoder.java @@ -22,7 +22,7 @@ public class PemDecoder extends java.io.BufferedReader { } public PublicKey getPemBytes() throws Exception { - StringBuffer b64 = new StringBuffer(); + StringBuilder b64 = new StringBuilder(); String line = readLine(); if (!line.matches(BEGIN)) { diff --git a/src/main/java/com/ryanmichela/sshd/ReflectionUtil.java b/src/main/java/com/ryanmichela/sshd/ReflectionUtil.java index f5d73c3..971e28d 100644 --- a/src/main/java/com/ryanmichela/sshd/ReflectionUtil.java +++ b/src/main/java/com/ryanmichela/sshd/ReflectionUtil.java @@ -28,9 +28,7 @@ public class ReflectionUtil { modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL); f.set(o, newValue); - } catch (NoSuchFieldException ex) { - System.out.println("*** " + c.getName() + ":" + ex); - } catch (IllegalAccessException ex) { + } catch (NoSuchFieldException | IllegalAccessException ex) { System.out.println("*** " + c.getName() + ":" + ex); } } diff --git a/src/main/java/com/ryanmichela/sshd/StreamHandlerAppender.java b/src/main/java/com/ryanmichela/sshd/StreamHandlerAppender.java index 162f51a..39d5807 100644 --- a/src/main/java/com/ryanmichela/sshd/StreamHandlerAppender.java +++ b/src/main/java/com/ryanmichela/sshd/StreamHandlerAppender.java @@ -71,12 +71,12 @@ public class StreamHandlerAppender implements Appender { @Override public State getState() { - return null; // TODO: Generated method stub + return State.INITIALIZED; } @Override public void initialize() { - // TODO: Generated method stub + } @Override @@ -96,6 +96,6 @@ public class StreamHandlerAppender implements Appender { @Override public boolean isStopped() { - return false; // TODO: Generated method stub + return false; } } diff --git a/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java b/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java index 81218ea..8307da8 100644 --- a/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java +++ b/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java @@ -22,24 +22,19 @@ public class PluginSlf4jFactory implements ILoggerFactory { private String name; private boolean isEnabled(Level level) { - if (SshdPlugin.instance != null) { - return SshdPlugin.instance.getLogger().isLoggable(level); - } - return false; + return SshdPlugin.instance != null && SshdPlugin.instance.getLogger().isLoggable(level); } private void log(Level level, String s, Object[] objects) { if (SshdPlugin.instance != null && isEnabled(level)) { FormattingTuple ft = MessageFormatter.arrayFormat(s, objects); SshdPlugin.instance.getLogger().log(level, ft.getMessage(), ft.getThrowable()); - SshdPlugin.instance.getLogger().log(level, s, Thread.currentThread().getStackTrace()); } } private void log(Level level, String s, Throwable throwable) { if (SshdPlugin.instance != null && isEnabled(level)) { SshdPlugin.instance.getLogger().log(level, s, throwable); - SshdPlugin.instance.getLogger().log(level, s, Thread.currentThread().getStackTrace()); } }