java - The method getConfig() is undefined for the type Signs -


when try config test if equals null, error saying

the method getconfig() undefined type signs

i have no errors in other class, , don't know problem is. here current code:

public class signs implements listener {      @eventhandler     public void onsignchange(signchangeevent e) {         if (e.getline(0).equalsignorecase("[shop]")) {             block attached = e.getblock().getrelative(0, -1, 0);             string name = e.getplayer().getdisplayname();             if (!(attached.gettype() == material.chest))                 e.getplayer().sendmessage(chatcolor.red + "please place shop on chest!");             else {                 if (!e.getplayer().haspermission("shops.create"))                     e.getplayer().sendmessage(chatcolor.red + "you don't have permission create shop! (shops.create)");                 else {                     if (!arrays.aslist("open", "closed").contains(e.getline(1).tolowercase())) {                         e.getplayer().sendmessage(chatcolor.red + "you must specify if shop open or closed on second line!");                     } else {                         boolean closed = true;                         if ("open".equalsignorecase(e.getline(1))) {                             closed = false;                         }                          string linethree = closed ? "§cclosed" : "§aopen";                         e.setline(3, linethree);                         e.setline(0, "§9[shop]");                         e.setline(1, "§b" + name + "'s");                         e.setline(2, "§bshop");                         e.getplayer().sendmessage(chatcolor.green + "shop created!");                         e.getplayer().playsound(e.getplayer().getlocation(), sound.level_up, 10, 10);                         if(getconfig().getstringlist(name) == null);                      }                 }             }         }     }      @eventhandler     public void onplayerinteract(playerinteractevent e) {         if (e.getaction().equals(action.right_click_block)) {             player p = e.getplayer();             block b = e.getclickedblock();             block = b.getrelative(0, -1, 0);             int ax = a.getx();             int ay = a.gety();             int az = a.getz();             material m = b.gettype();             if (!(m == material.sign_post)) {                 return;             } else {                 sign sign = (sign) e.getclickedblock().getstate();                 if ((sign.getline(0).equalsignorecase("§9[shop]"))) {                     if ((sign.getline(3).equalsignorecase("§aopen"))) {                         p.sendmessage("i opened shop!");                         world world = e.getplayer().getworld();                         location chestlocation = new location(world, ax, ay, az);                      }                 }             }         }     } } 

getconfig() method implemented javaplugin. in order use it, have have instance of whichever class extends javaplugin (this class called main).

in main class, add static variable contains configuration file, , initialized onenable()

public class main extends javaplugin{      public static fileconfiguration config;      @override     public void onenable(){         config = getconfig();          //other code in onenable()     } } 

then, can use variable main.config anywhere outside of main class use plugin's configuration file

public class signs implements listener {      @eventhandler     public void onsignchange(signchangeevent e){         //your code         if(main.config.getstringlist(name) == null){             //...         }     } } 

also, make sure set config variable null in ondisable() prevent memory leaks occur if server reloaded

public class main extends javaplugin{      public static fileconfiguration config;      @override     public void ondisable(){         config = null;          //other code in ondisable()     } } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -