Disabling /pl

Discussion in 'Plugin Development' started by FOEVERWAR73, Jul 25, 2014.

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

    FOEVERWAR73

    Hello, I am Derpy, I have a problem, I need to disable /pl, but I can't get a way to do that, can someone help me?
     
  2. Offline

    Garris0n

    Permissions?
     
  3. Offline

    FOEVERWAR73

    I don't want to use permissions since the message doesn't look nice, Garris0n I want to use PlayerChatEvents, Can you help?
     
  4. Offline

    jimbo8

    Override the /pl and /plugins command.
     
  5. Offline

    FOEVERWAR73

    Code? I don't seem to find out a way to do that...my code isn't valid...
    Code:java
    1. @EventHandler
    2. public void pl(PlayerChatEvent e){
    3. Player p = e.getPlayer();
    4. if(e.getMessage().toLowerCase().contains("/pl")){
    5. e.setCancelled(true);
    6. p.sendMessage(ChatColor.GREEN+"Message!");
    7. }
    8. }
     
  6. Offline

    ZodiacTheories

    FOEVERWAR73

    Listen to the PlayerCommandPreProccessEvent instead
     
  7. Offline

    FOEVERWAR73

    Can you help me with the code? Please?
     
  8. Offline

    jimbo8

    ...or make a new command that is named exactly the same as /pl and /plugins. You basically create a new command like every other command to override it.
     
  9. Offline

    DannyDog

    Code:java
    1. @EventHandler
    2. public void onPlugin(PlayerCommandPreprocessEvent event) {
    3. if (event.getMessage().startsWith("/pl")) {
    4. event.setCancelled(true);
    5. }
    6. }

    Read the bukkitdocs.
     
  10. Offline

    fireblast709

  11. Offline

    DannyDog

    fireblast709
    Yes, well then you can just use .contentsEquals() but you'd need to have it for both /pl and /plugins.
    There are other ways, but that was the way I do it because I don't have any other commands that start with /pl lel.
     
  12. Offline

    fireblast709

    DannyDog with split (and optionally substring for the /) you can get the command label. Then check for plugins, pl, bukkit: plugins, bukkit: pl, ? and bukkit:? (afaik all of them had the bukkit: fallback prefix, also ignore the spaces between : and p, its to prevent emoticons)
     
  13. Offline

    DannyDog

    fireblast709
    That's how I'm doing it to disable /bukkit: commands.
    Using split
     
  14. Offline

    macboinc

    I created a command called /pl or /plugins and used the @Override annotation, well, at least that works for me.
     
Thread Status:
Not open for further replies.

Share This Page