Add TraceScoreboardElement
Dieser Commit ist enthalten in:
Ursprung
47772ad23d
Commit
f69cbd2724
@ -479,8 +479,7 @@ TPSLIMIT_FROZEN = §eTPS frozen
|
||||
# Trace
|
||||
TRACE_RECORD=§aon
|
||||
TRACE_HAS_TRACES=§ehas Traces
|
||||
TRACE_IDLE_SINGLE=§esingle
|
||||
TRACE_IDLE_AUTO_IGNITE=§eauto
|
||||
TRACE_IDLE_AUTO=§eauto
|
||||
TRACE_MESSAGE_START = §aTNT-Tracer started
|
||||
TRACE_MESSAGE_STOP = §cTNT-Tracer stopped
|
||||
TRACE_MESSAGE_CLEAR=§cAll TNT-positions deleted
|
||||
|
@ -448,9 +448,6 @@ TPSLIMIT_FROZEN = §eTPS eingefroren.
|
||||
# Trace
|
||||
TRACE_RECORD=§aan
|
||||
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_DELETE_INVALID = §cAuto delete kann aktuell nicht genutzt werden
|
||||
TRACE_MESSAGE_AUTO_DELETE_ALWAYS = §7Der letzte Schuss wird §eimmer§7 gelöscht
|
||||
|
@ -176,6 +176,14 @@ public class TraceRecorder implements Listener {
|
||||
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.
|
||||
* Registers newly spawned TNT to be traced if reqired
|
||||
|
@ -91,5 +91,9 @@ public class TraceRecordingWrapper {
|
||||
protected void finalizeRecording() {
|
||||
recordsOutputStream.flush();
|
||||
recordsOutputStream.close();
|
||||
|
||||
if (trace.getRecords().isEmpty()) {
|
||||
TraceManager.instance.remove(trace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren