This repository has been archived by the owner on Jun 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
plugin.go
111 lines (90 loc) · 2.42 KB
/
plugin.go
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
102
103
104
105
106
107
108
109
110
111
package gomine
type Manifest struct {
Name string
Description string
Version string
APIVersion string
Author string
Organisation string
}
type IManifest interface {
GetName() string
GetDescription() string
GetVersion() string
GetAPIVersion() string
GetAuthor() string
GetOrganisation() string
}
type IPlugin interface {
GetServer() *Server
OnEnable()
GetName() string
GetVersion() string
GetAuthor() string
GetOrganisation() string
GetAPIVersion() string
setManifest(IManifest)
}
type Plugin struct {
server *Server
manifest IManifest
}
func NewPlugin(server *Server) *Plugin {
return &Plugin{server, Manifest{}}
}
// GetName returns the name of the manifest.
func (manifest Manifest) GetName() string {
return manifest.Name
}
// GetVersion returns the version of the manifest.
func (manifest Manifest) GetVersion() string {
return manifest.Version
}
// GetOrganisation returns the author of the manifest.
func (manifest Manifest) GetOrganisation() string {
return manifest.Organisation
}
// GetAPIVersion returns the API Version of the manifest.
func (manifest Manifest) GetAPIVersion() string {
return manifest.APIVersion
}
// GetAuthor returns the author of the manifest.
func (manifest Manifest) GetAuthor() string {
return manifest.Author
}
// GetDescription returns the description of the manifest.
func (manifest Manifest) GetDescription() string {
return manifest.Description
}
// GetName returns the name of the plugin.
func (plug *Plugin) GetName() string {
return plug.manifest.GetName()
}
// GetVersion returns the version of the plugin.
func (plug *Plugin) GetVersion() string {
return plug.manifest.GetVersion()
}
// GetAuthor returns the author of the plugin.
func (plug *Plugin) GetOrganisation() string {
return plug.manifest.GetOrganisation()
}
// GetAPIVersion returns the API Version of the plugin.
func (plug *Plugin) GetAPIVersion() string {
return plug.manifest.GetAPIVersion()
}
// GetAuthor returns the author of the plugin.
func (plug *Plugin) GetAuthor() string {
return plug.manifest.GetAuthor()
}
// GetDescription returns the description of the plugin.
func (plug *Plugin) GetDescription() string {
return plug.manifest.GetDescription()
}
// SetManifest sets the manifest of this plugin.
func (plug *Plugin) setManifest(manifest IManifest) {
plug.manifest = manifest
}
// GetServer returns the main server.
func (plug *Plugin) GetServer() *Server {
return plug.server
}