mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-23 01:27:33 +01:00
Use new netty method
This commit is contained in:
parent
0afeb4792d
commit
972be828a1
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_10_R1.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
@ -7,8 +9,7 @@ import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import net.citizensnpcs.util.Util;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
@ -65,7 +66,7 @@ public class EmptyChannel extends AbstractChannel {
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return null;
|
||||
return Util.requiresNettyChannelMetadata() ? new ChannelMetadata(true) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_11_R1.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
@ -7,8 +9,7 @@ import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import net.citizensnpcs.util.Util;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
@ -65,7 +66,7 @@ public class EmptyChannel extends AbstractChannel {
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return null;
|
||||
return Util.requiresNettyChannelMetadata() ? new ChannelMetadata(true) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_8_R3.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
@ -7,37 +9,9 @@ import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
import io.netty.util.Version;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.util.Map;
|
||||
import net.citizensnpcs.util.Util;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
|
||||
private static boolean updatedNetty = false;
|
||||
|
||||
static {
|
||||
Map<String, Version> versionMap = Version.identify();
|
||||
Version nettyVersion = versionMap.get("netty-common");
|
||||
if (nettyVersion == null)
|
||||
nettyVersion = versionMap.get("netty-all");
|
||||
|
||||
if (nettyVersion != null) {
|
||||
String[] split = nettyVersion.artifactVersion().split("\\.");
|
||||
try {
|
||||
int major = Integer.parseInt(split[0]);
|
||||
int minor = Integer.parseInt(split[1]);
|
||||
int revision = Integer.parseInt(split[2]);
|
||||
|
||||
if (major > 4 || minor > 1 || revision > 24) {
|
||||
updatedNetty = true;
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException ignored) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
@ -92,7 +66,7 @@ public class EmptyChannel extends AbstractChannel {
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return updatedNetty ? new ChannelMetadata(true) : null;
|
||||
return Util.requiresNettyChannelMetadata() ? new ChannelMetadata(true) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user