From 2806a87cc5372c71e1be4727657cfd6ddb3194d6 Mon Sep 17 00:00:00 2001 From: aro Date: Tue, 31 Jan 2023 15:46:17 +0100 Subject: [PATCH] feat(build): cleaned up dependencies --- core/dependency-reduced-pom.xml | 20 ++-- core/pom.xml | 11 +- dist/dependency-reduced-pom.xml | 33 ------ dist/pom.xml | 35 +----- pom.xml | 2 + v1_14_R1/pom.xml | 28 +++++ .../net/artelnatif/nicko/impl/v1_17_R1.java | 101 ++++++++++++++++++ v1_14_R1/v1_14_R1.iml | 69 ++++++++++++ v1_15_R1/pom.xml | 28 +++++ .../net/artelnatif/nicko/impl/v1_17_R1.java | 101 ++++++++++++++++++ v1_15_R1/v1_15_R1.iml | 69 ++++++++++++ v1_16_R1/pom.xml | 28 +++++ .../net/artelnatif/nicko/impl/v1_17_R1.java | 101 ++++++++++++++++++ v1_16_R1/v1_16_R1.iml | 69 ++++++++++++ v1_16_R2/pom.xml | 28 +++++ .../net/artelnatif/nicko/impl/v1_17_R1.java | 101 ++++++++++++++++++ v1_16_R2/v1_16_R2.iml | 69 ++++++++++++ v1_16_R3/pom.xml | 28 +++++ .../net/artelnatif/nicko/impl/v1_17_R1.java | 101 ++++++++++++++++++ v1_16_R3/v1_16_R3.iml | 69 ++++++++++++ v1_19_R2/pom.xml | 38 +++++++ 21 files changed, 1045 insertions(+), 84 deletions(-) create mode 100644 v1_14_R1/pom.xml create mode 100644 v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java create mode 100644 v1_14_R1/v1_14_R1.iml create mode 100644 v1_15_R1/pom.xml create mode 100644 v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java create mode 100644 v1_15_R1/v1_15_R1.iml create mode 100644 v1_16_R1/pom.xml create mode 100644 v1_16_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java create mode 100644 v1_16_R1/v1_16_R1.iml create mode 100644 v1_16_R2/pom.xml create mode 100644 v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java create mode 100644 v1_16_R2/v1_16_R2.iml create mode 100644 v1_16_R3/pom.xml create mode 100644 v1_16_R3/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java create mode 100644 v1_16_R3/v1_16_R3.iml diff --git a/core/dependency-reduced-pom.xml b/core/dependency-reduced-pom.xml index e615464..e35d9f3 100644 --- a/core/dependency-reduced-pom.xml +++ b/core/dependency-reduced-pom.xml @@ -6,7 +6,7 @@ 1.0-SNAPSHOT 4.0.0 - nicko-core + core 1.0-SNAPSHOT @@ -40,6 +40,14 @@ org.mariadb.jdbc + + + net.artelnatif:* + + META-INF/*.MF + + + net.wesjd.anvilgui @@ -115,14 +123,8 @@ net.md-5 bungeecord-api - 1.18-R0.1-SNAPSHOT - compile - - - org.apache.commons - commons-lang3 - 3.12.0 - compile + 1.19-R0.1-SNAPSHOT + provided com.google.guava diff --git a/core/pom.xml b/core/pom.xml index ba2f9a7..00a217c 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -65,7 +65,8 @@ net.md-5 bungeecord-api - 1.18-R0.1-SNAPSHOT + 1.19-R0.1-SNAPSHOT + provided @@ -79,12 +80,6 @@ anvilgui 1.6.3-SNAPSHOT - - - org.apache.commons - commons-lang3 - 3.12.0 - com.google.guava @@ -111,13 +106,11 @@ yamlconfig 1.1.1 - com.fasterxml.jackson.core jackson-core 2.14.0-rc1 - com.fasterxml.jackson.dataformat jackson-dataformat-yaml diff --git a/dist/dependency-reduced-pom.xml b/dist/dependency-reduced-pom.xml index abcb5d0..9ac078f 100644 --- a/dist/dependency-reduced-pom.xml +++ b/dist/dependency-reduced-pom.xml @@ -31,39 +31,6 @@ - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - remap-obf - package - - remap - - - org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:txt:maps-mojang - true - org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-mojang - true - remapped-obf - - - - remap-spigot - package - - remap - - - ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-obf - - - - diff --git a/dist/pom.xml b/dist/pom.xml index 680582d..025fd4b 100644 --- a/dist/pom.xml +++ b/dist/pom.xml @@ -37,39 +37,6 @@ - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:txt:maps-mojang - true - org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-mojang - true - remapped-obf - - - - package - - remap - - remap-spigot - - ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-obf - - - - @@ -79,6 +46,7 @@ core ${project.parent.version} + net.artelnatif v1_17_R1 diff --git a/pom.xml b/pom.xml index 7836e09..7310186 100644 --- a/pom.xml +++ b/pom.xml @@ -13,11 +13,13 @@ core dist + v1_17_R1 v1_18_R1 v1_18_R2 diff --git a/v1_14_R1/pom.xml b/v1_14_R1/pom.xml new file mode 100644 index 0000000..f69fa93 --- /dev/null +++ b/v1_14_R1/pom.xml @@ -0,0 +1,28 @@ + + + + nicko-parent + net.artelnatif + 1.0-SNAPSHOT + + 4.0.0 + + v1_14_R1 + 1.0-SNAPSHOT + + + + org.spigotmc + spigot + 1.14.4-R0.1-SNAPSHOT + provided + + + net.artelnatif + core + 1.0-SNAPSHOT + + + \ No newline at end of file diff --git a/v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java b/v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java new file mode 100644 index 0000000..6ca5cd1 --- /dev/null +++ b/v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java @@ -0,0 +1,101 @@ +package net.artelnatif.nicko.impl; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; +import net.artelnatif.nicko.disguise.ActionResult; +import net.artelnatif.nicko.disguise.NickoProfile; +import net.artelnatif.nicko.mojang.MojangSkin; +import net.minecraft.network.chat.IChatBaseComponent; +import net.minecraft.network.protocol.game.*; +import net.minecraft.network.syncher.DataWatcher; +import net.minecraft.network.syncher.DataWatcherObject; +import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.world.level.EnumGamemode; +import net.minecraft.world.level.World; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerTeleportEvent; + +public class v1_17_R1 implements Internals { + @Override + public void updateSelf(Player player) { + final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + final ResourceKey levelResourceKey = entityPlayer.getWorld().getDimensionKey(); + final CraftWorld world = entityPlayer.getWorld().getWorld(); + final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(), + levelResourceKey, world.getSeed(), + entityPlayer.c.getGamemode(), entityPlayer.d.c(), + false, + false, + false); + + final boolean wasFlying = player.isFlying(); + entityPlayer.b.sendPacket(respawn); + player.setFlying(wasFlying); + player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + player.updateInventory(); + } + + @Override + public void updateOthers(Player player) { + final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId()); + final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer); + + final DataWatcher dataWatcher = entityPlayer.getDataWatcher(); + final DataWatcherObject displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); + dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f); + final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true); + + Bukkit.getOnlinePlayers().forEach(online -> { + EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); + if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) { + onlineEntityPlayer.b.sendPacket(destroy); + onlineEntityPlayer.b.sendPacket(spawn); + } + onlineEntityPlayer.b.sendPacket(entityMetadata); + }); + } + + @Override + public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) { + final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName()); + final String profileName = profile.getName() == null ? player.getName() : profile.getName(); + + final CraftPlayer craftPlayer = (CraftPlayer) player; + final EntityPlayer entityPlayer = craftPlayer.getHandle(); + final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName); + + if (skinChange || changeOnlyName) { + final ActionResult skinFetch = fetchSkinTextures(profile, reset); + if (!skinFetch.isError()) { + final MojangSkin skin = skinFetch.getResult(); + final PropertyMap properties = gameProfile.getProperties(); + properties.removeAll("textures"); + properties.put("textures", new Property("textures", skin.value(), skin.signature())); + updateSelf(player); + } + } + + final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer); + final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a); + + add.b().clear(); + add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, + player.getPing(), + EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName))); + + Bukkit.getOnlinePlayers().forEach(online -> { + EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); + onlineEntityPlayer.b.sendPacket(remove); + onlineEntityPlayer.b.sendPacket(add); + }); + updateOthers(player); + return new ActionResult<>(); + } +} diff --git a/v1_14_R1/v1_14_R1.iml b/v1_14_R1/v1_14_R1.iml new file mode 100644 index 0000000..fa42d64 --- /dev/null +++ b/v1_14_R1/v1_14_R1.iml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/v1_15_R1/pom.xml b/v1_15_R1/pom.xml new file mode 100644 index 0000000..783358e --- /dev/null +++ b/v1_15_R1/pom.xml @@ -0,0 +1,28 @@ + + + + nicko-parent + net.artelnatif + 1.0-SNAPSHOT + + 4.0.0 + + v1_15_R1 + 1.0-SNAPSHOT + + + + org.spigotmc + spigot + 1.15.2-R0.1-SNAPSHOT + provided + + + net.artelnatif + core + 1.0-SNAPSHOT + + + \ No newline at end of file diff --git a/v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java b/v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java new file mode 100644 index 0000000..6ca5cd1 --- /dev/null +++ b/v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java @@ -0,0 +1,101 @@ +package net.artelnatif.nicko.impl; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; +import net.artelnatif.nicko.disguise.ActionResult; +import net.artelnatif.nicko.disguise.NickoProfile; +import net.artelnatif.nicko.mojang.MojangSkin; +import net.minecraft.network.chat.IChatBaseComponent; +import net.minecraft.network.protocol.game.*; +import net.minecraft.network.syncher.DataWatcher; +import net.minecraft.network.syncher.DataWatcherObject; +import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.world.level.EnumGamemode; +import net.minecraft.world.level.World; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerTeleportEvent; + +public class v1_17_R1 implements Internals { + @Override + public void updateSelf(Player player) { + final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + final ResourceKey levelResourceKey = entityPlayer.getWorld().getDimensionKey(); + final CraftWorld world = entityPlayer.getWorld().getWorld(); + final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(), + levelResourceKey, world.getSeed(), + entityPlayer.c.getGamemode(), entityPlayer.d.c(), + false, + false, + false); + + final boolean wasFlying = player.isFlying(); + entityPlayer.b.sendPacket(respawn); + player.setFlying(wasFlying); + player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + player.updateInventory(); + } + + @Override + public void updateOthers(Player player) { + final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId()); + final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer); + + final DataWatcher dataWatcher = entityPlayer.getDataWatcher(); + final DataWatcherObject displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); + dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f); + final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true); + + Bukkit.getOnlinePlayers().forEach(online -> { + EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); + if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) { + onlineEntityPlayer.b.sendPacket(destroy); + onlineEntityPlayer.b.sendPacket(spawn); + } + onlineEntityPlayer.b.sendPacket(entityMetadata); + }); + } + + @Override + public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) { + final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName()); + final String profileName = profile.getName() == null ? player.getName() : profile.getName(); + + final CraftPlayer craftPlayer = (CraftPlayer) player; + final EntityPlayer entityPlayer = craftPlayer.getHandle(); + final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName); + + if (skinChange || changeOnlyName) { + final ActionResult skinFetch = fetchSkinTextures(profile, reset); + if (!skinFetch.isError()) { + final MojangSkin skin = skinFetch.getResult(); + final PropertyMap properties = gameProfile.getProperties(); + properties.removeAll("textures"); + properties.put("textures", new Property("textures", skin.value(), skin.signature())); + updateSelf(player); + } + } + + final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer); + final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a); + + add.b().clear(); + add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, + player.getPing(), + EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName))); + + Bukkit.getOnlinePlayers().forEach(online -> { + EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); + onlineEntityPlayer.b.sendPacket(remove); + onlineEntityPlayer.b.sendPacket(add); + }); + updateOthers(player); + return new ActionResult<>(); + } +} diff --git a/v1_15_R1/v1_15_R1.iml b/v1_15_R1/v1_15_R1.iml new file mode 100644 index 0000000..facaaba --- /dev/null +++ b/v1_15_R1/v1_15_R1.iml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/v1_16_R1/pom.xml b/v1_16_R1/pom.xml new file mode 100644 index 0000000..180ca4e --- /dev/null +++ b/v1_16_R1/pom.xml @@ -0,0 +1,28 @@ + + + + nicko-parent + net.artelnatif + 1.0-SNAPSHOT + + 4.0.0 + + v1_16_R1 + 1.0-SNAPSHOT + + + + org.spigotmc + spigot + 1.17.1-R0.1-SNAPSHOT + provided + + + net.artelnatif + core + 1.0-SNAPSHOT + + + \ No newline at end of file diff --git a/v1_16_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java b/v1_16_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java new file mode 100644 index 0000000..6ca5cd1 --- /dev/null +++ b/v1_16_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java @@ -0,0 +1,101 @@ +package net.artelnatif.nicko.impl; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; +import net.artelnatif.nicko.disguise.ActionResult; +import net.artelnatif.nicko.disguise.NickoProfile; +import net.artelnatif.nicko.mojang.MojangSkin; +import net.minecraft.network.chat.IChatBaseComponent; +import net.minecraft.network.protocol.game.*; +import net.minecraft.network.syncher.DataWatcher; +import net.minecraft.network.syncher.DataWatcherObject; +import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.world.level.EnumGamemode; +import net.minecraft.world.level.World; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerTeleportEvent; + +public class v1_17_R1 implements Internals { + @Override + public void updateSelf(Player player) { + final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + final ResourceKey levelResourceKey = entityPlayer.getWorld().getDimensionKey(); + final CraftWorld world = entityPlayer.getWorld().getWorld(); + final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(), + levelResourceKey, world.getSeed(), + entityPlayer.c.getGamemode(), entityPlayer.d.c(), + false, + false, + false); + + final boolean wasFlying = player.isFlying(); + entityPlayer.b.sendPacket(respawn); + player.setFlying(wasFlying); + player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + player.updateInventory(); + } + + @Override + public void updateOthers(Player player) { + final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId()); + final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer); + + final DataWatcher dataWatcher = entityPlayer.getDataWatcher(); + final DataWatcherObject displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); + dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f); + final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true); + + Bukkit.getOnlinePlayers().forEach(online -> { + EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); + if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) { + onlineEntityPlayer.b.sendPacket(destroy); + onlineEntityPlayer.b.sendPacket(spawn); + } + onlineEntityPlayer.b.sendPacket(entityMetadata); + }); + } + + @Override + public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) { + final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName()); + final String profileName = profile.getName() == null ? player.getName() : profile.getName(); + + final CraftPlayer craftPlayer = (CraftPlayer) player; + final EntityPlayer entityPlayer = craftPlayer.getHandle(); + final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName); + + if (skinChange || changeOnlyName) { + final ActionResult skinFetch = fetchSkinTextures(profile, reset); + if (!skinFetch.isError()) { + final MojangSkin skin = skinFetch.getResult(); + final PropertyMap properties = gameProfile.getProperties(); + properties.removeAll("textures"); + properties.put("textures", new Property("textures", skin.value(), skin.signature())); + updateSelf(player); + } + } + + final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer); + final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a); + + add.b().clear(); + add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, + player.getPing(), + EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName))); + + Bukkit.getOnlinePlayers().forEach(online -> { + EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); + onlineEntityPlayer.b.sendPacket(remove); + onlineEntityPlayer.b.sendPacket(add); + }); + updateOthers(player); + return new ActionResult<>(); + } +} diff --git a/v1_16_R1/v1_16_R1.iml b/v1_16_R1/v1_16_R1.iml new file mode 100644 index 0000000..d400a46 --- /dev/null +++ b/v1_16_R1/v1_16_R1.iml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/v1_16_R2/pom.xml b/v1_16_R2/pom.xml new file mode 100644 index 0000000..4367324 --- /dev/null +++ b/v1_16_R2/pom.xml @@ -0,0 +1,28 @@ + + + + nicko-parent + net.artelnatif + 1.0-SNAPSHOT + + 4.0.0 + + v1_16_R2 + 1.0-SNAPSHOT + + + + org.spigotmc + spigot + 1.16.5-R0.1-SNAPSHOT + provided + + + net.artelnatif + core + 1.0-SNAPSHOT + + + \ No newline at end of file diff --git a/v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java b/v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java new file mode 100644 index 0000000..6ca5cd1 --- /dev/null +++ b/v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java @@ -0,0 +1,101 @@ +package net.artelnatif.nicko.impl; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; +import net.artelnatif.nicko.disguise.ActionResult; +import net.artelnatif.nicko.disguise.NickoProfile; +import net.artelnatif.nicko.mojang.MojangSkin; +import net.minecraft.network.chat.IChatBaseComponent; +import net.minecraft.network.protocol.game.*; +import net.minecraft.network.syncher.DataWatcher; +import net.minecraft.network.syncher.DataWatcherObject; +import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.world.level.EnumGamemode; +import net.minecraft.world.level.World; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerTeleportEvent; + +public class v1_17_R1 implements Internals { + @Override + public void updateSelf(Player player) { + final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + final ResourceKey levelResourceKey = entityPlayer.getWorld().getDimensionKey(); + final CraftWorld world = entityPlayer.getWorld().getWorld(); + final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(), + levelResourceKey, world.getSeed(), + entityPlayer.c.getGamemode(), entityPlayer.d.c(), + false, + false, + false); + + final boolean wasFlying = player.isFlying(); + entityPlayer.b.sendPacket(respawn); + player.setFlying(wasFlying); + player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + player.updateInventory(); + } + + @Override + public void updateOthers(Player player) { + final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId()); + final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer); + + final DataWatcher dataWatcher = entityPlayer.getDataWatcher(); + final DataWatcherObject displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); + dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f); + final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true); + + Bukkit.getOnlinePlayers().forEach(online -> { + EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); + if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) { + onlineEntityPlayer.b.sendPacket(destroy); + onlineEntityPlayer.b.sendPacket(spawn); + } + onlineEntityPlayer.b.sendPacket(entityMetadata); + }); + } + + @Override + public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) { + final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName()); + final String profileName = profile.getName() == null ? player.getName() : profile.getName(); + + final CraftPlayer craftPlayer = (CraftPlayer) player; + final EntityPlayer entityPlayer = craftPlayer.getHandle(); + final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName); + + if (skinChange || changeOnlyName) { + final ActionResult skinFetch = fetchSkinTextures(profile, reset); + if (!skinFetch.isError()) { + final MojangSkin skin = skinFetch.getResult(); + final PropertyMap properties = gameProfile.getProperties(); + properties.removeAll("textures"); + properties.put("textures", new Property("textures", skin.value(), skin.signature())); + updateSelf(player); + } + } + + final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer); + final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a); + + add.b().clear(); + add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, + player.getPing(), + EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName))); + + Bukkit.getOnlinePlayers().forEach(online -> { + EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); + onlineEntityPlayer.b.sendPacket(remove); + onlineEntityPlayer.b.sendPacket(add); + }); + updateOthers(player); + return new ActionResult<>(); + } +} diff --git a/v1_16_R2/v1_16_R2.iml b/v1_16_R2/v1_16_R2.iml new file mode 100644 index 0000000..57cc7d8 --- /dev/null +++ b/v1_16_R2/v1_16_R2.iml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/v1_16_R3/pom.xml b/v1_16_R3/pom.xml new file mode 100644 index 0000000..055dbe2 --- /dev/null +++ b/v1_16_R3/pom.xml @@ -0,0 +1,28 @@ + + + + nicko-parent + net.artelnatif + 1.0-SNAPSHOT + + 4.0.0 + + v1_16_R3 + 1.0-SNAPSHOT + + + + org.spigotmc + spigot + 1.16.5-R0.1-SNAPSHOT + provided + + + net.artelnatif + core + 1.0-SNAPSHOT + + + \ No newline at end of file diff --git a/v1_16_R3/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java b/v1_16_R3/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java new file mode 100644 index 0000000..6ca5cd1 --- /dev/null +++ b/v1_16_R3/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java @@ -0,0 +1,101 @@ +package net.artelnatif.nicko.impl; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; +import net.artelnatif.nicko.disguise.ActionResult; +import net.artelnatif.nicko.disguise.NickoProfile; +import net.artelnatif.nicko.mojang.MojangSkin; +import net.minecraft.network.chat.IChatBaseComponent; +import net.minecraft.network.protocol.game.*; +import net.minecraft.network.syncher.DataWatcher; +import net.minecraft.network.syncher.DataWatcherObject; +import net.minecraft.network.syncher.DataWatcherRegistry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.EntityPlayer; +import net.minecraft.world.level.EnumGamemode; +import net.minecraft.world.level.World; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerTeleportEvent; + +public class v1_17_R1 implements Internals { + @Override + public void updateSelf(Player player) { + final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + final ResourceKey levelResourceKey = entityPlayer.getWorld().getDimensionKey(); + final CraftWorld world = entityPlayer.getWorld().getWorld(); + final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(), + levelResourceKey, world.getSeed(), + entityPlayer.c.getGamemode(), entityPlayer.d.c(), + false, + false, + false); + + final boolean wasFlying = player.isFlying(); + entityPlayer.b.sendPacket(respawn); + player.setFlying(wasFlying); + player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + player.updateInventory(); + } + + @Override + public void updateOthers(Player player) { + final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); + final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId()); + final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer); + + final DataWatcher dataWatcher = entityPlayer.getDataWatcher(); + final DataWatcherObject displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); + dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f); + final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true); + + Bukkit.getOnlinePlayers().forEach(online -> { + EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); + if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) { + onlineEntityPlayer.b.sendPacket(destroy); + onlineEntityPlayer.b.sendPacket(spawn); + } + onlineEntityPlayer.b.sendPacket(entityMetadata); + }); + } + + @Override + public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) { + final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName()); + final String profileName = profile.getName() == null ? player.getName() : profile.getName(); + + final CraftPlayer craftPlayer = (CraftPlayer) player; + final EntityPlayer entityPlayer = craftPlayer.getHandle(); + final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName); + + if (skinChange || changeOnlyName) { + final ActionResult skinFetch = fetchSkinTextures(profile, reset); + if (!skinFetch.isError()) { + final MojangSkin skin = skinFetch.getResult(); + final PropertyMap properties = gameProfile.getProperties(); + properties.removeAll("textures"); + properties.put("textures", new Property("textures", skin.value(), skin.signature())); + updateSelf(player); + } + } + + final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer); + final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a); + + add.b().clear(); + add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, + player.getPing(), + EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName))); + + Bukkit.getOnlinePlayers().forEach(online -> { + EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); + onlineEntityPlayer.b.sendPacket(remove); + onlineEntityPlayer.b.sendPacket(add); + }); + updateOthers(player); + return new ActionResult<>(); + } +} diff --git a/v1_16_R3/v1_16_R3.iml b/v1_16_R3/v1_16_R3.iml new file mode 100644 index 0000000..57cc7d8 --- /dev/null +++ b/v1_16_R3/v1_16_R3.iml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/v1_19_R2/pom.xml b/v1_19_R2/pom.xml index 52dd10e..385efc4 100644 --- a/v1_19_R2/pom.xml +++ b/v1_19_R2/pom.xml @@ -13,6 +13,44 @@ v1_19_R2 1.0-SNAPSHOT + + + + net.md-5 + specialsource-maven-plugin + 1.2.4 + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-obf + + + + + + + org.spigotmc