SteamWar/BauSystem2.0
Archiviert
12
0

Trace Refactor #233

Zusammengeführt
YoyoNow hat 121 Commits von TracerGUI nach master 2024-04-21 16:03:26 +02:00 zusammengeführt
5 geänderte Dateien mit 73 neuen und 5 gelöschten Zeilen
Nur Änderungen aus Commit f69cbd2724 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -479,8 +479,7 @@ TPSLIMIT_FROZEN = §eTPS frozen
# Trace # Trace
TRACE_RECORD=§aon TRACE_RECORD=§aon
TRACE_HAS_TRACES=§ehas Traces TRACE_HAS_TRACES=§ehas Traces
TRACE_IDLE_SINGLE=§esingle TRACE_IDLE_AUTO=§eauto
TRACE_IDLE_AUTO_IGNITE=§eauto
TRACE_MESSAGE_START = §aTNT-Tracer started TRACE_MESSAGE_START = §aTNT-Tracer started
TRACE_MESSAGE_STOP = §cTNT-Tracer stopped TRACE_MESSAGE_STOP = §cTNT-Tracer stopped
TRACE_MESSAGE_CLEAR=§cAll TNT-positions deleted TRACE_MESSAGE_CLEAR=§cAll TNT-positions deleted

Datei anzeigen

@ -448,9 +448,6 @@ TPSLIMIT_FROZEN = §eTPS eingefroren.
# Trace # Trace
TRACE_RECORD=§aan TRACE_RECORD=§aan
TRACE_HAS_TRACES=§ehat Traces TRACE_HAS_TRACES=§ehat Traces
TRACE_IDLE_SINGLE=§esingle
TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8)
TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8)
TRACE_MESSAGE_AUTO_IDLE_IGNITE = §aAuto-Tracer ignite gestartet TRACE_MESSAGE_AUTO_IDLE_IGNITE = §aAuto-Tracer ignite gestartet
TRACE_MESSAGE_AUTO_DELETE_INVALID = §cAuto delete kann aktuell nicht genutzt werden TRACE_MESSAGE_AUTO_DELETE_INVALID = §cAuto delete kann aktuell nicht genutzt werden
TRACE_MESSAGE_AUTO_DELETE_ALWAYS = §7Der letzte Schuss wird §eimmer§7 gelöscht TRACE_MESSAGE_AUTO_DELETE_ALWAYS = §7Der letzte Schuss wird §eimmer§7 gelöscht

Datei anzeigen

@ -176,6 +176,14 @@ public class TraceRecorder implements Listener {
return record; return record;
} }
public boolean isAutoTraceEnabledInRegion(Region region) {
return autoTraceRegions.contains(region);
}
public boolean isTraceActiveInRegion(Region region) {
return activeTraces.containsKey(region);
}
/** /**
* Event for TNTs beeing spawn. * Event for TNTs beeing spawn.
* Registers newly spawned TNT to be traced if reqired * Registers newly spawned TNT to be traced if reqired

Datei anzeigen

@ -91,5 +91,9 @@ public class TraceRecordingWrapper {
protected void finalizeRecording() { protected void finalizeRecording() {
recordsOutputStream.flush(); recordsOutputStream.flush();
recordsOutputStream.close(); recordsOutputStream.close();
if (trace.getRecords().isEmpty()) {
TraceManager.instance.remove(trace);
}
} }
} }

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;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
import java.util.Collection;
@Linked
public class TraceScoreboardElement implements ScoreboardElement {
@Override
public ScoreboardGroup getGroup() {
return ScoreboardGroup.OTHER;
}
@Override
public int order() {
return 1;
}
@Override
public String get(Region region, Player p) {
if (!Permission.BUILD.hasPermission(p)) return null;
if (TraceRecorder.instance.isTraceActiveInRegion(region)) {
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse("TRACE_RECORD", p);
} else if (TraceRecorder.instance.isAutoTraceEnabledInRegion(region)) {
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse("TRACE_IDLE_AUTO", p);
}
Collection<Trace> traces = TraceManager.instance.get(region);
if (traces.isEmpty()) {
return null;
} else {
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse("TRACE_HAS_TRACES", p);
}
}
}