diff --git a/pom.xml b/pom.xml index aba14d4..31d2bc6 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,7 @@ com.comphenix.protocol ProtocolLib 5.0.0-SNAPSHOT + provided diff --git a/src/main/java/xyz/atnrch/nicko/NickoBukkit.java b/src/main/java/xyz/atnrch/nicko/NickoBukkit.java index 55b87f0..7aa2ead 100644 --- a/src/main/java/xyz/atnrch/nicko/NickoBukkit.java +++ b/src/main/java/xyz/atnrch/nicko/NickoBukkit.java @@ -2,6 +2,12 @@ package xyz.atnrch.nicko; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.command.PluginCommand; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.java.JavaPluginLoader; import xyz.atnrch.nicko.command.NickoCommand; import xyz.atnrch.nicko.config.Configuration; import xyz.atnrch.nicko.config.ConfigurationManager; @@ -15,12 +21,6 @@ import xyz.atnrch.nicko.mojang.MojangAPI; import xyz.atnrch.nicko.placeholder.PlaceHolderHook; import xyz.atnrch.nicko.storage.PlayerDataStore; import xyz.atnrch.nicko.storage.name.PlayerNameStore; -import org.bukkit.Bukkit; -import org.bukkit.Material; -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; diff --git a/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java b/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java index 6b6ff82..51fc7c7 100644 --- a/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java +++ b/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java @@ -3,6 +3,7 @@ package xyz.atnrch.nicko.disguise; import com.comphenix.protocol.wrappers.*; import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; +import org.bukkit.event.player.PlayerTeleportEvent; import xyz.atnrch.nicko.NickoBukkit; import xyz.atnrch.nicko.i18n.I18NDict; import xyz.atnrch.nicko.mojang.MojangAPI; @@ -85,17 +86,14 @@ public class AppearanceManager { final String defaultName = nameStore.getStoredName(player); this.profile.setName(defaultName); this.profile.setSkin(defaultName); - final ActionResult actionResult = resetPlayer(); - this.profile.setSkin(null); - this.profile.setName(null); + final ActionResult actionResult = updatePlayer(true); + if (!actionResult.isError()) { + this.profile.setSkin(null); + this.profile.setName(null); + } return actionResult; } - public ActionResult resetPlayer() { - // TODO: 4/3/23 Reset player - return new ActionResult<>(); - } - public ActionResult updatePlayer(boolean skinChange) { final String displayName = profile.getName() == null ? player.getName() : profile.getName(); @@ -106,6 +104,7 @@ public class AppearanceManager { updateTabList(gameProfile, displayName); respawnPlayer(); } + player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); return new ActionResult<>(); } @@ -159,7 +158,6 @@ public class AppearanceManager { private void updateTabList(WrappedGameProfile gameProfile, String displayName) { final WrapperPlayerServerPlayerInfoRemove remove = new WrapperPlayerServerPlayerInfoRemove(); remove.setUUIDs(ImmutableList.of(player.getUniqueId())); - final WrapperPlayerServerPlayerInfo update = new WrapperPlayerServerPlayerInfo(); update.setActions(EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER, EnumWrappers.PlayerInfoAction.INITIALIZE_CHAT, @@ -173,9 +171,11 @@ public class AppearanceManager { true, EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()), gameProfile, - WrappedChatComponent.fromText(displayName), - new WrappedRemoteChatSessionData(UUID.randomUUID(), - WrappedProfilePublicKey.ofPlayer(player).getKeyData()) + WrappedChatComponent.fromText(displayName) + // Yes, I skip providing chat session data. + // Yes, this will cause players to get kicked as soon as they send a message. + // No, I'll not waste another day fixing their mess. Go cry about it to Mojang. + // (Long live NoEncryption!) ))); remove.sendPacket(player); update.sendPacket(player); diff --git a/src/main/java/xyz/atnrch/nicko/wrapper/WrapperPlayServerRespawn.java b/src/main/java/xyz/atnrch/nicko/wrapper/WrapperPlayServerRespawn.java index c8d46a1..817f8c1 100644 --- a/src/main/java/xyz/atnrch/nicko/wrapper/WrapperPlayServerRespawn.java +++ b/src/main/java/xyz/atnrch/nicko/wrapper/WrapperPlayServerRespawn.java @@ -32,7 +32,7 @@ public class WrapperPlayServerRespawn extends AbstractPacket { // The dimension field has changed numerous times: // - 1.8 through 1.17 (?) need an integer, // - 1.18 need a Holder of a World ResourceKey, - // - 1.19.2 reverted 1.18 and simply need a World ResourceKey. + // - 1.19 and beyond don't require a Holder. // // n.b.: this field is a nightmare please mojang stop refactoring // your code to change things that were working perfectly fine before