Fix TraceTNTClickListener Add Trace isolation Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
41a457920d
Commit
dd5c932f15
@ -45,11 +45,11 @@ public class TraceEntity19 extends BaseEntity19 implements AbstractTraceEntity {
|
|||||||
public void display(Player player, boolean exploded, int ticks) {
|
public void display(Player player, boolean exploded, int ticks) {
|
||||||
if (ticks != -1) {
|
if (ticks != -1) {
|
||||||
this.n(true);
|
this.n(true);
|
||||||
this.a(IChatMutableComponent.a(new LiteralContents(ticks + "")));
|
this.b(IChatMutableComponent.a(new LiteralContents(ticks + "")));
|
||||||
}
|
}
|
||||||
if (!this.exploded && exploded) {
|
if (!this.exploded && exploded) {
|
||||||
this.n(true);
|
this.n(true);
|
||||||
this.a(IChatMutableComponent.a(new LiteralContents("Bumm")));
|
this.b(IChatMutableComponent.a(new LiteralContents("Bumm")));
|
||||||
this.exploded = true;
|
this.exploded = true;
|
||||||
if (referenceCounter.increment() > 0) {
|
if (referenceCounter.increment() > 0) {
|
||||||
sendEntityDestroy(player);
|
sendEntityDestroy(player);
|
||||||
|
@ -696,6 +696,9 @@ 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_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_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
|
||||||
@ -1243,6 +1246,7 @@ TNT_CLICK_VELOCITY_X = §7Velocity §eX§8: §e{0}
|
|||||||
TNT_CLICK_VELOCITY_Y = §7Velocity §eY§8: §e{0}
|
TNT_CLICK_VELOCITY_Y = §7Velocity §eY§8: §e{0}
|
||||||
TNT_CLICK_VELOCITY_Z = §7Velocity §eZ§8: §e{0}
|
TNT_CLICK_VELOCITY_Z = §7Velocity §eZ§8: §e{0}
|
||||||
TNT_CLICK_COUNT = §7Count §8: §e{0}
|
TNT_CLICK_COUNT = §7Count §8: §e{0}
|
||||||
|
TNT_CLICK_ISOLATE = §eIsolate
|
||||||
|
|
||||||
SELECT_ITEM_CHOOSE_EXTENSION = Choose extension
|
SELECT_ITEM_CHOOSE_EXTENSION = Choose extension
|
||||||
SELECT_ITEM_CHOOSE_SELECTION = Choose selection
|
SELECT_ITEM_CHOOSE_SELECTION = Choose selection
|
||||||
|
@ -676,6 +676,9 @@ 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_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen
|
TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen
|
||||||
|
|
||||||
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
|
||||||
|
@ -293,6 +293,22 @@ public class TraceCommand extends SWCommand {
|
|||||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_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)
|
@ClassValidator(value = Player.class, local = true)
|
||||||
public TypeValidator<Player> validator() {
|
public TypeValidator<Player> validator() {
|
||||||
return (commandSender, player, messageSender) -> {
|
return (commandSender, player, messageSender) -> {
|
||||||
|
@ -26,6 +26,7 @@ import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
|
|||||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.api.Plain;
|
import de.steamwar.linkage.api.Plain;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.RayTraceResult;
|
import org.bukkit.util.RayTraceResult;
|
||||||
@ -42,8 +43,8 @@ public class TraceTNTClickListener implements Plain {
|
|||||||
Set<Player> playerSet = new HashSet<>();
|
Set<Player> playerSet = new HashSet<>();
|
||||||
|
|
||||||
TinyProtocol.instance.addFilter(useEntity, (player, o) -> {
|
TinyProtocol.instance.addFilter(useEntity, (player, o) -> {
|
||||||
if (!playerSet.add(player)) return o;
|
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
if (!playerSet.add(player)) return;
|
||||||
RayTraceResult rayTraceResult = RayTraceUtils.trace(player, player.getLocation(), TraceShowManager.getEntities(player));
|
RayTraceResult rayTraceResult = RayTraceUtils.trace(player, player.getLocation(), TraceShowManager.getEntities(player));
|
||||||
if (rayTraceResult == null) return;
|
if (rayTraceResult == null) return;
|
||||||
if (rayTraceResult.getHitEntity() == null) return;
|
if (rayTraceResult.getHitEntity() == null) return;
|
||||||
@ -58,8 +59,11 @@ public class TraceTNTClickListener implements Plain {
|
|||||||
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_X", player, tntPosition.getVelocity().getX() + "");
|
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_Y", player, tntPosition.getVelocity().getY() + "");
|
||||||
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Z", player, tntPosition.getVelocity().getZ() + "");
|
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Z", player, tntPosition.getVelocity().getZ() + "");
|
||||||
playerSet.remove(player);
|
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);
|
}, 1);
|
||||||
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
|
playerSet.remove(player);
|
||||||
|
}, 2);
|
||||||
return o;
|
return o;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -62,14 +62,24 @@ public class TraceGui {
|
|||||||
public static void openRecordGui(Player player, Record record) {
|
public static void openRecordGui(Player player, Record record) {
|
||||||
List<SWListInv.SWListEntry<Record.TNTRecord>> recordList = new ArrayList<>();
|
List<SWListInv.SWListEntry<Record.TNTRecord>> recordList = new ArrayList<>();
|
||||||
record.getTnt().forEach(tntRecord -> {
|
record.getTnt().forEach(tntRecord -> {
|
||||||
SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_ITEM", player, tntRecord.getPositions().size()));
|
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 -> {
|
||||||
|
});
|
||||||
recordList.add(new SWListInv.SWListEntry<>(swItem, tntRecord));
|
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) -> {
|
SWListInv<Record.TNTRecord> tntRecordSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, recordList, (clickType, tntRecord) -> {
|
||||||
openTntGui(player, record, tntRecord);
|
if (clickType.isShiftClick()) {
|
||||||
|
if (TraceShowManager.isIsolated(player, tntRecord)) {
|
||||||
|
TraceShowManager.unisolate(player, tntRecord);
|
||||||
|
} else {
|
||||||
|
TraceShowManager.isolate(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 -> {
|
tntRecordSWListInv.setItem(48, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_CLEAR", player), clickType -> {
|
||||||
StoredRecords.getRecords().remove(record);
|
StoredRecords.remove(record);
|
||||||
TraceShowManager.reshow();
|
TraceShowManager.reshow();
|
||||||
openGui(player);
|
openGui(player);
|
||||||
}));
|
}));
|
||||||
|
@ -2,6 +2,7 @@ package de.steamwar.bausystem.features.tracer.show;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
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.show.mode.TraceEntityShowMode;
|
||||||
import de.steamwar.bausystem.shared.ShowMode;
|
import de.steamwar.bausystem.shared.ShowMode;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -10,24 +11,48 @@ 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.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class TraceShowManager implements Listener {
|
public class TraceShowManager implements Listener {
|
||||||
private TraceShowManager() {
|
private TraceShowManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Map<Player, Set<Record.TNTRecord>> playerIsolatedRecords = new HashMap<>();
|
||||||
private static final Map<Player, ShowMode<TNTPosition>> showModes = 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);
|
||||||
|
}
|
||||||
|
|
||||||
public static void show(Player player, ShowMode<TNTPosition> traceShowMode) {
|
public static void show(Player player, ShowMode<TNTPosition> traceShowMode) {
|
||||||
|
Set<Record.TNTRecord> isolatedRecords = playerIsolatedRecords.get(player);
|
||||||
hide(player);
|
hide(player);
|
||||||
showModes.put(player, traceShowMode);
|
showModes.put(player, traceShowMode);
|
||||||
StoredRecords.showAll(traceShowMode);
|
if (isolatedRecords != null && !isolatedRecords.isEmpty()) {
|
||||||
|
playerIsolatedRecords.put(player, isolatedRecords);
|
||||||
|
for (Record.TNTRecord record : isolatedRecords) {
|
||||||
|
record.getPositions().forEach(traceShowMode::show);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
StoredRecords.showAll(traceShowMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void hide(Player player) {
|
public static void hide(Player player) {
|
||||||
|
playerIsolatedRecords.remove(player);
|
||||||
ShowMode<TNTPosition> traceShowMode = showModes.remove(player);
|
ShowMode<TNTPosition> traceShowMode = showModes.remove(player);
|
||||||
if (traceShowMode == null)
|
if (traceShowMode == null)
|
||||||
return;
|
return;
|
||||||
@ -63,12 +88,15 @@ public class TraceShowManager implements Listener {
|
|||||||
|
|
||||||
/* Only to be called by record */
|
/* Only to be called by record */
|
||||||
static void show(TNTPosition tnt) {
|
static void show(TNTPosition tnt) {
|
||||||
for (ShowMode<TNTPosition> mode : showModes.values())
|
for (Map.Entry<Player, ShowMode<TNTPosition>> entry : showModes.entrySet()) {
|
||||||
mode.show(tnt);
|
if (playerIsolatedRecords.containsKey(entry.getKey())) continue;
|
||||||
|
entry.getValue().show(tnt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only to be called by StoredRecords */
|
/* Only to be called by StoredRecords */
|
||||||
static void clear() {
|
static void clear() {
|
||||||
|
playerIsolatedRecords.clear();
|
||||||
for (ShowMode<TNTPosition> mode : showModes.values())
|
for (ShowMode<TNTPosition> mode : showModes.values())
|
||||||
mode.hide();
|
mode.hide();
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren