Solved how to deny your commands overwriting other plugins

Discussion in 'Spigot Plugin Development' started by Nothing00, Jul 7, 2018.

Thread Status:
Not open for further replies.
  1. Hi, I need my plugin to be OVERWRITTEN by the other plugins both when you make an equal command for events, in practice as essentials that has the lowest priority. As far as I know you have to set the lowest priority on the events in fact I set all the events on LOWEST, but still users who use my plugin complain that my plugin always prevails over other commands and events .... what escapes me?
     
  2. If both plugins are at "lowest" then it's not certain which one will prevail. What you can do is add the ignoredCancelled = true option that force the event to be ignored if any other plugin cancels it.
     
    #2 darklazerog, Jul 7, 2018
    Last edited: Jul 7, 2018
  3. Priorities aren't all that intuitive to understand. Depending on how you look at them they can seem backwards. Unfortunately, the way you're looking at them is indeed backwards.

    Lowest priorities will fire first. High priorities fire last. This gives plugins with a higher priority to override something a plugin with lower priority has done to the event.

    So, lets say WorldGuard/GriefPrevention is cancelling the BlockPlaceEvent on Normal priority and you dont want to do anything in that case (like set a block down in a region/claim they dont have access to) then you want to listen on a higher priority and ignore the event if it was cancelled already.

    Code (Java):
    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onBlockPlace(BlockPlaceEvent event) {
        // stuffs
    }
    If you listened on a lower priority your action would happen without regard to what the other plugin is going to do.

    I know this seems backwards as hell (your plugin is actually higher priority to avoid conflicts), but thats just how it is. Once you can wrap your head around why priorities are named that way they'll make more sense to you. ;)
     
    • Agree Agree x 2
    • Winner Winner x 2
    • Like Like x 1
  4. Aint that what I said? With less detailed explanations? Pffff.
    *sarcasm*
     
    • Like Like x 1
  5. JanTuck

    Supporter

    Essentials uses the PlayerPreprocessCommand iirc to allow overrides.
     
  6. I'll try this way because it's the only one that stays with me even if I do not find much sense for what I have to do
     
  7. if you can try to explain you would save me a little 'time kindly and maybe it could be useful to users who read.
     
  8. @BillyGalbreath gave a pretty good explanation to your issue.
     
  9. unfortunately it did not work my plugin continues to overwrite others
     
  10. Updated code?
     
  11. Code (Java):
    @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
        public void onChat(PlayerChatEvent e){
              //...
            }
     
    • Funny Funny x 3
  12. I correct I have shown on the events but not for the commands if for example I insert a plugin that contains the command / ban when I do / ban takes that of my plugin and not the plugin I put ... I want the commands of my plugin are overwritten by plugins that have the same command
     
  13. You legit did the opposite of what I said..
     
    • Agree Agree x 1
  14. Like @BillyGalbreath said... you did the opposite. Try setting the priority to Highest (Monitor is the biggest you can go). Re-read Billy's previous post.
     
  15. I did exactly what I wanted to do is you who understood the opposite, however you did not answer my question, how can I make the commands of my plugin NOT overwrite those of others but on the contrary are they to be overwritten?
     
    • Funny Funny x 2
  16. This is what I meant when I said you are thinking about the priorities backwards from what they really mean. Please, re-read my post.
     
  17. I understood very well what you wrote but I have already solved on this point ... my question is now on the commands how can I make the same thing happen on the commands? for example I do / ban and I have two plugins that have this command based on what bukkit decides to make one of two work?
     
  18. Ok, that's a whole other ballgame. I cant remember if its first command to set an executor, or the last. But theres no easy way (that I'm aware of) to fix this.

    However, the server admin has a Commands.yml file where they can set aliases of specific commands to specific plugins.

    Like, if you have /ban and essential has /ban, the server admin can specify which plugin to use for /ban by doing something like this:
    Code (Text):

    aliases:
      ban:
      - essentials:ban $1-
    More information about Commands.yml can be found here.

    Now, there are other more complex ways you can solve this. Essentials has a way to do it (I havent seen how they do it, but I know its not easy). Someone else might have an idea on it. But thats the best I got for commands. The server admins need to take more responsibility for the things they install on their servers, imho.
     
    • Agree Agree x 1
  19. thank you very much for your answer unfortunately I'm not looking for simple things otherwise I would not have opened a post here :LOL:
    so you would not know how to do this thing directly to my plugin itself? Without the user having to go to put the commands.yml in short, exactly how does essentials?
     
  20. When multiple plugins have the same command Bukkit registers the one of the first plugin that is enabled. Use the command preprocessevent and check if the command is the command you are looking for, if yes set as executor of that command the class that you want. Nice and easy(Sono italiano)
     
Thread Status:
Not open for further replies.