Skip to main content

Multi Sidebars

Providers

Now you know how to make a basic sidebar with a single provider, we also support multiple providers to enhance your plugin structure!

Let's say I want the sidebar to have different variants between 4 of the gamemodes, we can do that by creating multiple providers.


@InjectableComponent
public class SurvivalSidebarProvider implements SidebarProvider {
@Override
public @Nullable Component getTitle(@NotNull MCPlayer mcPlayer) {
return Component.text("You are playing in Survival mode!", NamedTextColor.GREEN);
}

@Override
public @Nullable List<SidebarLine> getLines(@NotNull MCPlayer mcPlayer) {
return Arrays.asList(
SidebarLine.of(Component.text("SURVIVAL", NamedTextColor.RED))
);
}

@Override
public boolean shouldDisplay(@NotNull MCPlayer mcPlayer) {
return mcPlayer.getGameMode() == GameMode.SURVIVAL;
}
}

multi-sidebars


Priority

Every sidebar provider contains a method to set the priority of the sidebar, the higher the priority, the higher the sidebar will be displayed. If one of the sidebar has been displayed, the sidebar with lower priority will be hidden.

@Override
public int getPriority() {
return 0;
}