Running File retrieval from Playerlistener

Discussion in 'Plugin Development' started by MarkusNemesis, Jan 15, 2011.

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

    MarkusNemesis

    Hey folks,

    I am wondering how i can execute a file read from within the PlayerListener?

    I know how to read files, but i just need somewhere that will be executed, much like the "onEnable" main java file.

    being a total noob at Java and only having done a year on C++, i'm not the brightest in this field.

    Cheers,
     
  2. Offline

    cppchriscpp

    Why can't you just do it in the onEnable method? You can have stuff in your main class that can be used and modified by stuff in other classes.
     
  3. Offline

    MarkusNemesis

    Being a total noob at Java, how would i refer from one class to the other?
     
  4. Your listener will already have a reference to your plugin class

    Code:
    public class ListenerName extends PlayerListener {
        private final PluginName plugin;
    
        public ListenerName(PluginName instance) {
            plugin = instance;
        }
    You can access the public properties and methods of the plugin by doing plugin.whatever.
    Alternately you could load the file in the constructor of your Listener.
     
Thread Status:
Not open for further replies.

Share This Page