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:
parent
4157c71526
commit
fecfb7300b
4 changed files with 20 additions and 19 deletions
1
pom.xml
1
pom.xml
|
@ -44,6 +44,7 @@
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
<version>5.0.0-SNAPSHOT</version>
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- PlaceHolder API -->
|
<!-- PlaceHolder API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -2,6 +2,12 @@ package xyz.atnrch.nicko;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
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.command.NickoCommand;
|
||||||
import xyz.atnrch.nicko.config.Configuration;
|
import xyz.atnrch.nicko.config.Configuration;
|
||||||
import xyz.atnrch.nicko.config.ConfigurationManager;
|
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.placeholder.PlaceHolderHook;
|
||||||
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
||||||
import xyz.atnrch.nicko.storage.name.PlayerNameStore;
|
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.gui.structure.Structure;
|
||||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||||
import xyz.xenondevs.invui.item.impl.SimpleItem;
|
import xyz.xenondevs.invui.item.impl.SimpleItem;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package xyz.atnrch.nicko.disguise;
|
||||||
import com.comphenix.protocol.wrappers.*;
|
import com.comphenix.protocol.wrappers.*;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import xyz.atnrch.nicko.NickoBukkit;
|
import xyz.atnrch.nicko.NickoBukkit;
|
||||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||||
import xyz.atnrch.nicko.mojang.MojangAPI;
|
import xyz.atnrch.nicko.mojang.MojangAPI;
|
||||||
|
@ -85,17 +86,14 @@ public class AppearanceManager {
|
||||||
final String defaultName = nameStore.getStoredName(player);
|
final String defaultName = nameStore.getStoredName(player);
|
||||||
this.profile.setName(defaultName);
|
this.profile.setName(defaultName);
|
||||||
this.profile.setSkin(defaultName);
|
this.profile.setSkin(defaultName);
|
||||||
final ActionResult<Void> actionResult = resetPlayer();
|
final ActionResult<Void> actionResult = updatePlayer(true);
|
||||||
this.profile.setSkin(null);
|
if (!actionResult.isError()) {
|
||||||
this.profile.setName(null);
|
this.profile.setSkin(null);
|
||||||
|
this.profile.setName(null);
|
||||||
|
}
|
||||||
return actionResult;
|
return actionResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult<Void> resetPlayer() {
|
|
||||||
// TODO: 4/3/23 Reset player
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionResult<Void> updatePlayer(boolean skinChange) {
|
public ActionResult<Void> updatePlayer(boolean skinChange) {
|
||||||
final String displayName = profile.getName() == null ? player.getName() : profile.getName();
|
final String displayName = profile.getName() == null ? player.getName() : profile.getName();
|
||||||
|
|
||||||
|
@ -106,6 +104,7 @@ public class AppearanceManager {
|
||||||
updateTabList(gameProfile, displayName);
|
updateTabList(gameProfile, displayName);
|
||||||
respawnPlayer();
|
respawnPlayer();
|
||||||
}
|
}
|
||||||
|
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
return new ActionResult<>();
|
return new ActionResult<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +158,6 @@ public class AppearanceManager {
|
||||||
private void updateTabList(WrappedGameProfile gameProfile, String displayName) {
|
private void updateTabList(WrappedGameProfile gameProfile, String displayName) {
|
||||||
final WrapperPlayerServerPlayerInfoRemove remove = new WrapperPlayerServerPlayerInfoRemove();
|
final WrapperPlayerServerPlayerInfoRemove remove = new WrapperPlayerServerPlayerInfoRemove();
|
||||||
remove.setUUIDs(ImmutableList.of(player.getUniqueId()));
|
remove.setUUIDs(ImmutableList.of(player.getUniqueId()));
|
||||||
|
|
||||||
final WrapperPlayerServerPlayerInfo update = new WrapperPlayerServerPlayerInfo();
|
final WrapperPlayerServerPlayerInfo update = new WrapperPlayerServerPlayerInfo();
|
||||||
update.setActions(EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER,
|
update.setActions(EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER,
|
||||||
EnumWrappers.PlayerInfoAction.INITIALIZE_CHAT,
|
EnumWrappers.PlayerInfoAction.INITIALIZE_CHAT,
|
||||||
|
@ -173,9 +171,11 @@ public class AppearanceManager {
|
||||||
true,
|
true,
|
||||||
EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()),
|
EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()),
|
||||||
gameProfile,
|
gameProfile,
|
||||||
WrappedChatComponent.fromText(displayName),
|
WrappedChatComponent.fromText(displayName)
|
||||||
new WrappedRemoteChatSessionData(UUID.randomUUID(),
|
// Yes, I skip providing chat session data.
|
||||||
WrappedProfilePublicKey.ofPlayer(player).getKeyData())
|
// 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);
|
remove.sendPacket(player);
|
||||||
update.sendPacket(player);
|
update.sendPacket(player);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class WrapperPlayServerRespawn extends AbstractPacket {
|
||||||
// The dimension field has changed numerous times:
|
// The dimension field has changed numerous times:
|
||||||
// - 1.8 through 1.17 (?) need an integer,
|
// - 1.8 through 1.17 (?) need an integer,
|
||||||
// - 1.18 need a Holder of a World ResourceKey,
|
// - 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
|
// n.b.: this field is a nightmare please mojang stop refactoring
|
||||||
// your code to change things that were working perfectly fine before
|
// your code to change things that were working perfectly fine before
|
||||||
|
|
Loading…
Reference in a new issue