Skip to content

Commit

Permalink
Fix: start-up crashes delete holograms
Browse files Browse the repository at this point in the history
  • Loading branch information
danorris709 committed Aug 8, 2021
1 parent f37a172 commit a447ea1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ForgeHologram(String id, World world, Vec3d position, boolean save, Strin
this.world = world;
this.position = position;

this.addLines(lines);
this.addLines(save, lines);
HologramManager.addHologram(this);

if (save) {
Expand All @@ -49,18 +49,26 @@ public ForgeHologram(String id, World world, Vec3d position, boolean save, Strin

@Override
public void addLines(String... lines) {
this.addLines(true, lines);
}

private void addLines(boolean save, String... lines) {
if (!FMLCommonHandler.instance().getMinecraftServerInstance().isCallingFromMinecraftThread()) {
UtilForgeConcurrency.runSync(() -> this.addLines(lines));
return;
}

for (String line : lines) {
this.addLine(line);
this.addLine(line, save);
}
}

@Override
public void addLine(String line) {
this.addLine(line, true);
}

private void addLine(String line, boolean save) {
if (!FMLCommonHandler.instance().getMinecraftServerInstance().isCallingFromMinecraftThread()) {
UtilForgeConcurrency.runSync(() -> this.addLine(line));
return;
Expand All @@ -73,7 +81,9 @@ public void addLine(String line) {
armorStand.setText(line);
this.spawnLine(armorStand);

HologramManager.save();
if (save) {
HologramManager.save();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public static void preInit() {
private static HologramSaver saver;

public static void load() {
System.out.println("LOADING HOLOGRAMS");
saver.load();
System.out.println("LOADED HOLOGRAMS");
}

public static void save() {
Expand Down

0 comments on commit a447ea1

Please sign in to comment.