Skip to content

Commit

Permalink
add support for bungeecord build 1300
Browse files Browse the repository at this point in the history
  • Loading branch information
cyilin committed Feb 23, 2018
1 parent bd48ba3 commit e4209d4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ if (System.getenv("TRAVIS_BUILD_NUMBER") != null) {

dependencies {
compile 'net.md-5:bungeecord-api:1.12-SNAPSHOT'
compile 'io.netty:netty-codec-haproxy:4.1.15.Final'
compile 'io.netty:netty-codec-haproxy:4.1.21.Final'
}

processResources {
expand version:project.version
}
compileJava {
options.compilerArgs += ["-Xlint:deprecation", "-Xlint:unchecked"]
}
20 changes: 5 additions & 15 deletions src/main/java/cat/nyaa/bungeecordusercontrol/BungeeProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
*/
package cat.nyaa.bungeecordusercontrol;

import io.netty.channel.*;
import io.netty.handler.codec.haproxy.HAProxyMessage;
import io.netty.channel.AbstractChannel;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.haproxy.HAProxyMessageDecoder;

import java.lang.reflect.Field;
Expand Down Expand Up @@ -52,19 +53,8 @@ protected void initChannel(Channel channel) throws Exception {
initChannelMethod.invoke(bungeeChannelInitializer, channel);
if (plugin.config.haproxy_enable &&
plugin.config.haproxy_address.contains(((InetSocketAddress) channel.remoteAddress()).getAddress().getHostAddress())) {
channel.pipeline().addAfter("timeout", "haproxy-decoder", new HAProxyMessageDecoder() {
});
channel.pipeline().addAfter("haproxy-decoder", "haproxy-handler", new ChannelInboundHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HAProxyMessage) {
HAProxyMessage message = (HAProxyMessage) msg;
remoteAddressField.set(channel, new InetSocketAddress(message.sourceAddress(), message.sourcePort()));
} else {
super.channelRead(ctx, msg);
}
}
});
channel.pipeline().addFirst(new HAProxyMessageDecoder());
//https://github.com/SpigotMC/BungeeCord/blob/bd5a7e5b26b698c57e6f99933452bfc0659269f9/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java#L79
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cat/nyaa/bungeecordusercontrol/MojangAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
Expand All @@ -19,7 +19,7 @@ public class MojangAPI {
public static User getUserByName(String name) {
try {
URL url = new URL("https://api.mojang.com/profiles/minecraft");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
Expand Down

0 comments on commit e4209d4

Please sign in to comment.