This repository was archived by the owner on Aug 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPlugin.java
More file actions
101 lines (86 loc) · 3.05 KB
/
Plugin.java
File metadata and controls
101 lines (86 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package tc.oc.minecraft.api.plugin;
import java.io.File;
import java.io.InputStream;
import com.google.inject.Injector;
import tc.oc.inject.ProtectedBinder;
import tc.oc.minecraft.api.event.EventRegistry;
import tc.oc.exception.ExceptionHandler;
import tc.oc.minecraft.api.server.Server;
import tc.oc.minecraft.api.logging.Loggable;
import tc.oc.reference.Handle;
import tc.oc.reference.Handleable;
public interface Plugin extends Loggable, Handleable {
@Override
Handle<? extends Plugin> handle();
/**
* Return metadata about this plugin
*/
PluginDescription getDescription();
/**
* Return a folder where this plugin may store arbitrary data
*/
File getDataFolder();
/**
* Open a resource embedded in this plugin.
* The caller is responsible for closing the stream.
*/
InputStream getResource(String name);
/**
* Return the Server instance hosting this plugin
*/
Server getServer();
/**
* @return An {@link ExceptionHandler} that canbe used to report
* exceptions related to this plugin.
*/
ExceptionHandler exceptionHandler();
/**
* @return The {@link EventRegistry} belonging to this plugin.
*/
EventRegistry eventRegistry();
/**
* Return the private {@link Injector} for this plugin.
*
* Note that direct injector use is considered bad form,
* and is only provided to assist in migrating legacy code.
* Nice code should @Inject its dependencies.
*/
Injector injector();
/**
* Called during {@link Injector} creation to configure this plugin. This happens
* during server startup, before {@link #onLoad()} is called.
*
* The given {@link ProtectedBinder} belongs to this plugin's private environment,
* and the binder returned from {@link ProtectedBinder#publicBinder()} is the global
* environment shared by all plugins, and the server itself.
*
* If the plugin's main class is a {@link tc.oc.inject.ProtectedModule} rather than a
* {@link Plugin}, then the server will provide a generic {@link Plugin} instance that
* simply installs that module. The main class can also be a {@link com.google.inject.Module},
* but then it will only have access to the private environment. This is the recommended
* approach for purely injection-based plugins. This method is intended to assist in
* migrating legacy code.
*/
default void configure(ProtectedBinder binder) {}
/**
* Override and return false to prevent this plugin from being enabled by the server.
* The plugin will still load and be injected, but the enable/disable lifecycle
* callbacks will not be called.
*/
default boolean isActive() {
return true;
}
/**
* Called when this plugin is loaded.
* All plugins are loaded before any of them are disabled.
*/
void onLoad();
/**
* Called when this plugin is enabled.
*/
void onEnable();
/**
* Called when this plugin is disabled.
*/
void onDisable();
}