java - Issues while trying to get another class -
i wrote getplugin()
method able main class class.
public class main extends javaplugin { public main getplugin() { homecoming this; } }
but when seek phone call it...
public class arena { private main plugin = main.getplugin(); }
...eclipse gives me next error:
cannot create static reference non-static method getplugin() type main
i have used static, static gives me issue's in lot of different places, , i've seen static bad way of doing stuff. causes memory leaks , stuff.
i have tried using getters , setters, need static too? code i've been using messy , i'd find cleaner way of accessing class.
if want avoid using static methods, need pass variables parameter constructor of objects. in example, work this:
public class arena { private final main plugin; public arena(plugin plugin) { this.plugin = plugin; } }
and can create arena main plugin class, , pass in this
parameter:
public class main extends javaplugin { @override public void onenable() { arena arena = new arena(this); } }
java eclipse bukkit
No comments:
Post a Comment