Skip to content

Commit

Permalink
fix running on linux and rollback on version no use Virtual Thread
Browse files Browse the repository at this point in the history
  • Loading branch information
SenseiTarzan committed Dec 18, 2024
1 parent f308e01 commit 5d92f30
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 47 deletions.
72 changes: 46 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<protocol.version>3.0.0.Beta5-SNAPSHOT</protocol.version>
<raklib.version>1.0.0.CR3-SNAPSHOT</raklib.version>
<log4j2.version>2.23.1</log4j2.version>
<log4j2.version>2.17.1</log4j2.version>
<jline.version>3.23.0</jline.version>
<netty.version>4.1.101.Final</netty.version>
</properties>
Expand Down Expand Up @@ -97,12 +97,6 @@
<id>central</id>
<name>Maven Central</name>
<url>https://repo1.maven.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>projectlombok.org</id>
Expand Down Expand Up @@ -167,11 +161,6 @@
<version>${log4j2.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
Expand Down Expand Up @@ -293,27 +282,58 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifest>
<mainClass>org.sculk.Sculk</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<dependencies>
<dependency>
<groupId>com.github.edwgiz</groupId>
<artifactId>maven-shade-plugin.log4j2-cachefile-transformer</artifactId>
<version>2.8.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<!-- Replace this with your package! -->
<shadedPattern>org.sculk</shadedPattern>
</relocation>
</relocations>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer
implementation="com.github.edwgiz.mavenShadePlugin.log4j2CacheTransformer.PluginsCacheFileTransformer">
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.sculk.Sculk</mainClass>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<source>21</source>
<detectJavaApiLink>false</detectJavaApiLink>
<doclint>none</doclint>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sculk/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public Server(LocalManager localManager, Logger logger, String dataPath) {
//Language manager
this.localManager = localManager;
this.language = localManager.getLanguage(this.properties.get(ServerPropertiesKeys.LANGUAGE, DEFAULT_LANGUAGE));
System.out.println(this.properties.get(ServerPropertiesKeys.LANGUAGE, DEFAULT_LANGUAGE));
this.logger.info(this.language.translate(LanguageKeys.SCULK_SERVER_SELECTED_LANGUAGE, List.of(TextFormat.DARK_AQUA + this.language.getName() + TextFormat.RESET)));

//Load server properties
Expand All @@ -130,7 +131,6 @@ public Server(LocalManager localManager, Logger logger, String dataPath) {
this.motd = this.properties.get(ServerPropertiesKeys.MOTD, "A Sculk Server Software");
this.submotd = this.properties.get(ServerPropertiesKeys.SUB_MOTD, "Powered by Sculk");
this.maxPlayers = this.properties.get(ServerPropertiesKeys.MAX_PLAYERS, 20);
System.out.println(this.properties.getProperties());
this.query = this.properties.get(ServerPropertiesKeys.QUERY, false);

this.operators = new SculkOperators();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/sculk/network/BedrockInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public BedrockInterface(Server server) throws Exception {
for (EventLoops.ChannelType type : EventLoops.ChannelType.values()) {
server.getLogger().debug("Supported {} channels: {}", type.name(), type.isAvailable());
}
/*

workerFactory = new ThreadFactoryBuilder()
.setNameFormat("Bedrock Listener - #%d")
.setPriority(5)
Expand All @@ -93,9 +93,9 @@ public BedrockInterface(Server server) throws Exception {
.setPriority(8)
.setDaemon(true)
.build();
*/
this.workerEventLoopGroup = channelType.newEventLoopGroup(0, Thread.ofVirtual().name("Bedrock Listner - #%d").factory());
this.bossEventLoopGroup = channelType.newEventLoopGroup(0, Thread.ofVirtual().name("RakNet Listener - #%d").factory());

this.workerEventLoopGroup = channelType.newEventLoopGroup(0, workerFactory);
this.bossEventLoopGroup = channelType.newEventLoopGroup(0, bossFactory);
boolean allowEpoll = Epoll.isAvailable();
int bindCount = allowEpoll && EventLoops.getChannelType() != EventLoops.ChannelType.NIO
? Runtime.getRuntime().availableProcessors() : 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public LoginPacketHandler(SculkServerSession session, Consumer<ClientChainData>
@Override
public PacketSignal handle(LoginPacket packet) {
ClientChainData clientChainData = ClientChainData.read(packet);
if(!clientChainData.isXboxAuthed()) {
if(this.session.getServer().isXboxAuth() && !clientChainData.isXboxAuthed()) {
session.disconnect("disconnectionScreen.notAuthenticated");
return PacketSignal.HANDLED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public PacketSignal handlePacket(BedrockPacket packet) {
@Override
public PacketSignal handle(SetLocalPlayerAsInitializedPacket packet) {
this.responseCallback.accept(null);
Server.getInstance().getLogger().info("§b" + session.getPlayer().getName() + "[/" + session.getPlayerInfo().getServerAddress() + "]§r logged in with uuid §b" + session.getPlayer().getUniqueId());
Server.getInstance().getLogger().info("§b" + session.getPlayer().getName() + "[/" + session.getSocketAddress() + "]§r logged in with uuid §b" + session.getPlayer().getUniqueId());
return PacketSignal.HANDLED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public SculkBedrockServerInitializer(BedrockInterface bedrockInterface, Server s
protected void initSession(BedrockServerSession bedrockServerSession) {
bedrockServerSession.setCodec(ProtocolInfo.CODEC);
bedrockServerSession.setLogging(false);
System.out.println("Session Connected!");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public SculkServerSession(BedrockInterface bedrockInterface, PacketBroadcaster b
this.broadcaster = broadcaster;
this.entityEventBroadcaster = entityEventBroadcaster;
this.bedrockInterface = bedrockInterface;

this.setPacketHandler(new SessionStartPacketHandler(this, this::onSessionStartSuccess));
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sculk/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public void onChat(String message) {
if (!playerChatEvent.isCancelled()) {
// TODO please change for use this.messageCount
String messageFormat = playerChatEvent.getChatFormatter().format(this.getName(), message);
this.getNetworkSession().onChatMessage(messageFormat);
Server.getInstance().broadcastMessage(messageFormat);
this.getServer().getLogger().info(messageFormat);
}
}
Expand Down
13 changes: 1 addition & 12 deletions src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Configuration status="WARN" packages="net.minecrell.terminalconsole" shutdownHook="disable">
<Appenders>
<TerminalConsole name="Console">
<PatternLayout noConsoleNoAnsi="false"
Expand All @@ -25,20 +25,9 @@
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<!-- Capture SLF4J logs -->
<Logger name="org.slf4j" level="info" additivity="false">
<AppenderRef ref="Console"/>
<AppenderRef ref="File"/>
</Logger>

<!-- Root Logger -->
<Root level="info">
<AppenderRef ref="Console"/>
<AppenderRef ref="File"/>
</Root>
</Loggers>
<Plugins>
<!-- Define your plugins here -->
<Plugin name="TerminalConsole" class="net.minecrell.terminalconsole.TerminalConsolePlugin"/>
</Plugins>
</Configuration>

0 comments on commit 5d92f30

Please sign in to comment.