From f034cef46581ceb4bb2c4ec1c38ab0459b826727 Mon Sep 17 00:00:00 2001 From: Haarolean Date: Mon, 13 Nov 2017 04:02:19 +0300 Subject: [PATCH] Attempted fix for 1.12. --- pom.xml | 19 ++++++----- .../sshd/ConfigPasswordAuthenticator.java | 2 +- .../java/com/ryanmichela/sshd/PemDecoder.java | 2 +- .../sshd/PublicKeyAuthenticator.java | 2 +- .../java/com/ryanmichela/sshd/SshdPlugin.java | 4 +-- .../sshd/StreamHandlerAppender.java | 34 ++++++++++++++----- .../org/slf4j/impl/PluginSlf4jFactory.java | 2 ++ 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/pom.xml b/pom.xml index 94fcae1..572d927 100644 --- a/pom.xml +++ b/pom.xml @@ -12,8 +12,8 @@ - bukkit-repo - http://repo.bukkit.org/content/groups/public/ + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public @@ -30,14 +30,15 @@ org.bukkit craftbukkit - 1.7.9-R0.2 - provided + 1.12.2-R0.1-SNAPSHOT + system jar + ${basedir}/bukkit-build/bukkit.jar org.apache.sshd sshd-core - 0.9.0 + 1.6.0 compile jar @@ -47,7 +48,7 @@ - + org.apache.maven.plugins maven-compiler-plugin 3.0 - 1.6 - 1.6 + 1.8 + 1.8 true diff --git a/src/main/java/com/ryanmichela/sshd/ConfigPasswordAuthenticator.java b/src/main/java/com/ryanmichela/sshd/ConfigPasswordAuthenticator.java index 256453c..aa3954c 100644 --- a/src/main/java/com/ryanmichela/sshd/ConfigPasswordAuthenticator.java +++ b/src/main/java/com/ryanmichela/sshd/ConfigPasswordAuthenticator.java @@ -1,6 +1,6 @@ package com.ryanmichela.sshd; -import org.apache.sshd.server.PasswordAuthenticator; +import org.apache.sshd.server.auth.password.PasswordAuthenticator; import org.apache.sshd.server.session.ServerSession; import java.util.HashMap; diff --git a/src/main/java/com/ryanmichela/sshd/PemDecoder.java b/src/main/java/com/ryanmichela/sshd/PemDecoder.java index 1dc9424..cb368c0 100644 --- a/src/main/java/com/ryanmichela/sshd/PemDecoder.java +++ b/src/main/java/com/ryanmichela/sshd/PemDecoder.java @@ -1,6 +1,6 @@ package com.ryanmichela.sshd; -import org.apache.mina.util.Base64; +import org.apache.commons.codec.binary.Base64; import java.io.Reader; import java.math.BigInteger; diff --git a/src/main/java/com/ryanmichela/sshd/PublicKeyAuthenticator.java b/src/main/java/com/ryanmichela/sshd/PublicKeyAuthenticator.java index ea61a74..5e50dbe 100644 --- a/src/main/java/com/ryanmichela/sshd/PublicKeyAuthenticator.java +++ b/src/main/java/com/ryanmichela/sshd/PublicKeyAuthenticator.java @@ -1,7 +1,7 @@ package com.ryanmichela.sshd; import org.apache.commons.lang.ArrayUtils; -import org.apache.sshd.server.PublickeyAuthenticator; +import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator; import org.apache.sshd.server.session.ServerSession; import java.io.File; diff --git a/src/main/java/com/ryanmichela/sshd/SshdPlugin.java b/src/main/java/com/ryanmichela/sshd/SshdPlugin.java index 0fa10eb..2469d01 100644 --- a/src/main/java/com/ryanmichela/sshd/SshdPlugin.java +++ b/src/main/java/com/ryanmichela/sshd/SshdPlugin.java @@ -1,6 +1,6 @@ package com.ryanmichela.sshd; -import org.apache.sshd.SshServer; +import org.apache.sshd.server.SshServer; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; import org.bukkit.plugin.java.JavaPlugin; @@ -41,7 +41,7 @@ public class SshdPlugin extends JavaPlugin { File hostKey = new File(getDataFolder(), "hostkey"); File authorizedKeys = new File(getDataFolder(), "authorized_keys"); - sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(hostKey.getPath())); + sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(hostKey)); sshd.setShellFactory(new ConsoleShellFactory()); sshd.setPasswordAuthenticator(new ConfigPasswordAuthenticator()); sshd.setPublickeyAuthenticator(new PublicKeyAuthenticator(authorizedKeys)); diff --git a/src/main/java/com/ryanmichela/sshd/StreamHandlerAppender.java b/src/main/java/com/ryanmichela/sshd/StreamHandlerAppender.java index d55f4a5..162f51a 100644 --- a/src/main/java/com/ryanmichela/sshd/StreamHandlerAppender.java +++ b/src/main/java/com/ryanmichela/sshd/StreamHandlerAppender.java @@ -25,15 +25,18 @@ public class StreamHandlerAppender implements Appender { @Override public void append(LogEvent logEvent) { java.util.logging.Level level; - switch (logEvent.getLevel()) - { - case DEBUG: level = java.util.logging.Level.FINE; break; - case INFO: level = java.util.logging.Level.INFO; break; - case WARN: level = java.util.logging.Level.WARNING; break; - case ERROR: level = java.util.logging.Level.SEVERE; break; - default: level = java.util.logging.Level.INFO; break; - } + if(logEvent.getLevel().equals(org.apache.logging.log4j.Level.DEBUG)) { + level = java.util.logging.Level.FINE; + } else if(logEvent.getLevel().equals(org.apache.logging.log4j.Level.INFO)) { + level = java.util.logging.Level.INFO; + } else if(logEvent.getLevel().equals(org.apache.logging.log4j.Level.WARN)) { + level = java.util.logging.Level.WARNING; + } else if(logEvent.getLevel().equals(org.apache.logging.log4j.Level.ERROR)) { + level = java.util.logging.Level.SEVERE; + } else { + level = java.util.logging.Level.INFO; + } String message = logEvent.getMessage().getFormattedMessage(); @@ -66,6 +69,16 @@ public class StreamHandlerAppender implements Appender { } + @Override + public State getState() { + return null; // TODO: Generated method stub + } + + @Override + public void initialize() { + // TODO: Generated method stub + } + @Override public void start() { @@ -80,4 +93,9 @@ public class StreamHandlerAppender implements Appender { public boolean isStarted() { return true; } + + @Override + public boolean isStopped() { + return false; // TODO: Generated method stub + } } diff --git a/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java b/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java index 67c3e1c..81218ea 100644 --- a/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java +++ b/src/main/java/org/slf4j/impl/PluginSlf4jFactory.java @@ -32,12 +32,14 @@ public class PluginSlf4jFactory implements ILoggerFactory { 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()); } }