Thank you if you can. The code works I just want to under sands these lines. Code (Text): private ServerInfo plugin; public FirstJoin(ServerInfo pl) { plugin = pl; Bukkit.getServer().getPluginManager().registerEvents(this, plugin); } Code (Text): public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) a Code (Text): new FirstJoin(this);
new FirstJoin(this); is calling the constructor which is taking an instance of what you put in and storing it in 'plugin' and its registering the event of itself.
Just learn java - it really helps. Do not get me wrong, sometimes understanding a program/algorithm can be hard, especially when you are dealing with pointers. But if you do not know how a constructor call looks, you should learn java's syntax.
This is your constructor, you are passing it an instance of the plugins main class (which extends JavaPlugin) and when a new 'FirstJoin' object is created, you register your events.
When I first learned PHP is took me some time to understand how arrays worked and how they could possibly be useful. I have to say, I can understand how he might not understand them. That said, constructors are basic Java.
Not knowing what a constructor is means you cant write anything at all Find a good guide to java basics. Not some shitty video that tells you what to copy, a real written guide that explains what everything is. Code (Java): public FirstJoin(ServerInfo pl) Constructors are methods that are used to create a new object of a class, they have the same name as the class and no return type. In this case, this is a constructor to make a FirstJoin object, and it looks like it has to be passed the main class of the plugin 'ServerInfo' (which is what new FirstJoin(this) does. 'this' is a variable that points to whatever class object it is used inside).
Many scattered answers, lemme break it down for you, and in return, I want you to go read a tutorial on OOP. Code (Text): private ServerInfo plugin; private Class variable; Code (Text): public FirstJoin(ServerInfo pl) { plugin = pl; Bukkit.getServer().getPluginManager().registerEvents(this, plugin); } /* Constructor public Class(Class variable) { } */ previously defined variable = anotherVariable; Class.getInstance().getAnotherInstance().registerSomething(instance, instance); Code (Text): public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) a public boolean variable(Class variable, Class variable, DataType variable, ClassArray variable) Code (Text): new FirstJoin(this); // 'new' keyword new Constructor(instance); This got really messy, didn't expect that. OP, hopefully this explains some of what you want. https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html https://docs.oracle.com/javase/tutorial/java/concepts/class.html https://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html https://stackoverflow.com/questions/5126082/what-exactly-is-an-instance-in-java https://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html Some OOP tutorials: https://docs.oracle.com/javase/tutorial/java/concepts/ http://www.aonaware.com/oop1.htm https://www.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBasics.html