Skip to content

Commit

Permalink
Builds and runs.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxuin authored and Haarolean committed Nov 13, 2017
1 parent f034cef commit 3963517
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 18 deletions.
44 changes: 41 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,60 @@
<type>jar</type>
<systemPath>${basedir}/bukkit-build/bukkit.jar</systemPath>
</dependency>

<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>1.6.0</version>
<scope>compile</scope>
<type>jar</type>
</dependency>

<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.0.16</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.25</version>
</dependency>

</dependencies>

<!-- Build -->
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>

<!-- Shade plugin -->
<!--<plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -73,7 +110,8 @@
</filters>
<minimizeJar>true</minimizeJar>
</configuration>
</plugin>-->
</plugin> -->

<!-- Compile plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/ryanmichela/sshd/ConsoleShellFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import java.util.logging.StreamHandler;

public class ConsoleShellFactory implements Factory<Command> {
public Command get() {
return this.create();
}

public Command create() {
return new ConsoleShell();
Expand Down Expand Up @@ -92,7 +95,7 @@ public void run() {
String command;
try {
printPreamble(consoleReader);
while(true) {
while (true) {
command = consoleReader.readLine("\r>", null);
if (command != null) {
if (command.equals("exit")) {
Expand All @@ -109,7 +112,7 @@ public void run() {
}
}

private void printPreamble(ConsoleReader consoleReader) throws IOException{
private void printPreamble(ConsoleReader consoleReader) throws IOException {
consoleReader.println(" _____ _____ _ _ _____");
consoleReader.println(" / ____/ ____| | | | __ \\");
consoleReader.println("| (___| (___ | |__| | | | |");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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.*;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ryanmichela/sshd/PemDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public PemDecoder(Reader in) {
}

public PublicKey getPemBytes() throws Exception {
StringBuffer b64 = new StringBuffer();
StringBuilder b64 = new StringBuilder();

String line = readLine();
if (!line.matches(BEGIN)) {
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/ryanmichela/sshd/ReflectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public static void setProtectedValue(Class c, Object o, String field, Object new
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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/ryanmichela/sshd/StreamHandlerAppender.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public void setHandler(ErrorHandler errorHandler) {

@Override
public State getState() {
return null; // TODO: Generated method stub
return State.INITIALIZED;
}

@Override
public void initialize() {
// TODO: Generated method stub

}

@Override
Expand All @@ -96,6 +96,6 @@ public boolean isStarted() {

@Override
public boolean isStopped() {
return false; // TODO: Generated method stub
return false;
}
}
7 changes: 1 addition & 6 deletions src/main/java/org/slf4j/impl/PluginSlf4jFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,19 @@ public class PluginSlf4jAdapter implements Logger {
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());
}
}

Expand Down

0 comments on commit 3963517

Please sign in to comment.