Classes and objects
Blueprints and the things built from them, the heart of Java and of every plugin.
This page is still being written.
What it will cover
- Class = blueprint, object = thing built from it (diagram: one Zombie class, many zombie objects)
- Fields, constructors, this, new, methods using fields
- Encapsulation: private fields with getters and setters, and why
- toString, equals intro
- static vs instance in depth (shared vs per object)
- Objects are references: two variables pointing at one object; null
- Multi-file program example (folder with Main.java + Wallet.java) to show one class per file
- Records as short data classes (link enums-records)
- How Paper uses objects: Player, ItemStack, Location are objects with methods; your plugin class is an object the server creates
- Exercise: build a Kit class with a name and a list of item names