Add Tracer to global Region
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
5d56f4238d
Commit
3d4468ef8c
@ -763,7 +763,6 @@ TRACE_MESSAGE_ISOLATE = §aTNT-positions isolated
|
|||||||
TRACE_MESSAGE_UNISOLATE = §cTNT-positions hidden
|
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
|
||||||
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_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_SINGLE = §8/§etrace single §8- §7Starts a single recording of all TNT-positions
|
||||||
|
@ -735,7 +735,6 @@ TRACE_MESSAGE_ISOLATE = §aTNT-Positionen isoliert
|
|||||||
TRACE_MESSAGE_UNISOLATE = §cTNT-Positionen ausgeblendet
|
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
|
||||||
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_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_SINGLE = §8/§etrace single §8- §7Startet eine einzelne Aufnahme aller TNT-Positionen
|
||||||
|
@ -25,7 +25,6 @@ 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.Record;
|
||||||
import de.steamwar.bausystem.features.tracer.show.*;
|
import de.steamwar.bausystem.features.tracer.show.*;
|
||||||
import de.steamwar.bausystem.features.tracer.show.EntityShowMode;
|
|
||||||
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.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
@ -262,11 +261,6 @@ public class TraceCommand extends SWCommand {
|
|||||||
messageSender.send("TRACE_MESSAGE_DISALLOWED", player);
|
messageSender.send("TRACE_MESSAGE_DISALLOWED", player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Region region = Region.getRegion(player.getLocation());
|
|
||||||
if (region.isGlobal()) {
|
|
||||||
messageSender.send("TRACE_MESSAGE_NO_REGION", player);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,15 @@ package de.steamwar.bausystem.features.tracer;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.tracer.record.Recorder;
|
import de.steamwar.bausystem.features.tracer.record.Recorder;
|
||||||
|
import de.steamwar.bausystem.features.tracer.show.Record;
|
||||||
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
|
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TraceScoreboardElement implements ScoreboardElement {
|
public class TraceScoreboardElement implements ScoreboardElement {
|
||||||
|
|
||||||
@ -45,9 +48,14 @@ public class TraceScoreboardElement implements ScoreboardElement {
|
|||||||
String traceScore = Recorder.INSTANCE.get(region).scoreboard(p);
|
String traceScore = Recorder.INSTANCE.get(region).scoreboard(p);
|
||||||
if (traceScore != null) {
|
if (traceScore != null) {
|
||||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + traceScore;
|
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + traceScore;
|
||||||
} else if (!(Recorder.INSTANCE.get(region) instanceof Recorder.NoopTraceRecorder) && !StoredRecords.getRecords(region).isEmpty()) {
|
|
||||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse("TRACE_HAS_TRACES", p);
|
|
||||||
}
|
}
|
||||||
return null;
|
List<Record> records = StoredRecords.getRecords(region);
|
||||||
|
if (records.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (records.stream().allMatch(record -> record.getTnt().isEmpty())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse("TRACE_HAS_TRACES", p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
import de.steamwar.bausystem.region.utils.RegionType;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
@ -37,7 +36,9 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@ -49,36 +50,6 @@ public class Recorder implements Listener {
|
|||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public 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, boolean b) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String scriptState() {
|
|
||||||
return "OFF";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long scriptTime() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static final NoopTraceRecorder NOOP = new NoopTraceRecorder();
|
|
||||||
|
|
||||||
private static class DisabledTracerRecorder implements TraceRecorder {
|
private static class DisabledTracerRecorder implements TraceRecorder {
|
||||||
@Override
|
@Override
|
||||||
public String scoreboard(Player player) {
|
public String scoreboard(Player player) {
|
||||||
@ -115,8 +86,6 @@ public class Recorder implements Listener {
|
|||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final World world = Bukkit.getWorlds().get(0);
|
|
||||||
|
|
||||||
private Map<Region, TraceRecorder> regionTraceRecorderMap = new HashMap<>();
|
private Map<Region, TraceRecorder> regionTraceRecorderMap = new HashMap<>();
|
||||||
private Map<TNTPrimed, Region> tntTraceRecorderMap = new HashMap<>();
|
private Map<TNTPrimed, Region> tntTraceRecorderMap = new HashMap<>();
|
||||||
|
|
||||||
@ -125,7 +94,7 @@ public class Recorder implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TraceRecorder get(Region region) {
|
public TraceRecorder get(Region region) {
|
||||||
return regionTraceRecorderMap.getOrDefault(region, region.isGlobal() ? NOOP : DISABLED);
|
return regionTraceRecorderMap.getOrDefault(region, DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(Region region, TraceRecorder traceRecorder) {
|
public void set(Region region, TraceRecorder traceRecorder) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren