Event and implement Cancellable; register your listener the standard Bukkit way.
SidebarShowEvent
SidebarShowEvent fires when a sidebar is about to be shown to a player. Cancelling it prevents the sidebar from appearing.
Use
getSidebar().isPlayerSidebar() or getSidebar().isSharedSidebar() to determine which type is being shown before acting on it.
AddMemberToTeamEvent
AddMemberToTeamEvent fires when a player or entity is about to be added to a team. Cancelling it prevents the member from being added.