What is a "proper" or better way to access variables or functions outside of the same class without using static? I know it's generally bad practice to use the static keyword but all of the tutorials I have watched have not shown an alternative.
For example, if I store player's stats in the main class and want to change or read them in a different class, how would I go about doing that?
Main:
public class Main extends JavaPlugin {
public HashMap<String, Integer> armour = new HashMap<>();
public HashMap<String, Integer> toughness = new HashMap<>();
public HashMap<String, Integer> money = new HashMap<>();
public static Main main;
@Override
public void onEnable(){
main = this;
}
}```
Other class:
```java
public class Events implements Listener {
@EventHandler
public void playerShift(PlayerToggleSneakEvent event){
String uuid = event.getPlayer().getUniqueId().toString();
Main.main.armour.put(uuid, Main.main.armour.get(uuid) + 1);
event.getPlayer().sendMessage(Main.main.armour.get(uuid) + "");
}
}```
This is how I have done it ^. But what I have heard, this is still static abuse. As well as this:
```java
public static Main getInstance(){
return this;
}```
So if using static is generally bad practice, how do I access anything outside of the same class?