-
Notifications
You must be signed in to change notification settings - Fork 1
Shared Utilities and API
It is better if we share our abstractions and not do everything independently.
#Plugin Components
The class PluginComponent contains helpers related to this plugin, and all components of this plugin should extend this class. It allows instances to access the plugin.
#Configurations
Please see the Spigot API documentation for basics of configurations. ECPlugin contains a configuration field, which stores all configurations loaded. ECPlugin will take care of loading, reloading, etc., so let it shine, and do not do this on your own. You can register your configurations in Configuration.
#Minecraft Commands
Each Minecraft command should have its own corresponding CommandExecutor. We have the AbstractCommandExecutor class which contains helpers etc., and all executors should extend from it. We also have the PlayerCommand class for commands which require sender to be a player.
Each module of the plugin (e.g. Bank module, Trading module) should have its own abstract subclass of the AbstractCommandExecutor to which the module's commands extend from.
A command must be registered in the Commands enum, and the enum must be registered with the corresponding executor (this is done in Commands and ECPlugin). Please find a better way. Maybe using Java annotations?
#Place
I think "Place" might be too unclear.
This contains typical fields an actual in-game 'place' should have, such as coordinates, name, and address. Contains helper such as locating the closest of such place to a location, etc. Extend this class if you want to create some place such as a Bank or a Market.
#Dank Batabase
Don't write SQLs on your own. Please abstract them in the database package. And create generic shareable method others can reuse. Should not let any class outside the database package deal with SQL stuff e.g. Exceptions and connections resource management.
An instance of th.in.mihome.economyCraft.CentralBank accessible from children of PluginComponent via local field plugin.getCentralBank() provides the central payment system to transfer funds between accounts of different entities. ALL higher level calls shall not go lower than this.
- deposit
- getAccountBalance
- getPlayer
- getPlayerId
- pay
- withdraw
th.in.mihome.economyCraft.database.Database plugin.getDb() provides direct access to the database.
#Items
See Convention.
ECItem represents a type of item, e.g. any diamond_sword.
ECItemStack is an item with a quantity value.
Equality tests (.equals(...) and ==) in these classes are supported.
#Exceptions
Awaiting standards from Lonny.
So far we have InvalidArgumentException for invalid Minecraft console inputs, NonPlayerException when command senders aren't players, and UnfulfilledRequirementException as the very general, mother of all exceptions. Abstractions such as module abstract command executors make use of these extensively to allow subclasses to work with assumptions gracefully. (Such as assuming sender is a player or assuming player is inside a Bank.)