REntity #148
@ -1,82 +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.detonator.AbstractDetonatorEntity;
|
||||
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 DetonatorEntity15 extends EntityFallingBlock implements AbstractDetonatorEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
private final Vector position;
|
||||
private int references = 0;
|
||||
|
||||
public DetonatorEntity15(World world, Vector position) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.RED_STAINED_GLASS.getBlockData());
|
||||
this.position = position;
|
||||
|
||||
this.h(true);
|
||||
this.setNoGravity(true);
|
||||
this.ticksLived = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (references++ > 0)
|
||||
return;
|
||||
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, Block.getCombinedId(Blocks.RED_STAINED_GLASS.getBlockData()), ZERO);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
||||
playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!force && --references > 0)
|
||||
return false;
|
||||
|
||||
sendDestroy(player);
|
||||
die();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntity(Player player) {
|
||||
display(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntityDestroy(Player player) {
|
||||
hide(player, false);
|
||||
}
|
||||
}
|
@ -1,64 +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.simulator.AbstractSimulatorEntity;
|
||||
import de.steamwar.bausystem.shared.BaseEntity15;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SimulatorEntity15 extends BaseEntity15 implements AbstractSimulatorEntity {
|
||||
|
||||
private boolean printed = false;
|
||||
|
||||
public SimulatorEntity15(World world, Vector position, boolean highlight) {
|
||||
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
|
||||
|
||||
this.setNoGravity(true);
|
||||
this.ticksLived = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (printed) return;
|
||||
printed = true;
|
||||
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector position) {
|
||||
this.position = position;
|
||||
setPosition(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!printed) return false;
|
||||
printed = false;
|
||||
|
||||
|
||||
sendEntityDestroy(player);
|
||||
die();
|
||||
return true;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
@ -1,30 +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;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
||||
|
||||
public class SimulatorPreview15 implements SimulatorPreview {
|
||||
|
||||
@Override
|
||||
public Record simulate(TNTSimulator tntSimulator) {
|
||||
return new Record(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 <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);
|
||||
}
|
||||
}
|
@ -1,60 +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.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class BaseEntity15 extends EntityFallingBlock implements AbstractEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
|
||||
private final IBlockData iBlockData;
|
||||
protected Vector position;
|
||||
|
||||
public BaseEntity15(World world, Vector position, Material blockType) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), ((CraftBlockData) blockType.createBlockData()).getState());
|
||||
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
|
||||
this.position = position;
|
||||
|
||||
this.setNoGravity(true);
|
||||
this.ticksLived = -12000;
|
||||
}
|
||||
|
||||
public void sendEntity(Player player) {
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, Block.getCombinedId(iBlockData), 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);
|
||||
}
|
||||
}
|
@ -20,20 +20,11 @@
|
||||
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 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;
|
||||
@ -41,7 +32,6 @@ import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -162,26 +152,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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractDetonatorEntity constructDetonator(World world, Vector position) {
|
||||
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);
|
||||
|
@ -1,95 +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.detonator.AbstractDetonatorEntity;
|
||||
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.item.EntityFallingBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
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 DetonatorEntity18 extends EntityFallingBlock implements AbstractDetonatorEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
private final Vector position;
|
||||
private int references = 0;
|
||||
|
||||
public DetonatorEntity18(World world, Vector position) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.du.n());
|
||||
this.position = position;
|
||||
|
||||
this.h(true);
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ae();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (references++ > 0)
|
||||
return;
|
||||
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.C, Block.i(Blocks.du.n()), ZERO);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
||||
playerConnection.a(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Y, true);
|
||||
playerConnection.a(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!force && --references > 0)
|
||||
return false;
|
||||
|
||||
sendDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntity(Player player) {
|
||||
display(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntityDestroy(Player player) {
|
||||
hide(player, false);
|
||||
}
|
||||
}
|
@ -1,68 +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.simulator.AbstractSimulatorEntity;
|
||||
import de.steamwar.bausystem.shared.BaseEntity18;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulatorEntity {
|
||||
|
||||
private boolean printed = false;
|
||||
|
||||
public SimulatorEntity18(World world, Vector position, boolean highlight) {
|
||||
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ae();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (printed) return;
|
||||
printed = true;
|
||||
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector position) {
|
||||
this.position = position;
|
||||
e(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!printed) return false;
|
||||
printed = false;
|
||||
|
||||
sendEntityDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -1,68 +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.item.EntityFallingBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class BaseEntity18 extends EntityFallingBlock implements AbstractEntity {
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
|
||||
private final IBlockData iBlockData;
|
||||
protected Vector position;
|
||||
|
||||
public BaseEntity18(World world, Vector position, Material blockType) {
|
||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), ((CraftBlockData) blockType.createBlockData()).getState());
|
||||
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
|
||||
this.position = position;
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
public void sendEntity(Player player) {
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.C, Block.i(iBlockData), 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);
|
||||
}
|
||||
}
|
@ -21,15 +21,7 @@ package de.steamwar.bausystem.utils;
|
||||
|
||||
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,14 +31,16 @@ 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;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -167,26 +161,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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractDetonatorEntity constructDetonator(World world, Vector position) {
|
||||
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);
|
||||
|
@ -1,124 +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.detonator.AbstractDetonatorEntity;
|
||||
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.item.EntityFallingBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class DetonatorEntity19 extends EntityFallingBlock implements AbstractDetonatorEntity {
|
||||
|
||||
private static final Field ao;
|
||||
|
||||
static {
|
||||
try {
|
||||
ao = EntityFallingBlock.class.getDeclaredField("ao");
|
||||
ao.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
private final Vector position;
|
||||
private int references = 0;
|
||||
private IBlockData iBlockData;
|
||||
|
||||
public DetonatorEntity19(World world, Vector position) {
|
||||
super(EntityTypes.E, ((CraftWorld) world).getHandle());
|
||||
try {
|
||||
ao.set(this, ((CraftBlockData) Material.RED_STAINED_GLASS.createBlockData()).getState());
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.q = true;
|
||||
e(position.getX(), position.getY(), position.getZ());
|
||||
f(Vec3D.b);
|
||||
t = position.getX();
|
||||
u = position.getY();
|
||||
v = position.getZ();
|
||||
a(this.db());
|
||||
|
||||
this.iBlockData = ((CraftBlockData) Material.RED_STAINED_GLASS.createBlockData()).getState();
|
||||
this.position = position;
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ae();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (references++ > 0)
|
||||
return;
|
||||
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), co(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.E, Block.i(iBlockData), ZERO, 0.0);
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
||||
playerConnection.a(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Y, true);
|
||||
playerConnection.a(packetPlayOutEntityMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!force && --references > 0)
|
||||
return false;
|
||||
|
||||
sendDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendDestroy(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntity(Player player) {
|
||||
display(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEntityDestroy(Player player) {
|
||||
hide(player, false);
|
||||
}
|
||||
}
|
@ -1,68 +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.simulator.AbstractSimulatorEntity;
|
||||
import de.steamwar.bausystem.shared.BaseEntity19;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SimulatorEntity19 extends BaseEntity19 implements AbstractSimulatorEntity {
|
||||
|
||||
private boolean printed = false;
|
||||
|
||||
public SimulatorEntity19(World world, Vector position, boolean highlight) {
|
||||
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ae();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Player player) {
|
||||
if (printed) return;
|
||||
printed = true;
|
||||
|
||||
sendEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector position) {
|
||||
this.position = position;
|
||||
e(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hide(Player player, boolean force) {
|
||||
if (!printed) return false;
|
||||
printed = false;
|
||||
|
||||
sendEntityDestroy(player);
|
||||
ag();
|
||||
return true;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
@ -1,165 +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;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FakeExplosion19 extends Explosion {
|
||||
|
||||
private List<FakeTNT19> fakeTNT19s;
|
||||
private boolean c;
|
||||
private Explosion.Effect d;
|
||||
private RandomSource e;
|
||||
private World f;
|
||||
private double g;
|
||||
private double h;
|
||||
private double i;
|
||||
@Nullable
|
||||
public Entity j;
|
||||
private float k;
|
||||
private DamageSource l;
|
||||
private ExplosionDamageCalculator m;
|
||||
private ObjectArrayList<BlockPosition> n;
|
||||
private Map<EntityHuman, Vec3D> o;
|
||||
public boolean wasCanceled;
|
||||
|
||||
public FakeExplosion19(List<FakeTNT19> fakeTNT19s, World world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) {
|
||||
super(world, entity, damageSource, behavior, x, y, z, power, createFire, destructionType);
|
||||
this.fakeTNT19s = fakeTNT19s;
|
||||
this.wasCanceled = false;
|
||||
this.e = RandomSource.a();
|
||||
this.n = new ObjectArrayList();
|
||||
this.o = Maps.newHashMap();
|
||||
this.f = world;
|
||||
this.j = entity;
|
||||
this.k = (float) Math.max((double) power, 0.0D);
|
||||
this.g = x;
|
||||
this.h = y;
|
||||
this.i = z;
|
||||
this.c = createFire;
|
||||
this.d = destructionType;
|
||||
this.l = damageSource == null ? DamageSource.a(this) : damageSource;
|
||||
this.m = new ExplosionDamageCalculator();
|
||||
|
||||
}
|
||||
|
||||
private float getBlockDensity(Vec3D vec3d, Entity entity) {
|
||||
return a(vec3d, entity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void a() {
|
||||
if ((this.k) >= 0.1F) {
|
||||
this.f.a(this.j, GameEvent.w, new Vec3D(this.g, this.h, this.i));
|
||||
/*
|
||||
Set<BlockPosition> set = Sets.newHashSet();
|
||||
|
||||
int i;
|
||||
int j;
|
||||
for (int k = 0; k < 16; ++k) {
|
||||
for (i = 0; i < 16; ++i) {
|
||||
for (j = 0; j < 16; ++j) {
|
||||
if (k == 0 || k == 15 || i == 0 || i == 15 || j == 0 || j == 15) {
|
||||
double d0 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
|
||||
double d1 = (double) ((float) i / 15.0F * 2.0F - 1.0F);
|
||||
double d2 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
|
||||
double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
|
||||
d0 /= d3;
|
||||
d1 /= d3;
|
||||
d2 /= d3;
|
||||
float f = this.k * (0.7F + this.f.w.i() * 0.6F);
|
||||
double d4 = this.g;
|
||||
double d5 = this.h;
|
||||
double d6 = this.i;
|
||||
|
||||
for (float var21 = 0.3F; f > 0.0F; f -= 0.22500001F) {
|
||||
BlockPosition blockposition = new BlockPosition(d4, d5, d6);
|
||||
IBlockData iblockdata = this.f.a_(blockposition);
|
||||
Fluid fluid = iblockdata.p();
|
||||
if (!this.f.j(blockposition)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Optional<Float> optional = this.m.a(this, this.f, blockposition, iblockdata, fluid);
|
||||
if (optional.isPresent()) {
|
||||
f -= ((Float) optional.get() + 0.3F) * 0.3F;
|
||||
}
|
||||
|
||||
if (f > 0.0F && this.m.a(this, this.f, blockposition, iblockdata, f)) {
|
||||
set.add(blockposition);
|
||||
}
|
||||
|
||||
d4 += d0 * 0.30000001192092896D;
|
||||
d5 += d1 * 0.30000001192092896D;
|
||||
d6 += d2 * 0.30000001192092896D;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.n.addAll(set);
|
||||
*/
|
||||
|
||||
float f2 = this.k * 2.0F;
|
||||
Vec3D vec3d = new Vec3D(this.g, this.h, this.i);
|
||||
for (int l1 = 0; l1 < fakeTNT19s.size(); ++l1) {
|
||||
Entity entity = (Entity) fakeTNT19s.get(l1);
|
||||
if (!entity.cF()) {
|
||||
double d7 = Math.sqrt(entity.e(vec3d)) / (double) f2;
|
||||
if (d7 <= 1.0D) {
|
||||
double d8 = entity.df() - this.g;
|
||||
double d9 = entity.dh() - this.h;
|
||||
double d10 = entity.dl() - this.i;
|
||||
double d11 = Math.sqrt(d8 * d8 + d9 * d9 + d10 * d10);
|
||||
if (d11 != 0.0D) {
|
||||
d8 /= d11;
|
||||
d9 /= d11;
|
||||
d10 /= d11;
|
||||
double d12 = (double) this.getBlockDensity(vec3d, entity);
|
||||
|
||||
double d13 = (1.0D - d7) * d12;
|
||||
entity.lastDamageCancelled = false;
|
||||
CraftEventFactory.entityDamage = null;
|
||||
entity.f(entity.dd().b(d8 * d13, d9 * d13, d10 * d13));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,257 +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;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
||||
import net.minecraft.network.syncher.DataWatcher;
|
||||
import net.minecraft.network.syncher.DataWatcherObject;
|
||||
import net.minecraft.network.syncher.DataWatcherRegistry;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.bukkit.entity.Explosive;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FakeTNT19 extends EntityTNTPrimed {
|
||||
private static final DataWatcherObject<Integer> b;
|
||||
private static final int c = 80;
|
||||
private List<FakeTNT19> fakeTNT19s;
|
||||
private List<FakeTNT19> spawnList = new ArrayList<>();
|
||||
private int count;
|
||||
@Nullable
|
||||
public EntityLiving d;
|
||||
public float yield;
|
||||
public boolean isIncendiary;
|
||||
|
||||
public FakeTNT19(List<FakeTNT19> fakeTNT19s, EntityTypes<? extends EntityTNTPrimed> type, World world) {
|
||||
super(type, world);
|
||||
this.fakeTNT19s = fakeTNT19s;
|
||||
this.yield = 4.0F;
|
||||
this.isIncendiary = false;
|
||||
super.q = true;
|
||||
}
|
||||
|
||||
public FakeTNT19(List<FakeTNT19> fakeTNT19s, World world, double x, double y, double z, int fuse, int count) {
|
||||
this(fakeTNT19s, EntityTypes.av, world);
|
||||
this.e(x, y, z);
|
||||
double d3 = world.w.j() * 6.2831854820251465D;
|
||||
this.n(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D);
|
||||
this.a(fuse);
|
||||
super.t = x;
|
||||
super.u = y;
|
||||
super.v = z;
|
||||
this.d = null;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
protected void a_() {
|
||||
super.Y.a(b, 80);
|
||||
}
|
||||
|
||||
protected MovementEmission aO() {
|
||||
return MovementEmission.a;
|
||||
}
|
||||
|
||||
public boolean bl() {
|
||||
return !this.dt();
|
||||
}
|
||||
|
||||
private Vec3D g(Vec3D vec3d) {
|
||||
AxisAlignedBB axisalignedbb = this.cz();
|
||||
List<VoxelShape> list = this.s.b(this, axisalignedbb.b(vec3d));
|
||||
Vec3D vec3d1 = vec3d.g() == 0.0 ? vec3d : a(this, vec3d, axisalignedbb, this.s, list);
|
||||
boolean flag = vec3d.c != vec3d1.c;
|
||||
boolean flag1 = vec3d.d != vec3d1.d;
|
||||
boolean flag2 = vec3d.e != vec3d1.e;
|
||||
boolean flag3 = this.y || flag1 && vec3d.d < 0.0;
|
||||
if (this.P > 0.0F && flag3 && (flag || flag2)) {
|
||||
Vec3D vec3d2 = a(this, new Vec3D(vec3d.c, (double)this.P, vec3d.e), axisalignedbb, this.s, list);
|
||||
Vec3D vec3d3 = a(this, new Vec3D(0.0, (double)this.P, 0.0), axisalignedbb.b(vec3d.c, 0.0, vec3d.e), this.s, list);
|
||||
if (vec3d3.d < (double)this.P) {
|
||||
Vec3D vec3d4 = a(this, new Vec3D(vec3d.c, 0.0, vec3d.e), axisalignedbb.c(vec3d3), this.s, list).e(vec3d3);
|
||||
if (vec3d4.i() > vec3d2.i()) {
|
||||
vec3d2 = vec3d4;
|
||||
}
|
||||
}
|
||||
|
||||
if (vec3d2.i() > vec3d1.i()) {
|
||||
return vec3d2.e(a(this, new Vec3D(0.0, -vec3d2.d + vec3d.d, 0.0), axisalignedbb.c(vec3d2), this.s, list));
|
||||
}
|
||||
}
|
||||
|
||||
return vec3d1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(EnumMoveType enummovetype, Vec3D vec3d) {
|
||||
if (this.E.g() > 1.0E-7) {
|
||||
vec3d = vec3d.h(this.E);
|
||||
this.E = Vec3D.b;
|
||||
this.f(Vec3D.b);
|
||||
}
|
||||
|
||||
Vec3D vec3d1 = this.g(vec3d);
|
||||
double d0 = vec3d1.g();
|
||||
if (d0 > 1.0E-7) {
|
||||
this.e(this.df() + vec3d1.c, this.dg() + vec3d1.d, this.dl() + vec3d1.e);
|
||||
}
|
||||
|
||||
boolean flag = !MathHelper.b(vec3d.c, vec3d1.c);
|
||||
boolean flag1 = !MathHelper.b(vec3d.e, vec3d1.e);
|
||||
this.z = flag || flag1;
|
||||
this.A = vec3d.d != vec3d1.d;
|
||||
this.B = this.A && vec3d.d < 0.0;
|
||||
if (this.z) {
|
||||
this.C = this.b(vec3d1);
|
||||
} else {
|
||||
this.C = false;
|
||||
}
|
||||
|
||||
this.y = this.A && vec3d.d < 0.0;
|
||||
BlockPosition blockposition = this.aA();
|
||||
IBlockData iblockdata = this.s.a_(blockposition);
|
||||
// this.a(vec3d1.d, this.y, iblockdata, blockposition);
|
||||
if (!this.dt()) {
|
||||
if (this.z) {
|
||||
Vec3D vec3d2 = this.dd();
|
||||
this.n(flag ? 0.0 : vec3d2.c, vec3d2.d, flag1 ? 0.0 : vec3d2.e);
|
||||
}
|
||||
|
||||
net.minecraft.world.level.block.Block block = iblockdata.b();
|
||||
if (vec3d.d != vec3d1.d) {
|
||||
block.a(this.s, this);
|
||||
}
|
||||
|
||||
if (this.y) {
|
||||
block.a(this.s, blockposition, iblockdata, this);
|
||||
}
|
||||
|
||||
this.ax();
|
||||
float f2 = this.aD();
|
||||
this.f(this.dd().d((double)f2, 1.0, (double)f2));
|
||||
}
|
||||
}
|
||||
|
||||
public void k(List<FakeTNT19> spawnList) {
|
||||
if (!this.aN()) {
|
||||
this.f(this.dd().b(0.0D, -0.04D, 0.0D));
|
||||
}
|
||||
|
||||
this.a(EnumMoveType.a, this.dd());
|
||||
this.f(this.dd().a(0.98D));
|
||||
if (super.y) {
|
||||
this.f(this.dd().d(0.7D, -0.5D, 0.7D));
|
||||
}
|
||||
|
||||
int i = this.i() - 1;
|
||||
this.a(i);
|
||||
if (i <= 0) {
|
||||
if (!super.s.y) {
|
||||
this.j1();
|
||||
}
|
||||
|
||||
this.ah();
|
||||
} else {
|
||||
this.aY();
|
||||
}
|
||||
|
||||
if (i == 1 && count > 1) {
|
||||
for (int c = 0; c < count - 1; c++) {
|
||||
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, this.s, this.df(), this.dh(), this.dl(), i, 1);
|
||||
fakeTNT19.y = this.y;
|
||||
fakeTNT19.f(new Vec3D(this.dd().c, this.dd().d, this.dd().e));
|
||||
spawnList.add(fakeTNT19);
|
||||
}
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void j1() {
|
||||
ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) this.getBukkitEntity());
|
||||
super.s.getCraftServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
this.a(this, this.df(), this.e(0.0625D), this.dl(), event.getRadius(), event.getFire(), Explosion.Effect.b);
|
||||
}
|
||||
}
|
||||
|
||||
public FakeExplosion19 a(@Nullable Entity entity, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) {
|
||||
return this.a(entity, (DamageSource) null, (ExplosionDamageCalculator) null, x, y, z, power, createFire, destructionType);
|
||||
}
|
||||
|
||||
public FakeExplosion19 a(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) {
|
||||
FakeExplosion19 explosion = new FakeExplosion19(fakeTNT19s, SimulatorPreview19.WORLD, entity, damageSource, behavior, x, y, z, power, createFire, destructionType);
|
||||
explosion.a();
|
||||
// explosion.a(true);
|
||||
return explosion;
|
||||
}
|
||||
|
||||
|
||||
protected void b(NBTTagCompound nbt) {
|
||||
nbt.a("Fuse", (short) this.i());
|
||||
}
|
||||
|
||||
protected void a(NBTTagCompound nbt) {
|
||||
this.a(nbt.g("Fuse"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EntityLiving h() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
protected float a(EntityPose pose, EntitySize dimensions) {
|
||||
return 0.15F;
|
||||
}
|
||||
|
||||
public void a(int fuse) {
|
||||
super.Y.b(b, fuse);
|
||||
}
|
||||
|
||||
public int i() {
|
||||
return (Integer) super.Y.a(b);
|
||||
}
|
||||
|
||||
public Packet<?> S() {
|
||||
return new PacketPlayOutSpawnEntity(this);
|
||||
}
|
||||
|
||||
public boolean cr() {
|
||||
return super.cr();
|
||||
}
|
||||
|
||||
static {
|
||||
b = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.b);
|
||||
}
|
||||
}
|
@ -1,136 +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;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import net.minecraft.world.level.World;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SimulatorPreview19 implements SimulatorPreview {
|
||||
|
||||
public static final World WORLD = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
|
||||
|
||||
@Override
|
||||
public Record simulate(TNTSimulator tntSimulator) {
|
||||
if (true) {
|
||||
return new Record(null);
|
||||
}
|
||||
|
||||
Map<Integer, Map<Integer, Set<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> result = new HashMap<>();
|
||||
for (SimulatorElement element : tntSimulator.getTntElementList()) {
|
||||
element.locations(result);
|
||||
}
|
||||
|
||||
AtomicInteger maxTick = new AtomicInteger(0);
|
||||
Map<Integer, List<List<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> toSpawn = new HashMap<>();
|
||||
AtomicInteger tntCount = new AtomicInteger(0);
|
||||
result.forEach((integer, integerSetMap) -> {
|
||||
List<Pair<Integer, Set<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> internal = new ArrayList<>();
|
||||
integerSetMap.forEach((integer1, pairs) -> {
|
||||
internal.add(new Pair<>(integer1, pairs));
|
||||
});
|
||||
internal.sort(Comparator.comparingInt(Pair::getKey));
|
||||
|
||||
toSpawn.put(integer, internal.stream().map(Pair::getValue).peek(pairs -> {
|
||||
tntCount.addAndGet(pairs.stream().mapToInt(Pair::getValue).sum());
|
||||
}).map(ArrayList::new).peek(Collections::shuffle).collect(Collectors.toList()));
|
||||
|
||||
if (maxTick.get() < integer) {
|
||||
maxTick.set(integer);
|
||||
}
|
||||
});
|
||||
if (tntCount.get() > 500) {
|
||||
return new Record(null);
|
||||
}
|
||||
|
||||
List<FakeTNT19> fakeTNT19s = new ArrayList<>();
|
||||
Record record = new Record(null);
|
||||
Map<FakeTNT19, Record.TNTRecord> tntRecords = new HashMap<>();
|
||||
|
||||
int maxTickToCalc = maxTick.get() + 160;
|
||||
for (int tick = 0; tick < maxTickToCalc; tick++) {
|
||||
List<List<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>> toSpawnInTick = toSpawn.get(tick);
|
||||
try {
|
||||
if (toSpawnInTick == null) continue;
|
||||
toSpawnInTick.forEach(pairs -> {
|
||||
AtomicBoolean hasSomeLeft = new AtomicBoolean(true);
|
||||
while(hasSomeLeft.get()) {
|
||||
hasSomeLeft.set(false);
|
||||
pairs.forEach(pair -> {
|
||||
SimulatorPreview.SimulatorPreviewTNTData previewTNTData = pair.getKey();
|
||||
if (!previewTNTData.isXVelocity() && !previewTNTData.isZVelocity()) {
|
||||
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, WORLD, previewTNTData.getX(), previewTNTData.getY(), previewTNTData.getZ(), previewTNTData.getFuseTicks(), pair.getValue());
|
||||
TNTPrimed tntPrimed = (TNTPrimed) fakeTNT19.getBukkitEntity();
|
||||
if (!previewTNTData.isXVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
|
||||
if (!previewTNTData.isYVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));
|
||||
if (!previewTNTData.isZVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0));
|
||||
fakeTNT19s.add(fakeTNT19);
|
||||
pair.setValue(0);
|
||||
} else if (pair.getValue() > 0) {
|
||||
hasSomeLeft.set(true);
|
||||
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, WORLD, previewTNTData.getX(), previewTNTData.getY(), previewTNTData.getZ(), previewTNTData.getFuseTicks(), 1);
|
||||
TNTPrimed tntPrimed = (TNTPrimed) fakeTNT19.getBukkitEntity();
|
||||
if (!previewTNTData.isXVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
|
||||
if (!previewTNTData.isYVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));
|
||||
if (!previewTNTData.isZVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0));
|
||||
fakeTNT19s.add(fakeTNT19);
|
||||
pair.setValue(pair.getValue() - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
calculateTick(fakeTNT19s, record, tntRecords);
|
||||
}
|
||||
}
|
||||
return record;
|
||||
}
|
||||
|
||||
private void calculateTick(List<FakeTNT19> fakeTNT19s, Record record, Map<FakeTNT19, Record.TNTRecord> tntRecords) {
|
||||
int i = 0;
|
||||
while (i < fakeTNT19s.size()) {
|
||||
List<FakeTNT19> spawnList = new ArrayList<>();
|
||||
FakeTNT19 fakeTNT19 = fakeTNT19s.get(i);
|
||||
fakeTNT19.k(spawnList);
|
||||
TNTPrimed tntPrimed = ((TNTPrimed) (fakeTNT19.getBukkitEntity()));
|
||||
if (tntPrimed.getFuseTicks() <= 0) {
|
||||
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed);
|
||||
fakeTNT19s.remove(i);
|
||||
i--;
|
||||
} else {
|
||||
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed);
|
||||
}
|
||||
if (!spawnList.isEmpty()) {
|
||||
fakeTNT19s.addAll(i, spawnList);
|
||||
i += spawnList.size();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -1,94 +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.item.EntityFallingBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class BaseEntity19 extends EntityFallingBlock implements AbstractEntity {
|
||||
|
||||
private static final Field ao;
|
||||
|
||||
static {
|
||||
try {
|
||||
ao = EntityFallingBlock.class.getDeclaredField("ao");
|
||||
ao.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
||||
|
||||
private final IBlockData iBlockData;
|
||||
protected Vector position;
|
||||
|
||||
public BaseEntity19(World world, Vector position, Material blockType) {
|
||||
super(EntityTypes.E, ((CraftWorld) world).getHandle());
|
||||
try {
|
||||
ao.set(this, ((CraftBlockData) blockType.createBlockData()).getState());
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.q = true;
|
||||
e(position.getX(), position.getY(), position.getZ());
|
||||
f(Vec3D.b);
|
||||
t = position.getX();
|
||||
u = position.getY();
|
||||
v = position.getZ();
|
||||
a(this.db());
|
||||
|
||||
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
|
||||
this.position = position;
|
||||
|
||||
this.e(true);
|
||||
this.S = -12000;
|
||||
}
|
||||
|
||||
public void sendEntity(Player player) {
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), co(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.E, Block.i(iBlockData), 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);
|
||||
}
|
||||
}
|
@ -21,15 +21,7 @@ package de.steamwar.bausystem.utils;
|
||||
|
||||
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,14 +31,16 @@ 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;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -167,26 +161,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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractDetonatorEntity constructDetonator(World world, Vector position) {
|
||||
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);
|
||||
|
@ -1,40 +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.linkage.types;
|
||||
|
||||
import de.steamwar.linkage.LinkageType;
|
||||
import de.steamwar.linkage.plan.BuildPlan;
|
||||
import de.steamwar.linkage.plan.MethodBuilder;
|
||||
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
public class BlockAttribute_GENERIC implements LinkageType {
|
||||
|
||||
@Override
|
||||
public String method() {
|
||||
return "linkBlockAttributes";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
|
||||
buildPlan.addImport("de.steamwar.bausystem.features.attributescopy.*");
|
||||
methodBuilder.addLine("AttributesCopyCommand.add(" + s + ");");
|
||||
}
|
||||
}
|
@ -121,19 +121,4 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void createLink(String source, String destination) {
|
||||
try {
|
||||
Bukkit.getLogger().log(Level.INFO, "Executing: ln -s /home/minecraft/server/Bau15/{0} {1}", new String[]{source, destination});
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("ln", "-s", "/home/minecraft/server/Bau15/" + source, destination);
|
||||
processBuilder.directory(world.getWorldFolder());
|
||||
processBuilder.inheritIO();
|
||||
|
||||
Process process = processBuilder.start();
|
||||
process.waitFor();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
Bukkit.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
@ -36,7 +36,6 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
@MinVersion(18)
|
||||
public class AttributeRemoveCommand extends SWCommand {
|
||||
|
||||
public AttributeRemoveCommand() {
|
||||
|
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* 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.attributescopy;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@UtilityClass
|
||||
public class AttributeUtils {
|
||||
|
||||
private Map<Method, String> names = new HashMap<>();
|
||||
private Map<Class<?>, List<Method>> getters = new HashMap<>();
|
||||
private Map<Class<?>, Map<String, Method>> setters = new HashMap<>();
|
||||
|
||||
private void generate(BlockData blockData) {
|
||||
Class<? extends BlockData> clazz = blockData.getClass();
|
||||
if (getters.containsKey(clazz) && setters.containsKey(clazz)) return;
|
||||
|
||||
Map<String, List<Method>> methods = new HashMap<>();
|
||||
for (Method declaredMethod : clazz.getMethods()) {
|
||||
String s = declaredMethod.getName();
|
||||
if (s.startsWith("get") && declaredMethod.getParameterCount() == 0) {
|
||||
methods.computeIfAbsent(s.substring(3), aClass -> new ArrayList<>()).add(declaredMethod);
|
||||
} else if (s.startsWith("is") && declaredMethod.getParameterCount() == 0) {
|
||||
methods.computeIfAbsent(s.substring(2), aClass -> new ArrayList<>()).add(declaredMethod);
|
||||
} else if (s.startsWith("set") && declaredMethod.getParameterCount() == 1) {
|
||||
methods.computeIfAbsent(s.substring(3), aClass -> new ArrayList<>()).add(declaredMethod);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, List<Method>> entry : methods.entrySet()) {
|
||||
if (entry.getValue().size() != 2) continue;
|
||||
for (Method method : entry.getValue()) {
|
||||
names.put(method, entry.getKey());
|
||||
if (method.getName().startsWith("is") || method.getName().startsWith("get")) {
|
||||
getters.computeIfAbsent(clazz, aClass -> new ArrayList<>()).add(method);
|
||||
} else {
|
||||
setters.computeIfAbsent(clazz, aClass -> new HashMap<>()).put(entry.getKey(), method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void copy(BlockData blockData, List<String> attributes) {
|
||||
generate(blockData);
|
||||
|
||||
getters.getOrDefault(blockData.getClass(), new ArrayList<>()).forEach(method -> {
|
||||
try {
|
||||
Object invoke = method.invoke(blockData);
|
||||
if (invoke != null) {
|
||||
attributes.add("§8-§7 " + names.get(method) + "§8:§7 " + convert(invoke));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void paste(BlockData blockData, List<String> attributes) {
|
||||
generate(blockData);
|
||||
|
||||
for (String attribute : attributes) {
|
||||
String[] split = attribute.split("§8:§7 ");
|
||||
if (split.length != 2) continue;
|
||||
String name = split[0].substring(6);
|
||||
String value = split[1];
|
||||
Method method = setters.getOrDefault(blockData.getClass(), new HashMap<>()).get(name);
|
||||
if (method == null) continue;
|
||||
try {
|
||||
method.invoke(blockData, convert(value, method.getParameterTypes()[0]));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String convert(Object o) {
|
||||
if (o.getClass().isEnum()) {
|
||||
return ((Enum<?>) o).name();
|
||||
} else {
|
||||
return o.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private Object convert(String s, Class<?> type) {
|
||||
if (type.isEnum()) {
|
||||
return Enum.valueOf((Class<? extends Enum>) type, s);
|
||||
} else if (type == int.class || type == Integer.class) {
|
||||
return Integer.parseInt(s);
|
||||
} else if (type == double.class || type == Double.class) {
|
||||
return Double.parseDouble(s);
|
||||
} else if (type == float.class || type == Float.class) {
|
||||
return Float.parseFloat(s);
|
||||
} else if (type == long.class || type == Long.class) {
|
||||
return Long.parseLong(s);
|
||||
} else if (type == short.class || type == Short.class) {
|
||||
return Short.parseShort(s);
|
||||
} else if (type == byte.class || type == Byte.class) {
|
||||
return Byte.parseByte(s);
|
||||
} else if (type == boolean.class || type == Boolean.class) {
|
||||
return Boolean.parseBoolean(s);
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
@ -20,10 +20,8 @@
|
||||
package de.steamwar.bausystem.features.attributescopy;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.linkage.LinkageUtils;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -36,40 +34,29 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Linked
|
||||
@MinVersion(18)
|
||||
public class AttributesCopyCommand extends SWCommand {
|
||||
|
||||
static List<BlockAttribute<?>> blockAttributeList = new ArrayList<>();
|
||||
|
||||
public static void add(BlockAttribute<?> blockAttribute) {
|
||||
blockAttributeList.add(blockAttribute);
|
||||
}
|
||||
|
||||
public AttributesCopyCommand() {
|
||||
super("copyattributes", "attributescopy", "ac");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player player) {
|
||||
linkIfNeeded();
|
||||
|
||||
Block block = player.getTargetBlockExact(8, FluidCollisionMode.ALWAYS);
|
||||
if (block == null) return;
|
||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
if (!isSame(block, mainHand)) {
|
||||
|
||||
if (!(block.getType().isItem() && block.getType() == mainHand.getType() || isSame(block, mainHand))) {
|
||||
BauSystem.MESSAGE.send("ATTRIBUTES_CANT_COPY", player);
|
||||
return;
|
||||
}
|
||||
|
||||
BlockData blockData = block.getBlockData();
|
||||
List<String> attributesToCopy = new ArrayList<>();
|
||||
if (needsType(block)) {
|
||||
attributesToCopy.add("§8-§7 material " + block.getType().name().toLowerCase());
|
||||
}
|
||||
for (BlockAttribute blockAttribute : blockAttributeList) {
|
||||
if (blockAttribute.type().isInstance(blockData)) {
|
||||
blockAttribute.copy(attributesToCopy, blockData);
|
||||
}
|
||||
if (block.getType() != mainHand.getType()) {
|
||||
attributesToCopy.add("§8-§7 Material§8:§7 " + block.getType().name());
|
||||
}
|
||||
AttributeUtils.copy(blockData, attributesToCopy);
|
||||
if (attributesToCopy.isEmpty()) {
|
||||
BauSystem.MESSAGE.send("ATTRIBUTES_NO_COPY", player);
|
||||
return;
|
||||
@ -83,15 +70,7 @@ public class AttributesCopyCommand extends SWCommand {
|
||||
BauSystem.MESSAGE.send("ATTRIBUTES_COPIED", player);
|
||||
}
|
||||
|
||||
private static boolean isLinked = false;
|
||||
static void linkIfNeeded() {
|
||||
if (isLinked) return;
|
||||
LinkageUtils.linkBlockAttributes();
|
||||
isLinked = true;
|
||||
}
|
||||
|
||||
private boolean isSame(Block block, ItemStack itemStack) {
|
||||
if (block.getType() == itemStack.getType()) return true;
|
||||
if (itemStack.getType() == Material.REDSTONE && block.getType() == Material.REDSTONE_WIRE) return true;
|
||||
if (itemStack.getType() == Material.PLAYER_HEAD && block.getType() == Material.PLAYER_WALL_HEAD) return true;
|
||||
if (itemStack.getType() == Material.ZOMBIE_HEAD && block.getType() == Material.ZOMBIE_WALL_HEAD) return true;
|
||||
@ -102,22 +81,8 @@ public class AttributesCopyCommand extends SWCommand {
|
||||
if (itemStack.getType() == Material.TORCH && block.getType() == Material.WALL_TORCH) return true;
|
||||
if (itemStack.getType() == Material.SOUL_TORCH && block.getType() == Material.SOUL_WALL_TORCH) return true;
|
||||
if (itemStack.getType() == Material.REDSTONE_TORCH && block.getType() == Material.REDSTONE_WALL_TORCH) return true;
|
||||
if (itemStack.getType() == Material.WHEAT_SEEDS && block.getType() == Material.WHEAT) return true;
|
||||
if (itemStack.getType().name().contains("_BANNER") && block.getType().name().contains("_WALL_BANNER")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean needsType(Block block) {
|
||||
if (block.getType().name().contains("WALL")) return true;
|
||||
if (block.getType() == Material.PLAYER_HEAD) return true;
|
||||
if (block.getType() == Material.ZOMBIE_HEAD) return true;
|
||||
if (block.getType() == Material.CREEPER_HEAD) return true;
|
||||
if (block.getType() == Material.DRAGON_HEAD) return true;
|
||||
if (block.getType() == Material.SKELETON_SKULL) return true;
|
||||
if (block.getType() == Material.WITHER_SKELETON_SKULL) return true;
|
||||
if (block.getType() == Material.TORCH) return true;
|
||||
if (block.getType() == Material.SOUL_TORCH) return true;
|
||||
if (block.getType() == Material.REDSTONE_TORCH) return true;
|
||||
if (block.getType().name().contains("_BANNER")) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.attributescopy;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -33,21 +32,14 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.profile.PlayerProfile;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static de.steamwar.bausystem.features.attributescopy.AttributesCopyCommand.blockAttributeList;
|
||||
|
||||
@Linked
|
||||
@MinVersion(18)
|
||||
public class AttributesPlaceListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
AttributesCopyCommand.linkIfNeeded();
|
||||
ItemStack itemStack = event.getItemInHand();
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (itemMeta == null) return;
|
||||
@ -65,12 +57,12 @@ public class AttributesPlaceListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
Material material = strings.stream()
|
||||
.filter(s -> s.startsWith("§8-§7 material "))
|
||||
.map(s -> s.replace("§8-§7 material ", ""))
|
||||
.filter(s -> s.startsWith("§8-§7 Material§8:§7 "))
|
||||
.map(s -> s.replace("§8-§7 Material§8:§7 ", ""))
|
||||
.map(String::toUpperCase)
|
||||
.map(s -> {
|
||||
try {
|
||||
return Material.valueOf(s.toUpperCase());
|
||||
return Material.valueOf(s);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
@ -78,7 +70,6 @@ public class AttributesPlaceListener implements Listener {
|
||||
.findFirst()
|
||||
.orElse(type);
|
||||
event.getBlock().setType(material, false);
|
||||
Set<String> attributesToPaste = new HashSet<>(strings);
|
||||
Block block = event.getBlock();
|
||||
BlockData blockData = block.getBlockData();
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
@ -88,11 +79,7 @@ public class AttributesPlaceListener implements Listener {
|
||||
skull.update(true, false);
|
||||
}
|
||||
}, 1);
|
||||
for (BlockAttribute blockAttribute : blockAttributeList) {
|
||||
if (blockAttribute.type().isInstance(blockData)) {
|
||||
blockAttribute.paste(attributesToPaste, blockData);
|
||||
}
|
||||
}
|
||||
AttributeUtils.paste(blockData, strings);
|
||||
block.setBlockData(blockData, false);
|
||||
}, 1);
|
||||
}
|
||||
|
@ -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.attributescopy;
|
||||
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface BlockAttribute<T extends BlockData> {
|
||||
Class<T> type();
|
||||
void copy(List<String> attributes, T blockData);
|
||||
void paste(Set<String> attributes, T blockData);
|
||||
}
|
@ -1,53 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class AgeableAttribute implements BlockAttribute<Ageable> {
|
||||
|
||||
private String attribute = "§8-§7 age ";
|
||||
|
||||
@Override
|
||||
public Class<Ageable> type() {
|
||||
return Ageable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Ageable blockData) {
|
||||
attributes.add(attribute + blockData.getAge());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Ageable blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setAge);
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.AnaloguePowerable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class AnaloguePowerableAttribute implements BlockAttribute<AnaloguePowerable> {
|
||||
|
||||
private String attribute = "§8-§7 power ";
|
||||
|
||||
@Override
|
||||
public Class<AnaloguePowerable> type() {
|
||||
return AnaloguePowerable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, AnaloguePowerable blockData) {
|
||||
attributes.add(attribute + blockData.getPower());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, AnaloguePowerable blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setPower);
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Attachable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class AttachableAttribute implements BlockAttribute<Attachable> {
|
||||
|
||||
private String attribute = "§8-§7 attached";
|
||||
|
||||
@Override
|
||||
public Class<Attachable> type() {
|
||||
return Attachable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Attachable blockData) {
|
||||
if (blockData.isAttached()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Attachable blockData) {
|
||||
blockData.setAttached(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class BisectedAttribute implements BlockAttribute<Bisected> {
|
||||
|
||||
private String attribute = "§8-§7 half ";
|
||||
|
||||
@Override
|
||||
public Class<Bisected> type() {
|
||||
return Bisected.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Bisected blockData) {
|
||||
attributes.add(attribute + blockData.getHalf().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Bisected blockData) {
|
||||
for (Bisected.Half half : Bisected.Half.values()) {
|
||||
if (attributes.contains(attribute + half.name().toLowerCase())) {
|
||||
blockData.setHalf(half);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Directional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class DirectionalAttribute implements BlockAttribute<Directional> {
|
||||
|
||||
private String attribute = "§8-§7 facing ";
|
||||
|
||||
@Override
|
||||
public Class<Directional> type() {
|
||||
return Directional.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Directional blockData) {
|
||||
attributes.add(attribute + blockData.getFacing().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Directional blockData) {
|
||||
for (BlockFace blockFace : blockData.getFaces()) {
|
||||
if (attributes.contains(attribute + blockFace.name().toLowerCase())) {
|
||||
blockData.setFacing(blockFace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.FaceAttachable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class FaceAttachableAttribute implements BlockAttribute<FaceAttachable> {
|
||||
|
||||
private String attribute = "§8-§7 attached ";
|
||||
|
||||
@Override
|
||||
public Class<FaceAttachable> type() {
|
||||
return FaceAttachable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, FaceAttachable blockData) {
|
||||
attributes.add(attribute + blockData.getAttachedFace().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, FaceAttachable blockData) {
|
||||
for (FaceAttachable.AttachedFace attachedFace : FaceAttachable.AttachedFace.values()) {
|
||||
if (attributes.contains(attribute + attachedFace.name().toLowerCase())) {
|
||||
blockData.setAttachedFace(attachedFace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,51 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.block.data.Hangable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
@MinVersion(19)
|
||||
public class HangableAttribute implements BlockAttribute<Hangable> {
|
||||
|
||||
private String attribute = "§8-§7 hanging";
|
||||
|
||||
@Override
|
||||
public Class<Hangable> type() {
|
||||
return Hangable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Hangable blockData) {
|
||||
if (!blockData.isHanging()) return;
|
||||
attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Hangable blockData) {
|
||||
blockData.setHanging(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Levelled;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class LevelledAttribute implements BlockAttribute<Levelled> {
|
||||
|
||||
private String attribute = "§8-§7 level ";
|
||||
|
||||
@Override
|
||||
public Class<Levelled> type() {
|
||||
return Levelled.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Levelled blockData) {
|
||||
attributes.add(attribute + blockData.getLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Levelled blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setLevel);
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Lightable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class LightableAttribute implements BlockAttribute<Lightable> {
|
||||
|
||||
private String attribute = "§8-§7 lit";
|
||||
|
||||
@Override
|
||||
public Class<Lightable> type() {
|
||||
return Lightable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Lightable blockData) {
|
||||
if (blockData.isLit()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Lightable blockData) {
|
||||
blockData.setLit(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class MultipleFacingAttribute implements BlockAttribute<MultipleFacing> {
|
||||
|
||||
private String attribute = "§8-§7 connected ";
|
||||
|
||||
@Override
|
||||
public Class<MultipleFacing> type() {
|
||||
return MultipleFacing.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, MultipleFacing blockData) {
|
||||
blockData.getFaces().forEach(blockFace -> {
|
||||
attributes.add(attribute + blockFace.name().toLowerCase());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, MultipleFacing blockData) {
|
||||
for (BlockFace blockFace : BlockFace.values()) {
|
||||
blockData.setFace(blockFace, attributes.contains(attribute + blockFace.name().toLowerCase()));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Openable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class OpenableAttribute implements BlockAttribute<Openable> {
|
||||
|
||||
private String attribute = "§8-§7 open";
|
||||
|
||||
@Override
|
||||
public Class<Openable> type() {
|
||||
return Openable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Openable blockData) {
|
||||
if (blockData.isOpen()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Openable blockData) {
|
||||
blockData.setOpen(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,54 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Axis;
|
||||
import org.bukkit.block.data.Orientable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class OrientableAttribute implements BlockAttribute<Orientable> {
|
||||
|
||||
private String attribute = "§8-§7 orientation ";
|
||||
|
||||
@Override
|
||||
public Class<Orientable> type() {
|
||||
return Orientable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Orientable blockData) {
|
||||
attributes.add(attribute + blockData.getAxis().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Orientable blockData) {
|
||||
for (Axis axis : Axis.values()) {
|
||||
if (attributes.contains(attribute + axis.name().toLowerCase())) {
|
||||
blockData.setAxis(axis);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Powerable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class PowerableAttribute implements BlockAttribute<Powerable> {
|
||||
|
||||
private String attribute = "§8-§7 powered";
|
||||
|
||||
@Override
|
||||
public Class<Powerable> type() {
|
||||
return Powerable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Powerable blockData) {
|
||||
if (blockData.isPowered()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Powerable blockData) {
|
||||
blockData.setPowered(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Rail;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class RailAttribute implements BlockAttribute<Rail> {
|
||||
|
||||
private String attribute = "§8-§7 rail shape ";
|
||||
|
||||
@Override
|
||||
public Class<Rail> type() {
|
||||
return Rail.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Rail blockData) {
|
||||
attributes.add(attribute + blockData.getShape().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Rail blockData) {
|
||||
for (Rail.Shape shape : Rail.Shape.values()) {
|
||||
if (attributes.contains(attribute + shape)) {
|
||||
blockData.setShape(shape);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Rotatable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class RotatableAttribute implements BlockAttribute<Rotatable> {
|
||||
|
||||
private String attribute = "§8-§7 rotation ";
|
||||
|
||||
@Override
|
||||
public Class<Rotatable> type() {
|
||||
return Rotatable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Rotatable blockData) {
|
||||
attributes.add(attribute + blockData.getRotation().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Rotatable blockData) {
|
||||
for (BlockFace face : BlockFace.values()) {
|
||||
if (attributes.contains(attribute + face.name())) {
|
||||
blockData.setRotation(face);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Snowable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class SnowableAttribute implements BlockAttribute<Snowable> {
|
||||
|
||||
private String attribute = "§8-§7 snowy";
|
||||
|
||||
@Override
|
||||
public Class<Snowable> type() {
|
||||
return Snowable.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Snowable blockData) {
|
||||
if (blockData.isSnowy()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Snowable blockData) {
|
||||
blockData.setSnowy(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,49 +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.attributescopy.impl;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class WaterloggedAttribute implements BlockAttribute<Waterlogged> {
|
||||
|
||||
private String attribute = "§8-§7 waterlogged";
|
||||
|
||||
@Override
|
||||
public Class<Waterlogged> type() {
|
||||
return Waterlogged.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Waterlogged waterlogged) {
|
||||
if (!waterlogged.isWaterlogged()) return;
|
||||
attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Waterlogged waterlogged) {
|
||||
waterlogged.setWaterlogged(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Bamboo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class BambooAttribute implements BlockAttribute<Bamboo> {
|
||||
|
||||
private String attribute = "§8-§7 leaves ";
|
||||
|
||||
@Override
|
||||
public Class<Bamboo> type() {
|
||||
return Bamboo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Bamboo blockData) {
|
||||
attributes.add(attribute + blockData.getLeaves());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Bamboo blockData) {
|
||||
for (Bamboo.Leaves leaves : Bamboo.Leaves.values()) {
|
||||
if (attributes.contains(attribute + leaves)) {
|
||||
blockData.setLeaves(leaves);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Bell;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class BellAttribute implements BlockAttribute<Bell> {
|
||||
|
||||
private String attribute = "§8-§7 attachament ";
|
||||
|
||||
@Override
|
||||
public Class<Bell> type() {
|
||||
return Bell.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Bell blockData) {
|
||||
attributes.add(attribute + blockData.getAttachment());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Bell blockData) {
|
||||
for (Bell.Attachment attachment : Bell.Attachment.values()) {
|
||||
if (attributes.contains(attribute + attachment)) {
|
||||
blockData.setAttachment(attachment);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.block.data.type.BigDripleaf;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
@MinVersion(18)
|
||||
public class BigDripleafAttribute implements BlockAttribute<BigDripleaf> {
|
||||
|
||||
private String attribute = "§8-§7 tilt ";
|
||||
|
||||
@Override
|
||||
public Class<BigDripleaf> type() {
|
||||
return BigDripleaf.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, BigDripleaf blockData) {
|
||||
attributes.add(attribute + blockData.getTilt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, BigDripleaf blockData) {
|
||||
for (BigDripleaf.Tilt tilt : BigDripleaf.Tilt.values()) {
|
||||
if (attributes.contains(attribute + tilt)) {
|
||||
blockData.setTilt(tilt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Cake;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class CakeAttribute implements BlockAttribute<Cake> {
|
||||
|
||||
private String attribute = "§8-§7 bites ";
|
||||
|
||||
@Override
|
||||
public Class<Cake> type() {
|
||||
return Cake.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Cake blockData) {
|
||||
attributes.add(attribute + blockData.getBites());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Cake blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setBites);
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Campfire;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class CampfireAttribute implements BlockAttribute<Campfire> {
|
||||
|
||||
private String attribute = "§8-§7 signal fire";
|
||||
|
||||
@Override
|
||||
public Class<Campfire> type() {
|
||||
return Campfire.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Campfire blockData) {
|
||||
if (blockData.isSignalFire()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Campfire blockData) {
|
||||
blockData.setSignalFire(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Candle;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class CandleAttribute implements BlockAttribute<Candle> {
|
||||
|
||||
private String attribute = "§8-§7 candles ";
|
||||
|
||||
@Override
|
||||
public Class<Candle> type() {
|
||||
return Candle.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Candle blockData) {
|
||||
if (blockData.getCandles() > 0) attributes.add(attribute + blockData.getCandles());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Candle blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setCandles);
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.CaveVinesPlant;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class CaveVinesPlantAttribute implements BlockAttribute<CaveVinesPlant> {
|
||||
|
||||
private String attribute = "§8-§7 berries";
|
||||
|
||||
@Override
|
||||
public Class<CaveVinesPlant> type() {
|
||||
return CaveVinesPlant.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, CaveVinesPlant blockData) {
|
||||
if (blockData.isBerries()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, CaveVinesPlant blockData) {
|
||||
blockData.setBerries(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Comparator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class ComparatorAttribute implements BlockAttribute<Comparator> {
|
||||
|
||||
private String attribute = "§8-§7 mode ";
|
||||
|
||||
@Override
|
||||
public Class<Comparator> type() {
|
||||
return Comparator.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Comparator blockData) {
|
||||
attributes.add(attribute + blockData.getMode().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Comparator blockData) {
|
||||
for (Comparator.Mode mode : Comparator.Mode.values()) {
|
||||
if (attributes.contains(attribute + mode.name())) {
|
||||
blockData.setMode(mode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.DaylightDetector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class DaylightDetectorAttribute implements BlockAttribute<DaylightDetector> {
|
||||
|
||||
private String attribute = "§8-§7 inverted";
|
||||
|
||||
@Override
|
||||
public Class<DaylightDetector> type() {
|
||||
return DaylightDetector.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, DaylightDetector blockData) {
|
||||
if (blockData.isInverted()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, DaylightDetector blockData) {
|
||||
blockData.setInverted(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Door;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class DoorAttribute implements BlockAttribute<Door> {
|
||||
|
||||
private String attribute = "§8-§7 hinge ";
|
||||
|
||||
@Override
|
||||
public Class<Door> type() {
|
||||
return Door.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Door blockData) {
|
||||
attributes.add(attribute + blockData.getHinge().toString().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Door blockData) {
|
||||
for (Door.Hinge hinge : Door.Hinge.values()) {
|
||||
if (attributes.contains(attribute + hinge.toString().toLowerCase())) {
|
||||
blockData.setHinge(hinge);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.EndPortalFrame;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class EndPortalFrameAttribute implements BlockAttribute<EndPortalFrame> {
|
||||
|
||||
private String attribute = "§8-§7 eye";
|
||||
|
||||
@Override
|
||||
public Class<EndPortalFrame> type() {
|
||||
return EndPortalFrame.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, EndPortalFrame blockData) {
|
||||
if (blockData.hasEye()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, EndPortalFrame blockData) {
|
||||
blockData.setEye(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Farmland;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class FarmlandAttribute implements BlockAttribute<Farmland> {
|
||||
|
||||
private String attribute = "§8-§7 moisture ";
|
||||
|
||||
@Override
|
||||
public Class<Farmland> type() {
|
||||
return Farmland.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Farmland blockData) {
|
||||
attributes.add(attribute + blockData.getMoisture());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Farmland blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setMoisture);
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Gate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class GateAttribute implements BlockAttribute<Gate> {
|
||||
|
||||
private String attribute = "§8-§7 inWall";
|
||||
|
||||
@Override
|
||||
public Class<Gate> type() {
|
||||
return Gate.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Gate blockData) {
|
||||
if (blockData.isInWall()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Gate blockData) {
|
||||
blockData.setInWall(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Hopper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class HopperAttribute implements BlockAttribute<Hopper> {
|
||||
|
||||
private String attribute = "§8-§7 enabled";
|
||||
|
||||
@Override
|
||||
public Class<Hopper> type() {
|
||||
return Hopper.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Hopper blockData) {
|
||||
if (blockData.isEnabled()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Hopper blockData) {
|
||||
blockData.setEnabled(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Jigsaw;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class JigsawAttribute implements BlockAttribute<Jigsaw> {
|
||||
|
||||
private String attribute = "§8-§7 orientation ";
|
||||
|
||||
@Override
|
||||
public Class<Jigsaw> type() {
|
||||
return Jigsaw.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Jigsaw blockData) {
|
||||
attributes.add(attribute + blockData.getOrientation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Jigsaw blockData) {
|
||||
for (Jigsaw.Orientation orientation : Jigsaw.Orientation.values()) {
|
||||
if (attributes.contains(attribute + orientation)) {
|
||||
blockData.setOrientation(orientation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Lantern;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class LanternAttribute implements BlockAttribute<Lantern> {
|
||||
|
||||
private String attribute = "§8-§7 lantern";
|
||||
|
||||
@Override
|
||||
public Class<Lantern> type() {
|
||||
return Lantern.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Lantern lantern) {
|
||||
if (!lantern.isHanging()) return;
|
||||
attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Lantern lantern) {
|
||||
lantern.setHanging(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Leaves;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class LeavesAttribute implements BlockAttribute<Leaves> {
|
||||
|
||||
private String attribute = "§8-§7 persistent";
|
||||
|
||||
@Override
|
||||
public Class<Leaves> type() {
|
||||
return Leaves.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Leaves blockData) {
|
||||
if (blockData.isPersistent()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Leaves blockData) {
|
||||
blockData.setPersistent(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,62 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.PointedDripstone;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class PointedDripstoneAttribute implements BlockAttribute<PointedDripstone> {
|
||||
|
||||
private String attribute1 = "§8-§7 vertialDirection ";
|
||||
private String attribute2 = "§8-§7 thickness ";
|
||||
|
||||
@Override
|
||||
public Class<PointedDripstone> type() {
|
||||
return PointedDripstone.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, PointedDripstone blockData) {
|
||||
attributes.add(attribute1 + " " + blockData.getVerticalDirection().name().toLowerCase());
|
||||
attributes.add(attribute2 + " " + blockData.getThickness().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, PointedDripstone blockData) {
|
||||
for (BlockFace blockFace : blockData.getVerticalDirections()) {
|
||||
if (attributes.contains(attribute1 + " " + blockFace.name().toLowerCase())) {
|
||||
blockData.setVerticalDirection(blockFace);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (PointedDripstone.Thickness thickness : PointedDripstone.Thickness.values()) {
|
||||
if (attributes.contains(attribute2 + " " + thickness.name().toLowerCase())) {
|
||||
blockData.setThickness(thickness);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.RedstoneWire;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class RedstoneWireAttribute implements BlockAttribute<RedstoneWire> {
|
||||
|
||||
private String attribute = "§8-§7 connection ";
|
||||
|
||||
@Override
|
||||
public Class<RedstoneWire> type() {
|
||||
return RedstoneWire.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, RedstoneWire blockData) {
|
||||
for (BlockFace blockFace : blockData.getAllowedFaces()) {
|
||||
attributes.add(attribute + blockFace.name().toLowerCase() + " " + blockData.getFace(blockFace).name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, RedstoneWire blockData) {
|
||||
for (BlockFace blockFace : blockData.getAllowedFaces()) {
|
||||
for (RedstoneWire.Connection connection : RedstoneWire.Connection.values()) {
|
||||
if (attributes.contains(attribute + blockFace.name().toLowerCase() + " " + connection.name().toLowerCase())) {
|
||||
blockData.setFace(blockFace, connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,56 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Repeater;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class RepeaterAttribute implements BlockAttribute<Repeater> {
|
||||
|
||||
private String attribute1 = "§8-§7 delay ";
|
||||
private String attribute2 = "§8-§7 locked";
|
||||
|
||||
@Override
|
||||
public Class<Repeater> type() {
|
||||
return Repeater.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Repeater blockData) {
|
||||
attributes.add(attribute1 + blockData.getDelay());
|
||||
if (blockData.isLocked()) attributes.add(attribute2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Repeater blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute1))
|
||||
.map(s -> s.replace(attribute1, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setDelay);
|
||||
blockData.setLocked(attributes.contains(attribute2));
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.RespawnAnchor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class RespawnAnchorAttribute implements BlockAttribute<RespawnAnchor> {
|
||||
|
||||
private String attribute = "§8-§7 charges ";
|
||||
|
||||
@Override
|
||||
public Class<RespawnAnchor> type() {
|
||||
return RespawnAnchor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, RespawnAnchor blockData) {
|
||||
attributes.add(attribute + blockData.getCharges());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, RespawnAnchor blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setCharges);
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Sapling;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class SaplingAttribute implements BlockAttribute<Sapling> {
|
||||
|
||||
private String attribute = "§8-§7 stage ";
|
||||
|
||||
@Override
|
||||
public Class<Sapling> type() {
|
||||
return Sapling.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Sapling blockData) {
|
||||
attributes.add(attribute + blockData.getStage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Sapling blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setStage);
|
||||
}
|
||||
}
|
@ -1,56 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Scaffolding;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class ScaffoldingAttribute implements BlockAttribute<Scaffolding> {
|
||||
|
||||
private String attribute1 = "§8-§7 bottom";
|
||||
private String attribute2 = "§8-§7 distance ";
|
||||
|
||||
@Override
|
||||
public Class<Scaffolding> type() {
|
||||
return Scaffolding.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Scaffolding blockData) {
|
||||
if (blockData.isBottom()) attributes.add(attribute1);
|
||||
attributes.add(attribute2 + blockData.getDistance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Scaffolding blockData) {
|
||||
blockData.setBottom(attributes.contains(attribute1));
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute2))
|
||||
.map(s -> s.replace(attribute2, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setDistance);
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.SculkSensor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class SculkSensorAttribute implements BlockAttribute<SculkSensor> {
|
||||
|
||||
private String attribute = "§8-§7 phase ";
|
||||
|
||||
@Override
|
||||
public Class<SculkSensor> type() {
|
||||
return SculkSensor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, SculkSensor blockData) {
|
||||
attributes.add(attribute + blockData.getPhase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, SculkSensor blockData) {
|
||||
for (SculkSensor.Phase phase : SculkSensor.Phase.values()) {
|
||||
if (attributes.contains(attribute + phase)) {
|
||||
blockData.setPhase(phase);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.SeaPickle;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class SeaPickleAttribute implements BlockAttribute<SeaPickle> {
|
||||
|
||||
private String attribute = "§8-§7 pickles ";
|
||||
|
||||
@Override
|
||||
public Class<SeaPickle> type() {
|
||||
return SeaPickle.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, SeaPickle blockData) {
|
||||
attributes.add(attribute + blockData.getPickles());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, SeaPickle blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setPickles);
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Slab;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class SlabAttribute implements BlockAttribute<Slab> {
|
||||
|
||||
private String attribute = "§8-§7 type ";
|
||||
|
||||
@Override
|
||||
public Class<Slab> type() {
|
||||
return Slab.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Slab blockData) {
|
||||
attributes.add(attribute + blockData.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Slab blockData) {
|
||||
for (Slab.Type type : Slab.Type.values()) {
|
||||
if (attributes.contains(attribute + type)) {
|
||||
blockData.setType(type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Snow;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class SnowAttribute implements BlockAttribute<Snow> {
|
||||
|
||||
private String attribute = "§8-§7 layers ";
|
||||
|
||||
@Override
|
||||
public Class<Snow> type() {
|
||||
return Snow.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Snow blockData) {
|
||||
attributes.add(attribute + blockData.getLayers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Snow blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute))
|
||||
.map(s -> s.replace(attribute, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setLayers);
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Stairs;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class StairsAttribute implements BlockAttribute<Stairs> {
|
||||
|
||||
private String attribute = "§8-§7 shape ";
|
||||
|
||||
@Override
|
||||
public Class<Stairs> type() {
|
||||
return Stairs.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Stairs blockData) {
|
||||
attributes.add(attribute + blockData.getShape().name().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Stairs blockData) {
|
||||
for (Stairs.Shape shape : Stairs.Shape.values()) {
|
||||
if (attributes.contains(attribute + shape.name().toLowerCase())) {
|
||||
blockData.setShape(shape);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.StructureBlock;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class StructureBlockAttribute implements BlockAttribute<StructureBlock> {
|
||||
|
||||
private String attribute = "§8-§7 mode ";
|
||||
|
||||
@Override
|
||||
public Class<StructureBlock> type() {
|
||||
return StructureBlock.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, StructureBlock blockData) {
|
||||
attributes.add(attribute + blockData.getMode().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, StructureBlock blockData) {
|
||||
for (StructureBlock.Mode mode : StructureBlock.Mode.values()) {
|
||||
if (attributes.contains(attribute + mode.name())) {
|
||||
blockData.setMode(mode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.TNT;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class TNTAttribute implements BlockAttribute<TNT> {
|
||||
|
||||
private String attribute = "§8-§7 unstable";
|
||||
|
||||
@Override
|
||||
public Class<TNT> type() {
|
||||
return TNT.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, TNT blockData) {
|
||||
if (blockData.isUnstable()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, TNT blockData) {
|
||||
blockData.setUnstable(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,48 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.Tripwire;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class TripwireAttribute implements BlockAttribute<Tripwire> {
|
||||
|
||||
private String attribute = "§8-§7 disarmed";
|
||||
|
||||
@Override
|
||||
public Class<Tripwire> type() {
|
||||
return Tripwire.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Tripwire blockData) {
|
||||
if (blockData.isDisarmed()) attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Tripwire blockData) {
|
||||
blockData.setDisarmed(attributes.contains(attribute));
|
||||
}
|
||||
}
|
@ -1,61 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.data.type.TurtleEgg;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class TurtleEggAttribute implements BlockAttribute<TurtleEgg> {
|
||||
|
||||
private String attribute1 = "§8-§7 eggs ";
|
||||
private String attribute2 = "§8-§7 hatch ";
|
||||
|
||||
@Override
|
||||
public Class<TurtleEgg> type() {
|
||||
return TurtleEgg.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, TurtleEgg blockData) {
|
||||
attributes.add(attribute1 + blockData.getEggs());
|
||||
attributes.add(attribute2 + blockData.getHatch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, TurtleEgg blockData) {
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute1))
|
||||
.map(s -> s.replace(attribute1, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setEggs);
|
||||
attributes.stream()
|
||||
.filter(s -> s.startsWith(attribute2))
|
||||
.map(s -> s.replace(attribute2, ""))
|
||||
.map(Integer::parseInt)
|
||||
.findFirst()
|
||||
.ifPresent(blockData::setHatch);
|
||||
}
|
||||
}
|
@ -1,64 +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.attributescopy.impl.type;
|
||||
|
||||
import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.type.Wall;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class WallAttribute implements BlockAttribute<Wall> {
|
||||
|
||||
private BlockFace[] faces = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
|
||||
|
||||
private String attribute1 = "§8-§7 up";
|
||||
private String attribute2 = "§8-§7 connected ";
|
||||
|
||||
@Override
|
||||
public Class<Wall> type() {
|
||||
return Wall.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(List<String> attributes, Wall blockData) {
|
||||
if (blockData.isUp()) attributes.add(attribute1);
|
||||
for (BlockFace face : faces) {
|
||||
if (blockData.getHeight(face) == Wall.Height.NONE) continue;
|
||||
attributes.add(attribute2 + face.name().toLowerCase() + " " + blockData.getHeight(face).name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Set<String> attributes, Wall blockData) {
|
||||
blockData.setUp(attributes.contains(attribute1));
|
||||
for (BlockFace face : faces) {
|
||||
for (Wall.Height height : Wall.Height.values()) {
|
||||
if (attributes.contains(attribute2 + face.name().toLowerCase() + " " + height.name().toLowerCase())) {
|
||||
blockData.setHeight(face, height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,35 +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.detonator;
|
||||
|
||||
import de.steamwar.bausystem.shared.AbstractEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface AbstractDetonatorEntity extends AbstractEntity {
|
||||
|
||||
void display(Player player);
|
||||
|
||||
boolean hide(Player player, boolean always);
|
||||
|
||||
int getId();
|
||||
|
||||
Entity getBukkitEntity();
|
||||
}
|
@ -25,7 +25,8 @@ import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.features.autostart.AutostartListener;
|
||||
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
||||
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
||||
import de.steamwar.bausystem.utils.NMSWrapper;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -44,7 +45,7 @@ import java.util.*;
|
||||
@UtilityClass
|
||||
public class Detonator {
|
||||
|
||||
private static final Map<Player, List<AbstractDetonatorEntity>> ENTITIES_MAP = new HashMap<>();
|
||||
private static final Map<Player, REntityServer> ENTITIES_MAP = new HashMap<>();
|
||||
private static final Vector HALF = new Vector(0.5, 0, 0.5);
|
||||
|
||||
public static boolean isDetonator(ItemStack itemStack) {
|
||||
@ -52,18 +53,24 @@ public class Detonator {
|
||||
}
|
||||
|
||||
public static void showDetonator(Player p, List<Location> locs) {
|
||||
List<AbstractDetonatorEntity> entities = new LinkedList<>();
|
||||
locs.stream().map(Location::toVector).forEach(vector -> entities.add(NMSWrapper.impl.constructDetonator(p.getWorld(), vector.add(HALF))));
|
||||
entities.forEach(abstractDetonatorEntity -> abstractDetonatorEntity.display(p));
|
||||
ENTITIES_MAP.putIfAbsent(p, entities);
|
||||
if (ENTITIES_MAP.containsKey(p)) return;
|
||||
REntityServer entities = new REntityServer();
|
||||
entities.setCallback((player, rEntity, entityAction) -> {
|
||||
Vector vector = new Vector(rEntity.getX(), rEntity.getY(), rEntity.getZ());
|
||||
DetonatorListener.addLocationToDetonator(vector.toLocation(player.getWorld()).getBlock().getLocation(), player);
|
||||
DetonatorListener.HAS_UPDATED.add(player);
|
||||
});
|
||||
entities.addPlayer(p);
|
||||
ENTITIES_MAP.put(p, entities);
|
||||
|
||||
locs.forEach(location -> {
|
||||
RFallingBlockEntity entity = new RFallingBlockEntity(entities, location.clone().add(HALF), Material.RED_STAINED_GLASS);
|
||||
entity.setNoGravity(true);
|
||||
});
|
||||
}
|
||||
|
||||
public static void hideDetonator(Player p) {
|
||||
ENTITIES_MAP.remove(p).forEach(abstractDetonatorEntity -> abstractDetonatorEntity.hide(p, true));
|
||||
}
|
||||
|
||||
public static List<AbstractDetonatorEntity> getDetoEntities(Player p) {
|
||||
return ENTITIES_MAP.getOrDefault(p, new ArrayList<>());
|
||||
ENTITIES_MAP.remove(p).close();
|
||||
}
|
||||
|
||||
public static boolean hasActiveDetonatorShow(Player p) {
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package de.steamwar.bausystem.features.detonator;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
||||
@ -38,39 +36,14 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Linked
|
||||
public class DetonatorListener implements Listener {
|
||||
|
||||
public static final Class<?> useEntity = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity");
|
||||
private static final Reflection.FieldAccessor<Integer> entityIdFieldAccessor = Reflection.getField(useEntity, int.class, 0);
|
||||
static final Set<Player> HAS_UPDATED = new HashSet<>();
|
||||
|
||||
private static final Set<Player> HAS_UPDATED = new HashSet<>();
|
||||
|
||||
public DetonatorListener() {
|
||||
TinyProtocol.instance.addFilter(useEntity, (player, o) -> {
|
||||
List<AbstractDetonatorEntity> entities = Detonator.getDetoEntities(player);
|
||||
if (entities.isEmpty()) {
|
||||
return o;
|
||||
}
|
||||
|
||||
int entityId = entityIdFieldAccessor.get(o);
|
||||
AbstractDetonatorEntity entity = entities.stream().filter(abstractDetonatorEntity -> abstractDetonatorEntity.getId() == entityId).findFirst().orElse(null);
|
||||
|
||||
if (entity == null) {
|
||||
return o;
|
||||
}
|
||||
|
||||
Location location = entity.getBukkitEntity().getLocation().getBlock().getLocation();
|
||||
addLocationToDetonator(location, player);
|
||||
HAS_UPDATED.add(player);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private static void addLocationToDetonator(Location location, Player p) {
|
||||
static void addLocationToDetonator(Location location, Player p) {
|
||||
Detoblock detoblock = Detonator.getBlock(location.getBlock());
|
||||
if (detoblock == Detoblock.INVALID) {
|
||||
SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("DETONATOR_INVALID_BLOCK", p));
|
||||
|
@ -33,7 +33,10 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class KillcheckerVisualizer {
|
||||
|
||||
@ -207,7 +210,7 @@ public class KillcheckerVisualizer {
|
||||
public boolean hide(Player player) {
|
||||
rEntityServer.removePlayer(player);
|
||||
players.remove(player);
|
||||
if (player.isEmpty()) {
|
||||
if (players.isEmpty()) {
|
||||
rEntityServer.close();
|
||||
return true;
|
||||
}
|
||||
|
@ -1,38 +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;
|
||||
|
||||
import de.steamwar.bausystem.shared.AbstractEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public interface AbstractSimulatorEntity extends AbstractEntity {
|
||||
|
||||
void display(Player player);
|
||||
|
||||
void setPosition(Vector position);
|
||||
|
||||
boolean hide(Player player, boolean always);
|
||||
|
||||
int getId();
|
||||
|
||||
Entity getBukkitEntity();
|
||||
}
|
@ -20,13 +20,17 @@
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode;
|
||||
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -36,13 +40,14 @@ import java.util.Map;
|
||||
@UtilityClass
|
||||
public class SimulatorCursor {
|
||||
|
||||
private Map<Player, AbstractSimulatorEntity> cursors = new HashMap<>();
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
private Map<Player, REntityServer> rEntityServerMap = new HashMap<>();
|
||||
|
||||
public void show(Player player, TNTSimulator tntSimulator, RayTraceResult result) {
|
||||
AbstractSimulatorEntity cursor = cursors.get(player);
|
||||
public void show(Player player, TNTSimulator tntSimulator, RayTraceUtils.RRayTraceResult result) {
|
||||
REntityServer cursor = rEntityServerMap.get(player);
|
||||
|
||||
if (cursor != null)
|
||||
cursor.hide(player, false);
|
||||
cursor.close();
|
||||
|
||||
tntSimulator.show(player);
|
||||
|
||||
@ -51,11 +56,13 @@ public class SimulatorCursor {
|
||||
|
||||
if (result.getHitEntity() != null) {
|
||||
List<SimulatorElement> elements = tntSimulator.getEntity(result.getHitEntity());
|
||||
tntSimulator.hide(player, elements);
|
||||
|
||||
cursor = SimulatorEntityShowMode.createEntity(elements.isEmpty() ? getPos(player, result) : elements.get(0).getPosition(), true);
|
||||
cursor.display(player);
|
||||
cursors.put(player, cursor);
|
||||
cursor = new REntityServer();
|
||||
RFallingBlockEntity entity = new RFallingBlockEntity(cursor, (elements.isEmpty() ? getPos(player, result) : elements.get(0).getPosition()).toLocation(WORLD), Material.TNT);
|
||||
entity.setNoGravity(true);
|
||||
entity.setGlowing(true);
|
||||
cursor.addPlayer(player);
|
||||
rEntityServerMap.put(player, cursor);
|
||||
BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_EDIT", player, ChatMessageType.ACTION_BAR);
|
||||
return;
|
||||
}
|
||||
@ -64,25 +71,27 @@ public class SimulatorCursor {
|
||||
return;
|
||||
}
|
||||
|
||||
cursor = SimulatorEntityShowMode.createEntity(getPos(player, result), false);
|
||||
cursor.display(player);
|
||||
cursors.put(player, cursor);
|
||||
cursor = new REntityServer();
|
||||
RFallingBlockEntity entity = new RFallingBlockEntity(cursor, getPos(player, result).toLocation(WORLD), Material.TNT);
|
||||
entity.setNoGravity(true);
|
||||
cursor.addPlayer(player);
|
||||
rEntityServerMap.put(player, cursor);
|
||||
BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_ADD", player, ChatMessageType.ACTION_BAR);
|
||||
}
|
||||
|
||||
public void hide(Player player, TNTSimulator tntSimulator) {
|
||||
AbstractSimulatorEntity cursor = cursors.get(player);
|
||||
REntityServer cursor = rEntityServerMap.get(player);
|
||||
|
||||
if (cursor != null)
|
||||
cursor.hide(player, false);
|
||||
cursor.close();
|
||||
|
||||
if (tntSimulator != null) {
|
||||
tntSimulator.remove(player);
|
||||
tntSimulator.hide(player);
|
||||
}
|
||||
cursors.remove(player);
|
||||
rEntityServerMap.remove(player);
|
||||
}
|
||||
|
||||
public static Vector getPos(Player player, RayTraceResult result) {
|
||||
public static Vector getPos(Player player, RayTraceUtils.RRayTraceResult result) {
|
||||
Vector pos = result.getHitPosition();
|
||||
|
||||
BlockFace face = result.getHitBlockFace();
|
||||
|
@ -1,44 +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;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
||||
import de.steamwar.core.VersionDependent;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
public interface SimulatorPreview {
|
||||
SimulatorPreview impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
class SimulatorPreviewTNTData {
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private int fuseTicks;
|
||||
private boolean xVelocity;
|
||||
private boolean yVelocity;
|
||||
private boolean zVelocity;
|
||||
}
|
||||
|
||||
Record simulate(TNTSimulator tntSimulator);
|
||||
}
|
@ -1,92 +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;
|
||||
|
||||
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.shared.Pair;
|
||||
import de.steamwar.bausystem.shared.ShowMode;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@UtilityClass
|
||||
public class SimulatorPreviewStorage {
|
||||
private Map<TNTSimulator, Pair<Record, Set<Player>>> previews = new HashMap<>();
|
||||
private Map<Player, Pair<TNTSimulator, ShowMode<TNTPosition>>> showModes = new HashMap<>();
|
||||
|
||||
public void show(Player player, TNTSimulator tntSimulator) {
|
||||
if (showModes.containsKey(player)) {
|
||||
Pair<TNTSimulator, ShowMode<TNTPosition>> pair = showModes.get(player);
|
||||
if (pair.getKey() != tntSimulator) {
|
||||
pair.getValue().hide();
|
||||
Pair<Record, Set<Player>> setPair = previews.get(pair.getKey());
|
||||
setPair.getValue().remove(player);
|
||||
if (setPair.getValue().isEmpty()) {
|
||||
previews.remove(pair.getKey());
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Pair<Record, Set<Player>> pair = previews.computeIfAbsent(tntSimulator, k -> new Pair<>(SimulatorPreview.impl.simulate(k), new HashSet<>()));
|
||||
pair.getValue().add(player);
|
||||
|
||||
ShowModeParameter showModeParameter = new ShowModeParameter();
|
||||
PreviewEntityShowMode showMode = new PreviewEntityShowMode(player, showModeParameter);
|
||||
pair.getKey().showAll(showMode);
|
||||
showModes.put(player, new Pair<>(tntSimulator, showMode));
|
||||
}
|
||||
|
||||
public void hide(Player player) {
|
||||
if (showModes.containsKey(player)) {
|
||||
Pair<TNTSimulator, ShowMode<TNTPosition>> pair = showModes.get(player);
|
||||
pair.getValue().hide();
|
||||
Pair<Record, Set<Player>> setPair = previews.get(pair.getKey());
|
||||
setPair.getValue().remove(player);
|
||||
if (setPair.getValue().isEmpty()) {
|
||||
previews.remove(pair.getKey());
|
||||
}
|
||||
showModes.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void recalculate(TNTSimulator tntSimulator) {
|
||||
Pair<Record, Set<Player>> pair = previews.get(tntSimulator);
|
||||
if (pair == null) return;
|
||||
pair.setKey(SimulatorPreview.impl.simulate(tntSimulator));
|
||||
pair.getValue().forEach(player -> {
|
||||
Pair<TNTSimulator, ShowMode<TNTPosition>> setPair = showModes.get(player);
|
||||
setPair.getValue().hide();
|
||||
pair.getKey().showAll(setPair.getValue());
|
||||
});
|
||||
}
|
||||
|
||||
public void recalculateAll() {
|
||||
previews.keySet().forEach(SimulatorPreviewStorage::recalculate);
|
||||
}
|
||||
}
|
@ -105,10 +105,7 @@ public class SimulatorStorage implements Enable, Disable {
|
||||
public static void delete(String name) {
|
||||
TNTSimulator tntSimulator = tntSimulators.remove(name);
|
||||
if (tntSimulator != null) {
|
||||
new HashMap<>(tntSimulator.getPlayerShowMode()).forEach((player, simulatorEntityShowMode) -> {
|
||||
SimulatorCursor.hide(player, tntSimulator);
|
||||
});
|
||||
tntSimulator.hide();
|
||||
tntSimulator.close();
|
||||
}
|
||||
new File(simulatorsDir, name + ".simulator").delete();
|
||||
}
|
||||
@ -181,7 +178,7 @@ public class SimulatorStorage implements Enable, Disable {
|
||||
if (content.isEmpty()) continue;
|
||||
TNTSimulator tntSimulator = new TNTSimulator();
|
||||
for (YAPIONObject element : content.streamObject().collect(Collectors.toList())) {
|
||||
tntSimulator.getTntElementList().add(new TNTElement(element));
|
||||
tntSimulator.getTntElementList().add(new TNTElement(element, tntSimulator.getEntityServer()));
|
||||
}
|
||||
tntSimulators.put(newName, tntSimulator);
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.features.simulator.gui.TNTElementGUI;
|
||||
import de.steamwar.bausystem.features.simulator.gui.TNTSimulatorGui;
|
||||
import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode;
|
||||
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.tnt.TNTGroup;
|
||||
@ -31,12 +30,13 @@ import de.steamwar.bausystem.features.tracer.record.Recorder;
|
||||
import de.steamwar.bausystem.features.tracer.record.SingleTraceRecorder;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import yapion.hierarchy.types.YAPIONArray;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
import yapion.hierarchy.types.YAPIONType;
|
||||
@ -49,7 +49,8 @@ import java.util.stream.Collectors;
|
||||
@Getter
|
||||
public class TNTSimulator {
|
||||
|
||||
private Map<Player, SimulatorEntityShowMode> playerShowMode = new HashMap<>();
|
||||
private Set<Player> players = new HashSet<>();
|
||||
private REntityServer entityServer = new REntityServer();
|
||||
|
||||
private Material material = Material.TNT;
|
||||
|
||||
@ -64,9 +65,9 @@ public class TNTSimulator {
|
||||
YAPIONArray yapionArray = yapionObject.getArrayOrDefault("tntElements", new YAPIONArray());
|
||||
for (YAPIONObject element : yapionArray.streamObject().collect(Collectors.toList())) {
|
||||
if (element.containsKey("elements", YAPIONType.ARRAY)) {
|
||||
tntElementList.add(new TNTGroup(element));
|
||||
tntElementList.add(new TNTGroup(element, entityServer));
|
||||
} else {
|
||||
tntElementList.add(new TNTElement(element));
|
||||
tntElementList.add(new TNTElement(element, entityServer));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,74 +83,25 @@ public class TNTSimulator {
|
||||
return yapionObject;
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
playerShowMode.forEach((player, simulatorEntityShowMode) -> {
|
||||
simulatorEntityShowMode.hide();
|
||||
});
|
||||
}
|
||||
|
||||
public void show() {
|
||||
playerShowMode.forEach((player, simulatorEntityShowMode) -> {
|
||||
for (SimulatorElement element : tntElementList) {
|
||||
element.show(simulatorEntityShowMode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void hide(Player player) {
|
||||
SimulatorEntityShowMode showMode = playerShowMode.get(player);
|
||||
if (showMode == null) {
|
||||
return;
|
||||
}
|
||||
tntElementList.forEach(simulatorElement -> {
|
||||
simulatorElement.hide(showMode);
|
||||
});
|
||||
}
|
||||
|
||||
public void remove(Player player) {
|
||||
SimulatorEntityShowMode showMode = playerShowMode.remove(player);
|
||||
if (showMode == null) {
|
||||
return;
|
||||
}
|
||||
tntElementList.forEach(simulatorElement -> {
|
||||
simulatorElement.hide(showMode);
|
||||
});
|
||||
}
|
||||
|
||||
public void hide(Player player, List<SimulatorElement> simulatorElements) {
|
||||
SimulatorEntityShowMode showMode = playerShowMode.get(player);
|
||||
if (showMode == null) {
|
||||
return;
|
||||
}
|
||||
simulatorElements.forEach(simulatorElement -> {
|
||||
simulatorElement.hide(showMode);
|
||||
});
|
||||
}
|
||||
|
||||
public void hide(SimulatorElement simulatorElement) {
|
||||
playerShowMode.forEach((player, simulatorEntityShowMode) -> {
|
||||
simulatorElement.hide(simulatorEntityShowMode);
|
||||
});
|
||||
public void close() {
|
||||
entityServer.close();
|
||||
}
|
||||
|
||||
public void show(Player player) {
|
||||
SimulatorEntityShowMode showMode = playerShowMode.computeIfAbsent(player, SimulatorEntityShowMode::new);
|
||||
tntElementList.forEach(simulatorElement -> {
|
||||
simulatorElement.show(showMode);
|
||||
});
|
||||
entityServer.addPlayer(player);
|
||||
players.add(player);
|
||||
}
|
||||
|
||||
public void show(SimulatorElement simulatorElement) {
|
||||
playerShowMode.forEach((player, simulatorEntityShowMode) -> {
|
||||
simulatorElement.show(simulatorEntityShowMode);
|
||||
});
|
||||
public void hide(Player player) {
|
||||
entityServer.removePlayer(player);
|
||||
players.remove(player);
|
||||
}
|
||||
|
||||
public List<Entity> getEntities() {
|
||||
public List<REntity> getEntities() {
|
||||
return tntElementList.stream().flatMap(element -> element.getEntities().stream()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SimulatorElement> getEntity(Entity entity) {
|
||||
public List<SimulatorElement> getEntity(REntity entity) {
|
||||
List<SimulatorElement> tntSpawns = new ArrayList<>();
|
||||
for (SimulatorElement spawn : tntElementList) {
|
||||
spawn.getEntity(tntSpawns, entity);
|
||||
@ -158,7 +110,6 @@ public class TNTSimulator {
|
||||
}
|
||||
|
||||
public void remove(SimulatorElement element) {
|
||||
hide(element);
|
||||
tntElementList.remove(element);
|
||||
Set<SimulatorElement> toRemove = new HashSet<>();
|
||||
for (SimulatorElement spawn : tntElementList) {
|
||||
@ -185,7 +136,7 @@ public class TNTSimulator {
|
||||
});
|
||||
}
|
||||
|
||||
public void edit(Player player, RayTraceResult result) {
|
||||
public void edit(Player player, RayTraceUtils.RRayTraceResult result) {
|
||||
if (result == null) {
|
||||
TNTSimulatorGui.open(player, this, null, this::getTntElementList, null);
|
||||
return;
|
||||
@ -209,12 +160,9 @@ public class TNTSimulator {
|
||||
return;
|
||||
}
|
||||
|
||||
TNTElement tntElement = new TNTElement(SimulatorCursor.getPos(player, result));
|
||||
TNTElement tntElement = new TNTElement(SimulatorCursor.getPos(player, result), entityServer);
|
||||
tntElementList.add(tntElement);
|
||||
TNTElementGUI.open(player, tntElement, null);
|
||||
playerShowMode.forEach((p, simulatorEntityShowMode) -> {
|
||||
show(p);
|
||||
});
|
||||
}
|
||||
|
||||
public void start(Player p) {
|
||||
@ -230,7 +178,7 @@ public class TNTSimulator {
|
||||
}
|
||||
|
||||
AtomicBoolean needsAutoTrace = new AtomicBoolean();
|
||||
playerShowMode.forEach((player, simulatorEntityShowMode) -> {
|
||||
players.forEach(player -> {
|
||||
boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false);
|
||||
if (simulatorAutoTrace) {
|
||||
needsAutoTrace.set(true);
|
||||
|
@ -25,13 +25,10 @@ import de.steamwar.bausystem.features.simulator.gui.SimulatorSelectionGUI;
|
||||
import de.steamwar.bausystem.utils.ItemUtils;
|
||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
@ -50,19 +47,14 @@ public class TNTSimulatorListener implements Listener {
|
||||
return true;
|
||||
}
|
||||
|
||||
static RayTraceResult trace(Player player, Location to, TNTSimulator simulator) {
|
||||
return RayTraceUtils.trace(player, to, simulator.getEntities());
|
||||
static RayTraceUtils.RRayTraceResult trace(Player player, Location to, TNTSimulator simulator) {
|
||||
return RayTraceUtils.traceREntity(player, to, simulator.getEntities());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) {
|
||||
simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getTo());
|
||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(e.getPlayer().getInventory().getItemInOffHand());
|
||||
if (tntSimulator == null) SimulatorPreviewStorage.hide(e.getPlayer());
|
||||
} else {
|
||||
TNTSimulator tntSimulator = simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInOffHand, e.getTo());
|
||||
if (tntSimulator != null) SimulatorPreviewStorage.show(e.getPlayer(), tntSimulator);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,11 +83,6 @@ public class TNTSimulatorListener implements Listener {
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) {
|
||||
simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getPlayer().getLocation());
|
||||
} else {
|
||||
TNTSimulator tntSimulator = simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInOffHand, e.getPlayer().getLocation());
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
if (tntSimulator != null) SimulatorPreviewStorage.show(e.getPlayer(), tntSimulator);
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,29 +90,8 @@ public class TNTSimulatorListener implements Listener {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
SimulatorCursor.hide(event.getPlayer(), null);
|
||||
SimulatorStorage.getSimulatorNames().forEach(s -> {
|
||||
SimulatorStorage.getSimulator(s).remove(event.getPlayer());
|
||||
SimulatorStorage.getSimulator(s).hide(event.getPlayer());
|
||||
});
|
||||
SimulatorPreviewStorage.hide(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
|
||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(event.getOffHandItem());
|
||||
if (tntSimulator == null) {
|
||||
SimulatorPreviewStorage.hide(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
SimulatorPreviewStorage.show(event.getPlayer(), tntSimulator);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), SimulatorPreviewStorage::recalculateAll, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), SimulatorPreviewStorage::recalculateAll, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -49,7 +49,7 @@ public class SimulatorSelectionGUI {
|
||||
SWListInv<TNTSimulator> inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("SIMULATOR_GUI_SELECT_SIM", player), false, swListEntryList, (clickType, tntSimulator) -> {
|
||||
TNTSimulator current = SimulatorStorage.getSimulator(hand);
|
||||
if (current != null) {
|
||||
current.remove(player);
|
||||
current.hide(player);
|
||||
}
|
||||
SimulatorStorage.setSimulator(player, hand, tntSimulator);
|
||||
player.getInventory().setItemInMainHand(hand);
|
||||
@ -64,7 +64,7 @@ public class SimulatorSelectionGUI {
|
||||
if (SimulatorCommand.createSimulator(player, s)) {
|
||||
TNTSimulator current = SimulatorStorage.getSimulator(hand);
|
||||
if (current != null) {
|
||||
current.remove(player);
|
||||
current.hide(player);
|
||||
}
|
||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(s);
|
||||
SimulatorStorage.setSimulator(player, hand, tntSimulator);
|
||||
|
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.simulator.OrderUtils;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorPreviewStorage;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
||||
import de.steamwar.bausystem.features.simulator.TNTSimulator;
|
||||
import de.steamwar.bausystem.features.simulator.gui.components.ChangeMaterial;
|
||||
@ -42,7 +41,6 @@ import org.bukkit.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static de.steamwar.bausystem.features.simulator.gui.ItemUtils.unique;
|
||||
|
||||
@ -66,7 +64,6 @@ public class TNTElementGUI {
|
||||
}
|
||||
|
||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||
AtomicBoolean recalculate = new AtomicBoolean(false);
|
||||
Runnable editObserver = () -> {
|
||||
List<String> locationLore = new ArrayList<>();
|
||||
locationLore.add("");
|
||||
@ -76,7 +73,6 @@ public class TNTElementGUI {
|
||||
inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_LOCATION", player), locationLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
editLocation(player, tntElement, () -> open(player, tntElement, back));
|
||||
recalculate.set(true);
|
||||
}));
|
||||
|
||||
List<String> propertiesLore = new ArrayList<>();
|
||||
@ -91,7 +87,6 @@ public class TNTElementGUI {
|
||||
inv.setItem(22, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_PROPERTIES", player), propertiesLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
editProperties(player, tntElement, () -> open(player, tntElement, back));
|
||||
recalculate.set(true);
|
||||
}));
|
||||
|
||||
List<String> otherLore = new ArrayList<>();
|
||||
@ -105,13 +100,11 @@ public class TNTElementGUI {
|
||||
inv.setItem(24, new SWItem(Material.ANVIL, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_OTHER", player), otherLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
editOther(player, tntElement, () -> open(player, tntElement, back));
|
||||
recalculate.set(true);
|
||||
}));
|
||||
|
||||
// Delete tnt
|
||||
inv.setItem(44, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_REMOVE_TNT", player), clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntSimulator.remove(tntElement);
|
||||
player.closeInventory();
|
||||
}));
|
||||
@ -120,9 +113,6 @@ public class TNTElementGUI {
|
||||
tntElement.register(editObserver, player::closeInventory);
|
||||
inv.addCloseRunnable(() -> {
|
||||
tntElement.unregister(editObserver);
|
||||
if (recalculate.get()) {
|
||||
SimulatorPreviewStorage.recalculate(tntSimulator);
|
||||
}
|
||||
});
|
||||
|
||||
inv.open();
|
||||
@ -134,61 +124,49 @@ public class TNTElementGUI {
|
||||
inv.setItem(36, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run()));
|
||||
}
|
||||
|
||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||
AtomicBoolean recalculate = new AtomicBoolean(false);
|
||||
Runnable editObserver = () -> {
|
||||
ChangePosition.show(inv, player, recalculate, tntSimulator, tntElement, tntElement::getOwnPosition, x -> x - tntElement.getParentPosition().getX(), y -> y - tntElement.getParentPosition().getY(), z -> z - tntElement.getParentPosition().getZ(), () -> editLocation(player, tntElement, back));
|
||||
ChangePosition.show(inv, player, tntElement, vectorUnaryOperator -> {
|
||||
if (tntElement.getParent() == null) {
|
||||
tntElement.setPosition(vectorUnaryOperator.apply(tntElement.getPosition()));
|
||||
} else {
|
||||
tntElement.setPosition(vectorUnaryOperator.apply(tntElement.getPosition()).subtract(tntElement.getParent().getPosition()));
|
||||
}
|
||||
}, () -> editLocation(player, tntElement, back));
|
||||
|
||||
// Alignment
|
||||
inv.setItem(23, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_Z", player), clickType -> { // Z negative
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntSimulator.hide(tntElement);
|
||||
Vector position = tntElement.getPosition();
|
||||
Vector position = tntElement.getOwnPosition();
|
||||
align(position, new Vector(0, 0, 0.49));
|
||||
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
|
||||
tntSimulator.show(tntElement);
|
||||
tntElement.setPosition(position);
|
||||
tntElement.change();
|
||||
}));
|
||||
inv.setItem(25, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_Z", player), clickType -> { // Z positive
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntSimulator.hide(tntElement);
|
||||
Vector position = tntElement.getPosition();
|
||||
Vector position = tntElement.getOwnPosition();
|
||||
align(position, new Vector(0, 0, 0.51));
|
||||
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
|
||||
tntSimulator.show(tntElement);
|
||||
tntElement.setPosition(position);
|
||||
tntElement.change();
|
||||
}));
|
||||
inv.setItem(15, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_X", player), clickType -> { // X positive
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntSimulator.hide(tntElement);
|
||||
Vector position = tntElement.getPosition();
|
||||
Vector position = tntElement.getOwnPosition();
|
||||
align(position, new Vector(0.51, 0, 0));
|
||||
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
|
||||
tntSimulator.show(tntElement);
|
||||
tntElement.setPosition(position);
|
||||
tntElement.change();
|
||||
}));
|
||||
inv.setItem(33, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_X", player), clickType -> { // X negative
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntSimulator.hide(tntElement);
|
||||
Vector position = tntElement.getPosition();
|
||||
Vector position = tntElement.getOwnPosition();
|
||||
align(position, new Vector(0.49, 0, 0));
|
||||
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
|
||||
tntSimulator.show(tntElement);
|
||||
tntElement.setPosition(position);
|
||||
tntElement.change();
|
||||
}));
|
||||
inv.setItem(24, new SWItem(Material.SUNFLOWER, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_CENTER", player), clickType -> { // CENTER
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntSimulator.hide(tntElement);
|
||||
Vector position = tntElement.getPosition();
|
||||
Vector position = tntElement.getOwnPosition();
|
||||
align(position, new Vector(0.5, 0, 0.5));
|
||||
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
|
||||
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
|
||||
tntSimulator.show(tntElement);
|
||||
tntElement.setPosition(position);
|
||||
tntElement.change();
|
||||
}));
|
||||
};
|
||||
@ -196,9 +174,6 @@ public class TNTElementGUI {
|
||||
tntElement.register(editObserver, player::closeInventory);
|
||||
inv.addCloseRunnable(() -> {
|
||||
tntElement.unregister(editObserver);
|
||||
if (recalculate.get()) {
|
||||
SimulatorPreviewStorage.recalculate(tntSimulator);
|
||||
}
|
||||
});
|
||||
|
||||
inv.open();
|
||||
@ -236,18 +211,15 @@ public class TNTElementGUI {
|
||||
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
|
||||
|
||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||
AtomicBoolean recalculate = new AtomicBoolean(false);
|
||||
Runnable editObserver = () -> {
|
||||
// Change Count of spawned TNT
|
||||
inv.setItem(10, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setCount(tntElement.getCount() + ((clickType.isShiftClick()) ? 5 : 1));
|
||||
tntElement.change();
|
||||
})));
|
||||
SWItem countItem = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT", player, tntElement.getCount()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT_ANVIL_GUI_NAME", player), tntElement.getCount(), c -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setCount(c);
|
||||
tntElement.change();
|
||||
editProperties(player, tntElement, back);
|
||||
@ -256,7 +228,6 @@ public class TNTElementGUI {
|
||||
inv.setItem(19, countItem);
|
||||
inv.setItem(28, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setCount(tntElement.getCount() - ((clickType.isShiftClick()) ? 5 : 1));
|
||||
tntElement.change();
|
||||
})));
|
||||
@ -264,13 +235,11 @@ public class TNTElementGUI {
|
||||
// Change TickOffset
|
||||
inv.setItem(11, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setTickOffset(tntElement.getOwnTickOffset() + (clickType.isShiftClick() ? 5 : 1));
|
||||
tntElement.change();
|
||||
})));
|
||||
SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntElement.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntElement.getTickOffset(), tick -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setTickOffset(tick - tntElement.getParentTickOffset());
|
||||
tntElement.change();
|
||||
editProperties(player, tntElement, back);
|
||||
@ -279,7 +248,6 @@ public class TNTElementGUI {
|
||||
inv.setItem(20, tickItem);
|
||||
inv.setItem(29, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setTickOffset(tntElement.getOwnTickOffset() - (clickType.isShiftClick() ? 5 : 1));
|
||||
tntElement.change();
|
||||
})));
|
||||
@ -287,13 +255,11 @@ public class TNTElementGUI {
|
||||
// Change FuseTicks
|
||||
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setFuseTicks(tntElement.getFuseTicks() + (clickType.isShiftClick() ? 5 : 1));
|
||||
tntElement.change();
|
||||
})));
|
||||
SWItem fuseTickItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE", player, tntElement.getFuseTicks()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE_ANVIL_GUI_NAME", player), tntElement.getFuseTicks(), tick -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setFuseTicks(tick);
|
||||
tntElement.change();
|
||||
editProperties(player, tntElement, back);
|
||||
@ -302,7 +268,6 @@ public class TNTElementGUI {
|
||||
inv.setItem(21, fuseTickItem);
|
||||
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setFuseTicks(tntElement.getFuseTicks() - (clickType.isShiftClick() ? 5 : 1));
|
||||
tntElement.change();
|
||||
})));
|
||||
@ -310,7 +275,6 @@ public class TNTElementGUI {
|
||||
// Velocity Settings
|
||||
inv.setItem(24, Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_NAME", player), clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
if (tntElement.isXVelocity() || tntElement.isYVelocity() || tntElement.isZVelocity()) {
|
||||
tntElement.setXVelocity(false);
|
||||
tntElement.setYVelocity(false);
|
||||
@ -324,19 +288,16 @@ public class TNTElementGUI {
|
||||
});
|
||||
inv.setItem(32, new SWItem(getWool(tntElement.isXVelocity()), getColor(tntElement.isXVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_X", player, active(player, tntElement.isXVelocity())), clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setXVelocity(!tntElement.isXVelocity());
|
||||
tntElement.change();
|
||||
}));
|
||||
inv.setItem(15, new SWItem(getWool(tntElement.isYVelocity()), getColor(tntElement.isYVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Y", player, active(player, tntElement.isYVelocity())), clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setYVelocity(!tntElement.isYVelocity());
|
||||
tntElement.change();
|
||||
}));
|
||||
inv.setItem(34, new SWItem(getWool(tntElement.isZVelocity()), getColor(tntElement.isZVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Z", player, active(player, tntElement.isZVelocity())), clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntElement.setZVelocity(!tntElement.isZVelocity());
|
||||
tntElement.change();
|
||||
}));
|
||||
@ -345,9 +306,6 @@ public class TNTElementGUI {
|
||||
tntElement.register(editObserver, player::closeInventory);
|
||||
inv.addCloseRunnable(() -> {
|
||||
tntElement.unregister(editObserver);
|
||||
if (recalculate.get()) {
|
||||
SimulatorPreviewStorage.recalculate(tntSimulator);
|
||||
}
|
||||
});
|
||||
|
||||
inv.open();
|
||||
@ -360,11 +318,9 @@ public class TNTElementGUI {
|
||||
}
|
||||
|
||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||
AtomicBoolean recalculate = new AtomicBoolean(false);
|
||||
Runnable editObserver = () -> {
|
||||
inv.setItem(19, new SWItem(tntElement.getOrder(), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ACTIVATED_NAME", player), OrderUtils.orderList(tntElement.getOrder(), player), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
if (clickType.isShiftClick()) {
|
||||
tntElement.setOrder(OrderUtils.previous(tntElement.getOrder()));
|
||||
} else {
|
||||
@ -374,12 +330,11 @@ public class TNTElementGUI {
|
||||
}));
|
||||
|
||||
ChangeMaterial.show(inv, player, 21, tntElement, Material.BARREL, () -> editOther(player, tntElement, back));
|
||||
Disabled.show(inv, player, recalculate, 22, tntSimulator, tntElement);
|
||||
Disabled.show(inv, player, 22, tntSimulator, tntElement);
|
||||
|
||||
if (!tntElement.hasParent()) {
|
||||
inv.setItem(24, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE", player), Arrays.asList(), false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
// Create TNTGroup
|
||||
tntSimulator.getTntElementList().remove(tntElement);
|
||||
Vector vector = tntElement.getOwnPosition().clone();
|
||||
@ -394,7 +349,7 @@ public class TNTElementGUI {
|
||||
tntSimulator.getTntElementList().add(tntGroup);
|
||||
|
||||
// Add new TNT
|
||||
TNTElement newElement = new TNTElement(new Vector(0, 0, 0));
|
||||
TNTElement newElement = new TNTElement(new Vector(0, 0, 0), tntSimulator.getEntityServer());
|
||||
newElement.setTickOffset(1);
|
||||
tntGroup.add(newElement);
|
||||
|
||||
@ -409,9 +364,8 @@ public class TNTElementGUI {
|
||||
|
||||
inv.setItem(25, new SWItem(Material.DISPENSER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_TNT", player), clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
Vector vector = tntElement.getOwnPosition().clone();
|
||||
TNTElement newElement = new TNTElement(vector);
|
||||
TNTElement newElement = new TNTElement(vector, tntSimulator.getEntityServer());
|
||||
if (tntElement.hasParent()) {
|
||||
newElement.setTickOffset(tntElement.getOwnTickOffset() + 1);
|
||||
tntElement.getParent().add(newElement);
|
||||
@ -427,7 +381,6 @@ public class TNTElementGUI {
|
||||
// Delete tnt
|
||||
inv.setItem(44, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_REMOVE_TNT", player), clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntSimulator.remove(tntElement);
|
||||
player.closeInventory();
|
||||
}));
|
||||
@ -436,9 +389,6 @@ public class TNTElementGUI {
|
||||
tntElement.register(editObserver, player::closeInventory);
|
||||
inv.addCloseRunnable(() -> {
|
||||
tntElement.unregister(editObserver);
|
||||
if (recalculate.get()) {
|
||||
SimulatorPreviewStorage.recalculate(tntSimulator);
|
||||
}
|
||||
});
|
||||
|
||||
inv.open();
|
||||
|
@ -20,7 +20,6 @@
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorPreviewStorage;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
||||
import de.steamwar.bausystem.features.simulator.TNTSimulator;
|
||||
import de.steamwar.bausystem.features.simulator.gui.components.ChangeMaterial;
|
||||
@ -41,7 +40,6 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import static de.steamwar.bausystem.features.simulator.gui.ItemUtils.unique;
|
||||
@ -80,51 +78,39 @@ public class TNTGroupEditGUI {
|
||||
// X Position
|
||||
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(simulatorElements, clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||
tntSimulator.show();
|
||||
tntSimulator.change();
|
||||
})));
|
||||
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, vector.getX()), lore, false, clickType -> {}));
|
||||
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(simulatorElements, (clickType.isShiftClick() ? X_VECTOR : FX_VECTOR).clone().multiply(-1));
|
||||
tntSimulator.show();
|
||||
tntSimulator.change();
|
||||
})));
|
||||
|
||||
// Y Position
|
||||
inv.setItem(13, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(simulatorElements, clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||
tntSimulator.show();
|
||||
tntSimulator.change();
|
||||
})));
|
||||
inv.setItem(22, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, vector.getY()), lore, false, clickType -> {}));
|
||||
inv.setItem(31, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(simulatorElements, (clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR).clone().multiply(-1));
|
||||
tntSimulator.show();
|
||||
tntSimulator.change();
|
||||
})));
|
||||
|
||||
// Z Position
|
||||
inv.setItem(14, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(simulatorElements, clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||
tntSimulator.show();
|
||||
tntSimulator.change();
|
||||
})));
|
||||
inv.setItem(23, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, vector.getZ()), lore, false, clickType -> {}));
|
||||
inv.setItem(32, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(simulatorElements, (clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR).clone().multiply(-1));
|
||||
tntSimulator.show();
|
||||
})));
|
||||
|
||||
inv.open();
|
||||
@ -134,10 +120,10 @@ public class TNTGroupEditGUI {
|
||||
for (SimulatorElement element : simulatorElements) {
|
||||
if (element instanceof TNTGroup) {
|
||||
TNTGroup group = (TNTGroup) element;
|
||||
group.getPosition().add(vector);
|
||||
group.setPosition(group.getPosition().add(vector));
|
||||
} else if (element instanceof TNTElement) {
|
||||
TNTElement tntElement = (TNTElement) element;
|
||||
tntElement.getOwnPosition().add(vector);
|
||||
tntElement.setPosition(tntElement.getOwnPosition().add(vector));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -161,22 +147,21 @@ public class TNTGroupEditGUI {
|
||||
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
|
||||
|
||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||
AtomicBoolean recalculate = new AtomicBoolean(false);
|
||||
Runnable editObserver = () -> {
|
||||
ChangePosition.show(inv, player, recalculate, tntSimulator, tntGroup, tntGroup::getPosition, UnaryOperator.identity(), UnaryOperator.identity(), UnaryOperator.identity(), () -> open(player, tntGroup, back));
|
||||
ChangePosition.show(inv, player, tntGroup, vectorUnaryOperator -> {
|
||||
tntGroup.setPosition(vectorUnaryOperator.apply(tntGroup.getPosition()));
|
||||
}, () -> open(player, tntGroup, back));
|
||||
ChangeMaterial.show(inv, player, 14, tntGroup, Material.BARREL, () -> open(player, tntGroup, back));
|
||||
Disabled.show(inv, player, recalculate, 32, tntSimulator, tntGroup);
|
||||
Disabled.show(inv, player, 32, tntSimulator, tntGroup);
|
||||
|
||||
// Change TickOffset
|
||||
inv.setItem(16, new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntGroup.setTickOffset(tntGroup.getTickOffset() + (clickType.isShiftClick() ? 5 : 1));
|
||||
tntGroup.change();
|
||||
}));
|
||||
SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntGroup.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntGroup.getTickOffset(), tick -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntGroup.setTickOffset(tick);
|
||||
tntGroup.change();
|
||||
open(player, tntGroup, back);
|
||||
@ -185,7 +170,6 @@ public class TNTGroupEditGUI {
|
||||
inv.setItem(25, tickItem);
|
||||
inv.setItem(34, new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
tntGroup.setTickOffset(tntGroup.getTickOffset() - (clickType.isShiftClick() ? 5 : 1));
|
||||
tntGroup.change();
|
||||
}));
|
||||
@ -194,7 +178,6 @@ public class TNTGroupEditGUI {
|
||||
tntGroup.register(editObserver, player::closeInventory);
|
||||
inv.addCloseRunnable(() -> {
|
||||
tntGroup.unregister(editObserver);
|
||||
SimulatorPreviewStorage.recalculate(tntSimulator);
|
||||
});
|
||||
|
||||
inv.open();
|
||||
|
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorPreviewStorage;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
||||
import de.steamwar.bausystem.features.simulator.TNTSimulator;
|
||||
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
||||
@ -76,19 +75,6 @@ public class TNTSimulatorGui {
|
||||
if (back != null) {
|
||||
inv.setItem(47, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run()));
|
||||
}
|
||||
if (currentTntSimulator != null) {
|
||||
if (totalTNTCount > 0) {
|
||||
inv.setItem(48, new SWItem(Material.MAGENTA_GLAZED_TERRACOTTA, BauSystem.MESSAGE.parse("SIMULATOR_GUI_MOVE_ALL", player), clickType -> {
|
||||
moveAll(player, currentTntSimulator, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back));
|
||||
}));
|
||||
}
|
||||
|
||||
boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false);
|
||||
inv.setItem(47, new SWItem(simulatorAutoTrace ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, BauSystem.MESSAGE.parse("SIMULATOR_GUI_AUTO_TRACE", player, simulatorAutoTrace), clickType -> {
|
||||
Config.getInstance().get(player).put("simulatorAutoTrace", !simulatorAutoTrace);
|
||||
open(player, currentTntSimulator, currentTntGroup, simulatorElements, back);
|
||||
}));
|
||||
}
|
||||
SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TOTAL_TNT", player, totalTNTCount), clickType -> {
|
||||
});
|
||||
swItem.getItemStack().setAmount(totalTNTCount);
|
||||
@ -117,7 +103,6 @@ public class TNTSimulatorGui {
|
||||
currentTntGroup.register(editObserver, player::closeInventory);
|
||||
inv.addCloseRunnable(() -> {
|
||||
currentTntGroup.unregister(editObserver);
|
||||
SimulatorPreviewStorage.recalculate(currentTntSimulator);
|
||||
});
|
||||
} else {
|
||||
if (!elements.isEmpty()) {
|
||||
@ -126,15 +111,24 @@ public class TNTSimulatorGui {
|
||||
TNTGroupEditGUI.open(player, tntSimulator, elements, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back));
|
||||
}));
|
||||
}
|
||||
inv.addCloseCallback(clickType -> {
|
||||
SimulatorPreviewStorage.recalculate(currentTntSimulator);
|
||||
});
|
||||
}
|
||||
if (currentTntSimulator != null) {
|
||||
if (totalTNTCount > 0) {
|
||||
inv.setItem(48, new SWItem(Material.MAGENTA_GLAZED_TERRACOTTA, BauSystem.MESSAGE.parse("SIMULATOR_GUI_MOVE_ALL", player), clickType -> {
|
||||
moveAll(player, currentTntSimulator, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back));
|
||||
}));
|
||||
}
|
||||
|
||||
boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false);
|
||||
inv.setItem(47, new SWItem(simulatorAutoTrace ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, BauSystem.MESSAGE.parse("SIMULATOR_GUI_AUTO_TRACE", player, simulatorAutoTrace), clickType -> {
|
||||
Config.getInstance().get(player).put("simulatorAutoTrace", !simulatorAutoTrace);
|
||||
open(player, currentTntSimulator, currentTntGroup, simulatorElements, back);
|
||||
}));
|
||||
}
|
||||
|
||||
if (currentTntSimulator != null || currentTntGroup != null) {
|
||||
inv.setItem(51, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_GUI_DELETE", player), clickType -> {
|
||||
if (currentTntSimulator != null) {
|
||||
currentTntSimulator.hide();
|
||||
currentTntSimulator.getTntElementList().forEach(SimulatorElement::close);
|
||||
currentTntSimulator.getTntElementList().clear();
|
||||
player.closeInventory();
|
||||
@ -169,51 +163,40 @@ public class TNTSimulatorGui {
|
||||
// X Position
|
||||
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(tntSimulator, clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||
tntSimulator.show();
|
||||
tntSimulator.change();
|
||||
})));
|
||||
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_X", player), lore, false, clickType -> {}));
|
||||
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(tntSimulator, (clickType.isShiftClick() ? X_VECTOR : FX_VECTOR).clone().multiply(-1));
|
||||
tntSimulator.show();
|
||||
tntSimulator.change();
|
||||
})));
|
||||
|
||||
// Y Position
|
||||
inv.setItem(13, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(tntSimulator, clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||
tntSimulator.show();
|
||||
tntSimulator.change();
|
||||
})));
|
||||
inv.setItem(22, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Y", player), lore, false, clickType -> {}));
|
||||
inv.setItem(31, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(tntSimulator, (clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR).clone().multiply(-1));
|
||||
tntSimulator.show();
|
||||
tntSimulator.change();
|
||||
})));
|
||||
|
||||
// Z Position
|
||||
inv.setItem(14, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(tntSimulator, clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||
tntSimulator.show();
|
||||
tntSimulator.change();
|
||||
})));
|
||||
inv.setItem(23, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Z", player), lore, false, clickType -> {}));
|
||||
inv.setItem(32, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
tntSimulator.hide();
|
||||
moveAll(tntSimulator, (clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR).clone().multiply(-1));
|
||||
tntSimulator.show();
|
||||
tntSimulator.change();
|
||||
})));
|
||||
|
||||
inv.open();
|
||||
@ -223,10 +206,10 @@ public class TNTSimulatorGui {
|
||||
for (SimulatorElement element : tntSimulator.getTntElementList()) {
|
||||
if (element instanceof TNTGroup) {
|
||||
TNTGroup group = (TNTGroup) element;
|
||||
group.getPosition().add(vector);
|
||||
group.setPosition(group.getPosition().add(vector));
|
||||
} else if (element instanceof TNTElement) {
|
||||
TNTElement tntElement = (TNTElement) element;
|
||||
tntElement.getOwnPosition().add(vector);
|
||||
tntElement.setPosition(tntElement.getOwnPosition().add(vector));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import org.bukkit.util.Vector;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@ -51,7 +52,7 @@ public class ChangePosition {
|
||||
private static final Vector FY_VECTOR = new Vector(0, 1, 0);
|
||||
private static final Vector FZ_VECTOR = new Vector(0, 0, 1);
|
||||
|
||||
public void show(SWInventory inv, Player player, AtomicBoolean recalculate, TNTSimulator tntSimulator, SimulatorElement simulatorElement, Supplier<Vector> toChangeVector, UnaryOperator<Double> calculatePositionX, UnaryOperator<Double> calculatePositionY, UnaryOperator<Double> calculatePositionZ, Runnable back) {
|
||||
public void show(SWInventory inv, Player player, SimulatorElement simulatorElement, Consumer<UnaryOperator<Vector>> toChangeVector, Runnable back) {
|
||||
String plusOneName = BauSystem.MESSAGE.parse("SIMULATOR_PLUS_ONE", player);
|
||||
String minusOneName = BauSystem.MESSAGE.parse("SIMULATOR_MINUS_ONE", player);
|
||||
List<String> plusOnePixelShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_PLUS_PIXEL_SHIFT", player));
|
||||
@ -61,84 +62,84 @@ public class ChangePosition {
|
||||
// X Position
|
||||
inv.setItem(10, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().add(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.add(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
inv.setItem(19, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, simulatorElement.getPosition().getX()), lore, false, clickType -> {
|
||||
changePosition(player, simulatorElement.getPosition().getX(), x -> {
|
||||
recalculate.set(true);
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().setX(clamp(calculatePositionX.apply(x)));
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.setX(clamp(x));
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
back.run();
|
||||
}, back);
|
||||
}));
|
||||
inv.setItem(28, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().subtract(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.subtract(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
|
||||
// Y Position
|
||||
inv.setItem(11, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().add(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.add(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, simulatorElement.getPosition().getY()), lore, false, clickType -> {
|
||||
changePosition(player, simulatorElement.getPosition().getY(), y -> {
|
||||
recalculate.set(true);
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().setY(clamp(calculatePositionY.apply(y)));
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.setY(clamp(y));
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
back.run();
|
||||
}, back);
|
||||
}));
|
||||
inv.setItem(29, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().subtract(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.subtract(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
|
||||
// Z Position
|
||||
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().add(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.add(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, simulatorElement.getPosition().getZ()), lore, false, clickType -> {
|
||||
changePosition(player, simulatorElement.getPosition().getZ(), z -> {
|
||||
recalculate.set(true);
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().setZ(clamp(calculatePositionZ.apply(z)));
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.setZ(clamp(z));
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
back.run();
|
||||
}, back);
|
||||
}));
|
||||
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||
recalculate.set(true);
|
||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||
toChangeVector.get().subtract(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||
toChangeVector.accept(vector -> {
|
||||
vector.subtract(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||
return vector;
|
||||
});
|
||||
simulatorElement.change();
|
||||
})));
|
||||
}
|
||||
|
@ -29,21 +29,13 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@UtilityClass
|
||||
public class Disabled {
|
||||
|
||||
public void show(SWInventory inv, Player player, AtomicBoolean recalculate, int position, TNTSimulator tntSimulator, SimulatorElement simulatorElement) {
|
||||
public void show(SWInventory inv, Player player, int position, TNTSimulator tntSimulator, SimulatorElement simulatorElement) {
|
||||
inv.setItem(position, new SWItem(simulatorElement.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, BauSystem.MESSAGE.parse(simulatorElement.isDisabled() ? "SIMULATOR_TNT_SPAWN_DISABLED" : "SIMULATOR_TNT_SPAWN_ENABLED", player), new ArrayList<>(), !simulatorElement.isDisabled(), clickType -> {
|
||||
recalculate.set(true);
|
||||
if (!simulatorElement.isDisabled()) {
|
||||
tntSimulator.hide(simulatorElement);
|
||||
}
|
||||
simulatorElement.setDisabled(!simulatorElement.isDisabled());
|
||||
if (!simulatorElement.isDisabled()) {
|
||||
tntSimulator.show(simulatorElement);
|
||||
}
|
||||
simulatorElement.change();
|
||||
}));
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
In neuem Issue referenzieren
Einen Benutzer sperren