#spigot help

1 messages ยท Page 1 of 1 (latest)

vital knoll
#

I'm trying to use a method from a class in my onCommand listener

elfin blade
#

And multiple people have given you advice regarding this

#

I will repeat mine:

#

You should study a bit more OOP and make sure you understand how it works before attempting to write a plugin

#

"Accessing a method/variable from another class" is a common beginner question that demonstrates a fundamental misunderstanding of how object orientation works

elfin blade
#

Then you should know that you need to call a non-static method on an instance of a class, not the class itself

#

And that you will need to instantiate (or obtain) this instance

vital knoll
#

that's my code

elfin blade
#

Then you don't understand OOP in the right context, those languages' OOP implementations are nothing like java's

vital knoll
#

java is a weird language

elfin blade
#

Java has a much more rigid type system and more fleshed-out OOP because OOP was the entire point in java rather than an afterthought in language design

#

Python and js are the ones with weird OOP implementations

brave cedar
#

An issue with that code is that you'll have one global gui if you create one

elfin blade
#

You should learn more about java OOP before attempting to write plugins

#

It can be learned in a few hours to a few days and will be the foundation of all code you write in java

#

So it's very important

brave cedar
#

Once you understand OOP you'll need to understand HashMaps as well

#

Very useful for this context

vital knoll
#

but dont you agree that you learn from mistakes and erros you do ? im sure if i learn how to fix this then ill figure out the rest

elfin blade
#

You can't gain an understanding of OOP top-down

#

You have to start from the bottom

brave cedar
#

You'll learn best by learning the core structure of OOP. The issue at hand is by solving your problem you may not understand core functionality that will help in the long run

elfin blade
#

If you only understand the mechanics of it insofar as they enable you to make things work how you want them to, you will never be able to make conscious design decisions

vital knoll
brave cedar
#

I'm entirely self taught I don't really have any tutorials I can recommend. Others do but it really comes down to how one learns.

#

I kinda read the oracle docs

vital knoll
#

then how am i suppose to learn ๐Ÿคทโ€โ™‚๏ธ

brave cedar
#

If you like courses there are plenty out there

vital knoll
#

ok thanks

brave cedar
#

If you like videos there's lots but I like this guy https://www.youtube.com/c/CodingwithJohn/

vital knoll
#

I dont like articles, probably wont be useful for me

graceful lily
brave cedar
#

Got a ways to go before we reach DI

vital knoll
#

if that makes any sense

graceful lily
#

its a simple concept really

vital knoll
graceful lily
#

just pass your container class as a constructor parameter

vital knoll
#

thanks for that yall

#

!close

#

?close

#

$close

#

/close

elfin blade
#

-close

vital knoll
#

if only java could give debug info like go and python ๐Ÿ˜ฉ

#

aight ill just make the method in the same class

#

fixes everything