Message saying the server is going to shut down is now set using MinecraftServer.getPlayerManager().broadcastChatMessage()
parent
b172df6c0f
commit
f8f1b4a1f6
|
@ -21,6 +21,7 @@ package net.szum123321.textile_backup.core;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.szum123321.textile_backup.core.create.BackupContext;
|
import net.szum123321.textile_backup.core.create.BackupContext;
|
||||||
|
@ -47,7 +48,11 @@ public class CustomLogger {
|
||||||
this.messageFactory = ParameterizedMessageFactory.INSTANCE;
|
this.messageFactory = ParameterizedMessageFactory.INSTANCE;
|
||||||
this.logger = LogManager.getLogger(name, messageFactory);
|
this.logger = LogManager.getLogger(name, messageFactory);
|
||||||
this.prefix = "[" + prefix + "]" + " ";
|
this.prefix = "[" + prefix + "]" + " ";
|
||||||
this.prefixText = new LiteralText(this.prefix).formatted(Formatting.AQUA);
|
this.prefixText = new LiteralText(this.prefix).styled(style -> style.withColor(0x5B23DA));
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableText getPrefixText() {
|
||||||
|
return prefixText.shallowCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(Level level, String msg, Object... data) {
|
public void log(Level level, String msg, Object... data) {
|
||||||
|
|
|
@ -18,8 +18,12 @@
|
||||||
|
|
||||||
package net.szum123321.textile_backup.core.restore;
|
package net.szum123321.textile_backup.core.restore;
|
||||||
|
|
||||||
|
import net.minecraft.network.MessageType;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.MutableText;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
|
import net.minecraft.util.Util;
|
||||||
import net.szum123321.textile_backup.Statics;
|
import net.szum123321.textile_backup.Statics;
|
||||||
import net.szum123321.textile_backup.core.Utilities;
|
import net.szum123321.textile_backup.core.Utilities;
|
||||||
|
|
||||||
|
@ -46,8 +50,11 @@ public class RestoreHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AwaitThread create(File backupFile, MinecraftServer server, String comment) {
|
public static AwaitThread create(File backupFile, MinecraftServer server, String comment) {
|
||||||
server.getPlayerManager().getPlayerList()
|
MutableText msg = new LiteralText("Warning! The server is going to shut down in " + Statics.CONFIG.restoreDelay + " seconds!");
|
||||||
.forEach(serverPlayerEntity -> serverPlayerEntity.sendMessage(new LiteralText("Warning! The server is going to shut down in " + Statics.CONFIG.restoreDelay + " seconds!"), false));
|
msg.formatted(Formatting.WHITE);
|
||||||
|
msg = Statics.LOGGER.getPrefixText().append(msg);
|
||||||
|
|
||||||
|
server.getPlayerManager().broadcastChatMessage(msg, MessageType.SYSTEM, Util.NIL_UUID);
|
||||||
|
|
||||||
Statics.globalShutdownBackupFlag.set(false);
|
Statics.globalShutdownBackupFlag.set(false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue