Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions Plugin/src/main/java/dev/lrxh/neptune/game/arena/Arena.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,31 +182,61 @@ public void write(ConfigurationSection s) {
}

public void restore() {
if (Neptune.get() != null && !Neptune.get().isDuplicatesEnabled()) return;
if (min == null || min.getWorld() == null) return;
if (faweClipboard != null) {
Bukkit.getScheduler().runTaskAsynchronously(Neptune.get(),
() -> ArenaDuplicator.restore(min.getWorld(), faweClipboard));
() -> {
try {
ArenaDuplicator.restore(min.getWorld(), faweClipboard);
} catch (Throwable t) {
Neptune.get().getLogger().warning("Failed to restore arena snapshot for " + name + ": " + t.getMessage());
}
});
} else if (owner != null && owner.getFaweClipboard() != null) {
int x = Math.min(min.getBlockX(), max.getBlockX());
int y = Math.min(min.getBlockY(), max.getBlockY());
int z = Math.min(min.getBlockZ(), max.getBlockZ());
Object clip = owner.getFaweClipboard();
Bukkit.getScheduler().runTaskAsynchronously(Neptune.get(),
() -> ArenaDuplicator.restoreAt(min.getWorld(), clip, x, y, z));
() -> {
try {
ArenaDuplicator.restoreAt(min.getWorld(), clip, x, y, z);
} catch (Throwable t) {
Neptune.get().getLogger().warning("Failed to restore arena snapshot for " + name + ": " + t.getMessage());
}
});
}
}

public boolean isDoneLoading() {
if (Neptune.get() != null && !Neptune.get().isDuplicatesEnabled()) return true;
return doneLoading;
}

public void capture() {
if (min == null || max == null) return;
if (owner != null) {
this.doneLoading = true;
return;
}
if (Neptune.get() != null && !Neptune.get().isDuplicatesEnabled()) {
this.faweClipboard = null;
this.doneLoading = true;
return;
}
this.doneLoading = false;
Bukkit.getScheduler().runTaskAsynchronously(Neptune.get(), () -> {
if (owner == null) {
this.faweClipboard = ArenaDuplicator.capture(min.getWorld(), min, max);
try {
if (owner == null) {
this.faweClipboard = ArenaDuplicator.capture(min.getWorld(), min, max);
}
} catch (Throwable t) {
this.faweClipboard = null;
Neptune.get().getLogger().warning("Failed to capture arena snapshot for " + name + ": " + t.getMessage());
} finally {
this.doneLoading = true;
}
this.doneLoading = true;
});
}

Expand Down
Loading