9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2026-01-04 15:41:45 +00:00

Added close menu action

This commit is contained in:
Fisher2911
2022-04-29 21:44:29 -04:00
parent fc7b886727
commit 74a0d279b0
9 changed files with 3 additions and 459 deletions

View File

@@ -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")
}

View File

@@ -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<EnumWrappers.PlayerInfoAction> action = playerInfoPacket.getPlayerInfoAction();
// final StructureModifier<List<PlayerInfoData>> infoData = playerInfoPacket.getPlayerInfoDataLists();
//
// final List<PlayerInfoData> 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<EnumWrappers.PlayerInfoAction> action = playerPacket.getPlayerInfoAction();
// final StructureModifier<List<PlayerInfoData>> infoData = playerPacket.getPlayerInfoDataLists();
//
// final List<PlayerInfoData> 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;
// }
}

View File

@@ -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")
}

View File

@@ -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<EnumWrappers.PlayerInfoAction> action = playerInfoPacket.getPlayerInfoAction();
// final StructureModifier<List<PlayerInfoData>> infoData = playerInfoPacket.getPlayerInfoDataLists();
//
// final List<PlayerInfoData> 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<EnumWrappers.PlayerInfoAction> action = playerPacket.getPlayerInfoAction();
// final StructureModifier<List<PlayerInfoData>> infoData = playerPacket.getPlayerInfoDataLists();
//
// final List<PlayerInfoData> 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;
// }
}

View File

@@ -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")
}

View File

@@ -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<EnumWrappers.PlayerInfoAction> action = playerInfoPacket.getPlayerInfoAction();
// final StructureModifier<List<PlayerInfoData>> infoData = playerInfoPacket.getPlayerInfoDataLists();
//
// final List<PlayerInfoData> 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<EnumWrappers.PlayerInfoAction> action = playerPacket.getPlayerInfoAction();
// final StructureModifier<List<PlayerInfoData>> infoData = playerPacket.getPlayerInfoDataLists();
//
// final List<PlayerInfoData> 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;
// }
}

View File

@@ -38,6 +38,7 @@ public class ActionSerializer implements TypeSerializer<List<CosmeticGuiAction>>
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<List<CosmeticGuiAction>>
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<List<CosmeticGuiAction>>
gui.updateItem(entry.getKey(), item, user, player);
}
}
if (closeMenu) player.closeInventory();
}
);
}

View File

@@ -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")
}

View File

@@ -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);
}