diff --git a/BauSystem_12/src/de/steamwar/bausystem/tracer/TNTTracer_12.java b/BauSystem_12/src/de/steamwar/bausystem/tracer/TNTTracer_12.java index 1816f31..3dddf5f 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/tracer/TNTTracer_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/tracer/TNTTracer_12.java @@ -26,12 +26,8 @@ import org.bukkit.util.Vector; public class TNTTracer_12 { - public static AbstractTraceEntity createTNT(World world, Vector tntPosition, Player player, boolean exploded) { - return new TraceEntity_12(world, tntPosition, player, exploded); - } - - public static AbstractTraceEntity createUpdatePoint(World world, Vector tntPosition, Player player) { - return new UpdateEntity_12(world, tntPosition, player); + public static AbstractTraceEntity create(World world, Vector tntPosition, Player player, boolean exploded, boolean tnt) { + return new TraceEntity_12(world, tntPosition, player, exploded, tnt); } public static boolean inWater(World world, TNTPosition tntPosition) { diff --git a/BauSystem_12/src/de/steamwar/bausystem/tracer/TraceEntity_12.java b/BauSystem_12/src/de/steamwar/bausystem/tracer/TraceEntity_12.java index f3189ae..5c0ca6a 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/tracer/TraceEntity_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/tracer/TraceEntity_12.java @@ -30,8 +30,8 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity { private Vector position; - public TraceEntity_12(World world, Vector position, Player player, boolean exploded) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.TNT.getBlockData()); + public TraceEntity_12(World world, Vector position, Player player, boolean exploded, boolean tnt) { + super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), tnt ? Blocks.TNT.getBlockData() : Blocks.STAINED_GLASS.getBlockData()); this.position = position; this.setNoGravity(true); diff --git a/BauSystem_12/src/de/steamwar/bausystem/tracer/UpdateEntity_12.java b/BauSystem_12/src/de/steamwar/bausystem/tracer/UpdateEntity_12.java deleted file mode 100644 index 76ca075..0000000 --- a/BauSystem_12/src/de/steamwar/bausystem/tracer/UpdateEntity_12.java +++ /dev/null @@ -1,85 +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.tracer; - -import net.minecraft.server.v1_12_R1.*; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_12_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -class UpdateEntity_12 extends EntityFallingBlock implements AbstractTraceEntity { - - private Vector position; - - public UpdateEntity_12(World world, Vector position, Player player) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.STAINED_GLASS.getBlockData()); - this.position = position; - - this.setNoGravity(true); - this.ticksLived = -12000; - this.dropItem = false; - this.setCustomNameVisible(true); - - display(player); - } - - @Override - public void move(EnumMoveType enummovetype, double dx, double dy, double dz) { - - } - - @Override - public AbstractTraceEntity display(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(this, 0); - ReflectionUtils.setValue("c", packetPlayOutSpawnEntity, position.getX()); - ReflectionUtils.setValue("d", packetPlayOutSpawnEntity, position.getY()); - ReflectionUtils.setValue("e", packetPlayOutSpawnEntity, position.getZ()); - ReflectionUtils.setValue("f", packetPlayOutSpawnEntity, 0); - ReflectionUtils.setValue("g", packetPlayOutSpawnEntity, 0); - ReflectionUtils.setValue("h", packetPlayOutSpawnEntity, 0); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutSpawnEntity); - - PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityTeleport); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata); - - return this; - } - - @Override - public AbstractTraceEntity hide(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(new int[]{getId()}); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); - - return this; - } - - @Override - public void remove() { - killEntity(); - } - -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java index 1c541e8..2b1aa5f 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TNTTracer_15.java @@ -26,12 +26,8 @@ import org.bukkit.util.Vector; public class TNTTracer_15 { - public static AbstractTraceEntity createTNT(World world, Vector tntPosition, Player player, boolean exploded) { - return new TraceEntity_15(world, tntPosition, player, exploded); - } - - public static AbstractTraceEntity createUpdatePoint(World world, Vector tntPosition, Player player) { - return new UpdateEntity_15(world, tntPosition, player); + public static AbstractTraceEntity create(World world, Vector tntPosition, Player player, boolean exploded, boolean tnt) { + return new TraceEntity_15(world, tntPosition, player, exploded, tnt); } public static boolean inWater(World world, TNTPosition tntPosition) { diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/TraceEntity_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/TraceEntity_15.java index ec58a28..d31e076 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/TraceEntity_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/tracer/TraceEntity_15.java @@ -31,8 +31,8 @@ class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity { private static final Vec3D ZERO = new Vec3D(0, 0, 0); private Vector position; - public TraceEntity_15(World world, Vector position, Player player, boolean exploded) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.TNT.getBlockData()); + public TraceEntity_15(World world, Vector position, Player player, boolean exploded, 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.setNoGravity(true); diff --git a/BauSystem_15/src/de/steamwar/bausystem/tracer/UpdateEntity_15.java b/BauSystem_15/src/de/steamwar/bausystem/tracer/UpdateEntity_15.java deleted file mode 100644 index 7cabccd..0000000 --- a/BauSystem_15/src/de/steamwar/bausystem/tracer/UpdateEntity_15.java +++ /dev/null @@ -1,77 +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.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 UpdateEntity_15 extends EntityFallingBlock implements AbstractTraceEntity { - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - private Vector position; - - public UpdateEntity_15(World world, Vector position, Player player) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.TNT.getBlockData()); - this.position = position; - - this.setNoGravity(true); - this.ticksLived = -12000; - this.dropItem = false; - this.setCustomNameVisible(true); - - display(player); - } - - @Override - public void move(EnumMoveType enummovetype, Vec3D vec3d) { - - } - - @Override - public AbstractTraceEntity display(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, Block.getCombinedId(Blocks.WHITE_STAINED_GLASS.getBlockData()), ZERO); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata); - - return this; - } - - @Override - public AbstractTraceEntity hide(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(new int[]{getId()}); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); - - return this; - } - - @Override - public void remove() { - killEntity(); - } - -} diff --git a/BauSystem_API/src/de/steamwar/bausystem/tracer/ReflectionUtils.java b/BauSystem_API/src/de/steamwar/bausystem/tracer/ReflectionUtils.java index 0aac017..a891e8b 100644 --- a/BauSystem_API/src/de/steamwar/bausystem/tracer/ReflectionUtils.java +++ b/BauSystem_API/src/de/steamwar/bausystem/tracer/ReflectionUtils.java @@ -30,7 +30,7 @@ public class ReflectionUtils { f.setAccessible(true); f.set(object, value); } catch (NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); + throw new SecurityException(e); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/mode/Advanced.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/mode/Advanced.java index 269fcbd..79948db 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/mode/Advanced.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/mode/Advanced.java @@ -61,16 +61,16 @@ public class Advanced extends Basic { if (updateEntityMap.containsKey(updatePointPosition)) { return; } - updateEntityMap.put(updatePointPosition, VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.createUpdatePoint(player.getWorld(), updatePointY, player), 8), - new VersionedCallable<>(() -> TNTTracer_15.createUpdatePoint(player.getWorld(), updatePointY, player), 14))); + updateEntityMap.put(updatePointPosition, VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.create(player.getWorld(), updatePointY, player, false, false), 8), + new VersionedCallable<>(() -> TNTTracer_15.create(player.getWorld(), updatePointY, player, false, false), 14))); } if (!position.getLocation().equals(updatePointXZ)) { RoundedTNTPosition updatePointPosition = new RoundedTNTPosition(updatePointXZ); if (updateEntityMap.containsKey(updatePointPosition)) { return; } - updateEntityMap.put(updatePointPosition, VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.createUpdatePoint(player.getWorld(), updatePointXZ, player), 8), - new VersionedCallable<>(() -> TNTTracer_15.createUpdatePoint(player.getWorld(), updatePointXZ, player), 14))); + updateEntityMap.put(updatePointPosition, VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.create(player.getWorld(), updatePointXZ, player, false, false), 8), + new VersionedCallable<>(() -> TNTTracer_15.create(player.getWorld(), updatePointXZ, player, false, false), 14))); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/mode/Basic.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/mode/Basic.java index a9a94b2..74a43d9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/mode/Basic.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/mode/Basic.java @@ -2,7 +2,6 @@ package de.steamwar.bausystem.tracer.show.mode; import de.steamwar.bausystem.tracer.*; import de.steamwar.bausystem.tracer.show.ShowMode; -import de.steamwar.core.Core; import de.steamwar.core.VersionedCallable; import org.bukkit.entity.Player; @@ -25,8 +24,8 @@ public class Basic implements ShowMode { if (tntEntityMap.containsKey(roundedTNTPosition)) { return; } - tntEntityMap.put(roundedTNTPosition, VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.createTNT(player.getWorld(), position.getLocation(), player, position.isExploded()), 8), - new VersionedCallable<>(() -> TNTTracer_15.createTNT(player.getWorld(), position.getLocation(), player, position.isExploded()), 14))); + tntEntityMap.put(roundedTNTPosition, VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.create(player.getWorld(), position.getLocation(), player, position.isExploded(), true), 8), + new VersionedCallable<>(() -> TNTTracer_15.create(player.getWorld(), position.getLocation(), player, position.isExploded(), true), 14))); } @Override