Add TraceCommand
Add everything for TraceCommand
Dieser Commit ist enthalten in:
Ursprung
861fcde290
Commit
de2bb73444
@ -0,0 +1,59 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TNTTracer_15 {
|
||||
|
||||
public static AbstractTraceEntity create(World world, Vector tntPosition, boolean tnt) {
|
||||
return new TraceEntity_15(world, tntPosition, tnt);
|
||||
}
|
||||
|
||||
public static boolean inWater(World world, Vector tntPosition) {
|
||||
Block block = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ());
|
||||
if (block.getType() == Material.WATER)
|
||||
return true;
|
||||
|
||||
BlockData data = block.getBlockData();
|
||||
if (!(data instanceof Waterlogged))
|
||||
return false;
|
||||
|
||||
return ((Waterlogged) data).isWaterlogged();
|
||||
}
|
||||
|
||||
public static Material getTraceShowMaterial() {
|
||||
return Material.LIME_CONCRETE;
|
||||
}
|
||||
|
||||
public static Material getTraceHideMaterial() {
|
||||
return Material.RED_CONCRETE;
|
||||
}
|
||||
|
||||
public static Material getTraceXZMaterial() {
|
||||
return Material.QUARTZ_SLAB;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.*;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
private final Vector position;
|
||||
private final boolean tnt;
|
||||
|
||||
private boolean exploded = false;
|
||||
private int references = 0;
|
||||
|
||||
public TraceEntity_15(World world, Vector position, boolean tnt) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), tnt ? Blocks.TNT.getBlockData() : Blocks.WHITE_STAINED_GLASS.getBlockData());
|
||||
this.position = position;
|
||||
this.tnt = tnt;
|
||||
|
||||
this.setNoGravity(true);
|
||||
this.ticksLived = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player, boolean exploded) {
|
||||
if (!this.exploded && exploded) {
|
||||
this.setCustomNameVisible(true);
|
||||
this.setCustomName(new ChatComponentText("Bumm"));
|
||||
this.exploded = true;
|
||||
if (references++ > 0)
|
||||
sendDestroy(player);
|
||||
} else if (references++ > 0)
|
||||
return;
|
||||
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, tnt ? Block.getCombinedId(Blocks.TNT.getBlockData()) : Block.getCombinedId(Blocks.WHITE_STAINED_GLASS.getBlockData()), ZERO);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
||||
playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!force && --references > 0)
|
||||
return false;
|
||||
|
||||
sendDestroy(player);
|
||||
die();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface AbstractTraceEntity {
|
||||
|
||||
void display(Player player, boolean exploded);
|
||||
|
||||
boolean hide(Player player, boolean always);
|
||||
|
||||
int getId();
|
||||
|
||||
Entity getBukkitEntity();
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
*
|
||||
* 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;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class RoundedTNTPosition {
|
||||
|
||||
private static final int factor = 10;
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public RoundedTNTPosition(TNTPosition tntPosition) {
|
||||
this(tntPosition.getLocation().getX(), tntPosition.getLocation().getY(), tntPosition.getLocation().getZ());
|
||||
}
|
||||
|
||||
public RoundedTNTPosition(Vector vector) {
|
||||
this(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public RoundedTNTPosition(double x, double y, double z) {
|
||||
this.x = (int) (x * factor);
|
||||
this.y = (int) (y * factor);
|
||||
this.z = (int) (z * factor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof RoundedTNTPosition)) return false;
|
||||
RoundedTNTPosition that = (RoundedTNTPosition) o;
|
||||
return x == that.x &&
|
||||
y == that.y &&
|
||||
z == that.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(x, y, z);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tracer;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TNTPosition {
|
||||
|
||||
private final Record.TNTRecord record;
|
||||
private final Vector location;
|
||||
private final Vector previousLocation;
|
||||
private final boolean exploded;
|
||||
|
||||
public TNTPosition(Record.TNTRecord record, Entity entity, Vector previousLocation, boolean exploded) {
|
||||
this.location = entity.getLocation().toVector();
|
||||
this.record = record;
|
||||
this.previousLocation = previousLocation;
|
||||
this.exploded = exploded;
|
||||
}
|
||||
|
||||
public Vector getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public Vector getPreviousLocation() {
|
||||
return previousLocation;
|
||||
}
|
||||
|
||||
public boolean isExploded() {
|
||||
return exploded;
|
||||
}
|
||||
|
||||
public Record.TNTRecord getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Position{" +
|
||||
"location=" + location +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
|
||||
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.EntityShowMode;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked(LinkageType.COMMAND)
|
||||
public class TraceCommand extends SWCommand {
|
||||
|
||||
public TraceCommand() {
|
||||
super("trace", "trail");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen");
|
||||
p.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer");
|
||||
p.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart");
|
||||
// p.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui");
|
||||
p.sendMessage("§8/§etrace show §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen");
|
||||
p.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen");
|
||||
p.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen");
|
||||
// p.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf");
|
||||
// p.sendMessage("§8/§etrace gui §8- §7Zeigt die Trace Oberfläche an");
|
||||
// p.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]");
|
||||
}
|
||||
|
||||
@Register({"start"})
|
||||
public void startCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
RecordStateMachine.commandStart();
|
||||
p.sendMessage(BauSystem.PREFIX + "§aTNT-Tracer gestartet");
|
||||
}
|
||||
|
||||
@Register({"stop"})
|
||||
public void stopCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
RecordStateMachine.commandStop();
|
||||
p.sendMessage(BauSystem.PREFIX + "§cTNT-Tracer gestoppt");
|
||||
}
|
||||
|
||||
@Register({"toggleauto"})
|
||||
public void toggleAutoCommand(Player p) {
|
||||
autoCommand(p);
|
||||
}
|
||||
|
||||
@Register({"auto"})
|
||||
public void autoCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
RecordStateMachine.commandAuto();
|
||||
p.sendMessage(BauSystem.PREFIX + RecordStateMachine.getRecordStatus().getAutoMessage());
|
||||
}
|
||||
|
||||
@Register({"clear"})
|
||||
public void clearCommand(Player p) {
|
||||
deleteCommand(p);
|
||||
}
|
||||
|
||||
@Register({"delete"})
|
||||
public void deleteCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
StoredRecords.clear();
|
||||
p.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht");
|
||||
}
|
||||
|
||||
@Register({"show"})
|
||||
public void showCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
TraceShowManager.show(p, new EntityShowMode(p, new ShowModeParameter()));
|
||||
p.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
||||
}
|
||||
|
||||
@Register({"show"})
|
||||
public void showCommand(Player p, ShowModeParameterType... showModeParameterTypes) {
|
||||
if (!permissionCheck(p)) return;
|
||||
ShowModeParameter showModeParameter = new ShowModeParameter();
|
||||
for (ShowModeParameterType showModeParameterType : showModeParameterTypes) {
|
||||
showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter);
|
||||
}
|
||||
TraceShowManager.show(p, new EntityShowMode(p, showModeParameter));
|
||||
p.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
||||
}
|
||||
|
||||
@Register({"show", "gui"})
|
||||
public void showGuiCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
// GuiTraceShow.openGui(p);
|
||||
}
|
||||
|
||||
@Register({"hide"})
|
||||
public void hideCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
TraceShowManager.hide(p);
|
||||
p.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet");
|
||||
}
|
||||
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
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 class RecordStateMachine {
|
||||
private 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();
|
||||
}
|
||||
}
|
||||
|
||||
static void autoRecord() {
|
||||
recordStart();
|
||||
recordStatus = RecordStatus.RECORD_AUTO;
|
||||
}
|
||||
|
||||
static void autoIdle() {
|
||||
recordStop();
|
||||
recordStatus = RecordStatus.IDLE_AUTO;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
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("§aan", true, "§cTNT-Tracer muss gestoppt werden"),
|
||||
RECORD_AUTO("§aan", true, "§cTNT-Tracer darf nicht aufnehmen"),
|
||||
IDLE("§caus", false, "§cAuto-Tracer gestoppt"),
|
||||
IDLE_AUTO("§eauto", false, "§aAuto-Tracer gestartet");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
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 de.steamwar.bausystem.features.tracer.show.Record;
|
||||
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
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 java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Recorder implements Listener {
|
||||
|
||||
private static final World world = Bukkit.getWorlds().get(0);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void stopRecording() {
|
||||
HandlerList.unregisterAll(this);
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
int size() {
|
||||
return record.size();
|
||||
}
|
||||
|
||||
long getStartTime() {
|
||||
return record.getStartTime();
|
||||
}
|
||||
|
||||
void postClear() {
|
||||
record.clear();
|
||||
recordMap.clear();
|
||||
StoredRecords.add(record);
|
||||
}
|
||||
|
||||
private void run() {
|
||||
world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> get(tntPrimed).add(tntPrimed));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (!(event.getEntity() 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
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();
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
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.show;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.TNTPosition;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Record {
|
||||
|
||||
private final long startTime;
|
||||
private final List<TNTRecord> tnt = new ArrayList<>();
|
||||
|
||||
public int size() {
|
||||
return tnt.size();
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void showAll(ShowMode mode) {
|
||||
for (TNTRecord record : tnt)
|
||||
record.showAll(mode);
|
||||
}
|
||||
|
||||
/* The following methods should only be called by a recorder */
|
||||
public Record() {
|
||||
startTime = System.currentTimeMillis();
|
||||
StoredRecords.add(this);
|
||||
}
|
||||
|
||||
public TNTRecord spawn() {
|
||||
TNTRecord record = new TNTRecord();
|
||||
tnt.add(record);
|
||||
return record;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
tnt.clear();
|
||||
}
|
||||
|
||||
public static class TNTRecord {
|
||||
private final List<TNTPosition> positions = new ArrayList<>(41);
|
||||
|
||||
public void showAll(ShowMode mode) {
|
||||
for (TNTPosition position : positions)
|
||||
mode.show(position);
|
||||
}
|
||||
|
||||
/* The following methods should only be called by a recorder */
|
||||
public void add(TNTPrimed tntPrimed) {
|
||||
add(tntPrimed, false);
|
||||
}
|
||||
|
||||
private void add(TNTPrimed tntPrimed, boolean exploded) {
|
||||
TNTPosition position;
|
||||
if (positions.isEmpty()) {
|
||||
position = new TNTPosition(this, tntPrimed, null, exploded);
|
||||
} else {
|
||||
position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), exploded);
|
||||
}
|
||||
positions.add(position);
|
||||
TraceShowManager.show(position);
|
||||
}
|
||||
|
||||
public void explode(TNTPrimed tntPrimed) {
|
||||
add(tntPrimed, true);
|
||||
}
|
||||
|
||||
public List<TNTPosition> getPositions() {
|
||||
return positions;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.show;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.TNTPosition;
|
||||
|
||||
public interface ShowMode {
|
||||
void show(TNTPosition position);
|
||||
|
||||
void hide();
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
*
|
||||
* 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.show;
|
||||
|
||||
public class ShowModeParameter {
|
||||
|
||||
private boolean water = false;
|
||||
private boolean interpolate_Y = false;
|
||||
private boolean interpolate_XZ = false;
|
||||
|
||||
public ShowModeParameter() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isWater() {
|
||||
return water;
|
||||
}
|
||||
|
||||
public boolean isInterpolate_Y() {
|
||||
return interpolate_Y;
|
||||
}
|
||||
|
||||
public boolean isInterpolate_XZ() {
|
||||
return interpolate_XZ;
|
||||
}
|
||||
|
||||
public void setWater(boolean water) {
|
||||
this.water = water;
|
||||
}
|
||||
|
||||
public void setInterpolate_Y(boolean interpolate_Y) {
|
||||
this.interpolate_Y = interpolate_Y;
|
||||
}
|
||||
|
||||
public void setInterpolate_XZ(boolean interpolate_XZ) {
|
||||
this.interpolate_XZ = interpolate_XZ;
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.show;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public enum ShowModeParameterType {
|
||||
|
||||
WATER(showModeParameter -> showModeParameter.setWater(true)),
|
||||
INTERPOLATE_Y(showModeParameter -> showModeParameter.setInterpolate_Y(true)),
|
||||
INTERPOLATE_XZ(showModeParameter -> showModeParameter.setInterpolate_XZ(true)),
|
||||
ADVANCED(showModeParameter -> {
|
||||
showModeParameter.setInterpolate_Y(true);
|
||||
showModeParameter.setInterpolate_XZ(true);
|
||||
});
|
||||
|
||||
private final Consumer<ShowModeParameter> showModeParameterConsumer;
|
||||
|
||||
public Consumer<ShowModeParameter> getShowModeParameterConsumer() {
|
||||
return showModeParameterConsumer;
|
||||
}
|
||||
|
||||
ShowModeParameterType(Consumer<ShowModeParameter> showModeParameterConsumer) {
|
||||
this.showModeParameterConsumer = showModeParameterConsumer;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +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/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tracer.show;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StoredRecords {
|
||||
|
||||
private static final List<Record> records = new ArrayList<>();
|
||||
|
||||
public static void add(Record record) {
|
||||
records.add(record);
|
||||
}
|
||||
|
||||
public static void showAll(ShowMode mode) {
|
||||
for (Record record : records) record.showAll(mode);
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
records.clear();
|
||||
TraceShowManager.clear();
|
||||
RecordStateMachine.postClear();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package de.steamwar.bausystem.features.tracer.show;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tracer.TNTPosition;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TraceShowManager implements Listener {
|
||||
private TraceShowManager() {
|
||||
}
|
||||
|
||||
private static final Map<Player, ShowMode> showModes = new HashMap<>();
|
||||
|
||||
public static void show(Player player, ShowMode showMode) {
|
||||
hide(player);
|
||||
showModes.put(player, showMode);
|
||||
StoredRecords.showAll(showMode);
|
||||
}
|
||||
|
||||
public static void hide(Player player) {
|
||||
ShowMode showMode = showModes.remove(player);
|
||||
if (showMode == null)
|
||||
return;
|
||||
showMode.hide();
|
||||
}
|
||||
|
||||
/* Only to be called by record */
|
||||
static void show(TNTPosition tnt) {
|
||||
for (ShowMode mode : showModes.values())
|
||||
mode.show(tnt);
|
||||
}
|
||||
|
||||
/* Only to be called by StoredRecords */
|
||||
static void clear() {
|
||||
for (ShowMode mode : showModes.values())
|
||||
mode.hide();
|
||||
}
|
||||
|
||||
/* Internal if player leaves*/
|
||||
static {
|
||||
Bukkit.getPluginManager().registerEvents(new TraceShowManager(), BauSystem.getInstance());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeave(PlayerQuitEvent event) {
|
||||
showModes.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
public static boolean hasActiveShow(Player player) {
|
||||
return showModes.containsKey(player);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
*
|
||||
* 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.show.mode;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.AbstractTraceEntity;
|
||||
import de.steamwar.bausystem.features.tracer.RoundedTNTPosition;
|
||||
import de.steamwar.bausystem.features.tracer.TNTPosition;
|
||||
import de.steamwar.bausystem.features.tracer.TNTTracer_15;
|
||||
import de.steamwar.bausystem.features.tracer.show.ShowMode;
|
||||
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
|
||||
import de.steamwar.core.VersionedCallable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Consumer;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EntityShowMode implements ShowMode {
|
||||
|
||||
protected final Player player;
|
||||
protected final ShowModeParameter showModeParameter;
|
||||
|
||||
private final Map<RoundedTNTPosition, AbstractTraceEntity> tntEntityMap = new HashMap<>();
|
||||
private final Map<RoundedTNTPosition, AbstractTraceEntity> updateEntityMap = new HashMap<>();
|
||||
|
||||
public EntityShowMode(Player player, ShowModeParameter showModeParameter) {
|
||||
this.player = player;
|
||||
this.showModeParameter = showModeParameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(TNTPosition position) {
|
||||
if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) {
|
||||
// Basic
|
||||
for (TNTPosition pos : position.getRecord().getPositions()) {
|
||||
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(pos);
|
||||
tntEntityMap.computeIfPresent(roundedTNTPosition, (p, tnt) -> {
|
||||
return tnt.hide(player, false) ? null : tnt;
|
||||
});
|
||||
}
|
||||
// Advanced
|
||||
for (TNTPosition pos : position.getRecord().getPositions()) {
|
||||
applyOnPosition(pos, updatePointPosition -> {
|
||||
updateEntityMap.computeIfPresent(new RoundedTNTPosition(updatePointPosition), (p, point) -> {
|
||||
return point.hide(player, false) ? null : point;
|
||||
});
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(position);
|
||||
AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedTNTPosition, pos -> createEntity(player, position.getLocation(), true));
|
||||
entity.display(player, position.isExploded());
|
||||
|
||||
applyOnPosition(position, updatePointPosition -> {
|
||||
updateEntityMap.computeIfAbsent(new RoundedTNTPosition(updatePointPosition), pos -> {
|
||||
return createEntity(player, updatePointPosition, false);
|
||||
}).display(player, position.isExploded());
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkWater(Vector position) {
|
||||
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_15.inWater(player.getWorld(), position), 15));
|
||||
}
|
||||
|
||||
public static AbstractTraceEntity createEntity(Player player, Vector position, boolean tnt) {
|
||||
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_15.create(player.getWorld(), position, tnt), 15));
|
||||
}
|
||||
|
||||
private void applyOnPosition(TNTPosition position, Consumer<Vector> function) {
|
||||
if (position.getPreviousLocation() == null) return;
|
||||
|
||||
if (showModeParameter.isInterpolate_Y()) {
|
||||
Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY());
|
||||
if (!position.getLocation().equals(updatePointY)) {
|
||||
function.accept(updatePointY);
|
||||
}
|
||||
}
|
||||
|
||||
if (showModeParameter.isInterpolate_XZ()) {
|
||||
Vector movement = position.getLocation().clone().subtract(position.getPreviousLocation());
|
||||
Vector updatePointXZ = Math.abs(movement.getX()) > Math.abs(movement.getZ())
|
||||
? position.getLocation().clone().setZ(position.getPreviousLocation().getZ())
|
||||
: position.getLocation().clone().setX(position.getPreviousLocation().getX());
|
||||
if (!position.getLocation().equals(updatePointXZ)) {
|
||||
function.accept(updatePointXZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
tntEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
|
||||
tntEntityMap.clear();
|
||||
updateEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
|
||||
updateEntityMap.clear();
|
||||
}
|
||||
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren