Add trace replay loop
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
b0690d28d3
Commit
5e9b11d140
@ -707,10 +707,11 @@ TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Shows all
|
||||
TRACE_COMMAND_HELP_HIDE = §8/§etrace hide §8- §7Hides all TNT-positions
|
||||
TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Deletes all TNT-positions
|
||||
TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Shows the Trace GUI
|
||||
TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8[§7Tick§8] §8- §7Replays your recording
|
||||
TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8[§7tick§8] §8- §7Replays your recording
|
||||
TRACE_COMMAND_HELP_REPLAY_DISABLE = §8/§etrace replay disable §8- §7Stops the replay
|
||||
TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8[§7Step§8] §8- §7Jump one§8/§7step tick forward
|
||||
TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8[§7Step§8] §8- §7Jump one§8/§7step tick back
|
||||
TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8[§7step§8] §8- §7Jump one§8/§7step tick forward
|
||||
TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8[§7step§8] §8- §7Jump one§8/§7step tick back
|
||||
TRACE_COMMAND_HELP_REPLAY_LOOP = §8/§etrace replay loop §8<§7start§8> §8<§7end§8> §8[§7speed§8] §8- §7Loop the replay
|
||||
|
||||
TRACE_GUI_ITEM_NAME = §eTracer
|
||||
TRACE_GUI_ITEM_LORE = §7Status§8: {0}
|
||||
|
@ -687,10 +687,11 @@ TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Zeigt alle
|
||||
TRACE_COMMAND_HELP_HIDE = §8/§etrace hide §8- §7Versteckt alle TNT-Positionen
|
||||
TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Löscht alle TNT-Positionen
|
||||
TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Zeigt die Trace Oberfläche an
|
||||
TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8- §7Replayes die Aufnahme
|
||||
TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8[§7Tick§8] §8- §7Replayes die Aufnahme
|
||||
TRACE_COMMAND_HELP_REPLAY_DISABLE = §8/§etrace replay disable §8- §7Stoppt das Replay
|
||||
TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8- §7Springe einen§8/§7step Tick vor
|
||||
TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8- §7Springe einen§8/§7step Tick zurück
|
||||
TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8[§7Step§8] §8- §7Springe einen§8/§7step Tick vor
|
||||
TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8[§7Step§8] §8- §7Springe einen§8/§7step Tick zurück
|
||||
TRACE_COMMAND_HELP_REPLAY_LOOP = §8/§etrace replay loop §8<§7start§8> §8<§7end§8> §8[§7speed§8] §8- §7Spielt die Aufnahme in einer Schleife ab
|
||||
|
||||
TRACE_GUI_ITEM_NAME = §eTracer
|
||||
TRACE_GUI_ITEM_LORE = §7Status§8: {0}
|
||||
|
@ -165,6 +165,48 @@ public class TraceCommand extends SWCommand {
|
||||
StoredRecords.setReplayTime(region, p, replayTick);
|
||||
}
|
||||
|
||||
@Register(value = {"replay", "loop"}, description = "TRACE_COMMAND_HELP_REPLAY_LOOP")
|
||||
public void replayLoop(@Validator Player p, int start, int end, @OptionalValue("0") int speed) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
|
||||
if (start < 0) start = 0;
|
||||
if (end < 0) end = 0;
|
||||
|
||||
int initial = StoredRecords.getReplayTime(region, p);
|
||||
if (!(Math.min(start, end) < initial && Math.max(start, end) > initial)) {
|
||||
initial = start;
|
||||
}
|
||||
int finalInitial = initial;
|
||||
|
||||
int finalStart = start;
|
||||
int finalEnd = end;
|
||||
Supplier<Integer> supplier = new Supplier<Integer>() {
|
||||
int temp = speed;
|
||||
int current = finalInitial;
|
||||
|
||||
@Override
|
||||
public Integer get() {
|
||||
if (temp-- > 0) {
|
||||
return current;
|
||||
}
|
||||
temp = speed;
|
||||
if (finalEnd > finalStart) {
|
||||
current++;
|
||||
if (current > finalEnd) {
|
||||
current = finalStart;
|
||||
}
|
||||
} else {
|
||||
current--;
|
||||
if (current < finalEnd) {
|
||||
current = finalStart;
|
||||
}
|
||||
}
|
||||
return current;
|
||||
}
|
||||
};
|
||||
StoredRecords.setReplayLoop(region, p, supplier);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
private enum ShowModeType {
|
||||
ENTITY(TraceEntityShowMode::new, new ShowModeParameterType[]{}),
|
||||
|
@ -19,15 +19,18 @@
|
||||
|
||||
package de.steamwar.bausystem.features.tracer.show;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tracer.TNTPosition;
|
||||
import de.steamwar.bausystem.features.tracer.record.Recorder;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.shared.ShowMode;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@UtilityClass
|
||||
@ -35,8 +38,21 @@ public class StoredRecords {
|
||||
|
||||
private static final Map<Region, Map<Player, List<Record.TNTRecord>>> isolatedTNT = new HashMap<>();
|
||||
private static final Map<Region, Map<Player, Integer>> replayTime = new HashMap<>();
|
||||
private static final Map<Region, Map<Player, Supplier<Integer>>> replayLoops = new HashMap<>();
|
||||
private static final Map<Region, List<Record>> records = new HashMap<>();
|
||||
|
||||
static {
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
replayLoops.forEach((region, playerSupplierMap) -> {
|
||||
playerSupplierMap.forEach((player, integerSupplier) -> {
|
||||
int tick = integerSupplier.get();
|
||||
replayTime.computeIfAbsent(region, __ -> new HashMap<>()).put(player, tick);
|
||||
TraceShowManager.reshow(region, player);
|
||||
});
|
||||
});
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
public static void add(Region region, Record record) {
|
||||
records.computeIfAbsent(region, k -> new ArrayList<>()).add(record);
|
||||
}
|
||||
@ -107,15 +123,19 @@ public class StoredRecords {
|
||||
|
||||
public static void removeReplayTime(Region region) {
|
||||
replayTime.remove(region);
|
||||
replayLoops.remove(region);
|
||||
}
|
||||
|
||||
public static void removeReplayTime(Region region, Player player) {
|
||||
Map<Player, Integer> regionalReplayTime = replayTime.get(region);
|
||||
if (regionalReplayTime == null) {
|
||||
return;
|
||||
}
|
||||
if (regionalReplayTime != null) {
|
||||
regionalReplayTime.remove(player);
|
||||
}
|
||||
Map<Player, Supplier<Integer>> regionalReplayLoops = replayLoops.get(region);
|
||||
if (regionalReplayLoops != null) {
|
||||
regionalReplayLoops.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setReplayTime(Region region, Player player, int time) {
|
||||
if (time < 0) {
|
||||
@ -124,6 +144,15 @@ public class StoredRecords {
|
||||
}
|
||||
replayTime.computeIfAbsent(region, k -> new HashMap<>()).put(player, time);
|
||||
TraceShowManager.reshow(region, player);
|
||||
|
||||
Map<Player, Supplier<Integer>> regionalReplayLoops = replayLoops.get(region);
|
||||
if (regionalReplayLoops != null) {
|
||||
regionalReplayLoops.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setReplayLoop(Region region, Player player, Supplier<Integer> loop) {
|
||||
replayLoops.computeIfAbsent(region, k -> new HashMap<>()).put(player, loop);
|
||||
}
|
||||
|
||||
static void show(Region region, Player player, ShowMode<TNTPosition> traceShowMode) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren