use of io.github.nucleuspowered.nucleus.api.events.NucleusFirstJoinEvent in project Nucleus by NucleusPowered.
the class CoreListener method onPlayerJoinLast.
@Listener
public void onPlayerJoinLast(final ClientConnectionEvent.Join event, @Getter("getTargetEntity") final Player player) {
if (Nucleus.getNucleus().getUserDataManager().get(player).map(x -> x.get(CoreUserDataModule.class).isFirstPlay()).orElse(true)) {
NucleusFirstJoinEvent firstJoinEvent = new OnFirstLoginEvent(event.getCause(), player, event.getOriginalChannel(), event.getChannel().orElse(null), event.getOriginalMessage(), event.isMessageCancelled(), event.getFormatter());
Sponge.getEventManager().post(firstJoinEvent);
event.setChannel(firstJoinEvent.getChannel().get());
event.setMessageCancelled(firstJoinEvent.isMessageCancelled());
Nucleus.getNucleus().getUserDataManager().getUnchecked(player).get(CoreUserDataModule.class).setStartedFirstJoin(false);
}
// Warn about wildcard.
if (!ServiceChangeListener.isOpOnly() && player.hasPermission("nucleus")) {
MessageProvider provider = this.plugin.getMessageProvider();
Nucleus.getNucleus().getLogger().warn("The player " + player.getName() + " has got either the nucleus wildcard or the * wildcard " + "permission. This may cause unintended side effects.");
if (this.warnOnWildcard) {
// warn
List<Text> text = Lists.newArrayList();
text.add(provider.getTextMessageWithFormat("core.permission.wildcard2"));
text.add(provider.getTextMessageWithFormat("core.permission.wildcard3"));
if (this.url != null) {
text.add(provider.getTextMessageWithFormat("core.permission.wildcard4").toBuilder().onClick(TextActions.openUrl(this.url)).build());
}
text.add(provider.getTextMessageWithFormat("core.permission.wildcard5"));
Sponge.getServiceManager().provideUnchecked(PaginationService.class).builder().title(provider.getTextMessageWithFormat("core.permission.wildcard")).contents(text).padding(Text.of(TextColors.GOLD, "-")).sendTo(player);
}
}
}
Aggregations