From b4f4a2fe13d44f38c9d388f23ca6307205e21902 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 4 Feb 2023 14:31:24 +0100 Subject: [PATCH] Update tracer to REntityServer Update warp to REntityServer Signed-off-by: yoyosource --- .../bausystem/entities/TraceEntity15.java | 73 ------ .../bausystem/entities/WarpEntity15.java | 80 ------ .../bausystem/shared/BaseArmorStand15.java | 56 ----- .../bausystem/utils/NMSWrapper15.java | 17 +- .../bausystem/entities/TraceEntity18.java | 73 ------ .../bausystem/entities/WarpEntity18.java | 80 ------ .../bausystem/shared/BaseArmorStand18.java | 62 ----- .../bausystem/utils/NMSWrapper18.java | 19 +- .../bausystem/entities/TraceEntity19.java | 74 ------ .../bausystem/entities/WarpEntity19.java | 81 ------- .../bausystem/shared/BaseArmorStand19.java | 62 ----- .../bausystem/utils/NMSWrapper19.java | 19 +- .../simulator/SimulatorPreviewStorage.java | 4 +- .../simulator/show/PreviewEntityShowMode.java | 42 ---- .../laufbau/states/ProcessingTracesState.java | 1 - .../features/tracer/AbstractTraceEntity.java | 33 --- .../features/tracer/TraceCommand.java | 7 +- .../features/tracer/show/EntityShowMode.java | 229 ++++++++++++++++++ .../tracer/show/EntityTraceShowMode.java | 31 --- .../tracer/show/ShowModeParameter.java | 5 + .../tracer/show/ShowModeParameterType.java | 7 +- .../tracer/show/TraceShowManager.java | 10 +- .../show/mode/FactoredEntityShowMode.java | 170 ------------- .../tracer/show/mode/RawEntityShowMode.java | 32 --- .../tracer/show/mode/TraceEntityShowMode.java | 32 --- .../features/warp/AbstractWarpEntity.java | 39 --- .../bausystem/features/warp/WarpListener.java | 78 ++---- .../steamwar/bausystem/utils/NMSWrapper.java | 4 - 28 files changed, 282 insertions(+), 1138 deletions(-) delete mode 100644 BauSystem_15/src/de/steamwar/bausystem/entities/TraceEntity15.java delete mode 100644 BauSystem_15/src/de/steamwar/bausystem/entities/WarpEntity15.java delete mode 100644 BauSystem_15/src/de/steamwar/bausystem/shared/BaseArmorStand15.java delete mode 100644 BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java delete mode 100644 BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java delete mode 100644 BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java delete mode 100644 BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java delete mode 100644 BauSystem_19/src/de/steamwar/bausystem/entities/WarpEntity19.java delete mode 100644 BauSystem_19/src/de/steamwar/bausystem/shared/BaseArmorStand19.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/simulator/show/PreviewEntityShowMode.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/AbstractTraceEntity.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityTraceShowMode.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/RawEntityShowMode.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/TraceEntityShowMode.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/warp/AbstractWarpEntity.java diff --git a/BauSystem_15/src/de/steamwar/bausystem/entities/TraceEntity15.java b/BauSystem_15/src/de/steamwar/bausystem/entities/TraceEntity15.java deleted file mode 100644 index 99873513..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/entities/TraceEntity15.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; -import de.steamwar.bausystem.shared.BaseEntity15; -import de.steamwar.bausystem.shared.ReferenceCounter; -import net.minecraft.server.v1_15_R1.ChatComponentText; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class TraceEntity15 extends BaseEntity15 implements AbstractTraceEntity { - - private boolean exploded = false; - private ReferenceCounter referenceCounter = new ReferenceCounter(); - - public TraceEntity15(World world, Vector position, boolean tnt) { - super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS); - - this.setNoGravity(true); - this.ticksLived = -12000; - } - - @Override - public void display(Player player, boolean exploded, int ticks) { - if (ticks != -1) { - this.setCustomNameVisible(true); - this.setCustomName(new ChatComponentText(ticks + "")); - } - if (!this.exploded && exploded) { - this.setCustomNameVisible(true); - this.setCustomName(new ChatComponentText("Bumm")); - this.exploded = true; - if (referenceCounter.increment() > 0) { - sendEntityDestroy(player); - } - } else if (referenceCounter.increment() > 0) { - return; - } - - sendEntity(player); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!force && referenceCounter.decrement() > 0) { - return false; - } - - sendEntityDestroy(player); - die(); - return true; - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/entities/WarpEntity15.java b/BauSystem_15/src/de/steamwar/bausystem/entities/WarpEntity15.java deleted file mode 100644 index 03929086..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/entities/WarpEntity15.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.warp.AbstractWarpEntity; -import de.steamwar.bausystem.shared.BaseArmorStand15; -import net.minecraft.server.v1_15_R1.ChatComponentText; -import net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata; -import net.minecraft.server.v1_15_R1.PacketPlayOutEntityTeleport; -import net.minecraft.server.v1_15_R1.PlayerConnection; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class WarpEntity15 extends BaseArmorStand15 implements AbstractWarpEntity { - - public WarpEntity15(World world, Vector position, String name) { - super(world, position); - setInvisible(true); - setSmall(true); - setName(name); - this.setNoGravity(true); - this.ticksLived = -12000; - } - - @Override - public void display(Player player) { - sendEntity(player); - } - - @Override - public void setName(String name) { - this.setCustomNameVisible(true); - this.setCustomName(new ChatComponentText(name)); - } - - @Override - public boolean hide(Player player) { - sendEntityDestroy(player); - die(); - return true; - } - - @Override - public void sendMetaData(Player player) { - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; - playerConnection.sendPacket(packetPlayOutEntityMetadata); - } - - @Override - public void teleport(Player player, Vector position) { - setPositionRaw(position.getX(), position.getY(), position.getZ()); - PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityTeleport); - } - - @Override - public Vector getPosition() { - return new Vector(locX(), locY(), locZ()); - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/shared/BaseArmorStand15.java b/BauSystem_15/src/de/steamwar/bausystem/shared/BaseArmorStand15.java deleted file mode 100644 index 2e604c77..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/shared/BaseArmorStand15.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.shared; - -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; - -public class BaseArmorStand15 extends EntityArmorStand implements AbstractEntity { - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - - protected Vector position; - - public BaseArmorStand15(World world, Vector position) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ()); - - this.position = position; - setNoGravity(true); - ticksLived = -12000; - } - - public void sendEntity(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.ARMOR_STAND, 0, ZERO); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; - playerConnection.sendPacket(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); - playerConnection.sendPacket(packetPlayOutEntityMetadata); - } - - public void sendEntityDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java index 15756166..e27b9147 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java @@ -22,18 +22,13 @@ package de.steamwar.bausystem.utils; import com.comphenix.tinyprotocol.Reflection; import de.steamwar.bausystem.entities.DetonatorEntity15; import de.steamwar.bausystem.entities.SimulatorEntity15; -import de.steamwar.bausystem.entities.TraceEntity15; import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; -import de.steamwar.bausystem.features.util.NoClipCommand; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; -import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; -import de.steamwar.bausystem.features.warp.AbstractWarpEntity; -import de.steamwar.bausystem.entities.WarpEntity15; +import de.steamwar.bausystem.features.util.NoClipCommand; import net.minecraft.server.v1_15_R1.*; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; -import org.bukkit.Particle; import org.bukkit.World; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; @@ -162,11 +157,6 @@ public class NMSWrapper15 implements NMSWrapper { return invalid; } - @Override - public AbstractWarpEntity createWarp(World world, Vector position, String name) { - return new WarpEntity15(world, position, name); - } - @Override public AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight) { return new SimulatorEntity15(world, tntPosition, highlight); @@ -177,11 +167,6 @@ public class NMSWrapper15 implements NMSWrapper { return new DetonatorEntity15(world, position); } - @Override - public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) { - return new TraceEntity15(world, tntPosition, tnt); - } - private final Class explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion"); private final Reflection.FieldAccessor a = Reflection.getField(explosionPacket, double.class, 0); private final Reflection.FieldAccessor b = Reflection.getField(explosionPacket, double.class, 1); diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java deleted file mode 100644 index 437c2620..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; -import de.steamwar.bausystem.shared.BaseEntity18; -import de.steamwar.bausystem.shared.ReferenceCounter; -import net.minecraft.network.chat.ChatComponentText; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class TraceEntity18 extends BaseEntity18 implements AbstractTraceEntity { - - private boolean exploded = false; - private ReferenceCounter referenceCounter = new ReferenceCounter(); - - public TraceEntity18(World world, Vector position, boolean tnt) { - super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS); - - this.e(true); - this.S = -12000; - } - - @Override - public void display(Player player, boolean exploded, int ticks) { - if (ticks != -1) { - this.n(true); - this.a(new ChatComponentText(ticks + "")); - } - if (!this.exploded && exploded) { - this.n(true); - this.a(new ChatComponentText("Bumm")); - this.exploded = true; - if (referenceCounter.increment() > 0) { - sendEntityDestroy(player); - } - } else if (referenceCounter.increment() > 0) { - return; - } - - sendEntity(player); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!force && referenceCounter.decrement() > 0) { - return false; - } - - sendEntityDestroy(player); - ag(); - return true; - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java deleted file mode 100644 index 35f8287a..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.warp.AbstractWarpEntity; -import de.steamwar.bausystem.shared.BaseArmorStand18; -import net.minecraft.network.chat.ChatComponentText; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport; -import net.minecraft.server.network.PlayerConnection; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class WarpEntity18 extends BaseArmorStand18 implements AbstractWarpEntity { - - public WarpEntity18(World world, Vector position, String name) { - super(world, position); - this.j(true); - this.a(true); - setName(name); - this.e(true); - this.S = -12000; - } - - @Override - public void display(Player player) { - sendEntity(player); - } - - @Override - public void setName(String name) { - this.n(true); - this.a(new ChatComponentText(name)); - } - - @Override - public boolean hide(Player player) { - sendEntityDestroy(player); - ag(); - return true; - } - - @Override - public void sendMetaData(Player player) { - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutEntityMetadata); - } - - @Override - public void teleport(Player player, Vector position) { - setPosRaw(position.getX(), position.getY(), position.getZ(), false); - PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityTeleport); - } - - @Override - public Vector getPosition() { - return new Vector(dc(), de(), di()); - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java deleted file mode 100644 index cc0d278c..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.shared; - -import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; -import net.minecraft.server.network.PlayerConnection; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.decoration.EntityArmorStand; -import net.minecraft.world.phys.Vec3D; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class BaseArmorStand18 extends EntityArmorStand implements AbstractEntity { - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - - protected Vector position; - - public BaseArmorStand18(World world, Vector position) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ()); - - this.position = position; - e(true); - S = -12000; - } - - public void sendEntity(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.c, 0, ZERO); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); - playerConnection.a(packetPlayOutEntityMetadata); - } - - public void sendEntityDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae()); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy); - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java index 4d14fc01..932d37d7 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -23,13 +23,9 @@ import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.entities.DetonatorEntity18; import de.steamwar.bausystem.entities.SimulatorEntity18; -import de.steamwar.bausystem.entities.TraceEntity18; -import de.steamwar.bausystem.entities.WarpEntity18; import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; -import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; import de.steamwar.bausystem.features.util.NoClipCommand; -import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import net.minecraft.SystemUtils; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -39,7 +35,10 @@ import net.minecraft.network.protocol.game.*; import net.minecraft.server.level.PlayerInteractManager; import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.phys.Vec3D; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack; @@ -167,11 +166,6 @@ public class NMSWrapper18 implements NMSWrapper { return invalid; } - @Override - public AbstractWarpEntity createWarp(World world, Vector position, String name) { - return new WarpEntity18(world, position, name); - } - @Override public AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight) { return new SimulatorEntity18(world, tntPosition, highlight); @@ -182,11 +176,6 @@ public class NMSWrapper18 implements NMSWrapper { return new DetonatorEntity18(world, position); } - @Override - public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) { - return new TraceEntity18(world, tntPosition, tnt); - } - private final Class explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion"); private final Reflection.FieldAccessor a = Reflection.getField(explosionPacket, double.class, 0); private final Reflection.FieldAccessor b = Reflection.getField(explosionPacket, double.class, 1); diff --git a/BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java deleted file mode 100644 index e70dba55..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; -import de.steamwar.bausystem.shared.BaseEntity19; -import de.steamwar.bausystem.shared.ReferenceCounter; -import net.minecraft.network.chat.IChatMutableComponent; -import net.minecraft.network.chat.contents.LiteralContents; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class TraceEntity19 extends BaseEntity19 implements AbstractTraceEntity { - - private boolean exploded = false; - private ReferenceCounter referenceCounter = new ReferenceCounter(); - - public TraceEntity19(World world, Vector position, boolean tnt) { - super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS); - - this.e(true); - this.S = -12000; - } - - @Override - public void display(Player player, boolean exploded, int ticks) { - if (ticks != -1) { - this.n(true); - this.b(IChatMutableComponent.a(new LiteralContents(ticks + ""))); - } - if (!this.exploded && exploded) { - this.n(true); - this.b(IChatMutableComponent.a(new LiteralContents("Bumm"))); - this.exploded = true; - if (referenceCounter.increment() > 0) { - sendEntityDestroy(player); - } - } else if (referenceCounter.increment() > 0) { - return; - } - - sendEntity(player); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!force && referenceCounter.decrement() > 0) { - return false; - } - - sendEntityDestroy(player); - ag(); - return true; - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/entities/WarpEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/entities/WarpEntity19.java deleted file mode 100644 index a86a653e..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/entities/WarpEntity19.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.warp.AbstractWarpEntity; -import de.steamwar.bausystem.shared.BaseArmorStand19; -import net.minecraft.network.chat.IChatMutableComponent; -import net.minecraft.network.chat.contents.LiteralContents; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport; -import net.minecraft.server.network.PlayerConnection; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class WarpEntity19 extends BaseArmorStand19 implements AbstractWarpEntity { - - public WarpEntity19(World world, Vector position, String name) { - super(world, position); - this.j(true); - this.a(true); - setName(name); - this.e(true); - this.S = -12000; - } - - @Override - public void display(Player player) { - sendEntity(player); - } - - @Override - public void setName(String name) { - this.n(true); - this.b(IChatMutableComponent.a(new LiteralContents(name))); - } - - @Override - public boolean hide(Player player) { - sendEntityDestroy(player); - ag(); - return true; - } - - @Override - public void sendMetaData(Player player) { - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutEntityMetadata); - } - - @Override - public void teleport(Player player, Vector position) { - setPosRaw(position.getX(), position.getY(), position.getZ(), false); - PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityTeleport); - } - - @Override - public Vector getPosition() { - return new Vector(df(), dh(), dj()); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/shared/BaseArmorStand19.java b/BauSystem_19/src/de/steamwar/bausystem/shared/BaseArmorStand19.java deleted file mode 100644 index fcc0ef9f..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/shared/BaseArmorStand19.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.shared; - -import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; -import net.minecraft.server.network.PlayerConnection; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.decoration.EntityArmorStand; -import net.minecraft.world.phys.Vec3D; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class BaseArmorStand19 extends EntityArmorStand implements AbstractEntity { - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - - protected Vector position; - - public BaseArmorStand19(World world, Vector position) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ()); - - this.position = position; - e(true); - S = -12000; - } - - public void sendEntity(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), co(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.d, 0, ZERO, 0.0); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); - playerConnection.a(packetPlayOutEntityMetadata); - } - - public void sendEntityDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae()); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java b/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java index 4d184f6f..bd6e3b53 100644 --- a/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java +++ b/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java @@ -23,13 +23,9 @@ import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.entities.DetonatorEntity19; import de.steamwar.bausystem.entities.SimulatorEntity19; -import de.steamwar.bausystem.entities.TraceEntity19; -import de.steamwar.bausystem.entities.WarpEntity19; import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; -import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; import de.steamwar.bausystem.features.util.NoClipCommand; -import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import net.minecraft.SystemUtils; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -39,7 +35,10 @@ import net.minecraft.network.protocol.game.*; import net.minecraft.server.level.PlayerInteractManager; import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.phys.Vec3D; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack; @@ -167,11 +166,6 @@ public class NMSWrapper19 implements NMSWrapper { return invalid; } - @Override - public AbstractWarpEntity createWarp(World world, Vector position, String name) { - return new WarpEntity19(world, position, name); - } - @Override public AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight) { return new SimulatorEntity19(world, tntPosition, highlight); @@ -182,11 +176,6 @@ public class NMSWrapper19 implements NMSWrapper { return new DetonatorEntity19(world, position); } - @Override - public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) { - return new TraceEntity19(world, tntPosition, tnt); - } - private final Class explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion"); private final Reflection.FieldAccessor a = Reflection.getField(explosionPacket, double.class, 0); private final Reflection.FieldAccessor b = Reflection.getField(explosionPacket, double.class, 1); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorPreviewStorage.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorPreviewStorage.java index 43024440..363a9162 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorPreviewStorage.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorPreviewStorage.java @@ -19,10 +19,10 @@ package de.steamwar.bausystem.features.simulator; -import de.steamwar.bausystem.features.simulator.show.PreviewEntityShowMode; import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; +import de.steamwar.bausystem.features.tracer.show.EntityShowMode; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.shared.ShowMode; import lombok.experimental.UtilityClass; @@ -57,7 +57,7 @@ public class SimulatorPreviewStorage { pair.getValue().add(player); ShowModeParameter showModeParameter = new ShowModeParameter(); - PreviewEntityShowMode showMode = new PreviewEntityShowMode(player, showModeParameter); + EntityShowMode showMode = new EntityShowMode(player, showModeParameter, 10); pair.getKey().showAll(showMode); showModes.put(player, new Pair<>(tntSimulator, showMode)); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/show/PreviewEntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/show/PreviewEntityShowMode.java deleted file mode 100644 index b03a8a29..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/show/PreviewEntityShowMode.java +++ /dev/null @@ -1,42 +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 . - */ - -package de.steamwar.bausystem.features.simulator.show; - -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.features.tracer.show.mode.FactoredEntityShowMode; -import org.bukkit.entity.Player; - -public class PreviewEntityShowMode extends FactoredEntityShowMode { - - public PreviewEntityShowMode(Player player, ShowModeParameter showModeParameter) { - super(player, showModeParameter, 10); - } - - @Override - public void show(TNTPosition position) { - super.show(position); - } - - @Override - public void hide() { - super.hide(); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java index bde0c16f..e3fc265a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.slaves.laufbau.states; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.features.slaves.laufbau.states.LaufbauState; import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.region.Point; import lombok.Getter; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/AbstractTraceEntity.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/AbstractTraceEntity.java deleted file mode 100644 index 10179551..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/AbstractTraceEntity.java +++ /dev/null @@ -1,33 +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 . - */ - -package de.steamwar.bausystem.features.tracer; - -import de.steamwar.bausystem.shared.AbstractEntity; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -public interface AbstractTraceEntity extends AbstractEntity { - - void display(Player player, boolean exploded, int ticks); - - boolean hide(Player player, boolean always); - - Entity getBukkitEntity(); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index 77775134..b24ec012 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -25,8 +25,7 @@ import de.steamwar.bausystem.features.tracer.gui.TraceGui; 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.mode.RawEntityShowMode; -import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode; +import de.steamwar.bausystem.features.tracer.show.EntityShowMode; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.command.PreviousArguments; @@ -210,8 +209,8 @@ public class TraceCommand extends SWCommand { @AllArgsConstructor private enum ShowModeType { - ENTITY(TraceEntityShowMode::new, new ShowModeParameterType[]{}), - RAW(RawEntityShowMode::new, new ShowModeParameterType[]{}); + ENTITY((player, showModeParameter) -> new EntityShowMode(player, showModeParameter, 10), new ShowModeParameterType[]{}), + RAW((player, showModeParameter) -> new EntityShowMode(player, showModeParameter, -1), new ShowModeParameterType[]{}); private BiFunction> showModeBiFunction; private ShowModeParameterType[] removedTypes; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java new file mode 100644 index 00000000..0dcf1187 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java @@ -0,0 +1,229 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 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 . + */ + +package de.steamwar.bausystem.features.tracer.show; + +import de.steamwar.bausystem.features.tracer.TNTPosition; +import de.steamwar.bausystem.shared.RoundedPosition; +import de.steamwar.bausystem.shared.ShowMode; +import de.steamwar.bausystem.utils.FlatteningWrapper; +import de.steamwar.entity.REntity; +import de.steamwar.entity.REntityServer; +import de.steamwar.entity.RFallingBlockEntity; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import java.util.*; +import java.util.function.BiConsumer; + +public class EntityShowMode implements ShowMode { + + private final int factor; + private final Player player; + private final ShowModeParameter showModeParameter; + + private REntityServer entityServer; + + private final Map tntEntityMap = new HashMap<>(); + private final Map explodeEntityMap = new HashMap<>(); + private final Map updateEntityMap = new HashMap<>(); + + public EntityShowMode(Player player, ShowModeParameter showModeParameter, int factor) { + this.player = player; + this.showModeParameter = showModeParameter; + this.factor = factor; + } + + @Override + public void show(TNTPosition position) { + if (entityServer == null) { + entityServer = new REntityServer(); + entityServer.addPlayer(player); + } + + if (showModeParameter.isBuildDestroyOnly() && !position.getRecord().isInBuildArea()) { + return; + } + + if (showModeParameter.isExplodeOnly()) { + if (position.isExploded()) { + generatePositions(position, false, false); + } + if (!showModeParameter.isSourceOnly()) { + return; + } + } + + if (showModeParameter.isSourceOnly()) { + if (position.isSource()) { + generatePositions(position, false, false); + } + return; + } + + boolean exploded = position.getRecord().getPositions().stream().anyMatch(TNTPosition::isExploded); + if (!showModeParameter.isWater() && exploded && checkWater(position.getLocation())) { + if (position.isExploded()) { + for (TNTPosition pos : position.getRecord().getPositions()) { + generatePositions(pos, showModeParameter.isInterpolateY(), showModeParameter.isInterpolateXZ(), (positionType, vector) -> { + RoundedPosition roundedPosition = new RoundedPosition(vector, factor); + Map map; + if (positionType == PositionType.TNT) { + map = tntEntityMap; + } else if (positionType == PositionType.EXPLODE) { + map = explodeEntityMap; + } else { + map = updateEntityMap; + } + map.computeIfPresent(roundedPosition, (roundedPosition1, entityStack) -> { + if (!entityStack.remove(pos.getRecord())) { + return null; + } + return entityStack; + }); + }); + } + } + return; + } + + generatePositions(position, showModeParameter.isInterpolateY(), showModeParameter.isInterpolateXZ()); + } + + @Override + public void hide() { + tntEntityMap.clear(); + explodeEntityMap.clear(); + updateEntityMap.clear(); + entityServer.close(); + entityServer = null; + } + + private void generatePositions(TNTPosition position, boolean interpolateY, boolean interpolateXZ) { + generatePositions(position, interpolateY, interpolateXZ, (positionType, vector) -> { + RoundedPosition roundedPosition = new RoundedPosition(vector, factor); + EntityStack entityStack; + if (positionType == PositionType.TNT) { + entityStack = tntEntityMap.computeIfAbsent(roundedPosition, i -> new EntityStack(vector, positionType, position.getFuseTicks())); + } else if (positionType == PositionType.EXPLODE) { + entityStack = explodeEntityMap.computeIfAbsent(roundedPosition, i -> new EntityStack(vector, positionType, position.getFuseTicks())); + } else { + entityStack = updateEntityMap.computeIfAbsent(roundedPosition, i -> new EntityStack(vector, positionType, position.getFuseTicks())); + } + entityStack.add(position.getRecord()); + }); + } + + private boolean checkWater(Vector position) { + return FlatteningWrapper.impl.inWater(player.getWorld(), position); + } + + private REntity createEntity(Vector position, PositionType positionType) { + Material material; + if (positionType == PositionType.TNT) { + material = Material.TNT; + } else if (positionType == PositionType.EXPLODE) { + material = Material.RED_STAINED_GLASS; + } else { + material = Material.WHITE_STAINED_GLASS; + } + RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, position.toLocation(player.getWorld()), material); + entity.setNoGravity(true); + return entity; + } + + public List getEntities() { + return new ArrayList<>(); + } + + public TNTPosition getTNTPosition(Entity entity) { + return null; + } + + private class EntityStack { + + private final Vector position; + private final PositionType positionType; + private final int fuseTicks; + + private REntity entity; + private int count; + private List records = new ArrayList<>(); + + public EntityStack(Vector position, PositionType positionType, int fuseTicks) { + this.position = position; + this.positionType = positionType; + this.fuseTicks = fuseTicks; + } + + public void add(Record.TNTRecord record) { + records.add(record); + if (entity == null) { + entity = createEntity(position, positionType); + } + count++; + if (showModeParameter.isTicks()) { + entity.setDisplayName(fuseTicks + ""); + } else if (showModeParameter.isCount()) { + entity.setDisplayName(new HashSet<>(records).size() + ""); + } + } + + public boolean remove(Record.TNTRecord record) { + if (entity == null) return false; + records.remove(record); + count--; + if (count == 0) { + entity.die(); + entity = null; + return false; + } + return true; + } + } + + public static void generatePositions(TNTPosition position, boolean interpolateY, boolean interpolateXZ, BiConsumer positionCallback) { + positionCallback.accept(position.isExploded() ? PositionType.EXPLODE : PositionType.TNT, position.getLocation()); + if (position.getPreviousLocation() == null) return; + + if (interpolateY) { + Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY()); + if (!position.getLocation().equals(updatePointY)) { + positionCallback.accept(PositionType.UPDATE, updatePointY); + } + } + + if (interpolateXZ) { + Vector updatePointXZ = Math.abs(position.getUpdateVelocity().getX()) >= Math.abs(position.getUpdateVelocity().getZ()) + ? position.getLocation().clone().setZ(position.getPreviousLocation().getZ()) + : position.getLocation().clone().setX(position.getPreviousLocation().getX()); + if (!position.getLocation().equals(updatePointXZ)) { + positionCallback.accept(PositionType.UPDATE, updatePointXZ); + } + } + } + + public enum PositionType { + TNT, + EXPLODE, + UPDATE + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityTraceShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityTraceShowMode.java deleted file mode 100644 index 2b73a40b..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityTraceShowMode.java +++ /dev/null @@ -1,31 +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 . - */ - -package de.steamwar.bausystem.features.tracer.show; - -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.shared.ShowMode; -import org.bukkit.entity.Entity; - -import java.util.List; - -public interface EntityTraceShowMode extends ShowMode { - List getEntities(); - TNTPosition getTNTPosition(Entity entity); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java index 100e58c3..2544a28b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java @@ -30,6 +30,7 @@ public class ShowModeParameter { private boolean explodeOnly = false; private boolean ticks = false; private boolean buildDestroyOnly = false; + private boolean count = false; public void enableWater() { this.water = true; @@ -58,4 +59,8 @@ public class ShowModeParameter { public void enableBuildDestroyOnly() { this.buildDestroyOnly = true; } + + public void enableCount() { + this.count = true; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java index 5f4bcb46..3d28237d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java @@ -35,10 +35,11 @@ public enum ShowModeParameterType { ADVANCED(showModeParameter -> { showModeParameter.enableInterpolateY(); showModeParameter.enableInterpolateXZ(); - }, Arrays.asList("-advanced", "-a", "advanced"), "INTERPOLATE_Y", "INTERPOLATE_XZ"), - SOURCE(ShowModeParameter::enableSourceOnly, Arrays.asList("-source", "-sourceonly"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"), + }, Arrays.asList("-advanced", "-a"), "INTERPOLATE_Y", "INTERPOLATE_XZ"), + SOURCE(ShowModeParameter::enableSourceOnly, Arrays.asList("-source", "-sourceonly", "-ignite"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"), EXPLODE(ShowModeParameter::enableExplodeOnly, Arrays.asList("-explode", "-explodeonly"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"), - TICKS(ShowModeParameter::enableTicks, Arrays.asList("-ticks", "-t"), "EXPLODE", "SOURCE"), + TICKS(ShowModeParameter::enableTicks, Arrays.asList("-ticks", "-t"), "EXPLODE", "SOURCE", "COUNT"), + COUNT(ShowModeParameter::enableCount, Arrays.asList("-count", "-c"), "COUNT"), BUILD_DESTROY_ONLY(ShowModeParameter::enableBuildDestroyOnly, Arrays.asList("-builddestroy", "-builddestoryonly"), "WATER"); @Getter diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java index 565db661..82ca5673 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java @@ -83,8 +83,8 @@ public class TraceShowManager implements Listener { if (showMode == null) { return Collections.emptyList(); } - if (showMode instanceof EntityTraceShowMode) { - return ((EntityTraceShowMode) showMode).getEntities(); + if (showMode instanceof EntityShowMode) { + return ((EntityShowMode) showMode).getEntities(); } return Collections.emptyList(); } @@ -102,8 +102,8 @@ public class TraceShowManager implements Listener { if (showMode == null) { return null; } - if (showMode instanceof EntityTraceShowMode) { - return ((EntityTraceShowMode) showMode).getTNTPosition(entity); + if (showMode instanceof EntityShowMode) { + return ((EntityShowMode) showMode).getTNTPosition(entity); } return null; } @@ -164,7 +164,7 @@ public class TraceShowManager implements Listener { if (!region.isGlobal()) { Map> regionalShowModes = showModes.get(region); if (regionalShowModes != null) { - regionalShowModes.remove(event.getPlayer()); + regionalShowModes.remove(event.getPlayer()).hide(); } } StoredRecords.cleanup(event.getPlayer()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java deleted file mode 100644 index cb79d65b..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.tracer.show.mode; - -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.features.tracer.show.EntityTraceShowMode; -import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.shared.RoundedPosition; -import de.steamwar.bausystem.utils.FlatteningWrapper; -import de.steamwar.entity.REntity; -import de.steamwar.entity.REntityServer; -import de.steamwar.entity.RFallingBlockEntity; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.util.Consumer; -import org.bukkit.util.Vector; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public abstract class FactoredEntityShowMode implements EntityTraceShowMode { - - private int factor; - - protected final Player player; - protected final ShowModeParameter showModeParameter; - protected final REntityServer entityServer = new REntityServer(); // TODO: Needs to be closed - - private final Map tntEntityMap = new HashMap<>(); - private final Map updateEntityMap = new HashMap<>(); - private final Map tntPositionMap = new HashMap<>(); - - protected FactoredEntityShowMode(Player player, ShowModeParameter showModeParameter, int factor) { // TODO: Fix factor - this.player = player; - this.showModeParameter = showModeParameter; - this.factor = factor; - entityServer.addPlayer(player); - } - - @Override - public void show(TNTPosition position) { - if (showModeParameter.isBuildDestroyOnly() && !position.getRecord().isInBuildArea()) { - return; - } - if (showModeParameter.isExplodeOnly()) { - if (position.isExploded()) { - RoundedPosition roundedPosition = new RoundedPosition(position, factor); - REntity entity = tntEntityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true, position.isExploded(), showModeParameter.isTicks() ? position.getFuseTicks() : -1)); - tntPositionMap.put(entity, position); - } - if (!showModeParameter.isSourceOnly()) { - return; - } - } - if (showModeParameter.isSourceOnly()) { - if (position.isSource()) { - RoundedPosition roundedPosition = new RoundedPosition(position, factor); - REntity entity = tntEntityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true, position.isExploded(), showModeParameter.isTicks() ? position.getFuseTicks() : -1)); - tntPositionMap.put(entity, position); - } - return; - } - if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) { - // Basic - for (TNTPosition pos : position.getRecord().getPositions()) { - RoundedPosition roundedPosition = new RoundedPosition(pos, factor); - tntEntityMap.computeIfPresent(roundedPosition, (p, tnt) -> { - tnt.die(); - return null; - }); - } - // Advanced - for (TNTPosition pos : position.getRecord().getPositions()) { - applyOnPosition(pos, updatePointPosition -> { - updateEntityMap.computeIfPresent(new RoundedPosition(updatePointPosition, factor), (p, point) -> { - point.die(); - return null; - }); - }); - } - return; - } - - RoundedPosition roundedPosition = new RoundedPosition(position, factor); - REntity entity = tntEntityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true, position.isExploded(), showModeParameter.isTicks() ? position.getFuseTicks() : -1)); - tntPositionMap.put(entity, position); - - applyOnPosition(position, updatePointPosition -> { - updateEntityMap.computeIfAbsent(new RoundedPosition(updatePointPosition, factor), pos -> { - return createEntity(player, updatePointPosition, false, false, -1); - }); - }); - } - - private boolean checkWater(Vector position) { - return FlatteningWrapper.impl.inWater(player.getWorld(), position); - } - - private REntity createEntity(Player player, Vector position, boolean tnt, boolean explode, int ticks) { - Material material = tnt ? Material.TNT : Material.WHITE_STAINED_GLASS; - if (tnt && explode) material = Material.RED_STAINED_GLASS; - RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, position.toLocation(player.getWorld()), material); - entity.setNoGravity(true); - if (ticks != -1) { - entity.setDisplayName(ticks + ""); - } - return entity; - } - - private void applyOnPosition(TNTPosition position, Consumer function) { - if (position.getPreviousLocation() == null) return; - - if (showModeParameter.isInterpolateY()) { - Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY()); - if (!position.getLocation().equals(updatePointY)) { - function.accept(updatePointY); - } - } - - if (showModeParameter.isInterpolateXZ()) { - Vector updatePointXZ = Math.abs(position.getUpdateVelocity().getX()) >= Math.abs(position.getUpdateVelocity().getZ()) - ? position.getLocation().clone().setZ(position.getPreviousLocation().getZ()) - : position.getLocation().clone().setX(position.getPreviousLocation().getX()); - if (!position.getLocation().equals(updatePointXZ)) { - function.accept(updatePointXZ); - } - } - } - - @Override - public void hide() { - tntPositionMap.clear(); - tntEntityMap.forEach((roundedPosition, abstractTraceEntity) -> abstractTraceEntity.die()); - tntEntityMap.clear(); - updateEntityMap.forEach((roundedPosition, abstractTraceEntity) -> abstractTraceEntity.die()); - updateEntityMap.clear(); - } - - @Override - public List getEntities() { - // return new ArrayList<>(tntPositionMap.keySet()); - return new ArrayList<>(); - } - - @Override - public TNTPosition getTNTPosition(Entity entity) { - // return tntPositionMap.get(entity); - return null; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/RawEntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/RawEntityShowMode.java deleted file mode 100644 index 22952c0d..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/RawEntityShowMode.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * / - */ - -package de.steamwar.bausystem.features.tracer.show.mode; - -import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; -import org.bukkit.entity.Player; - -public class RawEntityShowMode extends FactoredEntityShowMode { - - public RawEntityShowMode(Player player, ShowModeParameter showModeParameter) { - super(player, showModeParameter, -1); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/TraceEntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/TraceEntityShowMode.java deleted file mode 100644 index a5decb5c..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/TraceEntityShowMode.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * / - */ - -package de.steamwar.bausystem.features.tracer.show.mode; - -import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; -import org.bukkit.entity.Player; - -public class TraceEntityShowMode extends FactoredEntityShowMode { - - public TraceEntityShowMode(Player player, ShowModeParameter showModeParameter) { - super(player, showModeParameter, 10); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/AbstractWarpEntity.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/AbstractWarpEntity.java deleted file mode 100644 index 4671d2f0..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/AbstractWarpEntity.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.warp; - -import de.steamwar.bausystem.shared.AbstractEntity; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public interface AbstractWarpEntity extends AbstractEntity { - - void display(Player player); - - void setName(String name); - - boolean hide(Player player); - - void sendMetaData(Player player); - - void teleport(Player player, Vector position); - - Vector getPosition(); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java index 33f437c4..ea48383e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java @@ -20,7 +20,8 @@ package de.steamwar.bausystem.features.warp; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.utils.NMSWrapper; +import de.steamwar.entity.RArmorStand; +import de.steamwar.entity.REntityServer; import de.steamwar.linkage.Linked; import org.bukkit.*; import org.bukkit.entity.Player; @@ -32,74 +33,51 @@ import org.bukkit.event.player.*; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import java.util.*; -import java.util.function.Consumer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; @Linked public class WarpListener implements Listener { - private Map> warpsShown = new HashMap<>(); + private Map warpEntityServer = new HashMap<>(); private Map> selected = new HashMap<>(); @EventHandler public void onPlayerItemHeld(PlayerItemHeldEvent e) { ItemStack itemStack = e.getPlayer().getInventory().getItem(e.getNewSlot()); Material material = itemStack == null ? Material.AIR : itemStack.getType(); - createStuff(e.getPlayer(), material, e.getPlayer().isSneaking()); + reshow(e.getPlayer(), material, e.getPlayer().isSneaking()); } @EventHandler public void onPlayerMove(PlayerMoveEvent event) { for (Player p : Bukkit.getOnlinePlayers()) { - createStuff(p, p.getInventory().getItemInMainHand().getType(), p.isSneaking()); + reshow(p, p.getInventory().getItemInMainHand().getType(), p.isSneaking()); } } @EventHandler public void onPlayerToggleSneak(PlayerToggleSneakEvent event) { - createStuff(event.getPlayer(), event.getPlayer().getInventory().getItemInMainHand().getType(), event.isSneaking()); + reshow(event.getPlayer(), event.getPlayer().getInventory().getItemInMainHand().getType(), event.isSneaking()); } - private static final class WarpEntityIterator { - - private final List warps; - - public WarpEntityIterator(List warps) { - this.warps = warps == null ? Collections.emptyList() : warps; + private void reshow(Player p, Material material, boolean sneaking) { + REntityServer entityServer = warpEntityServer.get(p); + if (entityServer != null) { + entityServer.close(); } - - public AbstractWarpEntity next(Player p, Vector position, String name) { - if (!warps.isEmpty()) { - AbstractWarpEntity abstractWarpEntity = warps.stream().min(Comparator.comparingDouble(o -> o.getPosition().distanceSquared(position))).get(); - warps.remove(abstractWarpEntity); - abstractWarpEntity.teleport(p, position); - abstractWarpEntity.setName(name); - abstractWarpEntity.sendMetaData(p); - return abstractWarpEntity; - } else { - AbstractWarpEntity warp = createEntity(p, position, name); - warp.display(p); - return warp; - } - } - - public void forEach(Consumer consumer) { - warps.forEach(consumer); - } - } - - private void createStuff(Player p, Material material, boolean sneaking) { - WarpEntityIterator it = new WarpEntityIterator(warpsShown.remove(p)); if (material != Material.COMPASS) { - it.forEach(abstractWarpEntity -> { - abstractWarpEntity.teleport(p, new Vector(0, 100000, 0)); - abstractWarpEntity.hide(p); - }); + warpEntityServer.remove(p); return; } selected.remove(p); - List warps = warpsShown.getOrDefault(p, new ArrayList<>()); + entityServer = new REntityServer(); + entityServer.addPlayer(p); + warpEntityServer.put(p, entityServer); + Vector current = p.getLocation().clone().add(p.getLocation().getDirection().multiply(5)).toVector(); current.setY(p.getLocation().getY() - 1); @@ -121,6 +99,7 @@ public class WarpListener implements Listener { } } + REntityServer finalEntityServer = entityServer; locations.forEach((name, location) -> { Vector vector = location.toVector().subtract(p.getLocation().toVector()); if (vector.getX() * vector.getX() + vector.getZ() * vector.getZ() < 25) { @@ -135,14 +114,11 @@ public class WarpListener implements Listener { name = "§a§l" + name; selected.computeIfAbsent(p, player -> new ArrayList<>()).add(location); } - warps.add(it.next(p, position, name)); + RArmorStand armorStand = new RArmorStand(finalEntityServer, position.toLocation(p.getWorld()), RArmorStand.Size.MARKER); + armorStand.setDisplayName(name); + armorStand.setNoGravity(true); + armorStand.setInvisible(true); }); - - it.forEach(abstractWarpEntity -> { - abstractWarpEntity.teleport(p, new Vector(0, 100000, 0)); - abstractWarpEntity.hide(p); - }); - warpsShown.put(p, warps); } @EventHandler(priority = EventPriority.LOWEST) @@ -163,13 +139,9 @@ public class WarpListener implements Listener { event.setCancelled(true); } - public static AbstractWarpEntity createEntity(Player player, Vector position, String name) { - return NMSWrapper.impl.createWarp(player.getWorld(), position, name); - } - @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - warpsShown.remove(event.getPlayer()); + warpEntityServer.remove(event.getPlayer()).close(); selected.remove(event.getPlayer()); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java index ffdc6438..96e38a05 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java @@ -22,8 +22,6 @@ package de.steamwar.bausystem.utils; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; -import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; -import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import de.steamwar.core.VersionDependent; import org.bukkit.GameMode; import org.bukkit.Material; @@ -51,10 +49,8 @@ public interface NMSWrapper { boolean checkItemStack(ItemStack item); - AbstractWarpEntity createWarp(World world, Vector position, String name); AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight); AbstractDetonatorEntity constructDetonator(World world, Vector position); - AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt); Object resetExplosionKnockback(Object packet); }