-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
- Don't statically fetch the plugin instance, use dependency injection instead (pass it through the constructor, as a parameter)
- Do mind the random imports.
- Don't use public on fields unless they're final & immutable (or at least, 99% of the time).
- Do use == for enum comparison (the enum class does this in it's equals method anyway, but == is null safe).
- Do prefer
if (!statement) { return; } // rest of code
overif (statement) { // rest of code }
as it reduces nesting depth by a great deal (EDIT: some classes seem to use it, some don't). - Sometimes there's still section signs, try to stick to ChatColor.
- Do avoid asynchronous tasks for small things, and absolutely do avoid them when Bukkit / Minecraft is involved and it's not guaranteed to be thread safe.
- Do prefer Runnables over BukkitRunnable if you're not using the cancel() method. (this means you should probably use it in all cases of runTask and runTaskLater).
- Liskov Substitution Principle! Program against abstractions rather than implementations (i.e. use List rather than ArrayList, Set rather than HashSet, Map rather than HashMap, etc, when choosing a type for a variable, parameter or field).
- Sets are faster than Lists. Importing a List once and converting it to a Set will give you a nice performance boost if your List gets large.
And sometimes a few spelling errors which I cannot bother to link (but who cares about that, the compiler sure doesn't).
Still, probably one of the cleaner tutorials I've seen online.
[EDIT] Seems it doesn't like multiline codeblocks in lists :/
Metadata
Metadata
Assignees
Labels
No labels