SteamWar/BauSystem2.0
Archiviert
12
0

Added at-Flag
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
D4rkr34lm 2024-03-30 16:09:06 +01:00
Ursprung 987a00ae51
Commit 870578dcf9
3 geänderte Dateien mit 95 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -23,12 +23,14 @@ import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.features.tracer.rendering.BundleFilter;
import de.steamwar.bausystem.features.tracer.rendering.TraceEntity;
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
import de.steamwar.bausystem.features.tracer.rendering.dynamicFlags.AtFlag;
import de.steamwar.bausystem.features.tracer.rendering.dynamicFlags.IsolateFlag;
import de.steamwar.bausystem.region.Region;
import de.steamwar.entity.REntityServer;
import lombok.Getter;
import org.bukkit.entity.Player;
import java.lang.reflect.Array;
import java.util.*;
import java.util.stream.Stream;
@ -247,6 +249,36 @@ public class Trace {
return bundles;
}
/** Modifies the render for the given player, to only show tnts at the given time interval
*
* @param player
* @param from start of time interval
* @param to end of time interval
*/
public void renderAt(Player player, int from, int to){
ViewFlag[] viewFlags = viewFlagMap.get(player);
if(viewFlags == null) return;
AtFlag atFlag = null;
atFlag = Stream.of(viewFlags)
.filter(AtFlag.class::isInstance)
.map(AtFlag.class::cast)
.findFirst()
.orElse(null);
if(atFlag != null){
atFlag.update(from, to);
}
else {
atFlag = new AtFlag(from, to);
viewFlags = Arrays.copyOf(viewFlags, viewFlags.length + 1);
viewFlags[viewFlags.length - 1] = atFlag;
}
render(player, viewFlags, BundleFilter.STRICT);
}
/** Toggles the isolated render for the given records and player
*
* @param player the player the trace is shown to

Datei anzeigen

@ -0,0 +1,60 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.tracer.rendering.dynamicFlags;
import de.steamwar.bausystem.features.tracer.TNTRecord;
import de.steamwar.bausystem.features.tracer.rendering.TraceEntity;
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
import de.steamwar.entity.REntityServer;
import java.util.List;
import java.util.stream.Collectors;
public class AtFlag extends ViewFlag {
private int start;
private int end;
public AtFlag(int start, int end){
super(false, false, ViewFlag.IGNITE, null);
this.start = start;
this.end = end;
}
/** Update this flag to represent another time interval
*
* @param start new interval start
* @param end new interval end
*/
public void update(int start, int end){
this.start = start;
this.end = end;
}
@Override
public List<TNTRecord> filter(List<TNTRecord> records) {
return records.stream()
.filter(record -> record.getTicksSinceStart() <= start && record.getTicksSinceStart() >= end)
.collect(Collectors.toList());
}
@Override
public void modify(REntityServer server, List<TraceEntity> entities) {}
}

Datei anzeigen

@ -32,6 +32,9 @@ import java.util.stream.Collectors;
public class IsolateFlag extends ViewFlag {
/**
* Tnt ids that will be isolated
*/
private final Set<Integer> tntToIsolate = new HashSet<>();
public IsolateFlag(){