From 19a9cebe49ad29e2815c588494fc333db6c508e6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 11 Jun 2022 21:02:36 +0200 Subject: [PATCH 1/4] Hotfix build.gradle Signed-off-by: yoyosource --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index 0d352184..7f44d482 100644 --- a/build.gradle +++ b/build.gradle @@ -94,6 +94,7 @@ dependencies { implementation project(":BauSystem_Main") implementation project(":BauSystem_15") implementation project(":BauSystem_18") + implementation project(":BauSystem_19") } task buildResources(type: Copy) { From e42c701ac7b1ad36f304216d2b4a84867b22ffb3 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 11 Jun 2022 21:12:24 +0200 Subject: [PATCH 2/4] Hotfix NoClipCommand Signed-off-by: yoyosource --- .../bausystem/utils/ProtocolWrapper15.java | 33 ++++++++++++++++++ .../bausystem/utils/ProtocolWrapper18.java | 34 +++++++++++++++++++ .../features/util/NoClipCommand.java | 13 ++++--- .../bausystem/utils/ProtocolWrapper.java | 30 ++++++++++++++++ 4 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 BauSystem_15/src/de/steamwar/bausystem/utils/ProtocolWrapper15.java create mode 100644 BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/utils/ProtocolWrapper.java diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/ProtocolWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/ProtocolWrapper15.java new file mode 100644 index 00000000..57ba7259 --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/ProtocolWrapper15.java @@ -0,0 +1,33 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.utils; + +import com.comphenix.tinyprotocol.Reflection; +import com.mojang.authlib.GameProfile; +import de.steamwar.bausystem.features.util.NoClipCommand; + +public class ProtocolWrapper15 implements ProtocolWrapper { + + private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, NoClipCommand.playerInfoPacket, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent); + @Override + public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) { + return playerInfoDataConstructor.invoke(packet, profile, 0, mode, null); + } +} diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java new file mode 100644 index 00000000..c82f70f2 --- /dev/null +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java @@ -0,0 +1,34 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.utils; + +import com.comphenix.tinyprotocol.Reflection; +import com.mojang.authlib.GameProfile; +import de.steamwar.bausystem.features.util.NoClipCommand; +import de.steamwar.sql.Fight; + +public class ProtocolWrapper18 implements ProtocolWrapper { + + private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent); + @Override + public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) { + return playerInfoDataConstructor.invoke(profile, 0, mode, null); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java index f605f828..700eb64f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java @@ -28,6 +28,7 @@ import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.bausystem.utils.ProtocolAPI; +import de.steamwar.bausystem.utils.ProtocolWrapper; import de.steamwar.command.SWCommand; import de.steamwar.core.Core; import lombok.Getter; @@ -47,17 +48,15 @@ import java.util.function.BiFunction; @Linked(LinkageType.LISTENER) public class NoClipCommand extends SWCommand implements Listener { - private static final Class playerInfoPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPlayerInfo"); + public 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.network.protocol.game}.PacketPlayOutPlayerInfo$PlayerInfoData"); - private static final Class enumGamemode = Reflection.getClass("{nms.world.level}.EnumGamemode"); + public static final Class playerInfoDataClass = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPlayerInfo$PlayerInfoData"); + public 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 = Core.getVersion() > 15 ? Reflection.getConstructor(playerInfoDataClass, GameProfile.class, int.class, enumGamemode, iChatBaseComponent) : Reflection.getConstructor(playerInfoDataClass, playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent); + public static final Class iChatBaseComponent = Reflection.getClass("{nms.network.chat}.IChatBaseComponent"); public static final Class gameStateChange = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutGameStateChange"); private static final Reflection.FieldAccessor floatFieldAccessor = Reflection.getField(gameStateChange, float.class, 0); @@ -158,7 +157,7 @@ public class NoClipCommand extends SWCommand implements Listener { private static Object playerInfoPacket(Object action, GameProfile profile, Object mode) { Object packet = Reflection.newInstance(playerInfoPacket); playerInfoAction.set(packet, action); - playerInfoData.set(packet, Collections.singletonList(Core.getVersion() > 15 ? playerInfoDataConstructor.invoke(profile, 0, mode, null) : playerInfoDataConstructor.invoke(packet, profile, 0, mode, null))); + playerInfoData.set(packet, Collections.singletonList(ProtocolWrapper.impl.playerInfoDataConstructor(packet, profile, mode))); return packet; } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/ProtocolWrapper.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/ProtocolWrapper.java new file mode 100644 index 00000000..536dec51 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/ProtocolWrapper.java @@ -0,0 +1,30 @@ +/* + * 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.mojang.authlib.GameProfile; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.core.VersionDependent; + +public interface ProtocolWrapper { + ProtocolWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); + + Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode); +} From e8bb2cfda580287102368fbd3899bee213d45532 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 11 Jun 2022 21:17:27 +0200 Subject: [PATCH 3/4] Hotfix NoClipCommand Signed-off-by: yoyosource --- .../bausystem/utils/ProtocolWrapper18.java | 1 - .../bausystem/utils/ProtocolWrapper19.java | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java index c82f70f2..962b8181 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java @@ -22,7 +22,6 @@ package de.steamwar.bausystem.utils; import com.comphenix.tinyprotocol.Reflection; import com.mojang.authlib.GameProfile; import de.steamwar.bausystem.features.util.NoClipCommand; -import de.steamwar.sql.Fight; public class ProtocolWrapper18 implements ProtocolWrapper { diff --git a/BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java b/BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java new file mode 100644 index 00000000..3a21ab08 --- /dev/null +++ b/BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java @@ -0,0 +1,33 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.bausystem.utils; + +import com.comphenix.tinyprotocol.Reflection; +import com.mojang.authlib.GameProfile; +import de.steamwar.bausystem.features.util.NoClipCommand; + +public class ProtocolWrapper19 implements ProtocolWrapper { + + private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent, Reflection.getClass("net.minecraft.world.entity.player.ProfilePublicKey$a")); + @Override + public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) { + return playerInfoDataConstructor.invoke(profile, 0, mode, null, null); + } +} From 1adce7baecb80be33272574750319f928d8ac86d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 11 Jun 2022 21:19:37 +0200 Subject: [PATCH 4/4] Hotfix BaseEntity19 Signed-off-by: yoyosource --- BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java index 7cf650c2..075d4987 100644 --- a/BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java +++ b/BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java @@ -79,7 +79,7 @@ public class BaseEntity19 extends EntityFallingBlock implements AbstractEntity { } public void sendEntity(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), cp(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.C, Block.i(iBlockData), ZERO, 0.0); + PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), cp(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.E, Block.i(iBlockData), ZERO, 0.0); PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; playerConnection.a(packetPlayOutSpawnEntity);