From 91255be7572e926c53f09fc27f4ffb37cb9e4f99 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 3 Mar 2023 16:34:40 +0100 Subject: [PATCH] Hotfix NoClipCommand Signed-off-by: yoyosource --- .../bausystem/utils/ProtocolWrapper15.java | 33 ------------------- .../bausystem/utils/ProtocolWrapper18.java | 33 ------------------- .../bausystem/utils/ProtocolWrapper19.java | 33 ------------------- .../features/util/NoClipCommand.java | 14 ++++---- .../bausystem/utils/ProtocolWrapper.java | 30 ----------------- 5 files changed, 8 insertions(+), 135 deletions(-) delete mode 100644 BauSystem_15/src/de/steamwar/bausystem/utils/ProtocolWrapper15.java delete mode 100644 BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java delete mode 100644 BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java delete 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 deleted file mode 100644 index 57ba7259..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/ProtocolWrapper15.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.utils; - -import com.comphenix.tinyprotocol.Reflection; -import com.mojang.authlib.GameProfile; -import de.steamwar.bausystem.features.util.NoClipCommand; - -public class ProtocolWrapper15 implements ProtocolWrapper { - - private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, NoClipCommand.playerInfoPacket, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent); - @Override - public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) { - return playerInfoDataConstructor.invoke(packet, profile, 0, mode, null); - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java deleted file mode 100644 index 962b8181..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/ProtocolWrapper18.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.utils; - -import com.comphenix.tinyprotocol.Reflection; -import com.mojang.authlib.GameProfile; -import de.steamwar.bausystem.features.util.NoClipCommand; - -public class ProtocolWrapper18 implements ProtocolWrapper { - - private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent); - @Override - public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) { - return playerInfoDataConstructor.invoke(profile, 0, mode, null); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java b/BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java deleted file mode 100644 index 3a21ab08..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/utils/ProtocolWrapper19.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2021 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ - -package de.steamwar.bausystem.utils; - -import com.comphenix.tinyprotocol.Reflection; -import com.mojang.authlib.GameProfile; -import de.steamwar.bausystem.features.util.NoClipCommand; - -public class ProtocolWrapper19 implements ProtocolWrapper { - - private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(NoClipCommand.playerInfoDataClass, GameProfile.class, int.class, NoClipCommand.enumGamemode, NoClipCommand.iChatBaseComponent, Reflection.getClass("net.minecraft.world.entity.player.ProfilePublicKey$a")); - @Override - public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) { - return playerInfoDataConstructor.invoke(profile, 0, mode, null, null); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java index 3aab2cca..42caa32e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java @@ -25,9 +25,8 @@ import com.mojang.authlib.GameProfile; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.utils.NMSWrapper; -import de.steamwar.bausystem.utils.ProtocolWrapper; import de.steamwar.command.SWCommand; -import de.steamwar.core.Core; +import de.steamwar.core.ProtocolWrapper; import de.steamwar.linkage.Linked; import lombok.Getter; import org.bukkit.Bukkit; @@ -40,7 +39,10 @@ import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.function.BiFunction; @Linked @@ -112,7 +114,7 @@ public class NoClipCommand extends SWCommand implements Listener { NOCLIPS.add(player); BauSystem.MESSAGE.send("OTHER_NOCLIP_SLOT_INFO", player); TinyProtocol.instance.sendPacket(player, gameStateChangeObject); - pseudoSpectator(player); + pseudoGameMode(player, GameMode.CREATIVE); } } @@ -151,7 +153,7 @@ public class NoClipCommand extends SWCommand implements Listener { } } - private static void pseudoSpectator(Player player) { - TinyProtocol.instance.sendPacket(player, de.steamwar.core.ProtocolWrapper.impl.playerInfoPacketConstructor(de.steamwar.core.ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), GameMode.CREATIVE)); + private static void pseudoGameMode(Player player, GameMode gameMode) { + TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), gameMode)); } } \ 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 deleted file mode 100644 index 536dec51..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/ProtocolWrapper.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -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); -}