|
4 | 4 | import dev.lrxh.blockChanger.BlockChanger; |
5 | 5 | import dev.lrxh.blockChanger.snapshot.CuboidSnapshot; |
6 | 6 | import dev.lrxh.neptune.Neptune; |
| 7 | +import dev.lrxh.neptune.configs.impl.SettingsLocale; |
7 | 8 | import dev.lrxh.neptune.game.kit.KitService; |
8 | 9 | import dev.lrxh.neptune.providers.manager.ConfigData; |
9 | 10 | import dev.lrxh.neptune.utils.LocationUtil; |
@@ -32,6 +33,7 @@ public class Arena implements IArena, ConfigData { |
32 | 33 | private long time; |
33 | 34 | private List<Material> whitelistedBlocks; |
34 | 35 | private CuboidSnapshot snapshot; |
| 36 | + private Object faweClipboard; |
35 | 37 | private Arena owner; |
36 | 38 | private boolean doneLoading; |
37 | 39 | private boolean inUse; |
@@ -60,14 +62,7 @@ public Arena(String name, String displayName, Location redSpawn, Location blueSp |
60 | 62 | this.buildLimit = buildLimit; |
61 | 63 | this.whitelistedBlocks = (whitelistedBlocks != null ? whitelistedBlocks : new ArrayList<>()); |
62 | 64 |
|
63 | | - if (min != null && max != null) { |
64 | | - this.doneLoading = false; |
65 | | - CuboidSnapshot.create(min, max).thenAccept(cuboidSnapshot -> { |
66 | | - this.snapshot = cuboidSnapshot; |
67 | | - this.doneLoading = true; |
68 | | - }); |
69 | | - } |
70 | | - |
| 65 | + capture(); |
71 | 66 | } |
72 | 67 |
|
73 | 68 | public Arena(String name, String displayName, Location redSpawn, Location blueSpawn, |
@@ -216,31 +211,44 @@ public static Arena read(String name, ConfigurationSection s) { |
216 | 211 | } |
217 | 212 |
|
218 | 213 | public void restore() { |
219 | | - if (snapshot != null) { |
| 214 | + if (faweClipboard != null) { |
| 215 | + Bukkit.getScheduler().runTaskAsynchronously(Neptune.get(), |
| 216 | + () -> ArenaDuplicator.restore(min.getWorld(), faweClipboard)); |
| 217 | + } else if (snapshot != null) { |
220 | 218 | snapshot.restore(true); |
221 | 219 | } |
222 | 220 | } |
223 | 221 |
|
224 | | - public void setMin(Location min) { |
225 | | - this.min = min; |
226 | | - if (min != null && max != null) { |
227 | | - this.doneLoading = false; |
| 222 | + private static boolean useFawe() { |
| 223 | + return "FAWE".equalsIgnoreCase(SettingsLocale.ARENA_CLEANUP_METHOD.getString()) && ArenaDuplicator.isAvailable(); |
| 224 | + } |
| 225 | + |
| 226 | + public void capture() { |
| 227 | + if (min == null || max == null) return; |
| 228 | + this.doneLoading = false; |
| 229 | + if (useFawe()) { |
| 230 | + this.snapshot = null; |
| 231 | + Bukkit.getScheduler().runTaskAsynchronously(Neptune.get(), () -> { |
| 232 | + this.faweClipboard = ArenaDuplicator.capture(min.getWorld(), min, max); |
| 233 | + this.doneLoading = true; |
| 234 | + }); |
| 235 | + } else { |
| 236 | + this.faweClipboard = null; |
228 | 237 | CuboidSnapshot.create(min, max).thenAccept(cuboidSnapshot -> { |
229 | 238 | this.snapshot = cuboidSnapshot; |
230 | 239 | this.doneLoading = true; |
231 | 240 | }); |
232 | 241 | } |
233 | 242 | } |
234 | 243 |
|
| 244 | + public void setMin(Location min) { |
| 245 | + this.min = min; |
| 246 | + capture(); |
| 247 | + } |
| 248 | + |
235 | 249 | public void setMax(Location max) { |
236 | 250 | this.max = max; |
237 | | - if (min != null && max != null) { |
238 | | - this.doneLoading = false; |
239 | | - CuboidSnapshot.create(min, max).thenAccept(cuboidSnapshot -> { |
240 | | - this.snapshot = cuboidSnapshot; |
241 | | - this.doneLoading = true; |
242 | | - }); |
243 | | - } |
| 251 | + capture(); |
244 | 252 | } |
245 | 253 |
|
246 | 254 | public void setRedSpawn(Location redSpawn) { |
|
0 commit comments