diff --git a/BauSystem_15/src/de/steamwar/bausystem/entities/DetonatorEntity15.java b/BauSystem_15/src/de/steamwar/bausystem/entities/DetonatorEntity15.java deleted file mode 100644 index efbd29d8..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/entities/DetonatorEntity15.java +++ /dev/null @@ -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 . - */ - -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); - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/entities/SimulatorEntity15.java b/BauSystem_15/src/de/steamwar/bausystem/entities/SimulatorEntity15.java deleted file mode 100644 index 5f828a33..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/entities/SimulatorEntity15.java +++ /dev/null @@ -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 . -*/ - -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; - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/entities/TraceEntity15.java b/BauSystem_15/src/de/steamwar/bausystem/entities/TraceEntity15.java deleted file mode 100644 index 99873513..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/entities/TraceEntity15.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; -import de.steamwar.bausystem.shared.BaseEntity15; -import de.steamwar.bausystem.shared.ReferenceCounter; -import net.minecraft.server.v1_15_R1.ChatComponentText; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class TraceEntity15 extends BaseEntity15 implements AbstractTraceEntity { - - private boolean exploded = false; - private ReferenceCounter referenceCounter = new ReferenceCounter(); - - public TraceEntity15(World world, Vector position, boolean tnt) { - super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS); - - this.setNoGravity(true); - this.ticksLived = -12000; - } - - @Override - public void display(Player player, boolean exploded, int ticks) { - if (ticks != -1) { - this.setCustomNameVisible(true); - this.setCustomName(new ChatComponentText(ticks + "")); - } - if (!this.exploded && exploded) { - this.setCustomNameVisible(true); - this.setCustomName(new ChatComponentText("Bumm")); - this.exploded = true; - if (referenceCounter.increment() > 0) { - sendEntityDestroy(player); - } - } else if (referenceCounter.increment() > 0) { - return; - } - - sendEntity(player); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!force && referenceCounter.decrement() > 0) { - return false; - } - - sendEntityDestroy(player); - die(); - return true; - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/entities/WarpEntity15.java b/BauSystem_15/src/de/steamwar/bausystem/entities/WarpEntity15.java deleted file mode 100644 index 03929086..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/entities/WarpEntity15.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.warp.AbstractWarpEntity; -import de.steamwar.bausystem.shared.BaseArmorStand15; -import net.minecraft.server.v1_15_R1.ChatComponentText; -import net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata; -import net.minecraft.server.v1_15_R1.PacketPlayOutEntityTeleport; -import net.minecraft.server.v1_15_R1.PlayerConnection; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class WarpEntity15 extends BaseArmorStand15 implements AbstractWarpEntity { - - public WarpEntity15(World world, Vector position, String name) { - super(world, position); - setInvisible(true); - setSmall(true); - setName(name); - this.setNoGravity(true); - this.ticksLived = -12000; - } - - @Override - public void display(Player player) { - sendEntity(player); - } - - @Override - public void setName(String name) { - this.setCustomNameVisible(true); - this.setCustomName(new ChatComponentText(name)); - } - - @Override - public boolean hide(Player player) { - sendEntityDestroy(player); - die(); - return true; - } - - @Override - public void sendMetaData(Player player) { - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; - playerConnection.sendPacket(packetPlayOutEntityMetadata); - } - - @Override - public void teleport(Player player, Vector position) { - setPositionRaw(position.getX(), position.getY(), position.getZ()); - PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityTeleport); - } - - @Override - public Vector getPosition() { - return new Vector(locX(), locY(), locZ()); - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/shared/BaseArmorStand15.java b/BauSystem_15/src/de/steamwar/bausystem/shared/BaseArmorStand15.java deleted file mode 100644 index 2e604c77..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/shared/BaseArmorStand15.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.shared; - -import net.minecraft.server.v1_15_R1.*; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class BaseArmorStand15 extends EntityArmorStand implements AbstractEntity { - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - - protected Vector position; - - public BaseArmorStand15(World world, Vector position) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ()); - - this.position = position; - setNoGravity(true); - ticksLived = -12000; - } - - public void sendEntity(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.ARMOR_STAND, 0, ZERO); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; - playerConnection.sendPacket(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); - playerConnection.sendPacket(packetPlayOutEntityMetadata); - } - - public void sendEntityDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/shared/BaseEntity15.java b/BauSystem_15/src/de/steamwar/bausystem/shared/BaseEntity15.java deleted file mode 100644 index 66480122..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/shared/BaseEntity15.java +++ /dev/null @@ -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 . - */ - -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); - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java index 00455db9..4b69606e 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java @@ -114,16 +114,11 @@ public class FlatteningWrapper15 implements FlatteningWrapper { } private static final BaseBlock WOOL = Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock(); - private static final BaseBlock WOOL2 = Objects.requireNonNull(BlockTypes.YELLOW_WOOL).getDefaultState().toBaseBlock(); private static final BaseBlock CLAY = Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock(); - private static final BaseBlock CLAY2 = Objects.requireNonNull(BlockTypes.YELLOW_TERRACOTTA).getDefaultState().toBaseBlock(); private static final BaseBlock GLAZED = Objects.requireNonNull(BlockTypes.PINK_GLAZED_TERRACOTTA).getDefaultState().toBaseBlock(); private static final BaseBlock GLASS = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS).getDefaultState().toBaseBlock(); - private static final BaseBlock GLASS2 = Objects.requireNonNull(BlockTypes.YELLOW_STAINED_GLASS).getDefaultState().toBaseBlock(); private static final BaseBlock GLASS_PANE = Objects.requireNonNull(BlockTypes.PINK_STAINED_GLASS_PANE).getDefaultState().toBaseBlock(); - private static final BaseBlock GLASS_PANE2 = Objects.requireNonNull(BlockTypes.YELLOW_STAINED_GLASS_PANE).getDefaultState().toBaseBlock(); private static final BaseBlock CONCRETE = Objects.requireNonNull(BlockTypes.PINK_CONCRETE).getDefaultState().toBaseBlock(); - private static final BaseBlock CONCRETE2 = Objects.requireNonNull(BlockTypes.YELLOW_CONCRETE).getDefaultState().toBaseBlock(); private static final BaseBlock CONCRETE_POWDER = Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock(); private static final BaseBlock CARPET = Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock(); @@ -143,7 +138,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper { @Override public EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) { try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { - if (pasteOptions.getColor() != Color.YELLOW) { + if (pasteOptions.getColor() != Color.PINK) { changeColor(clipboard, pasteOptions.getColor()); } @@ -233,28 +228,18 @@ public class FlatteningWrapper15 implements FlatteningWrapper { BaseBlock block = clipboard.getFullBlock(pos); if (block.equals(WOOL)) { clipboard.setBlock(pos, wool); - } else if (block.equals(WOOL2)) { - clipboard.setBlock(pos, wool); } else if (block.equals(CLAY)) { clipboard.setBlock(pos, clay); - } else if (block.equals(CLAY2)) { - clipboard.setBlock(pos, clay); } else if (block.equals(GLAZED)) { clipboard.setBlock(pos, glazed); } else if (block.equals(GLASS)) { clipboard.setBlock(pos, glass); - } else if (block.equals(GLASS2)) { - clipboard.setBlock(pos, glass); } else if (block.equals(GLASS_PANE)) { clipboard.setBlock(pos, glassPane); - } else if (block.equals(GLASS_PANE2)) { - clipboard.setBlock(pos, glassPane); } else if (block.equals(CARPET)) { clipboard.setBlock(pos, carpet); } else if (block.equals(CONCRETE)) { clipboard.setBlock(pos, concrete); - } else if (block.equals(CONCRETE2)) { - clipboard.setBlock(pos, concrete); } else if (block.equals(CONCRETE_POWDER)) { clipboard.setBlock(pos, concretePowder); } diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java index 15756166..b6cd9609 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java @@ -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 a = Reflection.getField(explosionPacket, double.class, 0); private final Reflection.FieldAccessor b = Reflection.getField(explosionPacket, double.class, 1); diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/ProtocolWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/ProtocolWrapper15.java deleted file mode 100644 index 57ba7259..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/ProtocolWrapper15.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.utils; - -import com.comphenix.tinyprotocol.Reflection; -import com.mojang.authlib.GameProfile; -import de.steamwar.bausystem.features.util.NoClipCommand; - -public class ProtocolWrapper15 implements ProtocolWrapper { - - private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, NoClipCommand.playerInfoPacket, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent); - @Override - public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) { - return playerInfoDataConstructor.invoke(packet, profile, 0, mode, null); - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java deleted file mode 100644 index 8b28359e..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java +++ /dev/null @@ -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 . - */ - -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); - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java deleted file mode 100644 index 58537b7b..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java +++ /dev/null @@ -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 . -*/ - -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; - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java deleted file mode 100644 index 437c2620..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; -import de.steamwar.bausystem.shared.BaseEntity18; -import de.steamwar.bausystem.shared.ReferenceCounter; -import net.minecraft.network.chat.ChatComponentText; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class TraceEntity18 extends BaseEntity18 implements AbstractTraceEntity { - - private boolean exploded = false; - private ReferenceCounter referenceCounter = new ReferenceCounter(); - - public TraceEntity18(World world, Vector position, boolean tnt) { - super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS); - - this.e(true); - this.S = -12000; - } - - @Override - public void display(Player player, boolean exploded, int ticks) { - if (ticks != -1) { - this.n(true); - this.a(new ChatComponentText(ticks + "")); - } - if (!this.exploded && exploded) { - this.n(true); - this.a(new ChatComponentText("Bumm")); - this.exploded = true; - if (referenceCounter.increment() > 0) { - sendEntityDestroy(player); - } - } else if (referenceCounter.increment() > 0) { - return; - } - - sendEntity(player); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!force && referenceCounter.decrement() > 0) { - return false; - } - - sendEntityDestroy(player); - ag(); - return true; - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java deleted file mode 100644 index 35f8287a..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.warp.AbstractWarpEntity; -import de.steamwar.bausystem.shared.BaseArmorStand18; -import net.minecraft.network.chat.ChatComponentText; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport; -import net.minecraft.server.network.PlayerConnection; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class WarpEntity18 extends BaseArmorStand18 implements AbstractWarpEntity { - - public WarpEntity18(World world, Vector position, String name) { - super(world, position); - this.j(true); - this.a(true); - setName(name); - this.e(true); - this.S = -12000; - } - - @Override - public void display(Player player) { - sendEntity(player); - } - - @Override - public void setName(String name) { - this.n(true); - this.a(new ChatComponentText(name)); - } - - @Override - public boolean hide(Player player) { - sendEntityDestroy(player); - ag(); - return true; - } - - @Override - public void sendMetaData(Player player) { - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutEntityMetadata); - } - - @Override - public void teleport(Player player, Vector position) { - setPosRaw(position.getX(), position.getY(), position.getZ(), false); - PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityTeleport); - } - - @Override - public Vector getPosition() { - return new Vector(dc(), de(), di()); - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java deleted file mode 100644 index cc0d278c..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.shared; - -import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; -import net.minecraft.server.network.PlayerConnection; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.decoration.EntityArmorStand; -import net.minecraft.world.phys.Vec3D; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class BaseArmorStand18 extends EntityArmorStand implements AbstractEntity { - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - - protected Vector position; - - public BaseArmorStand18(World world, Vector position) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ()); - - this.position = position; - e(true); - S = -12000; - } - - public void sendEntity(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.c, 0, ZERO); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); - playerConnection.a(packetPlayOutEntityMetadata); - } - - public void sendEntityDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae()); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy); - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java deleted file mode 100644 index ef776851..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java +++ /dev/null @@ -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 . - */ - -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); - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java index 4d14fc01..3e9ed190 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -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 a = Reflection.getField(explosionPacket, double.class, 0); private final Reflection.FieldAccessor b = Reflection.getField(explosionPacket, double.class, 1); diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java deleted file mode 100644 index 962b8181..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.utils; - -import com.comphenix.tinyprotocol.Reflection; -import com.mojang.authlib.GameProfile; -import de.steamwar.bausystem.features.util.NoClipCommand; - -public class ProtocolWrapper18 implements ProtocolWrapper { - - private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent); - @Override - public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) { - return playerInfoDataConstructor.invoke(profile, 0, mode, null); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/entities/DetonatorEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/entities/DetonatorEntity19.java deleted file mode 100644 index 15b622ac..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/entities/DetonatorEntity19.java +++ /dev/null @@ -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 . - */ - -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); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/entities/SimulatorEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/entities/SimulatorEntity19.java deleted file mode 100644 index 51d3e6eb..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/entities/SimulatorEntity19.java +++ /dev/null @@ -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 . -*/ - -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; - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java deleted file mode 100644 index e70dba55..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; -import de.steamwar.bausystem.shared.BaseEntity19; -import de.steamwar.bausystem.shared.ReferenceCounter; -import net.minecraft.network.chat.IChatMutableComponent; -import net.minecraft.network.chat.contents.LiteralContents; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class TraceEntity19 extends BaseEntity19 implements AbstractTraceEntity { - - private boolean exploded = false; - private ReferenceCounter referenceCounter = new ReferenceCounter(); - - public TraceEntity19(World world, Vector position, boolean tnt) { - super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS); - - this.e(true); - this.S = -12000; - } - - @Override - public void display(Player player, boolean exploded, int ticks) { - if (ticks != -1) { - this.n(true); - this.b(IChatMutableComponent.a(new LiteralContents(ticks + ""))); - } - if (!this.exploded && exploded) { - this.n(true); - this.b(IChatMutableComponent.a(new LiteralContents("Bumm"))); - this.exploded = true; - if (referenceCounter.increment() > 0) { - sendEntityDestroy(player); - } - } else if (referenceCounter.increment() > 0) { - return; - } - - sendEntity(player); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!force && referenceCounter.decrement() > 0) { - return false; - } - - sendEntityDestroy(player); - ag(); - return true; - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/entities/WarpEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/entities/WarpEntity19.java deleted file mode 100644 index a86a653e..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/entities/WarpEntity19.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.warp.AbstractWarpEntity; -import de.steamwar.bausystem.shared.BaseArmorStand19; -import net.minecraft.network.chat.IChatMutableComponent; -import net.minecraft.network.chat.contents.LiteralContents; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport; -import net.minecraft.server.network.PlayerConnection; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class WarpEntity19 extends BaseArmorStand19 implements AbstractWarpEntity { - - public WarpEntity19(World world, Vector position, String name) { - super(world, position); - this.j(true); - this.a(true); - setName(name); - this.e(true); - this.S = -12000; - } - - @Override - public void display(Player player) { - sendEntity(player); - } - - @Override - public void setName(String name) { - this.n(true); - this.b(IChatMutableComponent.a(new LiteralContents(name))); - } - - @Override - public boolean hide(Player player) { - sendEntityDestroy(player); - ag(); - return true; - } - - @Override - public void sendMetaData(Player player) { - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutEntityMetadata); - } - - @Override - public void teleport(Player player, Vector position) { - setPosRaw(position.getX(), position.getY(), position.getZ(), false); - PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityTeleport); - } - - @Override - public Vector getPosition() { - return new Vector(df(), dh(), dj()); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeExplosion19.java b/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeExplosion19.java deleted file mode 100644 index eaa19495..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeExplosion19.java +++ /dev/null @@ -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 . - */ - -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 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 n; - private Map o; - public boolean wasCanceled; - - public FakeExplosion19(List 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 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 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)); - } - } - } - } - } - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeTNT19.java b/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeTNT19.java deleted file mode 100644 index abf89c09..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeTNT19.java +++ /dev/null @@ -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 . - */ - -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 b; - private static final int c = 80; - private List fakeTNT19s; - private List spawnList = new ArrayList<>(); - private int count; - @Nullable - public EntityLiving d; - public float yield; - public boolean isIncendiary; - - public FakeTNT19(List fakeTNT19s, EntityTypes type, World world) { - super(type, world); - this.fakeTNT19s = fakeTNT19s; - this.yield = 4.0F; - this.isIncendiary = false; - super.q = true; - } - - public FakeTNT19(List 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 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 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); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/SimulatorPreview19.java b/BauSystem_19/src/de/steamwar/bausystem/features/simulator/SimulatorPreview19.java deleted file mode 100644 index 5a06c342..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/SimulatorPreview19.java +++ /dev/null @@ -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 . - */ - -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>>> result = new HashMap<>(); - for (SimulatorElement element : tntSimulator.getTntElementList()) { - element.locations(result); - } - - AtomicInteger maxTick = new AtomicInteger(0); - Map>>> toSpawn = new HashMap<>(); - AtomicInteger tntCount = new AtomicInteger(0); - result.forEach((integer, integerSetMap) -> { - List>>> 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 fakeTNT19s = new ArrayList<>(); - Record record = new Record(null); - Map tntRecords = new HashMap<>(); - - int maxTickToCalc = maxTick.get() + 160; - for (int tick = 0; tick < maxTickToCalc; tick++) { - List>> 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 fakeTNT19s, Record record, Map tntRecords) { - int i = 0; - while (i < fakeTNT19s.size()) { - List 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++; - } - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator19.java b/BauSystem_19/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator19.java index b56e04b3..17498269 100644 --- a/BauSystem_19/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator19.java +++ b/BauSystem_19/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator19.java @@ -21,7 +21,7 @@ package de.steamwar.bausystem.features.tracer.record; import net.minecraft.world.entity.item.EntityTNTPrimed; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_19_R2.CraftWorld; import org.bukkit.entity.TNTPrimed; import java.util.stream.Stream; diff --git a/BauSystem_19/src/de/steamwar/bausystem/shared/BaseArmorStand19.java b/BauSystem_19/src/de/steamwar/bausystem/shared/BaseArmorStand19.java deleted file mode 100644 index fcc0ef9f..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/shared/BaseArmorStand19.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.shared; - -import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; -import net.minecraft.server.network.PlayerConnection; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.decoration.EntityArmorStand; -import net.minecraft.world.phys.Vec3D; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class BaseArmorStand19 extends EntityArmorStand implements AbstractEntity { - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - - protected Vector position; - - public BaseArmorStand19(World world, Vector position) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ()); - - this.position = position; - e(true); - S = -12000; - } - - public void sendEntity(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), co(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.d, 0, ZERO, 0.0); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); - playerConnection.a(packetPlayOutEntityMetadata); - } - - public void sendEntityDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae()); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java deleted file mode 100644 index df65d56a..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java +++ /dev/null @@ -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 . - */ - -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); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java b/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java index 4d184f6f..d6c7df29 100644 --- a/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java +++ b/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java @@ -21,32 +21,27 @@ 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; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.*; +import net.minecraft.network.syncher.DataWatcher; import net.minecraft.server.level.PlayerInteractManager; import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.phys.Vec3D; -import org.bukkit.*; -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.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_19_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; @@ -96,7 +91,9 @@ public class NMSWrapper19 implements NMSWrapper { if (entity instanceof TNTPrimed) { net.minecraft.world.entity.Entity serverEntity = ((CraftEntity) entity).getHandle(); - packets.add(new PacketPlayOutEntityMetadata(serverEntity.ae(), serverEntity.ai(), true)); + List> list = serverEntity.al().c(); + if(list != null) + packets.add(new PacketPlayOutEntityMetadata(serverEntity.ah(), list)); } }); } @@ -119,8 +116,8 @@ public class NMSWrapper19 implements NMSWrapper { @Override public void setPlayerBuildAbilities(Player player) { - ((CraftPlayer) player).getHandle().fB().d = true; - ((CraftPlayer) player).getHandle().fB().e = true; + ((CraftPlayer) player).getHandle().fF().d = true; + ((CraftPlayer) player).getHandle().fF().e = true; } @Override @@ -167,26 +164,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 a = Reflection.getField(explosionPacket, double.class, 0); private final Reflection.FieldAccessor b = Reflection.getField(explosionPacket, double.class, 1); diff --git a/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java b/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java index 4b9f7939..afc51ded 100644 --- a/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java +++ b/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java @@ -19,22 +19,62 @@ package de.steamwar.bausystem.utils; -import de.steamwar.bausystem.utils.PlayerMovementWrapper; import net.minecraft.network.protocol.game.PacketPlayInFlying; import net.minecraft.server.level.EntityPlayer; -import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; import org.bukkit.entity.Player; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + public class PlayerMovementWrapper19 implements PlayerMovementWrapper { + private static class Position { + private double x; + private double y; + private double z; + private float yaw; + private float pitch; + } + + private Map playerLocationMap = new HashMap<>(); + @Override public void setPosition(Player player, Object object) { + Position position = playerLocationMap.computeIfAbsent(player.getUniqueId(), uuid -> { + Position pos = new Position(); + Location location = player.getLocation(); + pos.x = location.getX(); + pos.y = location.getY(); + pos.z = location.getZ(); + pos.yaw = location.getYaw(); + pos.pitch = location.getPitch(); + return pos; + }); PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); if (packetPlayInFlying.h) { entityPlayer.b(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, packetPlayInFlying.d, packetPlayInFlying.e); + position.x = packetPlayInFlying.a; + position.y = packetPlayInFlying.b; + position.z = packetPlayInFlying.c; + position.yaw = packetPlayInFlying.d; + position.pitch = packetPlayInFlying.e; } else { entityPlayer.e(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c); + position.x = packetPlayInFlying.a; + position.y = packetPlayInFlying.b; + position.z = packetPlayInFlying.c; + } + } + + @Override + public void disable(Player player) { + Position position = playerLocationMap.remove(player.getUniqueId()); + if (position != null) { + player.teleport(new Location(player.getWorld(), position.x, position.y, position.z, position.yaw, position.pitch)); } } } diff --git a/BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java b/BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java deleted file mode 100644 index 3a21ab08..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2021 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ - -package de.steamwar.bausystem.utils; - -import com.comphenix.tinyprotocol.Reflection; -import com.mojang.authlib.GameProfile; -import de.steamwar.bausystem.features.util.NoClipCommand; - -public class ProtocolWrapper19 implements ProtocolWrapper { - - private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent, Reflection.getClass("net.minecraft.world.entity.player.ProfilePublicKey$a")); - @Override - public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) { - return playerInfoDataConstructor.invoke(profile, 0, mode, null, null); - } -} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/LuaLib_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/LuaLib_GENERIC.java new file mode 100644 index 00000000..570f6a33 --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/LuaLib_GENERIC.java @@ -0,0 +1,40 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.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 LuaLib_GENERIC implements LinkageType { + + @Override + public String method() { + return "link"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { + buildPlan.addImport("de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin"); + methodBuilder.addLine("SteamWarLuaPlugin.add(" + s + ");"); + } +} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/Operator_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/Operator_GENERIC.java deleted file mode 100644 index 8a1916a8..00000000 --- a/BauSystem_Linkage/src/de/steamwar/linkage/types/Operator_GENERIC.java +++ /dev/null @@ -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 . - */ - -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 Operator_GENERIC implements LinkageType { - - @Override - public String method() { - return "linkScriptCommands"; - } - - @Override - public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { - buildPlan.addImport("de.steamwar.bausystem.features.script.expression.Expression"); - methodBuilder.addLine("Expression.registerOperator(" + s + ");"); - } -} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/BlockAttribute_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/ScoreboardElement_GENERIC.java similarity index 79% rename from BauSystem_Linkage/src/de/steamwar/linkage/types/BlockAttribute_GENERIC.java rename to BauSystem_Linkage/src/de/steamwar/linkage/types/ScoreboardElement_GENERIC.java index b898485b..01e29833 100644 --- a/BauSystem_Linkage/src/de/steamwar/linkage/types/BlockAttribute_GENERIC.java +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/ScoreboardElement_GENERIC.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * 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 @@ -25,16 +25,16 @@ import de.steamwar.linkage.plan.MethodBuilder; import javax.lang.model.element.TypeElement; -public class BlockAttribute_GENERIC implements LinkageType { +public class ScoreboardElement_GENERIC implements LinkageType { @Override public String method() { - return "linkBlockAttributes"; + return "link"; } @Override public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { - buildPlan.addImport("de.steamwar.bausystem.features.attributescopy.*"); - methodBuilder.addLine("AttributesCopyCommand.add(" + s + ");"); + buildPlan.addImport("de.steamwar.bausystem.features.world.BauScoreboard"); + methodBuilder.addLine("BauScoreboard.ELEMENTS.add(" + s + ");"); } } diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/SpecialCommand_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/SpecialCommand_GENERIC.java deleted file mode 100644 index 97c63276..00000000 --- a/BauSystem_Linkage/src/de/steamwar/linkage/types/SpecialCommand_GENERIC.java +++ /dev/null @@ -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 . - */ - -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 SpecialCommand_GENERIC implements LinkageType { - - @Override - public String method() { - return "linkScriptCommands"; - } - - @Override - public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { - buildPlan.addImport("de.steamwar.bausystem.features.script.ScriptExecutor"); - methodBuilder.addLine("ScriptExecutor.SPECIAL_COMMANDS.add(" + s + ");"); - } -} diff --git a/BauSystem_Main/build.gradle b/BauSystem_Main/build.gradle index 1052e30a..2e9a8d6c 100644 --- a/BauSystem_Main/build.gradle +++ b/BauSystem_Main/build.gradle @@ -64,4 +64,6 @@ dependencies { annotationProcessor swdep('SpigotCore') compileOnly swdep('FastAsyncWorldEdit-1.18') + + implementation 'org.luaj:luaj-jse:3.0.1' } \ No newline at end of file diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 690fcb6d..5ae58f17 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -37,12 +37,16 @@ SCOREBOARD_TPS_FROZEN = §e Frozen SCOREBOARD_TRACE_TICKS = Ticks +SCOREBOARD_TECHHIDER = TechHider§8: §aOn +SCOREBOARD_XRAY = XRay§8: §aOn + # Flags FLAG_COLOR = Color FLAG_TNT = TNT FLAG_FIRE = Fire FLAG_FREEZE = Freeze FLAG_PROTECT = Protect +FLAG_ITEMS = Items FLAG_FIRE_ALLOW = §con FLAG_FIRE_DENY = §aoff @@ -57,6 +61,9 @@ FLAG_TNT_ALLOW = §aon FLAG_TNT_DENY = §coff FLAG_TNT_ONLY_TB = §7no §ebuild area +FLAG_ITEMS_ACTIVE = §aon +FLAG_ITEMS_INACTIVE = §coff + FLAG_COLOR_WHITE = §fWhite FLAG_COLOR_ORANGE = §6Orange FLAG_COLOR_MAGENTA = §dMagenta @@ -137,6 +144,7 @@ BAU_INFO_ITEM_LORE_DAMAGE= BAU_INFO_ITEM_LORE_FIRE = §7Fire§8: §e{0} BAU_INFO_ITEM_LORE_COLOR = §7Color§8: §e{0} BAU_INFO_ITEM_LORE_PROTECT = §7Protect§8: §e{0} +BAU_INFO_ITEM_LORE_ITEMS = §7Items§8: §e{0} BAU_INFO_COMMAND_HELP = §8/§ebauinfo §8- §7Information regarding this build server BAU_INFO_COMMAND_OWNER = §7Owner: §e{0} @@ -159,6 +167,12 @@ COUNTINGWAND_MESSAGE_LCLICK = §7Second position at: §8[§7{0}§8, §7{1}§8, COUNTINGWAND_MESSAGE_VOLUME = §e{0} COUNTINGWAND_MESSAGE_DIMENSION = §e{0}§8, §e{1}§8, §e{2} +# Design Endstone +DESIGN_ENDSTONE_COMMAND_HELP = §8/§edesign endstone §8- §7Show where Endstone is +DESIGN_ENDSTONE_REGION_ERROR = §cThis region has no build area +DESIGN_ENDSTONE_ENABLE = §aEndstone is activated +DESIGN_ENDSTONE_DISABLE = §cEndstone is deactivated + # Detonator DETONATOR_LOC_REMOVE = §e{0} removed DETONATOR_LOC_ADD = §e{0} added @@ -216,298 +230,51 @@ GUI_EDITOR_TITLE_MORE=Select item # Script ## Errors -SCRIPT_SLEEP_ERROR = §cInsert a sleep into your script -SCRIPT_COMMAND_ERROR_UNKNOWN_VAR = §cUnknown variable {0} -SCRIPT_COMMAND_ERROR_EXPRESSION = §cExpression error with: {0} -SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR = §cThe first argument is missing and should be a variable -SCRIPT_COMMAND_ERROR_FIRST_ARG_NONUMER = §cThe first argument is missing and should be a number -SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR_OR_VALUE = §cThe first argument is missing and should be a variable or a number -SCRIPT_COMMAND_ERROR_FIRST_ARG_NOJUMPPOINT = §cThe first argument is missing and should be a jump-point -SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR = §cThe second argument is missing and should be a variable -SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE = §cThe econd argument is missing and should be a value -SCRIPT_COMMAND_ERROR_SECOND_ARG_NOJUMPPOINT = §cThe second argument is missing and should be a jump-point -SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR = §cThe third argument is missing and should be a variable -SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVALUE = §cThe third argument is missing and should be a value -SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR_OR_NUMBER = §cThe third argument is missing and should be a variable or a number -SCRIPT_COMMAND_ERROR_FOURTH_ARG_NOVALUE = §cThe fourth argument is missing and should be a value - -SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE = §cOnly booleans can be compared -SCRIPT_COMMAND_ERROR_NUMBER_COMPARE = §cOnly numbers can be compared -SCRIPT_COMMAND_ERROR_NO_BOOLEAN = §cThe value is not a boolean - -SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED = §cOnly strings are allowed -SCRIPT_COMMAND_ERROR_ONLY_NUMBERS_ALLOWED = §cOnly numbers are allowed - -SCRIPT_COMMAND_ERROR_UNKNOWN_OPERATION = §cUnknown operation: {0} - -## Commands -SCRIPT_COMMAND_ARITHMETIC_ADD_ERROR = §cOnly numbers or strings can be added -SCRIPT_COMMAND_ARITHMETIC_DIV_ERROR = §cOnly numbers can be divided -SCRIPT_COMMAND_ARITHMETIC_MUL_ERROR = §cOnly numbers can be multiplied -SCRIPT_COMMAND_ARITHMETIC_SUB_ERROR = §cOnly numbers can be subtracted -SCRIPT_COMMAND_ARITHMETIC_POW_ERROR = §cOnly numbers can be raised to a power -SCRIPT_COMMAND_ARITHMETIC_MOD_ERROR = §cOnly whole numbers can be used for modulo -SCRIPT_COMMAND_ARITHMETIC_BIT_AND_ERROR = §cOnly whole numbers and booleans can be used for and -SCRIPT_COMMAND_ARITHMETIC_BIT_OR_ERROR = §cOnly whole numbers and booleans can be used for or -SCRIPT_COMMAND_ARITHMETIC_BIT_XOR_ERROR = §cOnly whole numbers and booleans can be used for xor -SCRIPT_COMMAND_ARITHMETIC_BIT_LEFT_ERROR = §cOnly whole numbers can be used for left shift value -SCRIPT_COMMAND_ARITHMETIC_BIT_RIGHT_ERROR = §cOnly whole numbers can be used for right shift value -SCRIPT_COMMAND_ARITHMETIC_BIT_RIGHT_LOGIC_ERROR = §cOnly whole numbers can be used for logic right shift value - -SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_1 = §eceil §8<§7variable§8> §8<§7variable§8|§7value§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_2 = §eceil §8<§7variable§8> §8<§7variable§8|§7value§8> §8<§7variable§8|§7value§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_3 = Ceils the second number and writes it in the first or ceils the second number with the precision from the third number and writes it in the first -SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_ERROR_1 = §cOnly floating point numbers can be ceiled -SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_ERROR_2 = §cThe precision needs to be a whole number - -SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_1 = §efloor §8<§7variable§8> §8<§7variable§8|§7value§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_2 = §efloor §8<§7variable§8> §8<§7variable§8|§7value§8> §8<§7variable§8|§7value§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_3 = Floors the second number and writes it in the first or floors the second number with the precision from the third number and writes it in the first -SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_ERROR_1 = §cOnly floating point numbers can be floored -SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_ERROR_2 = §cThe precision needs to be a whole number - -SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_1 = §eround §8<§7variable§8> §8<§7variable§8|§7value§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_2 = §eround §8<§7variable§8> §8<§7variable§8|§7value§8> §8<§7variable§8|§7value§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_3 = Round the second number and writes it in the first or rounds the second number with the precision from the third number and writes it in the first -SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_ERROR_1 = §cOnly floating point numbers can be rounded -SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_ERROR_2 = §cThe precision needs to be a whole number - -SCRIPT_COMMAND_IO_ECHO_HELP_1 = §eecho §8<§7value§8> -SCRIPT_COMMAND_IO_ECHO_HELP_2 = §7Send a message to the player. If the value is empty, the message will be empty as well -SCRIPT_COMMAND_IO_ECHO_MESSAGE = §f{0} - -SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_1 = §eechoactionbar §8<§7value§8> -SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_2 = §7Send a message to the player to the action bar. If the value is empty, the message will be empty as well - -SCRIPT_COMMAND_IO_INPUT_HELP_1 = §einput §8<§7variable§8> §8<§7text§8> -SCRIPT_COMMAND_IO_INPUT_HELP_2 = §7Request an input from the player, which will be written in the variable. The text is optional - -SCRIPT_COMMAND_STRING_INSERT_HELP_1 = §einsert §8<§7variable§8> §8<§7variable§8> §8<§7number§8> -SCRIPT_COMMAND_STRING_INSERT_HELP_2 = §einsert §8<§7variable§8> §8<§7variable§8> §8<§7variable§8> §8<§7number§8> -SCRIPT_COMMAND_STRING_INSERT_HELP_3 = Insert something into a String at a given index. The number is the index and the variable is the string. Optionally the result can be written in another or a new variable - -SCRIPT_COMMAND_STRING_REMOVE_HELP_1 = §eremove §8<§7variable§8> §8<§7from variable§8> -SCRIPT_COMMAND_STRING_REMOVE_HELP_2 = §eremove §8<§7variable§8> §8<§7variable§8> §8<§7from variable§8> -SCRIPT_COMMAND_STRING_REMOVE_HELP_3 = Removes all occurrences of a string from another string. - -SCRIPT_COMMAND_STRING_REPLACE_HELP_1 = §ereplace §8<§7variable§8> §8<§7from variable§8> §8<§7to variable§8> -SCRIPT_COMMAND_STRING_REPLACE_HELP_2 = §ereplace §8<§7variable§8> §8<§7variable§8> §8<§7from variable§8> §8<§7to variable§8> -SCRIPT_COMMAND_STRING_REPLACE_HELP_3 = Replaces all occurrences of a string from another string with a given string - -SCRIPT_COMMAND_STRING_SUBSTRING_HELP_1 = §esubstring §8<§7variable§8> §8<§7number§8> -SCRIPT_COMMAND_STRING_SUBSTRING_HELP_2 = §esubstring §8<§7variable§8> §8<§7variable§8> §8<§7number§8> -SCRIPT_COMMAND_STRING_SUBSTRING_HELP_3 = Shortens a string either from the start or the end, depending on whether the given index is positive (start) or negative (end) - -SCRIPT_COMMAND_VARIABLE_CONST_HELP_1 = §econst §8<§7variable§8> §8[§7value§8(§7s§8)§8] -SCRIPT_COMMAND_VARIABLE_CONST_HELP_2 = Writes a value in a constant, which can be a number, a boolean or a string - -SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_1 = §econvert §8<§7variable§8> §8<§7value§8> -SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_2 = Converts a value to 'number' if it's a number, or to 'boolean' if it's either 'true' or 'false'. Otherwise it remains of type 'text'. - -SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_1 = §eglobal §8<§7variable§8> §8[§7value§8(§7s§8)§8] -SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_2 = Writes a value in a variable, which can be a number, a boolean or a string - -SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_1 = §eunglobal §8<§7variable§8> -SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_2 = Deletes a global variable. - -SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_1 = §eunvar §8<§7variable§8> -SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_2 = Deletes a local variable. - -SCRIPT_COMMAND_VARIABLE_VAR_HELP_1 = §evar §8<§7variable§8> §8[§7value§8(§7s§8)§8] -SCRIPT_COMMAND_VARIABLE_VAR_HELP_2 = Writes a value in a variable, which can be a number, a boolean or a string - -SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_1 = §egetmaterial §8<§7variable§8> §8<§7number§8> §8<§7number§8> §8<§7number§8> -SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_2 = Writes the material of a block in the world in the variable - -SCRIPT_COMMAND_WORLD_SETMATERIAL_HELP_1 = §esetmaterial §8<§7variable§8> §8<§7number§8> §8<§7number§8> §8<§7number§8> -SCRIPT_COMMAND_WORLD_SETMATERIAL_HELP_2 = Sets a block in the world with the given material, given in the variable - -SCRIPT_COMMAND_EXIT_HELP_1 = §eexit -SCRIPT_COMMAND_EXIT_HELP_2 = Exits the script - -SCRIPT_COMMAND_IF_HELP_1 = §eif §8<§7true/false§8> §8<§7jump-point§8> -SCRIPT_COMMAND_IF_HELP_2 = §eif §8<§7true/false§8> §8<§7jump-point§8> §8<§7jump-point§8> -SCRIPT_COMMAND_IF_HELP_3 = §7Jump to the first jump-point if the given value is true or the second jump-point otherwise. - -SCRIPT_COMMAND_JUMP_HELP_1 = §ejump §8<§7jump-point§8> -SCRIPT_COMMAND_JUMP_HELP_2 = §7Jump to a jump-point. A jump-point is a line with §8'§7.§8'§7 before. -SCRIPT_COMMAND_JUMP_ERROR = §cUnknown jump-point: {0} - -SCRIPT_COMMAND_CALL_HELP_1 = §ecall §8<§7jump-point§8> -SCRIPT_COMMAND_CALL_HELP_2 = §7Jump to a jump-point. A jump-point is a line with §8'§7.§8'§7 before. Building a return stack alongside. Use 'return' to jump back. -SCRIPT_COMMAND_CALL_ERROR = §cUnknown jump-point: {0} - -SCRIPT_COMMAND_RETURN_HELP_1 = §ereturn -SCRIPT_COMMAND_RETURN_HELP_2 = §7Jump back to the last 'call' command -SCRIPT_COMMAND_RETURN_ERROR = §cNo 'call' command executed before - -SCRIPT_COMMAND_SLEEP_HELP_1 = §esleep §8<§7time§8> -SCRIPT_COMMAND_SLEEP_HELP_2 = Pauses the execution by the given number of game ticks. -SCRIPT_COMMAND_SLEEP_ERROR = §cThe given number needs to be greater than zero. - -## GUI -SCRIPT_GUI_ITEM_NAME = §eScript Help +SCRIPT_ERROR_GUI=§cError in parsing script: Line {0} +SCRIPT_ERROR_GLOBAL=§cError in global script: Line {0} +SCRIPT_ERROR_CLICK=§cError in script: Line {0} +SCRIPT_ERROR_ONLY_IN_GLOBAL=§cThis function is only available in global scripts ## CustomScript -SCRIPT_HOTKEY_ITEM_NAME = §7Hotkey§8: §e{0} §8-§7 {1} -SCRIPT_EVENT_ITEM_NAME = §7Event§8: §e{0} §8-§7 {1} -SCRIPT_COMMAND_ITEM_NAME = §7Command§8: §e{0} +SCRIPT_HOTKEY_ITEM_NAME = §7Hotkey§8: §e{0} +SCRIPT_EVENT_ITEM_NAME = §7Event§8: §e{0} +SCRIPT_COMMAND_ITEM_NAME = §7Command§8: §e/{0} ## Script Menu GUI SCRIPT_MENU_GUI_ITEM_LORE_1 = §7Click to retrieve SCRIPT_MENU_GUI_ITEM_LORE_2 = §7Shift-Click to copy -SCRIPT_MENU_GUI_NAME = §eScript Commands {0}{1}§7% +SCRIPT_MENU_GUI_ITEM_LORE_3 = §7Right-Click to edit +SCRIPT_MENU_GUI_ITEM_LORE_4 = §7Middle-Click to preview +SCRIPT_MENU_GUI_NAME = §eScript-Menu SCRIPT_MENU_GUI_ITEM_ADD_NAME = §eInsert SCRIPT_MENU_GUI_ITEM_ADD_LORE = §7Click with a book to insert -SCRIPT_MENU_GUI_DUPLICATE_COMMAND = §cCommand '{0}' already defined -SCRIPT_MENU_GUI_UNKNOWN_EVENT = §cEvent '{0}' cannot be defined -SCRIPT_MENU_GUI_LIMIT = §cScript-Book limit reached +SCRIPT_MENU_GUI_ENTER_NAME = §eEnter a name +SCRIPT_DEPRECATED=§cThe function §8'§e{0}§8'§c is deprecated and will be removed in the future. Please use §8'§e{1}§8'§c instead. -## ScriptCommand -SCRIPT_COMMAND_HELP = §8/§escript §8- §7Opens the ScriptGUI -SCRIPT_COMMAND_HELP_MENU = §8/§escript menu §8- §7Opens the ScriptGUI for custom commands shares across baus +# Shield Printing +SHIELD_PRINTING_HELP_START = §8/§eshieldprinting start §8- §7Starts the shield printing +SHIELD_PRINTING_HELP_COPY = §8/§eshieldprinting copy §8- §7Copies the shield configuration +SHIELD_PRINTING_HELP_APPLY = §8/§eshieldprinting apply §8- §7Applies the shield configuration +SHIELD_PRINTING_HELP_STOP = §8/§eshieldprinting stop §8- §7Stops the shield printing +SHIELD_PRINTING_HELP_STEP_1 = §81. §7Paste the schematic you want to use +SHIELD_PRINTING_HELP_STEP_2 = §82. §7Start the shield printing with §8/§eshieldprinting start +SHIELD_PRINTING_HELP_STEP_3 = §83. §7Wait until the shield printing is finished +SHIELD_PRINTING_HELP_STEP_4 = §84. §7Edit the shields if necessary +SHIELD_PRINTING_HELP_STEP_5 = §85. §7Copy the shields printing with §8/§eshieldprinting copy +SHIELD_PRINTING_HELP_STEP_6 = §86. §7Paste the original schematic +SHIELD_PRINTING_HELP_STEP_7 = §87. §7Apply the shield printing with §8/§eshieldprinting apply -## Script GUI -SCRIPT_GUI_NAME = Script Elements -SCRIPT_GUI_COMMAND_CHAT = §eScript Command§8: §e{0} +SHIELD_PRINTING_NO_REGION = §cYou are not in a region. +SHIELD_PRINTING_NOT_RUNNING = §cThe shield printing is not running. +SHIELD_PRINTING_DISALLOWED = §cYou are not allowed to use shield printing here. +SHIELD_PRINTING_BOSSBAR = §fMovements: {0} +SHIELD_PRINTING_BOSSBAR_COPIED = §fMovements: {0} Copied: {1} -SCRIPT_GUI_CUSTOM_HOTKEYS = §eCustom Hotkeys -SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_1 = §7Write§8: §e#!HOTKEY 'Char' -SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_2 = §7at the beginning of a Script Book to use a custom hotkey. The 'Char' can be any char between '§eA§7' and '§eZ§7' as well as '§e0§7' and '§e9§7'. While executing two variables are available: §epressed§7, §ereleased§7. -SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_3 = §7You can add modifiers like "SHIFT", "CTRL", "ALT" or "META" to the hotkey. §7Example: §e#!HOTKEY SHIFT+A -SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_4 = §7 -SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_5 = §cThis can only be used in conjunction with the Fabric-Mod: §eAdvancedScripts §7found on §ehttps://steamwar.de/downloads - -SCRIPT_GUI_CUSTOM_COMMANDS = §eCustom Commands -SCRIPT_GUI_CUSTOM_COMMANDS_LORE_1 = §7Write§8: §e#!CMD 'COMMAND' -SCRIPT_GUI_CUSTOM_COMMANDS_LORE_2 = §7at the beginning of a Script Book to use a custom command. The command always starts with §e/§7 and can be structured as you wish. Everything in pointy Brackets '§e<>§7' will be counted as a Parameter and therefore as a variable. Parameters in round brackets '§e()§7' are optional. Simple texts as parameters get a variable with the same name with the values true/false, depending on whether the value was given or not - -SCRIPT_GUI_CUSTOM_EVENTS = §eCustom Events -SCRIPT_GUI_CUSTOM_EVENTS_LORE_1 = §7Write§8: §e#!EVENT 'EventName' -SCRIPT_GUI_CUSTOM_EVENTS_LORE_2 = §7at the beginning of a Script Book to use a custom event. Every event can ve canceled by using 'var cancel true'. After the event name are the variables which are usable in a Script Book. -SCRIPT_GUI_CUSTOM_EVENTS_LORE_3 = §7Usable Events are: -SCRIPT_GUI_CUSTOM_EVENTS_LORE_4 = §eFF -SCRIPT_GUI_CUSTOM_EVENTS_LORE_5 = §ePlaceBlock §8-§7 blockX, blockY, blockZ, blockType -SCRIPT_GUI_CUSTOM_EVENTS_LORE_6 = §eBreakBlock §8-§7 blockX, blockY, blockZ, blockType -SCRIPT_GUI_CUSTOM_EVENTS_LORE_7 = §eRightClick §8-§7 blockInHand, action, handType, -SCRIPT_GUI_CUSTOM_EVENTS_LORE_8 = §7 hasBlock §8[§7blockX, blockY, blockZ, blockFace§8]§e* -SCRIPT_GUI_CUSTOM_EVENTS_LORE_9 = §eLeftClick §8-§7 blockInHand, action, handType, -SCRIPT_GUI_CUSTOM_EVENTS_LORE_10 = §7 hasBlock §8[§7blockX, blockY, blockZ, blockFace§8]§e* -SCRIPT_GUI_CUSTOM_EVENTS_LORE_11 = §eTNTSpawn -SCRIPT_GUI_CUSTOM_EVENTS_LORE_12 = §eTNTExplode §8-§7 x, y, z -SCRIPT_GUI_CUSTOM_EVENTS_LORE_13 = §eTNTExplodeInBuild §8-§7 x, y, z -SCRIPT_GUI_CUSTOM_EVENTS_LORE_14 = §eSelfJoin §8-§7 x, y, z, playerName -SCRIPT_GUI_CUSTOM_EVENTS_LORE_15 = §eSelfLeave §8-§7 x, y, z, playerName -SCRIPT_GUI_CUSTOM_EVENTS_LORE_16 = §eDropItem §8-§7 material, x, y, z -SCRIPT_GUI_CUSTOM_EVENTS_LORE_17 = §eEntityDeath §8-§7 entityType, x, y, z -SCRIPT_GUI_CUSTOM_EVENTS_LORE_18 = §eScoreboard -SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1 = §e* §8-§7 Everything in brackets is only set if the variable before is set on §etrue§7. - -SCRIPT_GUI_OTHER = §eOther -SCRIPT_GUI_OTHER_LORE_1 = §7Comments start with §e#§7. -SCRIPT_GUI_OTHER_LORE_2 = §7Jump_Points start with §e.§7. -SCRIPT_GUI_OTHER_LORE_3 = §7A variable name enclosed in '§e{}§7' is replaced by its value. A variable can be prefixed with '§econst.§7' or '§elocal.§7' or '§eglobal.§7'. -SCRIPT_GUI_OTHER_LORE_4 = §7The following applies: -SCRIPT_GUI_OTHER_LORE_5 = §7- Local variables are only available in the script book. -SCRIPT_GUI_OTHER_LORE_6 = §7- Global variables are available in every script book. -SCRIPT_GUI_OTHER_LORE_7 = §7- Constant variables are variables from the server (e.g. player name, TPS, etc.) -SCRIPT_GUI_OTHER_LORE_8 = §7A variable can be appended with '§e.length§7' or '§e.type§7' or '§e.isset§7'. -SCRIPT_GUI_OTHER_LORE_9 = §7The following applies: -SCRIPT_GUI_OTHER_LORE_10 = §7- Length returns the length of the variable as a number. -SCRIPT_GUI_OTHER_LORE_11 = §7- Type returns the type (number, floating_number, text or boolean) as text. -SCRIPT_GUI_OTHER_LORE_12 = §7- Isset returns as a boolean whether the variable exists. -SCRIPT_GUI_OTHER_LORE_13 = §7Mathematical as well as logical operations can be specified in '§e{}§7'. -SCRIPT_GUI_OTHER_LORE_14 = §7The following applies: -SCRIPT_GUI_OTHER_LORE_15 = §7- arithmetic operators: §e+ * - /§7 as well as §e%§7 for modulo -SCRIPT_GUI_OTHER_LORE_16 = §7- Logical operators: §e==§7; §e!=§7; §e<=§7; §e>=§7; §e<§7; §e>§7; §e&&§7; §e||§7 (this is the character for or) -SCRIPT_GUI_OTHER_LORE_17 = §7- Bitwise operators: §e&§7; §e|§7; §e^ -SCRIPT_GUI_OTHER_LORE_18 = §7- Shift operators: §e<<§7; §e>>§7; §e>>>§7 - -SCRIPT_GUI_COMMAND_NAME = §7Command: §e{0} - -SCRIPT_GUI_CUSTOM_VARIABLES = §eCustom Variables - -SCRIPT_GUI_CONSTANT_TIME_NAME = §7Constant §etime -SCRIPT_GUI_CONSTANT_TIME_LORE = §7Formatted time variable. - -SCRIPT_GUI_CONSTANT_TICKS_NAME = §7Constant §eticks -SCRIPT_GUI_CONSTANT_TICKS_LORE = §7Ticks since server start. - -SCRIPT_GUI_CONSTANT_TRACE_NAME = §7Constant §etrace -SCRIPT_GUI_CONSTANT_TRACE_LORE = §etrue§7 if the trace is activated. - -SCRIPT_GUI_CONSTANT_AUTO_TRACE_NAME = §7Constant §eautotrace -SCRIPT_GUI_CONSTANT_AUTO_TRACE_LORE = §etrue§7 if the auto trace is activated. - -SCRIPT_GUI_CONSTANT_TRACE_STATUS_NAME = §7Constant §etrace_status -SCRIPT_GUI_CONSTANT_TRACE_STATUS_LORE = §7One of: §eOFF§8, §eIDLE§8, §eIDLE_AUTO_EXPLODE§8, §eIDLE_AUTO_IGNITE§8, §eIDLE_SINGLE - -SCRIPT_GUI_CONSTANT_TRACE_TIME_NAME = §7Constant §etrace_time -SCRIPT_GUI_CONSTANT_TRACE_TIME_LORE = §e0§7 if the trace is not active, otherwise the time in ticks since the trace was started. - -SCRIPT_GUI_CONSTANT_LOADER_STATUS_NAME = §7Constant §eloader_status -SCRIPT_GUI_CONSTANT_LOADER_STATUS_LORE = §7One of: §eOFF§8, §eSETUP§8, §eRUNNING§8, §eSINGLE§8, §ePAUSE§8, §eEND - -SCRIPT_GUI_CONSTANT_TNT_NAME = §7Constant §etnt -SCRIPT_GUI_CONSTANT_TNT_LORE = §etrue§7 if tnt is not deactivated. - -SCRIPT_GUI_CONSTANT_ONLY_TB_NAME = §7Constant §etnt_onlytb -SCRIPT_GUI_CONSTANT_ONLY_TB_LORE = §etrue§7 if tnt no build is activated. - -SCRIPT_GUI_CONSTANT_FREEZE_NAME = §7Constant §efreeze -SCRIPT_GUI_CONSTANT_FREEZE_LORE = §etrue§7 if freeze is not deactivated. - -SCRIPT_GUI_CONSTANT_FIRE_NAME = §7Constant §efire -SCRIPT_GUI_CONSTANT_FIRE_LORE = §etrue§7 if fire is not deactivated. - -SCRIPT_GUI_CONSTANT_PROTECT_NAME = §7Constant §eprotect -SCRIPT_GUI_CONSTANT_PROTECT_LORE = §etrue§7 if protect is activated. - -SCRIPT_GUI_CONSTANT_X_NAME = §7Constant §ex -SCRIPT_GUI_CONSTANT_X_LORE = §ex§7 position of the player. - -SCRIPT_GUI_CONSTANT_Y_NAME = §7Constant §ey -SCRIPT_GUI_CONSTANT_Y_LORE = §ey§7 position of the player. - -SCRIPT_GUI_CONSTANT_Z_NAME = §7Constant §ez -SCRIPT_GUI_CONSTANT_Z_LORE = §ez§7 position of the player. - -SCRIPT_GUI_CONSTANT_NAME_NAME = §7Constant §ename -SCRIPT_GUI_CONSTANT_NAME_LORE = §eDisplay§7 name of the player. - -SCRIPT_GUI_CONSTANT_SNEAK_NAME = §7Constant §esneaking -SCRIPT_GUI_CONSTANT_SNEAK_LORE = §etrue§7 if the player is sneaking. - -SCRIPT_GUI_CONSTANT_SPRINTING_NAME = §7Constant §esprinting -SCRIPT_GUI_CONSTANT_SPRINTING_LORE = §etrue§7 is the player is sprinting. - -SCRIPT_GUI_CONSTANT_SLOT_NAME = §7Constant §eslot -SCRIPT_GUI_CONSTANT_SLOT_LORE = §e0-8§7 for the selected slot. - -SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_NAME = §7Constant §eslotmaterial -SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_LORE = §eMaterial§7 of the item in the current slot - -SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_NAME = §7Constant §eoffhandmaterial -SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_LORE = §eMaterial§7 of the item in the off hand - -SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_NAME = §7Constant §ematerialname -SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE = §eName§7 of the item in the current slot - -SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME = §7Constant §eoffmaterialname -SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE = §eName§7 of the item in the off hand - -SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME = §7Constant §eregion_type -SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE = §eregion type§7 of the current region - -SCRIPT_GUI_CONSTANT_REGION_NAME_NAME = §7Constant §eregion_name -SCRIPT_GUI_CONSTANT_REGION_NAME_LORE = §eregion name§7 of the current region - -SCRIPT_GUI_CONSTANT_TPS_NAME = §7Constant §etps -SCRIPT_GUI_CONSTANT_TPS_LORE = §etps§7 of the server - -SCRIPT_GUI_CONSTANT_TPS_LIMIT_NAME = §7Constant §etps_limit -SCRIPT_GUI_CONSTANT_TPS_LIMIT_LORE = §etps_limit§7 of the server +SHIELD_PRINTING_START = §aThe shield printing has been started. +SHIELD_PRINTING_COPY = §aThe shield has been copied. +SHIELD_PRINTING_APPLY = §aThe shield has been applied. +SHIELD_PRINTING_STOP = §aThe shield printing has been stopped. # Unsign Book UNSIGN_HELP=§8/§eunsign §8- §7Make a signed book writable again @@ -585,7 +352,6 @@ SIMULATOR_GUI_TNT_GROUP_LORE_6 = §7z§8: §e{0} SIMULATOR_GUI_TNT_DISABLED = §cDisabled SIMULATOR_GUI_NAME = Simulator SIMULATOR_GUI_DELETE = §cDelete TNT -SIMULATOR_GUI_START = §eStart SIMULATOR_GUI_AUTO_TRACE = §eAutoTrace§8: §7{0} SIMULATOR_GUI_MOVE_ALL = §eMove all @@ -651,30 +417,29 @@ INVENTORY_FILL_INFO = §7Helps you fill containers by looking at them while snea INVENTORY_FILL_ENABLE = §aInventoryFiller activated INVENTORY_FILL_DISABLE = §cInventoryFiller deactivated +# Killchecker +KILLCHECKER_HELP_ENABLE = §8/§ekillchecker enable §8- §7Enables Killchecker / Recalculates kills +KILLCHECKER_HELP_DISABLE = §8/§ekillchecker disable §8- §7Disables Killchecker +KILLCHECKER_INFO = §7Shows the overlaps of cannon kills in your build area. +KILLCHECKER_INFO2 = §7Only colorable blocks like Wool, Terractotta, Stained Glass and Concrete are counted. +KILLCHECKER_ENABLE = §aKillchecker activated +KILLCHECKER_DISABLE = §cKillchecker deactivated +KILLCHECKER_BOSSBAR = §e§l{0} §7(§e{1}%§7) §e§l{2}§7 cannons + # BlockCounter BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Toggle on/off BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Toggles BlockCounter on BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Toggles BlockCounter off -BLOCK_COUNTER_MESSAGE = §7Counter §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/tick -BLOCK_COUNTER_MESSAGE_SECOND = §7Counter §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/s +BLOCK_COUNTER_MESSAGE = §7Damage §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/tick +BLOCK_COUNTER_MESSAGE_SECOND = §7Damage §8> §e{0} §7Blocks §e{1} §7TNT §e{2} §7Blocks/TNT §e{3} §7Blocks/s BLOCK_COUNTER_ENABLE = §7BlockCounter activated BLOCK_COUNTER_DISABLE = §7BlockCounter deactivated # DepthCounter -DEPTH_COUNTER_COMMAND_ENABLE_HELP = §8/§edepthcounter enable §8- §7Activate the depth-counter -DEPTH_COUNTER_COMMAND_DISABLE_HELP = §8/§edepthcounter disable §8- §7Deactivate the depth-counter -DEPTH_COUNTER_COMMAND_INFO_HELP = §8/§edepthcounter info §8- §7Lists active counting modes -DEPTH_COUNTER_COMMAND_TOGGLE_HELP = §8/§edepthcounter toggle §8<§7CountMode§8> §8- §7Toggle counting modes -DEPTH_COUNTER_ENABLE_MESSAGE = §7You activated the depth-counter -DEPTH_COUNTER_DISABLE_MESSAGE = §7You deactivated the depth-counter -DEPTH_COUNTER_ACTIVE_MESSAGE = §7Active couting modes: §e{0}§8. -DEPTH_COUNTER_MESSAGE = §7Damage §8> §7{0} -DEPTH_COUNTER_HIGHLIGHT = §e -DEPTH_COUNTER_SEPARATOR = §7 §7 -DEPTH_COUNTER_X = X: {0} -DEPTH_COUNTER_Y = Y: {0} -DEPTH_COUNTER_Z = Z: {0} -DEPTH_COUNTER_TNT = §7TNT§8: §e{0} +DEPTH_COUNTER_MESSAGE = §7Depth §8> §7 +DEPTH_COUNTER_COUNT = {0}{1}§8×{2}{3}§8×{4}{5} +DEPTH_COUNTER_HOVER = §7X§8ק7Y§8ק7Z +DEPTH_COUNTER_TNT = §7 TNT§8: §e{0} # TPSLimit TICK_STEP_HELP = §8/§etick step §8<§7Ticks§8> §8- §7Step n ticks @@ -701,7 +466,7 @@ TPSLIMIT_INVALID_FROZEN = §c and '0' # Trace TRACE_RECORD=§aon -TRACE_IDLE=§coff +TRACE_HAS_TRACES=§ehas Traces TRACE_IDLE_SINGLE=§esingle TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8) TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8) @@ -717,7 +482,6 @@ TRACE_MESSAGE_ISOLATE = §aTNT-positions isolated TRACE_MESSAGE_UNISOLATE = §cTNT-positions hidden TRACE_MESSAGE_CLICK_ISOLATE = §eClick to §aisolate§8/§cunisolate TRACE_MESSAGE_DISALLOWED = §cYou are not allowed to use the TNT-Tracer here -TRACE_MESSAGE_NO_REGION = §cYou are not in a region TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Starts recording of all TNT-positions TRACE_COMMAND_HELP_SINGLE = §8/§etrace single §8- §7Starts a single recording of all TNT-positions @@ -757,63 +521,87 @@ TRACE_GUI_POSITION_SOURCE = §7Source§8: §e{0} TRACE_GUI_POSITION_EXPLODED = §7Exploded§8: §e{0} # Loader -LOADER_OFF = §coff LOADER_SETUP = §eSetup LOADER_RUNNING = §aRunning -LOADER_SINGLE_SIDEBAR = §aSingle LOADER_PAUSE = §7Pause LOADER_END = §8Finished -LOADER_MESSAGE_CLEAR = §7Loader cleared -LOADER_MESSAGE_CLEAR_HELP = §cYou have to be in Setup-Mode to clear the Loader -LOADER_MESSAGE_TNT = §eTNT added {0} -LOADER_MESSAGE_INTERACT = §e{0} added {1} +LOADER_MESSAGE_INTERACT=§e{0} added {1} +LOADER_BUTTON_TNT=TNT LOADER_BUTTON_SWITCH=Lever -LOADER_BUTTON_WOOD_BUTTON=Button -LOADER_BUTTON_STONE_BUTTON=Button +LOADER_BUTTON_WOOD_BUTTON=Wooden Button +LOADER_BUTTON_STONE_BUTTON=Stone Button LOADER_BUTTON_PRESSURE_PLATE=Pressure plate LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE=Pressure plate LOADER_BUTTON_TRIPWIRE=Tripwire LOADER_BUTTON_NOTEBLOCK=Noteblock -LOADER_BUTTON_DAYLIGHTSENSOR=Daylightsensor -LOADER_BUTTON_INVALID=Invalid +LOADER_BUTTON_DAYLIGHT_DETECTOR=Daylight Detector +LOADER_BUTTON_COMPARATOR=Comparator +LOADER_BUTTON_REPEATER=Repeater +LOADER_BUTTON_LECTERN=Lectern +LOADER_BUTTON_TRAPDOOR=Trapdoor +LOADER_BUTTON_DOOR=Door +LOADER_BUTTON_FENCEGATE=Fencegate + LOADER_HELP_SETUP=§8/§eloader setup §8- §7Starts recording actions -LOADER_HELP_UNDO=§8/§7loader undo §8- §7Removes last recorded action +LOADER_SETUP_STOP_FIRST=§cPlease stop the current loader first! LOADER_HELP_START=§8/§eloader start §8- §7Playback of previously recorded action -LOADER_HELP_WAIT=§8/§7loader wait §8[§7Ticks§8] - §7Sets wait time between shots -LOADER_HELP_SPEED=§8/§7loader speed §8[§7Ticks§8] - §7Sets wait time between actions LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pauses Loader -LOADER_HELP_RESUME=§8/§7loader resume §8- §7Resumes Loader +LOADER_HELP_GUI=§8/§7loader gui §8- §7Shows Loader gui LOADER_HELP_STOP=§8/§eloader stop §8- §7Stops recording/playback -LOADER_HELP_CLEAR=§8/§eloader clear §8- §7Clears recording -LOADER_HELP_SINGLE=§8/§eloader single §8- §7Starts a single shot -LOADER_HELP_OTHER=§7The loader works with §eIngame§8-§eTicks §7(20 ticks per Second) LOADER_NO_LOADER=§cYou have no Laoder. Create one with /loader setup -LOADER_BACK_SETUP=§7DYour Loader is in Setup again LOADER_NEW=§7Load your cannon and fire it once, to initialise the loader. LOADER_HOW_TO_START=§7Then, execute /§eloader start§7 to start the Loader LOADER_ACTIVE=§7The Loader is now active. LOADER_STOP=§7The Loader has been stopped. LOADER_PAUSED=§7The Loader is now paused. -LOADER_RESUME=§7The Loader is resuming. -LOADER_SINGLE=§7The Loader is shooting once. -LOADER_SMALL_TIME=§cThe wait time is too small -LOADER_NEW_TIME=§7The wait time is now: {0}, before {1} -LOADER_NEW_LOAD_TIME=§7The action wait time is now: {0}, before {1} -LOADER_UNDO=§7Undo succesful. LOADER_PERMS=§cYou are not allowed to use the Loader here -LOADER_GUI_NAME=§eLoader -LOADER_GUI_NEW=§eNew Loader -LOADER_GUI_START=§eStart Loader -LOADER_GUI_PAUSE=§7pause Loader -LOADER_GUI_UNDO=§7Undo last action -LOADER_GUI_WAIT=§7Shot delay -LOADER_GUI_WAIT_LORE=§7Currently: §e{0} -LOADER_GUI_WAIT_TITLE=§7Shot delay -LOADER_GUI_SPEED=§eSpeed -LOADER_GUI_SPEED_LORE=§7Currently: §e{0} -LOADER_GUI_SPEED_TITLE=§7Block placing speed -LOADER_GUI_STOP=§eStop Loader + +LOADER_NOTHING_RECORDED=§cYou have not recorded anything yet! +LOADER_GUI_TITLE=Loader GUI +LOADER_GUI_SHOW_INTERACTIONS=§eShow only Interactions +LOADER_GUI_SHOW_WAITS=§eShow only Waits +LOADER_GUI_SHOW_WAITS_SET_BETWEEN_TNT=§7Wait Time between TNT +LOADER_GUI_SHOW_WAITS_SET_ALL=§7Wait Time all +LOADER_GUI_SHOW_WAITS_TITLE=§7Wait Time +LOADER_GUI_SETTINGS_TITLE=Settings +LOADER_GUI_SETTINGS_BACK=§8Back +LOADER_GUI_SETTINGS_DELETE=§cDelete +LOADER_GUI_WAIT_TITLE=Settings +LOADER_GUI_WAIT_BACK=§8Back + +LOADER_GUI_CLICK_TO_EDIT=§7Klicke zum editieren +LOADER_GUI_ITEM_NAME=§7{0}§8: §e{1} +LOADER_SETTING_NAME=§7{0} +LOADER_SETTING_MODES=§7Modi§8: §e{0} +LOADER_SETTING_POWER=§7Redstone Stärke§8: §e{0} +LOADER_SETTING_TICKS=§7Ticks§8: §e{0} +LOADER_SETTING_REPEATER=§7Repeater§8: §e{0} +LOADER_SETTING_WAIT=§7Wartezeit§8: §e{0} Tick(s) +LOADER_SETTING_WAIT_NAME=Wartezeit +LOADER_SETTING_TICKS_NAME=Ticks +LOADER_SETTING_TICKS_REMOVE_ONE=§c-1 +LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT=§7Shift§8: §c-5 +LOADER_SETTING_TICKS_ADD_ONE=§a+1 +LOADER_SETTING_TICKS_ADD_ONE_SHIFT=§7Shift§8: §a+5 +LOADER_SETTING_TNT_NAME=§cTNT +LOADER_SETTING_TNT_X=§7X§8: §e{0} +LOADER_SETTING_TNT_Y=§7Y§8: §e{0} +LOADER_SETTING_TNT_Z=§7Z§8: §e{0} +LOADER_INTERACTION_NOOP=NOOP +LOADER_INTERACTION_INTERACT=Interagiere +LOADER_INTERACTION_POWERED=Aktiviert +LOADER_INTERACTION_UNPOWERED=Deaktiviert +LOADER_INTERACTION_PAGE_PREV=Vorherige Seite +LOADER_INTERACTION_PAGE_NEXT=Nächste Seite +LOADER_INTERACTION_PAGE=Seite {0} +LOADER_INTERACTION_ACTIVE=Aktiviert +LOADER_INTERACTION_INACTIVE=Deaktiviert +LOADER_INTERACTION_WAIT_FOR=Darauf warten +LOADER_INTERACTION_NO_WAIT_FOR=Nicht darauf warten +LOADER_INTERACTION_OPEN=Geöffnet +LOADER_INTERACTION_CLOSED=Geschlossen + # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Compete with your friends loading your cannon and get information about the cannon LOADTIMER_HELP_START_1=§8/§eloadtimer start §8-§7 Starts the simple Loadtimer @@ -911,6 +699,8 @@ SKULL_GUI_ITEM_NAME = §ePlayer Heads ANVIL_INV_NAME=Player name # StructureVoid STRUCTURE_VOID_COMMAND_HELP=§8/§estructureVoid §8-§7 Receive a StructureVoid +# Dragon Egg +DRAGON_EGG_COMMAND_HELP=§8/§edragonegg §8-§7 Receive a Dragon Egg # NightVision NIGHT_VISION_HELP=§8/§enightvision §8-§7 Toggel nightvision. NIGHT_VISION_OFF=§eNightvision deactivated @@ -997,6 +787,11 @@ REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze REGION_FREEZE_NO_PERMS=§cYou are not allowed to freeze this world REGION_FREEZE_ENABLED=§cRegion frozen REGION_FREEZE_DISABLED=§aRegion thawed +REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items +REGION_ITEMS_NO_PERMS=§cYou are not allowed to toggle items in this world +REGION_ITEMS_ENABLED=§aItems enabled in this region +REGION_ITEMS_DISABLED_GLOBAL=§cItems disabled in this world +REGION_ITEMS_DISABLED=§cItems disabled in this region REGION_PROTECT_HELP=§8/§eprotect §8- §7Protect the region REGION_PROTECT_DISABLE=§cProtection disabled REGION_PROTECT_ENABLE=§aProtection enabled @@ -1053,6 +848,8 @@ REGION_TB_DONE=§7Dummy reset REGION_TB_ERROR=§cError resetting the dummy REGION_TB_NO_PERMS=§cYou are not allowed to reset the dummy here REGION_TB_NO_REGION=§cYou are currently not in any region +REGION_TB_NO_SCHEMSHARING=§cYou currently cannot share schematics until {0}. +REGION_TB_NO_SCHEMRECEIVING=§cThe Owner of this build server cannot receive any schematics until {0}. REGION_TNT_HELP=§8/§etnt §8- §7Change the TNT behaviour REGION_TNT_HELP_MODE=§8/§etnt §8[§7Mode§8] §8- §7Set TNT behaviour to a given mode REGION_TNT_ON=§aTNT-Damage activated diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 7320b18d..cb1184a8 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -37,12 +37,16 @@ SCOREBOARD_TPS_FROZEN = §e Eingefroren SCOREBOARD_TRACE_TICKS = Ticks +SCOREBOARD_TECHHIDER = TechHider§8: §aAn +SCOREBOARD_XRAY = XRay§8: §aAn + # Flags FLAG_COLOR = Color FLAG_TNT = TNT FLAG_FIRE = Fire FLAG_FREEZE = Freeze FLAG_PROTECT = Protect +FLAG_ITEMS = Items FLAG_FIRE_ALLOW = §can FLAG_FIRE_DENY = §aaus @@ -57,6 +61,9 @@ FLAG_TNT_ALLOW = §aan FLAG_TNT_DENY = §caus FLAG_TNT_ONLY_TB = §7Kein §eBaurahmen +FLAG_ITEMS_ACTIVE = §aan +FLAG_ITEMS_INACTIVE = §caus + FLAG_COLOR_WHITE = §fWeiß FLAG_COLOR_ORANGE = §6Orange FLAG_COLOR_MAGENTA = §dMagenta @@ -157,6 +164,12 @@ COUNTINGWAND_MESSAGE_LCLICK = §7Zweite Position bei: §8[§7{0}§8, §7{1}§8, COUNTINGWAND_MESSAGE_VOLUME = §e{0} COUNTINGWAND_MESSAGE_DIMENSION = §e{0}§8, §e{1}§8, §e{2} +# Design Endstone +DESIGN_ENDSTONE_COMMAND_HELP = §8/§edesign endstone §8- §7Zeige wo Endstone ist +DESIGN_ENDSTONE_REGION_ERROR = §cDiese Region hat keinen Baubereich +DESIGN_ENDSTONE_ENABLE = §aEndstone ist aktiviert +DESIGN_ENDSTONE_DISABLE = §cEndstone ist deaktiviert + # Detonator DETONATOR_LOC_REMOVE = §e{0} entfernt DETONATOR_LOC_ADD = §e{0} hinzugefügt @@ -213,294 +226,45 @@ GUI_EDITOR_ITEM_CLOSE=§eSchließen GUI_EDITOR_TITLE_MORE=Item auswählen # Script -## Errors -SCRIPT_SLEEP_ERROR = §cFüge ein sleep in dein Script ein -SCRIPT_COMMAND_ERROR_UNKNOWN_VAR = §cUnbekannte Variable {0} -SCRIPT_COMMAND_ERROR_EXPRESSION = §cExpression fehler in: {0} -SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR = §cDas erste Argument fehlt und sollte eine Variable sein -SCRIPT_COMMAND_ERROR_FIRST_ARG_NONUMER = §cDas erste Argument fehlt und sollte eine Zahl sein -SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR_OR_VALUE = §cDas erste Argument fehlt und sollte eine Variable oder ein Wert sein -SCRIPT_COMMAND_ERROR_FIRST_ARG_NOJUMPPOINT = §cDas erste Argument fehlt und sollte ein Jump-Point sein -SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR = §cDas zweite Argument fehlt und sollte eine Variable sein -SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE = §cDas zweite Argument fehlt und sollte ein Wert sein -SCRIPT_COMMAND_ERROR_SECOND_ARG_NOJUMPPOINT = §cDas dritte Argument fehlt und sollte ein Jump-Point sein -SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR = §cDas dritte Argument fehlt und sollte eine Variable sein -SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVALUE = §cDas dritte Argument fehlt und sollte ein Wert sein -SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR_OR_NUMBER = §cDas dritte Argument fehlt und sollte eine Variable/Zahl sein -SCRIPT_COMMAND_ERROR_FOURTH_ARG_NOVALUE = §cDas vierte Argument fehlt und sollte ein Wert sein - -SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE = §cNur Booleans können verglichen werden -SCRIPT_COMMAND_ERROR_NUMBER_COMPARE = §cNur Zahlen können verglichen werden - -SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED = §cNur Strings können verwendet werden -SCRIPT_COMMAND_ERROR_ONLY_NUMBERS_ALLOWED = §cNur Zahlen können verwendet werden - -SCRIPT_COMMAND_ERROR_UNKNOWN_OPERATION = §cUnbekannte Operation: {0} - -## Commands -SCRIPT_COMMAND_ARITHMETIC_ADD_ERROR = §cNur Zahlen können addiert werden -SCRIPT_COMMAND_ARITHMETIC_DIV_ERROR = §cNur Zahlen können dividiert werden -SCRIPT_COMMAND_ARITHMETIC_MUL_ERROR = §cNur Zahlen können multipliziert werden -SCRIPT_COMMAND_ARITHMETIC_SUB_ERROR = §cNur Zahlen können subtrahiert werden -SCRIPT_COMMAND_ARITHMETIC_POW_ERROR = §cNur Zahlen können potenziert werden -SCRIPT_COMMAND_ARITHMETIC_MOD_ERROR = §cNur ganze Zahlen können für modulo verwendet werden -SCRIPT_COMMAND_ARITHMETIC_BIT_AND_ERROR = §cNur ganze Zahlen und booleans können für und verwendet werden -SCRIPT_COMMAND_ARITHMETIC_BIT_OR_ERROR = §cNur ganze Zahlen und booleans können für oder verwendet werden -SCRIPT_COMMAND_ARITHMETIC_BIT_XOR_ERROR = §cNur ganze Zahlen und booleans können für xor verwendet werden - -SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_1 = §eceil §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_2 = §eceil §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> §8<§7Variable§8|§7Wert§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_3 = Aufrunden der zweiten Zahl und schreibt es in die erste oder aufrunden der zweiten Zahl auf die Nachkommastellenanzahl aus der dritten Zahl und schreibt es in die erste. -SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_ERROR_1 = §cNur Fließ-Komma-Zahlen können aufgerundet werden -SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_ERROR_2 = §cEs kann nur auf ganze Nachkommastellen gerundet werden - -SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_1 = §efloor §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_2 = §efloor §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> §8<§7Variable§8|§7Wert§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_HELP_3 = Abrunden der zweiten Zahl und schreibt es in die erste oder abrunden der zweiten Zahl auf die Nachkommastellenanzahl aus der dritten Zahl und schreibt es in die erste. -SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_ERROR_1 = §cNur Fließ-Komma-Zahlen können abgerundet werden -SCRIPT_COMMAND_ARITHMETIC_OTHER_FLOOR_ERROR_2 = §cEs kann nur auf ganze Nachkommastellen gerundet werden - -SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_1 = §eround §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_2 = §eround §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> §8<§7Variable§8|§7Wert§8> -SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_HELP_3 = Runden der zweiten Zahl und schreibt es in die erste oder runden der zweiten Zahl auf die Nachkommastellenanzahl aus der dritten Zahl und schreibt es in die erste. -SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_ERROR_1 = §cNur Fließ-Komma-Zahlen können gerundet werden -SCRIPT_COMMAND_ARITHMETIC_OTHER_ROUND_ERROR_2 = §cEs kann nur auf ganze Nachkommastellen gerundet werden - -SCRIPT_COMMAND_IO_ECHO_HELP_1 = §eecho §8<§7Wert§8> -SCRIPT_COMMAND_IO_ECHO_HELP_2 = §7Schreibe etwas dem Spieler. Wenn kein Wert angegeben wurde ist die Nachricht leer. -SCRIPT_COMMAND_IO_ECHO_MESSAGE = §f{0} - -SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_1 = §eechoactionbar §8<§7Wert§8> -SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_2 = §7Schreibe etwas dem Spieler in der ActionBar. Wenn kein Wert angegeben wurde ist die Nachricht leer. - -SCRIPT_COMMAND_IO_INPUT_HELP_1 = §einput §8<§7Variable§8> §8<§7Text§8> -SCRIPT_COMMAND_IO_INPUT_HELP_2 = §7Fordere eine Eingabe von dem Spieler, welche in die Variable geschrieben wird. Der Text ist optional. - -SCRIPT_COMMAND_STRING_INSERT_HELP_1 = §einsert §8<§7Variable§8> §8<§7Variable§8> §8<§7Zahl§8> -SCRIPT_COMMAND_STRING_INSERT_HELP_2 = §einsert §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8> §8<§7Zahl§8> -SCRIPT_COMMAND_STRING_INSERT_HELP_3 = Füge etwas in einen String an einer Stelle ein. Die Zahl ist für die Position und die Variable davor für was. Schreibe optional dies in eine neue oder andere Variable. - -SCRIPT_COMMAND_STRING_REMOVE_HELP_1 = §eremove §8<§7Variable§8> §8<§7Von Variable§8> -SCRIPT_COMMAND_STRING_REMOVE_HELP_2 = §eremove §8<§7Variable§8> §8<§7Variable§8> §8<§7Von Variable§8> -SCRIPT_COMMAND_STRING_REMOVE_HELP_3 = Lösche eine Zeichenkette aus dem Ursprung. Dies ersetzt nicht nur die erste Stelle sondern alle. - -SCRIPT_COMMAND_STRING_REPLACE_HELP_1 = §ereplace §8<§7Variable§8> §8<§7Von Variable§8> §8<§7Zu Variable§8> -SCRIPT_COMMAND_STRING_REPLACE_HELP_2 = §ereplace §8<§7Variable§8> §8<§7Variable§8> §8<§7Von Variable§8> §8<§7Zu Variable§8> -SCRIPT_COMMAND_STRING_REPLACE_HELP_3 = Ersetzte eine Zeichenkette aus dem Ursprung mit einer neuen Zeichenkette. Dies ersetzt nicht nur die erste Stelle sondern alle. - -SCRIPT_COMMAND_STRING_SUBSTRING_HELP_1 = §esubstring §8<§7Variable§8> §8<§7Zahl§8> -SCRIPT_COMMAND_STRING_SUBSTRING_HELP_2 = §esubstring §8<§7Variable§8> §8<§7Variable§8> §8<§7Zahl§8> -SCRIPT_COMMAND_STRING_SUBSTRING_HELP_3 = Kürze einen String entweder vorne oder hinter, je nachdem ob die Zahl positiv (vorne) oder negativ (hinten) ist. - -SCRIPT_COMMAND_VARIABLE_CONST_HELP_1 = §econst §8<§7Variable§8> §8[§7Value§8(§7s§8)§8] -SCRIPT_COMMAND_VARIABLE_CONST_HELP_2 = Schreibt in eine Konstante einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text. - -SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_1 = §econvert §8<§7Variable§8> §8<§7Value§8> -SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_2 = Konvertiere den Value zu 'number' wenn es eine Zahl ist, oder zu 'boolean' bei 'true' oder 'false' und behalte 'text' bei wenn nichts zutrifft. - -SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_1 = §eglobal §8<§7Variable§8> §8[§7Value§8(§7s§8)§8] -SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_2 = Schreibt in eine Variable einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text. - -SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_1 = §eunglobal §8<§7Variable§8> -SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_2 = Lösche eine Globale variable. - -SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_1 = §eunvar §8<§7Variable§8> -SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_2 = Lösche eine Locale variable. - -SCRIPT_COMMAND_VARIABLE_VAR_HELP_1 = §evar §8<§7Variable§8> §8[§7Value§8(§7s§8)§8] -SCRIPT_COMMAND_VARIABLE_VAR_HELP_2 = Schreibt in eine Variable einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text. - -SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_1 = §egetmaterial §8<§7Variable§8> §8<§7Zahl§8> §8<§7Zahl§8> §8<§7Zahl§8> -SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_2 = Schreibt das material von einem Block in der Welt in die Variable. - -SCRIPT_COMMAND_WORLD_SETMATERIAL_HELP_1 = §esetmaterial §8<§7Variable§8> §8<§7Zahl§8> §8<§7Zahl§8> §8<§7Zahl§8> -SCRIPT_COMMAND_WORLD_SETMATERIAL_HELP_2 = Setzt an einem Block in der Welt das Material der ersten Variable. - -SCRIPT_COMMAND_EXIT_HELP_1 = §eexit -SCRIPT_COMMAND_EXIT_HELP_2 = Beendet das ausführen des Scripts. - -SCRIPT_COMMAND_IF_HELP_1 = §eif §8<§7true/false§8> §8<§7jump-point§8> -SCRIPT_COMMAND_IF_HELP_2 = §eif §8<§7true/false§8> §8<§7jump-point§8> §8<§7jump-point§8> -SCRIPT_COMMAND_IF_HELP_3 = §7Springe zu ersten Stelle, wenn der Wert true ist. Oder zu dem zweiten, wenn dies nicht der fall ist. - -SCRIPT_COMMAND_JUMP_HELP_1 = §ejump §8<§7Jump-Point§8> -SCRIPT_COMMAND_JUMP_HELP_2 = §7Springe zu einer anderen Zeile. Hierbei ist ein Jump-Point eine Zeile mit §8'§7.§8'§7 vor. -SCRIPT_COMMAND_JUMP_ERROR = §cDer Jump-Point ({0}) ist nicht definiert. - -SCRIPT_COMMAND_CALL_HELP_1 = §ecall §8<§7Jump-Point§8> -SCRIPT_COMMAND_CALL_HELP_2 = §7Springe zu einer anderen Zeile. Hierbei ist ein Jump-Point eine Zeile mit §8'§7.§8'§7 vor. Hierbei wird auf den ReturnStack die jetzige Zeile geschrieben, dahin kann man wieder mit 'return' zurück springen. -SCRIPT_COMMAND_CALL_ERROR = §cDer Jump-Point ({0}) ist nicht definiert. - -SCRIPT_COMMAND_RETURN_HELP_1 = §ereturn -SCRIPT_COMMAND_RETURN_HELP_2 = §7Springe zum letzten 'call' Befehl. -SCRIPT_COMMAND_RETURN_ERROR = §cEs wurde kein 'call' Befehl ausgeführt - -SCRIPT_COMMAND_SLEEP_HELP_1 = §esleep §8<§7Time§8> -SCRIPT_COMMAND_SLEEP_HELP_2 = Pausiert das Ausführen des Scripts. Das erste Argument ist in GameTicks. -SCRIPT_COMMAND_SLEEP_ERROR = §cDie Zeit muss eine Zahl großer 0 sein. - -## GUI -SCRIPT_GUI_ITEM_NAME = §eScript Hilfe - ## CustomScript -SCRIPT_HOTKEY_ITEM_NAME = §7Hotkey§8: §e{0} §8-§7 {1} -SCRIPT_EVENT_ITEM_NAME = §7Event§8: §e{0} §8-§7 {1} -SCRIPT_COMMAND_ITEM_NAME = §7Command§8: §e{0} +SCRIPT_HOTKEY_ITEM_NAME = §7Hotkey§8: §e{0} +SCRIPT_EVENT_ITEM_NAME = §7Event§8: §e{0} +SCRIPT_COMMAND_ITEM_NAME = §7Befehl§8: §e/{0} +SCRIPT_ERROR_ONLY_IN_GLOBAL=§cDieses Skript kann nur als globales Skript ausgeführt werden ## Script Menu GUI SCRIPT_MENU_GUI_ITEM_LORE_1 = §7Klicke zum rausnehmen -SCRIPT_MENU_GUI_ITEM_LORE_2 = §7Shift Klicke zum kopieren -SCRIPT_MENU_GUI_NAME = §eScript Commands {0}{1}§7% +SCRIPT_MENU_GUI_ITEM_LORE_2 = §7Shiftklick zum kopieren +SCRIPT_MENU_GUI_ITEM_LORE_3 = §7Rechtsklick zum editieren +SCRIPT_MENU_GUI_ITEM_LORE_4 = §7Mittelklick zum anschauen +SCRIPT_MENU_GUI_NAME = §eSkript-Menü SCRIPT_MENU_GUI_ITEM_ADD_NAME = §eHinzufügen SCRIPT_MENU_GUI_ITEM_ADD_LORE = §7Klicke mit einem Buch zum hinzufügen +SCRIPT_DEPRECATED=§cDie Funktion §e{0}§c ist veraltet und wird demnächst entfernt. Bitte benutze §e{1}§c. -SCRIPT_MENU_GUI_DUPLICATE_COMMAND = §cCommand '{0}' bereits definiert -SCRIPT_MENU_GUI_UNKNOWN_EVENT = §cEvent '{0}' ist nicht definierbar -SCRIPT_MENU_GUI_LIMIT = §cScript-Buch Limit erreicht +# Shield Printing +SHIELD_PRINTING_HELP_START = §8/§eshieldprinting start §8- §7Starte das Schild drucken +SHIELD_PRINTING_HELP_COPY = §8/§eshieldprinting copy §8- §7Kopiert die Schilder +SHIELD_PRINTING_HELP_APPLY = §8/§eshieldprinting apply §8- §7Wendet die Schilder an +SHIELD_PRINTING_HELP_STOP = §8/§eshieldprinting stop §8- §7Stoppt das Schild drucken +SHIELD_PRINTING_HELP_STEP_1 = §81. §7Füge die Schematic in die Welt ein +SHIELD_PRINTING_HELP_STEP_2 = §82. §7Starte das Schild drucken mit §8/§eshieldprinting start +SHIELD_PRINTING_HELP_STEP_3 = §83. §7Warte bis alle Schilde ausgefahren sind +SHIELD_PRINTING_HELP_STEP_4 = §84. §7Editiere die Schilde wenn nötig +SHIELD_PRINTING_HELP_STEP_5 = §85. §7Kopiere das gedruckte mit §8/§eshieldprinting copy +SHIELD_PRINTING_HELP_STEP_6 = §86. §7Füge die originale Schematic wieder ein +SHIELD_PRINTING_HELP_STEP_7 = §87. §7Wende das gedruckte mit §8/§eshieldprinting apply§7 an -## ScriptCommand -SCRIPT_COMMAND_HELP = §8/§escript §8- §7Öffnet die ScriptGUI -SCRIPT_COMMAND_HELP_MENU = §8/§escript menu §8- §7Öffnet die ScriptMenuGUI für Custom Command bauübergreifend +SHIELD_PRINTING_NO_REGION = §cDu bist in keiner Region. +SHIELD_PRINTING_NOT_RUNNING = §cShield printing ist nicht aktiv. +SHIELD_PRINTING_DISALLOWED = §cDu darfst Shield printing nicht benutzen. +SHIELD_PRINTING_BOSSBAR = §fBewegungen: {0} +SHIELD_PRINTING_BOSSBAR_COPIED = §fBewegungen: {0} Kopiert: {1} -## Script GUI -SCRIPT_GUI_NAME = Script Elements -SCRIPT_GUI_COMMAND_CHAT = §eScript Command§8: §e{0} - -SCRIPT_GUI_CUSTOM_HOTKEYS = §eCustom Hotkeys -SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_1 = §7Schreibe§8: §e#!HOTKEY 'Char' -SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_2 = §7am Anfang eines Skript Buches, um einen benutzerdefinierten Hotkey zu verwenden. Das 'Char' kann ein beliebiges Zeichen zwischen '§eA§7' und '§eZ§7' sowie '§e0§7' und '§e9§7' sein. Während der Ausführung sind zwei Variablen verfügbar: §epressed§7, §ereleased§7 -SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_3 = §7Sie können dem Hotkey Modifikatoren wie "SHIFT", "CTRL", "ALT" oder "META" hinzufügen. §7Beispiel: §e#!HOTKEY SHIFT+A -SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_4 = §7 -SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_5 = §cDies kann nur in Verbindung mit den Fabric-Mod: §eAdvancedScripts §7runterladbar unter §ehttps://steamwar.de/downloads §cverwendet werden. - -SCRIPT_GUI_CUSTOM_COMMANDS = §eCustom Commands -SCRIPT_GUI_CUSTOM_COMMANDS_LORE_1 = §7Schreibe§8: §e#!CMD 'COMMAND' -SCRIPT_GUI_CUSTOM_COMMANDS_LORE_2 = §7an den Anfang eines Script Buches um ein Custom Command zu nutzen. Der Befehl startet immer mit §e/§7 und kann dann so aufgebaut sein wie du willst. Alles was in Spitzen Klammern steht '§e<>§7' wird als Parameter und somit als Variable gewertet. Parameter, welche in runden Klammern stehen sind Optional. Einfache Texte als Parameter bekommen eine gleichnamige Variable mit true/false als Wert je nachdem ob dieser angegeben wurde oder nicht - -SCRIPT_GUI_CUSTOM_EVENTS = §eCustom Events -SCRIPT_GUI_CUSTOM_EVENTS_LORE_1 = §7Schreibe§8: §e#!EVENT 'EventName' -SCRIPT_GUI_CUSTOM_EVENTS_LORE_2 = §7an den Anfang eines Script Buches um ein Custom Event zu nutzen. Jedes Event kann durch 'var cancel true' gecancelt werden. Hinter dem Event Namen stehen die Variablen, welche im Script durch das Event nutztbar sind. -SCRIPT_GUI_CUSTOM_EVENTS_LORE_3 = §7Nutzbare Events sind: -SCRIPT_GUI_CUSTOM_EVENTS_LORE_4 = §eFF -SCRIPT_GUI_CUSTOM_EVENTS_LORE_5 = §ePlaceBlock §8-§7 blockX, blockY, blockZ, blockType -SCRIPT_GUI_CUSTOM_EVENTS_LORE_6 = §eBreakBlock §8-§7 blockX, blockY, blockZ, blockType -SCRIPT_GUI_CUSTOM_EVENTS_LORE_7 = §eRightClick §8-§7 blockInHand, action, handType, -SCRIPT_GUI_CUSTOM_EVENTS_LORE_8 = §7 hasBlock §8[§7blockX, blockY, blockZ, blockFace§8]§e* -SCRIPT_GUI_CUSTOM_EVENTS_LORE_9 = §eLeftClick §8-§7 blockInHand, action, handType, -SCRIPT_GUI_CUSTOM_EVENTS_LORE_10 = §7 hasBlock §8[§7blockX, blockY, blockZ, blockFace§8]§e* -SCRIPT_GUI_CUSTOM_EVENTS_LORE_11 = §eTNTSpawn -SCRIPT_GUI_CUSTOM_EVENTS_LORE_12 = §eTNTExplode §8-§7 x, y, z -SCRIPT_GUI_CUSTOM_EVENTS_LORE_13 = §eTNTExplodeInBuild §8-§7 x, y, z -SCRIPT_GUI_CUSTOM_EVENTS_LORE_14 = §eSelfJoin §8-§7 x, y, z, playerName -SCRIPT_GUI_CUSTOM_EVENTS_LORE_15 = §eSelfLeave §8-§7 x, y, z, playerName -SCRIPT_GUI_CUSTOM_EVENTS_LORE_16 = §eDropItem §8-§7 material, x, y, z -SCRIPT_GUI_CUSTOM_EVENTS_LORE_17 = §eEntityDeath §8-§7 entityType, x, y, z -SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1 = §e* §8-§7 Alles in den Klammern ist nur gesetzt, wenn die Variable davor auf §etrue§7 gesetzt ist. - -SCRIPT_GUI_OTHER = §eOther -SCRIPT_GUI_OTHER_LORE_1 = §7Kommentare fangen mit §e#§7 an. -SCRIPT_GUI_OTHER_LORE_2 = §7Jump_Points fangen mit §e.§7 an. -SCRIPT_GUI_OTHER_LORE_3 = §7Einen Variablennamen, der in '§e{}§7' eingeschlossen ist wird durch seinen Wert ersetzt. Eine Variable kann mit den Präfixen '§econst.§7' oder '§elocal.§7' oder '§eglobal.§7' versehen werden. -SCRIPT_GUI_OTHER_LORE_4 = §7Dabei gilt: -SCRIPT_GUI_OTHER_LORE_5 = §7- Lokalevariablen sind nur in dem Script-Buch verfügbar. -SCRIPT_GUI_OTHER_LORE_6 = §7- Gloablevariablen sind in jedem Script-Buch verfügbar. -SCRIPT_GUI_OTHER_LORE_7 = §7- Konstantevariablen sind Variablen vom Server (z.B. Spielername, TPS usw.) -SCRIPT_GUI_OTHER_LORE_8 = §7Eine Variable kann mit den Appendixen '§e.length§7' oder '§e.type§7' oder '§e.isset§7' versehen werden. -SCRIPT_GUI_OTHER_LORE_9 = §7Dabei gilt: -SCRIPT_GUI_OTHER_LORE_10 = §7- Length gibt die Länge der variable als Zahl zurück. -SCRIPT_GUI_OTHER_LORE_11 = §7- Type gibt den typen (number, floating number, text oder boolean) als Text zurück. -SCRIPT_GUI_OTHER_LORE_12 = §7- Isset gibt als boolean zurück, ob die Variable existiert. -SCRIPT_GUI_OTHER_LORE_13 = §7Mathematische sowie logische Operationsvorgänge können in '§e{}§7' angegeben werden. -SCRIPT_GUI_OTHER_LORE_14 = §7Dabei gilt: -SCRIPT_GUI_OTHER_LORE_15 = §7- Rechenoperatoren: §e+ * - /§7 sowie §e%§7 für Modulo -SCRIPT_GUI_OTHER_LORE_16 = §7- Logische Operatoren: §e==§7; §e!=§7; §e<=§7; §e>=§7; §e<§7; §e>§7; §e&&§7; §e||§7 (Dies ist das Zeichen für oder) -SCRIPT_GUI_OTHER_LORE_17 = §7- Bitweise Operatoren: §e&§7; §e|§7; §e^ -SCRIPT_GUI_OTHER_LORE_18 = §7- Shift Operatoren: §e<<§7; §e>>§7; §e>>>§7 - -SCRIPT_GUI_COMMAND_NAME = §7Command: §e{0} - -SCRIPT_GUI_CUSTOM_VARIABLES = §eCustom Variables - -SCRIPT_GUI_CONSTANT_TIME_NAME = §7Constant §etime -SCRIPT_GUI_CONSTANT_TIME_LORE = §7Formattierte Uhrzeit - -SCRIPT_GUI_CONSTANT_TICKS_NAME = §7Constant §eticks -SCRIPT_GUI_CONSTANT_TICKS_LORE = §7Ticks seit dem Serverstart - -SCRIPT_GUI_CONSTANT_TRACE_NAME = §7Constant §etrace -SCRIPT_GUI_CONSTANT_TRACE_LORE = §etrue§7 wenn gerade der Tracer an ist. - -SCRIPT_GUI_CONSTANT_AUTO_TRACE_NAME = §7Constant §eautotrace -SCRIPT_GUI_CONSTANT_AUTO_TRACE_LORE = §etrue§7 wenn gerade der AutoTracer an ist. - -SCRIPT_GUI_CONSTANT_TRACE_STATUS_NAME = §7Constant §etrace_status -SCRIPT_GUI_CONSTANT_TRACE_STATUS_LORE = §7Ein Wert von: §eOFF§8, §eIDLE§8, §eIDLE_AUTO_EXPLODE§8, §eIDLE_AUTO_IGNITE§8, §eIDLE_SINGLE - -SCRIPT_GUI_CONSTANT_TRACE_TIME_NAME = §7Constant §etrace_time -SCRIPT_GUI_CONSTANT_TRACE_TIME_LORE = §e0§7 wenn gerade kein TNT getraced wird, ansonsten die Zeit in Ticks seit dem Start des Tracers. - -SCRIPT_GUI_CONSTANT_LOADER_STATUS_NAME = §7Constant §eloader_status -SCRIPT_GUI_CONSTANT_LOADER_STATUS_LORE = §7Ein Wert von: §eOFF§8, §eSETUP§8, §eRUNNING§8, §eSINGLE§8, §ePAUSE§8, §eEND - -SCRIPT_GUI_CONSTANT_TNT_NAME = §7Constant §etnt -SCRIPT_GUI_CONSTANT_TNT_LORE = §etrue§7 wenn TNT nicht ausgeschaltet ist. - -SCRIPT_GUI_CONSTANT_ONLY_TB_NAME = §7Constant §etnt_onlytb -SCRIPT_GUI_CONSTANT_ONLY_TB_LORE = §etrue§7 wenn TNT Nur Testblock an ist. - -SCRIPT_GUI_CONSTANT_FREEZE_NAME = §7Constant §efreeze -SCRIPT_GUI_CONSTANT_FREEZE_LORE = §etrue§7 wenn Freeze nicht ausgeschaltet ist. - -SCRIPT_GUI_CONSTANT_FIRE_NAME = §7Constant §efire -SCRIPT_GUI_CONSTANT_FIRE_LORE = §etrue§7 wenn Fire nicht ausgeschaltet ist. - -SCRIPT_GUI_CONSTANT_PROTECT_NAME = §7Constant §eprotect -SCRIPT_GUI_CONSTANT_PROTECT_LORE = §etrue§7 wenn Protect angeschaltet ist. - -SCRIPT_GUI_CONSTANT_X_NAME = §7Constant §ex -SCRIPT_GUI_CONSTANT_X_LORE = §ex§7 Position des Spielers. - -SCRIPT_GUI_CONSTANT_Y_NAME = §7Constant §ey -SCRIPT_GUI_CONSTANT_Y_LORE = §ey§7 Position des Spielers. - -SCRIPT_GUI_CONSTANT_Z_NAME = §7Constant §ez -SCRIPT_GUI_CONSTANT_Z_LORE = §ez§7 Position des Spielers. - -SCRIPT_GUI_CONSTANT_NAME_NAME = §7Constant §ename -SCRIPT_GUI_CONSTANT_NAME_LORE = §eDisplay§7 Name des Spielers. - -SCRIPT_GUI_CONSTANT_SNEAK_NAME = §7Constant §esneaking -SCRIPT_GUI_CONSTANT_SNEAK_LORE = §etrue§7 wenn der Spieler gerade sneakt. - -SCRIPT_GUI_CONSTANT_SPRINTING_NAME = §7Constant §esprinting -SCRIPT_GUI_CONSTANT_SPRINTING_LORE = §etrue§7 wenn der Spieler gerade rennt. - -SCRIPT_GUI_CONSTANT_SLOT_NAME = §7Constant §eslot -SCRIPT_GUI_CONSTANT_SLOT_LORE = §e0-8§7 für den ausgewählten slot. - -SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_NAME = §7Constant §eslotmaterial -SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_LORE = §eMaterial§7 des Items im Slot - -SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_NAME = §7Constant §eoffhandmaterial -SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_LORE = §eMaterial§7 des Items in der Off Hand - -SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_NAME = §7Constant §ematerialname -SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE = §eName§7 des Items im Slot - -SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME = §7Constant §eoffmaterialname -SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE = §eName§7 des Items in der Off Hand - -SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME = §7Constant §eregion_type -SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE = §eRegionstype§7 der jetztigen Region - -SCRIPT_GUI_CONSTANT_REGION_NAME_NAME = §7Constant §eregion_name -SCRIPT_GUI_CONSTANT_REGION_NAME_LORE = §eRegionsname§7 der jetztigen Region - -SCRIPT_GUI_CONSTANT_TPS_NAME = §7Constant §etps -SCRIPT_GUI_CONSTANT_TPS_LORE = §etps§7 vom Server - -SCRIPT_GUI_CONSTANT_TPS_LIMIT_NAME = §7Constant §etps_limit -SCRIPT_GUI_CONSTANT_TPS_LIMIT_LORE = §etps_limit§7 vom Server +SHIELD_PRINTING_START = §aShield printing wurde gestartet. +SHIELD_PRINTING_COPY = §aSchilde wurden kopiert. +SHIELD_PRINTING_APPLY = §aSchilde wurden angewendet. +SHIELD_PRINTING_STOP = §aShield printing wurde gestoppt. # Unsign Book UNSIGN_HELP=§8/§eunsign §8- §7Mache ein Buch beschreibbar @@ -568,7 +332,6 @@ SIMULATOR_GUI_TNT_GROUP_LORE_1 = §7Elementanzahl§8: §e{0} SIMULATOR_GUI_TNT_DISABLED = §cDisabled SIMULATOR_GUI_NAME = Kanonensimulator SIMULATOR_GUI_DELETE = §cTNT löschen -SIMULATOR_GUI_START = §eStarten SIMULATOR_GUI_AUTO_TRACE = §eAutoTrace§8: §7{0} SIMULATOR_GUI_MOVE_ALL = §eAlle Verschieben @@ -624,30 +387,26 @@ INVENTORY_FILL_INFO = §7Hilft dir, Behälter zu füllen, indem du sie beim snea INVENTORY_FILL_ENABLE = §aInventoryFiller activated INVENTORY_FILL_DISABLE = §cInventoryFiller deactivated +# Killchecker +KILLCHECKER_HELP_ENABLE = §8/§ekillchecker enable §8- §7Aktiviert Killchecker / Berechnet kills neu +KILLCHECKER_HELP_DISABLE = §8/§ekillchecker disable §8- §7Deaktiviert Killchecker +KILLCHECKER_INFO = §7Zeigt Überlappungen der Kanonen Kills im Baubereich an. +KILLCHECKER_INFO2 = §7Nur farbige Blöcke wie Wolle, Terracotta, Stained Glass und Concrete wird gezählt. +KILLCHECKER_ENABLE = §aKillchecker aktiviert +KILLCHECKER_DISABLE = §cKillchecker deaktiviert +KILLCHECKER_BOSSBAR = §e§l{0} §7(§e{1}%§7) §e§l{2}§7 Kanonnen + # BlockCounter BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Schalte den BlockCounter aus -BLOCK_COUNTER_MESSAGE = §7Counter §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick -BLOCK_COUNTER_MESSAGE_SECOND = §7Counter §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s +BLOCK_COUNTER_MESSAGE = §7Schaden §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick +BLOCK_COUNTER_MESSAGE_SECOND = §7Schaden §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s BLOCK_COUNTER_ENABLE = §7BlockCounter angemacht BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht # DepthCounter -DEPTH_COUNTER_COMMAND_ENABLE_HELP = §8/§edepthcounter enable §8- §7Aktiviere den Tiefenzähler -DEPTH_COUNTER_COMMAND_DISABLE_HELP = §8/§edepthcounter disable §8- §7Deaktiviere den Tiefenzähler -DEPTH_COUNTER_COMMAND_INFO_HELP = §8/§edepthcounter info §8- §7Zähle aktive Zählmodi auf -DEPTH_COUNTER_COMMAND_TOGGLE_HELP = §8/§edepthcounter toggle §8<§7CountMode§8> §8- §7Stelle einzelne Zählmodi ein -DEPTH_COUNTER_ENABLE_MESSAGE = §7Du hast den Tiefenzähler aktiviert. -DEPTH_COUNTER_DISABLE_MESSAGE = §7Du hast den Tiefenzähler deaktiviert. -DEPTH_COUNTER_ACTIVE_MESSAGE = §7Aktive Zählmodi: §e{0}§8. -DEPTH_COUNTER_MESSAGE = §7Schaden §8> §7{0} -DEPTH_COUNTER_HIGHLIGHT = §e -DEPTH_COUNTER_SEPARATOR = §7 §7 -DEPTH_COUNTER_X = X: {0} -DEPTH_COUNTER_Y = Y: {0} -DEPTH_COUNTER_Z = Z: {0} -DEPTH_COUNTER_TNT = §7TNT§8: §e{0} +DEPTH_COUNTER_MESSAGE = §7Tiefe §8> §7 # TPSLimit TICK_STEP_HELP = §8/§etick step §8<§7Ticks§8> §8- §7Spule n Ticks vor @@ -674,7 +433,7 @@ TPSLIMIT_INVALID_FROZEN = §c und '0' # Trace TRACE_RECORD=§aan -TRACE_IDLE=§caus +TRACE_HAS_TRACES=§ehat Traces TRACE_IDLE_SINGLE=§esingle TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8) TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8) @@ -690,7 +449,6 @@ TRACE_MESSAGE_ISOLATE = §aTNT-Positionen isoliert TRACE_MESSAGE_UNISOLATE = §cTNT-Positionen ausgeblendet TRACE_MESSAGE_CLICK_ISOLATE = §eKlicken zum §aisolieren§8/§causblenden TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen -TRACE_MESSAGE_NO_REGION = §cDu bist in keiner Region TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen TRACE_COMMAND_HELP_SINGLE = §8/§etrace single §8- §7Startet eine einzelne Aufnahme aller TNT-Positionen @@ -730,63 +488,87 @@ TRACE_GUI_POSITION_SOURCE = §7Ursprung§8: §e{0} TRACE_GUI_POSITION_EXPLODED = §7Explodiert§8: §e{0} # Loader -LOADER_OFF = §caus LOADER_SETUP = §eEinrichtung LOADER_RUNNING = §aLaufend -LOADER_SINGLE_SIDEBAR = §aEiner LOADER_PAUSE = §7Pausiert LOADER_END = §8Beendet -LOADER_MESSAGE_CLEAR = §7Loader gecleart -LOADER_MESSAGE_CLEAR_HELP = §cDu must im Setup-Modus sein um den Loader zu clearen -LOADER_MESSAGE_TNT = §eTNT hinzugefügt {0} LOADER_MESSAGE_INTERACT = §e{0} hinzugefügt {1} +LOADER_BUTTON_TNT = TNT LOADER_BUTTON_SWITCH=Hebel -LOADER_BUTTON_WOOD_BUTTON=Knopf -LOADER_BUTTON_STONE_BUTTON=Knopf +LOADER_BUTTON_WOOD_BUTTON=Holzknopf +LOADER_BUTTON_STONE_BUTTON=Steinknopf LOADER_BUTTON_PRESSURE_PLATE=Druckplatte LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE=Druckplatte LOADER_BUTTON_TRIPWIRE=Tripwire LOADER_BUTTON_NOTEBLOCK=Noteblock -LOADER_BUTTON_DAYLIGHTSENSOR=Tageslichtsensor -LOADER_BUTTON_INVALID=Invalider +LOADER_BUTTON_DAYLIGHT_DETECTOR=Tageslichtsensor +LOADER_BUTTON_COMPARATOR=Comparator +LOADER_BUTTON_REPEATER=Repeater +LOADER_BUTTON_LECTERN=Lectern +LOADER_BUTTON_TRAPDOOR=Trapdoor +LOADER_BUTTON_DOOR=Door +LOADER_BUTTON_FENCEGATE=Fencegate + LOADER_HELP_SETUP=§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen -LOADER_HELP_UNDO=§8/§7loader undo §8- §7Entfernt die zuletzt aufgenommene Aktion +LOADER_SETUP_STOP_FIRST=§cBitte stoppe zuerst den Loader LOADER_HELP_START=§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab -LOADER_HELP_WAIT=§8/§7loader wait §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Schüssen -LOADER_HELP_SPEED=§8/§7loader speed §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Aktionen LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pausiert das Abspielen -LOADER_HELP_RESUME=§8/§7loader resume §8- §7Spielt den Loader weiter ab +LOADER_HELP_GUI=§8/§7loader settings §8- §7Zeigt die Einstellungen an LOADER_HELP_STOP=§8/§eloader stop §8- §7Stoppt die Aufnahme bzw. das Abspielen -LOADER_HELP_CLEAR=§8/§eloader clear §8- §7Cleart die Aufnahme -LOADER_HELP_SINGLE=§8/§eloader single §8- §7Spielt die Aufnahme einmal ab -LOADER_HELP_OTHER=§7Der Loader arbeitet mit §eIngame§8-§eTicks §7(20 Ticks pro Sekunde) LOADER_NO_LOADER=§cDu hast noch keinen Loader. Erstelle dir einen mit /loader setup -LOADER_BACK_SETUP=§7Dein Loader ist nun wieder im Setup LOADER_NEW=§7Belade und feuer einmal die Kanone ab, um den Loader zu initialisieren. LOADER_HOW_TO_START=§7Führe dann /§eloader start§7 um den Loader zu starten LOADER_ACTIVE=§7Der Loader ist nun aktiviert. LOADER_STOP=§7Der Loader ist nun gestoppt. LOADER_PAUSED=§7Der Loader ist nun pausiert. -LOADER_RESUME=§7Der Loader läuft nun weiter. -LOADER_SINGLE=§7Der Loader schießt einmal. -LOADER_SMALL_TIME=§cDie Wartezeit ist zu klein -LOADER_NEW_TIME=§7Die Schusswartezeit ist nun: {0}, zuvor {1} -LOADER_NEW_LOAD_TIME=§7Die Setzwartezeit ist nun: {0}, zuvor {1} -LOADER_UNDO=§7Undo erfolgreich. LOADER_PERMS=§cDu darfst hier nicht den Detonator nutzen -LOADER_GUI_NAME=§eLoader -LOADER_GUI_NEW=§eNeuer Loader -LOADER_GUI_START=§eLoader starten -LOADER_GUI_PAUSE=§7Loader pausieren -LOADER_GUI_UNDO=§7Letzte Aktion Rückgängig machen -LOADER_GUI_WAIT=§7Schuss Delay -LOADER_GUI_WAIT_LORE=§7Aktuell: §e{0} -LOADER_GUI_WAIT_TITLE=§7Schuss Delay -LOADER_GUI_SPEED=§eGeschwindigkeit -LOADER_GUI_SPEED_LORE=§7Aktuell: §e{0} -LOADER_GUI_SPEED_TITLE=§7Block Platzier Geschwindigkeit -LOADER_GUI_STOP=§eLoader Stoppen + +LOADER_NOTHING_RECORDED=§cEs wurden keine Elemente aufgenommen! +LOADER_GUI_TITLE=Loader Einstellungen +LOADER_GUI_SHOW_INTERACTIONS=§eZeige Interaktionen +LOADER_GUI_SHOW_WAITS=§eZeige Wartezeiten +LOADER_GUI_SHOW_WAITS_SET_BETWEEN_TNT=§7Wait Time zwischen TNT +LOADER_GUI_SHOW_WAITS_SET_ALL=§7Wait Time alle +LOADER_GUI_SHOW_WAITS_TITLE=§7Wartezeit +LOADER_GUI_SETTINGS_TITLE=Einstellungen +LOADER_GUI_SETTINGS_BACK=§8Zurück +LOADER_GUI_SETTINGS_DELETE=§cLöschen +LOADER_GUI_WAIT_TITLE=Wartezeit +LOADER_GUI_WAIT_BACK=§8Zurück + +LOADER_GUI_CLICK_TO_EDIT=§7Click to edit +LOADER_GUI_ITEM_NAME=§7{0}§8: §e{1} +LOADER_SETTING_NAME=§7{0} +LOADER_SETTING_MODES=§7Modes§8: §e{0} +LOADER_SETTING_POWER=§7Power§8: §e{0} +LOADER_SETTING_TICKS=§7Ticks§8: §e{0} +LOADER_SETTING_REPEATER=§7Repeater§8: §e{0} +LOADER_SETTING_WAIT=§7Wait§8: §e{0} Tick(s) +LOADER_SETTING_WAIT_NAME=Wait +LOADER_SETTING_TICKS_NAME=Ticks +LOADER_SETTING_TICKS_REMOVE_ONE=§c-1 +LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT=§7Shift§8: §c-5 +LOADER_SETTING_TICKS_ADD_ONE=§a+1 +LOADER_SETTING_TICKS_ADD_ONE_SHIFT=§7Shift§8: §a+5 +LOADER_SETTING_TNT_NAME=§cTNT +LOADER_SETTING_TNT_X=§7X§8: §e{0} +LOADER_SETTING_TNT_Y=§7Y§8: §e{0} +LOADER_SETTING_TNT_Z=§7Z§8: §e{0} +LOADER_INTERACTION_NOOP=NOOP +LOADER_INTERACTION_INTERACT=Interact +LOADER_INTERACTION_POWERED=Powered +LOADER_INTERACTION_UNPOWERED=Unpowered +LOADER_INTERACTION_PAGE_PREV=Previous Page +LOADER_INTERACTION_PAGE_NEXT=Next Page +LOADER_INTERACTION_PAGE=Page {0} +LOADER_INTERACTION_ACTIVE=Active +LOADER_INTERACTION_INACTIVE=Inactive +LOADER_INTERACTION_WAIT_FOR=Wait for +LOADER_INTERACTION_NO_WAIT_FOR=No wait for +LOADER_INTERACTION_OPEN=Open +LOADER_INTERACTION_CLOSED=Closed + # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Messe dich und deine Freunde beim Beladen einer Kanone und bekomme informationen über die Kanone LOADTIMER_HELP_START_1=§8/§eloadtimer start §8-§7 Startet den einfachen Loadtimer @@ -882,6 +664,8 @@ SKULL_GUI_ITEM_NAME = §eSpieler Köpfe ANVIL_INV_NAME=Spieler name # StructureVoid STRUCTURE_VOID_COMMAND_HELP=§8/§estructureVoid §8-§7 Erhalte ein StructureVoid +# Dragon Egg +DRAGON_EGG_COMMAND_HELP=§8/§edragonegg §8-§7 Erhalte ein Drachenei # NightVision NIGHT_VISION_HELP=§8/§enightvision §8-§7 Schalte Nightvision an oder aus. NIGHT_VISION_OFF=§eNightvision deaktiviert @@ -966,6 +750,11 @@ REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze REGION_FREEZE_NO_PERMS=§cDu darfst diese Welt nicht einfrieren REGION_FREEZE_ENABLED=§cRegion eingefroren REGION_FREEZE_DISABLED=§aRegion aufgetaut +REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items +REGION_ITEMS_NO_PERMS=§cDu darfst hier nicht Items (de-)aktivieren +REGION_ITEMS_ENABLED=§aItems aktiviert in dieser Region +REGION_ITEMS_DISABLED=§cItems deaktiviert in dieser Region +REGION_ITEMS_DISABLED_GLOBAL=§cItems sind auf dem Server deaktiviert. REGION_PROTECT_HELP=§8/§eprotect §8- §7Schütze die Region REGION_PROTECT_DISABLE=§cBoden Schutz aufgehoben REGION_PROTECT_ENABLE=§aBoden geschützt @@ -1022,6 +811,8 @@ REGION_TB_DONE=§7Testblock zurückgesetzt REGION_TB_ERROR=§cFehler beim Zurücksetzen des Testblocks REGION_TB_NO_PERMS=§cDu darfst hier nicht den Testblock zurücksetzen REGION_TB_NO_REGION=§cDu befindest dich derzeit in keiner Region +REGION_TB_NO_SCHEMSHARING=§cDu kannst aktuell keine Schematics teilen bis {0}. +REGION_TB_NO_SCHEMRECEIVING=§cDer Besitzer dieses Bauservers kann keine Schematics erhalten bis {0}. REGION_TNT_HELP=§8/§etnt §8- §7Ändere das TNT verhalten REGION_TNT_HELP_MODE=§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten auf einen Modus REGION_TNT_ON=§aTNT-Schaden aktiviert @@ -1228,7 +1019,7 @@ WARP_EXISTS=§7Ein Warp mit dem namen §e{0} §7existiert bereits WARP_NAME_RESERVED=§7Du kannst nicht §c{0} §7als name für einen Warp nutzen WARP_CREATED=§7Der Warp §e{0} §7wurde erstellt WARP_DELETE_HOVER=§e{0} §7löschen -WARP_DELETED=§e{0} §7wurde gelöcht +WARP_DELETED=§e{0} §7wurde gelöscht WARP_TELEPORT_HOVER=§7Zu §e{0} §7teleportieren WARP_MATERIAL_CHOOSE=Material auswählen WARP_GUI_NAME=Warps diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 565f368f..0d38af4e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -21,6 +21,11 @@ package de.steamwar.bausystem; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.configplayer.Config; +import de.steamwar.bausystem.features.tpslimit.FreezeUtils; +import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils; +import de.steamwar.bausystem.features.tpslimit.TPSUtils; +import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; +import de.steamwar.bausystem.features.world.RamUsage; import de.steamwar.bausystem.region.loader.PrototypeLoader; import de.steamwar.bausystem.region.loader.RegionLoader; import de.steamwar.bausystem.region.loader.Updater; @@ -31,11 +36,16 @@ import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.event.Listener; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.scheduler.BukkitTask; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; import java.util.logging.Level; public class BauSystem extends JavaPlugin implements Listener { @@ -73,6 +83,7 @@ public class BauSystem extends JavaPlugin implements Listener { new Updater(RegionLoader.file, RegionLoader::load); LinkageUtils.link(); + RamUsage.init(); // This could disable any watchdog stuff. We need to investigate if this is a problem. /* @@ -122,18 +133,44 @@ 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(); + public static BukkitTask runTaskLater(Plugin plugin, Runnable runnable, long delay) { + return new BukkitRunnable() { + private int counter = 1; - Process process = processBuilder.start(); - process.waitFor(); - } catch (IOException | InterruptedException e) { - Thread.currentThread().interrupt(); - Bukkit.shutdown(); - } + @Override + public void run() { + if (FreezeUtils.isFrozen()) return; + if (counter >= delay) { + runnable.run(); + cancel(); + return; + } + counter++; + } + }.runTaskTimer(plugin, 0, 1); + } + + public static BukkitTask runTaskTimer(Plugin plugin, Runnable runnable, long delay, long period) { + return new BukkitRunnable() { + private int counter = 1; + private boolean first = true; + + @Override + public void run() { + if (FreezeUtils.isFrozen()) return; + if (counter >= (first ? delay : period)) { + first = false; + runnable.run(); + counter = 1; + return; + } + counter++; + } + }.runTaskTimer(plugin, 0, 1); + } + + public static void runTaskTimer(Plugin plugin, Consumer consumer, long delay, long period) { + AtomicReference task = new AtomicReference<>(); + task.set(runTaskTimer(plugin, () -> consumer.accept(task.get()), delay, period)); } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java index f9217497..4f1bdd92 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java @@ -36,7 +36,6 @@ import java.util.List; import java.util.stream.Collectors; @Linked -@MinVersion(18) public class AttributeRemoveCommand extends SWCommand { public AttributeRemoveCommand() { @@ -100,13 +99,15 @@ public class AttributeRemoveCommand extends SWCommand { return lore.stream() .skip(1) .map(s1 -> s1.substring(6)) + .map(s1 -> s1.replace('§', '&')) .map(s1 -> s1.replace(' ', '_')) .collect(Collectors.toList()); } @Override public String map(CommandSender commandSender, PreviousArguments previousArguments, String s) { - return s.replace('_', ' '); + return s.replace('_', ' ') + .replace('&', '§'); } }; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeUtils.java new file mode 100644 index 00000000..246e4ab9 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeUtils.java @@ -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 . + */ + +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 names = new HashMap<>(); + private Map, List> getters = new HashMap<>(); + private Map, Map> setters = new HashMap<>(); + + private void generate(BlockData blockData) { + Class clazz = blockData.getClass(); + if (getters.containsKey(clazz) && setters.containsKey(clazz)) return; + + Map> 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> 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 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 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) 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; + } + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java index d63204f3..01d652b4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java @@ -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> 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 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; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java index 0daed5af..de4b192a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java @@ -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 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); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/BlockAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/BlockAttribute.java deleted file mode 100644 index 13fbf86c..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/BlockAttribute.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.attributescopy; - -import org.bukkit.block.data.BlockData; - -import java.util.List; -import java.util.Set; - -public interface BlockAttribute { - Class type(); - void copy(List attributes, T blockData); - void paste(Set attributes, T blockData); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/AgeableAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/AgeableAttribute.java deleted file mode 100644 index a52d6819..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/AgeableAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 age "; - - @Override - public Class type() { - return Ageable.class; - } - - @Override - public void copy(List attributes, Ageable blockData) { - attributes.add(attribute + blockData.getAge()); - } - - @Override - public void paste(Set attributes, Ageable blockData) { - attributes.stream() - .filter(s -> s.startsWith(attribute)) - .map(s -> s.replace(attribute, "")) - .map(Integer::parseInt) - .findFirst() - .ifPresent(blockData::setAge); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/AnaloguePowerableAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/AnaloguePowerableAttribute.java deleted file mode 100644 index 6d9c7df0..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/AnaloguePowerableAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 power "; - - @Override - public Class type() { - return AnaloguePowerable.class; - } - - @Override - public void copy(List attributes, AnaloguePowerable blockData) { - attributes.add(attribute + blockData.getPower()); - } - - @Override - public void paste(Set attributes, AnaloguePowerable blockData) { - attributes.stream() - .filter(s -> s.startsWith(attribute)) - .map(s -> s.replace(attribute, "")) - .map(Integer::parseInt) - .findFirst() - .ifPresent(blockData::setPower); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/AttachableAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/AttachableAttribute.java deleted file mode 100644 index 05a716e9..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/AttachableAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 attached"; - - @Override - public Class type() { - return Attachable.class; - } - - @Override - public void copy(List attributes, Attachable blockData) { - if (blockData.isAttached()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Attachable blockData) { - blockData.setAttached(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/BisectedAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/BisectedAttribute.java deleted file mode 100644 index 31849b40..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/BisectedAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 half "; - - @Override - public Class type() { - return Bisected.class; - } - - @Override - public void copy(List attributes, Bisected blockData) { - attributes.add(attribute + blockData.getHalf().name().toLowerCase()); - } - - @Override - public void paste(Set attributes, Bisected blockData) { - for (Bisected.Half half : Bisected.Half.values()) { - if (attributes.contains(attribute + half.name().toLowerCase())) { - blockData.setHalf(half); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/DirectionalAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/DirectionalAttribute.java deleted file mode 100644 index c0e11fc8..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/DirectionalAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 facing "; - - @Override - public Class type() { - return Directional.class; - } - - @Override - public void copy(List attributes, Directional blockData) { - attributes.add(attribute + blockData.getFacing().name().toLowerCase()); - } - - @Override - public void paste(Set attributes, Directional blockData) { - for (BlockFace blockFace : blockData.getFaces()) { - if (attributes.contains(attribute + blockFace.name().toLowerCase())) { - blockData.setFacing(blockFace); - break; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/FaceAttachableAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/FaceAttachableAttribute.java deleted file mode 100644 index 59f79a19..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/FaceAttachableAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 attached "; - - @Override - public Class type() { - return FaceAttachable.class; - } - - @Override - public void copy(List attributes, FaceAttachable blockData) { - attributes.add(attribute + blockData.getAttachedFace().name().toLowerCase()); - } - - @Override - public void paste(Set attributes, FaceAttachable blockData) { - for (FaceAttachable.AttachedFace attachedFace : FaceAttachable.AttachedFace.values()) { - if (attributes.contains(attribute + attachedFace.name().toLowerCase())) { - blockData.setAttachedFace(attachedFace); - break; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/HangableAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/HangableAttribute.java deleted file mode 100644 index 8e26bb31..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/HangableAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 hanging"; - - @Override - public Class type() { - return Hangable.class; - } - - @Override - public void copy(List attributes, Hangable blockData) { - if (!blockData.isHanging()) return; - attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Hangable blockData) { - blockData.setHanging(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/LevelledAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/LevelledAttribute.java deleted file mode 100644 index 6e60b601..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/LevelledAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 level "; - - @Override - public Class type() { - return Levelled.class; - } - - @Override - public void copy(List attributes, Levelled blockData) { - attributes.add(attribute + blockData.getLevel()); - } - - @Override - public void paste(Set attributes, Levelled blockData) { - attributes.stream() - .filter(s -> s.startsWith(attribute)) - .map(s -> s.replace(attribute, "")) - .map(Integer::parseInt) - .findFirst() - .ifPresent(blockData::setLevel); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/LightableAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/LightableAttribute.java deleted file mode 100644 index aa55a054..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/LightableAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 lit"; - - @Override - public Class type() { - return Lightable.class; - } - - @Override - public void copy(List attributes, Lightable blockData) { - if (blockData.isLit()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Lightable blockData) { - blockData.setLit(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/MultipleFacingAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/MultipleFacingAttribute.java deleted file mode 100644 index 262de53c..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/MultipleFacingAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 connected "; - - @Override - public Class type() { - return MultipleFacing.class; - } - - @Override - public void copy(List attributes, MultipleFacing blockData) { - blockData.getFaces().forEach(blockFace -> { - attributes.add(attribute + blockFace.name().toLowerCase()); - }); - } - - @Override - public void paste(Set attributes, MultipleFacing blockData) { - for (BlockFace blockFace : BlockFace.values()) { - blockData.setFace(blockFace, attributes.contains(attribute + blockFace.name().toLowerCase())); - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/OpenableAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/OpenableAttribute.java deleted file mode 100644 index 2e440e67..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/OpenableAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 open"; - - @Override - public Class type() { - return Openable.class; - } - - @Override - public void copy(List attributes, Openable blockData) { - if (blockData.isOpen()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Openable blockData) { - blockData.setOpen(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/OrientableAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/OrientableAttribute.java deleted file mode 100644 index e70d8ab3..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/OrientableAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 orientation "; - - @Override - public Class type() { - return Orientable.class; - } - - @Override - public void copy(List attributes, Orientable blockData) { - attributes.add(attribute + blockData.getAxis().name().toLowerCase()); - } - - @Override - public void paste(Set attributes, Orientable blockData) { - for (Axis axis : Axis.values()) { - if (attributes.contains(attribute + axis.name().toLowerCase())) { - blockData.setAxis(axis); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/RailAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/RailAttribute.java deleted file mode 100644 index e7ab4e76..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/RailAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 rail shape "; - - @Override - public Class type() { - return Rail.class; - } - - @Override - public void copy(List attributes, Rail blockData) { - attributes.add(attribute + blockData.getShape().name().toLowerCase()); - } - - @Override - public void paste(Set attributes, Rail blockData) { - for (Rail.Shape shape : Rail.Shape.values()) { - if (attributes.contains(attribute + shape)) { - blockData.setShape(shape); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/RotatableAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/RotatableAttribute.java deleted file mode 100644 index 94a1fa8d..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/RotatableAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 rotation "; - - @Override - public Class type() { - return Rotatable.class; - } - - @Override - public void copy(List attributes, Rotatable blockData) { - attributes.add(attribute + blockData.getRotation().name()); - } - - @Override - public void paste(Set attributes, Rotatable blockData) { - for (BlockFace face : BlockFace.values()) { - if (attributes.contains(attribute + face.name())) { - blockData.setRotation(face); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/SnowableAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/SnowableAttribute.java deleted file mode 100644 index 71358651..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/SnowableAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 snowy"; - - @Override - public Class type() { - return Snowable.class; - } - - @Override - public void copy(List attributes, Snowable blockData) { - if (blockData.isSnowy()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Snowable blockData) { - blockData.setSnowy(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/WaterloggedAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/WaterloggedAttribute.java deleted file mode 100644 index bd010c01..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/WaterloggedAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 waterlogged"; - - @Override - public Class type() { - return Waterlogged.class; - } - - @Override - public void copy(List attributes, Waterlogged waterlogged) { - if (!waterlogged.isWaterlogged()) return; - attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Waterlogged waterlogged) { - waterlogged.setWaterlogged(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/BambooAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/BambooAttribute.java deleted file mode 100644 index c2182b03..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/BambooAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 leaves "; - - @Override - public Class type() { - return Bamboo.class; - } - - @Override - public void copy(List attributes, Bamboo blockData) { - attributes.add(attribute + blockData.getLeaves()); - } - - @Override - public void paste(Set attributes, Bamboo blockData) { - for (Bamboo.Leaves leaves : Bamboo.Leaves.values()) { - if (attributes.contains(attribute + leaves)) { - blockData.setLeaves(leaves); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/BellAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/BellAttribute.java deleted file mode 100644 index b5fcb280..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/BellAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 attachament "; - - @Override - public Class type() { - return Bell.class; - } - - @Override - public void copy(List attributes, Bell blockData) { - attributes.add(attribute + blockData.getAttachment()); - } - - @Override - public void paste(Set attributes, Bell blockData) { - for (Bell.Attachment attachment : Bell.Attachment.values()) { - if (attributes.contains(attribute + attachment)) { - blockData.setAttachment(attachment); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/BigDripleafAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/BigDripleafAttribute.java deleted file mode 100644 index a1ebef35..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/BigDripleafAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 tilt "; - - @Override - public Class type() { - return BigDripleaf.class; - } - - @Override - public void copy(List attributes, BigDripleaf blockData) { - attributes.add(attribute + blockData.getTilt()); - } - - @Override - public void paste(Set attributes, BigDripleaf blockData) { - for (BigDripleaf.Tilt tilt : BigDripleaf.Tilt.values()) { - if (attributes.contains(attribute + tilt)) { - blockData.setTilt(tilt); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CakeAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CakeAttribute.java deleted file mode 100644 index 0e44b938..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CakeAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 bites "; - - @Override - public Class type() { - return Cake.class; - } - - @Override - public void copy(List attributes, Cake blockData) { - attributes.add(attribute + blockData.getBites()); - } - - @Override - public void paste(Set attributes, Cake blockData) { - attributes.stream() - .filter(s -> s.startsWith(attribute)) - .map(s -> s.replace(attribute, "")) - .map(Integer::parseInt) - .findFirst() - .ifPresent(blockData::setBites); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CampfireAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CampfireAttribute.java deleted file mode 100644 index 9d5d9e3e..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CampfireAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 signal fire"; - - @Override - public Class type() { - return Campfire.class; - } - - @Override - public void copy(List attributes, Campfire blockData) { - if (blockData.isSignalFire()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Campfire blockData) { - blockData.setSignalFire(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CandleAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CandleAttribute.java deleted file mode 100644 index a8e054d8..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CandleAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 candles "; - - @Override - public Class type() { - return Candle.class; - } - - @Override - public void copy(List attributes, Candle blockData) { - if (blockData.getCandles() > 0) attributes.add(attribute + blockData.getCandles()); - } - - @Override - public void paste(Set attributes, Candle blockData) { - attributes.stream() - .filter(s -> s.startsWith(attribute)) - .map(s -> s.replace(attribute, "")) - .map(Integer::parseInt) - .findFirst() - .ifPresent(blockData::setCandles); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CaveVinesPlantAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CaveVinesPlantAttribute.java deleted file mode 100644 index ecbaf271..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/CaveVinesPlantAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 berries"; - - @Override - public Class type() { - return CaveVinesPlant.class; - } - - @Override - public void copy(List attributes, CaveVinesPlant blockData) { - if (blockData.isBerries()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, CaveVinesPlant blockData) { - blockData.setBerries(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/ComparatorAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/ComparatorAttribute.java deleted file mode 100644 index 4342008e..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/ComparatorAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 mode "; - - @Override - public Class type() { - return Comparator.class; - } - - @Override - public void copy(List attributes, Comparator blockData) { - attributes.add(attribute + blockData.getMode().name()); - } - - @Override - public void paste(Set attributes, Comparator blockData) { - for (Comparator.Mode mode : Comparator.Mode.values()) { - if (attributes.contains(attribute + mode.name())) { - blockData.setMode(mode); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/DaylightDetectorAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/DaylightDetectorAttribute.java deleted file mode 100644 index 3c319987..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/DaylightDetectorAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 inverted"; - - @Override - public Class type() { - return DaylightDetector.class; - } - - @Override - public void copy(List attributes, DaylightDetector blockData) { - if (blockData.isInverted()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, DaylightDetector blockData) { - blockData.setInverted(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/DoorAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/DoorAttribute.java deleted file mode 100644 index 1c7885af..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/DoorAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 hinge "; - - @Override - public Class type() { - return Door.class; - } - - @Override - public void copy(List attributes, Door blockData) { - attributes.add(attribute + blockData.getHinge().toString().toLowerCase()); - } - - @Override - public void paste(Set attributes, Door blockData) { - for (Door.Hinge hinge : Door.Hinge.values()) { - if (attributes.contains(attribute + hinge.toString().toLowerCase())) { - blockData.setHinge(hinge); - break; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/EndPortalFrameAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/EndPortalFrameAttribute.java deleted file mode 100644 index 25f790a6..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/EndPortalFrameAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 eye"; - - @Override - public Class type() { - return EndPortalFrame.class; - } - - @Override - public void copy(List attributes, EndPortalFrame blockData) { - if (blockData.hasEye()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, EndPortalFrame blockData) { - blockData.setEye(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/FarmlandAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/FarmlandAttribute.java deleted file mode 100644 index b55971d4..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/FarmlandAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 moisture "; - - @Override - public Class type() { - return Farmland.class; - } - - @Override - public void copy(List attributes, Farmland blockData) { - attributes.add(attribute + blockData.getMoisture()); - } - - @Override - public void paste(Set attributes, Farmland blockData) { - attributes.stream() - .filter(s -> s.startsWith(attribute)) - .map(s -> s.replace(attribute, "")) - .map(Integer::parseInt) - .findFirst() - .ifPresent(blockData::setMoisture); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/GateAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/GateAttribute.java deleted file mode 100644 index 3f853135..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/GateAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 inWall"; - - @Override - public Class type() { - return Gate.class; - } - - @Override - public void copy(List attributes, Gate blockData) { - if (blockData.isInWall()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Gate blockData) { - blockData.setInWall(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/HopperAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/HopperAttribute.java deleted file mode 100644 index b64266a8..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/HopperAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 enabled"; - - @Override - public Class type() { - return Hopper.class; - } - - @Override - public void copy(List attributes, Hopper blockData) { - if (blockData.isEnabled()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Hopper blockData) { - blockData.setEnabled(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/JigsawAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/JigsawAttribute.java deleted file mode 100644 index 492e2543..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/JigsawAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 orientation "; - - @Override - public Class type() { - return Jigsaw.class; - } - - @Override - public void copy(List attributes, Jigsaw blockData) { - attributes.add(attribute + blockData.getOrientation()); - } - - @Override - public void paste(Set attributes, Jigsaw blockData) { - for (Jigsaw.Orientation orientation : Jigsaw.Orientation.values()) { - if (attributes.contains(attribute + orientation)) { - blockData.setOrientation(orientation); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/LanternAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/LanternAttribute.java deleted file mode 100644 index 3ea0d701..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/LanternAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 lantern"; - - @Override - public Class type() { - return Lantern.class; - } - - @Override - public void copy(List attributes, Lantern lantern) { - if (!lantern.isHanging()) return; - attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Lantern lantern) { - lantern.setHanging(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/LeavesAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/LeavesAttribute.java deleted file mode 100644 index 74f445f6..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/LeavesAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 persistent"; - - @Override - public Class type() { - return Leaves.class; - } - - @Override - public void copy(List attributes, Leaves blockData) { - if (blockData.isPersistent()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Leaves blockData) { - blockData.setPersistent(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/PointedDripstoneAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/PointedDripstoneAttribute.java deleted file mode 100644 index 5b25834a..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/PointedDripstoneAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute1 = "§8-§7 vertialDirection "; - private String attribute2 = "§8-§7 thickness "; - - @Override - public Class type() { - return PointedDripstone.class; - } - - @Override - public void copy(List attributes, PointedDripstone blockData) { - attributes.add(attribute1 + " " + blockData.getVerticalDirection().name().toLowerCase()); - attributes.add(attribute2 + " " + blockData.getThickness().name().toLowerCase()); - } - - @Override - public void paste(Set 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; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/RedstoneWireAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/RedstoneWireAttribute.java deleted file mode 100644 index a3049f2b..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/RedstoneWireAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 connection "; - - @Override - public Class type() { - return RedstoneWire.class; - } - - @Override - public void copy(List attributes, RedstoneWire blockData) { - for (BlockFace blockFace : blockData.getAllowedFaces()) { - attributes.add(attribute + blockFace.name().toLowerCase() + " " + blockData.getFace(blockFace).name().toLowerCase()); - } - } - - @Override - public void paste(Set 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); - } - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/RepeaterAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/RepeaterAttribute.java deleted file mode 100644 index 1f25d655..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/RepeaterAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute1 = "§8-§7 delay "; - private String attribute2 = "§8-§7 locked"; - - @Override - public Class type() { - return Repeater.class; - } - - @Override - public void copy(List attributes, Repeater blockData) { - attributes.add(attribute1 + blockData.getDelay()); - if (blockData.isLocked()) attributes.add(attribute2); - } - - @Override - public void paste(Set 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)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/RespawnAnchorAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/RespawnAnchorAttribute.java deleted file mode 100644 index 646a14d8..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/RespawnAnchorAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 charges "; - - @Override - public Class type() { - return RespawnAnchor.class; - } - - @Override - public void copy(List attributes, RespawnAnchor blockData) { - attributes.add(attribute + blockData.getCharges()); - } - - @Override - public void paste(Set attributes, RespawnAnchor blockData) { - attributes.stream() - .filter(s -> s.startsWith(attribute)) - .map(s -> s.replace(attribute, "")) - .map(Integer::parseInt) - .findFirst() - .ifPresent(blockData::setCharges); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SaplingAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SaplingAttribute.java deleted file mode 100644 index 3a15fc35..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SaplingAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 stage "; - - @Override - public Class type() { - return Sapling.class; - } - - @Override - public void copy(List attributes, Sapling blockData) { - attributes.add(attribute + blockData.getStage()); - } - - @Override - public void paste(Set attributes, Sapling blockData) { - attributes.stream() - .filter(s -> s.startsWith(attribute)) - .map(s -> s.replace(attribute, "")) - .map(Integer::parseInt) - .findFirst() - .ifPresent(blockData::setStage); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/ScaffoldingAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/ScaffoldingAttribute.java deleted file mode 100644 index 8da631d8..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/ScaffoldingAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute1 = "§8-§7 bottom"; - private String attribute2 = "§8-§7 distance "; - - @Override - public Class type() { - return Scaffolding.class; - } - - @Override - public void copy(List attributes, Scaffolding blockData) { - if (blockData.isBottom()) attributes.add(attribute1); - attributes.add(attribute2 + blockData.getDistance()); - } - - @Override - public void paste(Set 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); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SculkSensorAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SculkSensorAttribute.java deleted file mode 100644 index 8f974f40..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SculkSensorAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 phase "; - - @Override - public Class type() { - return SculkSensor.class; - } - - @Override - public void copy(List attributes, SculkSensor blockData) { - attributes.add(attribute + blockData.getPhase()); - } - - @Override - public void paste(Set attributes, SculkSensor blockData) { - for (SculkSensor.Phase phase : SculkSensor.Phase.values()) { - if (attributes.contains(attribute + phase)) { - blockData.setPhase(phase); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SeaPickleAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SeaPickleAttribute.java deleted file mode 100644 index 7b3ddf57..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SeaPickleAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 pickles "; - - @Override - public Class type() { - return SeaPickle.class; - } - - @Override - public void copy(List attributes, SeaPickle blockData) { - attributes.add(attribute + blockData.getPickles()); - } - - @Override - public void paste(Set attributes, SeaPickle blockData) { - attributes.stream() - .filter(s -> s.startsWith(attribute)) - .map(s -> s.replace(attribute, "")) - .map(Integer::parseInt) - .findFirst() - .ifPresent(blockData::setPickles); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SlabAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SlabAttribute.java deleted file mode 100644 index eca81bf4..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SlabAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 type "; - - @Override - public Class type() { - return Slab.class; - } - - @Override - public void copy(List attributes, Slab blockData) { - attributes.add(attribute + blockData.getType()); - } - - @Override - public void paste(Set attributes, Slab blockData) { - for (Slab.Type type : Slab.Type.values()) { - if (attributes.contains(attribute + type)) { - blockData.setType(type); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SnowAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SnowAttribute.java deleted file mode 100644 index 935e975d..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/SnowAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 layers "; - - @Override - public Class type() { - return Snow.class; - } - - @Override - public void copy(List attributes, Snow blockData) { - attributes.add(attribute + blockData.getLayers()); - } - - @Override - public void paste(Set attributes, Snow blockData) { - attributes.stream() - .filter(s -> s.startsWith(attribute)) - .map(s -> s.replace(attribute, "")) - .map(Integer::parseInt) - .findFirst() - .ifPresent(blockData::setLayers); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/StairsAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/StairsAttribute.java deleted file mode 100644 index 3686b506..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/StairsAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 shape "; - - @Override - public Class type() { - return Stairs.class; - } - - @Override - public void copy(List attributes, Stairs blockData) { - attributes.add(attribute + blockData.getShape().name().toLowerCase()); - } - - @Override - public void paste(Set attributes, Stairs blockData) { - for (Stairs.Shape shape : Stairs.Shape.values()) { - if (attributes.contains(attribute + shape.name().toLowerCase())) { - blockData.setShape(shape); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/StructureBlockAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/StructureBlockAttribute.java deleted file mode 100644 index 34055ce9..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/StructureBlockAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 mode "; - - @Override - public Class type() { - return StructureBlock.class; - } - - @Override - public void copy(List attributes, StructureBlock blockData) { - attributes.add(attribute + blockData.getMode().name()); - } - - @Override - public void paste(Set attributes, StructureBlock blockData) { - for (StructureBlock.Mode mode : StructureBlock.Mode.values()) { - if (attributes.contains(attribute + mode.name())) { - blockData.setMode(mode); - return; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/TripwireAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/TripwireAttribute.java deleted file mode 100644 index 27257568..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/TripwireAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute = "§8-§7 disarmed"; - - @Override - public Class type() { - return Tripwire.class; - } - - @Override - public void copy(List attributes, Tripwire blockData) { - if (blockData.isDisarmed()) attributes.add(attribute); - } - - @Override - public void paste(Set attributes, Tripwire blockData) { - blockData.setDisarmed(attributes.contains(attribute)); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/TurtleEggAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/TurtleEggAttribute.java deleted file mode 100644 index 478d1f75..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/TurtleEggAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - private String attribute1 = "§8-§7 eggs "; - private String attribute2 = "§8-§7 hatch "; - - @Override - public Class type() { - return TurtleEgg.class; - } - - @Override - public void copy(List attributes, TurtleEgg blockData) { - attributes.add(attribute1 + blockData.getEggs()); - attributes.add(attribute2 + blockData.getHatch()); - } - - @Override - public void paste(Set 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); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/WallAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/WallAttribute.java deleted file mode 100644 index a72ed734..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/type/WallAttribute.java +++ /dev/null @@ -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 . - */ - -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 { - - 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 type() { - return Wall.class; - } - - @Override - public void copy(List 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 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; - } - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java index 8d254a3a..66f53359 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java @@ -88,7 +88,7 @@ public class AutostartListener implements Listener { } else { BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_START", player); } - regionStartTime.put(region, TPSUtils.currentTick.get()); + regionStartTime.put(region, TPSUtils.currentRealTick.get()); } @EventHandler @@ -101,7 +101,7 @@ public class AutostartListener implements Listener { if (!regionStartTime.containsKey(region)) return; if (!region.hasType(RegionType.TESTBLOCK)) return; if (!region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return; - long tickDiff = TPSUtils.currentTick.get() - regionStartTime.remove(region); + long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region); RegionUtils.message(region, player -> { return BauSystem.MESSAGE.parse("AUTOSTART_MESSAGE_RESULT1", player, new SimpleDateFormat(BauSystem.MESSAGE.parse("AUTOSTART_MESSAGE_DATE_PATTERN", player)).format(new Date(tickDiff * 50))); }); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java index 7f3c27b9..d8ba9171 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java @@ -25,6 +25,7 @@ import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.core.Core; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; import de.steamwar.sql.SteamwarUser; @@ -58,6 +59,9 @@ public class BauInfoBauGuiItem extends BauGuiItem { if (flag == Flag.PROTECT && region.getFloorLevel() == 0) { continue; } + if (flag == Flag.ITEMS && Core.getVersion() < 19) { + continue; + } Flag.Value value = region.get(flag); if (value != null) { stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player))); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonDetector.java b/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonDetector.java new file mode 100644 index 00000000..09893fd5 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonDetector.java @@ -0,0 +1,99 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.cannon; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.cannon.depth.Depth; +import de.steamwar.bausystem.features.cannon.depth.DepthManager; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.linkage.Linked; +import org.bukkit.Bukkit; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.util.Vector; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Linked +public class CannonDetector implements Listener { + + private Map velocities = new HashMap<>(); + + @EventHandler + public void onEntityExplode(EntityExplodeEvent event) { + if (!(event.getEntity() instanceof TNTPrimed)) { + return; + } + + TNTPrimed tnt = (TNTPrimed) event.getEntity(); + DepthManager.update(tnt, event.blockList()); + + List tnts = Bukkit.getWorlds().get(0).getEntitiesByClass(TNTPrimed.class) + .stream() + .filter(entity -> entity != tnt) + .filter(entity -> entity.getFuseTicks() > 1) + .filter(entity -> entity.getLocation().distance(event.getLocation()) <= 8) + .collect(Collectors.toList()); + + if (tnts.isEmpty()) { + return; + } + + boolean isEmpty = velocities.isEmpty(); + tnts.forEach(tntPrimed -> { + velocities.put(tntPrimed, tntPrimed.getVelocity().clone()); + }); + + if (!isEmpty) { + return; + } + + BauSystem.runTaskLater(BauSystem.getInstance(), () -> { + Map> grouped = new HashMap<>(); + velocities.forEach((tntPrimed, vector) -> { + grouped.computeIfAbsent(new CannonKey(round(tntPrimed.getLocation().toVector()), round(vector)), ignored -> new ArrayList<>()).add(tntPrimed); + }); + grouped.forEach((cannonKey, tntPrimeds) -> { + if (tntPrimeds.size() <= 5) return; + Region region = Region.getRegion(tntPrimeds.get(0).getLocation()); + if (region.isGlobal()) return; + if (!region.hasType(RegionType.TESTBLOCK)) return; + Depth depth = new Depth(region); + DepthManager.init(tntPrimeds, depth); + }); + velocities.clear(); + }, 1); + } + + private Vector round(Vector vector) { + vector.multiply(10000); + vector.setX(Math.round(vector.getX())); + vector.setY(Math.round(vector.getY())); + vector.setZ(Math.round(vector.getZ())); + return vector; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonKey.java b/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonKey.java new file mode 100644 index 00000000..73270eab --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/CannonKey.java @@ -0,0 +1,33 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.cannon; + +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import org.bukkit.util.Vector; + +@AllArgsConstructor +@EqualsAndHashCode +@Getter +public final class CannonKey { + private Vector locationVector; + private Vector velocityVector; +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/depth/Depth.java b/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/depth/Depth.java new file mode 100644 index 00000000..506b6e93 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/depth/Depth.java @@ -0,0 +1,110 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.cannon.depth; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.RegionUtils; +import de.steamwar.bausystem.region.utils.RegionExtensionType; +import de.steamwar.bausystem.region.utils.RegionType; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +public class Depth { + + private Region region; + private Vector minVector = null; + private Vector maxVector = null; + private int tntCount = 0; + + public Depth(Region region) { + this.region = region; + } + + public void update(List blocks) { + List blocksList = blocks.stream() + .filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) + .collect(Collectors.toList()); + if (blocksList.isEmpty()) return; + tntCount++; + for (Block block : blocksList) { + internalUpdate(block); + } + } + + public void finish() { + if (maxVector == null || minVector == null) return; + Vector dimensions = maxVector.subtract(minVector); + dimensions.setX(Math.abs(dimensions.getX())); + dimensions.setY(Math.abs(dimensions.getY())); + dimensions.setZ(Math.abs(dimensions.getZ())); + + RegionUtils.message(region, player -> { + player.spigot().sendMessage(getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, tntCount)); + }); + } + + private void internalUpdate(Block block) { + if (minVector == null) { + minVector = block.getLocation().toVector(); + } + minVector.setX(Math.min(minVector.getX(), block.getX())); + minVector.setY(Math.min(minVector.getY(), block.getY())); + minVector.setZ(Math.min(minVector.getZ(), block.getZ())); + + if (maxVector == null) { + maxVector = block.getLocation().toVector(); + } + maxVector.setX(Math.max(maxVector.getX(), block.getX())); + maxVector.setY(Math.max(maxVector.getY(), block.getY())); + maxVector.setZ(Math.max(maxVector.getZ(), block.getZ())); + } + + private static BaseComponent[] getMessage(Player player, int x, int y, int z, int tntCount) { + final Set dimensions = new HashSet<>(); + dimensions.add(x); + dimensions.add(y); + dimensions.add(z); + + int max = getMax(dimensions); + + TextComponent headerComponent = new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_MESSAGE", player)); + + TextComponent depthComponent = new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_COUNT", player, x == max ? "§e" : "§7", x, y == max ? "§e" : "§7", y, z == max ? "§e" : "§7", z)); + depthComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_HOVER", player))})); + + TextComponent tntComponent = new TextComponent(BauSystem.MESSAGE.parse("DEPTH_COUNTER_TNT", player, tntCount)); + + return new BaseComponent[]{headerComponent, depthComponent, tntComponent}; + } + + private static int getMax(Set values) { + return values.stream().max(Integer::compare).orElse(0); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/depth/DepthManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/depth/DepthManager.java new file mode 100644 index 00000000..21789d7b --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/cannon/depth/DepthManager.java @@ -0,0 +1,48 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.cannon.depth; + +import lombok.experimental.UtilityClass; +import org.bukkit.block.Block; +import org.bukkit.entity.TNTPrimed; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@UtilityClass +public class DepthManager { + + private Map depths = new HashMap<>(); + + public void init(List list, Depth depth) { + for (TNTPrimed tnt : list) { + depths.putIfAbsent(tnt, depth); + } + } + + public void update(TNTPrimed tnt, List blocks) { + Depth depth = depths.remove(tnt); + if (depth == null) return; + depth.update(blocks); + if (depths.containsValue(depth)) return; + depth.finish(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java new file mode 100644 index 00000000..b2c83c7e --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java @@ -0,0 +1,109 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.design.endstone; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Region; +import de.steamwar.entity.REntity; +import de.steamwar.entity.REntityServer; +import de.steamwar.entity.RFallingBlockEntity; +import net.md_5.bungee.api.ChatMessageType; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class DesignEndStone { + + private static final World WORLD = Bukkit.getWorlds().get(0); + + private int minX, minY, minZ, maxX, maxY, maxZ; + private REntityServer entityServer = new REntityServer(); + private List entities = new ArrayList<>(); + private Set locations = new HashSet<>(); + private List players = new ArrayList<>(); + + public DesignEndStone(Region region) { + this.minX = region.getMinPointBuild().getX(); + this.minY = region.getMinPointBuild().getY(); + this.minZ = region.getMinPointBuild().getZ(); + this.maxX = region.getMaxPointBuild().getX(); + this.maxY = region.getMaxPointBuild().getY(); + this.maxZ = region.getMaxPointBuild().getZ(); + } + + private void calc() { + entities.forEach(REntity::die); + entities.clear(); + locations.clear(); + + calc(minX, minY, minZ, maxX, maxY, minZ, 0, 0, 1, maxZ - minZ); + calc(minX, minY, maxZ, maxX, maxY, maxZ, 0, 0, -1, maxZ - minZ); + calc(minX, minY, minZ, minX, maxY, maxZ, 1, 0, 0, maxX - minX); + calc(maxX, minY, minZ, maxX, maxY, maxZ, -1, 0, 0, maxX - minX); + // calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY); + calc(minX, maxY, minZ, maxX, maxY, maxZ, 0, -1, 0, maxY - minY); + } + + private void calc(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int dirX, int dirY, int dirZ, int steps) { + for (int x = minX; x <= maxX; x++) { + for (int y = minY; y <= maxY; y++) { + for (int z = minZ; z <= maxZ; z++) { + for (int step = 0; step < steps; step++) { + int cx = x + step * dirX; + int cy = y + step * dirY; + int cz = z + step * dirZ; + Material material = WORLD.getBlockAt(cx, cy, cz).getType(); + if (material == Material.END_STONE || material == Material.END_STONE_BRICKS || material == Material.END_STONE_BRICK_SLAB || material == Material.END_STONE_BRICK_STAIRS || material == Material.END_STONE_BRICK_WALL) { + Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5); + if (locations.contains(location)) break; + RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS); + entity.setNoGravity(true); + entity.setGlowing(true); + entities.add(entity); + break; + } else if (!material.isAir()) { + break; + } + } + } + } + } + } + + public void toggle(Player player) { + if (players.contains(player)) { + players.remove(player); + entityServer.removePlayer(player); + BauSystem.MESSAGE.send("DESIGN_ENDSTONE_DISABLE", player, ChatMessageType.ACTION_BAR); + } else { + players.add(player); + entityServer.addPlayer(player); + calc(); + BauSystem.MESSAGE.send("DESIGN_ENDSTONE_ENABLE", player, ChatMessageType.ACTION_BAR); + } + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java new file mode 100644 index 00000000..56b2d419 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java @@ -0,0 +1,50 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.design.endstone; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.Map; + +@Linked +public class DesignEndStoneCommand extends SWCommand { + + public DesignEndStoneCommand() { + super("designendstone"); + } + + private Map designEndStoneMap = new HashMap<>(); + + @Register(description = "DESIGN_ENDSTONE_COMMAND_HELP") + public void genericCommand(Player player) { + Region region = Region.getRegion(player.getLocation()); + if (!region.hasType(RegionType.BUILD)) { + BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player); + return; + } + designEndStoneMap.computeIfAbsent(region, DesignEndStone::new).toggle(player); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/AbstractDetonatorEntity.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/AbstractDetonatorEntity.java deleted file mode 100644 index 1f1a5b8b..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/AbstractDetonatorEntity.java +++ /dev/null @@ -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 . - */ - -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(); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java index c1ffd756..80d5b33b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java @@ -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> ENTITIES_MAP = new HashMap<>(); + private static final Map 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 locs) { - List 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 getDetoEntities(Player p) { - return ENTITIES_MAP.getOrDefault(p, new ArrayList<>()); + ENTITIES_MAP.remove(p).close(); } public static boolean hasActiveDetonatorShow(Player p) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java index 2e0cbf38..be8e8ce9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java @@ -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 entityIdFieldAccessor = Reflection.getField(useEntity, int.class, 0); + static final Set HAS_UPDATED = new HashSet<>(); - private static final Set HAS_UPDATED = new HashSet<>(); - - public DetonatorListener() { - TinyProtocol.instance.addFilter(useEntity, (player, o) -> { - List 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)); diff --git a/BauSystem_15/src/de/steamwar/bausystem/features/simulator/SimulatorPreview15.java b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/Cuboid.java similarity index 68% rename from BauSystem_15/src/de/steamwar/bausystem/features/simulator/SimulatorPreview15.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/Cuboid.java index f3e38be3..08632a9c 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/features/simulator/SimulatorPreview15.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/Cuboid.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * 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 @@ -17,14 +17,18 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.simulator; +package de.steamwar.bausystem.features.killchecker; -import de.steamwar.bausystem.features.tracer.show.Record; +import lombok.AllArgsConstructor; +import lombok.Data; -public class SimulatorPreview15 implements SimulatorPreview { - - @Override - public Record simulate(TNTSimulator tntSimulator) { - return new Record(null); - } -} +@Data +@AllArgsConstructor +public class Cuboid { + private double x; + private double y; + private double z; + private double dx; + private double dy; + private double dz; +} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java new file mode 100644 index 00000000..1340f1c1 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java @@ -0,0 +1,108 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.killchecker; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.utils.bossbar.BossBarService; +import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; +import org.bukkit.Bukkit; +import org.bukkit.block.Block; +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.PlayerQuitEvent; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +@Linked +public class KillcheckerCommand extends SWCommand implements Listener { + + private Map visualizers = new HashMap<>(); + + @LinkedInstance + public BossBarService bossBarService; + + public KillcheckerCommand() { + super("killchecker"); + addDefaultHelpMessage("KILLCHECKER_INFO"); + addDefaultHelpMessage("KILLCHECKER_INFO2"); + } + + @Register(value = "enable", description = "KILLCHECKER_HELP_ENABLE") + public void genericCommand(Player player, @OptionalValue("-outline") @StaticValue(value = {"-area", "-outline"}, allowISE = true) boolean onlyOutline) { + Region region = Region.getRegion(player.getLocation()); + KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService)); + killcheckerVisualizer.recalc(); + killcheckerVisualizer.show(player, onlyOutline); + BauSystem.MESSAGE.send("KILLCHECKER_ENABLE", player); + } + + @Register(value = "disable", description = "KILLCHECKER_HELP_DISABLE") + public void disableCommand(Player player) { + Region region = Region.getRegion(player.getLocation()); + KillcheckerVisualizer killcheckerVisualizer = visualizers.get(region); + if (killcheckerVisualizer != null) { + if (killcheckerVisualizer.hide(player)) { + visualizers.remove(region); + } + } + BauSystem.MESSAGE.send("KILLCHECKER_DISABLE", player); + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + Player player = event.getPlayer(); + Set regions = new HashSet<>(); + visualizers.forEach((region, visualizer) -> { + if (visualizer.disconnect(player)) { + regions.add(region); + } + }); + regions.forEach(visualizers::remove); + } + + private void recalc(Block block) { + Region region = Region.getRegion(block.getLocation()); + KillcheckerVisualizer killcheckerVisualizer = visualizers.get(region); + if (killcheckerVisualizer != null) { + killcheckerVisualizer.recalc(); + } + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) { + recalc(event.getBlock()); + } + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) { + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + recalc(event.getBlock()); + }, 1); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java new file mode 100644 index 00000000..6d4b8af2 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java @@ -0,0 +1,399 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.killchecker; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.utils.RegionExtensionType; +import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; +import de.steamwar.bausystem.utils.bossbar.BossBarService; +import de.steamwar.entity.REntity; +import de.steamwar.entity.REntityServer; +import de.steamwar.entity.RFallingBlockEntity; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.boss.BarColor; +import org.bukkit.boss.BarStyle; +import org.bukkit.boss.BossBar; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public class KillcheckerVisualizer { + + private static final Material[] MATERIALS = new Material[] {Material.YELLOW_STAINED_GLASS, Material.ORANGE_STAINED_GLASS, Material.RED_STAINED_GLASS, Material.PURPLE_STAINED_GLASS, Material.BLACK_STAINED_GLASS}; + private static final World WORLD = Bukkit.getWorlds().get(0); + + private static final double SURROUND = 4; + + private final Point minPoint; + private final Point maxPoint; + + private final int yArea; + private final int zArea; + private final int xArea; + + private final Set players = new HashSet<>(); + private final Set areaPlayers = new HashSet<>(); + + private final Region region; + private final BossBarService bossBarService; + + public KillcheckerVisualizer(Region region, BossBarService bossBarService) { + this.region = region; + this.minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.NORMAL); + this.maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.NORMAL); + + yArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getZ() - minPoint.getZ()); + zArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getY() - minPoint.getY()); + xArea = (maxPoint.getY() - minPoint.getY()) * (maxPoint.getZ() - minPoint.getZ()); + + this.bossBarService = bossBarService; + } + + private final REntityServer outline = new REntityServer(); + private final REntityServer inner = new REntityServer(); + + private final Map killCount = new HashMap<>(); + private final Set outlinePointsCache = new HashSet<>(); + private final Map rEntities = new HashMap<>(); + + private double percent = 0; + private int kills = 0; + private int cannonCount = 0; + + public void recalc() { + Set cuboids = new HashSet<>(); + Set points = new HashSet<>(); + for (int x = minPoint.getX() + 1; x < maxPoint.getX(); x++) { + for (int y = minPoint.getY(); y < maxPoint.getY(); y++) { + for (int z = minPoint.getZ() + 1; z < maxPoint.getZ(); z++) { + if (points.contains(new Point(x, y, z))) continue; + Block block = WORLD.getBlockAt(x, y, z); + if (block.getType().isAir()) continue; + String name = block.getType().name(); + if (!name.endsWith("_WOOL") && !name.endsWith("_STAINED_GLASS") && !name.endsWith("_CONCRETE") && !name.endsWith("_TERRACOTTA")) continue; + if (name.equals("_GLAZED_TERRACOTTA")) continue; + Cuboid cuboid = create(block.getType(), x, y, z); + cuboids.add(cuboid); + for (int dx = (int) cuboid.getX(); dx <= cuboid.getDx(); dx++) { + for (int dy = (int) cuboid.getY(); dy <= cuboid.getDy(); dy++) { + for (int dz = (int) cuboid.getZ(); dz <= cuboid.getDz(); dz++) { + points.add(new Point(dx, dy, dz)); + } + } + } + } + } + } + cannonCount = cuboids.size(); + + Map kill = new HashMap<>(); + int yKills = 0; + int yCount = 0; + Set yPoints = new HashSet<>(); + for (int x = minPoint.getX(); x <= maxPoint.getX(); x++) { + for (int z = minPoint.getZ(); z <= maxPoint.getZ(); z++) { + Set cuboidSet = new HashSet<>(); + for (Cuboid cuboid : cuboids) { + if (x >= cuboid.getX() - SURROUND && x < cuboid.getDx() + SURROUND && z >= cuboid.getZ() - SURROUND && z < cuboid.getDz() + SURROUND) { + cuboidSet.add(cuboid); + } + } + if (cuboidSet.size() > 1) { + yCount++; + yKills += splitIntoDoubleKills(cuboidSet.size()); + Point p2 = new Point(x, maxPoint.getY() + 1, z); + yPoints.add(p2); + kill.put(p2, Math.max(kill.getOrDefault(p2, 0), cuboidSet.size())); + } + } + } + + int xKills = 0; + int xCount = 0; + Set xPoints = new HashSet<>(); + for (int y = minPoint.getY(); y <= maxPoint.getY(); y++) { + for (int z = minPoint.getZ(); z <= maxPoint.getZ(); z++) { + Set cuboidSet = new HashSet<>(); + for (Cuboid cuboid : cuboids) { + if (y >= cuboid.getY() - SURROUND && y < cuboid.getDy() + SURROUND && z >= cuboid.getZ() - SURROUND && z < cuboid.getDz() + SURROUND) { + cuboidSet.add(cuboid); + } + } + if (cuboidSet.size() > 1) { + xCount++; + xKills += splitIntoDoubleKills(cuboidSet.size()); + Point p1 = new Point(minPoint.getX() - 1, y, z); + xPoints.add(p1); + kill.put(p1, Math.max(kill.getOrDefault(p1, 0), cuboidSet.size())); + Point p2 = new Point(maxPoint.getX() + 1, y, z); + xPoints.add(p2); + kill.put(p2, Math.max(kill.getOrDefault(p2, 0), cuboidSet.size())); + } + } + } + + int zKills = 0; + int zCount = 0; + Set zPoints = new HashSet<>(); + for (int x = minPoint.getX(); x <= maxPoint.getX(); x++) { + for (int y = minPoint.getY(); y <= maxPoint.getY(); y++) { + Set cuboidSet = new HashSet<>(); + for (Cuboid cuboid : cuboids) { + if (x >= cuboid.getX() - SURROUND && x < cuboid.getDx() + SURROUND && y >= cuboid.getY() - SURROUND && y < cuboid.getDy() + SURROUND) { + cuboidSet.add(cuboid); + } + } + if (cuboidSet.size() > 1) { + zCount++; + zKills += splitIntoDoubleKills(cuboidSet.size()); + Point p1 = new Point(x, y, minPoint.getZ() - 1); + zPoints.add(p1); + kill.put(p1, Math.max(kill.getOrDefault(p1, 0), cuboidSet.size())); + Point p2 = new Point(x, y, maxPoint.getZ() + 1); + zPoints.add(p2); + kill.put(p2, Math.max(kill.getOrDefault(p2, 0), cuboidSet.size())); + } + } + } + + Set outlinePoints = new HashSet<>(); + yPoints.forEach(point -> { + Point p1 = new Point(point.getX() - 1, point.getY(), point.getZ()); + Point p2 = new Point(point.getX() + 1, point.getY(), point.getZ()); + Point p3 = new Point(point.getX(), point.getY(), point.getZ() - 1); + Point p4 = new Point(point.getX(), point.getY(), point.getZ() + 1); + + Point p5 = new Point(point.getX() - 1, point.getY(), point.getZ() - 1); + Point p6 = new Point(point.getX() - 1, point.getY(), point.getZ() + 1); + Point p7 = new Point(point.getX() + 1, point.getY(), point.getZ() - 1); + Point p8 = new Point(point.getX() + 1, point.getY(), point.getZ() + 1); + + int count = kill.get(point); + + int surrounded = 0; + if (kill.getOrDefault(p1, 0) == count) surrounded++; + if (kill.getOrDefault(p2, 0) == count) surrounded++; + if (kill.getOrDefault(p3, 0) == count) surrounded++; + if (kill.getOrDefault(p4, 0) == count) surrounded++; + if (surrounded != 4) outlinePoints.add(point); + if (kill.getOrDefault(p5, 0) != count) outlinePoints.add(point); + if (kill.getOrDefault(p6, 0) != count) outlinePoints.add(point); + if (kill.getOrDefault(p7, 0) != count) outlinePoints.add(point); + if (kill.getOrDefault(p8, 0) != count) outlinePoints.add(point); + }); + xPoints.forEach(point -> { + Point p1 = new Point(point.getX(), point.getY() - 1, point.getZ()); + Point p2 = new Point(point.getX(), point.getY() + 1, point.getZ()); + Point p3 = new Point(point.getX(), point.getY(), point.getZ() - 1); + Point p4 = new Point(point.getX(), point.getY(), point.getZ() + 1); + + Point p5 = new Point(point.getX(), point.getY() - 1, point.getZ() - 1); + Point p6 = new Point(point.getX(), point.getY() - 1, point.getZ() + 1); + Point p7 = new Point(point.getX(), point.getY() + 1, point.getZ() - 1); + Point p8 = new Point(point.getX(), point.getY() + 1, point.getZ() + 1); + + int count = kill.get(point); + + int surrounded = 0; + if (kill.getOrDefault(p1, 0) == count) surrounded++; + if (kill.getOrDefault(p2, 0) == count) surrounded++; + if (kill.getOrDefault(p3, 0) == count) surrounded++; + if (kill.getOrDefault(p4, 0) == count) surrounded++; + if (surrounded != 4) outlinePoints.add(point); + if (kill.getOrDefault(p5, 0) != count) outlinePoints.add(point); + if (kill.getOrDefault(p6, 0) != count) outlinePoints.add(point); + if (kill.getOrDefault(p7, 0) != count) outlinePoints.add(point); + if (kill.getOrDefault(p8, 0) != count) outlinePoints.add(point); + }); + zPoints.forEach(point -> { + Point p1 = new Point(point.getX() - 1, point.getY(), point.getZ()); + Point p2 = new Point(point.getX() + 1, point.getY(), point.getZ()); + Point p3 = new Point(point.getX(), point.getY() - 1, point.getZ()); + Point p4 = new Point(point.getX(), point.getY() + 1, point.getZ()); + + Point p5 = new Point(point.getX() - 1, point.getY() - 1, point.getZ()); + Point p6 = new Point(point.getX() - 1, point.getY() + 1, point.getZ()); + Point p7 = new Point(point.getX() + 1, point.getY() - 1, point.getZ()); + Point p8 = new Point(point.getX() + 1, point.getY() + 1, point.getZ()); + + int count = kill.get(point); + + int surrounded = 0; + if (kill.getOrDefault(p1, 0) == count) surrounded++; + if (kill.getOrDefault(p2, 0) == count) surrounded++; + if (kill.getOrDefault(p3, 0) == count) surrounded++; + if (kill.getOrDefault(p4, 0) == count) surrounded++; + if (surrounded != 4) outlinePoints.add(point); + if (kill.getOrDefault(p5, 0) != count) outlinePoints.add(point); + if (kill.getOrDefault(p6, 0) != count) outlinePoints.add(point); + if (kill.getOrDefault(p7, 0) != count) outlinePoints.add(point); + if (kill.getOrDefault(p8, 0) != count) outlinePoints.add(point); + }); + + double xPercent = zCount / (double) xArea; + double yPercent = yCount / (double) yArea; + double zPercent = xCount / (double) zArea; + percent = (xPercent + yPercent + zPercent) / 3; + kills = zKills + yKills + xKills; + players.forEach(this::updateBossBar); + + Set pointSet = new HashSet<>(killCount.keySet()); + Set outlinePointsCacheLast = new HashSet<>(outlinePointsCache); + outlinePointsCache.clear(); + for (Point point : pointSet) { + if (!kill.containsKey(point)) { + rEntities.get(point).die(); + rEntities.remove(point); + killCount.remove(point); + } + } + kill.forEach((point, count) -> { + if (rEntities.containsKey(point)) { + if (killCount.get(point) == count && outlinePoints.contains(point) == outlinePointsCacheLast.contains(point)) return; + rEntities.get(point).die(); + } + RFallingBlockEntity entity = new RFallingBlockEntity(outlinePoints.contains(point) ? outline : inner, point.toLocation(WORLD, 0.5, 0, 0.5), MATERIALS[Math.min(count - 1, MATERIALS.length) - 1]); + entity.setNoGravity(true); + rEntities.put(point, entity); + if (outlinePoints.contains(point)) outlinePointsCache.add(point); + killCount.put(point, count); + }); + } + + private int splitIntoDoubleKills(int kills) { + return kills * (kills - 1) / 2; + } + + private void updateBossBar(Player player) { + BauSystemBossbar bossbar = bossBarService.get(player, region, "killchecker"); + bossbar.setTitle(BauSystem.MESSAGE.parse("KILLCHECKER_BOSSBAR", player, kills, ((int) (percent * 1000) / 10.0), cannonCount)); + bossbar.setProgress(Math.min(Math.max(percent, 0), 1)); + + if (percent >= 0.35) { + bossbar.setColor(BarColor.RED); + } else if (percent >= 0.25) { + bossbar.setColor(BarColor.PURPLE); + } else if (percent >= 0.15) { + bossbar.setColor(BarColor.YELLOW); + } else { + bossbar.setColor(BarColor.GREEN); + } + } + + private Cuboid create(Material type, int x, int y, int z) { + Set checked = new HashSet<>(); + Set points = new HashSet<>(); + points.add(new Point(x, y, z)); + while (!points.isEmpty()) { + Point point = points.iterator().next(); + points.remove(point); + if (!checked.add(point)) continue; + if (point.getX() < minPoint.getX() || point.getX() > maxPoint.getX()) continue; + if (point.getY() < minPoint.getY() || point.getY() > maxPoint.getY()) continue; + if (point.getZ() < minPoint.getZ() || point.getZ() > maxPoint.getZ()) continue; + + if (WORLD.getBlockAt(point.getX() + 1, point.getY(), point.getZ()).getType() == type) { + points.add(new Point(point.getX() + 1, point.getY(), point.getZ())); + } + if (WORLD.getBlockAt(point.getX(), point.getY() + 1, point.getZ()).getType() == type) { + points.add(new Point(point.getX(), point.getY() + 1, point.getZ())); + } + if (WORLD.getBlockAt(point.getX(), point.getY(), point.getZ() + 1).getType() == type) { + points.add(new Point(point.getX(), point.getY(), point.getZ() + 1)); + } + if (WORLD.getBlockAt(point.getX() - 1, point.getY(), point.getZ()).getType() == type) { + points.add(new Point(point.getX() - 1, point.getY(), point.getZ())); + } + if (WORLD.getBlockAt(point.getX(), point.getY() - 1, point.getZ()).getType() == type) { + points.add(new Point(point.getX(), point.getY() - 1, point.getZ())); + } + if (WORLD.getBlockAt(point.getX(), point.getY(), point.getZ() - 1).getType() == type) { + points.add(new Point(point.getX(), point.getY(), point.getZ() - 1)); + } + } + + int minX = Integer.MAX_VALUE; + int maxX = Integer.MIN_VALUE; + int minY = Integer.MAX_VALUE; + int maxY = Integer.MIN_VALUE; + int minZ = Integer.MAX_VALUE; + int maxZ = Integer.MIN_VALUE; + for (Point point : checked) { + if (point.getX() < minX) minX = point.getX(); + if (point.getX() > maxX) maxX = point.getX(); + if (point.getY() < minY) minY = point.getY(); + if (point.getY() > maxY) maxY = point.getY(); + if (point.getZ() < minZ) minZ = point.getZ(); + if (point.getZ() > maxZ) maxZ = point.getZ(); + } + + return new Cuboid(minX, minY, minZ, maxX, maxY, maxZ); + } + + public boolean show(Player player, boolean onlyOutline) { + outline.addPlayer(player); + if (!onlyOutline) { + inner.addPlayer(player); + areaPlayers.add(player); + } else if (areaPlayers.contains(player)) { + inner.removePlayer(player); + areaPlayers.remove(player); + } + updateBossBar(player); + return players.add(player); + } + + public boolean hide(Player player) { + outline.removePlayer(player); + if (areaPlayers.contains(player)) { + inner.removePlayer(player); + } + players.remove(player); + areaPlayers.remove(player); + bossBarService.remove(player, region, "killchecker"); + if (players.isEmpty()) { + outline.close(); + inner.close(); + return true; + } + return false; + } + + public boolean disconnect(Player player) { + players.remove(player); + areaPlayers.remove(player); + bossBarService.remove(player, region, "killchecker"); + if (players.isEmpty()) { + outline.close(); + inner.close(); + return true; + } + return false; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java index 8c12f2de..c0d8ebc3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * 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 @@ -20,214 +20,213 @@ package de.steamwar.bausystem.features.loader; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.features.loader.activations.AbstractLoaderActivation; -import de.steamwar.bausystem.features.loader.activations.BlockPlaceLoaderActivation; -import de.steamwar.bausystem.features.loader.activations.InteractionActivation; +import de.steamwar.bausystem.features.loader.elements.LoaderElement; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; +import de.steamwar.bausystem.features.loader.elements.impl.LoaderTNT; +import de.steamwar.bausystem.features.loader.elements.impl.LoaderWait; import de.steamwar.bausystem.shared.EnumDisplay; -import lombok.AccessLevel; +import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.inventory.SWItem; +import de.steamwar.inventory.SWListInv; import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.Setter; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.scheduler.BukkitTask; import java.util.*; -@Getter -@Setter public class Loader implements Listener { private static final Map LOADER_MAP = new HashMap<>(); + + public static Loader getLoader(Player player) { + return LOADER_MAP.get(player); + } + + public static void newLoader(Player player) { + LOADER_MAP.put(player, new Loader(player)); + } + private final Player p; - private final List actions = new LinkedList<>(); - private int ticksBetweenShots = 80; - private int ticksBetweenBlocks = 1; - private Stage stage; - private int lastActivation = -1; - private int countdown = 0; - @Getter(AccessLevel.PRIVATE) - private final BukkitTask task; + @Getter + private Stage stage = Stage.SETUP; + private LoaderRecorder recorder; - @Getter(AccessLevel.PRIVATE) - @Setter(AccessLevel.PRIVATE) - private AbstractLoaderActivation current; + private List elements = new ArrayList<>(); + private int currentElement = 0; + private long waitTime = 0; - @Getter(AccessLevel.PRIVATE) - @Setter(AccessLevel.PRIVATE) - private ListIterator iterator; - - private Loader(Player p) { + public Loader(Player p) { this.p = p; - stage = Stage.SETUP; + this.recorder = new LoaderRecorder(p, elements); Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); - task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this::run, 1, 1); - } - public static Loader getLoader(Player p) { - return LOADER_MAP.getOrDefault(p, null); - } + BauSystem.runTaskTimer(BauSystem.getInstance(), () -> { + if (stage != Stage.RUNNING) return; + if (waitTime > 0) { + waitTime--; + return; + } - public static Loader newLoader(Player p) { - return LOADER_MAP.put(p, new Loader(p)); + while (currentElement < elements.size()) { + LoaderElement element = elements.get(currentElement); + currentElement++; + element.execute(delay -> waitTime = delay); + if (waitTime > 0) { + break; + } + } + if (currentElement >= elements.size()) { + currentElement = 0; + } + }, 0, 1); } public void start() { - if (stage != Stage.SETUP) return; - iterator = actions.listIterator(); - countdown = 0; - current = null; + if (stage == Stage.END) return; + if (stage == Stage.RUNNING) return; stage = Stage.RUNNING; + if (recorder != null) { + recorder.stop(); + recorder = null; + } + if (elements.isEmpty()) { + BauSystem.MESSAGE.send("LOADER_NOTHING_RECORDED", p); + stop(); + } } public void pause() { - if (stage == Stage.RUNNING) { - stage = Stage.PAUSE; + if (stage == Stage.END) return; + if (stage == Stage.PAUSE) return; + stage = Stage.PAUSE; + if (recorder != null) { + recorder.stop(); + recorder = null; } } - public void resume() { - if (stage == Stage.PAUSE) { - stage = Stage.RUNNING; - } - } - - public void setup() { - stage = Stage.SETUP; - iterator = null; - current = null; - countdown = 0; - } - public void stop() { stage = Stage.END; - task.cancel(); - LOADER_MAP.remove(p, this); + if (recorder != null) { + recorder.stop(); + recorder = null; + } + elements.clear(); + LOADER_MAP.remove(p); } - public void clear() { - if (stage == Stage.SETUP) { - actions.clear(); - BauSystem.MESSAGE.send("LOADER_MESSAGE_CLEAR", p); - } else { - BauSystem.MESSAGE.send("LOADER_MESSAGE_CLEAR_HELP", p); - } - } - - public void single() { - if (stage != Stage.PAUSE && stage != Stage.SETUP) return; - if (iterator == null || !iterator.hasNext()) { - iterator = actions.listIterator(); - countdown = 0; - current = null; - } - stage = Stage.SINGLE; - } - - public void run() { - if (stage == Stage.SETUP && lastActivation >= 0) - lastActivation++; - - if (stage != Stage.RUNNING && stage != Stage.SINGLE) { - return; - } - - if (countdown-- > 0) { - return; - } - - while (countdown <= 0) { - if (!iterator.hasNext()) { - countdown = getTicksBetweenShots(); - iterator = actions.listIterator(); - if (stage == Stage.SINGLE) stage = Stage.PAUSE; - return; + public void gui(SettingsSorting settingsSorting) { + List> list = new ArrayList<>(); + for (LoaderElement element : elements) { + if (settingsSorting != null) { + if (settingsSorting == SettingsSorting.WAIT && !(element instanceof LoaderWait)) { + continue; + } + if (settingsSorting == SettingsSorting.INTERACTIONS && (element instanceof LoaderWait || element instanceof LoaderTNT)) { + continue; + } } - - current = iterator.next(); - - if (current.execute()) { - countdown = current.delay(this); + SWItem item = element.menu(p); + if (element instanceof LoaderInteractionElement) { + LoaderInteractionElement interactionElement = (LoaderInteractionElement) element; + item.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_MODES", p, interactionElement.size()), "§8", BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", p))); } else { - countdown = 1; - iterator.previous(); + item.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", p))); } + list.add(new SWListInv.SWListEntry<>(item, element)); } - } + SWListInv swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LOADER_GUI_TITLE", p), false, list, (clickType, loaderElement) -> {}); + swListInv.setCallback((clickType, entry) -> entry.click(p, swListInv::open)); - public void undo() { - if (actions.isEmpty() || stage != Stage.SETUP) { - return; - } - actions.remove(actions.size() - 1); - } + SWItem onlyInteractionsElements = new SWItem(Material.REPEATER, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_INTERACTIONS", p), clickType -> { + gui(settingsSorting == SettingsSorting.INTERACTIONS ? null : SettingsSorting.INTERACTIONS); + }); + if (settingsSorting == SettingsSorting.INTERACTIONS) onlyInteractionsElements.setEnchanted(true); + swListInv.setItem(47, onlyInteractionsElements); - @EventHandler - public void onBlockPlace(BlockPlaceEvent event) { - if (event.getPlayer() != p) { - return; + SWItem onlyWaitElements = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS", p), clickType -> { + gui(settingsSorting == SettingsSorting.WAIT ? null : SettingsSorting.WAIT); + }); + if (settingsSorting == SettingsSorting.WAIT) onlyWaitElements.setEnchanted(true); + swListInv.setItem(48, onlyWaitElements); + + if (settingsSorting == SettingsSorting.WAIT) { + SWItem waitBetweenTNT = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_SET_BETWEEN_TNT", p), clickType -> { + SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_TITLE", p), ""); + swAnvilInv.setCallback(s -> { + try { + long delay = Long.parseLong(s); + if (delay < 0) delay = 0; + for (int i = 1; i < elements.size() - 1; i++) { + if (!(elements.get(i - 1) instanceof LoaderTNT)) continue; + if (!(elements.get(i + 1) instanceof LoaderTNT)) continue; + if (!(elements.get(i) instanceof LoaderWait)) continue; + ((LoaderWait) elements.get(i)).setDelay(delay); + } + } catch (NumberFormatException ignored) { + } + gui(settingsSorting); + }); + swAnvilInv.open(); + }); + swListInv.setItem(50, waitBetweenTNT); + + SWItem waitTime = new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_SET_ALL", p), clickType -> { + SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_TITLE", p), ""); + swAnvilInv.setCallback(s -> { + try { + long delay = Long.parseLong(s); + if (delay < 0) delay = 0; + long finalDelay = delay; + elements.stream() + .filter(LoaderWait.class::isInstance) + .map(LoaderWait.class::cast) + .forEach(loaderWait -> loaderWait.setDelay(finalDelay)); + } catch (NumberFormatException ignored) { + } + gui(settingsSorting); + }); + swAnvilInv.open(); + }); + swListInv.setItem(51, waitTime); + } else { + SWItem empty = new SWItem(Material.STRUCTURE_VOID, "§7", clickType -> {}); + swListInv.setItem(50, empty); + swListInv.setItem(51, empty); } - if (stage != Stage.SETUP) { - return; - } - - if (event.getBlock().getType() != Material.TNT) { - return; - } - - actions.add(new BlockPlaceLoaderActivation(p, event.getBlock().getLocation(), Material.TNT)); - SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("LOADER_MESSAGE_TNT", p, actions.size())); - } - - @EventHandler - public void onPlayerInteract(PlayerInteractEvent event) { - if (event.getPlayer() != p) { - return; - } - - if (stage != Stage.SETUP) { - return; - } - - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) - return; - if (event.getClickedBlock().getType() == Material.OBSERVER) - return; - LoaderButton button = LoaderButton.fromBlock(event.getClickedBlock()); - if (button != LoaderButton.INVALID) { - actions.add(InteractionActivation.construct(p, event.getClickedBlock().getLocation(), this)); - lastActivation = 0; - SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("LOADER_MESSAGE_INTERACT", p, BauSystem.MESSAGE.parse(button.getName(), p), actions.size())); - } + swListInv.open(); } @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - if (event.getPlayer() != p) { - return; - } + if (event.getPlayer() != p) return; stop(); } + public String getProgress() { + return (currentElement + 1) + "§8/§7" + elements.size(); + } + + public enum SettingsSorting { + WAIT, + INTERACTIONS, + } + @AllArgsConstructor public enum Stage implements EnumDisplay { SETUP("LOADER_SETUP"), RUNNING("LOADER_RUNNING"), - SINGLE("LOADER_SINGLE_SIDEBAR"), PAUSE("LOADER_PAUSE"), END("LOADER_END"); @Getter - private String chatValue; + private final String chatValue; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java deleted file mode 100644 index 55370c3f..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.loader; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.inventory.SWAnvilInv; -import de.steamwar.inventory.SWInventory; -import de.steamwar.inventory.SWItem; -import de.steamwar.linkage.Linked; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.Arrays; - -@Linked -public class LoaderBauGuiItem extends BauGuiItem { - - public LoaderBauGuiItem() { - super(9); - } - - @Override - public ItemStack getItem(Player player) { - return SWUtils.setCustomModelData(new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", player)), 1).getItemStack(); - } - - @Override - public boolean click(ClickType click, Player p) { - p.closeInventory(); - openLoaderGui(p); - return false; - } - - private void openLoaderGui(Player p) { - SWInventory inv = new SWInventory(p, 9, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", p)); - if (Loader.getLoader(p) == null) { - inv.setItem(4, new SWItem(Material.SCUTE, BauSystem.MESSAGE.parse("LOADER_GUI_NEW", p), clickType -> { - p.closeInventory(); - p.performCommand("loader setup"); - })); - } else { - Loader loader = Loader.getLoader(p); - if (loader.getStage() != Loader.Stage.RUNNING) { - inv.setItem(0, new SWItem(Material.GREEN_DYE, BauSystem.MESSAGE.parse("LOADER_GUI_START", p), clickType -> { - p.closeInventory(); - p.performCommand("loader start"); - })); - } else { - inv.setItem(0, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("LOADER_GUI_PAUSE", p), clickType -> { - p.closeInventory(); - p.performCommand("loader pause"); - })); - } - inv.setItem(2, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_UNDO", p), clickType -> { - p.closeInventory(); - p.performCommand("loader undo"); - })); - inv.setItem(4, new SWItem(Material.COMPASS, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT", p), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_LORE", p, loader.getTicksBetweenShots())), false, clickType -> { - p.closeInventory(); - SWAnvilInv anvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_TITLE", p)); - anvilInv.setItem(Material.CLOCK); - anvilInv.setCallback(s -> p.performCommand("loader delay " + s)); - anvilInv.open(); - })); - inv.setItem(6, new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_GUI_SPEED", p), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_SPEED_LORE", p, loader.getTicksBetweenBlocks())), false, clickType -> { - p.closeInventory(); - SWAnvilInv anvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_SPEED_TITLE", p)); - anvilInv.setItem(Material.CLOCK); - anvilInv.setCallback(s -> p.performCommand("loader speed " + s)); - anvilInv.open(); - })); - inv.setItem(8, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_STOP", p), clickType -> { - p.closeInventory(); - p.performCommand("loader stop"); - })); - } - inv.open(); - } - - @Override - public Permission permission() { - return Permission.WORLD; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderButton.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderButton.java deleted file mode 100644 index e5e74171..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderButton.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.loader; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.bukkit.block.Block; - -@AllArgsConstructor -@RequiredArgsConstructor -@Getter -public enum LoaderButton { - SWITCH(0, true, "LOADER_BUTTON_SWITCH"), - WOOD_BUTTON(30, "LOADER_BUTTON_WOOD_BUTTON"), - STONE_BUTTON(20, "LOADER_BUTTON_STONE_BUTTON"), - PRESSURE_PLATE(30, "LOADER_BUTTON_PRESSURE_PLATE"), - WEIGHTED_PRESSURE_PLATE(20, "LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE"), - TRIPWIRE(30, "LOADER_BUTTON_TRIPWIRE"), - NOTEBLOCK(1, "LOADER_BUTTON_NOTEBLOCK"), - DAYLIGHTSENSOR(0, true, "LOADER_BUTTON_DAYLIGHTSENSOR"), - INVALID(-1, "LOADER_BUTTON_INVALID"); - - private final int time; - private boolean toggle; - private final String name; - - public static LoaderButton fromBlock(Block block) { - switch (block.getType()) { - case LEVER: - return LoaderButton.SWITCH; - case ACACIA_BUTTON: - case BIRCH_BUTTON: - case DARK_OAK_BUTTON: - case JUNGLE_BUTTON: - case OAK_BUTTON: - case SPRUCE_BUTTON: - return LoaderButton.WOOD_BUTTON; - case STONE_BUTTON: - return LoaderButton.STONE_BUTTON; - case ACACIA_PRESSURE_PLATE: - case BIRCH_PRESSURE_PLATE: - case DARK_OAK_PRESSURE_PLATE: - case JUNGLE_PRESSURE_PLATE: - case OAK_PRESSURE_PLATE: - case SPRUCE_PRESSURE_PLATE: - case STONE_PRESSURE_PLATE: - return LoaderButton.PRESSURE_PLATE; - case HEAVY_WEIGHTED_PRESSURE_PLATE: - case LIGHT_WEIGHTED_PRESSURE_PLATE: - return LoaderButton.WEIGHTED_PRESSURE_PLATE; - case TRIPWIRE: - return LoaderButton.TRIPWIRE; - case NOTE_BLOCK: - return LoaderButton.NOTEBLOCK; - case DAYLIGHT_DETECTOR: - return LoaderButton.DAYLIGHTSENSOR; - default: - return LoaderButton.INVALID; - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java index ffea7e4f..ee03be16 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * 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 @@ -30,8 +30,7 @@ import org.bukkit.entity.Player; public class LoaderCommand extends SWCommand { public LoaderCommand() { - super("loader", "autoloader", "al"); - addDefaultHelpMessage("LOADER_HELP_OTHER"); + super("loader"); } private boolean loaderNullCheck(Loader loader, Player p) { @@ -43,112 +42,45 @@ public class LoaderCommand extends SWCommand { } @Register(value = "setup", description = "LOADER_HELP_SETUP") - public void setupLoader(@Validator Player p) { - if (Loader.getLoader(p) != null) { - Loader.getLoader(p).setup(); - BauSystem.MESSAGE.send("LOADER_BACK_SETUP", p); - } else { - Loader.newLoader(p); - BauSystem.MESSAGE.send("LOADER_NEW", p); - BauSystem.MESSAGE.send("LOADER_HOW_TO_START", p); + public void setupLoader(@Validator Player player) { + if (Loader.getLoader(player) != null) { + BauSystem.MESSAGE.send("LOADER_SETUP_STOP_FIRST", player); + return; } + Loader.newLoader(player); + BauSystem.MESSAGE.send("LOADER_NEW", player); + BauSystem.MESSAGE.send("LOADER_HOW_TO_START", player); } @Register(value = "start", description = "LOADER_HELP_START") - public void startLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } + public void startLoader(@Validator Player player) { + Loader loader = Loader.getLoader(player); + if (loaderNullCheck(loader, player)) return; loader.start(); - BauSystem.MESSAGE.send("LOADER_ACTIVE", p); + BauSystem.MESSAGE.send("LOADER_ACTIVE", player); } @Register(value = "stop", description = "LOADER_HELP_STOP") - public void stopLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } + public void stopLoader(@Validator Player player) { + Loader loader = Loader.getLoader(player); + if (loaderNullCheck(loader, player)) return; loader.stop(); - BauSystem.MESSAGE.send("LOADER_STOP", p); + BauSystem.MESSAGE.send("LOADER_STOP", player); } @Register(value = "pause", description = "LOADER_HELP_PAUSE") - public void pauseLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } + public void pauseLoader(@Validator Player player) { + Loader loader = Loader.getLoader(player); + if (loaderNullCheck(loader, player)) return; loader.pause(); - BauSystem.MESSAGE.send("LOADER_PAUSED", p); + BauSystem.MESSAGE.send("LOADER_PAUSED", player); } - @Register(value = "resume", description = "LOADER_HELP_RESUME") - public void resumeLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - loader.resume(); - BauSystem.MESSAGE.send("LOADER_RESUME", p); - } - - @Register(value = "wait", description = "LOADER_HELP_WAIT") - public void shotDelayLoader(@Validator Player p, int delay) { - if (delay < 1) { - BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p); - return; - } - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - BauSystem.MESSAGE.send("LOADER_NEW_TIME", p, delay, loader.getTicksBetweenShots()); - loader.setTicksBetweenShots(delay); - } - - @Register(value = "speed", description = "LOADER_HELP_SPEED") - public void speedLoader(@Validator Player p, int delay) { - if (delay < 0) { - BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p); - return; - } - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - BauSystem.MESSAGE.send("LOADER_NEW_LOAD_TIME", p, delay, loader.getTicksBetweenBlocks()); - loader.setTicksBetweenBlocks(delay); - } - - @Register(value = "undo", description = "LOADER_HELP_UNDO") - public void undoLast(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - BauSystem.MESSAGE.send("LOADER_UNDO", p); - loader.undo(); - } - - @Register(value = "clear", description = "LOADER_HELP_CLEAR") - public void clearLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - loader.clear(); - } - - @Register(value = "single", description = "LOADER_HELP_SINGLE") - public void singleLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - loader.single(); - BauSystem.MESSAGE.send("LOADER_SINGLE", p); + @Register(value = "gui", description = "LOADER_HELP_GUI") + public void guiLoader(@Validator Player player) { + Loader loader = Loader.getLoader(player); + if (loaderNullCheck(loader, player)) return; + loader.gui(null); } @ClassValidator(value = Player.class, local = true) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java new file mode 100644 index 00000000..a0734231 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java @@ -0,0 +1,203 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.SWUtils; +import de.steamwar.bausystem.features.loader.elements.LoaderElement; +import de.steamwar.bausystem.features.loader.elements.impl.*; +import de.steamwar.bausystem.features.tpslimit.TPSUtils; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.EquipmentSlot; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class LoaderRecorder implements Listener { + + private Player player; + private List loaderElementList; + private long lastInteraction = TPSUtils.currentRealTick.get(); + + public LoaderRecorder(Player player, List loaderElementList) { + this.player = player; + this.loaderElementList = loaderElementList; + Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); + } + + public void stop() { + addWaitTime(true); + HandlerList.unregisterAll(this); + player = null; + blockSet.clear(); + } + + private void addWaitTime(boolean last) { + if (loaderElementList.isEmpty()) { + lastInteraction = TPSUtils.currentRealTick.get(); + return; + } + if (loaderElementList.get(loaderElementList.size() - 1) instanceof LoaderWait) { + return; + } + long diff = TPSUtils.currentRealTick.get() - lastInteraction; + if (last && diff > 160) diff = 160; + lastInteraction = TPSUtils.currentRealTick.get(); + loaderElementList.add(new LoaderWait(diff)); + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) { + if (event.getPlayer() != player) return; + if (event.getBlock().getType() != Material.TNT) return; + + addWaitTime(false); + loaderElementList.add(new LoaderTNT(event.getBlock().getLocation())); + message("LOADER_BUTTON_TNT"); + } + + @EventHandler + public void onPlayerInteractEntity(PlayerInteractEvent event) { + if (event.getPlayer() != player) return; + if (player.isSneaking()) return; + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) return; + if (event.getClickedBlock().getType() == Material.OBSERVER) return; + if (event.getHand() == EquipmentSlot.OFF_HAND) return; + + addWaitTime(false); + Block block = event.getClickedBlock(); + Material type = block.getType(); + switch (type) { + case COMPARATOR: + loaderElementList.add(new LoaderComparator(block.getLocation())); + message("LOADER_BUTTON_COMPARATOR"); + break; + case REPEATER: + loaderElementList.add(new LoaderRepeater(block.getLocation())); + message("LOADER_BUTTON_REPEATER"); + break; + case NOTE_BLOCK: + loaderElementList.add(new LoaderNoteBlock(block.getLocation())); + message("LOADER_BUTTON_NOTEBLOCK"); + break; + case LEVER: + loaderElementList.add(new LoaderLever(block.getLocation())); + message("LOADER_BUTTON_SWITCH"); + break; + case DAYLIGHT_DETECTOR: + loaderElementList.add(new LoaderDaylightDetector(block.getLocation())); + message("LOADER_BUTTON_DAYLIGHT_DETECTOR"); + break; + case LECTERN: + loaderElementList.add(new LoaderLectern(block.getLocation())); + message("LOADER_BUTTON_LECTERN"); + break; + case IRON_TRAPDOOR: + break; + default: + if (type.name().endsWith("_TRAPDOOR")) { + loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_TRAPDOOR", type)); + message("LOADER_BUTTON_TRAPDOOR"); + } else if (type.name().endsWith("_DOOR")) { + loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_DOOR", type)); + message("LOADER_BUTTON_DOOR"); + } else if (type.name().endsWith("FENCE_GATE")) { + loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_FENCEGATE", type)); + message("LOADER_BUTTON_FENCEGATE"); + } else if (type.name().endsWith("STONE_BUTTON")) { + loaderElementList.add(new LoaderTicks(block.getLocation(), "LOADER_BUTTON_STONE_BUTTON", type, 20)); + message("LOADER_BUTTON_STONE_BUTTON"); + } else if (type.name().endsWith("BUTTON")) { + loaderElementList.add(new LoaderTicks(block.getLocation(), "LOADER_BUTTON_WOOD_BUTTON", type, 30)); + message("LOADER_BUTTON_WOOD_BUTTON"); + } + break; + } + } + + private Map blockSet = new HashMap<>(); + private Map movementSet = new HashMap<>(); + + @EventHandler + public void onPlayerMove(PlayerMoveEvent event) { + if (event.getPlayer() != player) return; + + Block fromBlock = event.getFrom().getBlock(); + Block toBlock = event.getTo().getBlock(); + calcMovementBlocks(fromBlock, toBlock); + + fromBlock = fromBlock.getRelative(0, 1, 0); + toBlock = toBlock.getRelative(0, 1, 0); + calcMovementBlocks(fromBlock, toBlock); + } + + private void calcMovementBlocks(Block fromBlock, Block toBlock) { + if (!blockSet.containsKey(toBlock.getLocation())) { + Long startTime = blockSet.remove(fromBlock.getLocation()); + LoaderMovement loaderMovement = movementSet.remove(fromBlock.getLocation()); + if (loaderMovement != null && startTime != null) { + loaderMovement.setInitialTicks(TPSUtils.currentRealTick.get() - startTime); + } + + blockSet.put(toBlock.getLocation(), TPSUtils.currentRealTick.get()); + + addWaitTime(false); + loaderMovement = null; + Material type = toBlock.getType(); + switch (type) { + case TRIPWIRE: + loaderMovement = new LoaderMovement(toBlock.getLocation(), "LOADER_BUTTON_TRIPWIRE", Material.STRING); + message("LOADER_BUTTON_TRIPWIRE"); + break; + case LIGHT_WEIGHTED_PRESSURE_PLATE: + case HEAVY_WEIGHTED_PRESSURE_PLATE: + loaderMovement = new LoaderMovement(toBlock.getLocation(), "LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE", type); + message("LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE"); + break; + default: + if (type.name().endsWith("PRESSURE_PLATE")) { + loaderMovement = new LoaderMovement(toBlock.getLocation(), "LOADER_BUTTON_PRESSURE_PLATE", type); + message("LOADER_BUTTON_PRESSURE_PLATE"); + } + break; + } + if (loaderMovement != null) { + movementSet.put(toBlock.getLocation(), loaderMovement); + loaderElementList.add(loaderMovement); + } + } + } + + private void message(String type) { + SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("LOADER_MESSAGE_INTERACT", player, BauSystem.MESSAGE.parse(type, player), loaderElementList.size())); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java new file mode 100644 index 00000000..b3e2ba2f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java @@ -0,0 +1,53 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.utils.ScoreboardElement; +import de.steamwar.linkage.Linked; +import org.bukkit.entity.Player; + +@Linked +public class LoaderScoreboardElement implements ScoreboardElement { + + @Override + public ScoreboardGroup getGroup() { + return ScoreboardGroup.OTHER; + } + + @Override + public int order() { + return 2; + } + + @Override + public String get(Region region, Player p) { + Loader loader = Loader.getLoader(p); + if (loader == null) return null; + if (loader.getStage() == Loader.Stage.RUNNING) { + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: §a" + loader.getProgress(); + } else if (loader.getStage() == Loader.Stage.PAUSE) { + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: §c" + loader.getProgress(); + } else { + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader.getStage().getChatValue(), p); + } + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/BlockPlaceLoaderActivation.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/BlockPlaceLoaderActivation.java deleted file mode 100644 index 910f2071..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/BlockPlaceLoaderActivation.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.loader.activations; - -import de.steamwar.bausystem.features.loader.Loader; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -public class BlockPlaceLoaderActivation extends AbstractLoaderActivation { - - private final Location location; - private final Material material; - - public BlockPlaceLoaderActivation(Player p, Location location, Material material) { - super(p); - this.location = location; - if (!material.isBlock()) { - throw new IllegalStateException("Only Blocks, " + material.name() + " is not a Block"); - } - this.material = material; - } - - @Override - public boolean execute() { - Block currBlock = location.getBlock(); - if (currBlock.getType() != Material.AIR && currBlock.getType() != Material.WATER) { - return false; - } - - currBlock.setType(material, true); - return true; - } - - @Override - public int delay(Loader loader) { - return loader.getTicksBetweenBlocks(); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/InteractionActivation.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/InteractionActivation.java deleted file mode 100644 index c7f27bd3..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/InteractionActivation.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.loader.activations; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loader.Loader; -import de.steamwar.bausystem.features.loader.LoaderButton; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.data.*; -import org.bukkit.block.data.type.DaylightDetector; -import org.bukkit.block.data.type.Switch; -import org.bukkit.entity.Player; - -public abstract class InteractionActivation extends AbstractLoaderActivation { - - Location location; - LoaderButton button; - - InteractionActivation(Player p, Location location, LoaderButton button) { - super(p); - this.location = location; - this.button = button; - } - - public static InteractionActivation construct(Player p, Location location, Loader loader) { - LoaderButton button = LoaderButton.fromBlock(location.getBlock()); - if (button.isToggle()) { - return new ToggleActivation(p, location, button, loader.getLastActivation()); - } else { - return new TimedActivation(p, location, button); - } - } - - void updateButton() { - Block block = location.getBlock(); - if (block.getBlockData() instanceof Switch) { - Switch sw = (Switch) block.getBlockData(); - FaceAttachable.AttachedFace face = sw.getAttachedFace(); - if (face == FaceAttachable.AttachedFace.FLOOR) { - update(block.getRelative(BlockFace.DOWN)); - } else if (face == FaceAttachable.AttachedFace.CEILING) { - update(block.getRelative(BlockFace.UP)); - } else { - update(block.getRelative(sw.getFacing().getOppositeFace())); - } - } else if (button == LoaderButton.TRIPWIRE) { - update(block); - } else if (button == LoaderButton.PRESSURE_PLATE || button == LoaderButton.WEIGHTED_PRESSURE_PLATE) { - update(block.getRelative(BlockFace.DOWN)); - } - } - - void update(Block block) { - BlockData data = block.getBlockData(); - block.setType(Material.BARRIER, true); - block.setBlockData(data, true); - } - - boolean getBlockPower() { - Block block = location.getBlock(); - BlockData data = block.getBlockData(); - if (data instanceof Powerable) { - Powerable pow = (Powerable) data; - return pow.isPowered(); - } - if (data instanceof DaylightDetector) { - DaylightDetector detector = (DaylightDetector) data; - return detector.isInverted(); - } - if (data instanceof AnaloguePowerable) { - AnaloguePowerable powerable = (AnaloguePowerable) data; - return powerable.getPower() > 0; - } - return false; - } - - void setBlockPower(boolean state) { - Block block = location.getBlock(); - BlockData data = block.getBlockData(); - if (data instanceof Powerable) { - Powerable pow = (Powerable) data; - pow.setPowered(state); - } - if (data instanceof Openable) { - Openable openable = (Openable) data; - openable.setOpen(state); - } - if (data instanceof DaylightDetector) { - DaylightDetector detector = (DaylightDetector) data; - detector.setInverted(state); - } - if (data instanceof AnaloguePowerable) { - AnaloguePowerable powerable = (AnaloguePowerable) data; - if (block.getType() == Material.REDSTONE_WIRE) { - powerable.setPower(state ? 15 : 0); - } else { - powerable.setPower(state ? 1 : 0); - } - } - block.setBlockData(data); - } - - public static class ToggleActivation extends InteractionActivation { - - private final int delay; - - public ToggleActivation(Player p, Location location, LoaderButton button, int delay) { - super(p, location, button); - this.delay = Math.max(delay, 0); - } - - @Override - public boolean execute() { - if (LoaderButton.fromBlock(location.getBlock()) == LoaderButton.INVALID) - return false; - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - setBlockPower(!getBlockPower()); - updateButton(); - }, delay); - return true; - } - - @Override - public int delay(Loader loader) { - return delay; - } - } - - public static class TimedActivation extends InteractionActivation { - - public TimedActivation(Player p, Location location, LoaderButton button) { - super(p, location, button); - } - - @Override - public boolean execute() { - if (LoaderButton.fromBlock(location.getBlock()) == LoaderButton.INVALID) - return false; - setBlockPower(true); - updateButton(); - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - setBlockPower(false); - updateButton(); - }, button.getTime()); - return true; - } - - @Override - public int delay(Loader loader) { - return button.getTime(); - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/custom/event/CustomEvent.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/ElementSettings.java similarity index 55% rename from BauSystem_Main/src/de/steamwar/bausystem/features/script/custom/event/CustomEvent.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/ElementSettings.java index ec4bebd7..55bce084 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/custom/event/CustomEvent.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/ElementSettings.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * 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 @@ -17,18 +17,22 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.script.custom.event; +package de.steamwar.bausystem.features.loader.elements; -import de.steamwar.bausystem.features.script.custom.Script; -import de.steamwar.bausystem.features.script.variables.Value; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.inventory.SWItem; import org.bukkit.entity.Player; -import java.util.Map; import java.util.function.Consumer; -public interface CustomEvent extends Script { +public interface ElementSettings { + SWItem menu(Player player); + void execute(Consumer delay); + void click(Player player, Runnable backAction, Runnable deleteAction); - String eventName(); - boolean execute(Player p, Map variables, Consumer echoConsumer); + default void playerInteract() {} + default String translateItemName(String name, String mode, Player player, Object... args) { + return BauSystem.MESSAGE.parse("LOADER_GUI_ITEM_NAME", player, BauSystem.MESSAGE.parse(name, player), BauSystem.MESSAGE.parse(mode, player, args)); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/custom/MenuScript.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderElement.java similarity index 73% rename from BauSystem_Main/src/de/steamwar/bausystem/features/script/custom/MenuScript.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderElement.java index 49befa41..658a9f8d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/custom/MenuScript.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderElement.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * 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 @@ -17,13 +17,15 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.script.custom; +package de.steamwar.bausystem.features.loader.elements; import de.steamwar.inventory.SWItem; import org.bukkit.entity.Player; -import yapion.hierarchy.types.YAPIONMap; -public interface MenuScript { - void save(YAPIONMap yapionMap); - SWItem toItem(Player p); +import java.util.function.Consumer; + +public interface LoaderElement { + SWItem menu(Player player); + void execute(Consumer delay); + void click(Player player, Runnable backAction); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderInteractionElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderInteractionElement.java new file mode 100644 index 00000000..e90491d8 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderInteractionElement.java @@ -0,0 +1,130 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.inventory.SWItem; +import de.steamwar.inventory.SWListInv; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.FaceAttachable; +import org.bukkit.block.data.type.Switch; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +public abstract class LoaderInteractionElement implements LoaderElement { + + protected final Location location; + protected int currentShot = 0; + protected List elements = new ArrayList<>(); + + protected LoaderInteractionElement(Location location) { + this.location = location; + + T element = createNewElement(); + element.playerInteract(); + elements.add(element); + } + + @Override + public void execute(Consumer delay) { + if (currentShot >= elements.size()) currentShot = 0; + elements.get(currentShot).execute(delay); + currentShot++; + if (currentShot >= elements.size()) currentShot = 0; + } + + @Override + public void click(Player player, Runnable backAction) { + List> entries = new ArrayList<>(); + for (T element : elements) { + entries.add(new SWListInv.SWListEntry<>(element.menu(player), element)); + } + + SWListInv listInv = new SWListInv<>(player, "Interaction Settings", false, entries, (clickType, entry) -> { + entry.click(player, () -> { + click(player, backAction); + }, () -> { + if (elements.size() == 1) return; + elements.remove(entry); + click(player, backAction); + }); + }); + listInv.setItem(48, new SWItem(Material.ARROW, "§7Back", clickType -> { + backAction.run(); + })); + listInv.setItem(50, new SWItem(Material.GHAST_SPAWN_EGG, "§7Insert another Setting", clickType -> { + T element = createNewElement(); + elements.add(element); + element.click(player, () -> click(player, backAction), () -> { + if (elements.size() == 1) return; + elements.remove(element); + click(player, backAction); + }); + })); + listInv.open(); + } + + protected void update(BlockData blockData) { + Material material = blockData.getMaterial(); + Block block = location.getBlock(); + if (blockData instanceof Switch) { + Switch sw = (Switch) blockData; + updateBlock(block, sw); + FaceAttachable.AttachedFace face = sw.getAttachedFace(); + if (face == FaceAttachable.AttachedFace.FLOOR) { + updateBlock(block.getRelative(BlockFace.DOWN)); + } else if (face == FaceAttachable.AttachedFace.CEILING) { + updateBlock(block.getRelative(BlockFace.UP)); + } else { + updateBlock(block.getRelative(sw.getFacing().getOppositeFace())); + } + } else if (material == Material.TRIPWIRE) { + updateBlock(block, blockData); + } else if (material.name().endsWith("_PLATE")) { + updateBlock(block.getRelative(BlockFace.DOWN)); + } + } + + protected void updateBlock(Block block) { + updateBlock(block, block.getBlockData()); + } + + protected void updateBlock(Block block, BlockData data) { + block.setType(Material.BARRIER, true); + block.setBlockData(data, true); + } + + public abstract T createNewElement(); + + protected final String translateItemName(String name, Player player) { + return BauSystem.MESSAGE.parse("LOADER_SETTING_NAME", player, BauSystem.MESSAGE.parse(name, player)); + } + + public int size() { + return elements.size(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderComparator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderComparator.java new file mode 100644 index 00000000..4ddb1f02 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderComparator.java @@ -0,0 +1,136 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.type.Comparator; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Consumer; + +public class LoaderComparator extends LoaderInteractionElement { + + public LoaderComparator(Location location) { + super(location); + } + + public class ComparatorSettings implements ElementSettings { + + private boolean interact = false; + private Comparator.Mode mode = Comparator.Mode.COMPARE; + + @Override + public SWItem menu(Player player) { + return menu(player, interact, mode); + } + + private SWItem menu(Player player, boolean interact, Comparator.Mode mode) { + SWItem swItem; + if (interact) { + swItem = new SWItem(Material.STICK, "§7Comparator§8: §eInteract"); + } else if (mode == null) { + swItem = new SWItem(Material.STRUCTURE_VOID, "§7Comparator§8: §eNOOP"); + } else { + swItem = new SWItem(Material.COMPARATOR, "§7Comparator§8: §e" + mode.name()); + } + swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player))); + return swItem; + } + + @Override + public void execute(Consumer delay) { + if (location.getBlock().getType() != Material.COMPARATOR) return; + Comparator comparator = (Comparator) location.getBlock().getBlockData(); + if (interact) { + comparator.setMode(comparator.getMode() == Comparator.Mode.COMPARE ? Comparator.Mode.SUBTRACT : Comparator.Mode.COMPARE); + } else if (mode == null) { + return; + } else { + comparator.setMode(mode); + } + location.getBlock().setBlockData(comparator, true); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player)); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, false, null).getItemStack(), clickType -> { + interact = false; + mode = null; + click(player, backAction, deleteAction); + }); + swInventory.setItem(3, item(player, true, null).getItemStack(), clickType -> { + interact = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, Comparator.Mode.COMPARE).getItemStack(), clickType -> { + interact = false; + mode = Comparator.Mode.COMPARE; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, Comparator.Mode.SUBTRACT).getItemStack(), clickType -> { + interact = false; + mode = Comparator.Mode.SUBTRACT; + click(player, backAction, deleteAction); + }); + + swInventory.open(); + } + + private SWItem item(Player player, boolean interact, Comparator.Mode mode) { + SWItem swItem = menu(player, interact, mode); + if (swItem.getItemStack().equals(menu(player, this.interact, this.mode).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + + @Override + public void playerInteract() { + interact = true; + mode = null; + } + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(Material.COMPARATOR, "§7Comparator"); + swItem.setLore(Arrays.asList("§7Modes§8: §e" + elements.size(), "§8", "§7Click to edit")); + return swItem; + } + + @Override + public ComparatorSettings createNewElement() { + return new ComparatorSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderDaylightDetector.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderDaylightDetector.java new file mode 100644 index 00000000..ed192ba4 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderDaylightDetector.java @@ -0,0 +1,158 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.type.DaylightDetector; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Consumer; + +public class LoaderDaylightDetector extends LoaderInteractionElement { + + public LoaderDaylightDetector(Location location) { + super(location); + } + + public class DaylightDetectorSettings implements ElementSettings { + + private boolean noop = false; + private boolean interact = false; + private boolean inverted = true; + private int power = 0; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, interact, inverted); + } + + private SWItem menu(Player player, boolean noop, boolean interact, boolean powered) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName("LOADER_BUTTON_DAYLIGHT_DETECTOR", "LOADER_INTERACTION_NOOP", player)); + } else if (interact) { + swItem = new SWItem(Material.STICK, translateItemName("LOADER_BUTTON_DAYLIGHT_DETECTOR", "LOADER_INTERACTION_INTERACT", player)); + } else { + swItem = new SWItem(Material.DAYLIGHT_DETECTOR, translateItemName("LOADER_BUTTON_DAYLIGHT_DETECTOR", powered ? "LOADER_INTERACTION_POWERED": "LOADER_INTERACTION_UNPOWERED", player)); + } + swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player))); + return swItem; + } + + @Override + public void execute(Consumer delay) { + if (location.getBlock().getType() != Material.DAYLIGHT_DETECTOR) return; + DaylightDetector daylightDetector = (DaylightDetector) location.getBlock().getBlockData(); + if (noop) { + return; + } else if (interact) { + daylightDetector.setInverted(!daylightDetector.isInverted()); + } else { + daylightDetector.setInverted(inverted); + } + daylightDetector.setPower(daylightDetector.isInverted() ? 15 - power : power); + location.getBlock().setBlockData(daylightDetector); + updateBlock(location.getBlock().getRelative(0, -1, 0)); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 36, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player)); + for (int i = 27; i < 35; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(27, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(35, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(3, item(player, false, true, false).getItemStack(), clickType -> { + noop = false; + interact = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, false, false).getItemStack(), clickType -> { + noop = false; + interact = false; + inverted = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, false, true).getItemStack(), clickType -> { + noop = false; + interact = false; + inverted = true; + click(player, backAction, deleteAction); + }); + + for (int i = 0; i < 16; i++) { + int finalI = i; + int finalI2 = i; + if (i >= 9) finalI2++; + swInventory.setItem(finalI2 + 9, item(player, finalI).getItemStack(), clickType -> { + power = finalI; + click(player, backAction, deleteAction); + }); + } + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, boolean interact, boolean inverted) { + SWItem swItem = menu(player, noop, interact, inverted); + if (swItem.getItemStack().equals(menu(player, this.noop, this.interact, this.inverted).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + + private SWItem item(Player player, int power) { + SWItem swItem = new SWItem(power == 0 ? Material.GUNPOWDER : Material.REDSTONE, BauSystem.MESSAGE.parse("LOADER_SETTING_POWER", player, power)); + swItem.getItemStack().setAmount(power == 0 ? 1 : power); + if (!this.noop && this.power == power) swItem.setEnchanted(true); + return swItem; + } + + @Override + public void playerInteract() { + noop = false; + interact = true; + inverted = false; + } + } + + @Override + public SWItem menu(Player player) { + return new SWItem(Material.DAYLIGHT_DETECTOR, translateItemName("LOADER_BUTTON_DAYLIGHT_DETECTOR", player)); + } + + @Override + public DaylightDetectorSettings createNewElement() { + return new DaylightDetectorSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLectern.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLectern.java new file mode 100644 index 00000000..ca16eff5 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLectern.java @@ -0,0 +1,154 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Lectern; +import org.bukkit.entity.Player; +import org.bukkit.inventory.meta.BookMeta; + +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Consumer; + +public class LoaderLectern extends LoaderInteractionElement { + + + public LoaderLectern(Location location) { + super(location); + } + + public class LecternSettings implements ElementSettings { + + private boolean noop = true; + private LecternAction action = LecternAction.PAGE_NEXT; + private int page = 0; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, action, page); + } + + private SWItem menu(Player player, boolean noop, LecternAction action, int page) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName("LOADER_BUTTON_LECTERN", "LOADER_INTERACTION_NOOP", player)); + } else if (action == LecternAction.PAGE_PREV) { + swItem = new SWItem(Material.STICK, translateItemName("LOADER_BUTTON_LECTERN", "LOADER_INTERACTION_PAGE_PREV", player)); + } else if (action == LecternAction.PAGE_NEXT) { + swItem = new SWItem(Material.STICK, translateItemName("LOADER_BUTTON_LECTERN", "LOADER_INTERACTION_PAGE_NEXT", player)); + } else { + swItem = new SWItem(Material.LECTERN, translateItemName("LOADER_BUTTON_LECTERN", "LOADER_INTERACTION_PAGE", player, page)); + swItem.getItemStack().setAmount(page); + } + swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player))); + return swItem; + } + + @Override + public void execute(Consumer delay) { + if (location.getBlock().getType() != Material.LECTERN) return; + Lectern lectern = (Lectern) location.getBlock().getState(); + if (!((org.bukkit.block.data.type.Lectern) lectern.getBlockData()).hasBook()) return; + int pages = ((BookMeta) lectern.getInventory().getItem(0).getItemMeta()).getPages().size(); + if (noop) { + return; + } else if (action == LecternAction.PAGE_PREV) { + int page = lectern.getPage(); + if (page > 1) lectern.setPage(page - 1); + } else if (action == LecternAction.PAGE_NEXT) { + int page = lectern.getPage(); + if (page < pages) lectern.setPage(page + 1); + } else if (action == LecternAction.PAGE_SET) { + if (page <= pages) lectern.setPage(page); + } + lectern.update(false, true); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 36, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player)); + for (int i = 27; i < 35; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(27, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(35, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, true, LecternAction.PAGE_SET, 0).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, LecternAction.PAGE_PREV, 0).getItemStack(), clickType -> { + noop = false; + action = LecternAction.PAGE_PREV; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, LecternAction.PAGE_NEXT, 0).getItemStack(), clickType -> { + noop = false; + action = LecternAction.PAGE_NEXT; + click(player, backAction, deleteAction); + }); + + for (int i = 0; i < 15; i++) { + int finalI = i; + int finalI2 = i; + if (i >= 9) finalI2++; + if (i >= 12) finalI2++; + swInventory.setItem(finalI2 + 9, item(player, false, LecternAction.PAGE_SET, finalI + 1).getItemStack(), clickType -> { + noop = false; + action = LecternAction.PAGE_SET; + page = finalI + 1; + click(player, backAction, deleteAction); + }); + } + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, LecternAction action, int page) { + SWItem swItem = menu(player, noop, action, page); + if (swItem.getItemStack().equals(menu(player, this.noop, this.action, this.page).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + } + + public enum LecternAction { + PAGE_NEXT, + PAGE_PREV, + PAGE_SET + } + + @Override + public SWItem menu(Player player) { + return new SWItem(Material.LECTERN, translateItemName("LOADER_BUTTON_LECTERN", player)); + } + + @Override + public LecternSettings createNewElement() { + return new LecternSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLever.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLever.java new file mode 100644 index 00000000..733a329d --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLever.java @@ -0,0 +1,131 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.type.Switch; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Consumer; + +public class LoaderLever extends LoaderInteractionElement { + + public LoaderLever(Location location) { + super(location); + } + + public class LeverSettings implements ElementSettings { + + private boolean noop = false; + private boolean interact = false; + private boolean power = false; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, interact, power); + } + + private SWItem menu(Player player, boolean noop, boolean interact, boolean power) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName("LOADER_BUTTON_SWITCH", "LOADER_INTERACTION_NOOP", player)); + } else if (interact) { + swItem = new SWItem(Material.STICK, translateItemName("LOADER_BUTTON_SWITCH", "LOADER_INTERACTION_INTERACT", player)); + } else { + swItem = new SWItem(Material.LEVER, translateItemName("LOADER_BUTTON_SWITCH", power ? "LOADER_INTERACTION_ACTIVE" : "LOADER_INTERACTION_INACTIVE", player)); + } + swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player))); + return swItem; + } + + @Override + public void execute(Consumer delay) { + if (location.getBlock().getType() != Material.LEVER) return; + if (noop) return; + + Switch lever = (Switch) location.getBlock().getBlockData(); + if (interact) { + lever.setPowered(!lever.isPowered()); + } else { + lever.setPowered(power); + } + location.getBlock().setBlockData(lever, true); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player)); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(3, item(player, false, true, false).getItemStack(), clickType -> { + noop = false; + interact = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, false, false).getItemStack(), clickType -> { + noop = false; + interact = false; + power = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, false, true).getItemStack(), clickType -> { + noop = false; + interact = false; + power = true; + click(player, backAction, deleteAction); + }); + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, boolean interact, boolean power) { + SWItem swItem = menu(player, noop, interact, power); + if (swItem.getItemStack().equals(menu(player, this.noop, this.interact, this.power).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + } + + @Override + public SWItem menu(Player player) { + return new SWItem(Material.LEVER, translateItemName("LOADER_BUTTON_LECTERN", player)); + } + + @Override + public LeverSettings createNewElement() { + return new LeverSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderMovement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderMovement.java new file mode 100644 index 00000000..9e88b13c --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderMovement.java @@ -0,0 +1,222 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.AnaloguePowerable; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Powerable; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Consumer; + +public class LoaderMovement extends LoaderInteractionElement { + + private String name; + private Material material; + private boolean analogue; + + public LoaderMovement(Location location, String name, Material material) { + super(location); + this.name = name; + this.material = material; + this.analogue = location.getBlock().getBlockData() instanceof AnaloguePowerable; + } + + public void setInitialTicks(long ticks) { + if (ticks < 1) ticks = 1; + elements.get(currentShot).ticks = ticks; + } + + public class MovementSettings implements ElementSettings { + + private boolean noop = false; + private boolean waitFor = false; + private int power = 15; + private long ticks = 1; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, waitFor); + } + + private SWItem menu(Player player, boolean noop, boolean waitFor) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName(name, "LOADER_INTERACTION_NOOP", player)); + } else if (waitFor) { + swItem = new SWItem(material, translateItemName(name, "LOADER_INTERACTION_WAIT_FOR", player)); + swItem.getItemStack().setAmount((int) Math.min(ticks, 64)); + } else { + swItem = new SWItem(material, translateItemName(name, "LOADER_INTERACTION_NO_WAIT_FOR", player)); + swItem.getItemStack().setAmount((int) Math.min(ticks, 64)); + swItem.setEnchanted(true); + } + swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player))); + return swItem; + } + + @Override + public void execute(Consumer delay) { + if (!(material == Material.STRING && location.getBlock().getType() == Material.TRIPWIRE) && location.getBlock().getType() != material) return; + if (noop) return; + + BlockData blockData = location.getBlock().getBlockData(); + if (blockData instanceof AnaloguePowerable) { + AnaloguePowerable analoguePowerable = (AnaloguePowerable) location.getBlock().getBlockData(); + analoguePowerable.setPower(power); + location.getBlock().setBlockData(analoguePowerable, true); + update(analoguePowerable); + } else if (blockData instanceof Powerable) { + Powerable powerable = (Powerable) location.getBlock().getBlockData(); + if (ticks < 0) { + powerable.setPowered(power > 0); + } else { + powerable.setPowered(true); + } + location.getBlock().setBlockData(powerable, true); + update(powerable); + } + + if (ticks >= 0) { + if (waitFor) { + delay.accept(ticks); + } + BauSystem.runTaskLater(BauSystem.getInstance(), () -> { + if (blockData instanceof AnaloguePowerable) { + AnaloguePowerable analoguePowerable = (AnaloguePowerable) blockData; + analoguePowerable.setPower(0); + location.getBlock().setBlockData(analoguePowerable, true); + update(analoguePowerable); + } else { + Powerable powerable = (Powerable) blockData; + powerable.setPowered(false); + location.getBlock().setBlockData(powerable, true); + update(powerable); + } + }, ticks); + } + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, analogue ? 45 : 27, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player)); + for (int i = analogue ? 36 : 18; i < (analogue ? 44 : 26); i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(analogue ? 36 : 18, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(analogue ? 44 : 26, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, true, false).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + if (ticks >= 0) { + swInventory.setItem(5, item(player, false, false).getItemStack(), clickType -> { + noop = false; + waitFor = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, true).getItemStack(), clickType -> { + noop = false; + waitFor = true; + click(player, backAction, deleteAction); + }); + } + + swInventory.setItem(12, new SWItem(SWItem.getDye(1), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> { + ticks -= clickType.isShiftClick() ? 5 : 1; + if (ticks < 1) ticks = 1; + swInventory.setItem(13, item(player)); + }); + swInventory.setItem(13, item(player).getItemStack(), clickType -> { + SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_NAME", player), ticks + ""); + swAnvilInv.setCallback(s -> { + try { + ticks = Long.parseLong(s); + if (ticks < 1) ticks = 1; + } catch (NumberFormatException ignored) { + } + click(player, backAction, deleteAction); + }); + swAnvilInv.open(); + }); + swInventory.setItem(14, new SWItem(SWItem.getDye(10), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> { + ticks += clickType.isShiftClick() ? 5 : 1; + swInventory.setItem(13, item(player)); + }); + + if (analogue) { + for (int i = 0; i < 16; i++) { + int finalI = i; + int finalI2 = i; + if (i >= 9) finalI2++; + swInventory.setItem(finalI2 + 18, item(player, finalI).getItemStack(), clickType -> { + power = finalI; + click(player, backAction, deleteAction); + }); + } + } + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, boolean waitFor) { + SWItem swItem = menu(player, noop, waitFor); + if (swItem.getItemStack().equals(menu(player, this.noop, this.waitFor).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + + private SWItem item(Player player, int power) { + SWItem swItem = new SWItem(power == 0 ? Material.GUNPOWDER : Material.REDSTONE, BauSystem.MESSAGE.parse("LOADER_SETTING_POWER", player, power)); + swItem.getItemStack().setAmount(power == 0 ? 1 : power); + if (!this.noop && this.power == power) swItem.setEnchanted(true); + return swItem; + } + + private SWItem item(Player player) { + SWItem swItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS", player, ticks)); + swItem.getItemStack().setAmount((int) Math.min(ticks, 64)); + swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player))); + return swItem; + } + } + + @Override + public SWItem menu(Player player) { + return new SWItem(material, translateItemName(name, player)); + } + + @Override + public MovementSettings createNewElement() { + return new MovementSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderNoteBlock.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderNoteBlock.java new file mode 100644 index 00000000..a8a5680c --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderNoteBlock.java @@ -0,0 +1,114 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Instrument; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.type.NoteBlock; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Consumer; + +public class LoaderNoteBlock extends LoaderInteractionElement { + + public LoaderNoteBlock(Location location) { + super(location); + } + + public class NoteBlockSettings implements ElementSettings { + + private boolean interact = true; + + @Override + public SWItem menu(Player player) { + return menu(player, interact); + } + + private SWItem menu(Player player, boolean interact) { + SWItem swItem; + if (interact) { + swItem = new SWItem(Material.NOTE_BLOCK, translateItemName("LOADER_BUTTON_NOTEBLOCK", "LOADER_INTERACTION_INTERACT", player)); + } else { + swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName("LOADER_BUTTON_NOTEBLOCK", "LOADER_INTERACTION_NOOP", player)); + } + swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player))); + return swItem; + } + + @Override + public void execute(Consumer delay) { + if (location.getBlock().getType() != Material.NOTE_BLOCK) return; + NoteBlock noteBlock = (NoteBlock) location.getBlock().getBlockData(); + if (interact) { + if (noteBlock.getInstrument() == Instrument.BANJO) noteBlock.setInstrument(Instrument.BIT); + else noteBlock.setInstrument(Instrument.BANJO); + } else { + return; + } + location.getBlock().setBlockData(noteBlock); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player)); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, false).getItemStack(), clickType -> { + interact = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(3, item(player, true).getItemStack(), clickType -> { + interact = true; + click(player, backAction, deleteAction); + }); + + swInventory.open(); + } + + private SWItem item(Player player, boolean interact) { + SWItem swItem = menu(player, interact); + if (swItem.getItemStack().equals(menu(player, this.interact).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + } + + @Override + public SWItem menu(Player player) { + return new SWItem(Material.NOTE_BLOCK, translateItemName("LOADER_BUTTON_NOTEBLOCK", player)); + } + + @Override + public NoteBlockSettings createNewElement() { + return new NoteBlockSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderOpenable.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderOpenable.java new file mode 100644 index 00000000..f35aed98 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderOpenable.java @@ -0,0 +1,136 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.Openable; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Consumer; + +public class LoaderOpenable extends LoaderInteractionElement { + + private String name; + private Material material; + + public LoaderOpenable(Location location, String name, Material material) { + super(location); + this.name = name; + this.material = material; + } + + public class TrapdoorSettings implements ElementSettings { + + private boolean noop = false; + private boolean interact = true; + private boolean open = false; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, interact, open); + } + + private SWItem menu(Player player, boolean noop, boolean interact, boolean powered) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName(name, "LOADER_INTERACTION_NOOP", player)); + } else if (interact) { + swItem = new SWItem(Material.STICK, translateItemName(name, "LOADER_INTERACTION_INTERACT", player)); + } else { + swItem = new SWItem(material, translateItemName(name, open ? "LOADER_INTERACTION_OPEN" : "LOADER_INTERACTION_CLOSED", player)); + } + swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player))); + return swItem; + } + + @Override + public void execute(Consumer delay) { + if (location.getBlock().getType() != material) return; + Openable openable = (Openable) location.getBlock().getBlockData(); + if (noop) { + return; + } else if (interact) { + openable.setOpen(!openable.isOpen()); + } else { + openable.setOpen(open); + } + location.getBlock().setBlockData(openable); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player)); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(3, item(player, false, true, false).getItemStack(), clickType -> { + noop = false; + interact = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, false, false).getItemStack(), clickType -> { + noop = false; + interact = false; + open = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, false, true).getItemStack(), clickType -> { + noop = false; + interact = false; + open = true; + click(player, backAction, deleteAction); + }); + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, boolean interact, boolean open) { + SWItem swItem = menu(player, noop, interact, open); + if (swItem.getItemStack().equals(menu(player, this.noop, this.interact, this.open).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + } + + @Override + public SWItem menu(Player player) { + return new SWItem(material, translateItemName(name, player)); + } + + @Override + public TrapdoorSettings createNewElement() { + return new TrapdoorSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderRepeater.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderRepeater.java new file mode 100644 index 00000000..153721a0 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderRepeater.java @@ -0,0 +1,148 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.type.Repeater; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Consumer; + +public class LoaderRepeater extends LoaderInteractionElement { + + public LoaderRepeater(Location location) { + super(location); + } + + public class RepeaterSettings implements ElementSettings { + + private boolean interact = false; + private int delay = 1; + + @Override + public SWItem menu(Player player) { + return menu(player, interact, delay); + } + + private SWItem menu(Player player, boolean interact, int delay) { + SWItem swItem; + if (interact) { + swItem = new SWItem(Material.STICK, translateItemName("LOADER_BUTTON_REPEATER", "LOADER_INTERACTION_INTERACT", player)); + } else if (delay == 0) { + swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName("LOADER_BUTTON_REPEATER", "LOADER_INTERACTION_NOOP", player)); + } else { + swItem = new SWItem(Material.REPEATER, BauSystem.MESSAGE.parse("LOADER_SETTING_REPEATER", player, delay)); + swItem.getItemStack().setAmount(delay); + } + swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player))); + return swItem; + } + + @Override + public void execute(Consumer __) { + if (location.getBlock().getType() != Material.REPEATER) return; + Repeater repeater = (Repeater) location.getBlock().getBlockData(); + if (interact) { + int delay = repeater.getDelay(); + delay++; + if (delay > 4) delay = 1; + repeater.setDelay(delay); + } else if (delay == 0) { + return; + } else { + repeater.setDelay(delay); + } + location.getBlock().setBlockData(repeater, true); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player)); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(1, item(player, false, 0).getItemStack(), clickType -> { + interact = false; + delay = 0; + click(player, backAction, deleteAction); + }); + swInventory.setItem(2, item(player, true, -1).getItemStack(), clickType -> { + interact = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(4, item(player, false, 1).getItemStack(), clickType -> { + interact = false; + delay = 1; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, 2).getItemStack(), clickType -> { + interact = false; + delay = 2; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, 3).getItemStack(), clickType -> { + interact = false; + delay = 3; + click(player, backAction, deleteAction); + }); + swInventory.setItem(7, item(player, false, 4).getItemStack(), clickType -> { + interact = false; + delay = 4; + click(player, backAction, deleteAction); + }); + + swInventory.open(); + } + + private SWItem item(Player player, boolean interact, int delay) { + SWItem swItem = menu(player, interact, delay); + if (swItem.getItemStack().equals(menu(player, this.interact, this.delay).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + + @Override + public void playerInteract() { + interact = true; + delay = 0; + } + } + + @Override + public SWItem menu(Player player) { + return new SWItem(Material.REPEATER, translateItemName("LOADER_BUTTON_REPEATER", player)); + } + + @Override + public RepeaterSettings createNewElement() { + return new RepeaterSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTNT.java new file mode 100644 index 00000000..964c5df2 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTNT.java @@ -0,0 +1,63 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loader.elements.LoaderElement; +import de.steamwar.inventory.SWItem; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.function.Consumer; + +public class LoaderTNT implements LoaderElement { + + private Location location; + + public LoaderTNT(Location location) { + this.location = location; + } + + @Override + public SWItem menu(Player player) { + SWItem item = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("LOADER_SETTING_TNT_NAME", player)); + item.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TNT_X", player, location.getBlockX()), BauSystem.MESSAGE.parse("LOADER_SETTING_TNT_Y", player, location.getBlockY()), BauSystem.MESSAGE.parse("LOADER_SETTING_TNT_Z", player, location.getBlockZ()))); + return item; + } + + @Override + public void execute(Consumer delay) { + Block block = location.getBlock(); + if (block.getType() != Material.AIR && block.getType() != Material.WATER) { + delay.accept(1L); + return; + } + + block.setType(Material.TNT, true); + } + + @Override + public void click(Player player, Runnable backAction) { + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTicks.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTicks.java new file mode 100644 index 00000000..b83d5c0b --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTicks.java @@ -0,0 +1,144 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.Powerable; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Consumer; + +public class LoaderTicks extends LoaderInteractionElement { + + private String name; + private Material material; + private int ticks; + + public LoaderTicks(Location location, String name, Material material, int ticks) { + super(location); + this.name = name; + this.material = material; + this.ticks = ticks; + } + + public class TicksSettings implements ElementSettings { + + private boolean noop = false; + private boolean waitFor = false; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, waitFor); + } + + private SWItem menu(Player player, boolean noop, boolean waitFor) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, translateItemName(name, "LOADER_INTERACTION_NOOP", player)); + } else if (waitFor) { + swItem = new SWItem(material, translateItemName(name, "LOADER_INTERACTION_WAIT_FOR", player, ticks)); + } else { + swItem = new SWItem(material, translateItemName(name, "LOADER_INTERACTION_NO_WAIT_FOR", player, ticks)); + swItem.setEnchanted(true); + } + swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player))); + return swItem; + } + + @Override + public void execute(Consumer delay) { + if (location.getBlock().getType() != material) { + return; + } + if (noop) { + return; + } + + Powerable powerable = (Powerable) location.getBlock().getBlockData(); + powerable.setPowered(true); + location.getBlock().setBlockData(powerable, true); + update(powerable); + + if (waitFor) { + delay.accept((long) ticks); + } + BauSystem.runTaskLater(BauSystem.getInstance(), () -> { + powerable.setPowered(false); + location.getBlock().setBlockData(powerable, true); + update(powerable); + }, ticks); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player)); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, true, false).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + if (ticks >= 0) { + swInventory.setItem(5, item(player, false, false).getItemStack(), clickType -> { + noop = false; + waitFor = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, true).getItemStack(), clickType -> { + noop = false; + waitFor = true; + click(player, backAction, deleteAction); + }); + } + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, boolean waitFor) { + SWItem swItem = menu(player, noop, waitFor); + if (swItem.getItemStack().equals(menu(player, this.noop, this.waitFor).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + } + + @Override + public SWItem menu(Player player) { + return new SWItem(material, translateItemName(name, player)); + } + + @Override + public TicksSettings createNewElement() { + return new TicksSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderWait.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderWait.java new file mode 100644 index 00000000..b4df1432 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderWait.java @@ -0,0 +1,91 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loader.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loader.elements.LoaderElement; +import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import lombok.Getter; +import lombok.Setter; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +import java.util.Arrays; +import java.util.function.Consumer; + +public class LoaderWait implements LoaderElement, Listener { + + @Getter + @Setter + private long delay; + + public LoaderWait(long delay) { + this.delay = delay; + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_SETTING_WAIT", player, delay)); + swItem.getItemStack().setAmount((int) Math.max(Math.min(delay, 64), 1)); + if (delay == 0) swItem.setEnchanted(true); + swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", player))); + return swItem; + } + + @Override + public void execute(Consumer __) { + __.accept(delay); + } + + @Override + public void click(Player player, Runnable backAction) { + SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_TITLE", player)); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_BACK", player)).getItemStack(), clickType -> backAction.run()); + + swInventory.setItem(3, new SWItem(SWItem.getDye(1), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> { + delay -= clickType.isShiftClick() ? 5 : 1; + if (delay < 0) delay = 0; + swInventory.setItem(4, menu(player)); + }); + swInventory.setItem(4, menu(player).getItemStack(), clickType -> { + SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_SETTING_WAIT_NAME", player), delay + ""); + swAnvilInv.setCallback(s -> { + try { + delay = Long.parseLong(s); + if (delay < 0) delay = 0; + } catch (NumberFormatException ignored) { + } + click(player, backAction); + }); + swAnvilInv.open(); + }); + swInventory.setItem(5, new SWItem(SWItem.getDye(10), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> { + delay += clickType.isShiftClick() ? 5 : 1; + swInventory.setItem(4, menu(player)); + }); + + swInventory.open(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java index c321faba..116edba5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/Loadtimer.java @@ -65,9 +65,9 @@ public class Loadtimer implements Listener { this.region = region; this.stage = Stage.WAITING; Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); - task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { + task = BauSystem.runTaskTimer(BauSystem.getInstance(), () -> { if (stage == Stage.COUNTING) { - long timeSinceStart = TPSUtils.currentTick.get() - start; + long timeSinceStart = TPSUtils.currentRealTick.get() - start; long timeSinceHalf = timeSinceStart / 2; double timeSec = (timeSinceStart / 20d); String sec = new DecimalFormat("#.#").format(timeSec); @@ -119,7 +119,7 @@ public class Loadtimer implements Listener { public void onTntPlace(BlockPlaceEvent event) { if (stage == Stage.WAITING) { this.stage = Stage.COUNTING; - this.start = TPSUtils.currentTick.get(); + this.start = TPSUtils.currentRealTick.get(); } if (stage == Stage.COUNTING) { @@ -146,9 +146,9 @@ public class Loadtimer implements Listener { public void onTntSpawn() { if ((stage == Stage.COUNTING || stage == Stage.ACTIVATED)) { stage = Stage.IGNITION; - ignite = TPSUtils.currentTick.get(); + ignite = TPSUtils.currentRealTick.get(); if (activate == -1) - activate = TPSUtils.currentTick.get(); + activate = TPSUtils.currentRealTick.get(); if (finishOnActive) { stage = Stage.END; print(); @@ -160,14 +160,14 @@ public class Loadtimer implements Listener { public void onTntExplode(EntityExplodeEvent event) { if (region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION) && stage == Stage.IGNITION) { stage = Stage.END; - explode = TPSUtils.currentTick.get(); + explode = TPSUtils.currentRealTick.get(); print(); delete(); } } private void setActivate() { - activate = TPSUtils.currentTick.get(); + activate = TPSUtils.currentRealTick.get(); stage = Stage.ACTIVATED; if (finishOnActive) { print(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java index 128c79ae..a70b143b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java @@ -89,18 +89,18 @@ public class RedstonetesterUtils { tick = null; return; } - if (TPSUtils.currentTick.get() - lastTick > 100) { + if (TPSUtils.currentRealTick.get() - lastTick > 100) { tick = null; } if (loc1.equals(location)) { - lastTick = TPSUtils.currentTick.get(); + lastTick = TPSUtils.currentRealTick.get(); if (tick == null) { - tick = TPSUtils.currentTick.get(); + tick = TPSUtils.currentRealTick.get(); } return; } if (tick != null && loc2.equals(location)) { - BauSystem.MESSAGE.send("RT_RESULT", player, (TPSUtils.currentTick.get() - tick), ((TPSUtils.currentTick.get() - tick) / 2.0)); + BauSystem.MESSAGE.send("RT_RESULT", player, (TPSUtils.currentRealTick.get() - tick), ((TPSUtils.currentRealTick.get() - tick) / 2.0)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java index 43aaf626..3cf4d1dc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java @@ -1,16 +1,19 @@ package de.steamwar.bausystem.features.region; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FireMode; +import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockSpreadEvent; @Linked -public class FireListener implements Listener { +public class FireListener implements Listener, ScoreboardElement { @EventHandler public void onFireDamage(BlockBurnEvent e) { @@ -22,4 +25,19 @@ public class FireListener implements Listener { if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FIRE, FireMode.class) == FireMode.DENY) e.setCancelled(true); } + @Override + public ScoreboardGroup getGroup() { + return ScoreboardGroup.REGION; + } + + @Override + public int order() { + return 1; + } + + @Override + public String get(Region region, Player p) { + if (region.get(Flag.FIRE) == Flag.FIRE.getDefaultValue()) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FIRE).getChatValue(), p); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java index 303bc49a..339ea122 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java @@ -33,7 +33,7 @@ import org.bukkit.entity.Player; public class FreezeCommand extends SWCommand { public FreezeCommand() { - super("freeze", "stoplag"); + super("freeze", "stoplag", "sl"); } @Register(description = "REGION_FREEZE_HELP") diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java index f8e811aa..df73575c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java @@ -4,6 +4,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; +import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.core.Core; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; @@ -11,6 +12,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.data.type.Switch; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -21,7 +23,7 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.player.PlayerInteractEvent; @Linked -public class FreezeListener implements Listener { +public class FreezeListener implements Listener, ScoreboardElement { @EventHandler public void onEntitySpawn(EntitySpawnEvent e) { @@ -98,7 +100,9 @@ public class FreezeListener implements Listener { @EventHandler public void onInventoryMoveEvent(InventoryMoveItemEvent e) { - if (Region.getRegion(e.getDestination().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + e.setCancelled(true); + } else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { e.setCancelled(true); } } @@ -182,4 +186,20 @@ public class FreezeListener implements Listener { event.setCancelled(true); } } + + @Override + public ScoreboardGroup getGroup() { + return ScoreboardGroup.REGION; + } + + @Override + public int order() { + return 2; + } + + @Override + public String get(Region region, Player p) { + if (region.get(Flag.FREEZE) == Flag.FREEZE.getDefaultValue()) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FREEZE).getChatValue(), p); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java new file mode 100644 index 00000000..3b99382d --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java @@ -0,0 +1,87 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.region; + +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.region.GlobalRegion; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.RegionUtils; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.flagvalues.ItemMode; +import de.steamwar.command.SWCommand; +import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MinVersion; +import org.bukkit.entity.Player; + +@Linked +@MinVersion(19) +public class ItemsCommand extends SWCommand { + + public ItemsCommand() { + super("items"); + } + + @Register(description = "REGION_ITEMS_HELP") + public void toggleCommand(@Validator Player p) { + Region region = Region.getRegion(p.getLocation()); + if (region != GlobalRegion.getInstance() && GlobalRegion.getInstance().getPlain(Flag.ITEMS, ItemMode.class) == ItemMode.INACTIVE) { + RegionUtils.actionBar(region, "REGION_ITEMS_DISABLED_GLOBAL"); + return; + } + + if (toggle(region)) { + RegionUtils.actionBar(region, getEnableMessage()); + } else { + RegionUtils.actionBar(region, getDisableMessage()); + } + } + + private String getNoPermMessage() { + return "REGION_ITEMS_NO_PERMS"; + } + + private String getEnableMessage(){ + return "REGION_ITEMS_ENABLED"; + } + + private String getDisableMessage(){ + return "REGION_ITEMS_DISABLED"; + } + + private boolean toggle(Region region) { + switch (region.getPlain(Flag.ITEMS, ItemMode.class)) { + case ACTIVE: + region.set(Flag.ITEMS, ItemMode.INACTIVE); + return false; + default: + case INACTIVE: + region.set(Flag.ITEMS, ItemMode.ACTIVE); + return true; + } + } + + @ClassValidator(value = Player.class, local = true) + public TypeValidator validator() { + return (commandSender, player, messageSender) -> { + return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage()); + }; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java new file mode 100644 index 00000000..66e1fdb7 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsListener.java @@ -0,0 +1,64 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.region; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.flagvalues.ItemMode; +import de.steamwar.bausystem.utils.ScoreboardElement; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MinVersion; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ItemSpawnEvent; + +@Linked +@MinVersion(19) +public class ItemsListener implements Listener, ScoreboardElement { + + private static ItemMode getMode(Region region) { + return region.getPlain(Flag.ITEMS, ItemMode.class); + } + + @EventHandler + public void onItemSpawn(ItemSpawnEvent event) { + if (getMode(Region.getRegion(event.getLocation())) == ItemMode.INACTIVE) { + event.setCancelled(true); + } + } + + @Override + public ScoreboardGroup getGroup() { + return ScoreboardGroup.REGION; + } + + @Override + public int order() { + return 3; + } + + @Override + public String get(Region region, Player p) { + if (region.get(Flag.ITEMS) == Flag.ITEMS.getDefaultValue()) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.ITEMS).getChatValue(), p); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java index e52d1ebb..65ec30de 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java @@ -1,11 +1,14 @@ package de.steamwar.bausystem.features.region; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode; +import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; import org.bukkit.Location; import org.bukkit.block.Block; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockExplodeEvent; @@ -14,7 +17,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import java.util.List; @Linked -public class ProtectListener implements Listener { +public class ProtectListener implements Listener, ScoreboardElement { private void explode(List blockList, Location location) { Region region = Region.getRegion(location); @@ -36,4 +39,21 @@ public class ProtectListener implements Listener { public void onExplode(EntityExplodeEvent event) { explode(event.blockList(), event.getLocation()); } + + @Override + public ScoreboardGroup getGroup() { + return ScoreboardGroup.REGION; + } + + @Override + public int order() { + return 2; + } + + @Override + public String get(Region region, Player p) { + if (region.getFloorLevel() == 0) return null; + if (region.get(Flag.PROTECT) != Flag.PROTECT.getDefaultValue()) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.PROTECT).getChatValue(), p); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/PowerableAttribute.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java similarity index 53% rename from BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/PowerableAttribute.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java index 3aabee78..246b9a01 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/impl/PowerableAttribute.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionScoreboardElement.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2022 SteamWar.de-Serverteam + * 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 @@ -17,32 +17,31 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.attributescopy.impl; +package de.steamwar.bausystem.features.region; -import de.steamwar.bausystem.features.attributescopy.BlockAttribute; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.GlobalRegion; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; -import org.bukkit.block.data.Powerable; - -import java.util.List; -import java.util.Set; +import org.bukkit.entity.Player; @Linked -public class PowerableAttribute implements BlockAttribute { - - private String attribute = "§8-§7 powered"; +public class RegionScoreboardElement implements ScoreboardElement { @Override - public Class type() { - return Powerable.class; + public ScoreboardGroup getGroup() { + return ScoreboardGroup.HEADER; } @Override - public void copy(List attributes, Powerable blockData) { - if (blockData.isPowered()) attributes.add(attribute); + public int order() { + return 1; } @Override - public void paste(Set attributes, Powerable blockData) { - blockData.setPowered(attributes.contains(attribute)); + public String get(Region region, Player p) { + if (GlobalRegion.getInstance() == region) return null; + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getDisplayName(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java index 670facf5..d057d59f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; @@ -28,7 +29,10 @@ import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; +import de.steamwar.sql.Punishment; import de.steamwar.sql.SchematicNode; +import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -38,6 +42,9 @@ import java.util.logging.Level; @Linked public class ResetCommand extends SWCommand { + @LinkedInstance + public BauServer bauServer; + public ResetCommand() { super("reset"); } @@ -59,6 +66,15 @@ public class ResetCommand extends SWCommand { public void schematicResetCommand(@Validator Player p, SchematicNode node) { Region region = regionCheck(p); if (region == null) return; + + if (bauServer.getOwner() != p.getUniqueId()) { + if (Punishment.isPunished(SteamwarUser.get(p.getUniqueId()), Punishment.PunishmentType.NoSchemSharing, punishment -> BauSystem.MESSAGE.parse("REGION_TB_NO_SCHEMSHARING", p, punishment.getEndTime()))) { + return; + } + } else if (Punishment.isPunished(SteamwarUser.get(bauServer.getOwner()), Punishment.PunishmentType.NoSchemReceiving, punishment -> BauSystem.MESSAGE.parse("REGION_TB_NO_SCHEMRECEIVING", p, punishment.getEndTime()))) { + return; + } + if (node.isDir()) { BauSystem.MESSAGE.send("ONLY_SCHEMS", p); return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java index 6bb5b15b..d65a8750 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java @@ -19,14 +19,14 @@ package de.steamwar.bausystem.features.region; -import de.steamwar.bausystem.features.script.CustomScriptManager; -import de.steamwar.bausystem.features.script.custom.event.EventType; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; import org.bukkit.Bukkit; @@ -35,6 +35,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent; @@ -43,12 +44,9 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @Linked -public class TNTListener implements Listener { +public class TNTListener implements Listener, ScoreboardElement { - @LinkedInstance - public CustomScriptManager customScriptManager; - - private void explode(List blockList, Location location, EventType eventType, Event event) { + private void explode(List blockList) { AtomicBoolean inBuild = new AtomicBoolean(); blockList.removeIf(block -> { Region region = Region.getRegion(block.getLocation()); @@ -68,23 +66,30 @@ public class TNTListener implements Listener { } return value == TNTMode.DENY; }); - if (inBuild.get()) { - Region region = Region.getRegion(location); - for (Player player : Bukkit.getOnlinePlayers()) { - if (region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) { - customScriptManager.callEvent(eventType, player, event); - } - } - } } @EventHandler public void onBlockExplode(BlockExplodeEvent event) { - explode(event.blockList(), event.getBlock().getLocation(), null, null); + explode(event.blockList()); } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onExplode(EntityExplodeEvent event) { - explode(event.blockList(), event.getLocation(), EventType.TNTExplodeInBuild, event); + explode(event.blockList()); + } + + @Override + public ScoreboardGroup getGroup() { + return ScoreboardGroup.REGION; + } + + @Override + public int order() { + return 0; + } + + @Override + public String get(Region region, Player p) { + return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.TNT).getChatValue(), p); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java index 67c741ce..9bff99b4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java @@ -21,15 +21,16 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.features.tracer.TraceCommand; -import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.features.tracer.show.ShowModeParameterType; +import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.*; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; +import de.steamwar.command.PreviousArguments; +import de.steamwar.sql.Punishment; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; import lombok.Getter; @@ -48,6 +49,9 @@ import java.util.stream.Collectors; @Linked public class TestblockCommand extends SWCommand { + @LinkedInstance + public BauServer bauServer; + public TestblockCommand() { super("testblock", "tb", "dummy"); } @@ -74,6 +78,14 @@ public class TestblockCommand extends SWCommand { } } + if (bauServer.getOwner() != p.getUniqueId()) { + if (Punishment.isPunished(SteamwarUser.get(p.getUniqueId()), Punishment.PunishmentType.NoSchemSharing, punishment -> BauSystem.MESSAGE.parse("REGION_TB_NO_SCHEMSHARING", p, punishment.getEndTime()))) { + return; + } + } else if (Punishment.isPunished(SteamwarUser.get(bauServer.getOwner()), Punishment.PunishmentType.NoSchemReceiving, punishment -> BauSystem.MESSAGE.parse("REGION_TB_NO_SCHEMRECEIVING", p, punishment.getEndTime()))) { + return; + } + try { region.reset(node,RegionType.TESTBLOCK, regionExtensionType,ignoreAir,onlyColors,removeTNT,removeWater); RegionUtils.message(region, "REGION_TB_DONE"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/CustomScriptManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/CustomScriptManager.java deleted file mode 100644 index 0c4e50af..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/CustomScriptManager.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.script; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.features.script.custom.MenuScript; -import de.steamwar.bausystem.features.script.custom.Script; -import de.steamwar.bausystem.features.script.custom.command.CustomCommand; -import de.steamwar.bausystem.features.script.custom.command.InventoryCommand; -import de.steamwar.bausystem.features.script.custom.command.MenuCommand; -import de.steamwar.bausystem.features.script.custom.event.CustomEvent; -import de.steamwar.bausystem.features.script.custom.event.EventType; -import de.steamwar.bausystem.features.script.custom.event.InventoryEvent; -import de.steamwar.bausystem.features.script.custom.event.MenuEvent; -import de.steamwar.bausystem.features.script.custom.hotkey.Hotkey; -import de.steamwar.bausystem.features.script.custom.hotkey.Hotkeys; -import de.steamwar.bausystem.features.script.custom.hotkey.InventoryHotkey; -import de.steamwar.bausystem.features.script.custom.hotkey.MenuHotkey; -import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.utils.FlatteningWrapper; -import de.steamwar.inventory.SWItem; -import de.steamwar.inventory.SWListInv; -import de.steamwar.linkage.Linked; -import de.steamwar.sql.UserConfig; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryCloseEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BookMeta; -import yapion.hierarchy.output.LengthOutput; -import yapion.hierarchy.output.StringOutput; -import yapion.hierarchy.types.YAPIONArray; -import yapion.hierarchy.types.YAPIONMap; -import yapion.hierarchy.types.YAPIONObject; -import yapion.hierarchy.types.YAPIONValue; -import yapion.parser.YAPIONParser; - -import java.util.*; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -@Linked -public class CustomScriptManager implements Listener { - - public final Map> playerMap = Collections.synchronizedMap(new HashMap<>()); // new ConcurrentHashMap<>(); - - private void updateInventory(Player p) { - playerMap.computeIfPresent(p, (player, customCommands) -> { - customCommands.removeIf(script -> !(script instanceof MenuScript)); - return customCommands; - }); - for (ItemStack item : p.getInventory().getContents()) { - if (item == null || FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) { - continue; - } - - BookMeta bookMeta = ((BookMeta) item.getItemMeta()); - if (bookMeta.getPageCount() == 0) { - continue; - } - if (bookMeta.getPage(1).isEmpty()) { - continue; - } - String s = bookMeta.getPage(1).split("\n")[0]; - if (s.startsWith("#!CMD /")) { - playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new InventoryCommand(bookMeta, s.substring(6).split(" "))); - } else if (s.startsWith("#!EVENT ")) { - playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new InventoryEvent(bookMeta, s.substring(8).split(" "))); - } else if (s.startsWith("#!HOTKEY ")) { - playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new InventoryHotkey(bookMeta, s.substring(9).split(" "))); - } - } - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent e) { - load(e.getPlayer()); - } - - private synchronized void load(Player p) { - updateInventory(p); - - String s = UserConfig.getConfig(p.getUniqueId(), "bausystem-scripts"); - if (s == null) { - s = UserConfig.getConfig(p.getUniqueId(), "bausystem-commands"); - UserConfig.removePlayerConfig(p.getUniqueId(), "bausystem-commands"); - } - YAPIONObject yapionObject; - if (s == null) { - yapionObject = new YAPIONObject(); - yapionObject.getYAPIONMapOrSetDefault("events", new YAPIONMap()).add("FF", new YAPIONArray().add("#!EVENT FF /gui Script\ngui")); - } else { - yapionObject = YAPIONParser.parse(s); - if (yapionObject.containsKey("")) { - yapionObject.add("commands", yapionObject.getMap("")); - yapionObject.remove(""); - yapionObject.getYAPIONMapOrSetDefault("events", new YAPIONMap()).add("FF", new YAPIONArray().add("#!EVENT FF /gui Script\ngui")); - } - } - - yapionObject.getYAPIONMapOrSetDefault("commands", new YAPIONMap()).forEach((key, value) -> { - String[] command = ((YAPIONValue) key).get().split(" "); - List pages = ((YAPIONArray) value).stream().map(YAPIONValue.class::cast).map(YAPIONValue::get).map(String.class::cast).collect(Collectors.toList()); - playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new MenuCommand(pages, command)); - }); - - yapionObject.getYAPIONMapOrSetDefault("events", new YAPIONMap()).forEach((key, value) -> { - String[] event = ((YAPIONValue) key).get().split(" "); - List pages = ((YAPIONArray) value).stream().map(YAPIONValue.class::cast).map(YAPIONValue::get).map(String.class::cast).collect(Collectors.toList()); - playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new MenuEvent(pages, event)); - }); - - yapionObject.getYAPIONMapOrSetDefault("hotkeys", new YAPIONMap()).forEach((key, value) -> { - String[] hotkey = ((YAPIONValue) key).get().split(" "); - List pages = ((YAPIONArray) value).stream().map(YAPIONValue.class::cast).map(YAPIONValue::get).map(String.class::cast).collect(Collectors.toList()); - playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(new MenuHotkey(pages, hotkey)); - }); - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent e) { - save(e.getPlayer()); - playerMap.remove(e.getPlayer()); - } - - private YAPIONObject output(Player p) { - if (!playerMap.containsKey(p)) return new YAPIONObject(); - YAPIONObject yapionObject = new YAPIONObject(); - - YAPIONMap commandsMap = new YAPIONMap(); - yapionObject.add("commands", commandsMap); - playerMap.get(p).stream().filter(MenuCommand.class::isInstance).map(MenuCommand.class::cast).forEach(menuCommand -> { - menuCommand.save(commandsMap); - }); - - YAPIONMap eventsMap = new YAPIONMap(); - yapionObject.add("events", eventsMap); - playerMap.get(p).stream().filter(MenuEvent.class::isInstance).map(MenuEvent.class::cast).forEach(menuCommand -> { - menuCommand.save(eventsMap); - }); - - YAPIONMap hotkeysMap = new YAPIONMap(); - yapionObject.add("hotkeys", hotkeysMap); - playerMap.get(p).stream().filter(MenuHotkey.class::isInstance).map(MenuHotkey.class::cast).forEach(menuCommand -> { - menuCommand.save(hotkeysMap); - }); - return yapionObject; - } - - private boolean save(Player p) { - if (!playerMap.containsKey(p)) { - UserConfig.removePlayerConfig(p.getUniqueId(), "bausystem-scripts"); - return true; - } - YAPIONObject yapionObject = output(p); - if (yapionObject.toYAPION(new LengthOutput()).getLength() > 64 * 1024) { - return false; - } - UserConfig.updatePlayerConfig(p.getUniqueId(), "bausystem-scripts", yapionObject.toYAPION(new StringOutput()).getResult()); - return true; - } - - @EventHandler - public void onInventoryClose(InventoryCloseEvent e) { - if (e.getPlayer() instanceof Player) { - updateInventory((Player) e.getPlayer()); - } - } - - public void openCommandsMenu(Player p) { - List> menuCommands = new ArrayList<>(); - playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(MenuScript.class::isInstance).map(MenuScript.class::cast).forEach(menuItem -> { - SWItem swItem = menuItem.toItem(p); - ItemStack itemStack = swItem.getItemStack(); - if (menuItem instanceof MenuHotkey) { - itemStack.setType(Material.CHAIN_COMMAND_BLOCK); - } else if (menuItem instanceof MenuEvent) { - itemStack.setType(Material.REPEATING_COMMAND_BLOCK); - } else { - itemStack.setType(Material.COMMAND_BLOCK); - } - swItem.setItemStack(itemStack); - swItem.setLore(Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_1", p), BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_2", p))); - - menuCommands.add(new SWListInv.SWListEntry<>(swItem, menuItem)); - }); - - int length = (int) output(p).toYAPION(new LengthOutput()).getLength(); - double percentage = ((int) ((length / 655336.0) * 1000)) / 10.0; - String menuName = BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_NAME", p, percentage > 99 ? "§c" : (percentage >= 75 ? "§6" : "§a"), percentage); - - SWListInv menuCommandSWListInv = new SWListInv<>(p, menuName, false, menuCommands, (clickType, menuCommand) -> { - if (!clickType.isShiftClick()) { - playerMap.get(p).removeIf(customCommand -> customCommand == menuCommand); - } - SWUtils.giveItemToPlayer(p, menuCommand.toItem(p).getItemStack()); - p.closeInventory(); - save(p); - }); - menuCommandSWListInv.setItem(49, new SWItem(Material.HOPPER, BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_ADD_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_ADD_LORE", p)), false, clickType -> { - ItemStack item = p.getItemOnCursor(); - if (item.getType().isAir()) { - return; - } - if (FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) { - return; - } - - BookMeta bookMeta = ((BookMeta) item.getItemMeta()); - if (bookMeta.getPageCount() == 0) { - return; - } - if (bookMeta.getPage(1).isEmpty()) { - return; - } - String s = bookMeta.getPage(1).split("\n")[0]; - if (s.startsWith("#!CMD /")) { - MenuCommand menuCommand = new MenuCommand(bookMeta.getPages(), s.substring(6).split(" ")); - for (Script script : playerMap.computeIfAbsent(p, player -> new ArrayList<>())) { - if (!(script instanceof MenuCommand)) { - continue; - } - if (((MenuCommand) script).equals(menuCommand)) { - BauSystem.MESSAGE.sendPrefixless("SCRIPT_MENU_GUI_DUPLICATE_COMMAND", p, String.join(" ", menuCommand.command())); - return; - } - } - scriptBookLimit(p, menuCommand); - } else if (s.startsWith("#!EVENT ")) { - MenuEvent menuEvent = new MenuEvent(bookMeta.getPages(), s.substring(8).split(" ")); - try { - EventType.valueOf(menuEvent.eventName()); - } catch (Exception e) { - BauSystem.MESSAGE.sendPrefixless("SCRIPT_MENU_GUI_UNKNOWN_EVENT", p, menuEvent.eventName()); - return; - } - scriptBookLimit(p, menuEvent); - } else if (s.startsWith("#!HOTKEY ")) { - scriptBookLimit(p, new MenuHotkey(bookMeta.getPages(), s.substring(9).split(" "))); - } - })); - menuCommandSWListInv.open(); - } - - private void scriptBookLimit(Player p, Script menuScript) { - playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(menuScript); - if (!save(p)) { - playerMap.get(p).removeIf(script -> script == menuScript); - p.closeInventory(); - SWUtils.giveItemToPlayer(p, p.getItemOnCursor()); - save(p); - BauSystem.MESSAGE.sendPrefixless("SCRIPT_MENU_GUI_LIMIT", p); - return; - } - p.setItemOnCursor(null); - openCommandsMenu(p); - } - - public boolean callCommand(Player p, PlayerCommandPreprocessEvent e, String message) { - List customCommands = playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(CustomCommand.class::isInstance).map(CustomCommand.class::cast).collect(Collectors.toList()); - String[] command = message.split(" "); - for (CustomCommand customCommand : customCommands) { - if (customCommand.execute(command, e)) { - return true; - } - } - return false; - } - - public boolean callScoreboard(Player p, Map variables, Consumer echoConsumer) { - Map valueMap = new HashMap<>(); - for (Map.Entry entry : variables.entrySet()) { - valueMap.put(entry.getKey(), new Value.StringValue(entry.getValue())); - } - List customEvents = playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(CustomEvent.class::isInstance).map(CustomEvent.class::cast).collect(Collectors.toList()); - boolean hasScript = false; - for (CustomEvent customEvent : customEvents) { - if (customEvent.eventName().equals(EventType.Scoreboard.name())) { - customEvent.execute(p, valueMap, echoConsumer); - hasScript = true; - } - } - return hasScript; - } - - public void callEvent(EventType eventType, Player p, Event e) { - if (eventType == null) return; - if (!eventType.getEventType().equals(e.getClass())) return; - - List customEvents = playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(CustomEvent.class::isInstance).map(CustomEvent.class::cast).collect(Collectors.toList()); - for (CustomEvent customEvent : customEvents) { - if (customEvent.eventName().equals(eventType.name())) { - Map variables = eventType.getEventValues().apply(e); - if (variables == null) { - variables = new HashMap<>(); - } - if (e instanceof Cancellable) { - variables.put("cancel", new Value.BooleanValue(((Cancellable) e).isCancelled())); - } - customEvent.execute(p, variables, null); - if (variables.containsKey("cancel")) { - Value value = variables.get("cancel"); - ((Cancellable) e).setCancelled(value.asBoolean()); - } - } - } - } - - public void callHotkey(int modifiers, char pressedHotkey, Player p, boolean pressed) { - List hotkeys = playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(Hotkey.class::isInstance).map(Hotkey.class::cast).collect(Collectors.toList()); - for (Hotkey hotkey : hotkeys) { - if (Hotkeys.isSame(modifiers, pressedHotkey, hotkey.hotkey())) { - hotkey.execute(p, pressed); - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/Hotkey.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/Hotkey.java new file mode 100644 index 00000000..d149eedd --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/Hotkey.java @@ -0,0 +1,77 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.script; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; + +@AllArgsConstructor +@Builder +@EqualsAndHashCode +public class Hotkey { + + private final int charcode; + + private final boolean ctrl; + private final boolean shift; + private final boolean alt; + private final boolean meta; + + public static Hotkey fromString(String string) { + String[] parts = string.split("\\+"); + HotkeyBuilder builder = Hotkey.builder(); + + for (String part : parts) { + switch (part.toLowerCase()) { + case "ctrl": + builder.ctrl(true); + break; + case "shift": + builder.shift(true); + break; + case "alt": + builder.alt(true); + break; + case "meta": + builder.meta(true); + break; + default: + if (part.length() == 1) { + builder.charcode(Character.toLowerCase(part.charAt(0))); + } else { + throw new IllegalArgumentException("Invalid hotkey: " + string); + } + } + } + + return builder.build(); + } + + public static Hotkey fromChar(int c, int mods) { + return Hotkey.builder() + .charcode(Character.toLowerCase(c)) + .shift((mods & 1) != 0) + .ctrl((mods & 2) != 0) + .alt((mods & 4) != 0) + .meta((mods & 8) != 0) + .build(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java index d9bed371..9d640d52 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java @@ -1,20 +1,28 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + package de.steamwar.bausystem.features.script; -import de.steamwar.bausystem.BauSystem; import de.steamwar.command.SWCommand; -import de.steamwar.inventory.SWItem; -import de.steamwar.inventory.SWListInv; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.LinkedInstance; -import org.bukkit.Material; import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; - -import static de.steamwar.bausystem.features.script.ScriptExecutor.SPECIAL_COMMANDS; - @Linked public class ScriptCommand extends SWCommand { @@ -22,142 +30,8 @@ public class ScriptCommand extends SWCommand { super("script"); } - @LinkedInstance - public CustomScriptManager customScriptManager = null; - - private List loreBuilder(Player p, String... strings) { - List result = new ArrayList<>(); - for (String s : strings) { - result.addAll(split(BauSystem.MESSAGE.parse(s, p))); - } - return result; - } - - @Register(description = "SCRIPT_COMMAND_HELP") - public void menuCommand(Player p) { - List> swItems = new ArrayList<>(); - addEmptyItems(swItems, 2); - swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_HOTKEYS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_1", "SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_2", "SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_3", "SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_4", "SCRIPT_GUI_CUSTOM_HOTKEYS_COMMANDS_LORE_5")), null)); - swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_COMMANDS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_1", "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_2")), null)); - swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_EVENTS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_1", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_2", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_3", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_4", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_5", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_6", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_7", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_8", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_9", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_10", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_11", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_12", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_13", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_14", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_15", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_16", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_17", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_18", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1")), null)); - addEmptyItems(swItems, 1); - swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_OTHER", loreBuilder(p, "SCRIPT_GUI_OTHER_LORE_1", "SCRIPT_GUI_OTHER_LORE_2", "SCRIPT_GUI_OTHER_LORE_3", "SCRIPT_GUI_OTHER_LORE_4", "SCRIPT_GUI_OTHER_LORE_5", "SCRIPT_GUI_OTHER_LORE_6", "SCRIPT_GUI_OTHER_LORE_7", "SCRIPT_GUI_OTHER_LORE_8", "SCRIPT_GUI_OTHER_LORE_9", "SCRIPT_GUI_OTHER_LORE_10", "SCRIPT_GUI_OTHER_LORE_11", "SCRIPT_GUI_OTHER_LORE_12", "SCRIPT_GUI_OTHER_LORE_13", "SCRIPT_GUI_OTHER_LORE_14", "SCRIPT_GUI_OTHER_LORE_15", "SCRIPT_GUI_OTHER_LORE_16", "SCRIPT_GUI_OTHER_LORE_17", "SCRIPT_GUI_OTHER_LORE_18")), null)); - addEmptyItems(swItems, 2); - addCustomScriptsItems(swItems, p); - addEmptyItems(swItems, 45 - swItems.size() % 45); - addEmptyItems(swItems, 4); - swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_VARIABLES", new ArrayList<>()), null)); - addEmptyItems(swItems, 4); - addConstantItem(swItems, p, Material.CLOCK, "SCRIPT_GUI_CONSTANT_TIME_NAME", "SCRIPT_GUI_CONSTANT_TIME_LORE"); - addConstantItem(swItems, p, Material.CLOCK, "SCRIPT_GUI_CONSTANT_TICKS_NAME", "SCRIPT_GUI_CONSTANT_TICKS_LORE"); - addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_TRACE_NAME", "SCRIPT_GUI_CONSTANT_TRACE_LORE"); - addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_AUTO_TRACE_NAME", "SCRIPT_GUI_CONSTANT_AUTO_TRACE_LORE"); - addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_TRACE_STATUS_NAME", "SCRIPT_GUI_CONSTANT_TRACE_STATUS_LORE"); - addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_TRACE_TIME_NAME", "SCRIPT_GUI_CONSTANT_TRACE_TIME_LORE"); - addConstantItem(swItems, p, Material.HOPPER, "SCRIPT_GUI_CONSTANT_LOADER_STATUS_NAME", "SCRIPT_GUI_CONSTANT_LOADER_STATUS_LORE"); - addConstantItem(swItems, p, Material.TNT, "SCRIPT_GUI_CONSTANT_TNT_NAME", "SCRIPT_GUI_CONSTANT_TNT_LORE"); - addConstantItem(swItems, p, Material.TNT, "SCRIPT_GUI_CONSTANT_ONLY_TB_NAME", "SCRIPT_GUI_CONSTANT_ONLY_TB_LORE"); - addConstantItem(swItems, p, Material.GUNPOWDER, "SCRIPT_GUI_CONSTANT_FREEZE_NAME", "SCRIPT_GUI_CONSTANT_FREEZE_LORE"); - addConstantItem(swItems, p, Material.FIRE_CHARGE, "SCRIPT_GUI_CONSTANT_FIRE_NAME", "SCRIPT_GUI_CONSTANT_FIRE_LORE"); - addConstantItem(swItems, p, Material.OBSIDIAN, "SCRIPT_GUI_CONSTANT_PROTECT_NAME", "SCRIPT_GUI_CONSTANT_PROTECT_LORE"); - addConstantItem(swItems, p, Material.PLAYER_HEAD, "SCRIPT_GUI_CONSTANT_X_NAME", "SCRIPT_GUI_CONSTANT_X_LORE"); - addConstantItem(swItems, p, Material.PLAYER_HEAD, "SCRIPT_GUI_CONSTANT_Y_NAME", "SCRIPT_GUI_CONSTANT_Y_LORE"); - addConstantItem(swItems, p, Material.PLAYER_HEAD, "SCRIPT_GUI_CONSTANT_Z_NAME", "SCRIPT_GUI_CONSTANT_Z_LORE"); - addConstantItem(swItems, p, Material.NAME_TAG, "SCRIPT_GUI_CONSTANT_NAME_NAME", "SCRIPT_GUI_CONSTANT_NAME_LORE"); - addConstantItem(swItems, p, Material.IRON_BOOTS, "SCRIPT_GUI_CONSTANT_SNEAK_NAME", "SCRIPT_GUI_CONSTANT_SNEAK_LORE"); - addConstantItem(swItems, p, Material.DIAMOND_BOOTS, "SCRIPT_GUI_CONSTANT_SPRINTING_NAME", "SCRIPT_GUI_CONSTANT_SPRINTING_LORE"); - addConstantItem(swItems, p, Material.ARROW, "SCRIPT_GUI_CONSTANT_SLOT_NAME", "SCRIPT_GUI_CONSTANT_SLOT_LORE"); - addConstantItem(swItems, p, Material.GRASS_BLOCK, "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_NAME", "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_LORE"); - addConstantItem(swItems, p, Material.IRON_BLOCK, "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_NAME", "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_LORE"); - addConstantItem(swItems, p, Material.BIRCH_SIGN, "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_NAME", "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE"); - addConstantItem(swItems, p, Material.ACACIA_SIGN, "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME", "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE"); - addConstantItem(swItems, p, Material.MAP, "SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME", "SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE"); - addConstantItem(swItems, p, Material.MAP, "SCRIPT_GUI_CONSTANT_REGION_NAME_NAME", "SCRIPT_GUI_CONSTANT_REGION_NAME_LORE"); - addConstantItem(swItems, p, Material.COMPASS, "SCRIPT_GUI_CONSTANT_TPS_NAME", "SCRIPT_GUI_CONSTANT_TPS_LORE"); - addConstantItem(swItems, p, Material.COMPASS, "SCRIPT_GUI_CONSTANT_TPS_LIMIT_NAME", "SCRIPT_GUI_CONSTANT_TPS_LIMIT_LORE"); - addEmptyItems(swItems, 45 - swItems.size() % 45); - - SWListInv swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("SCRIPT_GUI_NAME", p), swItems, (clickType, o) -> { - if (o != null) { - BauSystem.MESSAGE.send("SCRIPT_GUI_COMMAND_CHAT", p, o.command()); - for (String s : o.description()) { - if (s.isEmpty()) { - BauSystem.MESSAGE.sendPrefixless("PREFIX", p); - } else { - BauSystem.MESSAGE.send(s, p); - } - } - p.closeInventory(); - } - }); - swListInv.open(); - } - - private void addEmptyItems(List> swItems, int count) { - for (int i = 0; i < count; i++) { - swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> { - }), null)); - } - } - - private SWItem createItem(Player p, Material material, String name, List lore) { - return new SWItem(material, BauSystem.MESSAGE.parse(name, p), lore, false, clickType -> { - }); - } - - private void addConstantItem(List> swItems, Player p, Material material, String name, String lore) { - List itemLore = new ArrayList<>(); - itemLore.add(BauSystem.MESSAGE.parse(lore, p)); - swItems.add(new SWListInv.SWListEntry<>(createItem(p, material, name, itemLore), null)); - } - - private void addCustomScriptsItems(List> swItems, Player p) { - List specialCommands = new ArrayList<>(SPECIAL_COMMANDS); - specialCommands.sort(Comparator.comparing(specialCommand -> specialCommand.getClass().getTypeName())); - specialCommands.forEach(specialCommand -> { - List strings = new ArrayList<>(); - boolean b = false; - for (String s : specialCommand.description()) { - if (s.isEmpty()) { - b = true; - strings.add(""); - continue; - } - s = BauSystem.MESSAGE.parse(s, p); - if (b) { - strings.addAll(split(s)); - } else { - strings.add(s); - } - } - - SWItem swItem = new SWItem(specialCommand.material(), BauSystem.MESSAGE.parse("SCRIPT_GUI_COMMAND_NAME", p, specialCommand.command()), strings, false, clickType -> { - }); - swItems.add(new SWListInv.SWListEntry<>(swItem, specialCommand)); - }); - } - - private List split(String s) { - List strings = new ArrayList<>(); - while (s.length() > 60) { - int index = s.indexOf(' ', 60); - if (index == -1) { - strings.add("§7" + s); - s = null; - break; - } else { - strings.add("§7" + s.substring(0, index)); - s = s.substring(index + 1); - } - } - if (s != null) { - strings.add("§7" + s); - } - return strings; - } - - @Register(value = "menu", description = "SCRIPT_COMMAND_HELP_MENU") - public void menuGUICommand(Player p) { - customScriptManager.openCommandsMenu(p); + @Register + public void genericCommand(Player player) { + ScriptGUI.open(player); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java deleted file mode 100644 index 785c042b..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java +++ /dev/null @@ -1,328 +0,0 @@ -package de.steamwar.bausystem.features.script; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.event.platform.CommandEvent; -import com.sk89q.worldedit.extension.platform.Actor; -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.script.expression.Expression; -import de.steamwar.bausystem.features.script.expression.UnknownOperatorException; -import de.steamwar.bausystem.features.script.expression.VarNotFoundException; -import de.steamwar.bausystem.features.script.variables.Constants; -import de.steamwar.bausystem.features.script.variables.Context; -import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.features.world.WorldEditListener; -import de.steamwar.bausystem.linkage.LinkageUtils; -import de.steamwar.bausystem.utils.WorldEditUtils; -import lombok.Getter; -import lombok.Setter; -import net.md_5.bungee.api.ChatColor; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.inventory.meta.BookMeta; - -import java.util.*; -import java.util.function.Consumer; -import java.util.logging.Level; - -public final class ScriptExecutor { - - public static final Set SPECIAL_COMMANDS = new HashSet<>(); - - static { - LinkageUtils.linkScriptCommands(); - } - - private static final boolean hasFAWE = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null; - - private String specialCommand = null; - - @Getter - private final Player player; - - @Getter - private final Context localVariables = new Context(); - - @Getter - private final Context globalVariables; - - private final List commands = new ArrayList<>(); - - @Getter - public final Map jumpPoints = new HashMap<>(); - - @Getter - private final LinkedList returnStack = new LinkedList<>(); - - @Getter - @Setter - private int index = 0; - - @Getter - private final Consumer echoConsumer; - - public ScriptExecutor(BookMeta bookMeta, Player player, Consumer echoConsumer) { - this(bookMeta, player, new HashMap<>(), echoConsumer); - } - - public ScriptExecutor(List pages, Player player, Consumer echoConsumer) { - this(pages, player, new HashMap<>(), echoConsumer); - } - - public ScriptExecutor(BookMeta bookMeta, Player player, Map localVariables, Consumer echoConsumer) { - this.player = player; - globalVariables = ScriptListener.getGlobalContext(player); - - parseMeta(bookMeta); - this.echoConsumer = echoConsumer != null ? echoConsumer : s -> { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_IO_ECHO_MESSAGE", player, s); - }; - if (commands.isEmpty()) return; - localVariables.forEach(this.localVariables::putValue); - resume(); - } - - public ScriptExecutor(List pages, Player player, Map localVariables, Consumer echoConsumer) { - this.player = player; - globalVariables = ScriptListener.getGlobalContext(player); - - parseList(pages); - this.echoConsumer = echoConsumer != null ? echoConsumer : s -> { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_IO_ECHO_MESSAGE", player, s); - }; - if (commands.isEmpty()) return; - localVariables.forEach(this.localVariables::putValue); - resume(); - } - - private void parseMeta(BookMeta bookMeta) { - boolean initial = true; - for (String page : bookMeta.getPages()) { - initial = parsePage(page, initial); - } - } - - private void parseList(List pages) { - boolean initial = true; - for (String page : pages) { - initial = parsePage(page, initial); - } - } - - private boolean parsePage(String page, boolean initial) { - for (String command : page.split("\n")) { - command = command.replaceAll(" +", " "); - if (command.startsWith("#") || command.trim().isEmpty()) { - if (initial && command.startsWith("#!CMD /")) { - specialCommand = command.substring(7).split(" ")[0]; - } - initial = false; - continue; - } - initial = false; - if (command.startsWith(".")) { - jumpPoints.put(command.substring(1), commands.size()); - continue; - } - commands.add(command); - } - return initial; - } - - public void resume() { - if (!player.isOnline()) { - return; - } - - int executionPoints = 0; - - while (index < commands.size()) { - String command = commands.get(index).trim(); - index++; - if (executionPoints++ > 200) { - BauSystem.MESSAGE.send("SCRIPT_SLEEP_ERROR", player); - return; - } - - String[] strings = replaceExpressions(command); - if (strings.length == 0) { - return; - } - boolean found = false; - for (SpecialCommand specialCommand : SPECIAL_COMMANDS) { - if (specialCommand.command().equalsIgnoreCase(strings[0])) { - found = true; - if (!specialCommand.execute(strings, this)) { - return; - } - } - } - if (found) { - continue; - } - - if (strings[0].contains(":")) { - continue; - } - - // Variable Replaces in commands. - command = String.join(" ", strings); - - PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + (specialCommand != null && command.startsWith(specialCommand) ? "script:" : "") + command); - Bukkit.getServer().getPluginManager().callEvent(preprocessEvent); - if (preprocessEvent.isCancelled()) { - continue; - } - - Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command); - if (!strings[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + strings[0])) { - EditSession editSession = WorldEditUtils.getEditSession(player); - Actor actor = BukkitAdapter.adapt(player); - WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().handleCommandOnCurrentThread(new CommandEvent(actor, command, editSession)); - editSession.flushSession(); - WorldEditUtils.addToPlayer(player, editSession); - } else { - Bukkit.getServer().dispatchCommand(player, command); - } - } - } - - private String[] replaceExpressions(String s) { - s = s.replaceAll(" +", " "); - // TODO: Remove this code as the Expression System below will replace it! - Set variables = new HashSet<>(localVariables.allVariables()); - variables.addAll(Constants.allVariables()); - variables.addAll(globalVariables.allVariables()); - - for (int i = 0; i < 3; i++) { - for (String variable : variables) { - s = s.replace("<" + variable + ">", getValue(variable)); - s = s.replace("<" + variable + ".type>", getOrItselfValue(variable).type()); - } - for (String constVariable : Constants.allVariables()) { - s = s.replace("", getConstant(constVariable)); - s = s.replace("", Constants.getConstant(constVariable, player).type()); - } - for (String localVariable : localVariables.allVariables()) { - s = s.replace("", getLocal(localVariable)); - s = s.replace("", getLocalVariables().getValue(localVariable).type()); - } - for (String globalVariable : globalVariables.allVariables()) { - s = s.replace("", getGlobal(globalVariable)); - s = s.replace("", globalVariables.getValue(globalVariable).type()); - } - } - - StringBuilder result = new StringBuilder(); - int depth = 0; - StringBuilder st = new StringBuilder(); - for (int i = 0; i < s.length(); i++) { - char c = s.charAt(i); - if (c == '{') { - st.append(c); - depth++; - } else if (c == '}') { - st.append(c); - depth--; - if (depth == 0) { - try { - Expression expression = new Expression(player, st.toString(), this); - result.append(expression.eval().asString()); - st = new StringBuilder(); - } catch (IllegalArgumentException e) { - BauSystem.MESSAGE.send(e.getMessage(), player); - return new String[0]; - } catch (VarNotFoundException e) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_UNKNOWN_VAR", player, e.getMessage()); - return new String[0]; - } catch (IndexOutOfBoundsException e) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_EXPRESSION", player, st.toString()); - return new String[0]; - } catch (UnknownOperatorException e) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_UNKNOWN_OPERATION", player, e.getMessage()); - return new String[0]; - } - } - } else if (st.length() > 0) { - st.append(c); - } else { - result.append(c); - } - } - return result.toString().split(" "); - } - - public Value getOrItselfValue(String variable) { - if (!isVariable(variable)) { - return Value.parse(variable); - } - - if (localVariables.hasValue(variable)) { - return localVariables.getValue(variable); - } - if (globalVariables.hasValue(variable)) { - return globalVariables.getValue(variable); - } - return Constants.getConstant(variable, player); - } - - public Value getValueOrNull(String variable) { - if (localVariables.hasValue(variable)) { - return localVariables.getValue(variable); - } - if (globalVariables.hasValue(variable)) { - return globalVariables.getValue(variable); - } - if (Constants.isConstant(variable)) { - return Constants.getConstant(variable, player); - } - return null; - } - - public String getOrItself(String variable) { - if (isVariable(variable)) { - return getValue(variable); - } - return variable; - } - - public boolean isVariable(String variable) { - return Constants.isConstant(variable) || globalVariables.hasValue(variable) || localVariables.hasValue(variable); - } - - public String getValue(String variable) { - if (localVariables.hasValue(variable)) { - return localVariables.getValue(variable).asString(); - } - if (globalVariables.hasValue(variable)) { - return globalVariables.getValue(variable).asString(); - } - if (Constants.isConstant(variable)) { - return Constants.getConstant(variable, player).asString(); - } - return ""; - } - - public String getConstant(String variable) { - if (Constants.isConstant(variable)) { - return Constants.getConstant(variable, player).asString(); - } - return "0"; - } - - public String getGlobal(String variable) { - if (globalVariables.hasValue(variable)) { - return globalVariables.getValue(variable).asString(); - } - return "0"; - } - - public String getLocal(String variable) { - if (localVariables.hasValue(variable)) { - return localVariables.getValue(variable).asString(); - } - return "0"; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptGUI.java new file mode 100644 index 00000000..c8098fed --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptGUI.java @@ -0,0 +1,126 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.script; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.script.lua.SteamWarPlatform; +import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.inventory.SWItem; +import de.steamwar.inventory.SWListInv; +import de.steamwar.linkage.Linked; +import de.steamwar.sql.Script; +import de.steamwar.sql.SteamwarUser; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BookMeta; +import org.luaj.vm2.Globals; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +@Linked +public class ScriptGUI implements Listener { + public static void open(Player player) { + open(player, null); + } + + private static void open(Player player, ItemStack setCursor) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + List> entries = new ArrayList<>(); + List lore = new ArrayList<>(); + Globals globals = SteamWarPlatform.createGlobalParser( + (eventType, luaFunction) -> lore.add(BauSystem.MESSAGE.parse("SCRIPT_EVENT_ITEM_NAME", player, eventType.name())), + (s, luaFunction) -> lore.add(BauSystem.MESSAGE.parse("SCRIPT_HOTKEY_ITEM_NAME", player, s)), + commandRegister -> lore.add(BauSystem.MESSAGE.parse("SCRIPT_COMMAND_ITEM_NAME", player, commandRegister.getName())) + ); + + Script.list(user).forEach(script -> { + try { + globals.load(script.getCode()).call(); + } catch (Exception e) { + String[] sp = e.getMessage().split(":"); + lore.add(BauSystem.MESSAGE.parse("SCRIPT_ERROR_GUI", player, String.join(":", Arrays.copyOfRange(sp, 1, sp.length)))); + } + + if(!lore.isEmpty()) { + lore.add(""); + } + lore.add(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_1", player)); + lore.add(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_2", player)); + lore.add(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_3", player)); + lore.add(BauSystem.MESSAGE.parse("SCRIPT_MENU_GUI_ITEM_LORE_4", player)); + + entries.add(new SWListInv.SWListEntry<>(new SWItem(Material.ENCHANTED_BOOK, script.getName(), new ArrayList<>(lore), false, clickType -> {}), script)); + lore.clear(); + }); + + SWListInv