SteamWar/BauSystem2.0
Archiviert
12
0

REntity #148

Zusammengeführt
YoyoNow hat 19 Commits von REntity nach master 2023-02-24 20:31:33 +01:00 zusammengeführt
28 geänderte Dateien mit 282 neuen und 1138 gelöschten Zeilen
Nur Änderungen aus Commit b4f4a2fe13 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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;
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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());
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}
}

Datei anzeigen

@ -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<Double> a = Reflection.getField(explosionPacket, double.class, 0);
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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;
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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());
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}
}

Datei anzeigen

@ -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<Double> a = Reflection.getField(explosionPacket, double.class, 0);
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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;
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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());
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}
}

Datei anzeigen

@ -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<Double> a = Reflection.getField(explosionPacket, double.class, 0);
private final Reflection.FieldAccessor<Double> b = Reflection.getField(explosionPacket, double.class, 1);

Datei anzeigen

@ -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));
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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();
}
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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();
}

Datei anzeigen

@ -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<Player, ShowModeParameter, ShowMode<TNTPosition>> showModeBiFunction;
private ShowModeParameterType[] removedTypes;

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<TNTPosition> {
private final int factor;
private final Player player;
private final ShowModeParameter showModeParameter;
private REntityServer entityServer;
private final Map<RoundedPosition, EntityStack> tntEntityMap = new HashMap<>();
private final Map<RoundedPosition, EntityStack> explodeEntityMap = new HashMap<>();
private final Map<RoundedPosition, EntityStack> 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<RoundedPosition, EntityStack> 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<Entity> 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<Record.TNTRecord> 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<PositionType, Vector> 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
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<TNTPosition> {
List<Entity> getEntities();
TNTPosition getTNTPosition(Entity entity);
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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

Datei anzeigen

@ -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<Player, ShowMode<TNTPosition>> regionalShowModes = showModes.get(region);
if (regionalShowModes != null) {
regionalShowModes.remove(event.getPlayer());
regionalShowModes.remove(event.getPlayer()).hide();
}
}
StoredRecords.cleanup(event.getPlayer());

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<RoundedPosition, REntity> tntEntityMap = new HashMap<>();
private final Map<RoundedPosition, REntity> updateEntityMap = new HashMap<>();
private final Map<REntity, TNTPosition> 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<Vector> 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<Entity> getEntities() {
// return new ArrayList<>(tntPositionMap.keySet());
return new ArrayList<>();
}
@Override
public TNTPosition getTNTPosition(Entity entity) {
// return tntPositionMap.get(entity);
return null;
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
* /
*/
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);
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
* /
*/
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);
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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();
}

Datei anzeigen

@ -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<Player, List<AbstractWarpEntity>> warpsShown = new HashMap<>();
private Map<Player, REntityServer> warpEntityServer = new HashMap<>();
private Map<Player, List<Location>> 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<AbstractWarpEntity> warps;
public WarpEntityIterator(List<AbstractWarpEntity> 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<AbstractWarpEntity> 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<AbstractWarpEntity> 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());
}
}

Datei anzeigen

@ -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);
}