perf: 优化性能
This commit is contained in:
@@ -3,12 +3,17 @@ setArchivesBaseName("HamsterBall-Bukkit")
|
||||
evaluationDependsOn(':hamster-ball-common')
|
||||
|
||||
dependencies {
|
||||
apiShade(project(":hamster-ball-common")) { transitive = false }
|
||||
apiShade project(":hamster-ball-common") transitive false
|
||||
|
||||
compileOnly 'org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT'
|
||||
//noinspection VulnerableLibrariesLocal
|
||||
compileOnly 'org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT'
|
||||
|
||||
// https://mvnrepository.com/artifact/io.netty/netty-all
|
||||
//noinspection GradlePackageUpdate
|
||||
shade 'io.netty:netty-all:4.1.86.Final'
|
||||
|
||||
compileOnly "cn.hamster3.mc.plugin.core:bukkit:${hamster_core_version}"
|
||||
compileOnly("me.clip:placeholderapi:2.11.2") { transitive = false }
|
||||
compileOnly "me.clip:placeholderapi:2.11.2" transitive false
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@@ -3,10 +3,10 @@ setArchivesBaseName("HamsterBall-BungeeCord")
|
||||
evaluationDependsOn(':hamster-ball-common')
|
||||
|
||||
dependencies {
|
||||
apiShade(project(":hamster-ball-common")) { transitive = false }
|
||||
apiShade project(":hamster-ball-common") transitive false
|
||||
|
||||
//noinspection VulnerableLibrariesLocal
|
||||
compileOnly 'net.md-5:bungeecord-api:1.19-R0.1-SNAPSHOT'
|
||||
compileOnly 'net.md-5:bungeecord-api:1.19-R0.1-SNAPSHOT' exclude group: 'io.netty'
|
||||
|
||||
compileOnly "cn.hamster3.mc.plugin.core:bungeecord:${hamster_core_version}"
|
||||
}
|
||||
|
@@ -3,9 +3,10 @@ setArchivesBaseName("HamsterBall-Common")
|
||||
dependencies {
|
||||
// https://mvnrepository.com/artifact/com.google.code.gson/gson
|
||||
//noinspection GradlePackageUpdate
|
||||
//noinspection VulnerableLibrariesLocal
|
||||
compileOnly 'com.google.code.gson:gson:2.8.0'
|
||||
// https://mvnrepository.com/artifact/io.netty/netty-all
|
||||
compileOnly 'io.netty:netty-all:4.1.82.Final'
|
||||
compileOnly 'io.netty:netty-all:4.1.86.Final'
|
||||
|
||||
compileOnly "cn.hamster3.mc.plugin.core:common:${hamster_core_version}"
|
||||
|
||||
|
@@ -13,9 +13,6 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BallChannelInitializer extends ChannelInitializer<SocketChannel> {
|
||||
public BallChannelInitializer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initChannel(@NotNull SocketChannel channel) {
|
||||
channel.pipeline()
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cn.hamster3.mc.plugin.ball.common.utils;
|
||||
|
||||
import cn.hamster3.mc.plugin.core.common.thread.NamedThreadFactory;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.ServerChannel;
|
||||
@@ -14,12 +15,16 @@ import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
public enum OS {
|
||||
WINDOWS,
|
||||
LINUX,
|
||||
MACOS,
|
||||
OTHER;
|
||||
|
||||
private static final ThreadFactory THREAD_FACTORY = new NamedThreadFactory("HamsterBall-IO");
|
||||
|
||||
@NotNull
|
||||
public static OS getCurrentOS() {
|
||||
String s = System.getProperties().get("os.name").toString().toLowerCase();
|
||||
@@ -50,11 +55,11 @@ public enum OS {
|
||||
public EventLoopGroup getEventLoopGroup(int nThread) {
|
||||
switch (this) {
|
||||
case LINUX:
|
||||
return new EpollEventLoopGroup(nThread);
|
||||
return new EpollEventLoopGroup(nThread, THREAD_FACTORY);
|
||||
case MACOS:
|
||||
return new KQueueEventLoopGroup(nThread);
|
||||
return new KQueueEventLoopGroup(nThread, THREAD_FACTORY);
|
||||
default:
|
||||
return new NioEventLoopGroup(nThread);
|
||||
return new NioEventLoopGroup(nThread, THREAD_FACTORY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ setArchivesBaseName("HamsterBall-Server")
|
||||
evaluationDependsOn(':hamster-ball-common')
|
||||
|
||||
dependencies {
|
||||
apiShade(project(":hamster-ball-common")) { transitive = false }
|
||||
apiShade project(":hamster-ball-common") transitive false
|
||||
|
||||
// // https://mvnrepository.com/artifact/org.slf4j/slf4j-api
|
||||
// implementation 'org.slf4j:slf4j-api:2.0.3'
|
||||
|
@@ -13,10 +13,6 @@ import org.slf4j.LoggerFactory;
|
||||
public class BallServerChannelHandler extends SimpleChannelInboundHandler<String> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger("BallServerChannelHandler");
|
||||
|
||||
public BallServerChannelHandler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext context, String message) {
|
||||
if ("ping".equals(message)) {
|
||||
|
@@ -24,9 +24,6 @@ public class BallServerChannelInitializer extends ChannelInitializer<SocketChann
|
||||
public static final List<Channel> CHANNELS = new ArrayList<>();
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger("BallServerChannelInitializer");
|
||||
|
||||
public BallServerChannelInitializer() {
|
||||
}
|
||||
|
||||
public static void broadcastMessage(BallMessageInfo messageInfo) {
|
||||
String string = messageInfo.toString();
|
||||
synchronized (CHANNELS) {
|
||||
|
@@ -11,10 +11,6 @@ import org.slf4j.LoggerFactory;
|
||||
public class BallServerKeepAliveHandler extends SimpleUserEventChannelHandler<IdleStateEvent> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger("BallServerKeepAliveHandler");
|
||||
|
||||
public BallServerKeepAliveHandler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void eventReceived(ChannelHandlerContext context, IdleStateEvent event) {
|
||||
context.close();
|
||||
|
Reference in New Issue
Block a user