mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
Fix Replay not save mode, and issue #209 done
This commit is contained in:
@@ -1312,10 +1312,10 @@ index 0000000000000000000000000000000000000000..1568f6928d5d4f38ca1919c6de6ec9bb
|
||||
+}
|
||||
diff --git a/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java b/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..99d00b6acd2302e06f70f75786e8928610592261
|
||||
index 0000000000000000000000000000000000000000..f5c6e823d7ab9a61307e27e7b859e76bdfdd1e58
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java
|
||||
@@ -0,0 +1,216 @@
|
||||
@@ -0,0 +1,222 @@
|
||||
+package org.leavesmc.leaves.replay;
|
||||
+
|
||||
+import com.mojang.authlib.GameProfile;
|
||||
@@ -1325,8 +1325,8 @@ index 0000000000000000000000000000000000000000..99d00b6acd2302e06f70f75786e89286
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import net.minecraft.stats.ServerStatsCounter;
|
||||
+import net.minecraft.world.damagesource.DamageSource;
|
||||
+import net.minecraft.world.level.GameType;
|
||||
+import net.minecraft.world.phys.Vec3;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
@@ -1342,8 +1342,6 @@ index 0000000000000000000000000000000000000000..99d00b6acd2302e06f70f75786e89286
|
||||
+import java.util.concurrent.CompletableFuture;
|
||||
+import java.util.concurrent.CopyOnWriteArrayList;
|
||||
+
|
||||
+import static org.leavesmc.leaves.bot.ServerBot.isCreateLegal;
|
||||
+
|
||||
+public class ServerPhotographer extends ServerPlayer {
|
||||
+
|
||||
+ private static final List<ServerPhotographer> photographers = new CopyOnWriteArrayList<>();
|
||||
@@ -1366,7 +1364,7 @@ index 0000000000000000000000000000000000000000..99d00b6acd2302e06f70f75786e89286
|
||||
+
|
||||
+ public static ServerPhotographer createPhotographer(@NotNull PhotographerCreateState state) throws IOException {
|
||||
+ if (!isCreateLegal(state.id)) {
|
||||
+ return null;
|
||||
+ throw new IllegalArgumentException(state.id + " is a invalid photographer id");
|
||||
+ }
|
||||
+
|
||||
+ MinecraftServer server = MinecraftServer.getServer();
|
||||
@@ -1453,7 +1451,7 @@ index 0000000000000000000000000000000000000000..99d00b6acd2302e06f70f75786e89286
|
||||
+
|
||||
+ LeavesLogger.LOGGER.info("Photographer " + createState.id + " removed");
|
||||
+
|
||||
+ if (save && !recorder.isSaved()) {
|
||||
+ if (!recorder.isSaved()) {
|
||||
+ CompletableFuture<Void> future = recorder.saveRecording(saveFile, save);
|
||||
+ if (!async) {
|
||||
+ future.join();
|
||||
@@ -1510,6 +1508,14 @@ index 0000000000000000000000000000000000000000..99d00b6acd2302e06f70f75786e89286
|
||||
+ return (CraftPhotographer) super.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isCreateLegal(@NotNull String name) {
|
||||
+ if (!name.matches("^[a-zA-Z0-9_]{4,16}$")) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return Bukkit.getPlayerExact(name) == null && ServerPhotographer.getPhotographer(name) == null;
|
||||
+ }
|
||||
+
|
||||
+ public static class PhotographerCreateState {
|
||||
+
|
||||
+ public RecorderOption option;
|
||||
|
||||
Reference in New Issue
Block a user