Search in sources :

Example 51 with Subscribe

use of com.google.common.eventbus.Subscribe in project quorrabot by GloriousEggroll.

the class EventWebSocketServer method sendToAll.

@Subscribe
public void sendToAll(Event event) {
    Collection<WebSocket> con = connections();
    synchronized (con) {
        for (WebSocket c : con) {
            try {
                Method output = event.getClass().getMethod("toEventSocket", (Class<?>[]) null);
                c.send(event.getClass().getSimpleName() + ":" + output.invoke(event, (Object[]) null));
            } catch (Exception ex) {
                return;
            }
        }
    }
}
Also used : Method(java.lang.reflect.Method) WebSocket(org.java_websocket.WebSocket) Subscribe(com.google.common.eventbus.Subscribe)

Example 52 with Subscribe

use of com.google.common.eventbus.Subscribe in project trex-stateless-gui by cisco-system-traffic-generator.

the class MainViewController method handleScapyClientNeedConnectEvent.

@Subscribe
public void handleScapyClientNeedConnectEvent(ScapyClientNeedConnectEvent event) {
    LogsController.getInstance().getView().setDisable(false);
    if (!ConnectionManager.getInstance().isScapyConnected()) {
        ConnectionsWrapper connection = (ConnectionsWrapper) XMLFileManager.loadXML("connections.xml", ConnectionsWrapper.class);
        Connection lastUsed = null;
        for (Connection con : connection.getConnectionList()) {
            if (con.isLastUsed()) {
                lastUsed = con;
            }
        }
        if (lastUsed == null) {
            ConnectionManager.getInstance().connectScapy();
        } else {
            ConnectionManager.getInstance().connectScapy(lastUsed.getIp(), lastUsed.getScapyPort());
        }
        if (!ConnectionManager.getInstance().isScapyConnected()) {
            openConnectDialog();
        }
        if (ConnectionManager.getInstance().isScapyConnected()) {
            eventBus.post(new InitPacketEditorEvent());
            return;
        }
    }
}
Also used : ConnectionsWrapper(com.exalttech.trex.ui.models.datastore.ConnectionsWrapper) Connection(com.exalttech.trex.ui.models.datastore.Connection) InitPacketEditorEvent(com.xored.javafx.packeteditor.events.InitPacketEditorEvent) Subscribe(com.google.common.eventbus.Subscribe)

Example 53 with Subscribe

use of com.google.common.eventbus.Subscribe in project jabref by JabRef.

the class SpecialFieldUpdateListener method listen.

@Subscribe
public void listen(FieldChangedEvent fieldChangedEvent) {
    // only sync if keyword sync is enabled
    if (!Globals.prefs.isKeywordSyncEnabled()) {
        return;
    }
    final BibEntry entry = fieldChangedEvent.getBibEntry();
    final String fieldName = fieldChangedEvent.getFieldName();
    // Source editor cycles through all entries
    // if we immediately updated the fields, the entry editor would detect a subsequent change as a user change
    // and re-fire this event
    // e.g., "keyword = {prio1}, priority = {prio2}" and a change at keyword to prio3 would not succeed.
    SwingUtilities.invokeLater(() -> {
        if (FieldName.KEYWORDS.equals(fieldName)) {
            SpecialFieldsUtils.syncSpecialFieldsFromKeywords(entry, Globals.prefs.getKeywordDelimiter());
        } else if (SpecialField.isSpecialField(fieldName)) {
            SpecialFieldsUtils.syncKeywordsFromSpecialFields(entry, Globals.prefs.getKeywordDelimiter());
        }
        SwingUtilities.invokeLater(() -> JabRefGUI.getMainFrame().getCurrentBasePanel().updateEntryEditorIfShowing());
    });
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) Subscribe(com.google.common.eventbus.Subscribe)

Example 54 with Subscribe

use of com.google.common.eventbus.Subscribe in project jabref by JabRef.

the class DBMSSynchronizer method listen.

/**
     * Listening method. Updates an existing shared {@link BibEntry}.
     *
     * @param event {@link FieldChangedEvent} object
     */
@Subscribe
public void listen(FieldChangedEvent event) {
    // In this case DBSynchronizer should not try to update the bibEntry entry again (but it would not harm).
    if (isPresentLocalBibEntry(event.getBibEntry()) && isEventSourceAccepted(event) && checkCurrentConnection()) {
        synchronizeLocalMetaData();
        BibEntry bibEntry = event.getBibEntry();
        synchronizeSharedEntry(bibEntry);
        // Pull changes for the case that there were some
        synchronizeLocalDatabase();
    }
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) Subscribe(com.google.common.eventbus.Subscribe)

Example 55 with Subscribe

use of com.google.common.eventbus.Subscribe in project MantaroBot by Mantaro.

the class ActionCmds method register.

@Subscribe
public void register(CommandRegistry cr) {
    // pat();
    cr.register("pat", new ImageActionCmd("Pat", "Pats the specified user.", Color.PINK, "pat", EmoteReference.TALKING + "%s you have been patted by %s", "pat", "Aww, I see you are lonely, take a pat <3"));
    // hug();
    cr.register("hug", new ImageActionCmd("Hug", "Hugs the specified user.", Color.PINK, "hug", EmoteReference.TALKING + "%s you have been hugged by %s", "hug", "Aww, I see you are lonely, take a hug <3"));
    // kiss();
    cr.register("kiss", new ImageActionCmd("Kiss", "Kisses the specified user.", Color.PINK, "kiss", EmoteReference.TALKING + "%s you have been kissed by %s", "kiss", "Aww, I see you are lonely, *kisses*"));
    // poke();
    cr.register("poke", new ImageActionCmd("Poke", "Pokes the specified user.", Color.PINK, "poke", EmoteReference.TALKING + "%s you have been poked by %s :eyes:", "poke", "Aww, I see you are lonely, *pokes you*"));
    // slap();
    cr.register("slap", new ImageActionCmd("Slap", "Slaps the specified user ;).", Color.PINK, "slap", EmoteReference.TALKING + "%s you have been slapped by %s!", "slap", "Hmm, why do you want this? Uh, I guess... *slaps you*"));
    // bite();
    cr.register("bite", new ImageActionCmd("Bite", "Bites the specified user.", Color.PINK, "bite", EmoteReference.TALKING + "%s you have been bitten by %s :eyes:", "bite", "*bites you*"));
    // tickle();
    cr.register("tickle", new ImageActionCmd("Tickle", "Tickles the specified user.", Color.PINK, "tickle", EmoteReference.JOY + "%s you have been tickled by %s", "tickle", "*tickles you*"));
    // highfive();
    cr.register("highfive", new ImageActionCmd("Highfive", "Highfives with the specified user.", Color.PINK, "highfive", EmoteReference.TALKING + "%s highfives %s :heart:", "highfive", "*highfives*", true));
    // pout();
    cr.register("pout", new ImageActionCmd("Pout", "Pouts at the specified user.", Color.PINK, "pout", EmoteReference.TALKING + "%s pouts at %s *hmph*", "pout", "*pouts, hmph*", true));
    // teehee()
    cr.register("teehee", new ImageActionCmd("Teehee", "Teehee~", Color.PINK, "teehee", EmoteReference.EYES + "%s is teasing %s", "teehee", "*teases you*", true));
    // smile()
    cr.register("smile", new ImageActionCmd("Smile", "Smiles at someone", Color.PINK, "smile", EmoteReference.TALKING + "%s is smiling at %s :heart:", "smile", "*smiles at you*", true));
    // stare()
    cr.register("stare", new ImageActionCmd("Stare", "Stares at someone", Color.PINK, "stare", EmoteReference.EYES + "%s is staring at %s", "stare", "*stares you*", true));
    // holdhands()
    cr.register("holdhands", new ImageActionCmd("Hold Hands", "Hold someone's hands", Color.PINK, "holdhands", EmoteReference.HEART + "%s is holding %s's hand", "handholding", "*holds your hand*", true));
    // cuddle()
    cr.register("cuddle", new ImageActionCmd("Cuddle", "Cuddles someone", Color.PINK, "cuddle", EmoteReference.HEART + "%s you have been cuddled by %s", "cuddle", "*cuddles you*"));
    // greet();
    cr.register("greet", new TextActionCmd("Greet", "Sends a random greeting", Color.DARK_GRAY, EmoteReference.TALKING + "%s", GREETINGS.get()));
    // tsundere();
    cr.register("tsundere", new TextActionCmd("Tsundere Command", "Y-You baka!", Color.PINK, EmoteReference.MEGA + "%s", TSUNDERE.get()));
    // nuzzle()
    cr.register("nuzzle", new ImageActionCmd("Nuzzle Command", "Nuzzles the specified user.", Color.PINK, "nuzzle", EmoteReference.TALKING + "%s is nuzzling %s", NUZZLE.get(), "*nuzzles you*", true));
    // bloodsuck()
    cr.register("bloodsuck", new ImageActionCmd("Bloodsuck command", "Sucks the blood of an user", Color.PINK, "bloodsuck", EmoteReference.TALKING + "%s is sucking the blood of %s!", BLOODSUCK.get(), "J-Just how am I meant to? Oh well.. *sucks your blood*", true));
    // lewd()
    cr.register("lewd", new ImageCmd("Lewd", "T-Too lewd!", "lewd", "lewd", "Y-You lewdie!"));
    // meow()
    cr.register("meow", new ImageCmd("Meow", "Meows at the specified user.", "meow", MEOW.get(), "Meow."));
    cr.registerAlias("meow", "mew");
    // nom()
    cr.register("nom", new ImageCmd("Nom", "*nom nom*", "nom", "nom", "Yummy."));
    // facedesk()
    cr.register("facedesk", new ImageCmd("Facedesk", "When it's just too much to handle.", "facedesk", "banghead", "*facedesks*", true));
}
Also used : ImageActionCmd(net.kodehawa.mantarobot.commands.action.ImageActionCmd) ImageCmd(net.kodehawa.mantarobot.commands.action.ImageCmd) TextActionCmd(net.kodehawa.mantarobot.commands.action.TextActionCmd) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Subscribe (com.google.common.eventbus.Subscribe)179 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)46 SimpleCommand (net.kodehawa.mantarobot.core.modules.commands.SimpleCommand)44 MessageEmbed (net.dv8tion.jda.core.entities.MessageEmbed)29 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)26 MantaroData (net.kodehawa.mantarobot.data.MantaroData)25 List (java.util.List)23 Category (net.kodehawa.mantarobot.core.modules.commands.base.Category)22 Utils (net.kodehawa.mantarobot.utils.Utils)22 CommandRegistry (net.kodehawa.mantarobot.core.CommandRegistry)21 Module (net.kodehawa.mantarobot.core.modules.Module)21 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)18 TimeUnit (java.util.concurrent.TimeUnit)16 Collectors (java.util.stream.Collectors)16 MantaroBot (net.kodehawa.mantarobot.MantaroBot)15 Player (net.kodehawa.mantarobot.db.entities.Player)15 DiscordUtils (net.kodehawa.mantarobot.utils.DiscordUtils)15 RateLimiter (net.kodehawa.mantarobot.utils.commands.RateLimiter)14 SubCommand (net.kodehawa.mantarobot.core.modules.commands.SubCommand)13 DBGuild (net.kodehawa.mantarobot.db.entities.DBGuild)13