Attempted fix for 1.12.

This commit is contained in:
Haarolean 2017-11-13 04:02:19 +03:00
parent 956f0cc3ef
commit f034cef465
7 changed files with 43 additions and 22 deletions

19
pom.xml
View File

@ -12,8 +12,8 @@
<!-- Repositories --> <!-- Repositories -->
<repositories> <repositories>
<repository> <repository>
<id>bukkit-repo</id> <id>spigot-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url> <url>https://hub.spigotmc.org/nexus/content/groups/public</url>
</repository> </repository>
</repositories> </repositories>
@ -30,14 +30,15 @@
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId> <artifactId>craftbukkit</artifactId>
<version>1.7.9-R0.2</version> <version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>system</scope>
<type>jar</type> <type>jar</type>
<systemPath>${basedir}/bukkit-build/bukkit.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.sshd</groupId> <groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId> <artifactId>sshd-core</artifactId>
<version>0.9.0</version> <version>1.6.0</version>
<scope>compile</scope> <scope>compile</scope>
<type>jar</type> <type>jar</type>
</dependency> </dependency>
@ -47,7 +48,7 @@
<build> <build>
<plugins> <plugins>
<!-- Shade plugin --> <!-- Shade plugin -->
<plugin> <!--<plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>1.5</version> <version>1.5</version>
@ -72,15 +73,15 @@
</filters> </filters>
<minimizeJar>true</minimizeJar> <minimizeJar>true</minimizeJar>
</configuration> </configuration>
</plugin> </plugin>-->
<!-- Compile plugin --> <!-- Compile plugin -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version> <version>3.0</version>
<configuration> <configuration>
<source>1.6</source> <source>1.8</source>
<target>1.6</target> <target>1.8</target>
<showDeprecation>true</showDeprecation> <showDeprecation>true</showDeprecation>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -1,6 +1,6 @@
package com.ryanmichela.sshd; 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 org.apache.sshd.server.session.ServerSession;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,6 +1,6 @@
package com.ryanmichela.sshd; package com.ryanmichela.sshd;
import org.apache.mina.util.Base64; import org.apache.commons.codec.binary.Base64;
import java.io.Reader; import java.io.Reader;
import java.math.BigInteger; import java.math.BigInteger;

View File

@ -1,7 +1,7 @@
package com.ryanmichela.sshd; package com.ryanmichela.sshd;
import org.apache.commons.lang.ArrayUtils; 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 org.apache.sshd.server.session.ServerSession;
import java.io.File; import java.io.File;

View File

@ -1,6 +1,6 @@
package com.ryanmichela.sshd; package com.ryanmichela.sshd;
import org.apache.sshd.SshServer; import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -41,7 +41,7 @@ public class SshdPlugin extends JavaPlugin {
File hostKey = new File(getDataFolder(), "hostkey"); File hostKey = new File(getDataFolder(), "hostkey");
File authorizedKeys = new File(getDataFolder(), "authorized_keys"); File authorizedKeys = new File(getDataFolder(), "authorized_keys");
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(hostKey.getPath())); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(hostKey));
sshd.setShellFactory(new ConsoleShellFactory()); sshd.setShellFactory(new ConsoleShellFactory());
sshd.setPasswordAuthenticator(new ConfigPasswordAuthenticator()); sshd.setPasswordAuthenticator(new ConfigPasswordAuthenticator());
sshd.setPublickeyAuthenticator(new PublicKeyAuthenticator(authorizedKeys)); sshd.setPublickeyAuthenticator(new PublicKeyAuthenticator(authorizedKeys));

View File

@ -25,15 +25,18 @@ public class StreamHandlerAppender implements Appender {
@Override @Override
public void append(LogEvent logEvent) { public void append(LogEvent logEvent) {
java.util.logging.Level level; 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(); 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 @Override
public void start() { public void start() {
@ -80,4 +93,9 @@ public class StreamHandlerAppender implements Appender {
public boolean isStarted() { public boolean isStarted() {
return true; return true;
} }
@Override
public boolean isStopped() {
return false; // TODO: Generated method stub
}
} }

View File

@ -32,12 +32,14 @@ public class PluginSlf4jFactory implements ILoggerFactory {
if (SshdPlugin.instance != null && isEnabled(level)) { if (SshdPlugin.instance != null && isEnabled(level)) {
FormattingTuple ft = MessageFormatter.arrayFormat(s, objects); FormattingTuple ft = MessageFormatter.arrayFormat(s, objects);
SshdPlugin.instance.getLogger().log(level, ft.getMessage(), ft.getThrowable()); 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) { private void log(Level level, String s, Throwable throwable) {
if (SshdPlugin.instance != null && isEnabled(level)) { if (SshdPlugin.instance != null && isEnabled(level)) {
SshdPlugin.instance.getLogger().log(level, s, throwable); SshdPlugin.instance.getLogger().log(level, s, throwable);
SshdPlugin.instance.getLogger().log(level, s, Thread.currentThread().getStackTrace());
} }
} }