plugins priority

Discussion in 'Plugin Development' started by Danza, Mar 24, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Danza

    Hi, i have 2 plugins(plugins is my):
    1 - Authorization
    2 - AntiGreif

    Auth is simple authorize plugin - anjo is not good for me cuz players can use commands(towny) without registration + i need mysql. not matter.

    AntiGreif is like http://forums.bukkit.org/threads/admn-sec-guestprev-v1-4d-antigrief-guest-manager-527-560.5762/ but not the same. So...

    i need for AntiGreif block any command of any plugins for player before his not allowed.
    AntiGreif Plugin:


    Code:
    public void onPlayerCommandPreprocess(PlayerChatEvent event){
    if(plugin.isAllowed(player).getValue()!=1){
                p.sendMessage(ChatColor.RED + "U are not allowed so far.");
                event.setCancelled(true);
     }
    }
    +
    Code:
    pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Highest, this);
    but this not working for my Auth plugin... players can type /register or /login
    how to fix it?
     
  2. Offline

    Edward Hand

    How is your Auth plugin responding to commands? Is it using CommandPreprocess stuff or is it using the proper onCommand function?
     
  3. Offline

    Danza

    CommandPreprocess using in both plugins

    omg im noob? :( what the diff between CommandPreprocess and onCommand?

    ok, i think solved -
    pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Low, this);
    and in auth CommandPreprocess first line set if (event.isCancelled()) return;

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  4. Offline

    Edward Hand

    using onCommand is the 'proper' way to capture commands.

    You put a function like this in your main JavaPlugin class (with onEnable etc)
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
    {
    
    }
    and then have to register the command in your plugin yml like this:
    Code:
    commands:
      register:
        description: does registering or something
        usage:
      login:
        description: does logging in or something
        usage:
    Using CommandPreprocess is necessary for responding to commands in other plugins (not registered in your plugin.yml) as well as for cancelling commands. using CommandPreprocess is the right thing to do for your AntiGreif plugin but you should use onCommand for your Auth plugin (then it should work)

    EDIT: or your last post which I just missed works as a shortcut ;)
     
  5. Offline

    Danza

    ok thanks, where i can find example for onCommand? any plugin opensource. something simple?
     
Thread Status:
Not open for further replies.

Share This Page