I do not know what to fill it with: main.preInit( ? )

Hello, in the GameStartedServerEvent event in my main class, I call a void with a crafting recipe. In my main class, the last line of the recipe was .build("saddle", this));, so I tried in the other class .build("saddle", main.preInit(??)));. But I don’t know what to fill in the brackets with ??.

main -> Main Class
preInit -> GameStartedServerEvent in the main class

You dont call main.preInit(). You need to get the plugin container from the main. Make sure you have a field like the following and then use that field.

@Inject
private PluginContainer container

Okay, I have that field now in my main and now?

You could put your main class instance into the other class with a constructor parameter of the other class. I recommend you to learn Java/programming first to make your life with Sponge plugins easier.

1 Like

Okay I got it working now. What is your definition of Java programming? I’ve read a basic book, I think that’s not enough. What do you think, how much I should learn Java before I should start with Sponge? By the way, thanks you for your help.

While you probably can quanitfy how much you need to learn of java before starting with Sponge. I would say when you feel comfortable with the terminology used as well as the topic of some of the more complex staples of Java such as Lamda and generics.

I understand that its a broad statement as it depends on what book you read to gain the terms. But to understand generics. You will need to understand Objects, Classes, Field variables and methods as well as manipulating the class to utilize the generics. As for Lamda thats more of a understanding on java behind the scenes and if you feel so comfortable that you could lecture a class on them, then i would say your ready

1 Like