Solved Method not working

Discussion in 'Spigot Plugin Development' started by Invaerne, May 17, 2017.

Thread Status:
Not open for further replies.
  1. Hi there,

    I'm having a small issue with getting the method to work.
    I'm aiming to create a config listener that would broadcast a message whenever the boolean is set to true.

    Any ideas on what could be possibly wrong with the code?

    Code (Text):
       
    public class ListenerClass   implements Listener
    {
         TestPoint plugin;

         public ListenerClass(TestPlugin plugin)
         {
           plugin.getServer().getPluginManager().registerEvents(this, plugin);
           this.configGetter = plugin;
         }


    @EventHandler
          public void configListener() {
           
          boolean enabledOne = this.plugin.getConfig().getBoolean("FirstEnabled");
          boolean enabledTwo = this.plugin.getConfig().getBoolean("SecondEnabled");
       
          if (enabledOne) {
           
              Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,new Runnable(){
               
                  @Override
                  public void run() {
                      Bukkit.getServer().broadcastMessage("Test");          
             
                  }
             
              }, 70L);
           
              }
          this.plugin.getConfig().set("FirstEnabled", Boolean.valueOf(true));
       
          }

    }
     
    #1 Invaerne, May 17, 2017
    Last edited: May 17, 2017
  2. You can't use @EventHandler like that, you're not supplying an event to begin with and there's no event for config manipulation.

    What are you trying to achieve by doing this?

    http://xyproblem.info/
     
  3. You are right, I just place it there after many unsuccessful attempts... an act of desperation :(
     
  4. Mas

    Mas

    Tell us what you are trying to accomplish - then we can attempt to help you.
     
Thread Status:
Not open for further replies.