Solved Failure to block a command?

Discussion in 'Plugin Development' started by HeadGam3z, Jun 16, 2014.

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

    HeadGam3z

    So I'm trying to block certain commands while a boolean is true, so I used this:
    Code:java
    1. public class NoCmdEvent implements Listener {
    2.  
    3. public void guardUsedBlockedCmdEventWhileOnDuty(PlayerCommandPreprocessEvent e) {
    4. Player player = e.getPlayer();
    5. File folder = new File(Main.plugin.getDataFolder() + "/", "Data");
    6. File guardInfo = new File(folder, player.getUniqueId().toString() + ".yml");
    7. YamlConfiguration Guardconfig = YamlConfiguration
    8. .loadConfiguration(guardInfo);
    9. if (Guardconfig.getBoolean(player.getUniqueId() + " Duty") == true) {
    10. List<String> Commands = Main.plugin.getConfig().getStringList("BanCmds");
    11. for (String string : Commands) {
    12. if (e.getMessage().toLowerCase().startsWith("/" + string.toLowerCase())) {
    13. player.sendMessage("no");
    14. e.setCancelled(true);
    15. }
    16. }
    17. }
    18. }
    19. }
    20.  

    But it's not blocking any commands in my list:
    Code:
    BanCmds:
    - reload
    - home
    - spawn
    Any suggestions? No errors, no nuffin'. And yes, the event is registered.
     
  2. Offline

    Gater12

    HeadGam3z
    You forgot your @EventHandler annotation above your event method.
     
  3. Offline

    HeadGam3z

    lol... No idea how I missed that... Thank you, it works now! :)
     
Thread Status:
Not open for further replies.

Share This Page