From 74a0d279b01afcb58af51742093f6b4bc3d46ff5 Mon Sep 17 00:00:00 2001 From: Fisher2911 Date: Fri, 29 Apr 2022 21:44:29 -0400 Subject: [PATCH] Added close menu action --- 1.16/build.gradle.kts | 19 --- .../fisher2911/nms/PacketHelper_1_16_R3.java | 120 ------------------ 1.17/build.gradle.kts | 23 ---- .../fisher2911/nms/PacketHelper_1_17_R1.java | 120 ------------------ 1.18/build.gradle.kts | 23 ---- .../fisher2911/nms/PacketHelper_1_18_R1.java | 119 ----------------- .../hmccosmetics/config/ActionSerializer.java | 3 + nms/build.gradle.kts | 22 ---- .../github/fisher2911/nms/PacketHelper.java | 13 -- 9 files changed, 3 insertions(+), 459 deletions(-) delete mode 100644 1.16/build.gradle.kts delete mode 100644 1.16/src/main/java/io/github/fisher2911/nms/PacketHelper_1_16_R3.java delete mode 100644 1.17/build.gradle.kts delete mode 100644 1.17/src/main/java/io/github/fisher2911/nms/PacketHelper_1_17_R1.java delete mode 100644 1.18/build.gradle.kts delete mode 100644 1.18/src/main/java/io/github/fisher2911/nms/PacketHelper_1_18_R1.java delete mode 100644 nms/build.gradle.kts delete mode 100644 nms/src/main/java/io/github/fisher2911/nms/PacketHelper.java diff --git a/1.16/build.gradle.kts b/1.16/build.gradle.kts deleted file mode 100644 index 6efd9955..00000000 --- a/1.16/build.gradle.kts +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - id("java") -} - -repositories { - mavenCentral() - maven("https://papermc.io/repo/repository/maven-public/") - maven("https://oss.sonatype.org/content/repositories/snapshots") - maven("https://jitpack.io") -// maven("https://repo.dmulloy2.net/repository/public/") -} - -dependencies { - implementation(project(":nms")) - compileOnly("com.mojang:authlib:1.5.25") - compileOnly("org.spigotmc:spigot:1.16.5-R0.1-SNAPSHOT") - compileOnly("org.jetbrains:annotations:22.0.0") -// compileOnly("com.comphenix.protocol:ProtocolLib:4.7.0") -} diff --git a/1.16/src/main/java/io/github/fisher2911/nms/PacketHelper_1_16_R3.java b/1.16/src/main/java/io/github/fisher2911/nms/PacketHelper_1_16_R3.java deleted file mode 100644 index 3781a739..00000000 --- a/1.16/src/main/java/io/github/fisher2911/nms/PacketHelper_1_16_R3.java +++ /dev/null @@ -1,120 +0,0 @@ -package io.github.fisher2911.nms; - -public class PacketHelper_1_16_R3 implements PacketHelper { - -// @Override -// public PacketContainer getPlayerSpawnPacket(final Location location, UUID uuid, final int entityId) { -// final PacketContainer spawnPacket = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN); -// spawnPacket.getUUIDs().write(0, uuid); -// spawnPacket.getIntegers().write(0, entityId); -// spawnPacket.getDoubles(). -// write(0, location.getX()). -// write(1, location.getY()). -// write(2, location.getZ()); -// spawnPacket.getBytes().write(0, (byte)(((location.getYaw() * 256.0F) / 360.0F))); -// -// return spawnPacket; -// } -// -// @Override -// public PacketContainer getPlayerInfoPacket(final Player player, final UUID uuid) { -// final GameProfile profile = this.getCopyProfile(player, uuid); -// final PacketContainer playerInfoPacket = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); -// final StructureModifier action = playerInfoPacket.getPlayerInfoAction(); -// final StructureModifier> infoData = playerInfoPacket.getPlayerInfoDataLists(); -// -// final List playerInfoData = new ArrayList<>(); -// -// playerInfoData.add(new PlayerInfoData(WrappedGameProfile -// .fromHandle(profile), -// 0, -// EnumWrappers.NativeGameMode.fromBukkit(GameMode.CREATIVE), -// WrappedChatComponent.fromText(profile.getName()))); -// -// action.write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER); -// infoData.write(0, playerInfoData); -// -// return playerInfoPacket; -// } -// -// @Override -// public PacketContainer getPlayerRemovePacket(final Player player, final UUID uuid, final int entityId) { -// final PacketContainer playerPacket = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); -// final StructureModifier action = playerPacket.getPlayerInfoAction(); -// final StructureModifier> infoData = playerPacket.getPlayerInfoDataLists(); -// -// final List playerInfoData = new ArrayList<>(); -// -// final GameProfile profile = this.getCopyProfile(player, uuid); -// -// playerInfoData.add(new PlayerInfoData(WrappedGameProfile -// .fromHandle(profile), -// 0, -// EnumWrappers.NativeGameMode.fromBukkit(GameMode.CREATIVE), -// WrappedChatComponent.fromText(""))); -// -// action.write(0, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER); -// infoData.write(0, playerInfoData); -// -// return playerPacket; -// } -// -// @Override -// public PacketContainer getPlayerOverlayPacket(final int entityId) { -// final PacketContainer metaContainer = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); -// -// WrappedDataWatcher metaData = new WrappedDataWatcher(); -// -// final WrappedDataWatcher.Serializer byteSerializer = WrappedDataWatcher.Registry.get(Byte.class); -// -// final byte mask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x40; -// -// metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(16, byteSerializer), mask); -// -// metaContainer.getIntegers().write(0, entityId); -// metaContainer.getWatchableCollectionModifier().write(0, metaData.getWatchableObjects()); -// return metaContainer; -// } -// -// private GameProfile getCopyProfile(final Player player, final UUID uuid) { -// final GameProfile playerProfile = ((CraftPlayer) player).getProfile(); -// final GameProfile profile = new GameProfile( -// uuid, -// player.getDisplayName() -// ); -// -// profile.getProperties().removeAll("textures"); -// Property textureProperty = playerProfile.getProperties().get("textures").iterator().next(); -// String texture = textureProperty.getValue(); -// String signature = textureProperty.getSignature(); -// profile.getProperties().put("textures", new Property("textures", texture, signature)); -// -// return profile; -// } -// -// @Override -// public PacketContainer getArmorStandMeta(final int armorStandId) { -// final PacketContainer metaContainer = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); -// -// WrappedDataWatcher metaData = new WrappedDataWatcher(); -// -// final WrappedDataWatcher.Serializer byteSerializer = WrappedDataWatcher.Registry.get(Byte.class); -// -// metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, byteSerializer), (byte) (0x20)); -// metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(14, byteSerializer), (byte) (0x10)); -// -// metaContainer.getIntegers().write(0, armorStandId); -// metaContainer.getWatchableCollectionModifier().write(0, metaData.getWatchableObjects()); -// return metaContainer; -// } -// -// @Override -// public PacketContainer getDestroyPacket(final int entityId) { -// final PacketContainer destroyPacket = new PacketContainer( -// PacketType.Play.Server.ENTITY_DESTROY); -// destroyPacket.getIntegerArrays().write(0, new int[]{entityId}); -// -// return destroyPacket; -// } - -} diff --git a/1.17/build.gradle.kts b/1.17/build.gradle.kts deleted file mode 100644 index 39540bb2..00000000 --- a/1.17/build.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -plugins { - id("java") -} - -//group = "io.github.fisher2911" -//version = "1.7.1" -//description = "Intuitive, easy-to-use cosmetics plugin, designed for servers using resource packs.\n" - -repositories { - mavenCentral() - maven("https://papermc.io/repo/repository/maven-public/") - maven("https://oss.sonatype.org/content/repositories/snapshots") - maven("https://jitpack.io") -// maven("https://repo.dmulloy2.net/repository/public/") -} - -dependencies { - implementation(project(":nms")) - compileOnly("com.mojang:authlib:1.5.25") - compileOnly("org.spigotmc:spigot:1.17-R0.1-SNAPSHOT") - compileOnly("org.jetbrains:annotations:22.0.0") -// compileOnly("com.comphenix.protocol:ProtocolLib:4.7.0") -} diff --git a/1.17/src/main/java/io/github/fisher2911/nms/PacketHelper_1_17_R1.java b/1.17/src/main/java/io/github/fisher2911/nms/PacketHelper_1_17_R1.java deleted file mode 100644 index e55e9f26..00000000 --- a/1.17/src/main/java/io/github/fisher2911/nms/PacketHelper_1_17_R1.java +++ /dev/null @@ -1,120 +0,0 @@ -package io.github.fisher2911.nms; - -public class PacketHelper_1_17_R1 implements PacketHelper { - -// @Override -// public PacketContainer getPlayerSpawnPacket(final Location location, UUID uuid, final int entityId) { -// final PacketContainer spawnPacket = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN); -// spawnPacket.getUUIDs().write(0, uuid); -// spawnPacket.getIntegers().write(0, entityId); -// spawnPacket.getDoubles(). -// write(0, location.getX()). -// write(1, location.getY()). -// write(2, location.getZ()); -// spawnPacket.getBytes().write(0, (byte)(((location.getYaw() * 256.0F) / 360.0F))); -// -// return spawnPacket; -// } -// -// @Override -// public PacketContainer getPlayerInfoPacket(final Player player, final UUID uuid) { -// final GameProfile profile = this.getCopyProfile(player, uuid); -// final PacketContainer playerInfoPacket = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); -// final StructureModifier action = playerInfoPacket.getPlayerInfoAction(); -// final StructureModifier> infoData = playerInfoPacket.getPlayerInfoDataLists(); -// -// final List playerInfoData = new ArrayList<>(); -// -// playerInfoData.add(new PlayerInfoData(WrappedGameProfile -// .fromHandle(profile), -// 0, -// EnumWrappers.NativeGameMode.fromBukkit(GameMode.CREATIVE), -// WrappedChatComponent.fromText(profile.getName()))); -// -// action.write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER); -// infoData.write(0, playerInfoData); -// -// return playerInfoPacket; -// } -// -// @Override -// public PacketContainer getPlayerRemovePacket(final Player player, final UUID uuid, final int entityId) { -// final PacketContainer playerPacket = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); -// final StructureModifier action = playerPacket.getPlayerInfoAction(); -// final StructureModifier> infoData = playerPacket.getPlayerInfoDataLists(); -// -// final List playerInfoData = new ArrayList<>(); -// -// final GameProfile profile = this.getCopyProfile(player, uuid); -// -// playerInfoData.add(new PlayerInfoData(WrappedGameProfile -// .fromHandle(profile), -// 0, -// EnumWrappers.NativeGameMode.fromBukkit(GameMode.CREATIVE), -// WrappedChatComponent.fromText(""))); -// -// action.write(0, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER); -// infoData.write(0, playerInfoData); -// -// return playerPacket; -// } -// -// @Override -// public PacketContainer getPlayerOverlayPacket(final int entityId) { -// final PacketContainer metaContainer = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); -// -// WrappedDataWatcher metaData = new WrappedDataWatcher(); -// -// final WrappedDataWatcher.Serializer byteSerializer = WrappedDataWatcher.Registry.get(Byte.class); -// -// final byte mask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x40; -// -// metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, byteSerializer), mask); -// -// metaContainer.getIntegers().write(0, entityId); -// metaContainer.getWatchableCollectionModifier().write(0, metaData.getWatchableObjects()); -// return metaContainer; -// } -// -// private GameProfile getCopyProfile(final Player player, final UUID uuid) { -// final GameProfile playerProfile = ((CraftPlayer) player).getProfile(); -// final GameProfile profile = new GameProfile( -// uuid, -// player.getDisplayName() -// ); -// -// profile.getProperties().removeAll("textures"); -// Property textureProperty = playerProfile.getProperties().get("textures").iterator().next(); -// String texture = textureProperty.getValue(); -// String signature = textureProperty.getSignature(); -// profile.getProperties().put("textures", new Property("textures", texture, signature)); -// -// return profile; -// } -// -// @Override -// public PacketContainer getArmorStandMeta(final int armorStandId) { -// final PacketContainer metaContainer = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); -// -// WrappedDataWatcher metaData = new WrappedDataWatcher(); -// -// final WrappedDataWatcher.Serializer byteSerializer = WrappedDataWatcher.Registry.get(Byte.class); -// -// metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, byteSerializer), (byte) (0x20)); -// metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, byteSerializer), (byte) (0x10)); -// -// metaContainer.getIntegers().write(0, armorStandId); -// metaContainer.getWatchableCollectionModifier().write(0, metaData.getWatchableObjects()); -// return metaContainer; -// } -// -// @Override -// public PacketContainer getDestroyPacket(final int entityId) { -// final PacketContainer destroyPacket = new PacketContainer( -// PacketType.Play.Server.ENTITY_DESTROY); -// destroyPacket.getModifier().write(0, new IntArrayList(new int[]{entityId})); -// -// return destroyPacket; -// } - -} diff --git a/1.18/build.gradle.kts b/1.18/build.gradle.kts deleted file mode 100644 index 482e2675..00000000 --- a/1.18/build.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -plugins { - id("java") -} - -//group = "io.github.fisher2911" -//version = "1.7.1" -//description = "Intuitive, easy-to-use cosmetics plugin, designed for servers using resource packs.\n" - -repositories { - mavenCentral() - maven("https://papermc.io/repo/repository/maven-public/") - maven("https://oss.sonatype.org/content/repositories/snapshots") - maven("https://jitpack.io") -// maven("https://repo.dmulloy2.net/repository/public/") -} - -dependencies { - implementation(project(":nms")) - compileOnly("com.mojang:authlib:1.5.25") - compileOnly("org.spigotmc:spigot:1.18-R0.1-SNAPSHOT") - compileOnly("org.jetbrains:annotations:22.0.0") -// compileOnly("com.comphenix.protocol:ProtocolLib:4.7.0") -} diff --git a/1.18/src/main/java/io/github/fisher2911/nms/PacketHelper_1_18_R1.java b/1.18/src/main/java/io/github/fisher2911/nms/PacketHelper_1_18_R1.java deleted file mode 100644 index 54b60823..00000000 --- a/1.18/src/main/java/io/github/fisher2911/nms/PacketHelper_1_18_R1.java +++ /dev/null @@ -1,119 +0,0 @@ -package io.github.fisher2911.nms; - -public class PacketHelper_1_18_R1 implements PacketHelper { - -// @Override -// public PacketContainer getPlayerSpawnPacket(final Location location, UUID uuid, final int entityId) { -// final PacketContainer spawnPacket = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN); -// spawnPacket.getUUIDs().write(0, uuid); -// spawnPacket.getIntegers().write(0, entityId); -// spawnPacket.getDoubles(). -// write(0, location.getX()). -// write(1, location.getY()). -// write(2, location.getZ()); -// spawnPacket.getBytes().write(0, (byte)(((location.getYaw() * 256.0F) / 360.0F))); -// -// return spawnPacket; -// } -// -// @Override -// public PacketContainer getPlayerInfoPacket(final Player player, final UUID uuid) { -// final GameProfile profile = this.getCopyProfile(player, uuid); -// final PacketContainer playerInfoPacket = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); -// final StructureModifier action = playerInfoPacket.getPlayerInfoAction(); -// final StructureModifier> infoData = playerInfoPacket.getPlayerInfoDataLists(); -// -// final List playerInfoData = new ArrayList<>(); -// -// playerInfoData.add(new PlayerInfoData(WrappedGameProfile -// .fromHandle(profile), -// 0, -// EnumWrappers.NativeGameMode.fromBukkit(GameMode.SURVIVAL), -// WrappedChatComponent.fromText(profile.getName()))); -// -// action.write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER); -// infoData.write(0, playerInfoData); -// -// return playerInfoPacket; -// } -// -// @Override -// public PacketContainer getPlayerRemovePacket(final Player player, final UUID uuid, final int entityId) { -// final PacketContainer playerPacket = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); -// final StructureModifier action = playerPacket.getPlayerInfoAction(); -// final StructureModifier> infoData = playerPacket.getPlayerInfoDataLists(); -// -// final List playerInfoData = new ArrayList<>(); -// -// final GameProfile profile = this.getCopyProfile(player, uuid); -// -// playerInfoData.add(new PlayerInfoData(WrappedGameProfile -// .fromHandle(profile), -// 0, -// EnumWrappers.NativeGameMode.fromBukkit(GameMode.CREATIVE), -// WrappedChatComponent.fromText(""))); -// -// action.write(0, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER); -// infoData.write(0, playerInfoData); -// -// return playerPacket; -// } -// -// @Override -// public PacketContainer getPlayerOverlayPacket(final int entityId) { -// final PacketContainer metaContainer = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); -// -// WrappedDataWatcher metaData = new WrappedDataWatcher(); -// -// final WrappedDataWatcher.Serializer byteSerializer = WrappedDataWatcher.Registry.get(Byte.class); -// -// final byte mask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x40; -// -// metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, byteSerializer), mask); -// -// metaContainer.getIntegers().write(0, entityId); -// metaContainer.getWatchableCollectionModifier().write(0, metaData.getWatchableObjects()); -// return metaContainer; -// } -// -// private GameProfile getCopyProfile(final Player player, final UUID uuid) { -// final GameProfile playerProfile = ((CraftPlayer) player).getProfile(); -// final GameProfile profile = new GameProfile( -// uuid, -// player.getDisplayName() -// ); -// -// profile.getProperties().removeAll("textures"); -// Property textureProperty = playerProfile.getProperties().get("textures").iterator().next(); -// String texture = textureProperty.getValue(); -// String signature = textureProperty.getSignature(); -// profile.getProperties().put("textures", new Property("textures", texture, signature)); -// -// return profile; -// } -// -// @Override -// public PacketContainer getArmorStandMeta(final int armorStandId) { -// final PacketContainer metaContainer = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); -// -// WrappedDataWatcher metaData = new WrappedDataWatcher(); -// -// final WrappedDataWatcher.Serializer byteSerializer = WrappedDataWatcher.Registry.get(Byte.class); -// -// metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, byteSerializer), (byte) (0x20)); -// metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, byteSerializer), (byte) (0x10)); -// -// metaContainer.getIntegers().write(0, armorStandId); -// metaContainer.getWatchableCollectionModifier().write(0, metaData.getWatchableObjects()); -// return metaContainer; -// } -// -// @Override -// public PacketContainer getDestroyPacket(final int entityId) { -// final PacketContainer destroyPacket = new PacketContainer( -// PacketType.Play.Server.ENTITY_DESTROY); -// destroyPacket.getModifier().write(0, new IntArrayList(new int[]{entityId})); -// -// return destroyPacket; -// } -} diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/config/ActionSerializer.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/config/ActionSerializer.java index 2bfede5d..3f1e26b0 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/config/ActionSerializer.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/config/ActionSerializer.java @@ -38,6 +38,7 @@ public class ActionSerializer implements TypeSerializer> private static final HMCCosmetics plugin; private static final String OPEN_MENU = "open-menu"; + private static final String CLOSE_MENU = "close-menu"; private static final String SET_ITEMS = "set-items"; private static final String REMOVE_COSMETICS = "remove-cosmetics"; private static final String SET_COSMETICS = "set-cosmetics"; @@ -98,6 +99,7 @@ public class ActionSerializer implements TypeSerializer> final ConfigurationNode removeItemsNode = node.node(REMOVE_COSMETICS); final ConfigurationNode setCosmeticsNode = node.node(SET_COSMETICS); final ConfigurationNode soundNode = node.node(SOUND); + final boolean closeMenu = node.node(CLOSE_MENU).getBoolean(false); final String openMenu = openMenuNode.getString(); @@ -150,6 +152,7 @@ public class ActionSerializer implements TypeSerializer> gui.updateItem(entry.getKey(), item, user, player); } } + if (closeMenu) player.closeInventory(); } ); } diff --git a/nms/build.gradle.kts b/nms/build.gradle.kts deleted file mode 100644 index e662c91f..00000000 --- a/nms/build.gradle.kts +++ /dev/null @@ -1,22 +0,0 @@ -plugins { - id("java") -} - -//group = "io.github.fisher2911" -//version = "1.7.1" -//description = "Intuitive, easy-to-use cosmetics plugin, designed for servers using resource packs.\n" - -repositories { - mavenCentral() - maven("https://papermc.io/repo/repository/maven-public/") - maven("https://oss.sonatype.org/content/repositories/snapshots") - maven("https://jitpack.io") -// maven("https://repo.dmulloy2.net/repository/public/") -} - -dependencies { - compileOnly("com.mojang:authlib:1.5.25") -// compileOnly("org.spigotmc:spigot:1.18-R0.1-SNAPSHOT") - compileOnly("org.jetbrains:annotations:22.0.0") -// compileOnly("com.comphenix.protocol:ProtocolLib:4.7.0") -} diff --git a/nms/src/main/java/io/github/fisher2911/nms/PacketHelper.java b/nms/src/main/java/io/github/fisher2911/nms/PacketHelper.java deleted file mode 100644 index 06fd9380..00000000 --- a/nms/src/main/java/io/github/fisher2911/nms/PacketHelper.java +++ /dev/null @@ -1,13 +0,0 @@ -package io.github.fisher2911.nms; - -public interface PacketHelper { - -// PacketContainer getPlayerSpawnPacket(final Location location, UUID uuid, final int entityId); -// PacketContainer getPlayerInfoPacket(final Player player, final UUID uuid); -// PacketContainer getPlayerRemovePacket(final Player player, final UUID uuid, final int entityId); -// PacketContainer getPlayerOverlayPacket(final int entityId); -// PacketContainer getDestroyPacket(final int entityId); -// PacketContainer getArmorStandMeta(final int armorStandId); -// PacketContainer getGuiOpenPacket(final Player player); - -}