Question: How to change loading order / Frage: Wie bestimmt man die Ladereihenfolge der Plugins

  • Hi there,

    maybe anyone has an idea for my problem. I have 2 Plugins that modify the chat / read the chat. Let's call them A and B. Plugin A is just a chat reader and consumes chat-input to send it to another location. Plugin B reads the chat too but in some cases re-routes the chat to another location if there was a certain prefix in the chat and then cancels the event, so no further chat Plugin should read this. The Problem is that Plugin A is loaded before Plugin B and so always reads the chat before it's getting processed and filtered by Plugin B.

    How can i guarantee that if - and only if - Plugin B is installed, it is always loaded before Plugin A but does not depend on it.


    Hallo zusammen,

    vielleicht hat einer von euch eine Idee zu meinem Problem. Ich habe jetzt 2 Plugins die den Chat lesen bzw. modifizieren. Nennen wir sie hier mal Plugin A und B. A ist nur ein chat Leser und sendet den chat ungefiltert "woanders" hin. Plugin B liest den chat auch aber routet den chat in manchen Fällen um wenn die nachricht mit einem speziellen präfix beginnt und beendet die event kette dann so das diesen chat (eigentlich) kein weiteres Plugin verarbeiten kann. Das Problem ist, das Plugin A immer vor Plugin B geladen wird und somit den chat liest bevor er von Plugin B ausgewertet und gefiltert wurde.

    Wie kann ich garantieren das wenn - und nur wenn - Plugin B installiert ist, dieses immer zuerst geladen wird ohne eine Abhängigkeit zwischen beiden zu haben.

    Viele Grüße,

  • Hi there,

    As far as I am aware plugins load alphabetically from the plugin directory.

    However, each plugin will have a listener for the onPlayerChatEvent and each plugin will receive the same chat event in the same game tick.

    By the time plugin B calls cancel the event the event has already been processed by plugin A.

    You could always use /someprefix for plugin B. That way plugin B uses onPlayerCommandEvent instead. Do your work with the "command" and if it's just a "chat command" broadcast to everyone?

  • I understand, so another idea, if there is a way to check for Plugin A like (IF B INSTALLED THEN) i could get around my issue.

    My Plugin B (GlobalIntercom - see Plugin Forum) uses the prefix # to determine that the following text goes into the "Global chat", so you might think i could just ignore messages that begin with # but there is also an optional switch that can be turned on that the Plugin remembers your last chat. For example:

    >Hello (local chat)
    >#Hello global (global chat)
    >Everybody okay? (global chat)
    >#%Can someone help me build?(local chat #% is a switch back to local)
    >i don't know where to start from (local chat)

    So even if Plugin A knows # is a prefix of Plugin B, it could not get the switch state, because there is A) a server flag for the default and B) a player override of this flag.

    My idea now:

    Plugin A -> onChat -> isBinstalled?B::getCurrentChatOf(message) -> if(chat!=local) => ignore

    Would this be possible? Without adding a dependency to A - it should run standalone if B is not installed

  • For what you want to do the load order doesn't matter at all since when the event is triggered the plugins are all already loaded if there are in the plugins folder.

    You can use getAllPlugins() and for loop through them to find if the one you want is there.

    Yeha i just found it in the API, i'll give it a try, thanks!

  • Ok it seems calling

    Plugin GlobalIntercom = getPluginByName("Omega Zirkel Global Intercom Plugin");

    does work fine. now i will find a way to filter correctly, thanks!

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!