Search in sources :

Example 1 with MessageHandler

use of io.github.nucleuspowered.nucleus.modules.message.handlers.MessageHandler in project Nucleus by NucleusPowered.

the class MessageModule method performEnableTasks.

@Override
public void performEnableTasks() {
    createSeenModule(SocialSpyCommand.class, (cs, user) -> {
        MessageHandler handler = Nucleus.getNucleus().getInternalServiceManager().getServiceUnchecked(MessageHandler.class);
        boolean socialSpy = handler.isSocialSpy(user);
        boolean msgToggle = Nucleus.getNucleus().getUserDataManager().get(user).map(y -> y.get(MessageUserDataModule.class).isMsgToggle()).orElse(true);
        MessageProvider mp = plugin.getMessageProvider();
        List<Text> lt = Lists.newArrayList(mp.getTextMessageWithFormat("seen.socialspy", mp.getMessageWithFormat("standard.yesno." + Boolean.toString(socialSpy).toLowerCase())));
        getConfigAdapter().ifPresent(x -> lt.add(mp.getTextMessageWithFormat("seen.socialspylevel", String.valueOf(Util.getPositiveIntOptionFromSubject(user, MessageHandler.socialSpyOption).orElse(0)))));
        lt.add(mp.getTextMessageWithFormat("seen.msgtoggle", mp.getMessageWithFormat("standard.yesno." + Boolean.toString(msgToggle).toLowerCase())));
        return lt;
    });
}
Also used : Nucleus(io.github.nucleuspowered.nucleus.Nucleus) NucleusPrivateMessagingService(io.github.nucleuspowered.nucleus.api.service.NucleusPrivateMessagingService) Sponge(org.spongepowered.api.Sponge) SocialSpyCommand(io.github.nucleuspowered.nucleus.modules.message.commands.SocialSpyCommand) MessageUserDataModule(io.github.nucleuspowered.nucleus.modules.message.datamodules.MessageUserDataModule) MessageConfigAdapter(io.github.nucleuspowered.nucleus.modules.message.config.MessageConfigAdapter) ConfigurableModule(io.github.nucleuspowered.nucleus.internal.qsml.module.ConfigurableModule) List(java.util.List) Lists(com.google.common.collect.Lists) MessageProvider(io.github.nucleuspowered.nucleus.internal.messages.MessageProvider) MessageHandler(io.github.nucleuspowered.nucleus.modules.message.handlers.MessageHandler) Text(org.spongepowered.api.text.Text) RegisterService(io.github.nucleuspowered.nucleus.internal.annotations.RegisterService) Util(io.github.nucleuspowered.nucleus.Util) ModuleData(uk.co.drnaylor.quickstart.annotations.ModuleData) MessageProvider(io.github.nucleuspowered.nucleus.internal.messages.MessageProvider) MessageHandler(io.github.nucleuspowered.nucleus.modules.message.handlers.MessageHandler) MessageUserDataModule(io.github.nucleuspowered.nucleus.modules.message.datamodules.MessageUserDataModule) Text(org.spongepowered.api.text.Text)

Aggregations

Lists (com.google.common.collect.Lists)1 Nucleus (io.github.nucleuspowered.nucleus.Nucleus)1 Util (io.github.nucleuspowered.nucleus.Util)1 NucleusPrivateMessagingService (io.github.nucleuspowered.nucleus.api.service.NucleusPrivateMessagingService)1 RegisterService (io.github.nucleuspowered.nucleus.internal.annotations.RegisterService)1 MessageProvider (io.github.nucleuspowered.nucleus.internal.messages.MessageProvider)1 ConfigurableModule (io.github.nucleuspowered.nucleus.internal.qsml.module.ConfigurableModule)1 SocialSpyCommand (io.github.nucleuspowered.nucleus.modules.message.commands.SocialSpyCommand)1 MessageConfigAdapter (io.github.nucleuspowered.nucleus.modules.message.config.MessageConfigAdapter)1 MessageUserDataModule (io.github.nucleuspowered.nucleus.modules.message.datamodules.MessageUserDataModule)1 MessageHandler (io.github.nucleuspowered.nucleus.modules.message.handlers.MessageHandler)1 List (java.util.List)1 Sponge (org.spongepowered.api.Sponge)1 Text (org.spongepowered.api.text.Text)1 ModuleData (uk.co.drnaylor.quickstart.annotations.ModuleData)1