feat: 1.13 - 1.16.5 support
This commit is contained in:
parent
acef7e2f55
commit
dae78564c1
14 changed files with 527 additions and 214 deletions
12
dist/pom.xml
vendored
12
dist/pom.xml
vendored
|
@ -46,7 +46,16 @@
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
<dependency>
|
||||||
|
<groupId>net.artelnatif</groupId>
|
||||||
|
<artifactId>v1_13_R1</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.artelnatif</groupId>
|
||||||
|
<artifactId>v1_13_R2</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.artelnatif</groupId>
|
<groupId>net.artelnatif</groupId>
|
||||||
<artifactId>v1_14_R1</artifactId>
|
<artifactId>v1_14_R1</artifactId>
|
||||||
|
@ -72,7 +81,6 @@
|
||||||
<artifactId>v1_16_R3</artifactId>
|
<artifactId>v1_16_R3</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.artelnatif</groupId>
|
<groupId>net.artelnatif</groupId>
|
||||||
<artifactId>v1_17_R1</artifactId>
|
<artifactId>v1_17_R1</artifactId>
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -13,13 +13,13 @@
|
||||||
<modules>
|
<modules>
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
<module>dist</module>
|
<module>dist</module>
|
||||||
<!--
|
<module>v1_13_R1</module>
|
||||||
|
<module>v1_13_R2</module>
|
||||||
<module>v1_14_R1</module>
|
<module>v1_14_R1</module>
|
||||||
<module>v1_15_R1</module>
|
<module>v1_15_R1</module>
|
||||||
<module>v1_16_R1</module>
|
<module>v1_16_R1</module>
|
||||||
<module>v1_16_R2</module>
|
<module>v1_16_R2</module>
|
||||||
<module>v1_16_R3</module>
|
<module>v1_16_R3</module>
|
||||||
-->
|
|
||||||
<module>v1_17_R1</module>
|
<module>v1_17_R1</module>
|
||||||
<module>v1_18_R1</module>
|
<module>v1_18_R1</module>
|
||||||
<module>v1_18_R2</module>
|
<module>v1_18_R2</module>
|
||||||
|
|
28
v1_13_R1/pom.xml
Normal file
28
v1_13_R1/pom.xml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>nicko-parent</artifactId>
|
||||||
|
<groupId>net.artelnatif</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>v1_13_R1</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot</artifactId>
|
||||||
|
<version>1.13-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.artelnatif</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
106
v1_13_R1/src/main/java/net/artelnatif/nicko/impl/v1_13_R1.java
Normal file
106
v1_13_R1/src/main/java/net/artelnatif/nicko/impl/v1_13_R1.java
Normal file
|
@ -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<Byte> 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<Void> 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<MojangSkin> 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<PacketPlayOutPlayerInfo.PlayerInfoData> 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() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
v1_13_R2/pom.xml
Normal file
28
v1_13_R2/pom.xml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>nicko-parent</artifactId>
|
||||||
|
<groupId>net.artelnatif</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>v1_13_R2</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot</artifactId>
|
||||||
|
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.artelnatif</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
106
v1_13_R2/src/main/java/net/artelnatif/nicko/impl/v1_13_R2.java
Normal file
106
v1_13_R2/src/main/java/net/artelnatif/nicko/impl/v1_13_R2.java
Normal file
|
@ -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<Byte> 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<Void> 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<MojangSkin> 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<PacketPlayOutPlayerInfo.PlayerInfoData> 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() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,39 +3,29 @@ package net.artelnatif.nicko.impl;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
|
import net.artelnatif.nicko.bukkit.NickoBukkit;
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
import net.artelnatif.nicko.disguise.ActionResult;
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
import net.artelnatif.nicko.disguise.NickoProfile;
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
import net.artelnatif.nicko.mojang.MojangSkin;
|
||||||
import net.minecraft.network.chat.IChatBaseComponent;
|
import net.minecraft.server.v1_14_R1.*;
|
||||||
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.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
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
|
@Override
|
||||||
public void updateSelf(Player player) {
|
public void updateSelf(Player player) {
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||||
final ResourceKey<World> levelResourceKey = entityPlayer.getWorld().getDimensionKey();
|
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorldServer().getWorldProvider().getDimensionManager(),
|
||||||
final CraftWorld world = entityPlayer.getWorld().getWorld();
|
entityPlayer.getWorld().P(),
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(),
|
entityPlayer.playerInteractManager.getGameMode());
|
||||||
levelResourceKey, world.getSeed(),
|
|
||||||
entityPlayer.c.getGamemode(), entityPlayer.d.c(),
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false);
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
final boolean wasFlying = player.isFlying();
|
||||||
entityPlayer.b.sendPacket(respawn);
|
entityPlayer.playerConnection.sendPacket(respawn);
|
||||||
player.setFlying(wasFlying);
|
player.setFlying(wasFlying);
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
@ -55,10 +45,10 @@ public class v1_17_R1 implements Internals {
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
||||||
onlineEntityPlayer.b.sendPacket(destroy);
|
onlineEntityPlayer.playerConnection.sendPacket(destroy);
|
||||||
onlineEntityPlayer.b.sendPacket(spawn);
|
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 remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
|
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
||||||
|
final IChatBaseComponent name = new ChatComponentText(profileName);
|
||||||
|
|
||||||
add.b().clear();
|
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
|
||||||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
entityPlayer.ping,
|
||||||
player.getPing(),
|
EnumGamemode.getById(player.getGameMode().ordinal()), name);
|
||||||
EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
|
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>();
|
||||||
|
list.add(data);
|
||||||
|
spoofPlayerInfoPacket(add, list);
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||||
onlineEntityPlayer.b.sendPacket(remove);
|
onlineEntityPlayer.playerConnection.sendPacket(remove);
|
||||||
onlineEntityPlayer.b.sendPacket(add);
|
onlineEntityPlayer.playerConnection.sendPacket(add);
|
||||||
});
|
});
|
||||||
updateOthers(player);
|
updateOthers(player);
|
||||||
return new ActionResult<>();
|
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() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
107
v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_15_R1.java
Normal file
107
v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_15_R1.java
Normal file
|
@ -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<Byte> 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<Void> 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<MojangSkin> 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<PacketPlayOutPlayerInfo.PlayerInfoData> 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() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -3,39 +3,35 @@ package net.artelnatif.nicko.impl;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
|
import net.artelnatif.nicko.bukkit.NickoBukkit;
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
import net.artelnatif.nicko.disguise.ActionResult;
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
import net.artelnatif.nicko.disguise.NickoProfile;
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
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.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
import net.minecraft.server.v1_16_R1.*;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
|
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.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
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
|
@Override
|
||||||
public void updateSelf(Player player) {
|
public void updateSelf(Player player) {
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||||
final ResourceKey<World> levelResourceKey = entityPlayer.getWorld().getDimensionKey();
|
final ResourceKey<World> levelResourceKey = entityPlayer.getWorld().getDimensionKey();
|
||||||
final CraftWorld world = entityPlayer.getWorld().getWorld();
|
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(),
|
levelResourceKey, world.getSeed(),
|
||||||
entityPlayer.c.getGamemode(), entityPlayer.d.c(),
|
entityPlayer.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
final boolean wasFlying = player.isFlying();
|
||||||
entityPlayer.b.sendPacket(respawn);
|
entityPlayer.playerConnection.sendPacket(respawn);
|
||||||
player.setFlying(wasFlying);
|
player.setFlying(wasFlying);
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
@ -55,10 +51,10 @@ public class v1_17_R1 implements Internals {
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
||||||
onlineEntityPlayer.b.sendPacket(destroy);
|
onlineEntityPlayer.playerConnection.sendPacket(destroy);
|
||||||
onlineEntityPlayer.b.sendPacket(spawn);
|
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 remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
|
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
||||||
|
final IChatBaseComponent name = new ChatComponentText(profileName);
|
||||||
|
|
||||||
add.b().clear();
|
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
|
||||||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
entityPlayer.ping,
|
||||||
player.getPing(),
|
EnumGamemode.getById(player.getGameMode().ordinal()), name);
|
||||||
EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
|
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>();
|
||||||
|
list.add(data);
|
||||||
|
spoofPlayerInfoPacket(add, list);
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||||
onlineEntityPlayer.b.sendPacket(remove);
|
onlineEntityPlayer.playerConnection.sendPacket(remove);
|
||||||
onlineEntityPlayer.b.sendPacket(add);
|
onlineEntityPlayer.playerConnection.sendPacket(add);
|
||||||
});
|
});
|
||||||
updateOthers(player);
|
updateOthers(player);
|
||||||
return new ActionResult<>();
|
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() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
<version>1.16.3-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -3,25 +3,21 @@ package net.artelnatif.nicko.impl;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
|
import net.artelnatif.nicko.bukkit.NickoBukkit;
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
import net.artelnatif.nicko.disguise.ActionResult;
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
import net.artelnatif.nicko.disguise.NickoProfile;
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
import net.artelnatif.nicko.mojang.MojangSkin;
|
||||||
import net.minecraft.network.chat.IChatBaseComponent;
|
import net.minecraft.server.v1_16_R2.*;
|
||||||
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.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
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
|
@Override
|
||||||
public void updateSelf(Player player) {
|
public void updateSelf(Player player) {
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
@ -29,13 +25,13 @@ public class v1_17_R1 implements Internals {
|
||||||
final CraftWorld world = entityPlayer.getWorld().getWorld();
|
final CraftWorld world = entityPlayer.getWorld().getWorld();
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(),
|
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(),
|
||||||
levelResourceKey, world.getSeed(),
|
levelResourceKey, world.getSeed(),
|
||||||
entityPlayer.c.getGamemode(), entityPlayer.d.c(),
|
entityPlayer.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
final boolean wasFlying = player.isFlying();
|
||||||
entityPlayer.b.sendPacket(respawn);
|
entityPlayer.playerConnection.sendPacket(respawn);
|
||||||
player.setFlying(wasFlying);
|
player.setFlying(wasFlying);
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
@ -55,10 +51,10 @@ public class v1_17_R1 implements Internals {
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
||||||
onlineEntityPlayer.b.sendPacket(destroy);
|
onlineEntityPlayer.playerConnection.sendPacket(destroy);
|
||||||
onlineEntityPlayer.b.sendPacket(spawn);
|
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 remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
|
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
||||||
|
final IChatBaseComponent name = new ChatComponentText(profileName);
|
||||||
|
|
||||||
add.b().clear();
|
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
|
||||||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
entityPlayer.ping,
|
||||||
player.getPing(),
|
EnumGamemode.getById(player.getGameMode().ordinal()), name);
|
||||||
EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
|
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>();
|
||||||
|
list.add(data);
|
||||||
|
spoofPlayerInfoPacket(add, list);
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||||
onlineEntityPlayer.b.sendPacket(remove);
|
onlineEntityPlayer.playerConnection.sendPacket(remove);
|
||||||
onlineEntityPlayer.b.sendPacket(add);
|
onlineEntityPlayer.playerConnection.sendPacket(add);
|
||||||
});
|
});
|
||||||
updateOthers(player);
|
updateOthers(player);
|
||||||
return new ActionResult<>();
|
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() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -3,25 +3,21 @@ package net.artelnatif.nicko.impl;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
|
import net.artelnatif.nicko.bukkit.NickoBukkit;
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
import net.artelnatif.nicko.disguise.ActionResult;
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
import net.artelnatif.nicko.disguise.NickoProfile;
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
import net.artelnatif.nicko.mojang.MojangSkin;
|
||||||
import net.minecraft.network.chat.IChatBaseComponent;
|
import net.minecraft.server.v1_16_R3.*;
|
||||||
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.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
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
|
@Override
|
||||||
public void updateSelf(Player player) {
|
public void updateSelf(Player player) {
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
@ -29,13 +25,13 @@ public class v1_17_R1 implements Internals {
|
||||||
final CraftWorld world = entityPlayer.getWorld().getWorld();
|
final CraftWorld world = entityPlayer.getWorld().getWorld();
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(),
|
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(),
|
||||||
levelResourceKey, world.getSeed(),
|
levelResourceKey, world.getSeed(),
|
||||||
entityPlayer.c.getGamemode(), entityPlayer.d.c(),
|
entityPlayer.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
final boolean wasFlying = player.isFlying();
|
||||||
entityPlayer.b.sendPacket(respawn);
|
entityPlayer.playerConnection.sendPacket(respawn);
|
||||||
player.setFlying(wasFlying);
|
player.setFlying(wasFlying);
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
@ -55,10 +51,10 @@ public class v1_17_R1 implements Internals {
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
||||||
onlineEntityPlayer.b.sendPacket(destroy);
|
onlineEntityPlayer.playerConnection.sendPacket(destroy);
|
||||||
onlineEntityPlayer.b.sendPacket(spawn);
|
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 remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
|
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
||||||
|
final IChatBaseComponent name = new ChatComponentText(profileName);
|
||||||
|
|
||||||
add.b().clear();
|
// what the fuck? didn't even KNOW instantiating a new class from an existing object was possible in java
|
||||||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
|
||||||
player.getPing(),
|
player.getPing(),
|
||||||
EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
|
EnumGamemode.getById(player.getGameMode().ordinal()), name);
|
||||||
|
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>();
|
||||||
|
list.add(data);
|
||||||
|
spoofPlayerInfoPacket(add, list);
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||||
onlineEntityPlayer.b.sendPacket(remove);
|
onlineEntityPlayer.playerConnection.sendPacket(remove);
|
||||||
onlineEntityPlayer.b.sendPacket(add);
|
onlineEntityPlayer.playerConnection.sendPacket(add);
|
||||||
});
|
});
|
||||||
updateOthers(player);
|
updateOthers(player);
|
||||||
return new ActionResult<>();
|
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() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -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<World> 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<Byte> 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<Void> 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<MojangSkin> 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<>();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue