diff --git a/dist/pom.xml b/dist/pom.xml
index 025fd4b..6049122 100644
--- a/dist/pom.xml
+++ b/dist/pom.xml
@@ -46,7 +46,16 @@
core
${project.parent.version}
-
net.artelnatif
v1_17_R1
diff --git a/pom.xml b/pom.xml
index 7310186..fa15b26 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,13 +13,13 @@
core
dist
-
v1_17_R1
v1_18_R1
v1_18_R2
diff --git a/v1_13_R1/pom.xml b/v1_13_R1/pom.xml
new file mode 100644
index 0000000..6aa987b
--- /dev/null
+++ b/v1_13_R1/pom.xml
@@ -0,0 +1,28 @@
+
+
+
+ nicko-parent
+ net.artelnatif
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ v1_13_R1
+ 1.0-SNAPSHOT
+
+
+
+ org.spigotmc
+ spigot
+ 1.13-R0.1-SNAPSHOT
+ provided
+
+
+ net.artelnatif
+ core
+ 1.0-SNAPSHOT
+
+
+
\ No newline at end of file
diff --git a/v1_13_R1/src/main/java/net/artelnatif/nicko/impl/v1_13_R1.java b/v1_13_R1/src/main/java/net/artelnatif/nicko/impl/v1_13_R1.java
new file mode 100644
index 0000000..659d147
--- /dev/null
+++ b/v1_13_R1/src/main/java/net/artelnatif/nicko/impl/v1_13_R1.java
@@ -0,0 +1,106 @@
+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.bukkit.NickoBukkit;
+import net.artelnatif.nicko.disguise.ActionResult;
+import net.artelnatif.nicko.disguise.NickoProfile;
+import net.artelnatif.nicko.mojang.MojangSkin;
+import net.minecraft.server.v1_13_R1.*;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerTeleportEvent;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+
+public class v1_13_R1 implements Internals {
+ @Override
+ public void updateSelf(Player player) {
+ final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
+ final WorldServer worldServer = entityPlayer.getWorldServer();
+ final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(worldServer.dimension,
+ worldServer.getDifficulty(),
+ worldServer.worldData.getType(),
+ entityPlayer.playerInteractManager.getGameMode());
+
+ final boolean wasFlying = player.isFlying();
+ entityPlayer.playerConnection.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.playerConnection.sendPacket(destroy);
+ onlineEntityPlayer.playerConnection.sendPacket(spawn);
+ }
+ onlineEntityPlayer.playerConnection.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.REMOVE_PLAYER, entityPlayer);
+ final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
+ final IChatBaseComponent name = new ChatComponentText(profileName);
+
+ final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
+ entityPlayer.ping,
+ EnumGamemode.getById(player.getGameMode().ordinal()), name);
+ final ArrayList list = new ArrayList<>();
+ list.add(data);
+ spoofPlayerInfoPacket(add, list);
+
+ Bukkit.getOnlinePlayers().forEach(online -> {
+ EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
+ onlineEntityPlayer.playerConnection.sendPacket(remove);
+ onlineEntityPlayer.playerConnection.sendPacket(add);
+ });
+ updateOthers(player);
+ return new ActionResult<>();
+ }
+
+ private void spoofPlayerInfoPacket(Object object, Object newValue) {
+ try {
+ final Field field = object.getClass().getDeclaredField("b");
+ field.setAccessible(true);
+ field.set(object, newValue);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")");
+ }
+ }
+}
diff --git a/v1_13_R2/pom.xml b/v1_13_R2/pom.xml
new file mode 100644
index 0000000..1e1606a
--- /dev/null
+++ b/v1_13_R2/pom.xml
@@ -0,0 +1,28 @@
+
+
+
+ nicko-parent
+ net.artelnatif
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ v1_13_R2
+ 1.0-SNAPSHOT
+
+
+
+ org.spigotmc
+ spigot
+ 1.13.2-R0.1-SNAPSHOT
+ provided
+
+
+ net.artelnatif
+ core
+ 1.0-SNAPSHOT
+
+
+
\ No newline at end of file
diff --git a/v1_13_R2/src/main/java/net/artelnatif/nicko/impl/v1_13_R2.java b/v1_13_R2/src/main/java/net/artelnatif/nicko/impl/v1_13_R2.java
new file mode 100644
index 0000000..735a8cd
--- /dev/null
+++ b/v1_13_R2/src/main/java/net/artelnatif/nicko/impl/v1_13_R2.java
@@ -0,0 +1,106 @@
+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.bukkit.NickoBukkit;
+import net.artelnatif.nicko.disguise.ActionResult;
+import net.artelnatif.nicko.disguise.NickoProfile;
+import net.artelnatif.nicko.mojang.MojangSkin;
+import net.minecraft.server.v1_13_R2.*;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerTeleportEvent;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+
+public class v1_13_R2 implements Internals {
+ @Override
+ public void updateSelf(Player player) {
+ final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
+ final WorldServer worldServer = entityPlayer.getWorldServer();
+ final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(worldServer.dimension,
+ worldServer.getDifficulty(),
+ worldServer.S(),
+ entityPlayer.playerInteractManager.getGameMode());
+
+ final boolean wasFlying = player.isFlying();
+ entityPlayer.playerConnection.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.playerConnection.sendPacket(destroy);
+ onlineEntityPlayer.playerConnection.sendPacket(spawn);
+ }
+ onlineEntityPlayer.playerConnection.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.REMOVE_PLAYER, entityPlayer);
+ final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
+ final IChatBaseComponent name = new ChatComponentText(profileName);
+
+ final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
+ entityPlayer.ping,
+ EnumGamemode.getById(player.getGameMode().ordinal()), name);
+ final ArrayList list = new ArrayList<>();
+ list.add(data);
+ spoofPlayerInfoPacket(add, list);
+
+ Bukkit.getOnlinePlayers().forEach(online -> {
+ EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
+ onlineEntityPlayer.playerConnection.sendPacket(remove);
+ onlineEntityPlayer.playerConnection.sendPacket(add);
+ });
+ updateOthers(player);
+ return new ActionResult<>();
+ }
+
+ private void spoofPlayerInfoPacket(Object object, Object newValue) {
+ try {
+ final Field field = object.getClass().getDeclaredField("b");
+ field.setAccessible(true);
+ field.set(object, newValue);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")");
+ }
+ }
+}
diff --git a/v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java b/v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_14_R1.java
similarity index 65%
rename from v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java
rename to v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_14_R1.java
index 6ca5cd1..09200d4 100644
--- a/v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java
+++ b/v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_14_R1.java
@@ -3,39 +3,29 @@ 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.bukkit.NickoBukkit;
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 net.minecraft.server.v1_14_R1.*;
import org.bukkit.Bukkit;
-import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
-import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
+import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
-public class v1_17_R1 implements Internals {
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+
+public class v1_14_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 PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorldServer().getWorldProvider().getDimensionManager(),
+ entityPlayer.getWorld().P(),
+ entityPlayer.playerInteractManager.getGameMode());
final boolean wasFlying = player.isFlying();
- entityPlayer.b.sendPacket(respawn);
+ entityPlayer.playerConnection.sendPacket(respawn);
player.setFlying(wasFlying);
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.updateInventory();
@@ -55,10 +45,10 @@ public class v1_17_R1 implements Internals {
Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
- onlineEntityPlayer.b.sendPacket(destroy);
- onlineEntityPlayer.b.sendPacket(spawn);
+ onlineEntityPlayer.playerConnection.sendPacket(destroy);
+ onlineEntityPlayer.playerConnection.sendPacket(spawn);
}
- onlineEntityPlayer.b.sendPacket(entityMetadata);
+ onlineEntityPlayer.playerConnection.sendPacket(entityMetadata);
});
}
@@ -82,20 +72,33 @@ public class v1_17_R1 implements Internals {
}
}
- final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer);
- final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
+ final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
+ final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
+ final IChatBaseComponent name = new ChatComponentText(profileName);
- add.b().clear();
- add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
- player.getPing(),
- EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
+ final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
+ entityPlayer.ping,
+ EnumGamemode.getById(player.getGameMode().ordinal()), name);
+ final ArrayList list = new ArrayList<>();
+ list.add(data);
+ spoofPlayerInfoPacket(add, list);
Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
- onlineEntityPlayer.b.sendPacket(remove);
- onlineEntityPlayer.b.sendPacket(add);
+ onlineEntityPlayer.playerConnection.sendPacket(remove);
+ onlineEntityPlayer.playerConnection.sendPacket(add);
});
updateOthers(player);
return new ActionResult<>();
}
+
+ private void spoofPlayerInfoPacket(Object object, Object newValue) {
+ try {
+ final Field field = object.getClass().getDeclaredField("b");
+ field.setAccessible(true);
+ field.set(object, newValue);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")");
+ }
+ }
}
diff --git a/v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_15_R1.java b/v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_15_R1.java
new file mode 100644
index 0000000..7324fde
--- /dev/null
+++ b/v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_15_R1.java
@@ -0,0 +1,107 @@
+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.bukkit.NickoBukkit;
+import net.artelnatif.nicko.disguise.ActionResult;
+import net.artelnatif.nicko.disguise.NickoProfile;
+import net.artelnatif.nicko.mojang.MojangSkin;
+import org.bukkit.Bukkit;
+import net.minecraft.server.v1_15_R1.*;
+import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
+import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerTeleportEvent;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+
+public class v1_15_R1 implements Internals {
+ @Override
+ public void updateSelf(Player player) {
+ final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
+ final CraftWorld world = entityPlayer.getWorld().getWorld();
+ final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorldServer().getWorldProvider().getDimensionManager(),
+ world.getSeed(),
+ entityPlayer.getWorld().P(),
+ entityPlayer.playerInteractManager.getGameMode());
+
+ final boolean wasFlying = player.isFlying();
+ entityPlayer.playerConnection.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.playerConnection.sendPacket(destroy);
+ onlineEntityPlayer.playerConnection.sendPacket(spawn);
+ }
+ onlineEntityPlayer.playerConnection.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.REMOVE_PLAYER, entityPlayer);
+ final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
+ final IChatBaseComponent name = new ChatComponentText(profileName);
+
+ final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
+ entityPlayer.ping,
+ EnumGamemode.getById(player.getGameMode().ordinal()), name);
+ final ArrayList list = new ArrayList<>();
+ list.add(data);
+ spoofPlayerInfoPacket(add, list);
+
+ Bukkit.getOnlinePlayers().forEach(online -> {
+ EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
+ onlineEntityPlayer.playerConnection.sendPacket(remove);
+ onlineEntityPlayer.playerConnection.sendPacket(add);
+ });
+ updateOthers(player);
+ return new ActionResult<>();
+ }
+
+ private void spoofPlayerInfoPacket(Object object, Object newValue) {
+ try {
+ final Field field = object.getClass().getDeclaredField("b");
+ field.setAccessible(true);
+ field.set(object, newValue);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")");
+ }
+ }
+}
diff --git a/v1_16_R1/pom.xml b/v1_16_R1/pom.xml
index 180ca4e..032d146 100644
--- a/v1_16_R1/pom.xml
+++ b/v1_16_R1/pom.xml
@@ -16,7 +16,7 @@
org.spigotmc
spigot
- 1.17.1-R0.1-SNAPSHOT
+ 1.16.1-R0.1-SNAPSHOT
provided
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_16_R1.java
similarity index 66%
rename from v1_16_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java
rename to v1_16_R1/src/main/java/net/artelnatif/nicko/impl/v1_16_R1.java
index 6ca5cd1..cdd44a7 100644
--- 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_16_R1.java
@@ -3,39 +3,35 @@ 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.bukkit.NickoBukkit;
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 net.minecraft.server.v1_16_R1.*;
+import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
+import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
-public class v1_17_R1 implements Internals {
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+
+public class v1_16_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(),
+ final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getTypeKey(),
levelResourceKey, world.getSeed(),
- entityPlayer.c.getGamemode(), entityPlayer.d.c(),
+ entityPlayer.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(),
false,
false,
false);
final boolean wasFlying = player.isFlying();
- entityPlayer.b.sendPacket(respawn);
+ entityPlayer.playerConnection.sendPacket(respawn);
player.setFlying(wasFlying);
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.updateInventory();
@@ -55,10 +51,10 @@ public class v1_17_R1 implements Internals {
Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
- onlineEntityPlayer.b.sendPacket(destroy);
- onlineEntityPlayer.b.sendPacket(spawn);
+ onlineEntityPlayer.playerConnection.sendPacket(destroy);
+ onlineEntityPlayer.playerConnection.sendPacket(spawn);
}
- onlineEntityPlayer.b.sendPacket(entityMetadata);
+ onlineEntityPlayer.playerConnection.sendPacket(entityMetadata);
});
}
@@ -82,20 +78,33 @@ public class v1_17_R1 implements Internals {
}
}
- final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer);
- final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
+ final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
+ final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
+ final IChatBaseComponent name = new ChatComponentText(profileName);
- add.b().clear();
- add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
- player.getPing(),
- EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
+ final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
+ entityPlayer.ping,
+ EnumGamemode.getById(player.getGameMode().ordinal()), name);
+ final ArrayList list = new ArrayList<>();
+ list.add(data);
+ spoofPlayerInfoPacket(add, list);
Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
- onlineEntityPlayer.b.sendPacket(remove);
- onlineEntityPlayer.b.sendPacket(add);
+ onlineEntityPlayer.playerConnection.sendPacket(remove);
+ onlineEntityPlayer.playerConnection.sendPacket(add);
});
updateOthers(player);
return new ActionResult<>();
}
+
+ private void spoofPlayerInfoPacket(Object object, Object newValue) {
+ try {
+ final Field field = object.getClass().getDeclaredField("b");
+ field.setAccessible(true);
+ field.set(object, newValue);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")");
+ }
+ }
}
diff --git a/v1_16_R2/pom.xml b/v1_16_R2/pom.xml
index 4367324..658413d 100644
--- a/v1_16_R2/pom.xml
+++ b/v1_16_R2/pom.xml
@@ -16,7 +16,7 @@
org.spigotmc
spigot
- 1.16.5-R0.1-SNAPSHOT
+ 1.16.3-R0.1-SNAPSHOT
provided
diff --git a/v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java b/v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_16_R2.java
similarity index 67%
rename from v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java
rename to v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_16_R2.java
index 6ca5cd1..f884eca 100644
--- a/v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java
+++ b/v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_16_R2.java
@@ -3,25 +3,21 @@ 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.bukkit.NickoBukkit;
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 net.minecraft.server.v1_16_R2.*;
import org.bukkit.Bukkit;
-import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
-import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
+import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
+import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
-public class v1_17_R1 implements Internals {
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+
+public class v1_16_R2 implements Internals {
@Override
public void updateSelf(Player player) {
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
@@ -29,13 +25,13 @@ public class v1_17_R1 implements Internals {
final CraftWorld world = entityPlayer.getWorld().getWorld();
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(),
levelResourceKey, world.getSeed(),
- entityPlayer.c.getGamemode(), entityPlayer.d.c(),
+ entityPlayer.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(),
false,
false,
false);
final boolean wasFlying = player.isFlying();
- entityPlayer.b.sendPacket(respawn);
+ entityPlayer.playerConnection.sendPacket(respawn);
player.setFlying(wasFlying);
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.updateInventory();
@@ -55,10 +51,10 @@ public class v1_17_R1 implements Internals {
Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
- onlineEntityPlayer.b.sendPacket(destroy);
- onlineEntityPlayer.b.sendPacket(spawn);
+ onlineEntityPlayer.playerConnection.sendPacket(destroy);
+ onlineEntityPlayer.playerConnection.sendPacket(spawn);
}
- onlineEntityPlayer.b.sendPacket(entityMetadata);
+ onlineEntityPlayer.playerConnection.sendPacket(entityMetadata);
});
}
@@ -82,20 +78,33 @@ public class v1_17_R1 implements Internals {
}
}
- final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer);
- final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
+ final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
+ final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
+ final IChatBaseComponent name = new ChatComponentText(profileName);
- add.b().clear();
- add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
- player.getPing(),
- EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
+ final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
+ entityPlayer.ping,
+ EnumGamemode.getById(player.getGameMode().ordinal()), name);
+ final ArrayList list = new ArrayList<>();
+ list.add(data);
+ spoofPlayerInfoPacket(add, list);
Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
- onlineEntityPlayer.b.sendPacket(remove);
- onlineEntityPlayer.b.sendPacket(add);
+ onlineEntityPlayer.playerConnection.sendPacket(remove);
+ onlineEntityPlayer.playerConnection.sendPacket(add);
});
updateOthers(player);
return new ActionResult<>();
}
+
+ private void spoofPlayerInfoPacket(Object object, Object newValue) {
+ try {
+ final Field field = object.getClass().getDeclaredField("b");
+ field.setAccessible(true);
+ field.set(object, newValue);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")");
+ }
+ }
}
diff --git a/v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java b/v1_16_R3/src/main/java/net/artelnatif/nicko/impl/v1_16_R3.java
similarity index 66%
rename from v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java
rename to v1_16_R3/src/main/java/net/artelnatif/nicko/impl/v1_16_R3.java
index 6ca5cd1..b1e203e 100644
--- a/v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java
+++ b/v1_16_R3/src/main/java/net/artelnatif/nicko/impl/v1_16_R3.java
@@ -3,25 +3,21 @@ 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.bukkit.NickoBukkit;
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 net.minecraft.server.v1_16_R3.*;
import org.bukkit.Bukkit;
-import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
-import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
+import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
+import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
-public class v1_17_R1 implements Internals {
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+
+public class v1_16_R3 implements Internals {
@Override
public void updateSelf(Player player) {
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
@@ -29,13 +25,13 @@ public class v1_17_R1 implements Internals {
final CraftWorld world = entityPlayer.getWorld().getWorld();
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(),
levelResourceKey, world.getSeed(),
- entityPlayer.c.getGamemode(), entityPlayer.d.c(),
+ entityPlayer.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(),
false,
false,
false);
final boolean wasFlying = player.isFlying();
- entityPlayer.b.sendPacket(respawn);
+ entityPlayer.playerConnection.sendPacket(respawn);
player.setFlying(wasFlying);
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.updateInventory();
@@ -55,10 +51,10 @@ public class v1_17_R1 implements Internals {
Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
- onlineEntityPlayer.b.sendPacket(destroy);
- onlineEntityPlayer.b.sendPacket(spawn);
+ onlineEntityPlayer.playerConnection.sendPacket(destroy);
+ onlineEntityPlayer.playerConnection.sendPacket(spawn);
}
- onlineEntityPlayer.b.sendPacket(entityMetadata);
+ onlineEntityPlayer.playerConnection.sendPacket(entityMetadata);
});
}
@@ -82,20 +78,34 @@ public class v1_17_R1 implements Internals {
}
}
- final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer);
- final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
+ final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
+ final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
+ final IChatBaseComponent name = new ChatComponentText(profileName);
- add.b().clear();
- add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
+ // what the fuck? didn't even KNOW instantiating a new class from an existing object was possible in java
+ final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
player.getPing(),
- EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
+ EnumGamemode.getById(player.getGameMode().ordinal()), name);
+ final ArrayList list = new ArrayList<>();
+ list.add(data);
+ spoofPlayerInfoPacket(add, list);
Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
- onlineEntityPlayer.b.sendPacket(remove);
- onlineEntityPlayer.b.sendPacket(add);
+ onlineEntityPlayer.playerConnection.sendPacket(remove);
+ onlineEntityPlayer.playerConnection.sendPacket(add);
});
updateOthers(player);
return new ActionResult<>();
}
+
+ private void spoofPlayerInfoPacket(Object object, Object newValue) {
+ try {
+ final Field field = object.getClass().getDeclaredField("b");
+ field.setAccessible(true);
+ field.set(object, newValue);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")");
+ }
+ }
}
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
deleted file mode 100644
index 6ca5cd1..0000000
--- a/v1_16_R3/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java
+++ /dev/null
@@ -1,101 +0,0 @@
-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<>();
- }
-}