Changed chat message prefix color to match mod's theme. Slightly improved functions notifyPlayer in BackupHelper and RestoreHelper
parent
95653d066d
commit
2ba6ba444c
|
@ -46,11 +46,11 @@ public class CustomLogger {
|
|||
this.messageFactory = ParameterizedMessageFactory.INSTANCE;
|
||||
this.logger = LogManager.getLogger(name, messageFactory);
|
||||
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;
|
||||
return prefixText.shallowCopy();
|
||||
}
|
||||
|
||||
public void log(Level level, String msg, Object... data) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import java.time.ZoneOffset;
|
|||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class BackupHelper {
|
||||
|
@ -73,7 +74,6 @@ public class BackupHelper {
|
|||
);
|
||||
|
||||
MutableText text = Statics.LOGGER.getPrefixText()
|
||||
.shallowCopy()
|
||||
.append(new LiteralText("In order for backup to be up-to-date call ").formatted(Formatting.WHITE))
|
||||
.append(
|
||||
new LiteralText("[/save-all flush]")
|
||||
|
@ -89,7 +89,6 @@ public class BackupHelper {
|
|||
ctx.getCommandSource().sendFeedback(text, false);
|
||||
|
||||
text = Statics.LOGGER.getPrefixText()
|
||||
.shallowCopy()
|
||||
.append(new LiteralText("This is known issue (See ").formatted(Formatting.WHITE))
|
||||
.append(
|
||||
new LiteralText("https://github.com/Szum123321/textile_backup/issues/42")
|
||||
|
@ -114,13 +113,20 @@ public class BackupHelper {
|
|||
}
|
||||
|
||||
private static void notifyPlayers(BackupContext ctx) {
|
||||
MutableText message = Statics.LOGGER.getPrefixText().shallowCopy();
|
||||
MutableText message = Statics.LOGGER.getPrefixText();
|
||||
message.append(new LiteralText("Warning! Server backup will begin shortly. You may experience some lag.").formatted(Formatting.WHITE));
|
||||
|
||||
UUID uuid;
|
||||
|
||||
if(ctx.getInitiator().equals(ActionInitiator.Player) && ctx.getCommandSource().getEntity() != null)
|
||||
uuid = ctx.getCommandSource().getEntity().getUuid();
|
||||
else
|
||||
uuid = Util.NIL_UUID;
|
||||
|
||||
ctx.getServer().getPlayerManager().broadcastChatMessage(
|
||||
message,
|
||||
MessageType.GAME_INFO,
|
||||
ctx.getInitiator() == ActionInitiator.Player ? ctx.getCommandSource().getEntity().getUuid() : Util.NIL_UUID
|
||||
MessageType.SYSTEM,
|
||||
uuid
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,9 @@ package net.szum123321.textile_backup.core.restore;
|
|||
|
||||
import net.minecraft.network.MessageType;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
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.ConfigHandler;
|
||||
import net.szum123321.textile_backup.Statics;
|
||||
|
@ -30,10 +32,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
@ -58,7 +57,7 @@ public class RestoreHelper {
|
|||
else
|
||||
Statics.LOGGER.info("Backup restoration was initiated form Server Console");
|
||||
|
||||
notifyPlayer(ctx);
|
||||
notifyPlayers(ctx);
|
||||
|
||||
return new AwaitThread(
|
||||
Statics.CONFIG.restoreDelay,
|
||||
|
@ -66,14 +65,27 @@ public class RestoreHelper {
|
|||
);
|
||||
}
|
||||
|
||||
private static void notifyPlayer(RestoreContext ctx) {
|
||||
MutableText message = Statics.LOGGER.getPrefixText().shallowCopy();
|
||||
message.append("Warning! The server is going to shut down in " + Statics.CONFIG.restoreDelay + " seconds!");
|
||||
private static void notifyPlayers(RestoreContext ctx) {
|
||||
MutableText message = Statics.LOGGER.getPrefixText();
|
||||
message.append(
|
||||
new LiteralText(
|
||||
"Warning! The server is going to shut down in " +
|
||||
Statics.CONFIG.restoreDelay +
|
||||
" seconds!"
|
||||
).formatted(Formatting.WHITE)
|
||||
);
|
||||
|
||||
UUID uuid;
|
||||
|
||||
if(ctx.getInitiator().equals(ActionInitiator.Player) && ctx.getCommandSource().getEntity() != null)
|
||||
uuid = ctx.getCommandSource().getEntity().getUuid();
|
||||
else
|
||||
uuid = Util.NIL_UUID;
|
||||
|
||||
ctx.getServer().getPlayerManager().broadcastChatMessage(
|
||||
message,
|
||||
MessageType.GAME_INFO,
|
||||
ctx.getInitiator() == ActionInitiator.Player ? ctx.getCommandSource().getEntity().getUuid() : Util.NIL_UUID
|
||||
MessageType.SYSTEM,
|
||||
uuid
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue