Development Assistance help with command whitelist plugin

Discussion in 'Plugin Help/Development/Requests' started by TImewalkerZ, Oct 26, 2015.

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

    TImewalkerZ

    So, I am trying to make a plugin what makes plugins look like they are invalid if they do not appear in the config. It does compile and run without errors but the plugin does not show invalid command when i do /fly (not in the config).

    Code:
    public class Main extends JavaPlugin
      implements Listener
    {
      FileConfiguration config;
    
      public void onEnable()
      {
        this.config = getConfig();
        this.config.addDefault("Commandslist", new String[] { "/plugins", "/essentials" });
        this.config.options().copyDefaults(true);
        saveConfig();
        getServer().getPluginManager().registerEvents(this, this);
      }
    
      @EventHandler
      public void onCommand(PlayerCommandPreprocessEvent e) {
        String cmd = e.getMessage();
        String msg = "§8[§c?§8] Unknown command. Please do §b/help§8 or contact a Staff Member for help.";
        for (String s : this.config.getStringList("Commandslist"))
          if (!(s.equalsIgnoreCase(cmd)) && !(e.getPlayer().hasPermission("commandhider.bypass"))) {
            e.setCancelled(true);
            e.getPlayer().sendMessage(msg);
            break;
          }
      }
    }
    Help and solutions will be much appreciated. :)
     
Thread Status:
Not open for further replies.

Share This Page