Command Blocker?

Discussion in 'Plugin Development' started by razorkings, Feb 7, 2014.

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

    razorkings

    Hi, i been creating some custom plugins lately and i am stuck on this one no idea on how to make it like i want it to be so that if a player were to do a command for example:
    /plugins it will block them saying something like "Sorry, Only Operators Can See This" or something anyway you guys can give me like a full set up on how to code it or just send me the whole coding
     
  2. Offline

    HungerCraftNL

    Code:java
    1. @EventHandler
    2. public void onCommandPreProecess(PlayerCommandPreProcessEvent e){
    3. Player p = e.getPlayer();
    4. if(!p.isOp()){
    5. if(e.getMessage().equalsIgnoreCase("pl") || e.getMessage().equalsIgnoreCase("plugins")){
    6. e.setCancelled(true);
    7. p.sendMessage(ChatColor.RED + "You're not allowed to see the plugins!");
    8. }
    9. } else {
    10. String message = "";
    11. int index = 0;
    12. for(Plugin pl : Bukkit.getPluginManager().getPlugins()){
    13. if(index == 0){
    14. message = message.concat(pl.getName());
    15. } else {
    16. message = message.concat(ChatColor.GRAY + ", " + ChatColor.AQUA + pl.getName());
    17. }
    18. index++;
    19. }
    20. p.sendMessage(ChatColor.GOLD + "Plugins("+index+"):");
    21. p.sendMessage(message);
    22. }
     
    mastermustard likes this.
Thread Status:
Not open for further replies.

Share This Page