mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 12:45:57 +01:00
Remove tablist hider because it's useless and produces too much issues
(Related #810)
This commit is contained in:
parent
70226f7ddb
commit
bc9717d650
@ -1,120 +0,0 @@
|
|||||||
package fr.xephi.authme.listener.protocollib;
|
|
||||||
|
|
||||||
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.utility.MinecraftVersion;
|
|
||||||
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 com.google.common.collect.Lists;
|
|
||||||
import fr.xephi.authme.AuthMe;
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
|
||||||
import fr.xephi.authme.util.BukkitService;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
class AuthMeTablistPacketAdapter extends PacketAdapter {
|
|
||||||
|
|
||||||
private final BukkitService bukkitService;
|
|
||||||
private boolean isRegistered;
|
|
||||||
|
|
||||||
public AuthMeTablistPacketAdapter(AuthMe plugin, BukkitService bukkitService) {
|
|
||||||
super(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.PLAYER_INFO);
|
|
||||||
this.bukkitService = bukkitService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPacketSending(PacketEvent packetEvent) {
|
|
||||||
Player receiver = packetEvent.getPlayer();
|
|
||||||
if (packetEvent.getPacketType() == PacketType.Play.Server.PLAYER_INFO
|
|
||||||
&& !PlayerCache.getInstance().isAuthenticated(receiver.getName().toLowerCase())) {
|
|
||||||
//this hides the tablist for the new joining players. Already playing users will see the new player
|
|
||||||
try {
|
|
||||||
PacketContainer packet = packetEvent.getPacket();
|
|
||||||
PlayerInfoAction playerInfoAction = packet.getPlayerInfoAction().read(0);
|
|
||||||
if (playerInfoAction == PlayerInfoAction.ADD_PLAYER) {
|
|
||||||
List<PlayerInfoData> playerInfoList = Lists.newArrayList(packet.getPlayerInfoDataLists().read(0));
|
|
||||||
for (Iterator<PlayerInfoData> iterator = playerInfoList.iterator(); iterator.hasNext();) {
|
|
||||||
PlayerInfoData current = iterator.next();
|
|
||||||
UUID uuid = current.getProfile().getUUID();
|
|
||||||
if (Bukkit.getPlayer(uuid) == null) {
|
|
||||||
//player is not online -> a NPC
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
packet.getPlayerInfoDataLists().write(0, playerInfoList);
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ConsoleLogger.logException("Couldn't modify outgoing tablist packet", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendTablist(Player receiver) {
|
|
||||||
if (!isRegistered) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 : bukkitService.getOnlinePlayers()) {
|
|
||||||
if (onlinePlayer.equals(receiver) || !receiver.canSee(onlinePlayer)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//removes the entity and display them
|
|
||||||
receiver.hidePlayer(onlinePlayer);
|
|
||||||
receiver.showPlayer(onlinePlayer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void register() {
|
|
||||||
if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.BOUNTIFUL_UPDATE)) {
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(this);
|
|
||||||
isRegistered = true;
|
|
||||||
} else {
|
|
||||||
ConsoleLogger.info("The hideTablist feature is not compatible with your minecraft version");
|
|
||||||
ConsoleLogger.info("It requires 1.8+. Disabling the hideTablist feature...");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unregister() {
|
|
||||||
ProtocolLibrary.getProtocolManager().removePacketListener(this);
|
|
||||||
isRegistered = false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,12 +15,10 @@ public class ProtocolLibService implements SettingsDependent {
|
|||||||
/* Packet Adapters */
|
/* Packet Adapters */
|
||||||
private AuthMeInventoryPacketAdapter inventoryPacketAdapter;
|
private AuthMeInventoryPacketAdapter inventoryPacketAdapter;
|
||||||
private AuthMeTabCompletePacketAdapter tabCompletePacketAdapter;
|
private AuthMeTabCompletePacketAdapter tabCompletePacketAdapter;
|
||||||
private AuthMeTablistPacketAdapter tablistPacketAdapter;
|
|
||||||
|
|
||||||
/* Settings */
|
/* Settings */
|
||||||
private boolean protectInvBeforeLogin;
|
private boolean protectInvBeforeLogin;
|
||||||
private boolean denyTabCompleteBeforeLogin;
|
private boolean denyTabCompleteBeforeLogin;
|
||||||
private boolean hideTablistBeforeLogin;
|
|
||||||
|
|
||||||
/* Service */
|
/* Service */
|
||||||
private boolean isEnabled;
|
private boolean isEnabled;
|
||||||
@ -44,12 +42,10 @@ public class ProtocolLibService implements SettingsDependent {
|
|||||||
if (protectInvBeforeLogin) {
|
if (protectInvBeforeLogin) {
|
||||||
ConsoleLogger.showError("WARNING! The protectInventory feature requires ProtocolLib! Disabling it...");
|
ConsoleLogger.showError("WARNING! The protectInventory feature requires ProtocolLib! Disabling it...");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (denyTabCompleteBeforeLogin) {
|
if (denyTabCompleteBeforeLogin) {
|
||||||
ConsoleLogger.showError("WARNING! The denyTabComplete feature requires ProtocolLib! Disabling it...");
|
ConsoleLogger.showError("WARNING! The denyTabComplete feature requires ProtocolLib! Disabling it...");
|
||||||
}
|
}
|
||||||
if (hideTablistBeforeLogin) {
|
|
||||||
ConsoleLogger.showError("WARNING! The hideTablist feature requires ProtocolLib! Disabling it...");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isEnabled = false;
|
this.isEnabled = false;
|
||||||
return;
|
return;
|
||||||
@ -70,13 +66,6 @@ public class ProtocolLibService implements SettingsDependent {
|
|||||||
tabCompletePacketAdapter.unregister();
|
tabCompletePacketAdapter.unregister();
|
||||||
tabCompletePacketAdapter = null;
|
tabCompletePacketAdapter = null;
|
||||||
}
|
}
|
||||||
if (hideTablistBeforeLogin && tablistPacketAdapter == null) {
|
|
||||||
tablistPacketAdapter = new AuthMeTablistPacketAdapter(plugin, bukkitService);
|
|
||||||
tablistPacketAdapter.register();
|
|
||||||
} else if (tablistPacketAdapter != null) {
|
|
||||||
tablistPacketAdapter.unregister();
|
|
||||||
tablistPacketAdapter = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isEnabled = true;
|
this.isEnabled = true;
|
||||||
}
|
}
|
||||||
@ -92,10 +81,6 @@ public class ProtocolLibService implements SettingsDependent {
|
|||||||
tabCompletePacketAdapter.unregister();
|
tabCompletePacketAdapter.unregister();
|
||||||
tabCompletePacketAdapter = null;
|
tabCompletePacketAdapter = null;
|
||||||
}
|
}
|
||||||
if (tablistPacketAdapter != null) {
|
|
||||||
tablistPacketAdapter.unregister();
|
|
||||||
tablistPacketAdapter = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,21 +105,9 @@ public class ProtocolLibService implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a tab list packet to a player.
|
|
||||||
*
|
|
||||||
* @param player The player to send the packet to.
|
|
||||||
*/
|
|
||||||
public void sendTabList(Player player) {
|
|
||||||
if (isEnabled && tablistPacketAdapter != null) {
|
|
||||||
tablistPacketAdapter.sendTablist(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings(NewSetting settings) {
|
public void loadSettings(NewSetting settings) {
|
||||||
this.protectInvBeforeLogin = settings.getProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN);
|
this.protectInvBeforeLogin = settings.getProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN);
|
||||||
this.denyTabCompleteBeforeLogin = settings.getProperty(RestrictionSettings.DENY_TABCOMPLETE_BEFORE_LOGIN);
|
this.denyTabCompleteBeforeLogin = settings.getProperty(RestrictionSettings.DENY_TABCOMPLETE_BEFORE_LOGIN);
|
||||||
this.hideTablistBeforeLogin = settings.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,10 +112,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
|||||||
restoreInventory(player);
|
restoreInventory(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN)) {
|
|
||||||
protocolLibService.sendTabList(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clean up no longer used temporary data
|
// Clean up no longer used temporary data
|
||||||
limboCache.deleteLimboPlayer(name);
|
limboCache.deleteLimboPlayer(name);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
@ -96,10 +95,6 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
|||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
LimboPlayer limbo = limboCache.getLimboPlayer(name);
|
LimboPlayer limbo = limboCache.getLimboPlayer(name);
|
||||||
if (limbo != null) {
|
if (limbo != null) {
|
||||||
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN)) {
|
|
||||||
protocolLibService.sendTabList(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils.teleportToSpawn(player);
|
Utils.teleportToSpawn(player);
|
||||||
|
|
||||||
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
||||||
|
@ -141,10 +141,6 @@ public class RestrictionSettings implements SettingsClass {
|
|||||||
public static final Property<Boolean> DENY_TABCOMPLETE_BEFORE_LOGIN =
|
public static final Property<Boolean> DENY_TABCOMPLETE_BEFORE_LOGIN =
|
||||||
newProperty("settings.restrictions.DenyTabCompleteBeforeLogin", true);
|
newProperty("settings.restrictions.DenyTabCompleteBeforeLogin", true);
|
||||||
|
|
||||||
@Comment("Should we hide the tablist before logging in? Requires ProtocolLib.")
|
|
||||||
public static final Property<Boolean> HIDE_TABLIST_BEFORE_LOGIN =
|
|
||||||
newProperty("settings.restrictions.HideTablistBeforeLogin", true);
|
|
||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"Should we display all other accounts from a player when he joins?",
|
"Should we display all other accounts from a player when he joins?",
|
||||||
"permission: /authme.admin.accounts"})
|
"permission: /authme.admin.accounts"})
|
||||||
|
@ -141,8 +141,6 @@ settings:
|
|||||||
ProtectInventoryBeforeLogIn: true
|
ProtectInventoryBeforeLogIn: true
|
||||||
# Should we deny the tabcomplete feature before logging in? Requires ProtocolLib.
|
# Should we deny the tabcomplete feature before logging in? Requires ProtocolLib.
|
||||||
DenyTabCompleteBeforeLogin: true
|
DenyTabCompleteBeforeLogin: true
|
||||||
# Should we hide the tablist before logging in? Requires ProtocolLib.
|
|
||||||
HideTablistBeforeLogin: true
|
|
||||||
# Should we display all other accounts from a player when he joins?
|
# Should we display all other accounts from a player when he joins?
|
||||||
# permission: /authme.admin.accounts
|
# permission: /authme.admin.accounts
|
||||||
displayOtherAccounts: true
|
displayOtherAccounts: true
|
||||||
|
Loading…
Reference in New Issue
Block a user