calling methods onenable and dissable?

Discussion in 'Plugin Development' started by 1337, Jan 26, 2011.

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

    1337

    how do you call methods on enable and disable when i do this
    Code:
    public void onEnable() {
            // TODO: Place any custom enable code here including the registration of any events
           load();
            // Register our events
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
            pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
            pm.registerEvent(Event.Type.ENTITY_DAMAGED, playerListener, Priority.Normal, this);
            pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_BLOCK, playerListener, Priority.Normal, this);
            pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, playerListener, Priority.Normal, this);
            pm.registerEvent(Event.Type.ENTITY_DEATH, playerListener, Priority.Normal, this);
            PluginDescriptionFile pdfFile = this.getDescription();
    
            System.out.println("[INFO] " + pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
        }
    it errors and also is ondissable called when the server shuts down?
     
  2. Offline

    Fifteen

    Never say "it shows an error" when you need help. Instead, please tell us what the error says. onDisable() is not called when the server shuts down.
     
  3. Offline

    1337

    here
    [​IMG]
    --- merged: Jan 27, 2011 8:41 PM ---
    is there not an event that calls when the server shuts down then?
     
  4. Offline

    Reil

    That red burns the eyes, please just copy/paste from a log. Use pastebin or something.

    Your problem is that your load() function, whatever it is, is giving a NullPointerException. Fix it. Line 95.
     
  5. Offline

    1337

    line 95 is just an } this is my load
    Code:
      public void load(){
            r.loadsettings();
            r.loadplayers();
        }
    and here is the loadplayers and loadsettings
    Code:
    MclsPlayerListener pl;
        MclsBlockListener bl;
        String name =  pl.loginname;
        public void loadsettings(){
    
              //create an instance of properties class
    
              Properties props = new Properties();
    
              //try retrieve data from file
                 try {
    
                 props.load(new FileInputStream(Mcls.Directory + "mclssettings.properties"));
    
                 pl.one = props.getProperty("1");
                 pl.two = props.getProperty("2");
                 pl.three = props.getProperty("3");
                 pl.four = props.getProperty("4");
                 pl.five = props.getProperty("5");
    
                 bl.Diamond = props.getProperty("diamond");
                 bl.Iron = props.getProperty("iron");
                 bl.Redstone = props.getProperty("redstone");
                 bl.Coal = props.getProperty("coal");
                 bl.Gold = props.getProperty("gold");
                 bl.LapisLazuli = props.getProperty("Lapis Lazuli");
    
                 pl.Creeper = props.getProperty("creeper");
                 pl.Spider = props.getProperty("spider");
                 pl.Skeliton = props.getProperty("skeliton");
                 pl.Zombie = props.getProperty("zombie");
                 pl.Player = props.getProperty("player");
    
                 pl.Ondeath = props.getProperty("ondeath");
    
                 }
    
                 //catch exception in case properties file does not exist
    
                 catch(IOException e)
                 {
                 e.printStackTrace();
                 System.out.println("error loading mclssettings.properties does it exist?");
                 }
         }
    public void loadplayers(){
    
    //try retrieve data from file
                try {
               BufferedReader br = new BufferedReader(new FileReader(Mcls.Directory + "mclsplayer.txt"));
               String curLine;
    
               while ((curLine = br.readLine()) != null){
                   StringTokenizer strTok = new StringTokenizer(curLine, ":");
                   if (strTok.nextToken().equals(name)){
                    String Level  = strTok.nextToken();
                     level = Integer.parseInt(Level);
                String Nextlvl = strTok.nextToken();
                nextlvl = Integer.parseInt(Nextlvl);
                String Prestige = strTok.nextToken();
                int prestige = Integer.parseInt(Prestige);
                // Here you can do whatever you want with the rest of the tokens. Just use strTok.nextToken() to get the rest of the token, split by colons.
                   }
               }
           // This catches all the exceptions. You can go more in detail here if you want.
           } catch(Exception e){
               e.printStackTrace();
               System.out.println("error reading the mclsplayer.txt file. does it exist?");
           }
           }
    
    --- merged: Jan 29, 2011 11:44 AM ---
    bump :(
    --- merged: Jan 29, 2011 3:43 PM ---
    help?
     
Thread Status:
Not open for further replies.

Share This Page