SteamWar/BauSystem2.0
Archiviert
12
0
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-10-03 17:01:43 +02:00
Ursprung 1e1d8d718a
Commit 399c86aa6d
41 geänderte Dateien mit 856 neuen und 1193 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,6 @@ public class SimulatorPreview15 implements SimulatorPreview {
@Override
public Record simulate(TNTSimulator tntSimulator) {
return new Record(false);
return new Record(null);
}
}

Datei anzeigen

@ -118,11 +118,6 @@ public class NMSWrapper15 implements NMSWrapper {
((CraftPlayer) player).getHandle().abilities.canInstantlyBuild = true;
}
@Override
public Particle tntPositionParticle() {
return Particle.BARRIER;
}
@Override
public Material pathMaterial() {
return Material.GRASS_PATH;

Datei anzeigen

@ -123,11 +123,6 @@ public class NMSWrapper18 implements NMSWrapper {
((CraftPlayer) player).getHandle().fs().e = true;
}
@Override
public Particle tntPositionParticle() {
return Particle.BLOCK_MARKER;
}
@Override
public Material pathMaterial() {
return Material.DIRT_PATH;

Datei anzeigen

@ -39,7 +39,7 @@ public class SimulatorPreview19 implements SimulatorPreview {
@Override
public Record simulate(TNTSimulator tntSimulator) {
if (true) {
return new Record(false);
return new Record(null);
}
Map<Integer, Map<Integer, Set<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> result = new HashMap<>();
@ -66,11 +66,11 @@ public class SimulatorPreview19 implements SimulatorPreview {
}
});
if (tntCount.get() > 500) {
return new Record(false);
return new Record(null);
}
List<FakeTNT19> fakeTNT19s = new ArrayList<>();
Record record = new Record(false);
Record record = new Record(null);
Map<FakeTNT19, Record.TNTRecord> tntRecords = new HashMap<>();
int maxTickToCalc = maxTick.get() + 160;
@ -120,11 +120,11 @@ public class SimulatorPreview19 implements SimulatorPreview {
fakeTNT19.k(spawnList);
TNTPrimed tntPrimed = ((TNTPrimed) (fakeTNT19.getBukkitEntity()));
if (tntPrimed.getFuseTicks() <= 0) {
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn()).explode(tntPrimed);
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed);
fakeTNT19s.remove(i);
i--;
} else {
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn()).explode(tntPrimed);
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed);
}
if (!spawnList.isEmpty()) {
fakeTNT19s.addAll(i, spawnList);

Datei anzeigen

@ -123,11 +123,6 @@ public class NMSWrapper19 implements NMSWrapper {
((CraftPlayer) player).getHandle().fB().e = true;
}
@Override
public Particle tntPositionParticle() {
return Particle.BLOCK_MARKER;
}
@Override
public Material pathMaterial() {
return Material.DIRT_PATH;

Datei anzeigen

@ -681,15 +681,11 @@ TPSLIMIT_INVALID_FROZEN = §c and '0'
# Trace
TRACE_RECORD=§aon
TRACE_RECORD_AUTO=§aon
TRACE_RECORD_SINGLE=§aon
TRACE_IDLE=§coff
TRACE_IDLE_AUTO=§eauto
TRACE_IDLE_SINGLE=§esingle
TRACE_MESSAGE_AUTO_RECORD=§cTNT-Tracer must be stopped
TRACE_MESSAGE_AUTO_RECORD_AUTO=§cTNT-Tracer is not allowed to record
TRACE_MESSAGE_AUTO_IDLE=§cAuto-Tracer stopped
TRACE_MESSAGE_AUTO_IDLE_AUTO = §aAuto-Tracer started
TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8)
TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8)
TRACE_MESSAGE_AUTO_IDLE_EXPLODE = §aAuto-Tracer explode started
TRACE_MESSAGE_AUTO_IDLE_IGNITE = §aAuto-Tracer ignite started
TRACE_MESSAGE_START = §aTNT-Tracer started
TRACE_MESSAGE_SINGLE = §aSingle-Tracer started
TRACE_MESSAGE_STOP = §cTNT-Tracer stopped
@ -700,16 +696,15 @@ TRACE_MESSAGE_ISOLATE = §aTNT-positions isolated
TRACE_MESSAGE_UNISOLATE = §cTNT-positions hidden
TRACE_MESSAGE_CLICK_ISOLATE = §eClick to §aisolate§8/§cunisolate
TRACE_MESSAGE_DISALLOWED = §cYou are not allowed to use the TNT-Tracer here
TRACE_MESSAGE_NO_REGION = §cYou are not in a region
TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Starts recording of all TNT-positions
TRACE_COMMAND_HELP_SINGLE = §8/§etrace single §8- §7Starts a single recording of all TNT-positions
TRACE_COMMAND_HELP_STOP = §8/§etrace stop §8- §7Stops the TNT-Tracer
TRACE_COMMAND_HELP_AUTO = §8/§etrace toggleauto §8- §7Automatic start of recording
TRACE_COMMAND_HELP_SHOW_GUI = §8/§etrace show gui §8- §7Shows the trace GUI
TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Shows all TNT-positions
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_LIST = §8/§etrace list §8- §7Trace GUI but in the Chat
TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Shows the Trace GUI
TRACE_GUI_ITEM_NAME = §eTracer
@ -720,22 +715,8 @@ TRACE_GUI_TRACE_ACTIVE = §eStop Tracer
TRACE_GUI_TRACE_ACTIVE_AUTO = §eAuto-Trace is active
TRACE_GUI_AUTO_TRACE_INACTIVE = §eacitvate Auto-Tracer
TRACE_GUI_AUTO_TRACE_ACTIVE = §edeactivate Auto-Tracer
TRACE_GUI_SHOW_GUI = §eTrace Show Gui
TRACE_GUI_DELETE = §eDelete trace
TRACE_SHOW_GUI_TITLE = Trace Show GUI
TRACE_SHOW_GUI_SHOWN = §aTraces shown
TRACE_SHOW_GUI_HIDDEN = §cTraces hidden
TRACE_SHOW_GUI_WATER_ITEM = §eWater §7positions
TRACE_SHOW_GUI_WATER_LORE1 = §7Shows all TNT which
TRACE_SHOW_GUI_WATER_LORE2 = §7exploded in water.
TRACE_SHOW_GUI_INTERPOLATE_Y_ITEM = §eInterpolation §7Y-Axis
TRACE_SHOW_GUI_INTERPOLATE_Y_LORE1 = §7Shows the interpolation
TRACE_SHOW_GUI_INTERPOLATE_Y_LORE2 = §7on the Y-Axis.
TRACE_SHOW_GUI_INTERPOLATE_XZ_ITEM = §eInterpolation §7XZ-Achsis
TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE1 = §7Shows the interpolation
TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE2 = §7ont the XZ-Achsis.
TRACE_GUI_TITLE = Trace GUI
TRACE_GUI_ITEM_BACK = §eBack
TRACE_GUI_ITEM = §eTrace §8- §e{0} §7TNT
@ -746,29 +727,9 @@ TRACE_GUI_POSITION_ITEM = §ePosition
TRACE_GUI_POSITION_X = §7X§8: §e{0}
TRACE_GUI_POSITION_Y = §7Y§8: §e{0}
TRACE_GUI_POSITION_Z = §7Z§8: §e{0}
TRACE_GUI_POSITION_SOURCE = §7Source§8: §e{0}
TRACE_GUI_POSITION_EXPLODED = §7Exploded§8: §e{0}
TRACE_RECORD_LIST_ELEMENT = §eTrace §8- §e{0} §7TNT
TRACE_RECORD_LIST_ELEMENT_HOVER = §7Shows all §eTNT §7from this trace
TRACE_RECORD_LIST_ELEMENT_DELETE = §7 §cDelete
TRACE_RECORD_LIST_ELEMENT_DELETE_HOVER = §cDelete §7trace
TRACE_RECORD_DELETE = §7Trace deleted
TRACE_RECORD_NOT_FOUND = §7Unknown trace
TRACE_RECORD_ELEMENT = §eTNT §8- §e{0} §7Positions
TRACE_RECORD_ELEMENT_HOVER = §7Shows all §ePositions §7from this TNT
TRACE_RECORD_ELEMENT_DELETE = §7 §cDelete
TRACE_RECORD_ELEMENT_DELETE_HOVER = §cDelete §7trace
TRACE_RECORD_TNT_NOT_FOUND = §7Unknown TNT
TRACE_TNT_ELEMENT = §ePosition §8- §e{0} §7FuseTicks
TRACE_TNT_DELETE = §7TNT deleted
TRACE_TNT_ELEMENT_HOVER = §7Shows information on the §ePosition
TRACE_RECORD_TNT_POSITION_NOT_FOUND = §7Unknown TNT Position
TRACE_CHAT_POSITION_HEAD = §ePosition
TRACE_CHAT_POSITION_X = §7X§8: §e{0}
TRACE_CHAT_POSITION_Y = §7Y§8: §e{0}
TRACE_CHAT_POSITION_Z = §7Z§8: §e{0}
TRACE_CHAT_POSITION_EXPLODED = §7Exploded§8: §e{0}
# Loader
LOADER_OFF = §coff
LOADER_SETUP = §eSetup

Datei anzeigen

@ -661,15 +661,11 @@ TPSLIMIT_INVALID_FROZEN = §c und '0'
# Trace
TRACE_RECORD=§aan
TRACE_RECORD_AUTO=§aan
TRACE_RECORD_SINGLE=§aan
TRACE_IDLE=§caus
TRACE_IDLE_AUTO=§eauto
TRACE_IDLE_SINGLE=§esingle
TRACE_MESSAGE_AUTO_RECORD=§cTNT-Tracer muss gestoppt werden
TRACE_MESSAGE_AUTO_RECORD_AUTO=§cTNT-Tracer darf nicht aufnehmen
TRACE_MESSAGE_AUTO_IDLE=§cAuto-Tracer gestoppt
TRACE_MESSAGE_AUTO_IDLE_AUTO = §aAuto-Tracer gestartet
TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8)
TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8)
TRACE_MESSAGE_AUTO_IDLE_EXPLODE = §aAuto-Tracer explode gestartet
TRACE_MESSAGE_AUTO_IDLE_IGNITE = §aAuto-Tracer ignite gestartet
TRACE_MESSAGE_START = §aTNT-Tracer gestartet
TRACE_MESSAGE_SINGLE = §aSingle-Tracer gestartet
TRACE_MESSAGE_STOP = §cTNT-Tracer gestoppt
@ -680,16 +676,15 @@ TRACE_MESSAGE_ISOLATE = §aTNT-Positionen isoliert
TRACE_MESSAGE_UNISOLATE = §cTNT-Positionen ausgeblendet
TRACE_MESSAGE_CLICK_ISOLATE = §eKlicken zum §aisolieren§8/§causblenden
TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen
TRACE_MESSAGE_NO_REGION = §cDu bist in keiner Region
TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen
TRACE_COMMAND_HELP_SINGLE = §8/§etrace single §8- §7Startet eine einzelne Aufnahme aller TNT-Positionen
TRACE_COMMAND_HELP_STOP = §8/§etrace stop §8- §7Stoppt den TNT-Tracer
TRACE_COMMAND_HELP_AUTO = §8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart
TRACE_COMMAND_HELP_SHOW_GUI = §8/§etrace show gui §8- §7Zeigt die Trace show gui
TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Zeigt alle TNT-Positionen
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_LIST = §8/§etrace list §8- §7Trace GUI nur im Chat
TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Zeigt die Trace Oberfläche an
TRACE_GUI_ITEM_NAME = §eTracer
@ -700,22 +695,8 @@ TRACE_GUI_TRACE_ACTIVE = §eTracer Stoppen
TRACE_GUI_TRACE_ACTIVE_AUTO = §eAuto-Trace ist Aktiv
TRACE_GUI_AUTO_TRACE_INACTIVE = §eAuto-Tracer Aktivieren
TRACE_GUI_AUTO_TRACE_ACTIVE = §eAuto-Tracer Deaktivieren
TRACE_GUI_SHOW_GUI = §eTrace Show Gui
TRACE_GUI_DELETE = §eTrace Löschen
TRACE_SHOW_GUI_TITLE = Trace Show GUI
TRACE_SHOW_GUI_SHOWN = §aTraces angezeigt
TRACE_SHOW_GUI_HIDDEN = §cTraces ausgeblendet
TRACE_SHOW_GUI_WATER_ITEM = §eWasser §7Positionen
TRACE_SHOW_GUI_WATER_LORE1 = §7Zeigt alles TNT, welches
TRACE_SHOW_GUI_WATER_LORE2 = §7im Wasser explodiert ist.
TRACE_SHOW_GUI_INTERPOLATE_Y_ITEM = §eInterpolation §7Y-Achse
TRACE_SHOW_GUI_INTERPOLATE_Y_LORE1 = §7Zeigt die Interpolation
TRACE_SHOW_GUI_INTERPOLATE_Y_LORE2 = §7auf der Y-Achse.
TRACE_SHOW_GUI_INTERPOLATE_XZ_ITEM = §eInterpolation §7XZ-Achse
TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE1 = §7Zeigt die Interpolation
TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE2 = §7auf der XZ-Achse.
TRACE_GUI_TITLE = Trace GUI
TRACE_GUI_ITEM_BACK = §eBack
TRACE_GUI_ITEM = §eTrace §8- §e{0} §7TNT
@ -726,29 +707,9 @@ TRACE_GUI_POSITION_ITEM = §ePosition
TRACE_GUI_POSITION_X = §7X§8: §e{0}
TRACE_GUI_POSITION_Y = §7Y§8: §e{0}
TRACE_GUI_POSITION_Z = §7Z§8: §e{0}
TRACE_GUI_POSITION_SOURCE = §7Ursprung§8: §e{0}
TRACE_GUI_POSITION_EXPLODED = §7Explodiert§8: §e{0}
TRACE_RECORD_LIST_ELEMENT = §eTrace §8- §e{0} §7TNT
TRACE_RECORD_LIST_ELEMENT_HOVER = §7Zeige alle §eTNT §7aus diesem Trace
TRACE_RECORD_LIST_ELEMENT_DELETE = §7 §cLöschen
TRACE_RECORD_LIST_ELEMENT_DELETE_HOVER = §7Trace §clöschen
TRACE_RECORD_DELETE = §7Trace gelöscht
TRACE_RECORD_NOT_FOUND = §7Unbekannter Trace
TRACE_RECORD_ELEMENT = §eTNT §8- §e{0} §7Positionen
TRACE_RECORD_ELEMENT_HOVER = §7Zeige alle §ePositionen §7aus diesem TNT
TRACE_RECORD_ELEMENT_DELETE = §7 §cLöschen
TRACE_RECORD_ELEMENT_DELETE_HOVER = §7Trace §clöschen
TRACE_RECORD_TNT_NOT_FOUND = §7Unbekanntes TNT
TRACE_TNT_ELEMENT = §ePosition §8- §e{0} §7FuseTicks
TRACE_TNT_DELETE = §7TNT gelöscht
TRACE_TNT_ELEMENT_HOVER = §7Zeige Infos zur §ePosition §7an
TRACE_RECORD_TNT_POSITION_NOT_FOUND = §7Unbekannte TNT Position
TRACE_CHAT_POSITION_HEAD = §ePosition
TRACE_CHAT_POSITION_X = §7X§8: §e{0}
TRACE_CHAT_POSITION_Y = §7Y§8: §e{0}
TRACE_CHAT_POSITION_Z = §7Z§8: §e{0}
TRACE_CHAT_POSITION_EXPLODED = §7Explodiert§8: §e{0}
# Loader
LOADER_OFF = §caus
LOADER_SETUP = §eEinrichtung

Datei anzeigen

@ -1,6 +1,8 @@
package de.steamwar.bausystem.features.script.variables;
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.features.tracer.record.ActiveTracer;
import de.steamwar.bausystem.features.tracer.record.AutoTraceRecorder;
import de.steamwar.bausystem.features.tracer.record.Recorder;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
@ -218,10 +220,18 @@ public class Constants {
static {
CONSTANTS.put("trace", player -> {
return new ConstantBooleanValue(RecordStateMachine.getRecordStatus()::isTracing);
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
return new ConstantBooleanValue(() -> false);
}
return new ConstantBooleanValue(() -> Recorder.INSTANCE.get(region) instanceof ActiveTracer);
});
CONSTANTS.put("autotrace", player -> {
return new ConstantBooleanValue(RecordStateMachine.getRecordStatus()::isAutoTrace);
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
return new ConstantBooleanValue(() -> false);
}
return new ConstantBooleanValue(() -> Recorder.INSTANCE.get(region) instanceof AutoTraceRecorder);
});
CONSTANTS.put("tnt", player -> {
return new ConstantBooleanValue(() -> Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class) != TNTMode.DENY);

Datei anzeigen

@ -22,11 +22,11 @@ package de.steamwar.bausystem.features.simulator;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.simulator.tnt.TNTElement;
import de.steamwar.bausystem.linkage.Disable;
import de.steamwar.bausystem.linkage.Enable;
import de.steamwar.bausystem.utils.ItemUtils;
import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.api.Disable;
import de.steamwar.linkage.api.Enable;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.Material;

Datei anzeigen

@ -27,7 +27,8 @@ import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode;
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
import de.steamwar.bausystem.features.simulator.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator.tnt.TNTGroup;
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.features.tracer.record.AutoExplodeTraceRecorder;
import de.steamwar.bausystem.features.tracer.record.Recorder;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.shared.Pair;
import lombok.Getter;
@ -228,13 +229,17 @@ public class TNTSimulator {
return;
}
AtomicBoolean needsAutoTrace = new AtomicBoolean();
playerShowMode.forEach((player, simulatorEntityShowMode) -> {
boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false);
if (simulatorAutoTrace) {
RecordStateMachine.commandSingle();
needsAutoTrace.set(true);
player.performCommand("trace show");
}
});
if (needsAutoTrace.get()) {
Recorder.INSTANCE.set(region, new AutoExplodeTraceRecorder());
}
AtomicInteger maxTick = new AtomicInteger(0);
Map<Integer, List<List<Pair<Runnable, Integer>>>> toSpawn = new HashMap<>();

Datei anzeigen

@ -22,11 +22,11 @@ package de.steamwar.bausystem.features.tpslimit;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.linkage.Enable;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.api.Enable;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2022 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

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2022 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
@ -53,15 +53,17 @@ public class TNTPosition extends Position {
private final Vector previousLocation;
private final Vector velocity;
private final CachingSupplier<Vector> updateVelocity;
private final boolean source;
private final boolean exploded;
public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, Vector velocity, CachingSupplier<Vector> updateVelocity, boolean exploded) {
public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, Vector velocity, CachingSupplier<Vector> updateVelocity, boolean source, boolean exploded) {
super(entity.getLocation().toVector());
this.record = record;
this.fuseTicks = entity.getFuseTicks();
this.previousLocation = previousLocation;
this.velocity = velocity;
this.updateVelocity = updateVelocity;
this.source = source;
this.exploded = exploded;
}

Datei anzeigen

@ -1,46 +1,45 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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/>.
*/
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.features.tracer.gui.TraceGui;
import de.steamwar.bausystem.features.tracer.gui.TraceShowGui;
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.features.tracer.show.Record;
import de.steamwar.bausystem.features.tracer.show.*;
import de.steamwar.bausystem.features.tracer.show.mode.BlockShowMode;
import de.steamwar.bausystem.features.tracer.show.mode.ParticleShowMode;
import de.steamwar.bausystem.features.tracer.record.AutoExplodeTraceRecorder;
import de.steamwar.bausystem.features.tracer.record.AutoIgniteTraceRecorder;
import de.steamwar.bausystem.features.tracer.record.Recorder;
import de.steamwar.bausystem.features.tracer.record.SimpleTraceRecorder;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameterType;
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
import de.steamwar.bausystem.features.tracer.show.mode.RawEntityShowMode;
import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.shared.ShowMode;
import de.steamwar.bausystem.utils.ListChatView;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.LinkedInstance;
import lombok.AllArgsConstructor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -56,6 +55,79 @@ public class TraceCommand extends SWCommand {
super("trace", "trail");
}
@LinkedInstance
public Recorder recorder;
@Register(value = {"start"}, description = "TRACE_COMMAND_HELP_START")
public void startCommand(@Validator Player p) {
Region region = Region.getRegion(p.getLocation());
recorder.set(region, new SimpleTraceRecorder());
BauSystem.MESSAGE.send("TRACE_MESSAGE_START", p);
}
@Register(value = {"stop"}, description = "TRACE_COMMAND_HELP_STOP")
public void stopCommand(@Validator Player p) {
Region region = Region.getRegion(p.getLocation());
recorder.remove(region);
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", p);
}
@Register(value = {"auto"}, description = "TRACE_COMMAND_HELP_AUTO")
@Register({"toggleauto"})
public void autoCommand(@Validator Player p, @OptionalValue("-explode") @StaticValue({"-explode", "-ignite"}) String type) {
Region region = Region.getRegion(p.getLocation());
switch (type) {
case "-explode":
recorder.set(region, new AutoExplodeTraceRecorder());
BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_IDLE_EXPLODE", p);
break;
case "-ignite":
recorder.set(region, new AutoIgniteTraceRecorder());
BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_IDLE_IGNITE", p);
break;
default:
break;
}
}
@Register(value = {"show"}, description = "TRACE_COMMAND_HELP_SHOW")
public void showCommand(@Validator Player p, @OptionalValue("entity") ShowModeType showModeType, ShowModeParameterType... showModeParameterTypes) {
ShowModeParameter showModeParameter = new ShowModeParameter();
for (ShowModeParameterType showModeParameterType : showModeParameterTypes) {
showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter);
}
TraceShowManager.show(p, showModeType.showModeBiFunction.apply(p, showModeParameter));
BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", p);
}
@Register(value = {"hide"}, description = "TRACE_COMMAND_HELP_HIDE")
public void hideCommand(@Validator Player p) {
TraceShowManager.hide(p);
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p);
}
@Register(value = {"delete"}, description = "TRACE_COMMAND_HELP_DELETE")
@Register({"clear"})
public void deleteCommand(@Validator Player p) {
Region region = Region.getRegion(p.getLocation());
StoredRecords.clear(region);
BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p);
}
@Register(value = {"gui"}, description = "TRACE_COMMAND_HELP_GUI")
public void guiCommand(@Validator Player p) {
TraceGui.openGui(p);
}
@AllArgsConstructor
private enum ShowModeType {
ENTITY(TraceEntityShowMode::new, new ShowModeParameterType[]{}),
RAW(RawEntityShowMode::new, new ShowModeParameterType[]{});
private BiFunction<Player, ShowModeParameter, ShowMode<TNTPosition>> showModeBiFunction;
private ShowModeParameterType[] removedTypes;
}
@ClassMapper(value = ShowModeParameterType.class, local = true)
public TypeMapper<ShowModeParameterType> showModeParameterTypesTypeMapper() {
Map<ShowModeParameterType, List<String>> showModeParameterTypeListMap = new EnumMap<>(ShowModeParameterType.class);
@ -104,215 +176,19 @@ public class TraceCommand extends SWCommand {
};
}
@Register(value = {"gui"}, description = "TRACE_COMMAND_HELP_GUI")
public void guiCommand(@Validator Player p) {
TraceGui.openGui(p);
}
@Register(value = {"record", "list"})
@Register(value = {"list"}, description = "TRACE_COMMAND_HELP_LIST")
public void listCommand(@Validator Player player, @OptionalValue("0") int page) {
ListChatView.chatView(player, StoredRecords.getRecords(), page, record -> {
TextComponent component = new TextComponent();
component.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT", player, record.size()));
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId()));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT_HOVER", player))));
TextComponent deleteComponent = new TextComponent();
deleteComponent.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT_DELETE", player));
deleteComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record delete " + record.getId()));
deleteComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT_DELETE_HOVER", player))));
component.addExtra(deleteComponent);
return component;
}, (beforePageComponent, beforePage) -> {
beforePageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_PREVIOUS_PAGE", player)).create()));
beforePageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record list " + beforePage));
}, (afterPageComponent, afterPage) -> {
afterPageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_NEXT_PAGE", player)).create()));
afterPageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record list " + afterPage));
});
}
@Register(value = {"record", "delete"}, noTabComplete = true)
public void recordDelete(@Validator Player p, int id) {
StoredRecords.remove(id);
BauSystem.MESSAGE.send("TRACE_RECORD_DELETE", p);
}
@Register(value = "record", noTabComplete = true)
public void recordList(@Validator Player player, int recordID, @OptionalValue("0") int page) {
Record traceRecord = StoredRecords.get(recordID);
if (traceRecord == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
return;
}
ListChatView.chatView(player, traceRecord.getTnt(), page, tntRecord -> {
TextComponent component = new TextComponent();
component.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT", player, tntRecord.getPositions().size()));
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + traceRecord.getId() + " tnt " + tntRecord.getId()));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT_HOVER", player))));
TextComponent deleteComponent = new TextComponent();
deleteComponent.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT_DELETE", player));
deleteComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record tnt delete " + traceRecord.getId() + " " + tntRecord.getId()));
deleteComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT_DELETE_HOVER", player))));
component.addExtra(deleteComponent);
return component;
}, (beforePageComponent, beforePage) -> {
beforePageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_PREVIOUS_PAGE", player)).create()));
beforePageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + traceRecord.getId() + " " + beforePage));
}, (afterPageComponent, afterPage) -> {
afterPageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_NEXT_PAGE", player)).create()));
afterPageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + traceRecord.getId() + " " + afterPage));
});
}
@Register(value = {"record", "tnt", "delete"}, noTabComplete = true)
public void deleteRecordTNT(@Validator Player player, int recordID, int tntID) {
Record record = StoredRecords.get(recordID);
if (record == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
return;
}
record.remove(tntID);
BauSystem.MESSAGE.send("TRACE_TNT_DELETE", player);
}
@Register(value = "record", noTabComplete = true)
public void recordTNTPositions(@Validator Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, @OptionalValue("0") int page) {
Record record = StoredRecords.get(recordID);
if (record == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
return;
}
Record.TNTRecord tntRecord = record.get(tntID);
if (tntRecord == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_TNT_NOT_FOUND", player);
return;
}
ListChatView.chatView(player, tntRecord.getPositions(), page, tntPosition -> {
TextComponent component = new TextComponent();
component.setText(BauSystem.MESSAGE.parse("TRACE_TNT_ELEMENT", player, tntPosition.getFuseTicks()));
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " tnt " + tntRecord.getId() + " fuse " + tntPosition.getFuseTicks()));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_TNT_ELEMENT_HOVER", player))));
return component;
}, (beforePageComponent, beforePage) -> {
beforePageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_PREVIOUS_PAGE", player)).create()));
beforePageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " tnt " + beforePage));
}, (afterPageComponent, afterPage) -> {
afterPageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_NEXT_PAGE", player)).create()));
afterPageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " tnt " + afterPage));
});
}
@Register(value = "record", noTabComplete = true)
public void recordTNTPositions(@Validator Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, @StaticValue("fuse") String fuse, int fuseTicks) {
Record record = StoredRecords.get(recordID);
if (record == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
return;
}
Record.TNTRecord tntRecord = record.get(tntID);
if (tntRecord == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_TNT_NOT_FOUND", player);
return;
}
TNTPosition tntPosition = tntRecord.get(fuseTicks);
if (tntPosition == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_TNT_POSITION_NOT_FOUND", player);
return;
}
BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_HEAD", player);
BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_X", player, tntPosition.getLocation().getX());
BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_Y", player, tntPosition.getLocation().getY());
BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_Z", player, tntPosition.getLocation().getZ());
BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_EXPLODED", player, tntPosition.isExploded());
}
@Register(value = {"start"}, description = "TRACE_COMMAND_HELP_START")
public void startCommand(@Validator Player p) {
RecordStateMachine.commandStart();
BauSystem.MESSAGE.send("TRACE_MESSAGE_START", p);
}
@Register(value = {"single"}, description = "TRACE_COMMAND_HELP_SINGLE")
public void singleCommand(@Validator Player p) {
RecordStateMachine.commandSingle();
BauSystem.MESSAGE.send("TRACE_MESSAGE_SINGLE", p);
}
@Register(value = {"stop"}, description = "TRACE_COMMAND_HELP_STOP")
public void stopCommand(@Validator Player p) {
RecordStateMachine.commandStop();
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", p);
}
@Register(value = {"auto"}, description = "TRACE_COMMAND_HELP_AUTO")
@Register({"toggleauto"})
public void autoCommand(@Validator Player p) {
RecordStateMachine.commandAuto();
BauSystem.MESSAGE.send(RecordStateMachine.getRecordStatus().getAutoMessage(), p);
}
@Register(value = {"delete"}, description = "TRACE_COMMAND_HELP_DELETE")
@Register({"clear"})
public void deleteCommand(@Validator Player p) {
StoredRecords.clear();
BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p);
}
@Register(value = {"show"}, description = "TRACE_COMMAND_HELP_SHOW")
public void showCommand(@Validator Player p, @OptionalValue("entity") ShowModeType showModeType, ShowModeParameterType... showModeParameterTypes) {
ShowModeParameter showModeParameter = new ShowModeParameter();
for (ShowModeParameterType showModeParameterType : showModeParameterTypes) {
showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter);
}
TraceShowManager.show(p, showModeType.showModeBiFunction.apply(p, showModeParameter));
BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", p);
}
@AllArgsConstructor
private enum ShowModeType {
ENTITY(TraceEntityShowMode::new, new ShowModeParameterType[]{}),
RAW(RawEntityShowMode::new, new ShowModeParameterType[]{}),
PARTICLE(ParticleShowMode::new, new ShowModeParameterType[]{ShowModeParameterType.TICKS}),
BLOCK(BlockShowMode::new, new ShowModeParameterType[]{ShowModeParameterType.TICKS});
private BiFunction<Player, ShowModeParameter, ShowMode<TNTPosition>> showModeBiFunction;
private ShowModeParameterType[] removedTypes;
}
@Register(value = {"show", "gui"}, description = "TRACE_COMMAND_HELP_SHOW_GUI")
public void showGuiCommand(@Validator Player p) {
TraceShowGui.openGui(p);
}
@Register(value = {"hide"}, description = "TRACE_COMMAND_HELP_HIDE")
public void hideCommand(@Validator Player p) {
TraceShowManager.hide(p);
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p);
}
@Register(value = {"isolate"}, noTabComplete = true)
public void isolateCommand(@Validator Player p, long tntRecordId) {
Record.TNTRecord tntRecord = StoredRecords.getRecords().stream().flatMap(record -> record.getTnt().stream()).filter(record -> record.getId() == tntRecordId).findFirst().orElse(null);
if (tntRecord == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_TNT_NOT_FOUND", p);
return;
}
if (TraceShowManager.isIsolated(p, tntRecord)) {
TraceShowManager.unisolate(p, tntRecord);
BauSystem.MESSAGE.send("TRACE_MESSAGE_UNISOLATE", p);
} else {
TraceShowManager.isolate(p, tntRecord);
BauSystem.MESSAGE.send("TRACE_MESSAGE_ISOLATE", p);
}
}
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "TRACE_MESSAGE_DISALLOWED");
if (!Permission.hasPermission(player, Permission.WORLD)) {
messageSender.send("TRACE_MESSAGE_DISALLOWED", player);
return false;
}
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
messageSender.send("TRACE_MESSAGE_NO_REGION", player);
return false;
}
return true;
};
}
}

Datei anzeigen

@ -26,7 +26,6 @@ import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
import de.steamwar.bausystem.utils.RayTraceUtils;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.api.Plain;
import net.md_5.bungee.api.chat.ClickEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.util.RayTraceResult;
@ -59,7 +58,7 @@ public class TraceTNTClickListener implements Plain {
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_X", player, tntPosition.getVelocity().getX() + "");
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Y", player, tntPosition.getVelocity().getY() + "");
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Z", player, tntPosition.getVelocity().getZ() + "");
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ISOLATE", player, BauSystem.MESSAGE.parse("TRACE_MESSAGE_CLICK_ISOLATE", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace isolate " + tntPosition.getRecord().getId()));
// BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ISOLATE", player, BauSystem.MESSAGE.parse("TRACE_MESSAGE_CLICK_ISOLATE", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace isolate " + tntPosition.getRecord().getId()));
}, 1);
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
playerSet.remove(player);

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2022 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
@ -21,10 +21,9 @@ package de.steamwar.bausystem.features.tracer;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.features.tracer.record.RecordStatus;
import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
import de.steamwar.bausystem.features.tracer.record.*;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked;
@ -34,6 +33,7 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.Collections;
@Linked
public class TracerBauGuiItem extends BauGuiItem {
@ -44,15 +44,21 @@ public class TracerBauGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
return new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_LORE", player, BauSystem.MESSAGE.parse(RecordStateMachine.getRecordStatus().getName(), player))), false, clickType -> {
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
return new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Collections.emptyList(), false, clickType -> {
}).getItemStack();
}
return new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_LORE", player, Recorder.INSTANCE.get(region).scoreboard(player))), false, clickType -> {
}).getItemStack();
}
private static void open(Player p) {
RecordStatus status = RecordStateMachine.getRecordStatus();
Region region = Region.getRegion(p.getLocation());
TraceRecorder traceRecorder = Recorder.INSTANCE.get(region);
SWInventory inv = new SWInventory(p, 9, BauSystem.MESSAGE.parse("TRACE_GUI_NAME", p));
if (status.isTracing()) {
if (status.isAutoTrace()) {
if (traceRecorder instanceof ActiveTracer) {
if (traceRecorder instanceof AutoTraceRecorder) {
inv.setItem(1, new SWItem(Material.GRAY_DYE, BauSystem.MESSAGE.parse("TRACE_GUI_TRACE_ACTIVE_AUTO", p)));
} else {
inv.setItem(1, new SWItem(Material.GREEN_DYE, BauSystem.MESSAGE.parse("TRACE_GUI_TRACE_ACTIVE", p), clickType -> {
@ -66,7 +72,7 @@ public class TracerBauGuiItem extends BauGuiItem {
open(p);
}));
}
if (status.isAutoTrace()) {
if (traceRecorder instanceof AutoTraceRecorder) {
inv.setItem(3, new SWItem(Material.ENDER_EYE, BauSystem.MESSAGE.parse("TRACE_GUI_AUTO_TRACE_ACTIVE", p), clickType -> {
p.performCommand("trace auto");
open(p);
@ -77,15 +83,6 @@ public class TracerBauGuiItem extends BauGuiItem {
open(p);
}));
}
if (TraceShowManager.hasActiveShow(p)) {
inv.setItem(5, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("TRACE_GUI_SHOW_GUI", p), clickType -> {
p.performCommand("trace show gui");
}));
} else {
inv.setItem(5, new SWItem(Material.GLASS, BauSystem.MESSAGE.parse("TRACE_GUI_SHOW_GUI", p), clickType -> {
p.performCommand("trace show gui");
}));
}
inv.setItem(7, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("TRACE_GUI_DELETE", p), clickType -> {
p.performCommand("trace delete");
open(p);

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2022 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
@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.show.Record;
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
import de.steamwar.bausystem.region.Region;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import lombok.experimental.UtilityClass;
@ -38,8 +39,9 @@ import java.util.List;
public class TraceGui {
public static void openGui(Player player) {
Region region = Region.getRegion(player.getLocation());
List<SWListInv.SWListEntry<Record>> recordList = new ArrayList<>();
StoredRecords.getRecords().forEach(record -> {
StoredRecords.getRecords(region).forEach(record -> {
if (record.getTnt().isEmpty()) {
return;
}
@ -49,24 +51,23 @@ public class TraceGui {
SWListInv<Record> recordSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, recordList, (clickType, record) -> {
openRecordGui(player, record);
});
recordSWListInv.setItem(48, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_CLEAR", player), clickType -> {
StoredRecords.clear();
recordSWListInv.setItem(49, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_CLEAR", player), clickType -> {
StoredRecords.clear(region);
player.getOpenInventory().close();
}));
recordSWListInv.setItem(50, new SWItem(Material.GLASS, "§e" + BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_TITLE", player), clickType -> {
TraceShowGui.openGui(player);
}));
recordSWListInv.open();
}
public static void openRecordGui(Player player, Record record) {
Region region = Region.getRegion(player.getLocation());
List<SWListInv.SWListEntry<Record.TNTRecord>> recordList = new ArrayList<>();
record.getTnt().forEach(tntRecord -> {
SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_ITEM", player, tntRecord.getPositions().size()), new ArrayList<>(), TraceShowManager.isIsolated(player, tntRecord), clickType -> {
SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_ITEM", player, tntRecord.getPositions().size()), new ArrayList<>(), false, clickType -> {
});
recordList.add(new SWListInv.SWListEntry<>(swItem, tntRecord));
});
SWListInv<Record.TNTRecord> tntRecordSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, recordList, (clickType, tntRecord) -> {
/*
if (clickType.isShiftClick()) {
if (TraceShowManager.isIsolated(player, tntRecord)) {
TraceShowManager.unisolate(player, tntRecord);
@ -75,18 +76,18 @@ public class TraceGui {
}
openRecordGui(player, record);
} else {
openTntGui(player, record, tntRecord);
}
*/
openTntGui(player, record, tntRecord);
});
tntRecordSWListInv.setItem(48, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_CLEAR", player), clickType -> {
StoredRecords.remove(record);
TraceShowManager.reshow();
StoredRecords.remove(region, record);
TraceShowManager.reshow(region);
openGui(player);
}));
tntRecordSWListInv.setItem(49, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_BACK", player), clickType -> {
tntRecordSWListInv.setItem(50, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_BACK", player), clickType -> {
openGui(player);
}));
// 48, 51
tntRecordSWListInv.open();
}
@ -98,7 +99,9 @@ public class TraceGui {
BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_X", player, tntPosition.getLocation().getX()),
BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_Y", player, tntPosition.getLocation().getY()),
BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_Z", player, tntPosition.getLocation().getZ()),
BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_EXPLODED", player, tntPosition.isExploded())));
BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_SOURCE", player, tntPosition.isSource()),
BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_EXPLODED", player, tntPosition.isExploded())
));
positionList.add(new SWListInv.SWListEntry<>(swItem, tntPosition));
});
SWListInv<TNTPosition> tntPositionSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, positionList, (clickType, tntPosition) -> {

Datei anzeigen

@ -1,129 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.gui;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import lombok.experimental.UtilityClass;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@UtilityClass
public class TraceShowGui {
private static final Map<Player, ShowModeParameter> ShowModeParameterMap = new HashMap<>();
public static void openGui(Player player) {
ShowModeParameter playerShowMode = new ShowModeParameter();
playerShowMode.setInterpolate_Y(false);
playerShowMode.setInterpolate_XZ(false);
ShowModeParameterMap.put(player, playerShowMode);
SWInventory swInventory = new SWInventory(player, 9, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_TITLE", player));
swInventory.addCloseCallback(clickType -> ShowModeParameterMap.remove(player));
setActiveShow(player, swInventory);
SWItem water = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_WATER_ITEM", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_WATER_LORE1", player), BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_WATER_LORE2", player)), false, clickType -> {
});
swInventory.setItem(5, water);
swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, water));
SWItem interpolateY = new SWItem(Material.QUARTZ_STAIRS, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_Y_ITEM", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_Y_LORE1", player), BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_Y_LORE2", player)), false, clickType -> {
});
swInventory.setItem(6, interpolateY);
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, interpolateY));
Material xzMaterial = FlatteningWrapper.impl.getTraceXZMaterial();
SWItem interpolateXZ = new SWItem(xzMaterial, (byte) 7, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_XZ_ITEM", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE1", player), BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE2", player)), false, clickType -> {
});
swInventory.setItem(7, interpolateXZ);
swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, interpolateXZ));
// Water Bucket (-water)
// TNT (-water-exploded)
// Quartz_Stair (-interpolate-y)
// Quartz_Slab (-interpolate-xz)
swInventory.open();
}
private static void setActiveShow(Player player, SWInventory swInventory) {
if (TraceShowManager.hasActiveShow(player)) {
Material showMaterial = FlatteningWrapper.impl.getTraceShowMaterial();
SWItem shown = new SWItem(showMaterial, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_SHOWN", player), new ArrayList<>(), false, clickType -> {
TraceShowManager.hide(player);
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", player);
setActiveShow(player, swInventory);
});
swInventory.setItem(1, shown);
} else {
Material hideMaterial = FlatteningWrapper.impl.getTraceHideMaterial();
SWItem hidden = new SWItem(hideMaterial, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_HIDDEN", player), new ArrayList<>(), false, clickType -> {
show(player);
BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", player);
setActiveShow(player, swInventory);
});
swInventory.setItem(1, hidden);
}
}
private static void toggleHideTNTinWaterExploded(Player player, SWInventory swInventory, SWItem swItem) {
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
showModeParameter.setWater(!showModeParameter.isWater());
show(player);
swItem.setEnchanted(showModeParameter.isWater());
swInventory.setItem(5, swItem);
swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, swItem));
}
private static void toggleInterpolateYPosition(Player player, SWInventory swInventory, SWItem swItem) {
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
showModeParameter.setInterpolate_Y(!showModeParameter.isInterpolate_Y());
show(player);
swItem.setEnchanted(showModeParameter.isInterpolate_Y());
swInventory.setItem(6, swItem);
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, swItem));
}
private static void toggleInterpolateXZPosition(Player player, SWInventory swInventory, SWItem swItem) {
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
showModeParameter.setInterpolate_XZ(!showModeParameter.isInterpolate_XZ());
show(player);
swItem.setEnchanted(showModeParameter.isInterpolate_XZ());
swInventory.setItem(7, swItem);
swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, swItem));
}
private static void show(Player player) {
TraceShowManager.show(player, new TraceEntityShowMode(player, ShowModeParameterMap.get(player)));
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2022 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
@ -17,8 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.linkage;
package de.steamwar.bausystem.features.tracer.record;
public interface Disable {
void disable();
public interface ActiveTracer {
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2022 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
@ -17,8 +17,17 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.linkage;
package de.steamwar.bausystem.features.tracer.record;
public interface Enable {
void enable();
public class AutoExplodeTraceRecorder extends AutoTraceRecorder {
@Override
protected String getInactivityMessage() {
return "TRACE_IDLE_AUTO_EXPLODE";
}
@Override
protected boolean shouldStartRecording(StartType startType) {
return startType == StartType.EXPLODE;
}
}

Datei anzeigen

@ -0,0 +1,33 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.record;
public class AutoIgniteTraceRecorder extends AutoTraceRecorder implements ActiveTracer {
@Override
protected String getInactivityMessage() {
return "TRACE_IDLE_AUTO_IGNITE";
}
@Override
protected boolean shouldStartRecording(StartType startType) {
return startType == StartType.IGNITE;
}
}

Datei anzeigen

@ -0,0 +1,118 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.record;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.features.tracer.show.Record;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
public abstract class AutoTraceRecorder implements TraceRecorder {
private boolean recording = false;
private long startTime = TPSUtils.currentTick.get();
private long lastExplosion = 0;
private final Map<TNTPrimed, Record.TNTRecord> recordMap = new HashMap<>();
private Record record;
private Supplier<Record> recordSupplier;
private Record.TNTRecord getRecord(TNTPrimed tntPrimed) {
return recordMap.computeIfAbsent(tntPrimed, __ -> record.spawn(TPSUtils.currentTick.get() - startTime));
}
protected abstract String getInactivityMessage();
protected abstract boolean shouldStartRecording(StartType startType);
@Override
public final String scoreboard(Player player) {
if (recording) {
return BauSystem.MESSAGE.parse("TRACE_RECORD", player) + " §8| §e" + (TPSUtils.currentTick.get() - startTime) + " §7" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", player);
} else {
return BauSystem.MESSAGE.parse(getInactivityMessage(), player);
}
}
private void startRecording() {
lastExplosion = 0;
recording = true;
startTime = TPSUtils.currentTick.get();
record = recordSupplier.get();
}
@Override
public void recordSupplier(Supplier<Record> recordSupplier) {
this.recordSupplier = recordSupplier;
}
@Override
public Record postClear() {
recordMap.clear();
return record;
}
@Override
public final void spawn(TNTPrimed tntPrimed) {
if (!recording && shouldStartRecording(StartType.IGNITE)) {
startRecording();
}
if (recording) {
getRecord(tntPrimed).source(tntPrimed);
}
}
@Override
public final void tick(TNTPrimed tntPrimed) {
if (recording) {
getRecord(tntPrimed).location(tntPrimed);
}
}
@Override
public final void explode(TNTPrimed tntPrimed) {
if (!recording && shouldStartRecording(StartType.EXPLODE)) {
startRecording();
}
if (recording) {
getRecord(tntPrimed).explode(tntPrimed);
}
lastExplosion = 0;
}
@Override
public final void tick() {
lastExplosion++;
if (recording && lastExplosion > 80) {
recording = false;
recordMap.clear();
record = null;
}
}
protected enum StartType {
IGNITE,
EXPLODE
}
}

Datei anzeigen

@ -1,113 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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.record;
import lombok.experimental.UtilityClass;
@UtilityClass
public class RecordStateMachine {
private static final TraceAutoHandler autoHandler = new TraceAutoHandler();
private static RecordStatus recordStatus = RecordStatus.IDLE;
private static Recorder recorder = null;
public static void commandStart() {
autoHandler.disable();
recordStart();
recordStatus = RecordStatus.RECORD;
}
public static void commandStop() {
autoHandler.disable();
recordStop();
recordStatus = RecordStatus.IDLE;
}
public static void commandAuto() {
if (recordStatus.isTracing())
return;
if (recordStatus == RecordStatus.IDLE_AUTO) {
recordStatus = RecordStatus.IDLE;
autoHandler.disable();
} else {
recordStatus = RecordStatus.IDLE_AUTO;
autoHandler.enable();
}
}
public static void commandSingle() {
if (recordStatus.isTracing())
return;
if (recordStatus != RecordStatus.IDLE_SINGLE) {
recordStatus = RecordStatus.IDLE_SINGLE;
autoHandler.enable();
}
}
static void autoRecord() {
recordStart();
if (recordStatus == RecordStatus.IDLE_AUTO) {
recordStatus = RecordStatus.RECORD_AUTO;
} else {
recordStatus = RecordStatus.RECORD_SINGLE;
}
}
static void autoIdle() {
recordStop();
if (recordStatus == RecordStatus.RECORD_AUTO) {
recordStatus = RecordStatus.IDLE_AUTO;
} else {
autoHandler.disable();
recordStatus = RecordStatus.IDLE;
}
}
private static void recordStart() {
if (recordStatus.isTracing()) return;
recorder = new Recorder();
}
private static void recordStop() {
if (!recordStatus.isTracing()) return;
recorder.stopRecording();
}
public static RecordStatus getRecordStatus() {
return recordStatus;
}
public static int size() {
if (recorder == null) return 0;
return recorder.size();
}
public static long getStartTime() {
if (recorder == null) return 0;
return recorder.getStartTime();
}
public static void postClear() {
if (recorder == null) return;
recorder.postClear();
}
}

Datei anzeigen

@ -1,56 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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.record;
public enum RecordStatus {
RECORD("TRACE_RECORD", true, "TRACE_MESSAGE_AUTO_RECORD"),
RECORD_AUTO("TRACE_RECORD_AUTO", true, "TRACE_MESSAGE_AUTO_RECORD_AUTO"),
RECORD_SINGLE("TRACE_RECORD_SINGLE", true, "TRACE_MESSAGE_AUTO_RECORD"),
IDLE("TRACE_IDLE", false, "TRACE_MESSAGE_AUTO_IDLE"),
IDLE_AUTO("TRACE_IDLE_AUTO", false, "TRACE_MESSAGE_AUTO_IDLE_AUTO"),
IDLE_SINGLE("TRACE_IDLE_SINGLE", false, "TRACE_MESSAGE_AUTO_IDLE");
String name;
boolean tracing;
String autoMessage;
RecordStatus(String value, boolean tracing, String autoMessage) {
this.name = value;
this.tracing = tracing;
this.autoMessage = autoMessage;
}
public String getName() {
return name;
}
public boolean isTracing() {
return tracing;
}
public boolean isAutoTrace() {
return this == RECORD_AUTO || this == IDLE_AUTO;
}
public String getAutoMessage() {
return autoMessage;
}
}

Datei anzeigen

@ -1,96 +1,162 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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/>.
*/
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.record;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tracer.show.Record;
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
import de.steamwar.bausystem.region.Region;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.event.entity.EntitySpawnEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
@Linked
public class Recorder implements Listener {
private static final World world = Bukkit.getWorlds().get(0);
public static Recorder INSTANCE;
private final Map<TNTPrimed, Record.TNTRecord> recordMap = new HashMap<>();
private final BukkitTask task;
private final Record record;
Recorder() {
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this::run, 1, 1);
record = new Record();
// To trace TNT initial positions with AutoTracer
run();
{
INSTANCE = this;
}
void stopRecording() {
HandlerList.unregisterAll(this);
task.cancel();
private static class NoopTraceRecorder implements TraceRecorder {
@Override
public String scoreboard(Player player) {
return null;
}
@Override
public void spawn(TNTPrimed tntPrimed) {
}
@Override
public void tick(TNTPrimed tntPrimed) {
}
@Override
public void explode(TNTPrimed tntPrimed) {
}
}
private static final NoopTraceRecorder NOOP = new NoopTraceRecorder();
private static class DisabledTracerRecorder implements TraceRecorder {
@Override
public String scoreboard(Player player) {
return BauSystem.MESSAGE.parse("TRACE_IDLE", player);
}
@Override
public void spawn(TNTPrimed tntPrimed) {
}
@Override
public void tick(TNTPrimed tntPrimed) {
}
@Override
public void explode(TNTPrimed tntPrimed) {
}
}
private static final DisabledTracerRecorder DISABLED = new DisabledTracerRecorder();
static Recorder instance;
{
instance = this;
}
int size() {
return record.size();
private final World world = Bukkit.getWorlds().get(0);
private Map<Region, TraceRecorder> regionTraceRecorderMap = new HashMap<>();
private Map<TNTPrimed, Region> tntTraceRecorderMap = new HashMap<>();
private TraceRecorder get(TNTPrimed tntPrimed) {
return get(tntTraceRecorderMap.computeIfAbsent(tntPrimed, e -> Region.getRegion(e.getLocation())));
}
long getStartTime() {
return record.getStartTime();
public TraceRecorder get(Region region) {
return regionTraceRecorderMap.getOrDefault(region, region.isGlobal() ? NOOP : DISABLED);
}
void postClear() {
record.clear();
recordMap.clear();
StoredRecords.add(record);
public void set(Region region, TraceRecorder traceRecorder) {
regionTraceRecorderMap.put(region, traceRecorder);
traceRecorder.recordSupplier(() -> {
Record record = new Record(region);
StoredRecords.add(region, record);
return record;
});
}
private void run() {
world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> get(tntPrimed).add(tntPrimed));
public void remove(Region region) {
regionTraceRecorderMap.remove(region);
}
public void postClear(Region region) {
TraceRecorder traceRecorder = get(region);
Record record = traceRecorder.postClear();
if (record != null) {
StoredRecords.add(region, record);
}
}
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed)) {
return;
}
get((TNTPrimed) entity).spawn((TNTPrimed) entity);
}
{
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> {
get(tntPrimed).tick(tntPrimed);
});
tntTraceRecorderMap.keySet()
.stream()
.filter(e -> !e.isValid())
.collect(Collectors.toList())
.forEach(tntTraceRecorderMap::remove);
regionTraceRecorderMap.values().forEach(TraceRecorder::tick);
}, 1, 1);
}
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof TNTPrimed))
Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed)) {
return;
TNTPrimed tntPrimed = (TNTPrimed) event.getEntity();
get(tntPrimed).explode(tntPrimed);
recordMap.remove(tntPrimed);
}
private Record.TNTRecord get(TNTPrimed tntPrimed) {
Record.TNTRecord tntRecord = recordMap.get(tntPrimed);
if (tntRecord != null)
return tntRecord;
tntRecord = this.record.spawn();
recordMap.put(tntPrimed, tntRecord);
return tntRecord;
}
get((TNTPrimed) entity).explode((TNTPrimed) entity);
tntTraceRecorderMap.remove(entity);
}
}

Datei anzeigen

@ -0,0 +1,73 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.record;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.features.tracer.show.Record;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer {
private final long startTime = TPSUtils.currentTick.get();
private final Map<TNTPrimed, Record.TNTRecord> recordMap = new HashMap<>();
private Record record;
@Override
public String scoreboard(Player player) {
return BauSystem.MESSAGE.parse("TRACE_RECORD", player) + " §8| §e" + (TPSUtils.currentTick.get() - startTime) + " §7" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", player);
}
@Override
public void recordSupplier(Supplier<Record> recordSupplier) {
record = recordSupplier.get();
}
@Override
public Record postClear() {
recordMap.clear();
return record;
}
private Record.TNTRecord getRecord(TNTPrimed tntPrimed) {
return recordMap.computeIfAbsent(tntPrimed, __ -> record.spawn(TPSUtils.currentTick.get() - startTime));
}
@Override
public void spawn(TNTPrimed tntPrimed) {
getRecord(tntPrimed).source(tntPrimed);
}
@Override
public void tick(TNTPrimed tntPrimed) {
getRecord(tntPrimed).location(tntPrimed);
}
@Override
public void explode(TNTPrimed tntPrimed) {
getRecord(tntPrimed).explode(tntPrimed);
recordMap.remove(tntPrimed);
}
}

Datei anzeigen

@ -1,72 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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.record;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.Bukkit;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.scheduler.BukkitTask;
public class TraceAutoHandler implements Listener {
/* This listener handles the en- and disabling of the Tracer in AUTO mode */
private BukkitTask task;
private int lastExplosion = 0; // Time since the last explosion in ticks
public void enable() {
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
}
public void disable() {
HandlerList.unregisterAll(this);
if (task != null) {
task.cancel();
task = null;
}
}
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof TNTPrimed))
return;
lastExplosion = 0;
if (task == null) {
RecordStateMachine.autoRecord();
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this::run, 1, 1);
}
}
private void run() {
lastExplosion++;
if (lastExplosion > 80) {
RecordStateMachine.autoIdle();
if (task != null) {
task.cancel();
task = null;
}
}
}
}

Datei anzeigen

@ -0,0 +1,41 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.record;
import de.steamwar.bausystem.features.tracer.show.Record;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import java.util.function.Supplier;
public interface TraceRecorder {
String scoreboard(Player player);
default void recordSupplier(Supplier<Record> recordSupplier) {
}
default Record postClear() {
return null;
}
void spawn(TNTPrimed tntPrimed);
void tick(TNTPrimed tntPrimed);
void explode(TNTPrimed tntPrimed);
default void tick() {
}
}

Datei anzeigen

@ -1,26 +1,26 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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/>.
*/
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.show;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.shared.ShowMode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@ -30,40 +30,23 @@ import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
@Getter
@RequiredArgsConstructor
public class Record {
private static long idNumber = 0;
private final long id = idNumber++;
private final long startTime = TPSUtils.currentTick.get();
@Getter
private final List<TNTRecord> tnt = new ArrayList<>();
private final boolean trace;
private final Region region;
public int size() {
return tnt.size();
}
public void showAll(ShowMode<TNTPosition> mode) {
for (TNTRecord record : tnt)
record.showAll(mode);
public void showAll(ShowMode<TNTPosition> traceShowMode) {
tnt.forEach(tntRecord -> tntRecord.getPositions().forEach(traceShowMode::show));
}
/* The following methods should only be called by a recorder */
public Record() {
this(true);
}
public Record(boolean trace) {
if (trace) {
StoredRecords.add(this);
}
this.trace = trace;
}
public TNTRecord spawn() {
TNTRecord record = new TNTRecord(trace);
public TNTRecord spawn(long offset) {
TNTRecord record = new TNTRecord(offset, region);
tnt.add(record);
return record;
}
@ -72,46 +55,35 @@ public class Record {
tnt.clear();
}
public TNTRecord get(long id) {
for (TNTRecord record : tnt) {
if (record.getId() == id) return record;
}
return null;
}
public void remove(long id) {
tnt.removeIf(record -> record.getId() == id);
}
@Getter
@RequiredArgsConstructor
public static class TNTRecord {
private final long id = idNumber++;
private final List<TNTPosition> positions = new ArrayList<>(41);
private final boolean trace;
@Getter
private final long offset;
private final Region region;
@Getter
private final List<TNTPosition> positions = new ArrayList<>(82);
public void showAll(ShowMode<TNTPosition> mode) {
for (TNTPosition position : positions)
mode.show(position);
public TNTRecord(long offset, Region region) {
this.offset = offset;
this.region = region;
}
public TNTPosition get(int fuseTicks) {
for (TNTPosition position : positions) {
if (position.getFuseTicks() == fuseTicks) return position;
}
return null;
public void source(TNTPrimed tntPrimed) {
add(tntPrimed, true, false);
}
/* The following methods should only be called by a recorder */
public void add(TNTPrimed tntPrimed) {
add(tntPrimed, false);
public void location(TNTPrimed tntPrimed) {
add(tntPrimed, false, false);
}
private void add(TNTPrimed tntPrimed, boolean exploded) {
public void explode(TNTPrimed tntPrimed) {
add(tntPrimed, false, true);
}
private void add(TNTPrimed tntPrimed, boolean source, boolean exploded) {
TNTPosition position;
if (positions.isEmpty()) {
position = new TNTPosition(this, tntPrimed, null, tntPrimed.getVelocity(), new TNTPosition.CachingSupplier<>(() -> null), exploded);
position = new TNTPosition(this, tntPrimed, null, tntPrimed.getVelocity(), new TNTPosition.CachingSupplier<>(() -> null), source, exploded);
} else {
int currentSize = positions.size() + 1;
TNTPosition.CachingSupplier<Vector> velocitySupplier = new TNTPosition.CachingSupplier<>(() -> {
@ -125,16 +97,10 @@ public class Record {
}
return current;
});
position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), velocitySupplier, exploded);
position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), velocitySupplier, source, exploded);
}
positions.add(position);
if (trace) {
TraceShowManager.show(position);
}
}
public void explode(TNTPrimed tntPrimed) {
add(tntPrimed, true);
TraceShowManager.show(region, position);
}
}
}

Datei anzeigen

@ -1,35 +1,56 @@
/*
* This file is a part of the SteamWar software.
*
* This file is a part of the SteamWar software.
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* Copyright (C) 2020 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 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.
*
* 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/>.
* /
* 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.show;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ShowModeParameter {
private boolean water = false;
private boolean interpolate_Y = false;
private boolean interpolate_XZ = false;
private boolean interpolateY = false;
private boolean interpolateXZ = false;
private boolean sourceOnly = false;
private boolean explodeOnly = false;
private boolean ticks = false;
public void enableWater() {
this.water = true;
}
public void enableInterpolateY() {
this.interpolateY = true;
}
public void enableInterpolateXZ() {
this.interpolateXZ = true;
}
public void enableSourceOnly() {
this.sourceOnly = true;
}
public void enableExplodeOnly() {
this.explodeOnly = true;
}
public void enableTicks() {
this.ticks = true;
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
* Copyright (C) 2022 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
@ -29,15 +29,16 @@ import java.util.function.Supplier;
public enum ShowModeParameterType {
WATER(showModeParameter -> showModeParameter.setWater(true), Arrays.asList("-water"), "EXPLODE"),
INTERPOLATE_Y(showModeParameter -> showModeParameter.setInterpolate_Y(true), Arrays.asList("-interpolatey", "-interpolate-y", "-interpolate_y", "-y"), "ADVANCED"),
INTERPOLATE_XZ(showModeParameter -> showModeParameter.setInterpolate_XZ(true), Arrays.asList("-interpolatex", "-interpolate-x", "-interpolate_x", "-x", "-interpolatez", "-interpolate-z", "-interpolate_z", "-z", "-interpolatexz", "-interpolate-xz", "-interpolate_xz", "-xz"), "ADVANCED"),
WATER(ShowModeParameter::enableWater, Arrays.asList("-water"), "EXPLODE", "SOURCE"),
INTERPOLATE_Y(ShowModeParameter::enableInterpolateY, Arrays.asList("-interpolatey", "-interpolate-y", "-interpolate_y", "-y"), "ADVANCED"),
INTERPOLATE_XZ(ShowModeParameter::enableInterpolateXZ, Arrays.asList("-interpolatex", "-interpolate-x", "-interpolate_x", "-x", "-interpolatez", "-interpolate-z", "-interpolate_z", "-z", "-interpolatexz", "-interpolate-xz", "-interpolate_xz", "-xz"), "ADVANCED"),
ADVANCED(showModeParameter -> {
showModeParameter.setInterpolate_Y(true);
showModeParameter.setInterpolate_XZ(true);
showModeParameter.enableInterpolateY();
showModeParameter.enableInterpolateXZ();
}, Arrays.asList("-advanced", "-a", "advanced"), "INTERPOLATE_Y", "INTERPOLATE_XZ"),
EXPLODE(showModeParameter -> showModeParameter.setExplodeOnly(true), Arrays.asList("-explode", "-explodeonly"), "WATER", "TICKS"),
TICKS(showModeParameter -> showModeParameter.setTicks(true), Arrays.asList("-ticks", "-t"), "EXPLODE");
SOURCE(ShowModeParameter::enableSourceOnly, Arrays.asList("-source", "-sourceonly"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"),
EXPLODE(ShowModeParameter::enableExplodeOnly, Arrays.asList("-explode", "-explodeonly"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"),
TICKS(ShowModeParameter::enableTicks, Arrays.asList("-ticks", "-t"), "EXPLODE", "SOURCE");
@Getter
private final Consumer<ShowModeParameter> showModeParameterConsumer;

Datei anzeigen

@ -1,63 +1,63 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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/>.
*/
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.show;
import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.features.tracer.record.Recorder;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.shared.ShowMode;
import lombok.Getter;
import lombok.experimental.UtilityClass;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@UtilityClass
public class StoredRecords {
@Getter
private static final List<Record> records = new ArrayList<>();
private static final Map<Region, List<Record>> records = new HashMap<>();
public static void add(Record record) {
records.add(record);
public static void add(Region region, Record record) {
records.computeIfAbsent(region, k -> new ArrayList<>()).add(record);
}
public static void remove(Record record) {
records.remove(record);
public static void remove(Region region, Record record) {
records.computeIfAbsent(region, k -> new ArrayList<>()).remove(record);
}
public static void remove(long id) {
records.removeIf(record -> record.getId() == id);
public static void clear(Region region) {
records.remove(region);
TraceShowManager.clear(region);
Recorder.INSTANCE.postClear(region);
}
public static Record get(long id) {
for (Record record : records) {
if (record.getId() == id) return record;
}
return null;
public static List<Record> getRecords() {
return records.values().stream()
.flatMap(Collection::stream)
.collect(Collectors.toList());
}
public static void showAll(ShowMode<TNTPosition> mode) {
for (Record record : records) record.showAll(mode);
public static List<Record> getRecords(Region region) {
return records.getOrDefault(region, Collections.emptyList());
}
public static void clear() {
records.clear();
TraceShowManager.clear();
RecordStateMachine.postClear();
static void show(Region region, ShowMode<TNTPosition> traceShowMode) {
records.getOrDefault(region, new ArrayList<>()).forEach(record -> record.showAll(traceShowMode));
}
}

Datei anzeigen

@ -1,8 +1,27 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.show;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.shared.ShowMode;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
@ -11,56 +30,55 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TraceShowManager implements Listener {
private TraceShowManager() {
}
private static final Map<Player, Set<Record.TNTRecord>> playerIsolatedRecords = new HashMap<>();
private static final Map<Player, ShowMode<TNTPosition>> showModes = new HashMap<>();
public static void isolate(Player player, Record.TNTRecord tntRecord) {
playerIsolatedRecords.computeIfAbsent(player, p -> new HashSet<>()).add(tntRecord);
show(player, showModes.getOrDefault(player, new TraceEntityShowMode(player, new ShowModeParameter())));
}
public static void unisolate(Player player, Record.TNTRecord tntRecord) {
playerIsolatedRecords.computeIfPresent(player, (player1, tntRecords) -> {
tntRecords.remove(tntRecord);
return tntRecords;
});
show(player, showModes.getOrDefault(player, new TraceEntityShowMode(player, new ShowModeParameter())));
}
public static boolean isIsolated(Player player, Record.TNTRecord tntRecord) {
return playerIsolatedRecords.getOrDefault(player, Collections.emptySet()).contains(tntRecord);
}
private static final Map<Region, Map<Player, ShowMode<TNTPosition>>> showModes = new HashMap<>();
public static void show(Player player, ShowMode<TNTPosition> traceShowMode) {
Set<Record.TNTRecord> isolatedRecords = playerIsolatedRecords.get(player);
hide(player);
showModes.put(player, traceShowMode);
if (isolatedRecords != null && !isolatedRecords.isEmpty()) {
playerIsolatedRecords.put(player, isolatedRecords);
for (Record.TNTRecord record : isolatedRecords) {
record.getPositions().forEach(traceShowMode::show);
}
} else {
StoredRecords.showAll(traceShowMode);
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
return;
}
Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.computeIfAbsent(region, __ -> new HashMap<>());
regionalShowModes.put(player, traceShowMode);
StoredRecords.show(region, traceShowMode);
}
public static void hide(Player player) {
playerIsolatedRecords.remove(player);
ShowMode<TNTPosition> traceShowMode = showModes.remove(player);
if (traceShowMode == null)
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
return;
traceShowMode.hide();
}
Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.get(region);
if (regionalShowModes == null) {
return;
}
ShowMode<TNTPosition> showMode = regionalShowModes.get(player);
if (showMode == null) {
return;
}
showMode.hide();
}
public static List<Entity> getEntities(Player player) {
ShowMode<TNTPosition> showMode = showModes.get(player);
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
return Collections.emptyList();
}
Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.get(region);
if (regionalShowModes == null) {
return Collections.emptyList();
}
ShowMode<TNTPosition> showMode = regionalShowModes.get(player);
if (showMode == null) {
return Collections.emptyList();
}
@ -71,7 +89,15 @@ public class TraceShowManager implements Listener {
}
public static TNTPosition getTNTPosition(Player player, Entity entity) {
ShowMode<TNTPosition> showMode = showModes.get(player);
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
return null;
}
Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.get(region);
if (regionalShowModes == null) {
return null;
}
ShowMode<TNTPosition> showMode = regionalShowModes.get(player);
if (showMode == null) {
return null;
}
@ -81,24 +107,33 @@ public class TraceShowManager implements Listener {
return null;
}
public static void reshow() {
Map<Player, ShowMode<TNTPosition>> current = new HashMap<>(showModes);
current.forEach(TraceShowManager::show);
}
/* Only to be called by record */
static void show(TNTPosition tnt) {
for (Map.Entry<Player, ShowMode<TNTPosition>> entry : showModes.entrySet()) {
if (playerIsolatedRecords.containsKey(entry.getKey())) continue;
entry.getValue().show(tnt);
public static void reshow(Region region) {
Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.get(region);
if (regionalShowModes == null) {
return;
}
for (Map.Entry<Player, ShowMode<TNTPosition>> entry : regionalShowModes.entrySet()) {
entry.getValue().hide();
StoredRecords.show(region, entry.getValue());
}
}
/* Only to be called by record */
static void show(Region region, TNTPosition tnt) {
Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.get(region);
if (regionalShowModes == null) {
return;
}
regionalShowModes.values().forEach(tntPositionShowMode -> tntPositionShowMode.show(tnt));
}
/* Only to be called by StoredRecords */
static void clear() {
playerIsolatedRecords.clear();
for (ShowMode<TNTPosition> mode : showModes.values())
mode.hide();
static void clear(Region region) {
Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.get(region);
if (regionalShowModes == null) {
return;
}
regionalShowModes.values().forEach(ShowMode::hide);
}
/* Internal if player leaves*/
@ -108,11 +143,14 @@ public class TraceShowManager implements Listener {
@EventHandler
public void onLeave(PlayerQuitEvent event) {
showModes.remove(event.getPlayer());
Region region = Region.getRegion(event.getPlayer().getLocation());
if (region.isGlobal()) {
return;
}
Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.get(region);
if (regionalShowModes == null) {
return;
}
regionalShowModes.remove(event.getPlayer());
}
public static boolean hasActiveShow(Player player) {
return showModes.containsKey(player);
}
}

Datei anzeigen

@ -1,67 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.show.mode;
import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.shared.ShowMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.HashSet;
import java.util.Set;
public class BlockShowMode implements ShowMode<TNTPosition> {
protected final Player player;
protected final ShowModeParameter showModeParameter;
private Set<Point> positionSet = new HashSet<>();
public BlockShowMode(Player player, ShowModeParameter showModeParameter) {
this.player = player;
this.showModeParameter = showModeParameter;
}
@Override
public void show(TNTPosition position) {
if (showModeParameter.isExplodeOnly() && !position.isExploded()) {
return;
}
Location location = position.getLocation().toLocation(player.getWorld());
Point point = Point.fromLocation(location);
if (positionSet.contains(point)) {
return;
}
positionSet.add(point);
player.sendBlockChange(location, Material.RED_STAINED_GLASS.createBlockData());
}
@Override
public void hide() {
positionSet.forEach(point -> {
Location location = point.toLocation(player.getWorld());
player.sendBlockChange(location, location.getBlock().getBlockData());
});
positionSet.clear();
}
}

Datei anzeigen

@ -56,13 +56,23 @@ public abstract class FactoredEntityShowMode implements EntityTraceShowMode {
@Override
public void show(TNTPosition position) {
if (showModeParameter.isExplodeOnly()) {
if (!position.isExploded()) {
if (position.isExploded()) {
RoundedPosition roundedPosition = new RoundedPosition(position, factor);
AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true));
tntPositionMap.put(entity.getBukkitEntity(), position);
entity.display(player, position.isExploded(), showModeParameter.isTicks() ? position.getFuseTicks() : -1);
}
if (!showModeParameter.isSourceOnly()) {
return;
}
RoundedPosition roundedPosition = new RoundedPosition(position, factor);
AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true));
tntPositionMap.put(entity.getBukkitEntity(), position);
entity.display(player, position.isExploded(), showModeParameter.isTicks() ? position.getFuseTicks() : -1);
}
if (showModeParameter.isSourceOnly()) {
if (position.isSource()) {
RoundedPosition roundedPosition = new RoundedPosition(position, factor);
AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true));
tntPositionMap.put(entity.getBukkitEntity(), position);
entity.display(player, position.isExploded(), showModeParameter.isTicks() ? position.getFuseTicks() : -1);
}
return;
}
if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) {
@ -107,14 +117,14 @@ public abstract class FactoredEntityShowMode implements EntityTraceShowMode {
private void applyOnPosition(TNTPosition position, Consumer<Vector> function) {
if (position.getPreviousLocation() == null) return;
if (showModeParameter.isInterpolate_Y()) {
if (showModeParameter.isInterpolateY()) {
Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY());
if (!position.getLocation().equals(updatePointY)) {
function.accept(updatePointY);
}
}
if (showModeParameter.isInterpolate_XZ()) {
if (showModeParameter.isInterpolateXZ()) {
Vector updatePointXZ = Math.abs(position.getUpdateVelocity().getX()) >= Math.abs(position.getUpdateVelocity().getZ())
? position.getLocation().clone().setZ(position.getPreviousLocation().getZ())
: position.getLocation().clone().setX(position.getPreviousLocation().getX());

Datei anzeigen

@ -1,72 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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.show.mode;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.shared.ShowMode;
import de.steamwar.bausystem.utils.NMSWrapper;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import java.util.HashSet;
import java.util.Set;
public class ParticleShowMode implements ShowMode<TNTPosition> {
protected final Player player;
protected final ShowModeParameter showModeParameter;
private Set<Vector> positionSet = new HashSet<>();
private BukkitTask bukkitTask;
public ParticleShowMode(Player player, ShowModeParameter showModeParameter) {
this.player = player;
this.showModeParameter = showModeParameter;
}
@Override
public void show(TNTPosition position) {
if (showModeParameter.isExplodeOnly() && !position.isExploded()) {
return;
}
if (positionSet.contains(position.getLocation())) {
return;
}
positionSet.add(position.getLocation());
if (bukkitTask == null) {
bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
positionSet.forEach(p -> player.spawnParticle(NMSWrapper.impl.tntPositionParticle(), p.toLocation(player.getWorld()), 1, 0, 0, 0, 0));
}, 40L, 40L);
}
}
@Override
public void hide() {
positionSet.clear();
if (bukkitTask != null) {
bukkitTask.cancel();
}
}
}

Datei anzeigen

@ -21,13 +21,15 @@ package de.steamwar.bausystem.features.warp;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.Disable;
import de.steamwar.bausystem.linkage.Enable;
import de.steamwar.bausystem.utils.ListChatView;
import de.steamwar.bausystem.worlddata.WorldData;
import de.steamwar.command.*;
import de.steamwar.linkage.LinkageType;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.api.Disable;
import de.steamwar.linkage.api.Enable;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;

Datei anzeigen

@ -4,14 +4,14 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.Loader;
import de.steamwar.bausystem.features.tpslimit.FreezeUtils;
import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils;
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.features.tracer.record.Recorder;
import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.core.TPSWatcher;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.LinkedInstance;
import de.steamwar.scoreboard.SWScoreboard;
import de.steamwar.scoreboard.ScoreboardCallback;
import org.bukkit.entity.Player;
@ -28,6 +28,9 @@ import java.util.List;
@Linked
public class BauScoreboard implements Listener {
@LinkedInstance
public Recorder recorder;
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
@ -74,12 +77,10 @@ public class BauScoreboard implements Listener {
}
strings.add("§3");
StringBuilder st = new StringBuilder();
st.append(colorCode).append(BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p)).append("§8: ").append(BauSystem.MESSAGE.parse(RecordStateMachine.getRecordStatus().getName(), p));
if (RecordStateMachine.getRecordStatus().isTracing()) {
st.append(" §8| §e").append(traceTicks()).append(" §7").append(BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", p));
String traceScore = recorder.get(region).scoreboard(p);
if (traceScore != null) {
strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + traceScore);
}
strings.add(st.toString());
Loader loader = Loader.getLoader(p);
strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader != null ? loader.getStage().getChatValue() : "LOADER_OFF", p));
@ -99,10 +100,6 @@ public class BauScoreboard implements Listener {
return result;
}
private long traceTicks() {
return TPSUtils.currentTick.get() - RecordStateMachine.getStartTime();
}
private String tpsColor() {
double tps = TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND);
if (tps > TPSLimitUtils.getCurrentTPSLimit() * 0.9) {

Datei anzeigen

@ -19,8 +19,8 @@
package de.steamwar.bausystem.features.world;
import de.steamwar.bausystem.linkage.Enable;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.api.Enable;
import org.bukkit.Bukkit;
import org.bukkit.GameRule;

Datei anzeigen

@ -20,9 +20,9 @@
package de.steamwar.bausystem.region;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.Enable;
import de.steamwar.bausystem.region.tags.Tag;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.api.Enable;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.Iterator;

Datei anzeigen

@ -48,7 +48,6 @@ public interface NMSWrapper {
void setGameStateChangeReason(Object packet);
void setPlayerBuildAbilities(Player player);
Particle tntPositionParticle();
Material pathMaterial();
boolean checkItemStack(ItemStack item);