mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-23 16:11:31 +01:00
Hide the inventory for online players on reload (Related #1709)
This commit is contained in:
parent
75e1e5ce51
commit
2f7672b489
@ -27,6 +27,8 @@ import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -63,8 +65,14 @@ class InventoryPacketAdapter extends PacketAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public void register() {
|
||||
public void register(BukkitService bukkitService, boolean hideNow) {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(this);
|
||||
|
||||
if (hideNow) {
|
||||
bukkitService.getOnlinePlayers().stream()
|
||||
.filter(player -> playerCache.isAuthenticated(player.getName()))
|
||||
.forEach(this::sendBlankInventoryPacket);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
|
@ -58,8 +58,9 @@ public class ProtocolLibService implements SettingsDependent {
|
||||
// Set up packet adapters
|
||||
if (protectInvBeforeLogin) {
|
||||
if (inventoryPacketAdapter == null) {
|
||||
// register the packet listener and start hiding it for all already online players (reload)
|
||||
inventoryPacketAdapter = new InventoryPacketAdapter(plugin, playerCache);
|
||||
inventoryPacketAdapter.register();
|
||||
inventoryPacketAdapter.register(bukkitService, true);
|
||||
}
|
||||
} else if (inventoryPacketAdapter != null) {
|
||||
inventoryPacketAdapter.unregister();
|
||||
|
Loading…
Reference in New Issue
Block a user