Skip to content
This repository was archived by the owner on Jul 20, 2020. It is now read-only.

Commit 0ff0ee2

Browse files
committed
Update Guice info in README
1 parent 2a3b2f9 commit 0ff0ee2

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,17 @@ the former Overcast Network.
164164
* We use Guice everywhere. You will need to [understand it thoroughly](https://github.com/google/guice/wiki/Motivation).
165165
* Follow the Guice [best practices](https://github.com/google/guice/wiki/InjectOnlyDirectDependencies) (especially that one).
166166
* We sometimes use the term "manifest" in place of "module", to avoid confusion with PGM modules.
167-
* Using Guice in a Bukkit plugin environment has proven to be [somewhat complex](https://github.com/OvercastNetwork/Plugins/blob/master/Util/core/src/main/java/tc/oc/commons/core/plugin/InjectedPluginLoader.java).
168-
You don't have to understand all of that, but there are a few things you should know:
169-
* Each plugin has its own [private module](https://google.github.io/guice/api-docs/latest/javadoc/index.html?com/google/inject/PrivateModule.html)
167+
* We make good use of SportBukkit's built-in Guice support:
168+
* Each plugin has its own [private environment](https://github.com/OvercastNetwork/minecraft-api/blob/master/src/main/java/tc/oc/inject/ProtectedModule.java)
170169
in which most of its bindings live.
171170
* Each plugin instance is bound to `org.bukkit.plugin.Plugin` inside its private module.
172171
* Anything that indirectly depends on `Plugin` will need to be bound in some plugin's private module.
173172
* If other plugins need access to that thing, it needs to be [exposed](https://google.github.io/guice/api-docs/latest/javadoc/com/google/inject/PrivateModule.html#expose-com.google.inject.Key-).
174173
* Avoid depending on `Plugin` directly. There are specific bindings for most Bukkit service types (e.g. `Configuration`)
175174
and several interfaces of our own that wrap small parts of the Bukkit API (e.g. `BukkitEventBus`).
176175
* If you really need a `Plugin`, always inject the base interface, never a specific plugin's class. This makes it easy to move things between plugins.
177-
* If the same `@Singleton` type is provisioned in multiple plugins, we will detect it and throw an exception.
178-
If you actually want a per-plugin singleton, make it `@PluginScoped`.
179-
* `PluginFacet`s are service objects registered with a specific plugin to share its lifecycle callbacks (i.e. enable() and disable()).
180-
They are also registered automatically in the appropriate way if they implement various interfaces such as `Listener` (see the javadocs for details).
176+
* A `@Singleton` bound in a private environment (e.g. a plugin's private environment) will only be unique within that environment,
177+
not the entire process, so be careful not to accidentally duplicate a singleton in multiple private environments.
181178
* Exceptions
182179
* Detect errors as early as possible, ideally at server startup. This applies to both user errors and internal assertions.
183180
* Only catch specific exceptions that you are expecting and can handle thoroughly. Don't hide exceptions that other handlers need to know about.

0 commit comments

Comments
 (0)