diff --git a/core/pom.xml b/core/pom.xml index 6c98136..602d6b4 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -18,6 +18,10 @@ + + dmulloy2-repo + https://repo.dmulloy2.net/repository/public/ + papermc https://repo.papermc.io/repository/maven-public/ @@ -37,6 +41,12 @@ + + com.comphenix.protocol + ProtocolLib + 5.0.0-SNAPSHOT + provided + me.clip @@ -92,12 +102,12 @@ com.fasterxml.jackson.core jackson-core - 2.14.2 + 2.13.3 com.fasterxml.jackson.dataformat jackson-dataformat-yaml - 2.14.2 + 2.13.3 diff --git a/core/src/main/java/net/artelnatif/nicko/NickoBukkit.java b/core/src/main/java/net/artelnatif/nicko/NickoBukkit.java index b5cc0ec..fc8e1bf 100644 --- a/core/src/main/java/net/artelnatif/nicko/NickoBukkit.java +++ b/core/src/main/java/net/artelnatif/nicko/NickoBukkit.java @@ -1,19 +1,16 @@ package net.artelnatif.nicko; -import net.artelnatif.nicko.gui.items.common.OptionUnavailable; -import xyz.xenondevs.invui.gui.structure.Structure; -import xyz.xenondevs.invui.item.builder.ItemBuilder; -import xyz.xenondevs.invui.item.impl.SimpleItem; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.ProtocolManager; import net.artelnatif.nicko.command.NickoCommand; import net.artelnatif.nicko.config.Configuration; import net.artelnatif.nicko.config.ConfigurationManager; import net.artelnatif.nicko.event.PlayerJoinListener; import net.artelnatif.nicko.event.PlayerQuitListener; +import net.artelnatif.nicko.gui.items.common.OptionUnavailable; import net.artelnatif.nicko.gui.items.main.ExitGUI; import net.artelnatif.nicko.i18n.Locale; import net.artelnatif.nicko.i18n.LocaleFileManager; -import net.artelnatif.nicko.impl.Internals; -import net.artelnatif.nicko.impl.InternalsProvider; import net.artelnatif.nicko.mojang.MojangAPI; import net.artelnatif.nicko.placeholder.PlaceHolderHook; import net.artelnatif.nicko.storage.PlayerDataStore; @@ -24,6 +21,9 @@ import org.bukkit.command.PluginCommand; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPluginLoader; +import xyz.xenondevs.invui.gui.structure.Structure; +import xyz.xenondevs.invui.item.builder.ItemBuilder; +import xyz.xenondevs.invui.item.impl.SimpleItem; import java.io.File; import java.io.IOException; @@ -39,6 +39,7 @@ public class NickoBukkit extends JavaPlugin { private Configuration configuration; private LocaleFileManager localeFileManager; private PlayerNameStore nameStore; + private ProtocolManager protocolManager; public NickoBukkit() { this.unitTesting = false; } @@ -65,6 +66,7 @@ public class NickoBukkit extends JavaPlugin { configurationManager = new ConfigurationManager(getDataFolder()); configurationManager.saveDefaultConfig(); + protocolManager = ProtocolLibrary.getProtocolManager(); mojangAPI = new MojangAPI(); dataStore = new PlayerDataStore(mojangAPI, getNickoConfig()); nameStore = new PlayerNameStore(); @@ -78,14 +80,6 @@ public class NickoBukkit extends JavaPlugin { } if (!unitTesting) { - getLogger().info("Loading internals..."); - if (getInternals() == null) { - getLogger().severe("Nicko could not find a valid implementation for this server version. Is your server supported?"); - dataStore.getStorage().setError(true); - getServer().getPluginManager().disablePlugin(this); - } - - localeFileManager = new LocaleFileManager(); if (configuration.isCustomLocale()) { if (localeFileManager.dumpFromLocale(Locale.ENGLISH)) { @@ -161,7 +155,5 @@ public class NickoBukkit extends JavaPlugin { return localeFileManager; } - public Internals getInternals() { - return InternalsProvider.getInternals(); - } + public ProtocolManager getProtocolManager() { return protocolManager; } } diff --git a/core/src/main/java/net/artelnatif/nicko/appearance/AppearanceManager.java b/core/src/main/java/net/artelnatif/nicko/appearance/AppearanceManager.java index 3120f39..7ce4a3b 100644 --- a/core/src/main/java/net/artelnatif/nicko/appearance/AppearanceManager.java +++ b/core/src/main/java/net/artelnatif/nicko/appearance/AppearanceManager.java @@ -1,14 +1,27 @@ package net.artelnatif.nicko.appearance; +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.*; +import com.google.common.collect.Multimap; import net.artelnatif.nicko.NickoBukkit; import net.artelnatif.nicko.disguise.ActionResult; import net.artelnatif.nicko.disguise.NickoProfile; +import net.artelnatif.nicko.i18n.I18NDict; +import net.artelnatif.nicko.mojang.MojangAPI; +import net.artelnatif.nicko.mojang.MojangSkin; import net.artelnatif.nicko.storage.PlayerDataStore; import net.artelnatif.nicko.storage.name.PlayerNameStore; import org.bukkit.Bukkit; +import org.bukkit.World; import org.bukkit.entity.Player; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import java.util.Set; import java.util.UUID; +import java.util.concurrent.ExecutionException; public class AppearanceManager { private final NickoProfile profile; @@ -80,10 +93,93 @@ public class AppearanceManager { } public ActionResult resetPlayer() { - return NickoBukkit.getInstance().getInternals().updateProfile(player, profile, true, true); + // TODO: 4/3/23 Reset player + return new ActionResult<>(); } public ActionResult updatePlayer(boolean skinChange) { - return NickoBukkit.getInstance().getInternals().updateProfile(player, profile, skinChange, false); + final String displayName = profile.getName() == null ? player.getName() : profile.getName(); + final WrappedGameProfile gameProfile = new WrappedGameProfile(player.getUniqueId(), displayName); + + final ActionResult result = updateGameProfileSkin(gameProfile, skinChange); + if (!result.isError()) { + updateTabList(gameProfile, displayName); + } + return new ActionResult<>(); + } + + private ActionResult updateGameProfileSkin(WrappedGameProfile gameProfile, boolean skinChange) { + final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName()); + + if (skinChange || changeOnlyName) { + Optional skin; + try { + final MojangAPI mojang = NickoBukkit.getInstance().getMojangAPI(); + final Optional uuid = mojang.getUUID(profile.getSkin()); + if (uuid.isPresent()) { + skin = mojang.getSkin(uuid.get()); + if (skin.isPresent()) { + final MojangSkin skinResult = skin.get(); + final Multimap properties = gameProfile.getProperties(); + properties.removeAll("textures"); + properties.put("textures", new WrappedSignedProperty("textures", skinResult.getValue(), skinResult.getSignature())); + Bukkit.broadcastMessage("Modified properties"); + } + } + Bukkit.broadcastMessage("Respawning player"); + respawnPlayer(); + return new ActionResult<>(); + } catch (ExecutionException e) { + return new ActionResult<>(I18NDict.Error.SKIN_FAIL_CACHE); + } catch (IOException e) { + return new ActionResult<>(I18NDict.Error.NAME_FAIL_MOJANG); + } + } + return new ActionResult<>(); + } + + private void respawnPlayer() { + final PacketContainer respawnOtherWorld = getRespawnPacket(Bukkit.getWorld("world_the_end")); + final PacketContainer respawn = getRespawnPacket(player.getWorld()); + instance.getProtocolManager().sendServerPacket(player, respawnOtherWorld); + instance.getProtocolManager().sendServerPacket(player, respawn); + } + + private PacketContainer getRespawnPacket(World world) { + final PacketContainer packet = new PacketContainer(PacketType.Play.Server.RESPAWN); + final EnumWrappers.NativeGameMode gamemode = EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()); + packet.getWorldKeys().write(0, world); + packet.getLongs().write(0, world.getSeed()); + + packet.getGameModes().write(0, gamemode); // gamemode + packet.getGameModes().write(1, gamemode); // previous gamemode + + packet.getBooleans().write(0, false); + packet.getBooleans().write(1, false); + return packet; + } + + private void updateTabList(WrappedGameProfile gameProfile, String displayName) { + final PacketContainer infoAdd = new PacketContainer(PacketType.Play.Server.PLAYER_INFO); + infoAdd.getPlayerInfoActions().write(0, Set.of( + EnumWrappers.PlayerInfoAction.ADD_PLAYER, + EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE, + EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME, + EnumWrappers.PlayerInfoAction.UPDATE_LISTED, + EnumWrappers.PlayerInfoAction.UPDATE_LATENCY + )); + + infoAdd.getPlayerInfoDataLists().write(1, List.of(new PlayerInfoData( + gameProfile, + 0, + EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()), + WrappedChatComponent.fromText(displayName) + ))); + + final PacketContainer infoRemove = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE); + infoRemove.getUUIDLists().write(0, List.of(player.getUniqueId())); + + instance.getProtocolManager().broadcastServerPacket(infoRemove); + instance.getProtocolManager().broadcastServerPacket(infoAdd); } } diff --git a/core/src/main/java/net/artelnatif/nicko/event/PlayerJoinListener.java b/core/src/main/java/net/artelnatif/nicko/event/PlayerJoinListener.java index 2afa2c3..fc1a3c4 100644 --- a/core/src/main/java/net/artelnatif/nicko/event/PlayerJoinListener.java +++ b/core/src/main/java/net/artelnatif/nicko/event/PlayerJoinListener.java @@ -34,7 +34,7 @@ public class PlayerJoinListener implements Listener { if (!actionResult.isError()) { player.sendMessage(I18N.translate(player, I18NDict.Event.PreviousSkin.SUCCESS)); } else { - player.sendMessage(I18N.translate(player, I18NDict.Event.PreviousSkin.FAIL, I18N.translate(player, actionResult.getErrorMessage()))); + player.sendMessage(I18N.translate(player, I18NDict.Event.PreviousSkin.FAIL, I18N.translateWithoutPrefix(player, actionResult.getErrorMessage()))); } } }, 20L); diff --git a/core/src/main/java/net/artelnatif/nicko/impl/Internals.java b/core/src/main/java/net/artelnatif/nicko/impl/Internals.java deleted file mode 100644 index 0c68318..0000000 --- a/core/src/main/java/net/artelnatif/nicko/impl/Internals.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.artelnatif.nicko.impl; - -import net.artelnatif.nicko.NickoBukkit; -import net.artelnatif.nicko.disguise.NickoProfile; -import net.artelnatif.nicko.disguise.ActionResult; -import net.artelnatif.nicko.i18n.I18NDict; -import net.artelnatif.nicko.mojang.MojangAPI; -import net.artelnatif.nicko.mojang.MojangSkin; -import org.bukkit.entity.Player; - -import java.io.IOException; -import java.util.Optional; -import java.util.concurrent.ExecutionException; - -public interface Internals { - void updateSelf(Player player); - - void updateOthers(Player player); - - ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset); - - default ActionResult fetchSkinTextures(NickoProfile profile, boolean reset) { - Optional skin; - try { - final MojangAPI mojang = NickoBukkit.getInstance().getMojangAPI(); - final Optional uuid = mojang.getUUID(profile.getSkin()); - if (uuid.isPresent()) { - skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get())); - return skin.map(ActionResult::new).orElseGet(() -> new ActionResult<>(I18NDict.Error.SKIN_FAIL_MOJANG)); - } - return new ActionResult<>(I18NDict.Error.NAME_FAIL_MOJANG); - } catch (ExecutionException e) { - return new ActionResult<>(I18NDict.Error.SKIN_FAIL_CACHE); - } catch (IOException e) { - return new ActionResult<>(I18NDict.Error.NAME_FAIL_MOJANG); - } - } -} diff --git a/core/src/main/java/net/artelnatif/nicko/impl/InternalsProvider.java b/core/src/main/java/net/artelnatif/nicko/impl/InternalsProvider.java deleted file mode 100644 index d0ebd0d..0000000 --- a/core/src/main/java/net/artelnatif/nicko/impl/InternalsProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.artelnatif.nicko.impl; - -import org.bukkit.Bukkit; - -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Logger; - -public class InternalsProvider { - private static final Logger logger = Logger.getLogger("Internals"); - private static Internals internals; - - static { - try { - final String packageName = Internals.class.getPackage().getName(); - final String bukkitVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; - final String fullClassName = packageName + "." + bukkitVersion; - final Class clazz = Class.forName(fullClassName); - internals = (Internals) clazz.getConstructors()[0].newInstance(); - logger.info("Loaded support for " + bukkitVersion); - } catch (InvocationTargetException | ClassNotFoundException | InstantiationException | IllegalAccessException | - ClassCastException exception) { - internals = null; - } - } - - public static Internals getInternals() { - return internals; - } -} diff --git a/core/src/main/java/net/artelnatif/nicko/mojang/MojangAPI.java b/core/src/main/java/net/artelnatif/nicko/mojang/MojangAPI.java index d8b3bf2..7c1f852 100644 --- a/core/src/main/java/net/artelnatif/nicko/mojang/MojangAPI.java +++ b/core/src/main/java/net/artelnatif/nicko/mojang/MojangAPI.java @@ -25,7 +25,7 @@ public class MojangAPI { private final Logger logger = Logger.getLogger("MojangAPI"); - private final CacheLoader> loader = new CacheLoader>() { + private final CacheLoader> loader = new CacheLoader<>() { @Nonnull public Optional load(@Nonnull String uuid) throws Exception { return getSkinFromMojang(uuid); diff --git a/core/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml index 093c4b8..af81d31 100644 --- a/core/src/main/resources/plugin.yml +++ b/core/src/main/resources/plugin.yml @@ -1,9 +1,10 @@ name: Nicko main: net.artelnatif.nicko.NickoBukkit version: 1.0-SNAPSHOT -author: Aro +author: Ineanto api-version: 1.13 softdepend: [ PlaceholderAPI ] +depend: [ ProtocolLib ] commands: nicko: description: "Opens Nicko's GUI." diff --git a/pom.xml b/pom.xml index e9f92dc..c67c610 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ core dist - v1_13_R1 + - 11 - 11 + 17 + 17 \ No newline at end of file diff --git a/v1_13_R1/pom.xml b/v1_13_R1/pom.xml deleted file mode 100644 index 6aa987b..0000000 --- a/v1_13_R1/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - 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 deleted file mode 100644 index 013ddd4..0000000 --- a/v1_13_R1/src/main/java/net/artelnatif/nicko/impl/v1_13_R1.java +++ /dev/null @@ -1,128 +0,0 @@ -package net.artelnatif.nicko.impl; - -import com.google.common.collect.Lists; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import com.mojang.authlib.properties.PropertyMap; -import net.artelnatif.nicko.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.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; - -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.getValue(), skin.getSignature())); - 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 Object infoData = yes( - add, - gameProfile, - entityPlayer.ping, - EnumGamemode.getById(player.getGameMode().ordinal()), - name - ); - spoofPlayerInfoPacket(add, Lists.newArrayList(infoData)); - - 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() + ")"); - } - } - - public Object yes(PacketPlayOutPlayerInfo packet, GameProfile gameProfile, int ping, EnumGamemode gamemode, IChatBaseComponent name) { - try { - final Class clazz = Class.forName("net.minecraft.server.v1_13_R1.PacketPlayOutPlayerInfo$PlayerInfoData"); - final Constructor infoConstructor = clazz.getDeclaredConstructor( - PacketPlayOutPlayerInfo.class, - GameProfile.class, - int.class, - EnumGamemode.class, - IChatBaseComponent.class - ); - return infoConstructor.newInstance(packet, gameProfile, ping, gamemode, name); - } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InstantiationException | - IllegalAccessException e) { - NickoBukkit.getInstance().getLogger().warning("Unable to instantiate PlayerInfoData, that's bad! (" + e.getMessage() + ")"); - return null; - } - } -} diff --git a/v1_13_R2/pom.xml b/v1_13_R2/pom.xml deleted file mode 100644 index 1e1606a..0000000 --- a/v1_13_R2/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - 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 deleted file mode 100644 index ada42dc..0000000 --- a/v1_13_R2/src/main/java/net/artelnatif/nicko/impl/v1_13_R2.java +++ /dev/null @@ -1,128 +0,0 @@ -package net.artelnatif.nicko.impl; - -import com.google.common.collect.Lists; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import com.mojang.authlib.properties.PropertyMap; -import net.artelnatif.nicko.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.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; - -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.getValue(), skin.getSignature())); - 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 Object infoData = yes( - add, - gameProfile, - entityPlayer.ping, - EnumGamemode.getById(player.getGameMode().ordinal()), - name - ); - spoofPlayerInfoPacket(add, Lists.newArrayList(infoData)); - - 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() + ")"); - } - } - - public Object yes(PacketPlayOutPlayerInfo packet, GameProfile gameProfile, int ping, EnumGamemode gamemode, IChatBaseComponent name) { - try { - final Class clazz = Class.forName("net.minecraft.server.v1_13_R2.PacketPlayOutPlayerInfo$PlayerInfoData"); - final Constructor infoConstructor = clazz.getDeclaredConstructor( - PacketPlayOutPlayerInfo.class, - GameProfile.class, - int.class, - EnumGamemode.class, - IChatBaseComponent.class - ); - return infoConstructor.newInstance(packet, gameProfile, ping, gamemode, name); - } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InstantiationException | - IllegalAccessException e) { - NickoBukkit.getInstance().getLogger().warning("Unable to instantiate PlayerInfoData, that's bad! (" + e.getMessage() + ")"); - return null; - } - } -} diff --git a/v1_14_R1/pom.xml b/v1_14_R1/pom.xml deleted file mode 100644 index f69fa93..0000000 --- a/v1_14_R1/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - nicko-parent - net.artelnatif - 1.0-SNAPSHOT - - 4.0.0 - - v1_14_R1 - 1.0-SNAPSHOT - - - - org.spigotmc - spigot - 1.14.4-R0.1-SNAPSHOT - provided - - - net.artelnatif - core - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_14_R1.java b/v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_14_R1.java deleted file mode 100644 index 8cb1887..0000000 --- a/v1_14_R1/src/main/java/net/artelnatif/nicko/impl/v1_14_R1.java +++ /dev/null @@ -1,126 +0,0 @@ -package net.artelnatif.nicko.impl; - -import com.google.common.collect.Lists; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import com.mojang.authlib.properties.PropertyMap; -import net.artelnatif.nicko.NickoBukkit; -import net.artelnatif.nicko.disguise.ActionResult; -import net.artelnatif.nicko.disguise.NickoProfile; -import net.artelnatif.nicko.mojang.MojangSkin; -import net.minecraft.server.v1_14_R1.*; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; - -public class v1_14_R1 implements Internals { - @Override - public void updateSelf(Player player) { - final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorldServer().getWorldProvider().getDimensionManager(), - 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.getValue(), skin.getSignature())); - 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 Object infoData = yes( - add, - gameProfile, - entityPlayer.ping, - EnumGamemode.getById(player.getGameMode().ordinal()), - name - ); - spoofPlayerInfoPacket(add, Lists.newArrayList(infoData)); - - 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() + ")"); - } - } - - public Object yes(PacketPlayOutPlayerInfo packet, GameProfile gameProfile, int ping, EnumGamemode gamemode, IChatBaseComponent name) { - try { - final Class clazz = Class.forName("net.minecraft.server.v1_14_R1.PacketPlayOutPlayerInfo$PlayerInfoData"); - final Constructor infoConstructor = clazz.getDeclaredConstructor( - PacketPlayOutPlayerInfo.class, - GameProfile.class, - int.class, - EnumGamemode.class, - IChatBaseComponent.class - ); - return infoConstructor.newInstance(packet, gameProfile, ping, gamemode, name); - } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InstantiationException | - IllegalAccessException e) { - NickoBukkit.getInstance().getLogger().warning("Unable to instantiate PlayerInfoData, that's bad! (" + e.getMessage() + ")"); - return null; - } - } -} diff --git a/v1_15_R1/pom.xml b/v1_15_R1/pom.xml deleted file mode 100644 index 783358e..0000000 --- a/v1_15_R1/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - nicko-parent - net.artelnatif - 1.0-SNAPSHOT - - 4.0.0 - - v1_15_R1 - 1.0-SNAPSHOT - - - - org.spigotmc - spigot - 1.15.2-R0.1-SNAPSHOT - provided - - - net.artelnatif - core - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_15_R1.java b/v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_15_R1.java deleted file mode 100644 index 1bffee0..0000000 --- a/v1_15_R1/src/main/java/net/artelnatif/nicko/impl/v1_15_R1.java +++ /dev/null @@ -1,129 +0,0 @@ -package net.artelnatif.nicko.impl; - -import com.google.common.collect.Lists; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import com.mojang.authlib.properties.PropertyMap; -import net.artelnatif.nicko.NickoBukkit; -import net.artelnatif.nicko.disguise.ActionResult; -import net.artelnatif.nicko.disguise.NickoProfile; -import net.artelnatif.nicko.mojang.MojangSkin; -import net.minecraft.server.v1_15_R1.*; -import org.bukkit.Bukkit; -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.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; - -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.getValue(), skin.getSignature())); - 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 Object infoData = yes( - add, - gameProfile, - entityPlayer.ping, - EnumGamemode.getById(player.getGameMode().ordinal()), - name - ); - spoofPlayerInfoPacket(add, Lists.newArrayList(infoData)); - - 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() + ")"); - } - } - - public Object yes(PacketPlayOutPlayerInfo packet, GameProfile gameProfile, int ping, EnumGamemode gamemode, IChatBaseComponent name) { - try { - final Class clazz = Class.forName("net.minecraft.server.v1_15_R1.PacketPlayOutPlayerInfo$PlayerInfoData"); - final Constructor infoConstructor = clazz.getDeclaredConstructor( - PacketPlayOutPlayerInfo.class, - GameProfile.class, - int.class, - EnumGamemode.class, - IChatBaseComponent.class - ); - return infoConstructor.newInstance(packet, gameProfile, ping, gamemode, name); - } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InstantiationException | - IllegalAccessException e) { - NickoBukkit.getInstance().getLogger().warning("Unable to instantiate PlayerInfoData, that's bad! (" + e.getMessage() + ")"); - return null; - } - } -} diff --git a/v1_16_R1/pom.xml b/v1_16_R1/pom.xml deleted file mode 100644 index 032d146..0000000 --- a/v1_16_R1/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - nicko-parent - net.artelnatif - 1.0-SNAPSHOT - - 4.0.0 - - v1_16_R1 - 1.0-SNAPSHOT - - - - org.spigotmc - spigot - 1.16.1-R0.1-SNAPSHOT - provided - - - net.artelnatif - core - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/v1_16_R1/src/main/java/net/artelnatif/nicko/impl/v1_16_R1.java b/v1_16_R1/src/main/java/net/artelnatif/nicko/impl/v1_16_R1.java deleted file mode 100644 index c7939c1..0000000 --- a/v1_16_R1/src/main/java/net/artelnatif/nicko/impl/v1_16_R1.java +++ /dev/null @@ -1,132 +0,0 @@ -package net.artelnatif.nicko.impl; - -import com.google.common.collect.Lists; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import com.mojang.authlib.properties.PropertyMap; -import net.artelnatif.nicko.NickoBukkit; -import net.artelnatif.nicko.disguise.ActionResult; -import net.artelnatif.nicko.disguise.NickoProfile; -import net.artelnatif.nicko.mojang.MojangSkin; -import net.minecraft.server.v1_16_R1.*; -import org.bukkit.Bukkit; -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; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; - -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().getTypeKey(), - levelResourceKey, world.getSeed(), - entityPlayer.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(), - false, - false, - false); - - 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.getValue(), skin.getSignature())); - 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 Object infoData = yes( - add, - gameProfile, - entityPlayer.ping, - EnumGamemode.getById(player.getGameMode().ordinal()), - name - ); - spoofPlayerInfoPacket(add, Lists.newArrayList(infoData)); - - 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() + ")"); - } - } - - public Object yes(PacketPlayOutPlayerInfo packet, GameProfile gameProfile, int ping, EnumGamemode gamemode, IChatBaseComponent name) { - try { - final Class clazz = Class.forName("net.minecraft.server.v1_16_R1.PacketPlayOutPlayerInfo$PlayerInfoData"); - final Constructor infoConstructor = clazz.getDeclaredConstructor( - PacketPlayOutPlayerInfo.class, - GameProfile.class, - int.class, - EnumGamemode.class, - IChatBaseComponent.class - ); - return infoConstructor.newInstance(packet, gameProfile, ping, gamemode, name); - } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InstantiationException | - IllegalAccessException e) { - NickoBukkit.getInstance().getLogger().warning("Unable to instantiate PlayerInfoData, that's bad! (" + e.getMessage() + ")"); - return null; - } - } -} diff --git a/v1_16_R2/pom.xml b/v1_16_R2/pom.xml deleted file mode 100644 index 658413d..0000000 --- a/v1_16_R2/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - nicko-parent - net.artelnatif - 1.0-SNAPSHOT - - 4.0.0 - - v1_16_R2 - 1.0-SNAPSHOT - - - - org.spigotmc - spigot - 1.16.3-R0.1-SNAPSHOT - provided - - - net.artelnatif - core - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_16_R2.java b/v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_16_R2.java deleted file mode 100644 index 244970a..0000000 --- a/v1_16_R2/src/main/java/net/artelnatif/nicko/impl/v1_16_R2.java +++ /dev/null @@ -1,132 +0,0 @@ -package net.artelnatif.nicko.impl; - -import com.google.common.collect.Lists; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import com.mojang.authlib.properties.PropertyMap; -import net.artelnatif.nicko.NickoBukkit; -import net.artelnatif.nicko.disguise.ActionResult; -import net.artelnatif.nicko.disguise.NickoProfile; -import net.artelnatif.nicko.mojang.MojangSkin; -import net.minecraft.server.v1_16_R2.*; -import org.bukkit.Bukkit; -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; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; - -public class v1_16_R2 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.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(), - false, - false, - false); - - 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.getValue(), skin.getSignature())); - 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 Object infoData = yes( - add, - gameProfile, - entityPlayer.ping, - EnumGamemode.getById(player.getGameMode().ordinal()), - name - ); - spoofPlayerInfoPacket(add, Lists.newArrayList(infoData)); - - 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() + ")"); - } - } - - public Object yes(PacketPlayOutPlayerInfo packet, GameProfile gameProfile, int ping, EnumGamemode gamemode, IChatBaseComponent name) { - try { - final Class clazz = Class.forName("net.minecraft.server.v1_16_R2.PacketPlayOutPlayerInfo$PlayerInfoData"); - final Constructor infoConstructor = clazz.getDeclaredConstructor( - PacketPlayOutPlayerInfo.class, - GameProfile.class, - int.class, - EnumGamemode.class, - IChatBaseComponent.class - ); - return infoConstructor.newInstance(packet, gameProfile, ping, gamemode, name); - } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InstantiationException | - IllegalAccessException e) { - NickoBukkit.getInstance().getLogger().warning("Unable to instantiate PlayerInfoData, that's bad! (" + e.getMessage() + ")"); - return null; - } - } -} diff --git a/v1_16_R3/pom.xml b/v1_16_R3/pom.xml deleted file mode 100644 index 055dbe2..0000000 --- a/v1_16_R3/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - nicko-parent - net.artelnatif - 1.0-SNAPSHOT - - 4.0.0 - - v1_16_R3 - 1.0-SNAPSHOT - - - - org.spigotmc - spigot - 1.16.5-R0.1-SNAPSHOT - provided - - - net.artelnatif - core - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/v1_16_R3/src/main/java/net/artelnatif/nicko/impl/v1_16_R3.java b/v1_16_R3/src/main/java/net/artelnatif/nicko/impl/v1_16_R3.java deleted file mode 100644 index b0744ea..0000000 --- a/v1_16_R3/src/main/java/net/artelnatif/nicko/impl/v1_16_R3.java +++ /dev/null @@ -1,136 +0,0 @@ -package net.artelnatif.nicko.impl; - -import com.google.common.collect.Lists; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import com.mojang.authlib.properties.PropertyMap; -import net.artelnatif.nicko.NickoBukkit; -import net.artelnatif.nicko.disguise.ActionResult; -import net.artelnatif.nicko.disguise.NickoProfile; -import net.artelnatif.nicko.mojang.MojangSkin; -import net.minecraft.server.v1_16_R3.*; -import org.bukkit.Bukkit; -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; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; - -public class v1_16_R3 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.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(), - false, - false, - false); - - 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.getValue(), skin.getSignature())); - 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); - - // ok so what the actual fuck - // the PlayerDataInfo inner class is NOT static - // thus the compiler can't access it when compiling?????? - // i swear this is so dumb that I have to resort to doing this - final Object infoData = yes( - add, - gameProfile, - entityPlayer.ping, - EnumGamemode.getById(player.getGameMode().ordinal()), - name - ); - spoofPlayerInfoPacket(add, Lists.newArrayList(infoData)); - - 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() + ")"); - } - } - - public Object yes(PacketPlayOutPlayerInfo packet, GameProfile gameProfile, int ping, EnumGamemode gamemode, IChatBaseComponent name) { - try { - final Class clazz = Class.forName("net.minecraft.server.v1_16_R3.PacketPlayOutPlayerInfo$PlayerInfoData"); - final Constructor infoConstructor = clazz.getDeclaredConstructor( - PacketPlayOutPlayerInfo.class, - GameProfile.class, - int.class, - EnumGamemode.class, - IChatBaseComponent.class - ); - return infoConstructor.newInstance(packet, gameProfile, ping, gamemode, name); - } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InstantiationException | - IllegalAccessException e) { - NickoBukkit.getInstance().getLogger().warning("Unable to instantiate PlayerInfoData, that's bad! (" + e.getMessage() + ")"); - return null; - } - } -} diff --git a/v1_17_R1/pom.xml b/v1_17_R1/pom.xml deleted file mode 100644 index 7ca2642..0000000 --- a/v1_17_R1/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - nicko-parent - net.artelnatif - 1.0-SNAPSHOT - - 4.0.0 - - v1_17_R1 - 1.0-SNAPSHOT - - - - org.spigotmc - spigot - 1.17.1-R0.1-SNAPSHOT - provided - - - net.artelnatif - core - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/v1_17_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java b/v1_17_R1/src/main/java/net/artelnatif/nicko/impl/v1_17_R1.java deleted file mode 100644 index 24cd2a0..0000000 --- a/v1_17_R1/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.getValue(), skin.getSignature())); - updateSelf(player); - } - } - - final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer); - final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a); - - add.b().clear(); - add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, - player.getPing(), - EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName))); - - Bukkit.getOnlinePlayers().forEach(online -> { - EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); - onlineEntityPlayer.b.sendPacket(remove); - onlineEntityPlayer.b.sendPacket(add); - }); - updateOthers(player); - return new ActionResult<>(); - } -} diff --git a/v1_18_R1/pom.xml b/v1_18_R1/pom.xml deleted file mode 100644 index d842952..0000000 --- a/v1_18_R1/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - net.artelnatif - nicko-parent - 1.0-SNAPSHOT - - - v1_18_R1 - 1.0-SNAPSHOT - - - - org.spigotmc - spigot - 1.18.1-R0.1-SNAPSHOT - provided - - - net.artelnatif - core - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/v1_18_R1/src/main/java/net/artelnatif/nicko/impl/v1_18_R1.java b/v1_18_R1/src/main/java/net/artelnatif/nicko/impl/v1_18_R1.java deleted file mode 100644 index 1f1b7b7..0000000 --- a/v1_18_R1/src/main/java/net/artelnatif/nicko/impl/v1_18_R1.java +++ /dev/null @@ -1,103 +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_18_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent; - -public class v1_18_R1 implements Internals { - @Override - public void updateSelf(Player player) { - final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - final ResourceKey levelResourceKey = entityPlayer.x().aa(); - final CraftWorld world = entityPlayer.W().getWorld(); - // again, wtf is that - // f*ck obfuscation - final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.W().q_(), - levelResourceKey, world.getSeed(), - entityPlayer.d.b(), entityPlayer.d.c(), - false, - false, - false); - - final boolean wasFlying = player.isFlying(); - entityPlayer.b.a(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.ai(); - final DataWatcherObject displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); - dataWatcher.b(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.a(destroy); - onlineEntityPlayer.b.a(spawn); - } - onlineEntityPlayer.b.a(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.getValue(), skin.getSignature())); - 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.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName))); - - Bukkit.getOnlinePlayers().forEach(online -> { - EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); - onlineEntityPlayer.b.a(remove); - onlineEntityPlayer.b.a(add); - }); - updateOthers(player); - return new ActionResult<>(); - } -} diff --git a/v1_18_R2/pom.xml b/v1_18_R2/pom.xml deleted file mode 100644 index 4eb30ad..0000000 --- a/v1_18_R2/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - net.artelnatif - nicko-parent - 1.0-SNAPSHOT - - - v1_18_R2 - 1.0-SNAPSHOT - - - - org.spigotmc - spigot - 1.18.2-R0.1-SNAPSHOT - provided - - - net.artelnatif - core - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/v1_18_R2/src/main/java/net/artelnatif/nicko/impl/v1_18_R2.java b/v1_18_R2/src/main/java/net/artelnatif/nicko/impl/v1_18_R2.java deleted file mode 100644 index 1f085f6..0000000 --- a/v1_18_R2/src/main/java/net/artelnatif/nicko/impl/v1_18_R2.java +++ /dev/null @@ -1,103 +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.core.Holder; -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_18_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent; - -public class v1_18_R2 implements Internals { - @Override - public void updateSelf(Player player) { - final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - final ResourceKey levelResourceKey = entityPlayer.x().aa(); - final CraftWorld world = entityPlayer.s.getWorld(); - // wtf is that ? - final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(Holder.a(entityPlayer.s.q_()), - levelResourceKey, world.getSeed(), - entityPlayer.d.b(), entityPlayer.d.c(), - false, - false, - false); - - final boolean wasFlying = player.isFlying(); - entityPlayer.b.a(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.ai(); - final DataWatcherObject displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); - dataWatcher.b(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.a(destroy); - onlineEntityPlayer.b.a(spawn); - } - onlineEntityPlayer.b.a(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.getValue(), skin.getSignature())); - 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.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName))); - - Bukkit.getOnlinePlayers().forEach(online -> { - EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); - onlineEntityPlayer.b.a(remove); - onlineEntityPlayer.b.a(add); - }); - updateOthers(player); - return new ActionResult<>(); - } -} \ No newline at end of file diff --git a/v1_19_R1/pom.xml b/v1_19_R1/pom.xml deleted file mode 100644 index ccdb982..0000000 --- a/v1_19_R1/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - - net.artelnatif - nicko-parent - 1.0-SNAPSHOT - - - v1_19_R1 - 1.0-SNAPSHOT - - - - org.spigotmc - spigot - 1.19.2-R0.1-SNAPSHOT - provided - - - net.artelnatif - core - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/v1_19_R1/src/main/java/net/artelnatif/nicko/impl/v1_19_R1.java b/v1_19_R1/src/main/java/net/artelnatif/nicko/impl/v1_19_R1.java deleted file mode 100644 index fe98d37..0000000 --- a/v1_19_R1/src/main/java/net/artelnatif/nicko/impl/v1_19_R1.java +++ /dev/null @@ -1,107 +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.entity.player.ProfilePublicKey; -import net.minecraft.world.level.EnumGamemode; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent; - -import java.util.Optional; - -public class v1_19_R1 implements Internals { - @Override - public void updateSelf(Player player) { - final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); - final ResourceKey levelResourceKey = entityPlayer.x().ab(); - final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.x().Z(), - levelResourceKey, entityPlayer.s.getWorld().getSeed(), - entityPlayer.d.b(), entityPlayer.d.c(), - false, - false, - false, - Optional.empty()); - - final boolean wasFlying = player.isFlying(); - entityPlayer.b.a(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.ai(); - final DataWatcherObject displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); - dataWatcher.b(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.a(destroy); - onlineEntityPlayer.b.a(spawn); - } - onlineEntityPlayer.b.a(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.getValue(), skin.getSignature())); - updateSelf(player); - } - } - - final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a); - final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer); - // "It's a Surprise Tool That Will Help Us Later!" - final ProfilePublicKey.a key = remove.b().get(0).e(); - - add.b().clear(); - add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, - player.getPing(), - EnumGamemode.a(player.getGameMode().ordinal()), - IChatBaseComponent.a(profileName), - key)); // f mojang - - Bukkit.getOnlinePlayers().forEach(online -> { - EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); - onlineEntityPlayer.b.a(remove); - onlineEntityPlayer.b.a(add); - }); - updateOthers(player); - return new ActionResult<>(); - } -} diff --git a/v1_19_R2/pom.xml b/v1_19_R2/pom.xml deleted file mode 100644 index 385efc4..0000000 --- a/v1_19_R2/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - 4.0.0 - - - net.artelnatif - nicko-parent - 1.0-SNAPSHOT - - - v1_19_R2 - 1.0-SNAPSHOT - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:txt:maps-mojang - true - org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-mojang - true - remapped-obf - - - - package - - remap - - remap-spigot - - ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-obf - - - - - - - - - - org.spigotmc - spigot - 1.19.3-R0.1-SNAPSHOT - remapped-mojang - provided - - - net.artelnatif - core - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/v1_19_R2/src/main/java/net/artelnatif/nicko/impl/v1_19_R2.java b/v1_19_R2/src/main/java/net/artelnatif/nicko/impl/v1_19_R2.java deleted file mode 100644 index 4059960..0000000 --- a/v1_19_R2/src/main/java/net/artelnatif/nicko/impl/v1_19_R2.java +++ /dev/null @@ -1,132 +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.NickoBukkit; -import net.artelnatif.nicko.disguise.ActionResult; -import net.artelnatif.nicko.disguise.NickoProfile; -import net.artelnatif.nicko.mojang.MojangSkin; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.RemoteChatSession; -import net.minecraft.network.protocol.game.*; -import net.minecraft.network.syncher.EntityDataAccessor; -import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.network.syncher.SynchedEntityData; -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.ProfilePublicKey; -import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent; - -import java.lang.reflect.Field; -import java.util.*; - -public class v1_19_R2 implements Internals { - @Override - public void updateSelf(Player player) { - final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle(); - final ServerLevel level = serverPlayer.getLevel(); - final ResourceKey levelResourceKey = serverPlayer.getLevel().dimension(); - final ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(serverPlayer.level.dimensionTypeId(), - levelResourceKey, level.getWorld().getSeed(), - serverPlayer.gameMode.getGameModeForPlayer(), serverPlayer.gameMode.getPreviousGameModeForPlayer(), - level.isDebug(), - level.isFlat(), - (byte) 0x00, - Optional.empty()); - - final boolean wasFlying = player.isFlying(); - serverPlayer.connection.send(respawn); - player.setFlying(wasFlying); - player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); - player.updateInventory(); - } - - @Override - public void updateOthers(Player player) { - final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle(); - final ClientboundRemoveEntitiesPacket remove = new ClientboundRemoveEntitiesPacket(serverPlayer.getBukkitEntity().getEntityId()); - final ClientboundAddEntityPacket add = new ClientboundAddEntityPacket(serverPlayer); - - final SynchedEntityData entityData = serverPlayer.getEntityData(); - final EntityDataAccessor skinPartAccessor = new EntityDataAccessor<>(17, EntityDataSerializers.BYTE); - entityData.set(skinPartAccessor, (byte) 0x7f); - final ClientboundSetEntityDataPacket entityMetadata = new ClientboundSetEntityDataPacket(serverPlayer.getBukkitEntity().getEntityId(), entityData.getNonDefaultValues()); - - Bukkit.getOnlinePlayers().forEach(online -> { - final ServerPlayer onlineServerPlayer = ((CraftPlayer) online).getHandle(); - if (onlineServerPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) { - onlineServerPlayer.connection.send(remove); - onlineServerPlayer.connection.send(add); - } - onlineServerPlayer.connection.send(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 ServerPlayer serverPlayer = ((CraftPlayer) player).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.getValue(), skin.getSignature())); - updateSelf(player); - } - } - - final ClientboundPlayerInfoUpdatePacket init = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(Collections.singletonList(serverPlayer)); - final ClientboundPlayerInfoRemovePacket remove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(player.getUniqueId())); - - RemoteChatSession chatSession; - if (serverPlayer.getChatSession() == null) { - NickoBukkit.getInstance().getLogger().warning("Chat Session of " + serverPlayer.displayName + " is null!"); - NickoBukkit.getInstance().getLogger().warning("If your server is in offline mode/under BungeeCord you can safely ignore this message."); - chatSession = null; - } else { - final UUID uuid = serverPlayer.getChatSession().sessionId(); - final ProfilePublicKey ppk = serverPlayer.getChatSession().profilePublicKey(); - chatSession = new RemoteChatSession(uuid, ppk); - } - - spoofPlayerInfoPacket(init, Collections.singletonList(new ClientboundPlayerInfoUpdatePacket.Entry( - player.getUniqueId(), - gameProfile, - true, - serverPlayer.latency, - serverPlayer.gameMode.getGameModeForPlayer(), - Component.literal(profileName), - chatSession == null ? null : chatSession.asData() - ))); - - Bukkit.getOnlinePlayers().forEach(online -> { - final ServerPlayer onlinePlayer = ((CraftPlayer) online).getHandle(); - onlinePlayer.connection.send(remove); - onlinePlayer.connection.send(init); - }); - 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_19_R3/pom.xml b/v1_19_R3/pom.xml deleted file mode 100644 index eefd19d..0000000 --- a/v1_19_R3/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - 4.0.0 - - - net.artelnatif - nicko-parent - 1.0-SNAPSHOT - - - v1_19_R3 - 1.0-SNAPSHOT - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT:txt:maps-mojang - true - org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:jar:remapped-mojang - true - remapped-obf - - - - package - - remap - - remap-spigot - - ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar - org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT:csrg:maps-spigot - org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:jar:remapped-obf - - - - - - - - - - org.spigotmc - spigot - 1.19.4-R0.1-SNAPSHOT - remapped-mojang - provided - - - net.artelnatif - core - 1.0-SNAPSHOT - - - \ No newline at end of file diff --git a/v1_19_R3/src/main/java/net/artelnatif/nicko/impl/v1_19_R3.java b/v1_19_R3/src/main/java/net/artelnatif/nicko/impl/v1_19_R3.java deleted file mode 100644 index d0ef0eb..0000000 --- a/v1_19_R3/src/main/java/net/artelnatif/nicko/impl/v1_19_R3.java +++ /dev/null @@ -1,140 +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.NickoBukkit; -import net.artelnatif.nicko.disguise.ActionResult; -import net.artelnatif.nicko.disguise.NickoProfile; -import net.artelnatif.nicko.mojang.MojangSkin; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.RemoteChatSession; -import net.minecraft.network.protocol.game.*; -import net.minecraft.network.syncher.EntityDataAccessor; -import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.network.syncher.SynchedEntityData; -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.ProfilePublicKey; -import net.minecraft.world.level.Level; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent; - -import java.lang.reflect.Field; -import java.util.Collections; -import java.util.Optional; -import java.util.UUID; -import java.util.logging.Logger; - -public class v1_19_R3 implements Internals { - final Logger logger = Bukkit.getLogger(); - - @Override - public void updateSelf(Player player) { - final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle(); - final ServerLevel level = serverPlayer.getLevel(); - final ResourceKey levelResourceKey = serverPlayer.getLevel().dimension(); - final ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(serverPlayer.level.dimensionTypeId(), - levelResourceKey, level.getWorld().getSeed(), - serverPlayer.gameMode.getGameModeForPlayer(), serverPlayer.gameMode.getPreviousGameModeForPlayer(), - level.isDebug(), - level.isFlat(), - (byte) 0x00, - Optional.empty()); - - final boolean wasFlying = player.isFlying(); - serverPlayer.connection.send(respawn); - player.setFlying(wasFlying); - player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); - player.updateInventory(); - } - - @Override - public void updateOthers(Player player) { - final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle(); - - final ClientboundRemoveEntitiesPacket remove = new ClientboundRemoveEntitiesPacket(serverPlayer.getBukkitEntity().getEntityId()); - final ClientboundAddEntityPacket add = new ClientboundAddEntityPacket(serverPlayer); - - final SynchedEntityData entityData = serverPlayer.getEntityData(); - final EntityDataAccessor skinPartAccessor = new EntityDataAccessor<>(17, EntityDataSerializers.BYTE); - entityData.set(skinPartAccessor, (byte) 0x7f); - final ClientboundSetEntityDataPacket entityMetadata = new ClientboundSetEntityDataPacket(serverPlayer.getBukkitEntity().getEntityId(), entityData.getNonDefaultValues()); - - Bukkit.getOnlinePlayers().forEach(online -> { - final ServerPlayer onlineServerPlayer = ((CraftPlayer) online).getHandle(); - if (onlineServerPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) { - onlineServerPlayer.connection.send(remove); - onlineServerPlayer.connection.send(add); - } - onlineServerPlayer.connection.send(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 ServerPlayer serverPlayer = ((CraftPlayer) player).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.getValue(), skin.getSignature())); - updateSelf(player); - } - } - - final ClientboundPlayerInfoUpdatePacket init = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(Collections.singletonList(serverPlayer)); - final ClientboundPlayerInfoRemovePacket remove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(player.getUniqueId())); - - RemoteChatSession chatSession; - if (serverPlayer.getChatSession() == null) { - NickoBukkit.getInstance().getLogger().warning("Chat Session of " + serverPlayer.displayName + " is null!"); - NickoBukkit.getInstance().getLogger().warning("If your server is in offline mode/under BungeeCord you can safely ignore this message."); - chatSession = null; - } else { - final UUID uuid = serverPlayer.getChatSession().sessionId(); - final ProfilePublicKey ppk = serverPlayer.getChatSession().profilePublicKey(); - chatSession = new RemoteChatSession(uuid, ppk); - } - - spoofPlayerInfoPacket(init, Collections.singletonList(new ClientboundPlayerInfoUpdatePacket.Entry( - player.getUniqueId(), - gameProfile, - true, - serverPlayer.latency, - serverPlayer.gameMode.getGameModeForPlayer(), - Component.literal(profileName), - chatSession == null ? null : chatSession.asData() - ))); - - - Bukkit.getOnlinePlayers().forEach(online -> { - final ServerPlayer onlinePlayer = ((CraftPlayer) online).getHandle(); - onlinePlayer.connection.send(remove); - onlinePlayer.connection.send(init); - }); - // TODO: 3/17/23 Update signature to avoid duplicate for loop - 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() + ")"); - } - } -}