feat: player reset

for the time being, message signature is set to null, causing players beyond 1.19.2
to be kicked while being disguised, even after removing said one.
look at the comment for further information.
This commit is contained in:
ineanto 2023-05-18 18:49:04 +02:00
parent 4157c71526
commit fecfb7300b
4 changed files with 20 additions and 19 deletions

View file

@ -44,6 +44,7 @@
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- PlaceHolder API -->
<dependency>

View file

@ -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;

View file

@ -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,15 +86,12 @@ public class AppearanceManager {
final String defaultName = nameStore.getStoredName(player);
this.profile.setName(defaultName);
this.profile.setSkin(defaultName);
final ActionResult<Void> actionResult = resetPlayer();
final ActionResult<Void> actionResult = updatePlayer(true);
if (!actionResult.isError()) {
this.profile.setSkin(null);
this.profile.setName(null);
return actionResult;
}
public ActionResult<Void> resetPlayer() {
// TODO: 4/3/23 Reset player
return new ActionResult<>();
return actionResult;
}
public ActionResult<Void> updatePlayer(boolean skinChange) {
@ -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);

View file

@ -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