From a41be09ef3fa158790de7bc014347ef889958804 Mon Sep 17 00:00:00 2001 From: filoghost Date: Sat, 11 Apr 2020 19:02:24 +0200 Subject: [PATCH] Fix holograms not saving with `readImage` or `readText` commands --- .../commands/main/subs/ReadimageCommand.java | 5 ++++- .../commands/main/subs/ReadtextCommand.java | 6 ++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadimageCommand.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadimageCommand.java index 9e79b2a0..21460f72 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadimageCommand.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadimageCommand.java @@ -40,6 +40,7 @@ import com.gmail.filoghost.holographicdisplays.exception.TooWideException; import com.gmail.filoghost.holographicdisplays.exception.UnreadableImageException; import com.gmail.filoghost.holographicdisplays.image.ImageMessage; import com.gmail.filoghost.holographicdisplays.object.NamedHologram; +import com.gmail.filoghost.holographicdisplays.object.line.CraftTextLine; import com.gmail.filoghost.holographicdisplays.util.FileUtils; public class ReadimageCommand extends HologramSubCommand { @@ -113,7 +114,9 @@ public class ReadimageCommand extends HologramSubCommand { ImageMessage imageMessage = new ImageMessage(image, width); String[] newLines = imageMessage.getLines(); for (int i = 0; i < newLines.length; i++) { - hologram.appendTextLine(newLines[i]); + CraftTextLine line = new CraftTextLine(hologram, newLines[i]); + line.setSerializedConfigValue(newLines[i]); + hologram.getLinesUnsafe().add(line); } hologram.refreshAll(); diff --git a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadtextCommand.java b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadtextCommand.java index 1020e92a..74b12e88 100644 --- a/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadtextCommand.java +++ b/Plugin/src/main/java/com/gmail/filoghost/holographicdisplays/commands/main/subs/ReadtextCommand.java @@ -30,7 +30,6 @@ import com.gmail.filoghost.holographicdisplays.commands.CommandValidator; import com.gmail.filoghost.holographicdisplays.commands.Strings; import com.gmail.filoghost.holographicdisplays.commands.main.HologramSubCommand; import com.gmail.filoghost.holographicdisplays.disk.HologramDatabase; -import com.gmail.filoghost.holographicdisplays.disk.StringConverter; import com.gmail.filoghost.holographicdisplays.event.NamedHologramEditedEvent; import com.gmail.filoghost.holographicdisplays.exception.CommandException; import com.gmail.filoghost.holographicdisplays.object.NamedHologram; @@ -64,7 +63,6 @@ public class ReadtextCommand extends HologramSubCommand { CommandValidator.isTrue(!HolographicDisplays.isConfigFile(targetFile), "Cannot read default configuration files."); List lines = FileUtils.readLines(targetFile); - hologram.clearLines(); int linesAmount = lines.size(); if (linesAmount > 40) { @@ -72,10 +70,10 @@ public class ReadtextCommand extends HologramSubCommand { linesAmount = 40; } + hologram.clearLines(); for (int i = 0; i < linesAmount; i++) { - hologram.appendTextLine(StringConverter.toReadableFormat(lines.get(i))); + hologram.getLinesUnsafe().add(HologramDatabase.deserializeHologramLine(lines.get(i), hologram)); } - hologram.refreshAll(); HologramDatabase.saveHologram(hologram);