From 28bb95f00045348eab355bafa6051fc6a362dab6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 10 Feb 2022 16:15:40 +0100 Subject: [PATCH 01/15] Add package for 1.18 support Signed-off-by: yoyosource --- BauSystem_18/build.gradle | 56 +++++++++++++++++++ BauSystem_18/settings.gradle | 20 +++++++ .../src/de/steamwar/bausystem/.gitkeep | 0 settings.gradle | 1 + 4 files changed, 77 insertions(+) create mode 100644 BauSystem_18/build.gradle create mode 100644 BauSystem_18/settings.gradle create mode 100644 BauSystem_18/src/de/steamwar/bausystem/.gitkeep diff --git a/BauSystem_18/build.gradle b/BauSystem_18/build.gradle new file mode 100644 index 00000000..c82bd95c --- /dev/null +++ b/BauSystem_18/build.gradle @@ -0,0 +1,56 @@ +/* + * 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 . + */ + +plugins { + id 'base' + id 'java' +} + +group 'steamwar' +version '1.0' + +compileJava.options.encoding = 'UTF-8' + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +sourceSets { + main { + java { + srcDirs = ['src/'] + } + resources { + srcDirs = ['src/'] + exclude '**/*.java', '**/*.kt' + } + } +} + +dependencies { + compileOnly 'org.projectlombok:lombok:1.18.22' + testCompileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' + + implementation project(":BauSystem_Main") + + compileOnly files("${projectDir}/../lib/Spigot-1.18.jar") + compileOnly files("${projectDir}/../lib/WorldEdit-1.18.jar") + compileOnly files("${projectDir}/../lib/SpigotCore.jar") +} \ No newline at end of file diff --git a/BauSystem_18/settings.gradle b/BauSystem_18/settings.gradle new file mode 100644 index 00000000..808663da --- /dev/null +++ b/BauSystem_18/settings.gradle @@ -0,0 +1,20 @@ +/* + * 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 . + */ + +rootProject.name = 'BauSystem_18' \ No newline at end of file diff --git a/BauSystem_18/src/de/steamwar/bausystem/.gitkeep b/BauSystem_18/src/de/steamwar/bausystem/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/settings.gradle b/settings.gradle index 1a175985..9fec40dd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -20,4 +20,5 @@ rootProject.name = 'BauSystem2.0' include 'BauSystem_15' +include 'BauSystem_18' include 'BauSystem_Main' -- 2.39.2 From 4ee537e0177de3e3abddf64c0d32bbc535043098 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 10 Feb 2022 16:28:15 +0100 Subject: [PATCH 02/15] Add needed classes Signed-off-by: yoyosource --- BauSystem_18/build.gradle | 3 +- .../bausystem/entities/DetonatorEntity18.java | 89 +++++++++++++++ .../bausystem/entities/SimulatorEntity18.java | 66 ++++++++++++ .../bausystem/entities/TraceEntity18.java | 73 +++++++++++++ .../bausystem/entities/WarpEntity18.java | 60 +++++++++++ .../bausystem/shared/BaseArmorStand18.java | 62 +++++++++++ .../bausystem/shared/BaseEntity18.java | 67 ++++++++++++ .../bausystem/utils/FlatteningWrapper18.java | 102 ++++++++++++++++++ .../bausystem/utils/NMSWrapper18.java | 80 ++++++++++++++ build.gradle | 12 +++ 10 files changed, 613 insertions(+), 1 deletion(-) create mode 100644 BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java create mode 100644 BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java create mode 100644 BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java create mode 100644 BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java create mode 100644 BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java create mode 100644 BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java create mode 100644 BauSystem_18/src/de/steamwar/bausystem/utils/FlatteningWrapper18.java create mode 100644 BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java diff --git a/BauSystem_18/build.gradle b/BauSystem_18/build.gradle index c82bd95c..ecacac8c 100644 --- a/BauSystem_18/build.gradle +++ b/BauSystem_18/build.gradle @@ -50,7 +50,8 @@ dependencies { implementation project(":BauSystem_Main") + compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT' compileOnly files("${projectDir}/../lib/Spigot-1.18.jar") - compileOnly files("${projectDir}/../lib/WorldEdit-1.18.jar") + compileOnly files("${projectDir}/../lib/WorldEdit-1.15.jar") compileOnly files("${projectDir}/../lib/SpigotCore.jar") } \ No newline at end of file diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java new file mode 100644 index 00000000..2e586e41 --- /dev/null +++ b/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java @@ -0,0 +1,89 @@ +/* + * 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 com.sk89q.worldedit.blocks.Blocks; +import com.sk89q.worldedit.world.entity.EntityTypes; +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.item.EntityFallingBlock; +import net.minecraft.world.phys.Vec3D; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R1.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.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_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java new file mode 100644 index 00000000..40e60355 --- /dev/null +++ b/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java @@ -0,0 +1,66 @@ +/* + 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 de.steamwar.bausystem.shared.ReferenceCounter; +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 ReferenceCounter referenceCounter = new ReferenceCounter(); + + public SimulatorEntity18(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 (referenceCounter.increment() > 0) { + return; + } + + 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 (!force && referenceCounter.decrement() > 0) { + return false; + } + + sendEntityDestroy(player); + die(); + return true; + } +} diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java new file mode 100644 index 00000000..cdd5c191 --- /dev/null +++ b/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java @@ -0,0 +1,73 @@ +/* + 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.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 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.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_18/src/de/steamwar/bausystem/entities/WarpEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java new file mode 100644 index 00000000..3d439b3c --- /dev/null +++ b/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java @@ -0,0 +1,60 @@ +/* + * 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.server.v1_15_R1.ChatComponentText; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public class WarpEntity18 extends BaseArmorStand18 implements AbstractWarpEntity { + + private String name; + + public WarpEntity18(World world, Vector position, String name) { + super(world, position); + setInvisible(true); + setSmall(true); + this.name = name; + this.setNoGravity(true); + this.ticksLived = -12000; + } + + @Override + public void display(Player player) { + this.setCustomNameVisible(true); + this.setCustomName(new ChatComponentText(name)); + sendEntity(player); + } + + @Override + public void setName(String name) { + this.name = name; + } + + @Override + public boolean hide(Player player) { + sendEntityDestroy(player); + die(); + return true; + } +} diff --git a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java new file mode 100644 index 00000000..65e2ee52 --- /dev/null +++ b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java @@ -0,0 +1,62 @@ +/* + * 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 com.sk89q.worldedit.world.entity.EntityTypes; +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.decoration.EntityArmorStand; +import net.minecraft.world.phys.Vec3D; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_18_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R1.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; + 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_18/src/de/steamwar/bausystem/shared/BaseEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java new file mode 100644 index 00000000..ea863593 --- /dev/null +++ b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java @@ -0,0 +1,67 @@ +/* + * 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 com.sk89q.worldedit.world.entity.EntityTypes; +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.item.EntityFallingBlock; +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_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData; +import org.bukkit.craftbukkit.v1_18_R1.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.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_18/src/de/steamwar/bausystem/utils/FlatteningWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/FlatteningWrapper18.java new file mode 100644 index 00000000..e0b261bd --- /dev/null +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/FlatteningWrapper18.java @@ -0,0 +1,102 @@ +/* + * 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.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import de.steamwar.bausystem.region.Color; +import de.steamwar.bausystem.region.PasteOptions; +import de.steamwar.bausystem.region.Point; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.io.File; + +public class FlatteningWrapper18 implements FlatteningWrapper.IFlatteningWrapper { + + @Override + public boolean isNoBook(ItemStack item) { + return false; + } + + @Override + public boolean isUnpusheable(Material material) { + return false; + } + + @Override + public boolean isBreakingOnPush(Material material) { + return false; + } + + @Override + public boolean isWorldEditCommand(String command) { + return false; + } + + @Override + public void setSelection(Player p, Point minPoint, Point maxPoint) { + + } + + @Override + public EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) { + return null; + } + + @Override + public EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) { + return null; + } + + @Override + public void changeColor(Clipboard clipboard, Color color) throws WorldEditException { + + } + + @Override + public boolean backup(Point minPoint, Point maxPoint, File file) { + return false; + } + + @Override + public boolean inWater(World world, Vector tntPosition) { + return false; + } + + @Override + public Material getTraceShowMaterial() { + return null; + } + + @Override + public Material getTraceHideMaterial() { + return null; + } + + @Override + public Material getTraceXZMaterial() { + return null; + } +} diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java new file mode 100644 index 00000000..6d08609b --- /dev/null +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -0,0 +1,80 @@ +/* + * 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 de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; +import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; +import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; +import de.steamwar.bausystem.features.warp.AbstractWarpEntity; +import org.bukkit.GameMode; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.function.LongSupplier; + +public class NMSWrapper18 implements NMSWrapper.INMSWrapper { + + @Override + public void setInternalGameMode(Player player, GameMode gameMode) { + + } + + @Override + public void init(LongSupplier longSupplier) { + + } + + @Override + public void createTickCache(World world) { + + } + + @Override + public void sendTickPackets() { + + } + + @Override + public boolean checkItemStack(ItemStack item) { + return false; + } + + @Override + public AbstractWarpEntity createWarp(World world, Vector position, String name) { + return null; + } + + @Override + public AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight) { + return null; + } + + @Override + public AbstractDetonatorEntity constructDetonator(World world, Vector position) { + return null; + } + + @Override + public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) { + return null; + } +} diff --git a/build.gradle b/build.gradle index 6ad8376b..a94cd724 100644 --- a/build.gradle +++ b/build.gradle @@ -75,6 +75,18 @@ allprojects { maven { url = uri("https://raw.githubusercontent.com/yoyosource/YAPION/master/releases") } + + maven { + url = uri("https://repo.codemc.io/repository/maven-snapshots/") + } + + maven { + url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') + } + + maven { + url = uri('https://libraries.minecraft.net') + } } } -- 2.39.2 From 4bb25a4ca7c6fd567184bbf0ec9ee545e03cb386 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 10 Feb 2022 17:21:35 +0100 Subject: [PATCH 03/15] Update some stuff Signed-off-by: yoyosource --- .../bausystem/entities/SimulatorEntity18.java | 13 ++++++++---- .../bausystem/shared/BaseArmorStand18.java | 20 +++++++++--------- .../bausystem/shared/BaseEntity18.java | 21 ++++++++++--------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java index 40e60355..b3165142 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java @@ -34,8 +34,13 @@ public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulator public SimulatorEntity18(World world, Vector position, boolean highlight) { super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT); - this.setNoGravity(true); - this.ticksLived = -12000; + this.e(true); + this.S = -12000; + } + + @Override + public int getId() { + return ae(); } @Override @@ -50,7 +55,7 @@ public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulator @Override public void setPosition(Vector position) { this.position = position; - setPosition(position.getX(), position.getY(), position.getZ()); + e(position.getX(), position.getY(), position.getZ()); } @Override @@ -60,7 +65,7 @@ public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulator } sendEntityDestroy(player); - die(); + ag(); return true; } } diff --git a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java index 65e2ee52..b0a91d9e 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java @@ -19,11 +19,11 @@ package de.steamwar.bausystem.shared; -import com.sk89q.worldedit.world.entity.EntityTypes; 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; @@ -42,21 +42,21 @@ public class BaseArmorStand18 extends EntityArmorStand implements AbstractEntity super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ()); this.position = position; - setNoGravity(true); - ticksLived = -12000; + e(true); + S = -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); + 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(getId(), datawatcher, true); - playerConnection.sendPacket(packetPlayOutEntityMetadata); + PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Z, true); + playerConnection.a(packetPlayOutEntityMetadata); } public void sendEntityDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); + 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 index ea863593..b331f0da 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java @@ -19,12 +19,13 @@ package de.steamwar.bausystem.shared; -import com.sk89q.worldedit.world.entity.EntityTypes; 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; @@ -47,21 +48,21 @@ public class BaseEntity18 extends EntityFallingBlock implements AbstractEntity { this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState(); this.position = position; - this.setNoGravity(true); - this.ticksLived = -12000; + this.e(true); + this.S = -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); + 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(getId(), datawatcher, true); - playerConnection.sendPacket(packetPlayOutEntityMetadata); + PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Z, true); + playerConnection.a(packetPlayOutEntityMetadata); } public void sendEntityDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); + PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae()); + ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy); } } -- 2.39.2 From 9b4fe3c9d61914fa22cd5414d1fdf8c998403653 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 10 Feb 2022 17:35:12 +0100 Subject: [PATCH 04/15] Update some stuff Signed-off-by: yoyosource --- .../bausystem/entities/DetonatorEntity18.java | 28 +++++++++++-------- .../bausystem/entities/TraceEntity18.java | 16 +++++------ .../bausystem/entities/WarpEntity18.java | 16 +++++------ 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java index 2e586e41..bf1f670b 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java @@ -19,7 +19,6 @@ package de.steamwar.bausystem.entities; -import com.sk89q.worldedit.blocks.Blocks; import com.sk89q.worldedit.world.entity.EntityTypes; import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy; @@ -27,6 +26,8 @@ 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.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_R1.CraftWorld; @@ -41,12 +42,17 @@ public class DetonatorEntity18 extends EntityFallingBlock implements AbstractDet private int references = 0; public DetonatorEntity18(World world, Vector position) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.RED_STAINED_GLASS.getBlockData()); + super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.du.n()); this.position = position; this.h(true); - this.setNoGravity(true); - this.ticksLived = -12000; + this.e(true); + this.S = -12000; + } + + @Override + public int getId() { + return ae(); } @Override @@ -54,12 +60,12 @@ public class DetonatorEntity18 extends EntityFallingBlock implements AbstractDet 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); + PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, Block.i(Blocks.du.n()), ZERO); + PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; + playerConnection.a(packetPlayOutSpawnEntity); - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); - playerConnection.sendPacket(packetPlayOutEntityMetadata); + PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Z, true); + playerConnection.a(packetPlayOutEntityMetadata); } @Override @@ -68,13 +74,13 @@ public class DetonatorEntity18 extends EntityFallingBlock implements AbstractDet return false; sendDestroy(player); - die(); + ag(); return true; } private void sendDestroy(Player player) { PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); + ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy); } @Override diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java index cdd5c191..437c2620 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/entities/TraceEntity18.java @@ -22,7 +22,7 @@ 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.server.v1_15_R1.ChatComponentText; +import net.minecraft.network.chat.ChatComponentText; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.entity.Player; @@ -36,19 +36,19 @@ public class TraceEntity18 extends BaseEntity18 implements AbstractTraceEntity { public TraceEntity18(World world, Vector position, boolean tnt) { super(world, position, tnt ? Material.TNT : Material.WHITE_STAINED_GLASS); - this.setNoGravity(true); - this.ticksLived = -12000; + this.e(true); + this.S = -12000; } @Override public void display(Player player, boolean exploded, int ticks) { if (ticks != -1) { - this.setCustomNameVisible(true); - this.setCustomName(new ChatComponentText(ticks + "")); + this.n(true); + this.a(new ChatComponentText(ticks + "")); } if (!this.exploded && exploded) { - this.setCustomNameVisible(true); - this.setCustomName(new ChatComponentText("Bumm")); + this.n(true); + this.a(new ChatComponentText("Bumm")); this.exploded = true; if (referenceCounter.increment() > 0) { sendEntityDestroy(player); @@ -67,7 +67,7 @@ public class TraceEntity18 extends BaseEntity18 implements AbstractTraceEntity { } sendEntityDestroy(player); - die(); + 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 index 3d439b3c..d18bb067 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java @@ -21,7 +21,7 @@ package de.steamwar.bausystem.entities; import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import de.steamwar.bausystem.shared.BaseArmorStand18; -import net.minecraft.server.v1_15_R1.ChatComponentText; +import net.minecraft.network.chat.ChatComponentText; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -32,17 +32,17 @@ public class WarpEntity18 extends BaseArmorStand18 implements AbstractWarpEntity public WarpEntity18(World world, Vector position, String name) { super(world, position); - setInvisible(true); - setSmall(true); + j(true); + a(true); this.name = name; - this.setNoGravity(true); - this.ticksLived = -12000; + this.e(true); + this.S = -12000; } @Override public void display(Player player) { - this.setCustomNameVisible(true); - this.setCustomName(new ChatComponentText(name)); + this.n(true); + this.a(new ChatComponentText(name)); sendEntity(player); } @@ -54,7 +54,7 @@ public class WarpEntity18 extends BaseArmorStand18 implements AbstractWarpEntity @Override public boolean hide(Player player) { sendEntityDestroy(player); - die(); + ag(); return true; } } -- 2.39.2 From bcc4e7b0d3c1bfa9e8203a96bb5aaabb87586a5e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 10 Feb 2022 17:51:31 +0100 Subject: [PATCH 05/15] Update build.gradle Signed-off-by: yoyosource --- BauSystem_18/src/de/steamwar/bausystem/.gitkeep | 0 build.gradle | 1 + 2 files changed, 1 insertion(+) delete mode 100644 BauSystem_18/src/de/steamwar/bausystem/.gitkeep diff --git a/BauSystem_18/src/de/steamwar/bausystem/.gitkeep b/BauSystem_18/src/de/steamwar/bausystem/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/build.gradle b/build.gradle index a94cd724..e4b00a46 100644 --- a/build.gradle +++ b/build.gradle @@ -93,6 +93,7 @@ allprojects { dependencies { implementation project(":BauSystem_Main") implementation project(":BauSystem_15") + implementation project(":BauSystem_18") } task buildResources(type: Copy) { -- 2.39.2 From 775435783a72e061e057b825f6dfe7a34a2bba61 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 10 Feb 2022 17:52:59 +0100 Subject: [PATCH 06/15] Fix DetonatorEntity18 Signed-off-by: yoyosource --- .../src/de/steamwar/bausystem/entities/DetonatorEntity18.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java index bf1f670b..50078e9a 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java @@ -19,12 +19,12 @@ package de.steamwar.bausystem.entities; -import com.sk89q.worldedit.world.entity.EntityTypes; 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; @@ -60,7 +60,7 @@ public class DetonatorEntity18 extends EntityFallingBlock implements AbstractDet if (references++ > 0) return; - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, Block.i(Blocks.du.n()), ZERO); + 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); -- 2.39.2 From a250aeb6b6d019b9f271d381a1e7098edf335f93 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 10 Feb 2022 18:08:32 +0100 Subject: [PATCH 07/15] Fixing stuff because mojang Signed-off-by: yoyosource --- BauSystem_18/build.gradle | 6 ++++++ .../src/de/steamwar/bausystem/entities/WarpEntity18.java | 4 ++-- build.gradle | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/BauSystem_18/build.gradle b/BauSystem_18/build.gradle index ecacac8c..67d610e7 100644 --- a/BauSystem_18/build.gradle +++ b/BauSystem_18/build.gradle @@ -52,6 +52,12 @@ dependencies { compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT' compileOnly files("${projectDir}/../lib/Spigot-1.18.jar") + compileOnly 'it.unimi.dsi:fastutil:8.5.6' + compileOnly 'com.mojang:datafixerupper:4.0.26' + compileOnly 'io.netty:netty-all:4.1.68.Final' + compileOnly 'com.mojang:authlib:1.5.25' + compileOnly 'com.mojang:brigadier:1.0.18' + compileOnly files("${projectDir}/../lib/WorldEdit-1.15.jar") compileOnly files("${projectDir}/../lib/SpigotCore.jar") } \ No newline at end of file diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java index d18bb067..ef61a4b4 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/entities/WarpEntity18.java @@ -32,8 +32,8 @@ public class WarpEntity18 extends BaseArmorStand18 implements AbstractWarpEntity public WarpEntity18(World world, Vector position, String name) { super(world, position); - j(true); - a(true); + this.j(true); + this.a(true); this.name = name; this.e(true); this.S = -12000; diff --git a/build.gradle b/build.gradle index e4b00a46..0d352184 100644 --- a/build.gradle +++ b/build.gradle @@ -62,8 +62,8 @@ ext { compileJava.options.encoding = 'UTF-8' compileJava.options.compilerArgs << '-parameter' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 11 +targetCompatibility = 11 mainClassName = '' -- 2.39.2 From d4a7556b73c625ef518337af3021d702e1a281b2 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 22 Feb 2022 10:56:53 +0100 Subject: [PATCH 08/15] Update prototypes4.yapion Signed-off-by: yoyosource --- yapion/prototypes4.yapion | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/yapion/prototypes4.yapion b/yapion/prototypes4.yapion index 5d847ea2..0402a99d 100644 --- a/yapion/prototypes4.yapion +++ b/yapion/prototypes4.yapion @@ -217,6 +217,12 @@ creator(TheBreadBeard) schematic(sections4/custom/Prestige AirShip/ASArena.schem) testblockSchematic(sections4/custom/Prestige AirShip/ASTestblock.schem) + }, + { + name(Absturz AS) + creator(TheBreadBeard) + schematic(sections4/custom/Absturz AS/ASArena.schem) + testblockSchematic(sections4/custom/Absturz AS/ASTestblock.schem) } ] sizeX(121) -- 2.39.2 From a30d5c2fb02ed8db9217e267de57bce9098fa996 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 5 Mar 2022 12:16:09 +0100 Subject: [PATCH 09/15] Fix NightVisionCommand Signed-off-by: yoyosource --- .../de/steamwar/bausystem/features/util/NightVisionCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NightVisionCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NightVisionCommand.java index f1178df1..e2cf756b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NightVisionCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NightVisionCommand.java @@ -35,7 +35,7 @@ public class NightVisionCommand extends SWCommand { super("nightvision", "nv", "light"); } - @Register(description = "VISION_COMMAND_HELP") + @Register(description = "NIGHT_VISION_HELP") public void genericCommand(Player p) { if (p.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { p.removePotionEffect(PotionEffectType.NIGHT_VISION); -- 2.39.2 From 6dd4f686a4d9d0a4ae343b8ef82fcde7bbf728ab Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 14 Mar 2022 18:40:35 +0100 Subject: [PATCH 10/15] Update Loader Signed-off-by: yoyosource --- .../bausystem/features/loader/Loader.java | 24 ++++++++++--------- .../features/loader/LoaderCommand.java | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) 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 01e81be5..06acdd01 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java @@ -134,19 +134,21 @@ public class Loader implements Listener { return; } - if (!iterator.hasNext()) { - countdown = getTicksBetweenShots(); - iterator = actions.listIterator(); - return; - } + while (countdown <= 0) { + if (!iterator.hasNext()) { + countdown = getTicksBetweenShots(); + iterator = actions.listIterator(); + return; + } - current = iterator.next(); + current = iterator.next(); - if (current.execute()) { - countdown = current.delay(this); - } else { - countdown = 1; - iterator.previous(); + if (current.execute()) { + countdown = current.delay(this); + } else { + countdown = 1; + iterator.previous(); + } } } 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 548e44c9..616385f4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java @@ -114,7 +114,7 @@ public class LoaderCommand extends SWCommand { @Register(value = "speed", description = "LOADER_HELP_SPEED") public void speedLoader(@Guard Player p, int delay) { - if (delay < 1) { + if (delay < 0) { BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p); return; } -- 2.39.2 From fe317bec1e7ac24c3f81017b1f7a34a714d5fbb5 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 29 Mar 2022 11:43:37 +0200 Subject: [PATCH 11/15] Full untested impl --- .../bausystem/utils/NMSWrapper15.java | 9 +- .../bausystem/utils/FlatteningWrapper18.java | 102 ------------------ .../bausystem/utils/NMSWrapper18.java | 95 ++++++++++++++-- .../src/de/steamwar/bausystem/BauSystem.java | 4 +- .../features/detonator/DetonatorListener.java | 2 +- .../features/other/NoClipCommand.java | 40 +++---- .../bausystem/features/world/SignEdit.java | 28 ++--- .../steamwar/bausystem/utils/NMSWrapper.java | 2 + .../steamwar/bausystem/utils/ProtocolAPI.java | 4 +- 9 files changed, 139 insertions(+), 147 deletions(-) delete mode 100644 BauSystem_18/src/de/steamwar/bausystem/utils/FlatteningWrapper18.java diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java index 76478098..651010b7 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java @@ -24,6 +24,7 @@ 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.other.NoClipCommand; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; import de.steamwar.bausystem.features.warp.AbstractWarpEntity; @@ -46,7 +47,7 @@ import java.util.function.LongSupplier; public class NMSWrapper15 implements NMSWrapper.INMSWrapper { - private static final Reflection.FieldAccessor playerGameMode = Reflection.getField(PlayerInteractManager.class, "gamemode", EnumGamemode.class); + private static final Reflection.FieldAccessor playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0); @Override @SuppressWarnings("deprecation") public void setInternalGameMode(Player player, GameMode gameMode) { @@ -84,6 +85,12 @@ public class NMSWrapper15 implements NMSWrapper.INMSWrapper { }); } + private static final Reflection.FieldAccessor gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, int.class, 0); + @Override + public void setGameStateChangeReason(Object packet) { + gameStateChangeReason.set(packet, 3); + } + private static final int threshold = 2048; @Override public boolean checkItemStack(ItemStack item) { diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/FlatteningWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/FlatteningWrapper18.java deleted file mode 100644 index e0b261bd..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/FlatteningWrapper18.java +++ /dev/null @@ -1,102 +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.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import de.steamwar.bausystem.region.Color; -import de.steamwar.bausystem.region.PasteOptions; -import de.steamwar.bausystem.region.Point; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -import java.io.File; - -public class FlatteningWrapper18 implements FlatteningWrapper.IFlatteningWrapper { - - @Override - public boolean isNoBook(ItemStack item) { - return false; - } - - @Override - public boolean isUnpusheable(Material material) { - return false; - } - - @Override - public boolean isBreakingOnPush(Material material) { - return false; - } - - @Override - public boolean isWorldEditCommand(String command) { - return false; - } - - @Override - public void setSelection(Player p, Point minPoint, Point maxPoint) { - - } - - @Override - public EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) { - return null; - } - - @Override - public EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) { - return null; - } - - @Override - public void changeColor(Clipboard clipboard, Color color) throws WorldEditException { - - } - - @Override - public boolean backup(Point minPoint, Point maxPoint, File file) { - return false; - } - - @Override - public boolean inWater(World world, Vector tntPosition) { - return false; - } - - @Override - public Material getTraceShowMaterial() { - return null; - } - - @Override - public Material getTraceHideMaterial() { - return null; - } - - @Override - public Material getTraceXZMaterial() { - return null; - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java index 6d08609b..7d99946a 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -19,62 +19,145 @@ 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.other.NoClipCommand; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; 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.PacketPlayOutEntityMetadata; +import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport; +import net.minecraft.network.protocol.game.PacketPlayOutEntityVelocity; +import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange; +import net.minecraft.server.level.PlayerInteractManager; +import net.minecraft.world.level.EnumGamemode; +import net.minecraft.world.phys.Vec3D; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.World; +import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_18_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; import java.util.function.LongSupplier; public class NMSWrapper18 implements NMSWrapper.INMSWrapper { + private static final Reflection.FieldAccessor playerGameMode = Reflection.getField(PlayerInteractManager.class, "gamemode", EnumGamemode.class); @Override + @SuppressWarnings("deprecation") public void setInternalGameMode(Player player, GameMode gameMode) { + playerGameMode.set(((CraftPlayer) player).getHandle().d, EnumGamemode.a(gameMode.getValue())); } @Override public void init(LongSupplier longSupplier) { - + SystemUtils.a = () -> System.nanoTime() + longSupplier.getAsLong(); } + private static final List> packets = new ArrayList<>(); + private static final Vec3D noMotion = new Vec3D(0, 0, 0); @Override public void createTickCache(World world) { + packets.clear(); + world.getEntities().stream().filter(entity -> !(entity instanceof Player)).forEach(entity -> { + packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), noMotion)); + packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle())); + if (entity instanceof TNTPrimed) { + net.minecraft.world.entity.Entity serverEntity = ((CraftEntity) entity).getHandle(); + packets.add(new PacketPlayOutEntityMetadata(serverEntity.ae(), serverEntity.ai(), true)); + } + }); } @Override public void sendTickPackets() { - + Bukkit.getOnlinePlayers().forEach(player -> { + for (Packet p : packets) { + TinyProtocol.instance.sendPacket(player, p); + } + }); } + private static final Reflection.FieldAccessor gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 0); + @Override + public void setGameStateChangeReason(Object packet) { + gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d); + } + + private static final int threshold = 2048; @Override public boolean checkItemStack(ItemStack item) { + net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + NBTTagCompound tag = nmsItem.s(); + if (tag != null && tag.e("BlockEntityTag")) { + NBTTagCompound blockTag = tag.p("BlockEntityTag"); + if (blockTag.e("Items")) { + return drillDown(blockTag.c("Items", 10), 0, 0) > threshold; + } + } + return false; } + private int drillDown(NBTTagList items, int layer, int start) { + if (layer > 2) return start + threshold; + int invalid = start; + for (NBTBase nbtBase : items) { + if (!(nbtBase instanceof NBTTagCompound)) + continue; + NBTTagCompound slot = (NBTTagCompound) nbtBase; + if (slot.e("tag")) { + invalid += slot.f("Count"); + NBTTagCompound iTag = slot.p("tag"); + if (iTag.e("BlockEntityTag")) { + NBTTagCompound blockTag = iTag.p("BlockEntityTag"); + if (blockTag.e("Items")) { + invalid = drillDown(blockTag.c("Items", 10), layer + 1, invalid); + } + } + } + if (invalid > threshold) + break; + } + return invalid; + } + @Override public AbstractWarpEntity createWarp(World world, Vector position, String name) { - return null; + return new WarpEntity18(world, position, name); } @Override public AbstractSimulatorEntity createSimulator(World world, Vector tntPosition, boolean highlight) { - return null; + return new SimulatorEntity18(world, tntPosition, highlight); } @Override public AbstractDetonatorEntity constructDetonator(World world, Vector position) { - return null; + return new DetonatorEntity18(world, position); } @Override public AbstractTraceEntity createTrace(World world, Vector tntPosition, boolean tnt) { - return null; + return new TraceEntity18(world, tntPosition, tnt); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 60f193ce..c4329fbb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -19,12 +19,12 @@ package de.steamwar.bausystem; +import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.region.loader.PrototypeLoader; import de.steamwar.bausystem.region.loader.RegionLoader; import de.steamwar.bausystem.region.loader.Updater; -import de.steamwar.bausystem.utils.ProtocolAPI; import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.message.Message; import de.steamwar.scoreboard.SWScoreboard; @@ -89,7 +89,7 @@ public class BauSystem extends JavaPlugin implements Listener { WorldData.write(); Config.getInstance().saveAll(); - ProtocolAPI.tinyProtocol.close(); + TinyProtocol.instance.close(); } private void fixLogging() { 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 8b6b91da..9400b2c5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java @@ -45,7 +45,7 @@ import java.util.Set; @Linked(LinkageType.LISTENER) public class DetonatorListener implements Listener { - public static final Class useEntity = Reflection.getClass("{nms}.PacketPlayInUseEntity"); + public static final Class useEntity = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity"); private static final Reflection.FieldAccessor entityIdFieldAccessor = Reflection.getField(useEntity, int.class, 0); private static final Set HAS_UPDATED = new HashSet<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java index 549deb27..b5082dd8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.other; import com.comphenix.tinyprotocol.Reflection; +import com.comphenix.tinyprotocol.TinyProtocol; import com.mojang.authlib.GameProfile; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tpslimit.TPSUtils; @@ -28,6 +29,7 @@ import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.bausystem.utils.ProtocolAPI; import de.steamwar.command.SWCommand; +import de.steamwar.core.Core; import lombok.Getter; import org.bukkit.GameMode; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; @@ -46,28 +48,26 @@ import java.util.function.BiFunction; @Linked(LinkageType.LISTENER) public class NoClipCommand extends SWCommand implements Listener { - private static final Class playerInfoPacket = Reflection.getClass("{nms}.PacketPlayOutPlayerInfo"); - private static final Reflection.ConstructorInvoker playerInfoConstructor = Reflection.getConstructor(playerInfoPacket); - private static final Class playerInfoActionClass = Reflection.getClass("{nms}.PacketPlayOutPlayerInfo$EnumPlayerInfoAction"); + private static final Class playerInfoPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPlayerInfo"); + private static final Class playerInfoActionClass = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPlayerInfo$EnumPlayerInfoAction"); private static final Reflection.FieldAccessor playerInfoAction = Reflection.getField(playerInfoPacket, playerInfoActionClass, 0); private static final Object updateGamemode = playerInfoActionClass.getEnumConstants()[1]; private static final Reflection.FieldAccessor playerInfoData = Reflection.getField(playerInfoPacket, List.class, 0); - private static final Class playerInfoDataClass = Reflection.getClass("{nms}.PacketPlayOutPlayerInfo$PlayerInfoData"); - private static final Class enumGamemode = Reflection.getClass("{nms}.EnumGamemode"); - private static final Object spectator = enumGamemode.getEnumConstants()[4]; - private static final Class iChatBaseComponent = Reflection.getClass("{nms}.IChatBaseComponent"); + private static final Class playerInfoDataClass = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPlayerInfo$PlayerInfoData"); + private static final Class enumGamemode = Reflection.getClass("{nms.world.level}.EnumGamemode"); + private static final Object spectator = enumGamemode.getEnumConstants()[Core.getVersion() > 15 ? 3 : 4]; + private static final Class iChatBaseComponent = Reflection.getClass("{nms.network.chat}.IChatBaseComponent"); - private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClass, playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent); + private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Core.getVersion() > 15 ? Reflection.getConstructor(playerInfoDataClass, GameProfile.class, int.class, enumGamemode, iChatBaseComponent) : Reflection.getConstructor(playerInfoDataClass, playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent); - private static final Class gameStateChange = Reflection.getClass("{nms}.PacketPlayOutGameStateChange"); - private static final Reflection.FieldAccessor integerFieldAccessor = Reflection.getField(gameStateChange, int.class, 0); + public static final Class gameStateChange = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutGameStateChange"); private static final Reflection.FieldAccessor floatFieldAccessor = Reflection.getField(gameStateChange, float.class, 0); - private static final Class position = Reflection.getClass("{nms}.PacketPlayInFlying$PacketPlayInPosition"); - private static final Class positionLook = Reflection.getClass("{nms}.PacketPlayInFlying$PacketPlayInPositionLook"); - private static final Class useItem = Reflection.getClass("{nms}.PacketPlayInUseItem"); - private static final Class blockDig = Reflection.getClass("{nms}.PacketPlayInBlockDig"); - private static final Class windowClick = Reflection.getClass("{nms}.PacketPlayInWindowClick"); + private static final Class position = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPosition"); + private static final Class positionLook = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPositionLook"); + private static final Class useItem = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem"); + private static final Class blockDig = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInBlockDig"); + private static final Class windowClick = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInWindowClick"); @Getter private static final List NOCLIPS = new ArrayList<>(); @@ -110,12 +110,12 @@ public class NoClipCommand extends SWCommand implements Listener { ((CraftPlayer) player).getHandle().abilities.canInstantlyBuild = true; Object gameStateChangeObject = Reflection.newInstance(gameStateChange); - integerFieldAccessor.set(gameStateChangeObject, 3); + NMSWrapper.impl.setGameStateChangeReason(gameStateChangeObject); floatFieldAccessor.set(gameStateChangeObject, 1F); NOCLIPS.add(player); BauSystem.MESSAGE.send("OTHER_NOCLIP_SLOT_INFO", player); - ProtocolAPI.tinyProtocol.sendPacket(player, gameStateChangeObject); + TinyProtocol.instance.sendPacket(player, gameStateChangeObject); pseudoSpectator(player); } } @@ -154,13 +154,13 @@ public class NoClipCommand extends SWCommand implements Listener { } private static void pseudoSpectator(Player player) { - ProtocolAPI.tinyProtocol.sendPacket(player, playerInfoPacket(updateGamemode, new GameProfile(player.getUniqueId(), player.getName()), spectator)); + TinyProtocol.instance.sendPacket(player, playerInfoPacket(updateGamemode, new GameProfile(player.getUniqueId(), player.getName()), spectator)); } private static Object playerInfoPacket(Object action, GameProfile profile, Object mode) { - Object packet = playerInfoConstructor.invoke(); + Object packet = Reflection.newInstance(playerInfoPacket); playerInfoAction.set(packet, action); - playerInfoData.set(packet, Collections.singletonList(playerInfoDataConstructor.invoke(packet, profile, 0, mode, null))); + playerInfoData.set(packet, Collections.singletonList(Core.getVersion() > 15 ? playerInfoDataConstructor.invoke(profile, 0, mode, null) : playerInfoDataConstructor.invoke(packet, profile, 0, mode, null))); return packet; } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java index 5d525f0c..e7431347 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java @@ -20,14 +20,13 @@ package de.steamwar.bausystem.features.world; import com.comphenix.tinyprotocol.Reflection; +import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.ProtocolAPI; -import net.minecraft.server.v1_15_R1.BlockPosition; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; @@ -36,16 +35,23 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.util.Vector; @Linked(LinkageType.LISTENER) public class SignEdit implements Listener { - public static final Class openSign = Reflection.getClass("{nms}.PacketPlayOutOpenSignEditor"); - private static final Reflection.FieldAccessor blockPositionFieldAccessor = Reflection.getField(openSign, net.minecraft.server.v1_15_R1.BlockPosition.class, 0); + private static final Class blockPosition = Reflection.getClass("{nms.core}.BlockPosition"); + private static final Class craftBlock = Reflection.getClass("{obc}.CraftBlock"); + private static final Class craftWorld = Reflection.getClass("{obc}.CraftWorld"); + private static final Class generatorAccess = Reflection.getClass("{nms.world.level}.GeneratorAccess"); + private static final Reflection.MethodInvoker getPosition = Reflection.getTypedMethod(craftBlock, "getPosition", blockPosition); + private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(craftWorld, "getHandle", null); + private static final Reflection.MethodInvoker at = Reflection.getTypedMethod(craftBlock, "at", generatorAccess, blockPosition); - public static final Class updateSign = Reflection.getClass("{nms}.PacketPlayInUpdateSign"); - private static final Reflection.FieldAccessor getBlockPositionFieldAccessor = Reflection.getField(updateSign, BlockPosition.class, 0); + private static final Class openSign = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutOpenSignEditor"); + private static final Reflection.FieldAccessor blockPositionFieldAccessor = Reflection.getField(openSign, blockPosition, 0); + + private static final Class updateSign = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUpdateSign"); + private static final Reflection.FieldAccessor getBlockPositionFieldAccessor = Reflection.getField(updateSign, blockPosition, 0); private static final Reflection.FieldAccessor stringFieldAccessor = Reflection.getField(updateSign, String[].class, 0); @EventHandler @@ -66,18 +72,16 @@ public class SignEdit implements Listener { sign.update(); Object openSignObject = Reflection.newInstance(openSign); - Vector vector = event.getClickedBlock().getLocation().toVector(); - blockPositionFieldAccessor.set(openSignObject, new BlockPosition(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ())); - ProtocolAPI.tinyProtocol.sendPacket(player, openSignObject); + blockPositionFieldAccessor.set(openSignObject, getPosition.invoke(event.getClickedBlock())); + TinyProtocol.instance.sendPacket(player, openSignObject); } { ProtocolAPI.setIncomingHandler(updateSign, (player, o) -> { Bukkit.getScheduler().runTask(BauSystem.getInstance(), () -> { - BlockPosition position = getBlockPositionFieldAccessor.get(o); String[] lines = stringFieldAccessor.get(o); - Block signLoc = new Location(player.getWorld(), position.getX(), position.getY(), position.getZ()).getBlock(); + Block signLoc = (Block) at.invoke(null, getWorldHandle.invoke(player.getWorld()), getBlockPositionFieldAccessor.get(o)); if (!signLoc.getType().name().contains("SIGN")) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java index 38686fa8..fda7a934 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java @@ -45,6 +45,8 @@ public class NMSWrapper { void createTickCache(World world); void sendTickPackets(); + void setGameStateChangeReason(Object packet); + boolean checkItemStack(ItemStack item); AbstractWarpEntity createWarp(World world, Vector position, String name); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/ProtocolAPI.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/ProtocolAPI.java index d286f021..8d0543ed 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/ProtocolAPI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/ProtocolAPI.java @@ -34,8 +34,6 @@ public class ProtocolAPI { private static final Map, BiFunction> outgoingHandler = new HashMap<>(); private static final Map, BiFunction> incomingHandler = new HashMap<>(); - public static final TinyProtocol tinyProtocol = TinyProtocol.instance; - static { TinyProtocol.instance.setOutFilter((receiver, channel, packet) -> { BiFunction handler = outgoingHandler.get(packet.getClass()); @@ -70,6 +68,6 @@ public class ProtocolAPI { } public static void broadcastPacket(Object packet) { - Bukkit.getOnlinePlayers().stream().map(tinyProtocol::getChannel).filter(tinyProtocol::hasInjected).forEach(channel -> tinyProtocol.sendPacket(channel, packet)); + Bukkit.getOnlinePlayers().stream().map(TinyProtocol.instance::getChannel).filter(TinyProtocol.instance::hasInjected).forEach(channel -> TinyProtocol.instance.sendPacket(channel, packet)); } } -- 2.39.2 From 305664e9ea3d1328025fef2f995ca646d3e9e10b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 29 Mar 2022 12:29:19 +0200 Subject: [PATCH 12/15] Fix build --- .../bausystem/utils/NMSWrapper15.java | 12 +++++ .../bausystem/utils/NMSWrapper18.java | 12 +++++ BauSystem_Main/build.gradle | 5 +- .../features/observer/ObserverTracer.java | 5 +- .../features/other/NoClipCommand.java | 4 +- .../slaves/laufbau/BlockBoundingBox.java | 2 +- .../boundingboxes/WallBoundingBox.java | 46 +++++++++++++++++++ .../features/tpslimit/FreezeUtils.java | 10 ++-- .../tracer/show/mode/ParticleShowMode.java | 4 +- .../bausystem/features/world/SignEdit.java | 2 +- .../steamwar/bausystem/utils/NMSWrapper.java | 4 ++ 11 files changed, 92 insertions(+), 14 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java index 651010b7..a5d430b5 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java @@ -32,6 +32,7 @@ import de.steamwar.bausystem.entities.WarpEntity15; import net.minecraft.server.v1_15_R1.*; import org.bukkit.Bukkit; import org.bukkit.GameMode; +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; @@ -91,6 +92,17 @@ public class NMSWrapper15 implements NMSWrapper.INMSWrapper { gameStateChangeReason.set(packet, 3); } + @Override + public void setPlayerBuildAbilities(Player player) { + ((CraftPlayer) player).getHandle().abilities.mayBuild = true; + ((CraftPlayer) player).getHandle().abilities.canInstantlyBuild = true; + } + + @Override + public Particle tntPositionParticle() { + return Particle.BARRIER; + } + private static final int threshold = 2048; @Override public boolean checkItemStack(ItemStack item) { diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java index 7d99946a..10b01d26 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -44,6 +44,7 @@ import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.phys.Vec3D; import org.bukkit.Bukkit; import org.bukkit.GameMode; +import org.bukkit.Particle; import org.bukkit.World; import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; @@ -103,6 +104,17 @@ public class NMSWrapper18 implements NMSWrapper.INMSWrapper { gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d); } + @Override + public void setPlayerBuildAbilities(Player player) { + ((CraftPlayer) player).getHandle().fr().d = true; + ((CraftPlayer) player).getHandle().fr().e = true; + } + + @Override + public Particle tntPositionParticle() { + return Particle.BLOCK_MARKER; + } + private static final int threshold = 2048; @Override public boolean checkItemStack(ItemStack item) { diff --git a/BauSystem_Main/build.gradle b/BauSystem_Main/build.gradle index 5027460c..2b8f7a6e 100644 --- a/BauSystem_Main/build.gradle +++ b/BauSystem_Main/build.gradle @@ -56,7 +56,10 @@ dependencies { annotationProcessor 'org.atteo.classindex:classindex:3.11' testAnnotationProcessor 'org.atteo.classindex:classindex:3.11' - compileOnly files("${projectDir}/../lib/Spigot-1.15.jar") + compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT' + compileOnly files("${projectDir}/../lib/Spigot-1.18.jar") + compileOnly 'com.mojang:authlib:1.5.25' + compileOnly 'io.netty:netty-all:4.1.68.Final' compileOnly files("${projectDir}/../lib/WorldEdit-1.15.jar") compileOnly files("${projectDir}/../lib/SpigotCore.jar") } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java index a5b0bb4c..9f641e65 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.observer; +import com.comphenix.tinyprotocol.Reflection; import de.steamwar.bausystem.region.Point; import org.bukkit.Location; import org.bukkit.Material; @@ -29,7 +30,6 @@ import org.bukkit.block.data.Bisected; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.type.Observer; import org.bukkit.block.data.type.*; -import org.bukkit.craftbukkit.v1_15_R1.block.impl.CraftPoweredRail; import org.bukkit.entity.Player; import java.util.*; @@ -170,6 +170,7 @@ public class ObserverTracer { } } + private static final Class craftPoweredRail = Reflection.getClass("{obc}.block.impl.CraftPoweredRail"); private boolean checkAllowed(Block block, BlockData blockData) { if (checkMaterial(block)) return true; if (block.getType() == Material.BELL) { @@ -178,7 +179,7 @@ public class ObserverTracer { return blockData instanceof Door || blockData instanceof Gate - || blockData instanceof CraftPoweredRail + || craftPoweredRail.isInstance(blockData) || blockData instanceof TrapDoor || blockData instanceof GlassPane; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java index b5082dd8..d61df74e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java @@ -32,7 +32,6 @@ import de.steamwar.command.SWCommand; import de.steamwar.core.Core; import lombok.Getter; import org.bukkit.GameMode; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -106,8 +105,7 @@ public class NoClipCommand extends SWCommand implements Listener { player.setGameMode(GameMode.CREATIVE); } else { player.setGameMode(GameMode.SPECTATOR); - ((CraftPlayer) player).getHandle().abilities.mayBuild = true; - ((CraftPlayer) player).getHandle().abilities.canInstantlyBuild = true; + NMSWrapper.impl.setPlayerBuildAbilities(player); Object gameStateChangeObject = Reflection.newInstance(gameStateChange); NMSWrapper.impl.setGameStateChangeReason(gameStateChangeObject); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java index c4ccdefe..6c1257ad 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java @@ -86,7 +86,7 @@ public class BlockBoundingBox { addPixel(Material.AIR.createBlockData(), 0, 0, 0, 0, 0, 0, null); addPixel(Material.END_STONE.createBlockData(), 0, 0, 0, 16, 16, 16, null); - addPixel(Material.GRASS_PATH.createBlockData(), 0, 0, 0, 16, 15, 16, createItem("LAUFBAU_BLOCK_GRASS_PATH", Material.GRASS_PATH)); + addPixel(SWItem.getMaterial("GRASS_PATH").createBlockData(), 0, 0, 0, 16, 15, 16, createItem("LAUFBAU_BLOCK_GRASS_PATH", SWItem.getMaterial("GRASS_PATH"))); addPixel(Material.SOUL_SAND.createBlockData(), 0, 0, 0, 16, 14, 16, createItem("LAUFBAU_BLOCK_SOUL_SAND", Material.SOUL_SAND)); Cocoa cocoaNorth = (Cocoa) Material.COCOA.createBlockData(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java index a0bb9a0b..8f42dd98 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java @@ -24,9 +24,11 @@ import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.bausystem.linkage.Enable; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.core.Core; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.Fence; +import org.bukkit.block.data.type.Wall; import java.util.ArrayList; import java.util.List; @@ -39,6 +41,50 @@ public class WallBoundingBox implements Enable { @Override public void enable() { + if (Core.getVersion() > 15) { + v18(); + } else { + v15(); + } + } + + private void v18() { + for (int nx = 0; nx < 2; nx++) { + for (int nz = 0; nz < 2; nz++) { + for (int px = 0; px < 2; px++) { + for (int pz = 0; pz < 2; pz++) { + Wall fence = (Wall) Material.END_STONE_BRICK_WALL.createBlockData(); + List lore = new ArrayList<>(); + List cuboidList = new ArrayList<>(); + cuboidList.add(pixelCuboid(4, 0, 4, 8, 24, 8)); + if (nz == 1) { + lore.add("LAUFBAU_CONNECTION_NORTH"); + fence.setHeight(BlockFace.NORTH, Wall.Height.LOW); + cuboidList.add(pixelCuboid(5, 0, 0, 6, 24, 4)); + } + if (pz == 1) { + lore.add("LAUFBAU_CONNECTION_SOUTH"); + fence.setHeight(BlockFace.SOUTH, Wall.Height.LOW); + cuboidList.add(pixelCuboid(5, 0, 12, 6, 24, 4)); + } + if (nx == 1) { + lore.add("LAUFBAU_CONNECTION_WEST"); + fence.setHeight(BlockFace.WEST, Wall.Height.LOW); + cuboidList.add(pixelCuboid(0, 0, 5, 4, 24, 6)); + } + if (px == 1) { + lore.add("LAUFBAU_CONNECTION_EAST"); + fence.setHeight(BlockFace.EAST, Wall.Height.LOW); + cuboidList.add(pixelCuboid(12, 0, 5, 4, 24, 6)); + } + new BlockBoundingBox(fence, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_WALL", Material.END_STONE_BRICK_WALL, lore.toArray(new String[0]))); + } + } + } + } + } + + private void v15() { for (int nx = 0; nx < 2; nx++) { for (int nz = 0; nz < 2; nz++) { for (int px = 0; px < 2; px++) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/FreezeUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/FreezeUtils.java index e0d5804d..18679323 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/FreezeUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/FreezeUtils.java @@ -19,12 +19,11 @@ package de.steamwar.bausystem.features.tpslimit; +import com.comphenix.tinyprotocol.Reflection; import lombok.Getter; import lombok.experimental.UtilityClass; -import net.minecraft.server.v1_15_R1.WorldServer; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; import yapion.utils.ReflectionsUtils; import java.lang.reflect.Field; @@ -35,13 +34,16 @@ public class FreezeUtils { private static final Field field; public static final boolean freezeEnabled; + private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle", null); + @Getter private static boolean frozen = false; private static final World world; static { - field = ReflectionsUtils.getField(WorldServer.class, "freezed"); + + field = ReflectionsUtils.getField(Reflection.getClass("{nms.server.level}.WorldServer"), "freezed"); if (field != null) field.setAccessible(true); freezeEnabled = field != null; world = Bukkit.getWorlds().get(0); @@ -62,7 +64,7 @@ public class FreezeUtils { private void setFreeze(World world, boolean state) { if (freezeEnabled) { try { - field.set(((CraftWorld) world).getHandle(), state); + field.set(getWorldHandle.invoke(world), state); frozen = state; } catch (IllegalAccessException e) { // Ignored; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java index 1d64acfd..d897b45c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java @@ -23,8 +23,8 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; import de.steamwar.bausystem.shared.ShowMode; +import de.steamwar.bausystem.utils.NMSWrapper; import org.bukkit.Bukkit; -import org.bukkit.Particle; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; import org.bukkit.util.Vector; @@ -57,7 +57,7 @@ public class ParticleShowMode implements ShowMode { positionSet.add(position.getLocation()); if (bukkitTask == null) { bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { - positionSet.forEach(p -> player.spawnParticle(Particle.BARRIER, p.toLocation(player.getWorld()), 1, 0, 0, 0, 0)); + positionSet.forEach(p -> player.spawnParticle(NMSWrapper.impl.tntPositionParticle(), p.toLocation(player.getWorld()), 1, 0, 0, 0, 0)); }, 40L, 40L); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java index e7431347..e59c870e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java @@ -40,7 +40,7 @@ import org.bukkit.event.player.PlayerInteractEvent; public class SignEdit implements Listener { private static final Class blockPosition = Reflection.getClass("{nms.core}.BlockPosition"); - private static final Class craftBlock = Reflection.getClass("{obc}.CraftBlock"); + private static final Class craftBlock = Reflection.getClass("{obc}.block.CraftBlock"); private static final Class craftWorld = Reflection.getClass("{obc}.CraftWorld"); private static final Class generatorAccess = Reflection.getClass("{nms.world.level}.GeneratorAccess"); private static final Reflection.MethodInvoker getPosition = Reflection.getTypedMethod(craftBlock, "getPosition", blockPosition); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java index fda7a934..00dd5294 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java @@ -26,6 +26,7 @@ import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import de.steamwar.core.VersionDependent; import org.bukkit.GameMode; +import org.bukkit.Particle; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -46,6 +47,9 @@ public class NMSWrapper { void sendTickPackets(); void setGameStateChangeReason(Object packet); + void setPlayerBuildAbilities(Player player); + + Particle tntPositionParticle(); boolean checkItemStack(ItemStack item); -- 2.39.2 From 26140fd05411abfbbef1014e4db888fd7dc8c710 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 29 Mar 2022 12:37:32 +0200 Subject: [PATCH 13/15] Fix build --- .../src/de/steamwar/bausystem/utils/NMSWrapper15.java | 6 ++++++ .../src/de/steamwar/bausystem/utils/NMSWrapper18.java | 10 ++++++---- .../features/slaves/laufbau/BlockBoundingBox.java | 3 ++- .../de/steamwar/bausystem/features/world/SignEdit.java | 2 +- .../src/de/steamwar/bausystem/utils/NMSWrapper.java | 2 ++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java index a5d430b5..48c0d3a0 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java @@ -32,6 +32,7 @@ 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; @@ -103,6 +104,11 @@ public class NMSWrapper15 implements NMSWrapper.INMSWrapper { return Particle.BARRIER; } + @Override + public Material pathMaterial() { + return Material.GRASS_PATH; + } + private static final int threshold = 2048; @Override public boolean checkItemStack(ItemStack item) { diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java index 10b01d26..9cbcf429 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -42,10 +42,7 @@ import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange; import net.minecraft.server.level.PlayerInteractManager; import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.phys.Vec3D; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Particle; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack; @@ -115,6 +112,11 @@ public class NMSWrapper18 implements NMSWrapper.INMSWrapper { return Particle.BLOCK_MARKER; } + @Override + public Material pathMaterial() { + return Material.DIRT_PATH; + } + private static final int threshold = 2048; @Override public boolean checkItemStack(ItemStack item) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java index 6c1257ad..b8b51edf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.slaves.laufbau; +import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.inventory.SWItem; import lombok.Getter; import lombok.ToString; @@ -86,7 +87,7 @@ public class BlockBoundingBox { addPixel(Material.AIR.createBlockData(), 0, 0, 0, 0, 0, 0, null); addPixel(Material.END_STONE.createBlockData(), 0, 0, 0, 16, 16, 16, null); - addPixel(SWItem.getMaterial("GRASS_PATH").createBlockData(), 0, 0, 0, 16, 15, 16, createItem("LAUFBAU_BLOCK_GRASS_PATH", SWItem.getMaterial("GRASS_PATH"))); + addPixel(NMSWrapper.impl.pathMaterial().createBlockData(), 0, 0, 0, 16, 15, 16, createItem("LAUFBAU_BLOCK_GRASS_PATH", NMSWrapper.impl.pathMaterial())); addPixel(Material.SOUL_SAND.createBlockData(), 0, 0, 0, 16, 14, 16, createItem("LAUFBAU_BLOCK_SOUL_SAND", Material.SOUL_SAND)); Cocoa cocoaNorth = (Cocoa) Material.COCOA.createBlockData(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java index e59c870e..ea97e452 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java @@ -45,7 +45,7 @@ public class SignEdit implements Listener { private static final Class generatorAccess = Reflection.getClass("{nms.world.level}.GeneratorAccess"); private static final Reflection.MethodInvoker getPosition = Reflection.getTypedMethod(craftBlock, "getPosition", blockPosition); private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(craftWorld, "getHandle", null); - private static final Reflection.MethodInvoker at = Reflection.getTypedMethod(craftBlock, "at", generatorAccess, blockPosition); + private static final Reflection.MethodInvoker at = Reflection.getTypedMethod(craftBlock, "at", craftBlock, generatorAccess, blockPosition); private static final Class openSign = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutOpenSignEditor"); private static final Reflection.FieldAccessor blockPositionFieldAccessor = Reflection.getField(openSign, blockPosition, 0); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java index 00dd5294..3d7d2c05 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java @@ -26,6 +26,7 @@ import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import de.steamwar.core.VersionDependent; import org.bukkit.GameMode; +import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.World; import org.bukkit.entity.Player; @@ -50,6 +51,7 @@ public class NMSWrapper { void setPlayerBuildAbilities(Player player); Particle tntPositionParticle(); + Material pathMaterial(); boolean checkItemStack(ItemStack item); -- 2.39.2 From 7a91aa4527dfbce96ea8d94b411be02b38d4e9f4 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 29 Mar 2022 16:03:25 +0200 Subject: [PATCH 14/15] Move to 1.18.2 --- .../bausystem/entities/DetonatorEntity18.java | 6 +++--- .../bausystem/shared/BaseArmorStand18.java | 6 +++--- .../de/steamwar/bausystem/shared/BaseEntity18.java | 8 ++++---- .../de/steamwar/bausystem/utils/NMSWrapper18.java | 14 +++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java index 50078e9a..8b28359e 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java @@ -30,8 +30,8 @@ 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_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; +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; @@ -64,7 +64,7 @@ public class DetonatorEntity18 extends EntityFallingBlock implements AbstractDet PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; playerConnection.a(packetPlayOutSpawnEntity); - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Z, true); + PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Y, true); playerConnection.a(packetPlayOutEntityMetadata); } diff --git a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java index b0a91d9e..cc0d278c 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseArmorStand18.java @@ -27,8 +27,8 @@ 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_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; +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; @@ -51,7 +51,7 @@ public class BaseArmorStand18 extends EntityArmorStand implements AbstractEntity PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; playerConnection.a(packetPlayOutSpawnEntity); - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Z, true); + PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); playerConnection.a(packetPlayOutEntityMetadata); } diff --git a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java index b331f0da..ef776851 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java @@ -30,9 +30,9 @@ 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_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; +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; @@ -57,7 +57,7 @@ public class BaseEntity18 extends EntityFallingBlock implements AbstractEntity { PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; playerConnection.a(packetPlayOutSpawnEntity); - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Z, true); + PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); playerConnection.a(packetPlayOutEntityMetadata); } diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java index 9cbcf429..306b3af1 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -43,9 +43,9 @@ 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_18_R1.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack; +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; @@ -57,7 +57,7 @@ import java.util.function.LongSupplier; public class NMSWrapper18 implements NMSWrapper.INMSWrapper { - private static final Reflection.FieldAccessor playerGameMode = Reflection.getField(PlayerInteractManager.class, "gamemode", EnumGamemode.class); + private static final Reflection.FieldAccessor playerGameMode = Reflection.getField(PlayerInteractManager.class, EnumGamemode.class, 0); @Override @SuppressWarnings("deprecation") public void setInternalGameMode(Player player, GameMode gameMode) { @@ -103,8 +103,8 @@ public class NMSWrapper18 implements NMSWrapper.INMSWrapper { @Override public void setPlayerBuildAbilities(Player player) { - ((CraftPlayer) player).getHandle().fr().d = true; - ((CraftPlayer) player).getHandle().fr().e = true; + ((CraftPlayer) player).getHandle().fs().d = true; + ((CraftPlayer) player).getHandle().fs().e = true; } @Override @@ -121,7 +121,7 @@ public class NMSWrapper18 implements NMSWrapper.INMSWrapper { @Override public boolean checkItemStack(ItemStack item) { net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item); - NBTTagCompound tag = nmsItem.s(); + NBTTagCompound tag = nmsItem.t(); if (tag != null && tag.e("BlockEntityTag")) { NBTTagCompound blockTag = tag.p("BlockEntityTag"); if (blockTag.e("Items")) { -- 2.39.2 From 185d7ee56ae323ecc8887749ae34a49cef4d39ef Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 29 Mar 2022 22:28:38 +0200 Subject: [PATCH 15/15] Fix noclip --- BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java index 306b3af1..de2f6876 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -95,7 +95,7 @@ public class NMSWrapper18 implements NMSWrapper.INMSWrapper { }); } - private static final Reflection.FieldAccessor gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 0); + private static final Reflection.FieldAccessor gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12); @Override public void setGameStateChangeReason(Object packet) { gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d); -- 2.39.2