Merge pull request #79 from mlus-asuka/1.20.1-dev
Fix error when no player in server
This commit is contained in:
commit
2d891db071
|
|
@ -34,7 +34,7 @@ mod_name=PlayerSync
|
|||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=GPL-3.0 license
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=2.1.2
|
||||
mod_version=2.1.3
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
|
|
|||
28
src/main/java/vip/fubuki/playersync/CommandInit.java
Normal file
28
src/main/java/vip/fubuki/playersync/CommandInit.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package vip.fubuki.playersync;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import vip.fubuki.playersync.sync.chat.ChatSyncClient;
|
||||
|
||||
@Mod.EventBusSubscriber()
|
||||
public class CommandInit {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerCommand(RegisterCommandsEvent event){
|
||||
CommandDispatcher<CommandSourceStack> dispatcher=event.getDispatcher();
|
||||
dispatcher.register(Commands.literal("playersync")
|
||||
.requires(cs->cs.hasPermission(2))
|
||||
.then(Commands.literal("reconnect")
|
||||
.executes(context -> {
|
||||
new ChatSyncClient().run();
|
||||
// context.getSource().sendSuccess(()->MutableComponent.create(new TranslatableContents("playersync.command.reconnect")),true);
|
||||
return 0;
|
||||
}
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,9 @@ public class ChatSyncClient {
|
|||
while ((serverMessage = in.readLine()) != null) {
|
||||
PlayerSync.LOGGER.info("Received message from chat server: " + serverMessage);
|
||||
Component textComponents = Component.nullToEmpty(serverMessage);
|
||||
playerList.broadcastSystemMessage(textComponents,false);
|
||||
if(playerList!=null){
|
||||
playerList.broadcastSystemMessage(textComponents,false);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
|
@ -40,7 +42,7 @@ public class ChatSyncClient {
|
|||
}
|
||||
}
|
||||
|
||||
private static void reconnectClient() {
|
||||
private void reconnectClient() {
|
||||
ChatSync.LOGGER.warn("TODO: implement reconnectClient()");
|
||||
//TODO
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user