QOL #203
@ -495,8 +495,6 @@ TRACE_MESSAGE_STOP = §cTNT-Tracer stopped
|
|||||||
TRACE_MESSAGE_DELETE = §cAll TNT-positions deleted
|
TRACE_MESSAGE_DELETE = §cAll TNT-positions deleted
|
||||||
TRACE_MESSAGE_SHOW = §aAll TNT-positions shown
|
TRACE_MESSAGE_SHOW = §aAll TNT-positions shown
|
||||||
TRACE_MESSAGE_HIDE = §cAll TNT-positions hidden
|
TRACE_MESSAGE_HIDE = §cAll TNT-positions hidden
|
||||||
TRACE_MESSAGE_ISOLATE = §aTNT-positions isolated
|
|
||||||
TRACE_MESSAGE_UNISOLATE = §cTNT-positions hidden
|
|
||||||
TRACE_MESSAGE_CLICK_ISOLATE = §eClick to §aisolate§8/§cunisolate
|
TRACE_MESSAGE_CLICK_ISOLATE = §eClick to §aisolate§8/§cunisolate
|
||||||
TRACE_MESSAGE_DISALLOWED = §cYou are not allowed to use the TNT-Tracer here
|
TRACE_MESSAGE_DISALLOWED = §cYou are not allowed to use the TNT-Tracer here
|
||||||
|
|
||||||
@ -507,12 +505,6 @@ TRACE_COMMAND_HELP_AUTO = §8/§etrace toggleauto §8- §7Automatic start of rec
|
|||||||
TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Shows all TNT-positions
|
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_HIDE = §8/§etrace hide §8- §7Hides all TNT-positions
|
||||||
TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Deletes all TNT-positions
|
TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Deletes all TNT-positions
|
||||||
TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Shows the Trace GUI
|
|
||||||
TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8[§7tick§8] §8- §7Replays your recording
|
|
||||||
TRACE_COMMAND_HELP_REPLAY_DISABLE = §8/§etrace replay disable §8- §7Stops the replay
|
|
||||||
TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8[§7step§8] §8- §7Jump one§8/§7step tick forward
|
|
||||||
TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8[§7step§8] §8- §7Jump one§8/§7step tick back
|
|
||||||
TRACE_COMMAND_HELP_REPLAY_LOOP = §8/§etrace replay loop §8<§7start§8> §8<§7end§8> §8[§7speed§8] §8- §7Loop the replay
|
|
||||||
|
|
||||||
TRACE_GUI_ITEM_NAME = §eTracer
|
TRACE_GUI_ITEM_NAME = §eTracer
|
||||||
TRACE_GUI_ITEM_LORE = §7Status§8: {0}
|
TRACE_GUI_ITEM_LORE = §7Status§8: {0}
|
||||||
@ -524,19 +516,6 @@ TRACE_GUI_AUTO_TRACE_INACTIVE = §eacitvate Auto-Tracer
|
|||||||
TRACE_GUI_AUTO_TRACE_ACTIVE = §edeactivate Auto-Tracer
|
TRACE_GUI_AUTO_TRACE_ACTIVE = §edeactivate Auto-Tracer
|
||||||
TRACE_GUI_DELETE = §eDelete trace
|
TRACE_GUI_DELETE = §eDelete trace
|
||||||
|
|
||||||
TRACE_GUI_TITLE = Trace GUI
|
|
||||||
TRACE_GUI_ITEM_BACK = §eBack
|
|
||||||
TRACE_GUI_ITEM = §eTrace §8- §e{0} §7TNT
|
|
||||||
TRACE_GUI_CLEAR = §eDelete traces
|
|
||||||
TRACE_GUI_RECORD_ITEM = §eTNT §8- §e{0} §7Positions
|
|
||||||
TRACE_GUI_RECORD_CLEAR = §eDelete TNT
|
|
||||||
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}
|
|
||||||
|
|
||||||
# Loader
|
# Loader
|
||||||
LOADER_SETUP = §eSetup
|
LOADER_SETUP = §eSetup
|
||||||
LOADER_RUNNING = §aRunning
|
LOADER_RUNNING = §aRunning
|
||||||
|
@ -464,8 +464,6 @@ TRACE_MESSAGE_STOP = §cTNT-Tracer gestoppt
|
|||||||
TRACE_MESSAGE_DELETE = §cAlle TNT-Positionen gelöscht
|
TRACE_MESSAGE_DELETE = §cAlle TNT-Positionen gelöscht
|
||||||
TRACE_MESSAGE_SHOW = §aAlle TNT-Positionen angezeigt
|
TRACE_MESSAGE_SHOW = §aAlle TNT-Positionen angezeigt
|
||||||
TRACE_MESSAGE_HIDE = §cAlle TNT-Positionen ausgeblendet
|
TRACE_MESSAGE_HIDE = §cAlle TNT-Positionen ausgeblendet
|
||||||
TRACE_MESSAGE_ISOLATE = §aTNT-Positionen isoliert
|
|
||||||
TRACE_MESSAGE_UNISOLATE = §cTNT-Positionen ausgeblendet
|
|
||||||
TRACE_MESSAGE_CLICK_ISOLATE = §eKlicken zum §aisolieren§8/§causblenden
|
TRACE_MESSAGE_CLICK_ISOLATE = §eKlicken zum §aisolieren§8/§causblenden
|
||||||
TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen
|
TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen
|
||||||
|
|
||||||
@ -476,12 +474,6 @@ TRACE_COMMAND_HELP_AUTO = §8/§etrace toggleauto §8- §7Automatischer Aufnahme
|
|||||||
TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Zeigt alle TNT-Positionen
|
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_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_DELETE = §8/§etrace delete §8- §7Löscht alle TNT-Positionen
|
||||||
TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Zeigt die Trace Oberfläche an
|
|
||||||
TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8[§7Tick§8] §8- §7Replayes die Aufnahme
|
|
||||||
TRACE_COMMAND_HELP_REPLAY_DISABLE = §8/§etrace replay disable §8- §7Stoppt das Replay
|
|
||||||
TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8[§7Step§8] §8- §7Springe einen§8/§7step Tick vor
|
|
||||||
TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8[§7Step§8] §8- §7Springe einen§8/§7step Tick zurück
|
|
||||||
TRACE_COMMAND_HELP_REPLAY_LOOP = §8/§etrace replay loop §8<§7start§8> §8<§7end§8> §8[§7speed§8] §8- §7Spielt die Aufnahme in einer Schleife ab
|
|
||||||
|
|
||||||
TRACE_GUI_ITEM_NAME = §eTracer
|
TRACE_GUI_ITEM_NAME = §eTracer
|
||||||
TRACE_GUI_ITEM_LORE = §7Status§8: {0}
|
TRACE_GUI_ITEM_LORE = §7Status§8: {0}
|
||||||
@ -493,19 +485,6 @@ TRACE_GUI_AUTO_TRACE_INACTIVE = §eAuto-Tracer Aktivieren
|
|||||||
TRACE_GUI_AUTO_TRACE_ACTIVE = §eAuto-Tracer Deaktivieren
|
TRACE_GUI_AUTO_TRACE_ACTIVE = §eAuto-Tracer Deaktivieren
|
||||||
TRACE_GUI_DELETE = §eTrace Löschen
|
TRACE_GUI_DELETE = §eTrace Löschen
|
||||||
|
|
||||||
TRACE_GUI_TITLE = Trace GUI
|
|
||||||
TRACE_GUI_ITEM_BACK = §eBack
|
|
||||||
TRACE_GUI_ITEM = §eTrace §8- §e{0} §7TNT
|
|
||||||
TRACE_GUI_CLEAR = §eTraces löschen
|
|
||||||
TRACE_GUI_RECORD_ITEM = §eTNT §8- §e{0} §7Positionen
|
|
||||||
TRACE_GUI_RECORD_CLEAR = §eTNT löschen
|
|
||||||
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}
|
|
||||||
|
|
||||||
# Loader
|
# Loader
|
||||||
LOADER_SETUP = §eEinrichtung
|
LOADER_SETUP = §eEinrichtung
|
||||||
LOADER_RUNNING = §aLaufend
|
LOADER_RUNNING = §aLaufend
|
||||||
|
@ -125,6 +125,6 @@ public class BossbarLib implements LuaLib {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return null;
|
return table;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,7 @@ package de.steamwar.bausystem.features.tracer;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.features.tracer.gui.TraceGui;
|
|
||||||
import de.steamwar.bausystem.features.tracer.record.*;
|
import de.steamwar.bausystem.features.tracer.record.*;
|
||||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
|
||||||
import de.steamwar.bausystem.features.tracer.show.*;
|
import de.steamwar.bausystem.features.tracer.show.*;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.shared.ShowMode;
|
import de.steamwar.bausystem.shared.ShowMode;
|
||||||
@ -104,9 +102,6 @@ public class TraceCommand extends SWCommand {
|
|||||||
@Register(value = {"hide"}, description = "TRACE_COMMAND_HELP_HIDE")
|
@Register(value = {"hide"}, description = "TRACE_COMMAND_HELP_HIDE")
|
||||||
public void hideCommand(@Validator Player p) {
|
public void hideCommand(@Validator Player p) {
|
||||||
TraceShowManager.hide(p);
|
TraceShowManager.hide(p);
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
StoredRecords.hideIsolated(region, p);
|
|
||||||
StoredRecords.removeReplayTime(region, p);
|
|
||||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p);
|
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,97 +110,9 @@ public class TraceCommand extends SWCommand {
|
|||||||
public void deleteCommand(@Validator Player p) {
|
public void deleteCommand(@Validator Player p) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
StoredRecords.clear(region);
|
StoredRecords.clear(region);
|
||||||
StoredRecords.hideIsolated(region);
|
|
||||||
StoredRecords.removeReplayTime(region);
|
|
||||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p);
|
BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = {"gui"}, description = "TRACE_COMMAND_HELP_GUI")
|
|
||||||
public void guiCommand(@Validator Player p) {
|
|
||||||
TraceGui.openGui(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "isolate", noTabComplete = true)
|
|
||||||
public void isolate(Player p, String s) {
|
|
||||||
try {
|
|
||||||
UUID uuid = UUID.fromString(s);
|
|
||||||
Record.TNTRecord tntRecord = StoredRecords.getRecord(uuid);
|
|
||||||
StoredRecords.toggleIsolate(p, tntRecord);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "replay", description = "TRACE_COMMAND_HELP_REPLAY")
|
|
||||||
public void replay(@Validator Player p, @OptionalValue("0") int replayTick) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
if (replayTick < 0) replayTick = 0;
|
|
||||||
StoredRecords.setReplayTime(region, p, replayTick);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = {"replay", "disable"}, description = "TRACE_COMMAND_HELP_REPLAY_DISABLE")
|
|
||||||
public void replayDisable(@Validator Player p) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
StoredRecords.removeReplayTime(region, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = {"replay", "next"}, description = "TRACE_COMMAND_HELP_REPLAY_NEXT")
|
|
||||||
public void replayNext(@Validator Player p, @OptionalValue("1") int step) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
int replayTick = StoredRecords.getReplayTime(region, p);
|
|
||||||
StoredRecords.setReplayTime(region, p, replayTick + step);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = {"replay", "previous"}, description = "TRACE_COMMAND_HELP_REPLAY_PREVIOUS")
|
|
||||||
public void replayPrevious(@Validator Player p, @OptionalValue("1") int step) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
int replayTick = StoredRecords.getReplayTime(region, p) - step;
|
|
||||||
if (replayTick < 0) replayTick = 0;
|
|
||||||
StoredRecords.setReplayTime(region, p, replayTick);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = {"replay", "loop"}, description = "TRACE_COMMAND_HELP_REPLAY_LOOP")
|
|
||||||
public void replayLoop(@Validator Player p, int start, int end, @OptionalValue("0") int speed) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
|
|
||||||
if (start < 0) start = 0;
|
|
||||||
if (end < 0) end = 0;
|
|
||||||
|
|
||||||
int initial = StoredRecords.getReplayTime(region, p);
|
|
||||||
if (!(Math.min(start, end) < initial && Math.max(start, end) > initial)) {
|
|
||||||
initial = start;
|
|
||||||
}
|
|
||||||
int finalInitial = initial;
|
|
||||||
|
|
||||||
int finalStart = start;
|
|
||||||
int finalEnd = end;
|
|
||||||
Supplier<Integer> supplier = new Supplier<Integer>() {
|
|
||||||
int temp = speed;
|
|
||||||
int current = finalInitial;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer get() {
|
|
||||||
if (temp-- > 0) {
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
temp = speed;
|
|
||||||
if (finalEnd > finalStart) {
|
|
||||||
current++;
|
|
||||||
if (current > finalEnd) {
|
|
||||||
current = finalStart;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
current--;
|
|
||||||
if (current < finalEnd) {
|
|
||||||
current = finalStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
StoredRecords.setReplayLoop(region, p, supplier);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
private enum ShowModeType {
|
private enum ShowModeType {
|
||||||
ENTITY((player, showModeParameter) -> new EntityShowMode(player, showModeParameter, 10)),
|
ENTITY((player, showModeParameter) -> new EntityShowMode(player, showModeParameter, 10)),
|
||||||
|
@ -1,108 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.gui;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
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;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class TraceGui {
|
|
||||||
|
|
||||||
public static void openGui(Player player) {
|
|
||||||
Region region = Region.getRegion(player.getLocation());
|
|
||||||
List<SWListInv.SWListEntry<Record>> recordList = new ArrayList<>();
|
|
||||||
StoredRecords.getRecords(region).forEach(record -> {
|
|
||||||
if (record.getTnt().isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SWItem swItem = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM", player, record.size()));
|
|
||||||
recordList.add(new SWListInv.SWListEntry<>(swItem, record));
|
|
||||||
});
|
|
||||||
SWListInv<Record> recordSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, recordList, (clickType, record) -> {
|
|
||||||
openRecordGui(player, record);
|
|
||||||
});
|
|
||||||
recordSWListInv.setItem(49, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_CLEAR", player), clickType -> {
|
|
||||||
StoredRecords.clear(region);
|
|
||||||
player.getOpenInventory().close();
|
|
||||||
}));
|
|
||||||
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<>(), StoredRecords.isIsolated(player, tntRecord), 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()) {
|
|
||||||
StoredRecords.toggleIsolate(player, tntRecord);
|
|
||||||
openRecordGui(player, record);
|
|
||||||
} else {
|
|
||||||
openTntGui(player, record, tntRecord);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
tntRecordSWListInv.setItem(48, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_CLEAR", player), clickType -> {
|
|
||||||
StoredRecords.remove(region, record);
|
|
||||||
TraceShowManager.reshow(region);
|
|
||||||
openGui(player);
|
|
||||||
}));
|
|
||||||
tntRecordSWListInv.setItem(50, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_BACK", player), clickType -> {
|
|
||||||
openGui(player);
|
|
||||||
}));
|
|
||||||
tntRecordSWListInv.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void openTntGui(Player player, Record record, Record.TNTRecord tntRecord) {
|
|
||||||
List<SWListInv.SWListEntry<TNTPosition>> positionList = new ArrayList<>();
|
|
||||||
tntRecord.getPositions().forEach(tntPosition -> {
|
|
||||||
SWItem swItem = new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_ITEM", player));
|
|
||||||
swItem.setLore(Arrays.asList(
|
|
||||||
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_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) -> {
|
|
||||||
});
|
|
||||||
tntPositionSWListInv.setItem(49, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_BACK", player), clickType -> {
|
|
||||||
openRecordGui(player, record);
|
|
||||||
}));
|
|
||||||
tntPositionSWListInv.open();
|
|
||||||
}
|
|
||||||
}
|
|
@ -104,8 +104,8 @@ public class Recorder implements Listener {
|
|||||||
StoredRecords.add(region, record);
|
StoredRecords.add(region, record);
|
||||||
return record;
|
return record;
|
||||||
});
|
});
|
||||||
tntTraceRecorderMap.forEach((tntPrimed, region1) -> {
|
tntTraceRecorderMap.forEach((tntPrimed, rg) -> {
|
||||||
if (region1 == region) {
|
if (rg == region) {
|
||||||
traceRecorder.spawn(tntPrimed);
|
traceRecorder.spawn(tntPrimed);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -19,46 +19,20 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.tracer.show;
|
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.TNTPosition;
|
||||||
import de.steamwar.bausystem.features.tracer.record.Recorder;
|
import de.steamwar.bausystem.features.tracer.record.Recorder;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.shared.ShowMode;
|
import de.steamwar.bausystem.shared.ShowMode;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class StoredRecords {
|
public class StoredRecords {
|
||||||
|
|
||||||
private static final Map<Region, Map<Player, List<Record.TNTRecord>>> isolatedTNT = new HashMap<>();
|
|
||||||
private static final Map<Region, Map<Player, Integer>> replayTime = new HashMap<>();
|
|
||||||
private static final Map<Region, Map<Player, Supplier<Integer>>> replayLoops = new HashMap<>();
|
|
||||||
private static final Map<Region, List<Record>> records = new HashMap<>();
|
private static final Map<Region, List<Record>> records = new HashMap<>();
|
||||||
|
|
||||||
static {
|
|
||||||
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
|
||||||
replayLoops.forEach((region, playerSupplierMap) -> {
|
|
||||||
playerSupplierMap.forEach((player, integerSupplier) -> {
|
|
||||||
int tick = integerSupplier.get();
|
|
||||||
replayTime.computeIfAbsent(region, __ -> new HashMap<>()).put(player, tick);
|
|
||||||
TraceShowManager.reshow(region, player);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cleanup(Player player) {
|
|
||||||
isolatedTNT.forEach((region, playerListMap) -> playerListMap.remove(player));
|
|
||||||
replayTime.forEach((region, playerIntegerMap) -> playerIntegerMap.remove(player));
|
|
||||||
replayLoops.forEach((region, playerIntegerMap) -> playerIntegerMap.remove(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void add(Region region, Record record) {
|
public static void add(Region region, Record record) {
|
||||||
records.computeIfAbsent(region, k -> new ArrayList<>()).add(record);
|
records.computeIfAbsent(region, k -> new ArrayList<>()).add(record);
|
||||||
}
|
}
|
||||||
@ -93,107 +67,12 @@ public class StoredRecords {
|
|||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isIsolated(Player p, Record.TNTRecord tntRecord) {
|
static void show(Region region, ShowMode<TNTPosition> traceShowMode) {
|
||||||
return isolatedTNT.values()
|
records.getOrDefault(region, new ArrayList<>()).forEach(record -> {
|
||||||
.stream()
|
record.getTnt().forEach(tntRecord -> {
|
||||||
.filter(map -> map.containsKey(p))
|
tntRecord.getPositions()
|
||||||
.anyMatch(map -> map.get(p).contains(tntRecord));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void toggleIsolate(Player p, Record.TNTRecord tntRecord) {
|
|
||||||
List<Record.TNTRecord> tntRecords = isolatedTNT.computeIfAbsent(tntRecord.getRegion(), k -> new HashMap<>())
|
|
||||||
.computeIfAbsent(p, k -> new ArrayList<>());
|
|
||||||
if (tntRecords.contains(tntRecord)) {
|
|
||||||
tntRecords.remove(tntRecord);
|
|
||||||
if (tntRecords.isEmpty()) {
|
|
||||||
isolatedTNT.get(tntRecord.getRegion()).remove(p);
|
|
||||||
if (isolatedTNT.get(tntRecord.getRegion()).isEmpty()) {
|
|
||||||
isolatedTNT.remove(tntRecord.getRegion());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tntRecords.add(tntRecord);
|
|
||||||
}
|
|
||||||
TraceShowManager.reshow(tntRecord.getRegion(), p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void hideIsolated(Region region) {
|
|
||||||
isolatedTNT.remove(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void hideIsolated(Region region, Player player) {
|
|
||||||
Map<Player, List<Record.TNTRecord>> regionalIsolatedTNT = isolatedTNT.get(region);
|
|
||||||
if (regionalIsolatedTNT == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
regionalIsolatedTNT.remove(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getReplayTime(Region region, Player player) {
|
|
||||||
return replayTime.computeIfAbsent(region, k -> new HashMap<>()).getOrDefault(player, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeReplayTime(Region region) {
|
|
||||||
replayTime.remove(region);
|
|
||||||
replayLoops.remove(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeReplayTime(Region region, Player player) {
|
|
||||||
Map<Player, Integer> regionalReplayTime = replayTime.get(region);
|
|
||||||
if (regionalReplayTime != null) {
|
|
||||||
regionalReplayTime.remove(player);
|
|
||||||
}
|
|
||||||
Map<Player, Supplier<Integer>> regionalReplayLoops = replayLoops.get(region);
|
|
||||||
if (regionalReplayLoops != null) {
|
|
||||||
regionalReplayLoops.remove(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setReplayTime(Region region, Player player, int time) {
|
|
||||||
if (time < 0) {
|
|
||||||
removeReplayTime(region, player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
replayTime.computeIfAbsent(region, k -> new HashMap<>()).put(player, time);
|
|
||||||
TraceShowManager.reshow(region, player);
|
|
||||||
|
|
||||||
Map<Player, Supplier<Integer>> regionalReplayLoops = replayLoops.get(region);
|
|
||||||
if (regionalReplayLoops != null) {
|
|
||||||
regionalReplayLoops.remove(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setReplayLoop(Region region, Player player, Supplier<Integer> loop) {
|
|
||||||
replayLoops.computeIfAbsent(region, k -> new HashMap<>()).put(player, loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Predicate<TNTPosition> replayTimeFilter(Region region, Player player) {
|
|
||||||
Predicate<TNTPosition> replayTimeFilter = tntPosition -> true;
|
|
||||||
if (replayTime.containsKey(region) && replayTime.get(region).containsKey(player)) {
|
|
||||||
int time = replayTime.get(region).get(player);
|
|
||||||
replayTimeFilter = tntPosition -> (80 - tntPosition.getFuseTicks()) + tntPosition.getRecord().getOffset() == time;
|
|
||||||
}
|
|
||||||
return replayTimeFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void show(Region region, Player player, ShowMode<TNTPosition> traceShowMode) {
|
|
||||||
Predicate<TNTPosition> replayTimeFilter = replayTimeFilter(region, player);
|
|
||||||
if (isolatedTNT.containsKey(region) && isolatedTNT.get(region).containsKey(player)) {
|
|
||||||
isolatedTNT.get(region).get(player).forEach(record -> {
|
|
||||||
record.getPositions()
|
|
||||||
.stream()
|
|
||||||
.filter(replayTimeFilter)
|
|
||||||
.forEach(traceShowMode::show);
|
.forEach(traceShowMode::show);
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
records.getOrDefault(region, new ArrayList<>()).forEach(record -> {
|
|
||||||
record.getTnt().forEach(tntRecord -> {
|
|
||||||
tntRecord.getPositions()
|
|
||||||
.stream()
|
|
||||||
.filter(replayTimeFilter)
|
|
||||||
.forEach(traceShowMode::show);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,19 +23,14 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.features.tracer.TNTPosition;
|
import de.steamwar.bausystem.features.tracer.TNTPosition;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.shared.ShowMode;
|
import de.steamwar.bausystem.shared.ShowMode;
|
||||||
import de.steamwar.entity.REntity;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
public class TraceShowManager implements Listener {
|
public class TraceShowManager implements Listener {
|
||||||
private TraceShowManager() {
|
private TraceShowManager() {
|
||||||
@ -49,7 +44,7 @@ public class TraceShowManager implements Listener {
|
|||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.computeIfAbsent(region, __ -> new HashMap<>());
|
Map<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.computeIfAbsent(region, __ -> new HashMap<>());
|
||||||
regionalShowModes.put(player, traceShowMode);
|
regionalShowModes.put(player, traceShowMode);
|
||||||
StoredRecords.show(region, player, traceShowMode);
|
StoredRecords.show(region, traceShowMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void hide(Player player) {
|
public static void hide(Player player) {
|
||||||
@ -75,7 +70,7 @@ public class TraceShowManager implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showMode.hide();
|
showMode.hide();
|
||||||
StoredRecords.show(region, p, showMode);
|
StoredRecords.show(region, showMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reshow(Region region) {
|
public static void reshow(Region region) {
|
||||||
@ -85,7 +80,7 @@ public class TraceShowManager implements Listener {
|
|||||||
}
|
}
|
||||||
for (Map.Entry<Player, ShowMode<TNTPosition>> entry : regionalShowModes.entrySet()) {
|
for (Map.Entry<Player, ShowMode<TNTPosition>> entry : regionalShowModes.entrySet()) {
|
||||||
entry.getValue().hide();
|
entry.getValue().hide();
|
||||||
StoredRecords.show(region, entry.getKey(), entry.getValue());
|
StoredRecords.show(region, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,8 +91,7 @@ public class TraceShowManager implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
regionalShowModes.forEach((player, tntPositionShowMode) -> {
|
regionalShowModes.forEach((player, tntPositionShowMode) -> {
|
||||||
Predicate<TNTPosition> replayTimeFilter = StoredRecords.replayTimeFilter(region, player);
|
tntPositionShowMode.show(tnt);
|
||||||
if (replayTimeFilter.test(tnt)) tntPositionShowMode.show(tnt);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +115,5 @@ public class TraceShowManager implements Listener {
|
|||||||
ShowMode<TNTPosition> showMode = playerShowModeMap.remove(event.getPlayer());
|
ShowMode<TNTPosition> showMode = playerShowModeMap.remove(event.getPlayer());
|
||||||
if (showMode != null) showMode.hide();
|
if (showMode != null) showMode.hide();
|
||||||
});
|
});
|
||||||
StoredRecords.cleanup(event.getPlayer());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren