mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-06 20:28:06 +02:00
Fix restore of tablist hider
This commit is contained in:
parent
9ea75c502c
commit
48c5dd03bd
@ -127,9 +127,11 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
|
||||
PacketContainer inventoryPacket = protocolManager.createPacket(PacketType.Play.Server.WINDOW_ITEMS);
|
||||
inventoryPacket.getIntegers().write(0, PLAYER_INVENTORY);
|
||||
int inventorySize = CRAFTING_SIZE + ARMOR_SIZE + MAIN_SIZE + HOTBAR_SIZE;
|
||||
|
||||
ItemStack[] blankInventory = new ItemStack[inventorySize];
|
||||
Arrays.fill(blankInventory, new ItemStack(Material.AIR));
|
||||
inventoryPacket.getItemArrayModifier().write(0, blankInventory);
|
||||
|
||||
try {
|
||||
protocolManager.sendServerPacket(player, inventoryPacket, false);
|
||||
} catch (InvocationTargetException invocationExc) {
|
||||
|
@ -6,6 +6,7 @@ import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
|
@ -1,13 +1,29 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class AuthMeTablistPacketAdapter extends PacketAdapter {
|
||||
|
||||
@ -18,6 +34,7 @@ public class AuthMeTablistPacketAdapter extends PacketAdapter {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO) {
|
||||
//this hides the tablist for the new joining players. Already playing users will see the new player
|
||||
try {
|
||||
if (!PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase())) {
|
||||
event.setCancelled(true);
|
||||
@ -28,13 +45,47 @@ public class AuthMeTablistPacketAdapter extends PacketAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: fix this in 1.9
|
||||
public void sendTablist(Player receiver) {
|
||||
WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(receiver);
|
||||
|
||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
NativeGameMode gamemode = NativeGameMode.fromBukkit(receiver.getGameMode());
|
||||
|
||||
WrappedChatComponent displayName = WrappedChatComponent.fromText(receiver.getDisplayName());
|
||||
PlayerInfoData playerInfoData = new PlayerInfoData(gameProfile, 0, gamemode, displayName);
|
||||
|
||||
//add info containing the skin data
|
||||
PacketContainer addInfo = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO);
|
||||
addInfo.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER);
|
||||
addInfo.getPlayerInfoDataLists().write(0, Arrays.asList(playerInfoData));
|
||||
|
||||
try {
|
||||
//adds the skin
|
||||
protocolManager.sendServerPacket(receiver, addInfo);
|
||||
} catch (InvocationTargetException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Exception sending instant skin change packet", ex);
|
||||
}
|
||||
|
||||
//triggers an update for others player to see them
|
||||
for (Player onlinePlayer : Utils.getOnlinePlayers()) {
|
||||
if (onlinePlayer.equals(receiver)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//removes the entity and display them
|
||||
onlinePlayer.hidePlayer(receiver);
|
||||
onlinePlayer.showPlayer(receiver);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: fix this
|
||||
public void register() {
|
||||
ConsoleLogger.showError("The hideTablistBeforeLogin feature is temporarily disabled due to issues with 1.9 clients.");
|
||||
//ProtocolLibrary.getProtocolManager().addPacketListener(this);
|
||||
//commented out because it **could (not tested could also work with it)** still conflict with SkinRestorer
|
||||
ConsoleLogger.showError("The hideTablistBeforeLogin feature is temporarily disabled due to issues");
|
||||
// ProtocolLibrary.getProtocolManager().addPacketListener(this);
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
//ProtocolLibrary.getProtocolManager().removePacketListener(this);
|
||||
ProtocolLibrary.getProtocolManager().removePacketListener(this);
|
||||
}
|
||||
}
|
||||
|
@ -162,6 +162,10 @@ public class ProcessSyncPlayerLogin implements Runnable {
|
||||
restoreInventory();
|
||||
}
|
||||
|
||||
if (settings.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN) && plugin.tablistHider != null) {
|
||||
plugin.tablistHider.sendTablist(player);
|
||||
}
|
||||
|
||||
// Cleanup no longer used temporary data
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if (playerCache.doesCacheExist(player)) {
|
||||
@ -208,7 +212,7 @@ public class ProcessSyncPlayerLogin implements Runnable {
|
||||
|
||||
// Login is now finished; we can force all commands
|
||||
forceCommands();
|
||||
|
||||
|
||||
sendTo();
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class ProcessSyncPasswordRegister implements Process {
|
||||
}
|
||||
for (String command : Settings.forceRegisterCommandsAsConsole) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
command.replace("%p", player.getName()));
|
||||
command.replace("%p", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,6 +80,10 @@ public class ProcessSyncPasswordRegister implements Process {
|
||||
public void run() {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
if (limbo != null) {
|
||||
if (Settings.hideTablistBeforeLogin && plugin.tablistHider != null) {
|
||||
plugin.tablistHider.sendTablist(player);
|
||||
}
|
||||
|
||||
Utils.teleportToSpawn(player);
|
||||
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user