forked from SteamWar/SteamWar
Merge branch 'main' of https://git.steamwar.de/SteamWar/SteamWar
This commit is contained in:
+11
-1
@@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
|
||||
import com.destroystokyo.paper.event.server.ServerTickEndEvent;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
@@ -77,8 +78,16 @@ public class SimulatorCursor implements Listener {
|
||||
return isSimulatorItem(player.getInventory().getItemInMainHand()) || isSimulatorItem(player.getInventory().getItemInOffHand());
|
||||
}
|
||||
|
||||
private static Set<Player> scheduledUpdates = new HashSet<>();
|
||||
|
||||
private static void scheduleCursorUpdate(Player player) {
|
||||
BauSystem.runTaskLater(BauSystem.getInstance(), () -> calcCursor(player), 1);
|
||||
scheduledUpdates.add(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerTickEnd(ServerTickEndEvent event) {
|
||||
scheduledUpdates.forEach(SimulatorCursor::calcCursor);
|
||||
scheduledUpdates.clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -122,6 +131,7 @@ public class SimulatorCursor implements Listener {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
cursorType.remove(event.getPlayer());
|
||||
removeCursor(event.getPlayer());
|
||||
scheduledUpdates.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
private static final Map<Player, Long> LAST_SNEAKS = new HashMap<>();
|
||||
|
||||
+5
-1
@@ -153,7 +153,11 @@ public class TraceCommand extends SWCommand {
|
||||
|
||||
@Register(value = "isolate", description = "TRACE_COMMAND_HELP_ISOLATE")
|
||||
public void isolate(@Validator Player player, Trace trace, @ErrorMessage("TRACE_RECORD_ID_INVALID") TNTPoint... records) {
|
||||
TraceManager.instance.isolate(player, records);
|
||||
if (records.length == 0) {
|
||||
TraceManager.instance.isolate(player, trace, trace.getRecords().toArray(TNTPoint[]::new));
|
||||
} else {
|
||||
TraceManager.instance.isolate(player, trace, records);
|
||||
}
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_ISOLATE", player);
|
||||
}
|
||||
|
||||
|
||||
+11
-2
@@ -347,9 +347,10 @@ public class TraceManager implements Listener {
|
||||
* Toggles the isolated render for the given records and player
|
||||
*
|
||||
* @param player the player the trace is shown to
|
||||
* @param records the record for which isolation is toggled
|
||||
* @param ptrace the trace for whitch isolation is toggled
|
||||
* @param records the records of the trace for which isolation is toggled
|
||||
*/
|
||||
public void isolate(Player player, TNTPoint... records) {
|
||||
public void isolate(Player player, Trace ptrace, TNTPoint... records) {
|
||||
unfollow(player);
|
||||
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
@@ -374,12 +375,20 @@ public class TraceManager implements Listener {
|
||||
isolateFlag.toggleId(record.getTntId());
|
||||
}
|
||||
|
||||
if (isolateFlag.isEmpty() && playerTraceShowData.hasViewFlagOnly(IsolateFlag.class) && records.length != 0) {
|
||||
playerTraceShowData.removeViewFlag(IsolateFlag.class);
|
||||
}
|
||||
|
||||
PlayerTraceShowData finalPlayerTraceShowData = playerTraceShowData;
|
||||
tracesByRegion.getOrDefault(region, Collections.emptyMap()).forEach((integer, trace) -> {
|
||||
if (trace.getUuid() == ptrace.getUuid() || finalPlayerTraceShowData.hasNoViewFlags()) {
|
||||
trace.render(player, finalPlayerTraceShowData);
|
||||
followerMap.getOrDefault(player, Collections.emptySet()).forEach(follower -> {
|
||||
trace.render(follower, finalPlayerTraceShowData);
|
||||
});
|
||||
} else {
|
||||
trace.hide(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -135,6 +135,13 @@ public class TraceRecorder implements Listener {
|
||||
Iterator<TNTPrimed> iter = trackedTNT.getOrDefault(region, Collections.emptyList()).iterator();
|
||||
while (iter.hasNext()) {
|
||||
TNTPrimed tnt = iter.next();
|
||||
if (tnt.isDead()) {
|
||||
iter.remove();
|
||||
tntSpawnRegion.remove(tnt);
|
||||
historyMap.remove(tnt);
|
||||
tntSpawnRegion.remove(tnt);
|
||||
continue;
|
||||
}
|
||||
if (tnt.getFuseTicks() == 80) continue;
|
||||
TNTPoint record = record(tnt, wrappedTrace, Collections.emptyList());
|
||||
if (record == null) {
|
||||
|
||||
+4
@@ -95,4 +95,8 @@ public class PlayerTraceShowData {
|
||||
public void addViewFlag(ViewFlag viewFlag) {
|
||||
viewFlags.put(viewFlag.getClass(), viewFlag);
|
||||
}
|
||||
|
||||
public <T extends ViewFlag> void removeViewFlag(Class<T> clazz) {
|
||||
viewFlags.remove(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -51,6 +51,10 @@ public class IsolateFlag extends ViewFlag {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return tntToIsolate.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<TNTPoint> filter(Stream<TNTPoint> records) {
|
||||
if (tntToIsolate.isEmpty()) return records;
|
||||
|
||||
@@ -929,6 +929,13 @@ public final class GameModeConfig<M, W> {
|
||||
*/
|
||||
public final boolean PersonalKits;
|
||||
|
||||
/**
|
||||
* Maximal blast resistance for the blocks in the kit
|
||||
*
|
||||
* @implSpec {@code 9.0} by default
|
||||
*/
|
||||
public final double MaxBlastResistance;
|
||||
|
||||
/**
|
||||
* Items (Valid spigot material values) that are not allowed in the personal kit
|
||||
*/
|
||||
@@ -940,7 +947,10 @@ public final class GameModeConfig<M, W> {
|
||||
MemberDefault = loader.getString("MemberDefault", "default");
|
||||
LeaderDefault = loader.getString("LeaderDefault", "default");
|
||||
PersonalKits = loader.getBoolean("PersonalKits", false);
|
||||
ForbiddenItems = loader.getMaterialList("ForbiddenItems");
|
||||
MaxBlastResistance = loader.getDouble("MaxBlastResistance", 9.0);
|
||||
List forbiddenItems = new ArrayList<>(loader.getMaterialList("ForbiddenItems"));
|
||||
forbiddenItems.addAll(SQLWrapper.impl.getMaterialWithGreaterBlastResistance(MaxBlastResistance));
|
||||
ForbiddenItems = Collections.unmodifiableList(forbiddenItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user