mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-22 11:56:21 +01:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
e4cce0fa0c
@ -22,6 +22,7 @@ import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.util.ChatUtil;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.raphimc.vialoader.netty.ViaDecoder;
|
||||
|
||||
@ -41,7 +42,7 @@ public class ViaFabricPlusViaDecoder extends ViaDecoder {
|
||||
} catch (Throwable t) {
|
||||
ViaFabricPlus.LOGGER.error("Error occurred while decoding packet in ViaDecoder", t);
|
||||
if (mode == 1) {
|
||||
ChatUtil.sendPrefixedMessage(Formatting.RED + "An error occurred while decoding a packet! See more details in the logs!");
|
||||
ChatUtil.sendPrefixedMessage(Text.literal("An error occurred while decoding a packet! See more details in the logs!").formatted(Formatting.RED));
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -23,16 +23,21 @@ import net.minecraft.util.Formatting;
|
||||
|
||||
public class ChatUtil {
|
||||
public final static String PREFIX = Formatting.WHITE + "[" + Formatting.GOLD + "ViaFabricPlus" + Formatting.WHITE + "]";
|
||||
public final static Text PREFIX_TEXT = Text.literal("[").formatted(Formatting.WHITE).append(Text.literal("ViaFabricPlus").formatted(Formatting.GOLD)).append("]");
|
||||
|
||||
public static Text prefixText(final String message) {
|
||||
return prefixText(Text.literal(message));
|
||||
}
|
||||
|
||||
public static Text prefixText(final Text message) {
|
||||
return Text.literal("").append(PREFIX).append(" " + message.getString());
|
||||
return Text.empty().append(PREFIX_TEXT).append(" ").append(message);
|
||||
}
|
||||
|
||||
public static void sendPrefixedMessage(final String message) {
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(prefixText(message));
|
||||
}
|
||||
|
||||
public static void sendPrefixedMessage(final Text message) {
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(prefixText(message));
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ public abstract class FileSaver {
|
||||
public void init() {
|
||||
if (file.exists()) {
|
||||
JsonObject parentNode = null;
|
||||
try {
|
||||
parentNode = ViaFabricPlus.GSON.fromJson(new FileReader(file), JsonObject.class).getAsJsonObject();
|
||||
try (final FileReader fr = new FileReader(file)) {
|
||||
parentNode = ViaFabricPlus.GSON.fromJson(fr, JsonObject.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user