Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hi, just wanted to comment on a post you made is this thread: https://www.spigotmc.org/threads/using-getstringlist-in-a-static-method.287621/#post-2773663
- Static isn't "dangerous" - it exists for a reason, to be used in the right places.
- By creating instances of your utility classes you are completely _destroying_ the whole point of utility classes - they exist as part of the class, not the object, and are completely.
- I'm not sure why you'd ever have utility classes set up like that by passing through a constructor, in fact the general rule is to have your utility classes marked as final with a private constructor to ensure no instances are constructed, as well as obviously making all fields and methods static.
- What you should do is get an instance of your plugin class _in_ your utility class and access the methods that way. That is to say:
- public final class SomeUtils
- {
- private SomeUtils() {}
- private static final SomePlugin PLUGIN = JavaPlugin.getPlugin(SomePlugin.class);
- public static Something getSomething(SomeArgs... args)
- {
- return PLUGIN.getSomething();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement