A Note for My Stupidity

I’ve been working on learning how to create plugins for Bukkit/Spigot for Minecraft servers. This has been a pain in the ass, and one thing that has kept me from achieving things is being able to read from a simple config file. That’s not special when you’re trying to get it from the main class, but from another class, it’s more difficult. There’s tons of ways people have for doing this, but I ran across the simplest damn method ever thought up ever. Other methods basically have you creating 2 different classes to read from and write to a config file. While that’s great for more advanced purposes, for me right now all I needed to do was access it. Besides, the other ways didn’t work. So what’d I do? This.

String vprefix = Main.getPlugin(Main.class).getConfig().getString("prefix");

The important part about that code is the Main.getPlugin(Main.class).getConfig().getString("blahblah");. It’s important because all it does is go to your main class, knock on the door, ask it to read from a file because that would be the neighborly thing to do, and then tell you what it is. That’s it. It’s that stupidly simple. No extra classes required.

Leave a Reply