File tree Expand file tree Collapse file tree
src/main/java/cn/ussshenzhou/channel/subspace/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ mod_name=Channel
3030# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
3131mod_license =GNU GPL 3.0
3232# The mod version. See https://semver.org/
33- mod_version =26.1.2-23 +beta
33+ mod_version =26.1.2-24 +beta
3434# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
3535# This should match the base package used for the mod sources.
3636# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Original file line number Diff line number Diff line change @@ -232,11 +232,22 @@ protected void initChannel(SocketChannel ch) {
232232 }
233233
234234 public static void send (SubspacePacket packet ) {
235- if (channel != null && channel .isActive ()) {
236- var buf = new FriendlyByteBuf (channel .alloc ().buffer ());
237- packet .encode (buf );
238- channel .writeAndFlush (buf );
235+ if (channel == null ) {
236+ LogUtils .getLogger ().warn ("channel is null. This should not happen. Skip send {}." , packet .getClass ().getSimpleName ());
237+ return ;
238+ }
239+ if (!channel .isActive ()) {
240+ LogUtils .getLogger ().warn ("channel is inactive. This should not happen. Skip send {}." , packet .getClass ().getSimpleName ());
241+ return ;
239242 }
243+ var buf = new FriendlyByteBuf (channel .alloc ().buffer ());
244+ packet .encode (buf );
245+ channel .writeAndFlush (buf )
246+ .addListener ((ChannelFutureListener ) future -> {
247+ if (!future .isSuccess ()) {
248+ LogUtils .getLogger ().error ("Failed to send {}." , packet .getClass ().getSimpleName (), future .cause ());
249+ }
250+ });
240251 }
241252
242253 public static void terminate () {
You can’t perform that action at this time.
0 commit comments