Compare commits

..

194 Commits

Author SHA1 Message Date
afb72a6794 v0.7.0 2020-05-26 16:04:34 +08:00
40fb2869d5 feat: support spring
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-26 15:55:40 +08:00
8f3c0cc0bc feat: update docs
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-26 15:54:56 +08:00
2d281a13d1 feat: add spring support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-26 15:53:41 +08:00
cf3016e27e feat: support tomcat websocket
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-26 15:45:40 +08:00
ba3ef49ee5 fix: typings can't ignore 2020-05-26 15:38:13 +08:00
08b72cd05a v0.6.7 2020-05-15 18:24:24 +08:00
6e38da18bc feat: add npm publish script 2020-05-15 16:50:12 +08:00
2957150096 feat: link .npmignore file 2020-05-15 16:46:47 +08:00
c13ff26971 v0.6.6 2020-05-15 16:20:21 +08:00
104d1b18d6 feat: support nukkit getRootLogger
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-15 16:10:55 +08:00
db9746b641 feat: support bungee log forward
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-15 15:49:23 +08:00
6f18fe0990 feat: support get root Logger
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-15 15:48:38 +08:00
b33358cf59 feat: add token check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-15 14:29:13 +08:00
bc29221b9c feat: support config auto save
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-15 14:28:40 +08:00
dd88e63d1a feat: support token check & compatible more server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-14 19:05:07 +08:00
99a264677a feat: optimize import
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-14 19:04:19 +08:00
805f7ad521 feat: support handshark & boardcast
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-14 19:03:41 +08:00
e6aba870da feat: update dep version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-14 09:56:13 +08:00
321cb18cb9 feat: support log forward to client
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-13 18:42:41 +08:00
430edacd3f feat: complate upgrade
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-13 18:42:05 +08:00
ac88c15113 feat: add global eventCenter & static console source map
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-13 18:41:05 +08:00
2185b1a2f8 v0.6.5 2020-05-12 14:35:26 +08:00
c14e20e269 feat: optimize framework
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-12 14:22:31 +08:00
45a1c43dd8 feat: complate deploy access check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-12 00:07:05 +08:00
9226e1ab4f feat: ignore if trace.fileName is empty
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 22:13:31 +08:00
287585d8f5 feat: add node shim
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 22:13:03 +08:00
b323d16123 v0.6.4 2020-05-11 17:52:13 +08:00
85240608a1 feat: add npmignore
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:46:57 +08:00
6f9b458e6a v0.6.3 2020-05-11 17:32:02 +08:00
64159b621f feat: support address arg
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:24:26 +08:00
393ae6ce25 feat: support online load plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:22:45 +08:00
b9b80ecb83 feat: support blockly online debug
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:22:15 +08:00
57e2845ad9 feat: compatible blockly plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:20:50 +08:00
e03a4f9b34 feat: add i18n load tip
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:19:44 +08:00
72015ec132 feat: ignore jar:file stack info
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-10 16:25:04 +08:00
3e329233ce feat: add incremental compiler config
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-10 16:24:19 +08:00
b53d9e8a4e remove: plugins public file 2020-05-08 18:42:17 +08:00
331357f1a2 feat: support basic plugin... 2020-05-08 18:41:56 +08:00
ec809fb013 feat: update init command... 2020-05-08 10:11:30 +08:00
e38e772b17 feat: update gitpod init command... 2020-05-08 10:05:47 +08:00
2b56b1e573 feat: add gitpod config... 2020-05-08 09:53:18 +08:00
2df09b2472 feat: complate deploy feature 2020-05-08 00:50:30 +08:00
f9303b0e11 v0.6.2 2020-05-07 18:38:28 +08:00
d43f52a2a4 fix: reload & download error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-07 18:33:10 +08:00
7cf9718a9a v0.6.1 2020-05-07 17:18:38 +08:00
9693dc235f feat: update docs & MSPM
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-07 17:13:48 +08:00
40e9d1db6e feat: support source map & reload
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-07 17:12:15 +08:00
d50506ab9d v0.6.0 2020-05-03 00:15:06 +08:00
c34d3027e4 refactor: rename scope to @ccms
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-03 00:14:47 +08:00
edf8410cd1 v0.5.0 2020-04-26 10:24:49 +08:00
b0b4bbcc2b feat: merge stage exec & catch error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-26 10:19:44 +08:00
e68689c560 feat: update plugin & websocket
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 16:42:36 +08:00
58353cb5b8 feat: support stage decorators and remove space plugin floder
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 15:38:00 +08:00
8c6b75ff10 fix: netty inject error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 13:05:46 +08:00
d53287fc51 feat: support base64 source map
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 13:04:45 +08:00
13a3611ebd feat: update MiaoConsole
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-07 13:39:35 +08:00
6d90980726 v0.4.2 2020-04-07 13:39:50 +08:00
42de3700ba feat: add 1.8.8 reflect & export io namespace
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-07 13:31:20 +08:00
5991662764 feat: console执行异常只打印一次
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-03 13:32:54 +08:00
1c98c19e37 feat: cancel all task when disable engine
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-03 11:36:06 +08:00
c596280d8d feat: use module export
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 17:53:12 +08:00
77301e0130 feat: add internal node moudle punycode
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 14:39:00 +08:00
90878fc7df feat: merge decorators meta interface
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 11:08:57 +08:00
a0a4c13e7b feat: add pipeline reflect
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 11:08:15 +08:00
0e92a9c795 upgrade: js-yaml version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-31 16:16:13 +08:00
0c69462bb4 v0.4.1 2020-03-31 16:16:40 +08:00
78a5ed31b3 fix: disable server error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-31 14:53:23 +08:00
f4e9b2627d feat: add new nodejs modules
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-31 14:51:44 +08:00
9dd7abe6fd feat: update plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-30 18:49:19 +08:00
12743bbbe0 feat: instance i18n object
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-30 18:49:08 +08:00
d9a2ea9c78 v0.4.0 2020-03-25 13:54:45 +08:00
c505cda10b feat: export error handle & merge config
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 18:30:50 +08:00
100ccbcde3 feat: add api doc
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 17:59:18 +08:00
c6575ed481 fix: sourceMap sometime error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 15:02:20 +08:00
83359d8cb9 fix: ack callback call twice
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 14:52:50 +08:00
cca4979f16 feat: optimize framework add error catch(only log)
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 13:27:11 +08:00
251c9366f5 style: change error color
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 13:26:15 +08:00
8f01dcc8e8 feat: complate sockt.io server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-23 18:33:12 +08:00
c25a616dba feat: add adapter and socket
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-23 00:58:53 +08:00
aa9169b043 feat: tracatch plugin build
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-21 15:48:45 +08:00
d87e152f3b feat: add nodejs package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-21 15:47:59 +08:00
2fcadeda4e feat: complate socket.io base framework
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-21 15:47:42 +08:00
b7927830ae v0.3.2 2020-03-18 11:19:08 +08:00
2dbd2182c2 fix: source map print error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-18 11:15:49 +08:00
01df79eaf1 refactor: move docs to MiaoDocs
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-10 13:19:48 +08:00
16fe9ba9bd update: README
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:23:37 +08:00
950ce69b83 feat: modify stage order
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:11:55 +08:00
fa8e44d838 feat: update readme and fix container package error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:04:35 +08:00
b7af785273 feat: add docs package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:04:02 +08:00
6c9f7bbcf6 v0.3.1 2020-03-03 01:14:22 +08:00
c4c4c7f301 feat: public types package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-03 01:11:49 +08:00
6538c4b7bb feat: complate spiget and forgesvc api
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:40:18 +08:00
a4e6d1660d feat: update readme
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:38:34 +08:00
511b042eba feat: update MCBBS.MD
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:37:08 +08:00
6f0b5a5572 feat: add error handle
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:28:27 +08:00
e9ac46487c feat: merge type defiend
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:29:29 +08:00
9371823d30 remove: manager package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 21:00:54 +08:00
c86f0d9ec1 feat: add complate function
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 00:32:07 +08:00
c2d94ef104 feat: optimize types ref
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 20:28:16 +08:00
6ada3e41d0 fix: Dependency cycles
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 19:37:34 +08:00
8c12319dc9 feat: add i18n to ployfill
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 17:01:27 +08:00
395d2d8816 feat: add NativePluginManager
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 15:19:43 +08:00
6f628a3d7e feat: add download and getPluginsFolder
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-29 22:28:43 +08:00
2232e82c36 feat: upgrade typescript
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-29 18:21:02 +08:00
291b5010e7 feat: add command error i18n
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-29 00:44:11 +08:00
3595294444 feat: add normal env task
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 18:20:45 +08:00
e38358ef98 feat: MiaoConsole exclude nukkit
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 18:15:33 +08:00
4c418c33c0 feat: channel add ext data
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 18:14:17 +08:00
65d112be09 feat: add nukkit example
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 17:59:06 +08:00
15a75dffe2 fix: servers check error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 17:57:29 +08:00
7b8e693a03 v0.3.0 2020-02-27 12:27:19 +08:00
5426023adb feat: optimize code
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 12:26:04 +08:00
73b91c417e feat: improve i18n scope
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 12:11:18 +08:00
2693a22bf0 feat: support i18n translate
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 01:58:23 +08:00
2322de1e40 feat: add package i18n
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 01:57:44 +08:00
2320736a92 feat: remove async check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-26 10:43:47 +08:00
e8d5d10d44 feat: unmanaged baseEventDir
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-26 10:36:30 +08:00
a9996ba297 feat: use inversify autoProvide inject
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-26 10:15:33 +08:00
68380ddbba feat: exclude async event monitor
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-25 23:32:12 +08:00
0baf8f3cab fix: event execute class type error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-25 23:15:39 +08:00
a2bce715f3 fix: nukkit unregister event error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-25 18:25:16 +08:00
3c55df03d8 feat: use new channel service
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 18:36:32 +08:00
f6526e79fc feat: add channel support for bungee bukkit sponge
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 18:36:08 +08:00
f4c2294c06 feat: update ignore file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:35:19 +08:00
cf9508ba31 v0.2.1 2020-02-24 16:27:49 +08:00
e0f4c5e77d feat: add nukkit support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:25:54 +08:00
e4a87095ce feat: add config support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:25:38 +08:00
950575edbc feat: inject config folder
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:25:16 +08:00
c2a71b9a7a feat: add config support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:24:36 +08:00
068ac7b76e feat: update typescript version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 15:28:47 +08:00
05cbd85828 feat: add nukkit support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 04:02:29 +08:00
ea28d20aa1 feat: add nukkit package 2020-02-24 04:01:39 +08:00
d3f33f50e0 feat: add nukkit type defiend 2020-02-24 02:54:05 +08:00
d004ba17e6 v0.2.0 2020-02-24 00:21:48 +08:00
7a25dd8b3b feat: set manager and client to private
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:19:13 +08:00
dedc8393da feat: update plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:13:19 +08:00
8d344492d9 feat: add config decorator bate
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:12:32 +08:00
81a76af7be feat: update mcbbs file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:11:46 +08:00
b458da7a6e feat: add auto respawn support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-23 22:35:05 +08:00
45cb6fa667 fix: some bug at xhr and console
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-23 22:33:51 +08:00
9c4543df30 feat: channelRead0 处理逻辑移动到业务线程
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 19:46:50 +08:00
512bdb22c5 feat: update main script
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 19:03:09 +08:00
f6e39c131c feat: add source map support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 19:00:26 +08:00
73d4dad7f6 feat: add mc console client package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 18:59:02 +08:00
de4a22362f feat: remove script npx
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 18:56:02 +08:00
5fde2e5554 feat: update example plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 19:40:25 +08:00
6a6765e5c3 feat: add source map support(only local)
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 19:39:45 +08:00
4a1f25ee6a feat: enable sourceMap
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 18:49:18 +08:00
5999567ee3 feat: update dependencies version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 18:48:46 +08:00
fad4e27a7f fix: bungee servers forEach error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-14 04:03:25 +08:00
b477938e4f fix: bungee unregister error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-14 04:02:37 +08:00
7cbd91826a feat: chat compatible catserver
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-14 04:02:18 +08:00
6797761a2f feat: add bungee tab complate
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-09 22:07:00 +08:00
be114e6d1b feat: add core-js
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-09 22:06:45 +08:00
3e40934339 feat: rename plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-08 17:07:56 +08:00
3e6c7b2d8c fix: compile error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-02 01:58:07 +08:00
6c0bb75561 feat: use dom types and set Proxy global
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-02 01:56:45 +08:00
a47896a97f feat: update Proxy handle and optimize core index
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 03:37:56 +08:00
1d97bbc9ce feat: update Readme
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:54:03 +08:00
b1f1f9837e feat: add websocket package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:47:39 +08:00
99dee28fd4 feat: add plugin stage log
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:46:55 +08:00
c7f66d8252 feat: move type bind and export impl function
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:46:06 +08:00
8c4f266356 feat: move global declare to @ms/ployfill
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:44:23 +08:00
39e899211b feat: complete cross server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:48:23 +08:00
da72a0dac6 feat: optimize code
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:47:38 +08:00
9984787202 fix: sponge task callSyncMethod
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:45:39 +08:00
4493d35786 feat: optimiz plugin system
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:45:13 +08:00
e1aad59eeb feat: add tellraw string
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:44:08 +08:00
849393492f feat: update server filter
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:43:45 +08:00
1ff33702d8 feat: plugin & cmd add server check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:11:20 +08:00
e68005fd6f feat: use inject container
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:10:30 +08:00
17269b50f4 fix: bungee event error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:09:16 +08:00
363d0c164a feat: add callSyncMethod
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:08:51 +08:00
13a0b62103 fix: with error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:08:10 +08:00
cb4e152800 feat: add plugin controller
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:28:10 +08:00
fb83acfcc8 feat: update plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:27:24 +08:00
7263fbb437 feat: add bungee support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:26:31 +08:00
23868a58b9 feat: complete event and dispatch command
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:19:10 +08:00
effa7f70ec feat: add tellraw & Proxy utils
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 18:38:22 +08:00
eef0baa740 feat: formatting code & remove chinese
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:48:18 +08:00
4d0c0122c7 feat: completion base func
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:44:14 +08:00
aa581afbe5 feat: add bungee package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:43:00 +08:00
1425c473fd feat: delombok and regenerate d.ts
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:42:15 +08:00
53e4f6c658 feat: update bungee type file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 01:02:08 +08:00
73db4a9169 feat: add server module
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-14 17:44:20 +08:00
a2efd878db feat: add bungee typings
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-14 17:40:28 +08:00
4e6cda0545 feat: support multi code page
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-13 15:28:25 +08:00
859a3a9171 feat: upgrade version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-08 09:48:37 +08:00
96481032c5 feat: update websocket server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-11-10 10:11:13 +08:00
f950c3dae8 feat: update gitignore 2019-11-09 18:35:26 +08:00
9248294cb3 feat: add jdk support 2019-11-09 18:34:54 +08:00
53873d7b63 feat: update type defiend 2019-11-07 16:40:27 +08:00
be59ae480b feat: add bukkit sponge jdk type 2019-11-07 15:13:28 +08:00
6552 changed files with 378824 additions and 2820 deletions

View File

@@ -12,8 +12,7 @@
"build": "lerna run build --scope=\"@ccms/!(plugins)\"",
"build:plugins": "lerna run build --scope=\"@ccms/plugins\"",
"ug": "yarn upgrade-interactive --latest",
"np": "lerna exec \"npm publish --registry https://registry.npmjs.org\" --scope=\"@ccms/!(client|plugins)\"",
"lsp": "npm login --registry=https://registry.npmjs.org --scope=@ccms",
"np": "lerna exec \"npm publish --registry https://registry.npmjs.org\" --scope=\"@ccms/!(client|plugins|types)\"",
"lp": "lerna publish"
},
"workspaces": [

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,32 +0,0 @@
{
"name": "@ccms/amqp",
"version": "0.7.0",
"description": "MiaoScript amqp package",
"keywords": [
"miaoscript",
"minecraft",
"bukkit",
"sponge"
],
"author": "MiaoWoo <admin@yumc.pw>",
"homepage": "https://github.com/circlecloud/ms.git",
"license": "ISC",
"main": "dist/index.js",
"scripts": {
"clean": "rimraf dist",
"watch": "tsc --watch",
"build": "yarn clean && tsc",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@ccms/api": "^0.7.0",
"@ccms/nashorn": "^0.7.0",
"@ccms/common": "^0.7.0",
"@ccms/container": "^0.7.0"
},
"devDependencies": {
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.2"
}
}

View File

@@ -1,14 +0,0 @@
import { ConnectionFactoryAdapter } from "./connection"
import { RabbitTemplateAdapter } from "./template"
export const RabbitAdmin = Java.type('org.springframework.amqp.rabbit.core.RabbitAdmin')
export class RabbitAdminAdapter {
private _Handler: org.springframework.amqp.rabbit.core.RabbitAdmin
constructor(config: RabbitTemplateAdapter | org.springframework.amqp.rabbit.core.RabbitTemplate | ConnectionFactoryAdapter | org.springframework.amqp.rabbit.connection.ConnectionFactory) {
this._Handler = new RabbitAdmin((config instanceof RabbitTemplateAdapter || config instanceof ConnectionFactoryAdapter) ? config.getHandler() : config)
}
getHandler(): org.springframework.amqp.rabbit.core.RabbitAdmin {
return this._Handler
}
}

View File

@@ -1,30 +0,0 @@
export const ConfirmCallback = Java.type('org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback')
export const ReturnCallback = Java.type('org.springframework.amqp.rabbit.core.RabbitTemplate.ReturnCallback')
export abstract class ConfirmCallbackAdapter {
private _Handler: org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback
constructor() {
let ConfirmCallbackImpl = Java.extend(ReturnCallback, {
confirm: (correlationData: org.springframework.amqp.rabbit.connection.CorrelationData, ack: boolean, cause: string) => this.confirm(correlationData, ack, cause)
})
this._Handler = new ConfirmCallbackImpl()
}
abstract confirm(correlationData: org.springframework.amqp.rabbit.connection.CorrelationData, ack: boolean, cause: string)
getHandler() {
return this._Handler
}
}
export abstract class ReturnCallbackAdapter {
private _Handler: org.springframework.amqp.rabbit.core.RabbitTemplate.ReturnCallback
constructor() {
let ReturnCallbackImpl = Java.extend(ReturnCallback, {
returnedMessage: (message: org.springframework.amqp.core.Message, replyCode: number, replyText: string, exchange: string, routingKey: string) => this.returnedMessage(message, replyCode, replyText, exchange, routingKey)
})
this._Handler = new ReturnCallbackImpl()
}
abstract returnedMessage(message: org.springframework.amqp.core.Message, replyCode: number, replyText: string, exchange: string, routingKey: string)
getHandler() {
return this._Handler
}
}

View File

@@ -1,31 +0,0 @@
import threadPool from '@ccms/common/dist/thread-pool'
export const ConnectionFactory = Java.type('org.springframework.amqp.rabbit.connection.ConnectionFactory')
const CachingConnectionFactory = Java.type('org.springframework.amqp.rabbit.connection.CachingConnectionFactory')
interface ConnectionConfig {
url: string,
username?: string,
password?: string,
publisherConfirms?: boolean
cacheSize?: number
}
export class ConnectionFactoryAdapter {
private _Handler: org.springframework.amqp.rabbit.connection.CachingConnectionFactory
constructor(config: ConnectionConfig) {
if (!config.url) { throw new Error('Connection UrI Can\'t be undefiend!') }
config = { publisherConfirms: true, cacheSize: 50, ...config }
this._Handler = new CachingConnectionFactory(new java.net.URI(config.url))
config.username && this._Handler.setUsername(config.username)
config.password && this._Handler.setPassword(config.password)
this._Handler.setPublisherConfirms(config.publisherConfirms)
this._Handler.setExecutor(threadPool.create({
groupName: '@ccms/amqp-rabbit'
}))
this._Handler.setChannelCacheSize(config.cacheSize)
}
getHandler() {
return this._Handler
}
}

View File

@@ -1,30 +0,0 @@
import { ConnectionFactoryAdapter, ConnectionFactory } from "./connection"
import { ChannelAwareMessageListenerAdapter, ChannelAwareMessageListener } from "./listener"
export const SimpleMessageListenerContainer = org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
export const AcknowledgeMode = org.springframework.amqp.core.AcknowledgeMode
interface ContainerConfig {
connectionFactory: ConnectionFactoryAdapter | typeof ConnectionFactory
queueNames: string[]
messageListener: ChannelAwareMessageListenerAdapter | typeof ChannelAwareMessageListener
maxConcurrentConsumers?: number
concurrentConsumers?: number
acknowledgeMode?: org.springframework.amqp.core.AcknowledgeMode
}
export class MessageListenerContainerAdapter {
private _Handler: org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
constructor(config: ContainerConfig) {
config = { concurrentConsumers: 5, maxConcurrentConsumers: 10, acknowledgeMode: AcknowledgeMode.AUTO, ...config }
this._Handler = new SimpleMessageListenerContainer(config.connectionFactory instanceof ConnectionFactoryAdapter ? config.connectionFactory.getHandler() : config.connectionFactory)
//@ts-ignore
this._Handler.setQueueNames(config.queueNames)
this._Handler.setMaxConcurrentConsumers(config.maxConcurrentConsumers)
this._Handler.setConcurrentConsumers(config.concurrentConsumers)
this._Handler.setAcknowledgeMode(config.acknowledgeMode)
this._Handler.setMessageListener(config.messageListener instanceof ChannelAwareMessageListenerAdapter ? config.messageListener.getHandler() : config.messageListener)
}
getHandler() {
return this._Handler
}
}

View File

@@ -1,37 +0,0 @@
const JavaString = Java.type('java.lang.String')
const MessageProperties = org.springframework.amqp.core.MessageProperties
const Message = org.springframework.amqp.core.Message
export const MessageConverter = Java.type('org.springframework.amqp.support.converter.MessageConverter')
export class MessageConverterAdapter {
private _Handler: org.springframework.amqp.support.converter.MessageConverter
constructor() {
var MessageConverterImpl = Java.extend(MessageConverter, {
toMessage: (object: any, messageProperties: org.springframework.amqp.core.MessageProperties) => this.toMessage(object, messageProperties),
fromMessage: (message: org.springframework.amqp.core.Message) => this.fromMessage(message)
})
this._Handler = new MessageConverterImpl()
}
toMessage(object: any, messageProperties: org.springframework.amqp.core.MessageProperties) {
if (typeof object == "string") {
messageProperties.setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN)
return new Message(new JavaString(object).getBytes(), messageProperties)
} else {
messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON)
return new Message(new JavaString(JSON.stringify(object)).getBytes(), messageProperties)
}
}
fromMessage(message: org.springframework.amqp.core.Message) {
if (message.getMessageProperties().getContentType() == MessageProperties.CONTENT_TYPE_TEXT_PLAIN) {
return new JavaString(message.getBody(), message.getMessageProperties().getContentEncoding())
}
if (message.getMessageProperties().getContentType() == MessageProperties.CONTENT_TYPE_JSON) {
return JSON.parse(new JavaString(message.getBody(), message.getMessageProperties().getContentEncoding()))
}
return message
}
getHandler() {
return this._Handler
}
}

View File

@@ -1,7 +0,0 @@
export * from './admin'
export * from './callback'
export * from './connection'
export * from './container'
export * from './converter'
export * from './listener'
export * from './template'

View File

@@ -1,49 +0,0 @@
const JavaString = Java.type('java.lang.String')
export const MessageProperties = org.springframework.amqp.core.MessageProperties
export const ChannelAwareMessageListener = Java.type('org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener')
export const AmqpRejectAndDontRequeueException = org.springframework.amqp.AmqpRejectAndDontRequeueException
export const Channel: com.rabbitmq.client.Channel = Java.type('com.rabbitmq.client.Channel')
export const Message = org.springframework.amqp.core.Message
export type MessageHandler<T> = (content: T, message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel) => any
export abstract class ChannelAwareMessageListenerAdapter<T = any> {
private _Handler: org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener
constructor(manual: boolean = false) {
let ChannelAwareMessageListenerImpl = Java.extend(ChannelAwareMessageListener, {
onMessage: (message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel) => {
let content = new JavaString(message.getBody(), message.getMessageProperties().getContentEncoding() || "UTF-8")
try {
if (message.getMessageProperties().getContentType() == MessageProperties.CONTENT_TYPE_JSON) {
content = JSON.parse(content)
}
} catch (error) {
if (manual) {
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true)
} else {
throw new AmqpRejectAndDontRequeueException(`${error}`, error)
}
}
manual ? this.manualOnMessage(content, message, channel) : this.onMessage(content, message, channel)
}
})
this._Handler = new ChannelAwareMessageListenerImpl()
}
abstract onMessage(content: T, message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel): any
onError(error: Error, message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel): any { }
getHandler() {
return this._Handler
}
private manualOnMessage(content: T, message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel) {
let deliveryTag = message.getMessageProperties().getDeliveryTag()
try {
if (this.onMessage(content, message, channel)) {
channel.basicAck(deliveryTag, false)
} else if (message.getMessageProperties().getRedelivered()) {
channel.basicReject(deliveryTag, true)
} else {
channel.basicNack(deliveryTag, false, true)
}
} catch (error) {
channel.basicReject(deliveryTag, this.onError(error, message, channel))
}
}
}

View File

@@ -1,27 +0,0 @@
import { MessageConverterAdapter } from "./converter"
import { ConnectionFactoryAdapter } from "./connection"
import { ConfirmCallbackAdapter, ReturnCallbackAdapter } from "./callback"
export const RabbitTemplate = Java.type('org.springframework.amqp.rabbit.core.RabbitTemplate')
interface TemplateConfig {
connectionFactory: ConnectionFactoryAdapter | org.springframework.amqp.rabbit.connection.ConnectionFactory
confirmCallback?: ConfirmCallbackAdapter
returnCallback?: ReturnCallbackAdapter
messageConverter?: MessageConverterAdapter
}
export class RabbitTemplateAdapter {
private _Handler: org.springframework.amqp.rabbit.core.RabbitTemplate
constructor(config: TemplateConfig) {
config = { messageConverter: new MessageConverterAdapter(), ...config }
console.debug(JSON.stringify(config))
this._Handler = new RabbitTemplate(config.connectionFactory instanceof ConnectionFactoryAdapter ? config.connectionFactory.getHandler() : config.connectionFactory)
config.returnCallback && this._Handler.setReturnCallback(config.returnCallback.getHandler())
config.confirmCallback && this._Handler.setConfirmCallback(config.confirmCallback.getHandler())
config.messageConverter && this._Handler.setMessageConverter(config.messageConverter.getHandler())
}
getHandler() {
return this._Handler
}
}

View File

@@ -1,90 +0,0 @@
import { JSClass } from "@ccms/container"
import { RabbitAdminAdapter, MessageListenerContainerAdapter, AcknowledgeMode, MessageHandler, ChannelAwareMessageListenerAdapter } from "./adapter"
const RabbitAdmin = Java.type('org.springframework.amqp.rabbit.core.RabbitAdmin')
export class AmqpAdmin {
@JSClass('org.springframework.amqp.core.TopicExchange')
private TopicExchange: typeof org.springframework.amqp.core.TopicExchange
@JSClass('org.springframework.amqp.core.Queue')
private Queue: typeof org.springframework.amqp.core.Queue
@JSClass('org.springframework.amqp.core.Binding')
private Binding: typeof org.springframework.amqp.core.Binding
@JSClass('org.springframework.amqp.core.Binding.DestinationType')
private DestinationType: typeof org.springframework.amqp.core.Binding.DestinationType
private amqpAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin
constructor(amqpAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin | any) {
if (amqpAdmin instanceof RabbitAdmin) {
this.amqpAdmin = amqpAdmin
} else if (amqpAdmin instanceof RabbitAdminAdapter) {
this.amqpAdmin = amqpAdmin.getHandler()
} else {
this.amqpAdmin = new RabbitAdminAdapter(amqpAdmin).getHandler()
}
}
getHandler() {
return this.amqpAdmin
}
getQueueProperties(name: string) {
return this.amqpAdmin.getQueueProperties(name)
}
declareExchange(name: string) {
let exchange = new this.TopicExchange(name, true, false)
this.amqpAdmin.declareExchange(exchange)
return this
}
declareQueue(name: string) {
let queue = new this.Queue(name, true)
this.amqpAdmin.declareQueue(queue)
return this
}
declareBinding(queue: string, exchange: string, routerKey: string, argument: any = null) {
let binding = new this.Binding(queue, this.DestinationType.QUEUE, exchange, routerKey, argument)
this.amqpAdmin.declareBinding(binding)
return this
}
declareQueueAndBindExchange(queue: string, exchange: string, routerKey: string) {
return this.declareQueue(queue).declareExchange(exchange).declareBinding(queue, exchange, routerKey)
}
createContainer<T>(queue: string, listener: MessageHandler<T>, acknowledgeMode = AcknowledgeMode.AUTO) {
let connection = this.amqpAdmin.getRabbitTemplate().getConnectionFactory()
return new MessageListenerContainerAdapter({
connectionFactory: connection,
queueNames: [queue],
messageListener: new SimpleMessageHandler(listener),
acknowledgeMode: acknowledgeMode
}).getHandler()
}
send()
send() {
}
getTemplate() {
return this.amqpAdmin.getRabbitTemplate()
}
close() {
this.getTemplate().stop()
}
}
export class SimpleMessageHandler extends ChannelAwareMessageListenerAdapter {
constructor(private handler: MessageHandler<any>) {
super()
}
onMessage(content: any, message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel) {
return this.handler(content, message, channel)
}
}

View File

@@ -1,3 +0,0 @@
export const METADATA_KEY = {
}

View File

@@ -1,34 +0,0 @@
/// <reference types="@ccms/nashorn" />
/// <reference types="@ccms/types/dist/typings/jdk" />
/// <reference types="@ccms/types/dist/typings/spring" />
/// <reference types="@ccms/types/dist/typings/spring/amqp" />
/// <reference types="@ccms/types/dist/typings/rabbitmq" />
import { amqp } from '@ccms/api'
import { getContainer, reduceMetadata } from '@ccms/container'
function init() {
const beanFactory = base.getInstance().getAutowireCapableBeanFactory()
getContainer().bind(amqp.rabbit.Template).toDynamicValue((ctx) => {
let metadata = reduceMetadata(ctx)
if (!metadata.named) {
return beanFactory.getBean('rabbitTemplate')
} else {
return beanFactory.getBean(`${metadata.named}-rabbitTemplate`)
}
})
getContainer().bind(amqp.rabbit.Admin).toDynamicValue((ctx) => {
let metadata = reduceMetadata(ctx)
if (!metadata.named) {
return beanFactory.getBean('rabbitAdmin')
} else {
return beanFactory.getBean(`${metadata.named}-rabbitAdmin`)
}
})
}
init()
export * from './admin'
export * from './adapter'
export * from './manager'
export * from './constants'

View File

@@ -1,5 +0,0 @@
export class AmqpListener {
constructor() {
}
}

View File

@@ -1,18 +0,0 @@
import { amqp } from "@ccms/api"
import { provideSingleton } from "@ccms/container"
import { ConnectionFactoryAdapter, RabbitTemplateAdapter, RabbitAdminAdapter } from "./adapter"
import { AmqpAdmin } from "./admin"
@provideSingleton(amqp.Manager)
export class AmqpManager {
createConnection(url: string, username: string, password: string) {
return new ConnectionFactoryAdapter({ url, username, password })
}
createTemplate(adapter: ConnectionFactoryAdapter) {
return new RabbitTemplateAdapter({ connectionFactory: adapter })
}
createAdmin(adapter: RabbitTemplateAdapter | ConnectionFactoryAdapter) {
return new AmqpAdmin(new RabbitAdminAdapter(adapter))
}
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "src",
"outDir": "dist"
}
}

View File

@@ -21,7 +21,6 @@
"dependencies": {
"@ccms/container": "^0.7.0",
"@ccms/ployfill": "^0.7.0",
"@ccms/common": "^0.7.0",
"base64-js": "^1.3.1",
"source-map-builder": "^0.0.7"
},
@@ -31,4 +30,4 @@
"rimraf": "^3.0.2",
"typescript": "^3.9.2"
}
}
}

View File

@@ -1,6 +1,5 @@
import i18n from '@ccms/i18n'
import { injectable } from "@ccms/container"
import { plugin } from './interfaces'
import { injectable } from "@ccms/container";
export namespace command {
@injectable()
@@ -11,17 +10,16 @@ export namespace command {
* @param name 命令
* @param exec 执行器
*/
on(plugin: plugin.Plugin, name: string, exec: { cmd: Function, tab?: Function }) {
var cmd = this.create(plugin, name)
if (!cmd) { throw Error("") }
on(plugin: any, name: string, exec: { cmd: Function, tab?: Function }) {
var cmd = this.create(plugin, name);
console.debug(i18n.translate("ms.api.command.register", { plugin: plugin.description.name, name, cmd }))
if (exec.cmd && typeof exec.cmd === "function") {
this.onCommand(plugin, cmd, exec.cmd)
this.onCommand(plugin, cmd, exec.cmd);
} else {
throw Error(i18n.translate("ms.api.command.register.input.error", { exec: exec.cmd }))
}
if (exec.tab && typeof exec.tab === "function") {
this.onTabComplete(plugin, cmd, exec.tab)
this.onTabComplete(plugin, cmd, exec.tab);
}
}
/**
@@ -29,40 +27,40 @@ export namespace command {
* @param plugin 插件
* @param name 命令
*/
off(plugin: plugin.Plugin, name: string) {
off(plugin: any, name: string) {
console.debug(i18n.translate("ms.api.command.unregister", { plugin: plugin.description.name, name }))
this.remove(plugin, name)
this.remove(plugin, name);
}
protected abstract create(plugin: plugin.Plugin, command: string): any
protected abstract remove(plugin: plugin.Plugin, command: string): void
protected abstract onCommand(plugin: plugin.Plugin, command: any, executor: Function)
protected abstract onTabComplete(plugin: plugin.Plugin, command: any, tabCompleter: Function)
protected setExecutor(plugin: plugin.Plugin, command: any, executor: Function) {
protected abstract create(plugin: any, command: string);
protected abstract remove(plugin: any, command: string);
protected abstract onCommand(plugin: any, command: any, executor: Function);
protected abstract onTabComplete(plugin: any, command: any, tabCompleter: Function);
protected setExecutor(plugin: any, command: any, executor: Function) {
return (sender: any, _: any, command: string, args: string[]) => {
try {
return executor(sender, command, Java.from(args))
return executor(sender, command, Java.from(args));
} catch (ex) {
console.i18n("ms.api.command.execute.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex })
console.ex(ex)
console.ex(ex);
if (sender.name != 'CONSOLE') {
console.sender(sender, [i18n.translate("ms.api.command.execute.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)])
}
return true
return true;
}
}
}
protected setTabCompleter(plugin: plugin.Plugin, command: any, tabCompleter: Function) {
protected setTabCompleter(plugin: any, command: any, tabCompleter: Function) {
return (sender: any, _: any, command: string, args: string[]) => {
try {
var token = args[args.length - 1]
var complete = tabCompleter(sender, command, Java.from(args)) || []
return this.copyPartialMatches(complete, token)
var token = args[args.length - 1];
var complete = tabCompleter(sender, command, Java.from(args)) || [];
return this.copyPartialMatches(complete, token);
} catch (ex) {
console.i18n("ms.api.command.tab.completer.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex })
console.ex(ex)
console.sender(sender, [i18n.translate("ms.api.command.tab.completer.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)])
return []
console.ex(ex);
console.sender(sender, [i18n.translate("ms.api.command.tab.completer.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)]);
return [];
}
}
}
@@ -72,7 +70,7 @@ export namespace command {
if (typeof e === "string" && e.toLowerCase().startsWith(token.toLowerCase())) {
array.push(e)
}
})
});
return array
}
}

View File

@@ -2,10 +2,10 @@ import i18m from '@ccms/i18n'
import { SourceMapBuilder } from 'source-map-builder'
import * as base64 from 'base64-js'
const Arrays = Java.type('java.util.Arrays')
const Level = Java.type('java.util.logging.Level')
const Paths = Java.type('java.nio.file.Paths')
const ignoreLogPrefix = ['java.', 'javax.', 'sun.', 'net.minecraft.', 'org.bukkit.', 'jdk.nashorn.', 'io.netty.', 'org.spongepowered.', 'org.apache', 'org.springframework']
const Arrays = Java.type('java.util.Arrays');
const Level = Java.type('java.util.logging.Level');
const Paths = Java.type('java.nio.file.Paths');
const ignoreLogPrefix = ['java.', 'net.minecraft.', 'org.bukkit.', 'jdk.nashorn.', 'io.netty.', 'org.spongepowered.'];
enum LogLevel {
ALL,
@@ -19,19 +19,19 @@ enum LogLevel {
}
export class MiaoScriptConsole implements Console {
Console: NodeJS.ConsoleConstructor
Console: NodeJS.ConsoleConstructor;
private static sourceMaps: { [key: string]: SourceMapBuilder } = {}
private static sourceFileMaps: { [key: string]: string } = {}
private _name: string = ''
private _level: LogLevel = LogLevel.INFO
private static sourceMaps: { [key: string]: SourceMapBuilder } = {};
private static sourceFileMaps: { [key: string]: string } = {};
private _name: string = '';
private _level: LogLevel = LogLevel.INFO;
protected logger: any
protected prefix: string = '§6[§bMiaoScript§6]§r '
protected logger: any;
protected prefix: string = '§6[§bMiaoScript§6]§r ';
constructor(name?: string) {
this.name = name
this.logger = global.logger
this.name = name;
this.logger = global.logger;
if (global.debug) {
this._level = LogLevel.DEBUG
}
@@ -41,36 +41,36 @@ export class MiaoScriptConsole implements Console {
}
get name() {
return this._name
return this._name;
}
set name(name: string) {
if (name) {
this._name = `[${name}] `
this._name = `[${name}] `;
// noinspection JSUnusedGlobalSymbols
this.prefix = `§6[§cMS§6][§b${name}§6]§r `
this.prefix = `§6[§cMS§6][§b${name}§6]§r `;
}
}
log(...args: any[]): void {
this.logger.info(this.name + args.join(' '))
this.logger.info(this.name + args.join(' '));
}
info(...args: any[]) {
this.logger.info(this.name + args.join(' '))
this.logger.info(this.name + args.join(' '));
}
warn(...args: any[]) {
this.logger.warning(this.name + args.join(' '))
this.logger.warning(this.name + args.join(' '));
}
error(...args: any[]) {
this.logger.log(Level.SEVERE, this.name + args.join(' '))
this.logger.log(Level.SEVERE, this.name + args.join(' '));
}
debug(...args: any[]) {
if (global.debug) {
this.logger.info(this.name + '[DEBUG] ' + args.join(' '))
this.logger.info(this.name + '[DEBUG] ' + args.join(' '));
}
}
trace(...args: any[]): void {
if (this._level <= LogLevel.TRACE) {
this.logger.info(this.name + '[TRACE] ' + args.join(' '))
this.logger.info(this.name + '[TRACE] ' + args.join(' '));
}
}
sender(...args) {
@@ -95,29 +95,29 @@ export class MiaoScriptConsole implements Console {
if (fileName.endsWith('js')) {
if (MiaoScriptConsole.sourceMaps[fileName] === undefined) {
MiaoScriptConsole.sourceMaps[fileName] = null
let sourceLine = base.read(fileName).split('\n')
let sourceLine = base.read(fileName).split('\n');
let lastLine = sourceLine[sourceLine.length - 1]
if (lastLine.startsWith('//# sourceMappingURL=')) {
let sourceContent = null
let sourceMappingURL = lastLine.split('sourceMappingURL=', 2)[1]
if (sourceMappingURL.startsWith('data:application/jsonbase64,')) {
let sourceContent = null;
let sourceMappingURL = lastLine.split('sourceMappingURL=', 2)[1];
if (sourceMappingURL.startsWith('data:application/json;base64,')) {
sourceContent = String.fromCharCode(...Array.from(base64.toByteArray(sourceMappingURL.split(',', 2)[1])))
} else if (sourceMappingURL.startsWith('http')) {
// TODO
} else {
let file = Paths.get(Paths.get(fileName, '..', sourceMappingURL).toFile().getCanonicalPath()).toFile()
let file = Paths.get(Paths.get(fileName, '..', sourceMappingURL).toFile().getCanonicalPath()).toFile();
if (file.exists()) { sourceContent = base.read(file) }
}
if (sourceContent) {
MiaoScriptConsole.sourceMaps[fileName] = new SourceMapBuilder(JSON.parse(sourceContent))
MiaoScriptConsole.sourceFileMaps[fileName] = Paths.get(fileName, '..', MiaoScriptConsole.sourceMaps[fileName].sources[0]).toFile().getCanonicalPath()
MiaoScriptConsole.sourceFileMaps[fileName] = Paths.get(fileName, '..', MiaoScriptConsole.sourceMaps[fileName].sources[0]).toFile().getCanonicalPath();
}
}
}
if (MiaoScriptConsole.sourceMaps[fileName]) {
let sourceMapping = MiaoScriptConsole.sourceMaps[fileName].getSource(lineNumber, 25, true, true)
let sourceMapping = MiaoScriptConsole.sourceMaps[fileName].getSource(lineNumber, 25, true, true);
fileName = MiaoScriptConsole.sourceFileMaps[fileName]
if (sourceMapping && lineNumber != sourceMapping.mapping.sourceLine) { lineNumber = sourceMapping.mapping.sourceLine }
if (sourceMapping && lineNumber != sourceMapping.mapping.sourceLine) { lineNumber = sourceMapping.mapping.sourceLine; }
}
}
} catch (error) {
@@ -128,26 +128,22 @@ export class MiaoScriptConsole implements Console {
lineNumber
}
}
stack(ex: Error, color: boolean = true): string[] {
let stack = ex.getStackTrace()
let cache = [(color ? '§c' : '') + ex]
stack(ex: Error): string[] {
let stack = ex.getStackTrace();
let cache = ['§c' + ex];
//@ts-ignore
if (stack.class) {
stack = Arrays.asList(stack)
}
stack.forEach(trace => {
if (!trace.fileName || trace.fileName.startsWith('jar:file:') || trace.fileName.startsWith('file:')) { return }
if (!trace.fileName || trace.fileName.startsWith('jar:file:')) { return }
if (trace.className.startsWith('<')) {
let { fileName, lineNumber } = this.readSourceMap(trace.fileName, trace.lineNumber)
if (fileName.startsWith(root)) { fileName = fileName.split(root)[1] }
if (color) {
cache.push(` §e->§c ${fileName}:${lineNumber} => §4${trace.methodName}`)
} else {
cache.push(` -> ${fileName}:${lineNumber} => ${trace.methodName}`)
}
cache.push(` §e->§c ${fileName}:${lineNumber} => §4${trace.methodName}`)
} else {
let className = trace.className
var fileName = trace.fileName as string
let className = trace.className;
var fileName = trace.fileName as string;
if (className.startsWith('jdk.nashorn.internal.scripts')) {
className = className.substr(className.lastIndexOf('$') + 1)
var { fileName, lineNumber } = this.readSourceMap(trace.fileName, trace.lineNumber)
@@ -155,74 +151,70 @@ export class MiaoScriptConsole implements Console {
} else {
for (let prefix in ignoreLogPrefix) {
if (className.startsWith(ignoreLogPrefix[prefix])) {
return
return;
}
}
}
if (color) {
cache.push(` §e->§c ${className}.${trace.methodName}(§4${fileName}:${lineNumber}§c)`)
} else {
cache.push(` -> ${className}.${trace.methodName}(${fileName}:${lineNumber})`)
}
cache.push(` §e->§c ${className}.${trace.methodName}(§4${fileName}:${lineNumber}§c)`);
}
})
return cache
});
return cache;
}
assert(value: any, message?: string, ...optionalParams: any[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
clear(): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
count(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
countReset(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
dir(obj: any, options?: NodeJS.InspectOptions): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
dirxml(...data: any[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
group(...label: any[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
groupCollapsed(...label: any[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
groupEnd(): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
table(tabularData: any, properties?: string[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
time(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
timeEnd(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
timeLog(label?: string, ...data: any[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
markTimeline(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
profile(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
profileEnd(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
timeStamp(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
timeline(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
timelineEnd(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
}

View File

@@ -1,7 +0,0 @@
export namespace amqp {
export const Manager = Symbol('AmqpManager')
export namespace rabbit {
export const Admin = Symbol('RabbitAdmin')
export const Template = Symbol('RabbitTemplate')
}
}

View File

@@ -1,5 +0,0 @@
export namespace database {
export const DataBaseManager = Symbol("DataBaseManager");
export const DataSource = Symbol("DataSource");
export const DataBase = Symbol("DataBase");
}

View File

@@ -1,5 +1,2 @@
export * from './web'
export * from './amqp'
export * from './plugin'
export * from './server'
export * from './database'

View File

@@ -2,147 +2,73 @@ export namespace plugin {
/**
* MiaoScript Plugin
*/
export const Plugin = Symbol("Plugin")
export const Plugin = Symbol("Plugin");
/**
* MiaoScript Plugin Folder
*/
export const PluginFolder = Symbol("PluginFolder")
export const PluginFolder = Symbol("PluginFolder");
/**
* Runtime Plugin Instance
*/
export const PluginInstance = Symbol("PluginInstance")
export const PluginInstance = Symbol("PluginInstance");
/**
* MiaoScript Plugin Manager Symbol
*/
export const PluginManager = Symbol("PluginManager")
export const PluginManager = Symbol("PluginManager");
/**
* MiaoScript Plugin Manager Interface
*/
export interface PluginManager {
scan(folder: string): void
build(): void
loadFromFile(file: string, scanner?: plugin.PluginScanner): Plugin
load(...args: any[]): void
enable(...args: any[]): void
disable(...args: any[]): void
reload(...args: any[]): void
getPlugin(name: string): plugin.Plugin
getPlugins(): Map<string, plugin.Plugin>
}
export const PluginScanner = Symbol("PluginScanner")
/**
* 插件扫描器
*/
export interface PluginScanner {
/**
* 扫描器类型
*/
type: string
/**
* 扫描插件 返回插件加载列表
* @param target 扫描目标
*/
scan(target: any): string[]
/**
* 加载扫描到的目标
* @param target 加载目标
*/
load(target: any): any
}
export const PluginLoader = Symbol("PluginLoader")
/**
* 插件加载器
*/
export interface PluginLoader {
/**
* 加载器类型
*/
type: string
/**
* 加载插件 获取元数据
* @param target 加载目标
* @param result 扫描器加载的结果
*/
require(target: any, result: any): PluginMetadata
/**
* 构建插件
* @param metadata 插件元信息
*/
build(metadata: any): Plugin
/**
* Load 阶段
* @param plugin 插件
*/
load(plugin: Plugin): void
/**
* Enable 阶段
* @param plugin 插件
*/
enable(plugin: Plugin): void
/**
* Disable 阶段
* @param plugin 插件
*/
disable(plugin: Plugin): void
/**
* Reload 阶段
* @param plugin 插件
*/
reload(plugin: Plugin): void
scan(folder: string): void;
build(): void;
loadFromFile(file: string): Plugin;
load(...args: any[]): void;
enable(...args: any[]): void;
disable(...args: any[]): void;
reload(...args: any[]): void;
getPlugins(): Map<string, any>;
}
export interface Plugin {
description: PluginMetadata
logger: Console
load(): void
enable(): void
disable(): void
description: PluginMetadata;
logger: Console;
load(): void;
enable(): void;
disable(): void;
}
export interface BaseMetadata {
interface BaseMetadata {
/**
* 名称 为空则为对象名称
*/
name?: string
name?: string;
/**
* 支持的服务器列表 为空则代表所有
*/
servers?: string[]
servers?: string[];
}
export interface PluginMetadata extends BaseMetadata {
/**
* 插件名称
*/
name: string
name: string;
/**
* 前缀
*/
prefix?: string
prefix?: string;
/**
* 插件版本
*/
version: string
version: string;
/**
* 插件版本
*/
author: string | string[]
author: string | string[];
/**
* 插件源文件 必须指定为 __filename
*/
source: string
/**
* 插件类型 默认为 ioc 执行 MiaoScript 加载逻辑
*/
type?: string
/**
* 插件扫描器
*/
scanner?: PluginScanner
/**
* 插件加载器
*/
loader?: PluginLoader
source: string;
/**
* 插件本体
*/
target?: any
target?: any;
}
}

View File

@@ -1,143 +1,38 @@
import * as reflect from '@ccms/common/dist/reflect'
import { injectable } from '@ccms/container'
import { NativePluginManager } from './native_plugin'
import { constants } from '../../constants'
export namespace server {
/**
* Runtime ServerType
*/
export const ServerType = Symbol("ServerType")
export const ServerType = Symbol("ServerType");
/**
* Runtime Console
*/
export const Console = Symbol("Console")
export const Console = Symbol("Console");
/**
* MiaoScript Server
*/
export const Server = Symbol("Server")
export const Server = Symbol("Server");
/**
* Runtime Server Instance
*/
export const ServerInstance = Symbol("ServerInstance")
export const ServerInstance = Symbol("ServerInstance");
/**
* MiaoScript Server
*/
export interface Server {
getVersion(): string
getPlayer(name: string): any
getOnlinePlayers(): any[]
getConsoleSender(): any
getService(service: string): any
dispatchCommand(sender: string | any, command: string): boolean
dispatchConsoleCommand(command: string): boolean
getPluginsFolder(): string
getNativePluginManager(): NativePluginManager
getDedicatedServer?(): any
getNettyPipeline(): any
getRootLogger(): any
sendJson(sender: string | any, json: object | string): void
tabComplete?(sender: string | any, input: string, index?: number): string[]
}
@injectable()
export abstract class ReflectServer implements server.Server {
protected pipeline: any
protected rootLogger: any
constructor() {
this.reflect()
}
getVersion(): string {
throw new Error("Method not implemented.")
}
getPlayer(name: string) {
throw new Error("Method not implemented.")
}
getOnlinePlayers(): any[] {
throw new Error("Method not implemented.")
}
getConsoleSender() {
throw new Error("Method not implemented.")
}
getService(service: string) {
throw new Error("Method not implemented.")
}
dispatchCommand(sender: any, command: string): boolean {
throw new Error("Method not implemented.")
}
dispatchConsoleCommand(command: string): boolean {
throw new Error("Method not implemented.")
}
getPluginsFolder(): string {
throw new Error("Method not implemented.")
}
getNativePluginManager(): NativePluginManager {
throw new Error("Method not implemented.")
}
getDedicatedServer() {
throw new Error("Method not implemented.")
}
getNettyPipeline() {
throw new Error("Method not implemented.")
}
getRootLogger() {
throw new Error("Method not implemented.")
}
sendJson(sender: any, json: string | object): void {
throw new Error("Method not implemented.")
}
tabComplete?(sender: any, input: string, index?: number): string[] {
throw new Error("Method not implemented.")
}
protected reflect() {
try {
let consoleServer = this.getDedicatedServer()
this.reflectPipeline(consoleServer)
this.reflectRootLogger(consoleServer)
} catch (error) {
console.error('Error When Reflect MinecraftServer!', error)
console.ex(error)
}
}
protected reflectPipeline(consoleServer: any) {
let connection: any
let promise: any
for (const method of constants.Reflect.Method.getServerConnection) {
try {
connection = reflect.on(consoleServer).call(method).get()
if (connection.class.name.indexOf('ServerConnection') !== -1
|| connection.class.name.indexOf('NetworkSystem') !== -1) { break }
connection = undefined
} catch (error) { }
}
if (!connection) { console.error("Can't found ServerConnection!"); return }
for (const field of constants.Reflect.Field.listeningChannels) {
try {
promise = reflect.on(connection).get(field).get().get(0)
if (promise.class.name.indexOf('Promise') !== -1) { break }
promise = undefined
} catch (error) { }
}
if (!promise) { console.error("Can't found listeningChannels!"); return }
this.pipeline = reflect.on(promise).get('channel').get().pipeline()
}
protected reflectRootLogger(consoleServer: any) {
try {
this.rootLogger = reflect.on(consoleServer).get('LOGGER').get().parent
} catch (error) {
try { this.rootLogger = reflect.on(consoleServer).get(0).get().parent } catch (error) { }
}
if (this.rootLogger && this.rootLogger.class.name.indexOf('Logger') === -1) {
console.error('Error Logger Class: ' + this.rootLogger.class.name)
this.rootLogger = undefined
}
// get root logger
for (let index = 0; index < 5 && this.rootLogger.parent; index++) {
this.rootLogger = this.rootLogger.parent
}
if (!this.rootLogger) { console.error("Can't found rootLogger!") }
}
getVersion(): string;
getPlayer(name: string): any;
getOnlinePlayers(): any[];
getConsoleSender(): any;
getService(service: string): any;
dispatchCommand(sender: string | any, command: string): boolean;
dispatchConsoleCommand(command: string): boolean;
getPluginsFolder(): string;
getNativePluginManager(): NativePluginManager;
getNettyPipeline(): any;
getRootLogger(): any;
sendJson(sender: string | any, json: object | string): void;
tabComplete?(sender: string | any, input: string, index?: number);
}
}

View File

@@ -1,3 +0,0 @@
export namespace web {
export const Server = Symbol('Server')
}

View File

@@ -58,9 +58,9 @@ export namespace task {
return this;
}
protected run(...args: any[]): void {
protected run(): void {
try {
this.func(...args);
this.func();
} catch (ex) {
console.console('§4插件执行任务时发生错误', ex)
console.ex(ex);
@@ -69,9 +69,8 @@ export namespace task {
/**
* 提交任务
* @param args 任务参数
*/
abstract submit(...args: any[]): Cancelable;
abstract submit(): Cancelable;
}
/**
* 返可取消的对象

View File

@@ -7,12 +7,14 @@ import chat from './enhance/chat'
let Bukkit = org.bukkit.Bukkit;
@provideSingleton(server.Server)
export class BukkitServer extends server.ReflectServer {
export class BukkitServer implements server.Server {
private pluginsFolder: string;
private pipeline: any;
private rootLogger: any;
constructor() {
super();
this.pluginsFolder = Bukkit.getUpdateFolderFile().getParentFile().getCanonicalPath();
this.reflect()
}
getPlayer(name: string) {
@@ -45,9 +47,6 @@ export class BukkitServer extends server.ReflectServer {
getNativePluginManager() {
return Bukkit.getPluginManager() as any;
}
getDedicatedServer() {
return reflect.on(Bukkit.getServer()).get('console').get()
}
getNettyPipeline() {
return this.pipeline;
}
@@ -63,4 +62,41 @@ export class BukkitServer extends server.ReflectServer {
this.dispatchConsoleCommand(result)
}
}
private reflect() {
let consoleServer = reflect.on(Bukkit.getServer()).get('console').get()
this.reflectPipeline(consoleServer)
this.reflectRootLogger(consoleServer)
}
private reflectPipeline(consoleServer: any) {
let connection: any;
let promise: any;
for (const method of constants.Reflect.Method.getServerConnection) {
try {
connection = reflect.on(consoleServer).call(method).get()
if (connection.class.name.indexOf('ServerConnection') !== -1
|| connection.class.name.indexOf('NetworkSystem') !== -1) { break; }
connection = undefined;
} catch (error) { }
}
if (!connection) { console.error("Can't found ServerConnection!"); return }
for (const field of constants.Reflect.Field.listeningChannels) {
try {
promise = reflect.on(connection).get(field).get().get(0);
if (promise.class.name.indexOf('Promise') !== -1) { break; }
promise = undefined;
} catch (error) { }
}
if (!promise) { console.error("Can't found listeningChannels!"); return }
this.pipeline = reflect.on(promise).get('channel').get().pipeline()
}
private reflectRootLogger(consoleServer: any) {
try {
this.rootLogger = reflect.on(consoleServer).get('LOGGER').get().parent
} catch (error) {
console.error("Can't found rootLogger!")
}
}
}

View File

@@ -23,8 +23,10 @@ export class BukkitTaskManager implements task.TaskManager {
}
export class BukkitTask extends task.Task {
submit(...args: any[]): task.Cancelable {
let run = new BukkitRunnable({ run: () => this.run(...args) })
submit(): task.Cancelable {
let run = new BukkitRunnable({
run: () => this.run()
})
let funcName = `runTask${this.interval ? 'Timer' : 'Later'}${this.isAsync ? 'Asynchronously' : ''}`
if (this.interval) {
return run[funcName](this.plugin, this.laterTime, this.interval)

View File

@@ -22,8 +22,8 @@ export class BungeeTaskManager implements task.TaskManager {
}
export class BungeeTask extends task.Task {
submit(...args: any[]): task.Cancelable {
let run = new Runnable({ run: () => this.run(...args) })
submit(): task.Cancelable {
let run = new Runnable({ run: () => this.run() })
if (this.isAsync) {
return this.plugin.getProxy().getScheduler().runAsync(this.plugin, run)
}

View File

@@ -1,204 +1,196 @@
/// <reference types="@ccms/types/dist/typings/jdk" />
/**
* 反射工具类
* Created by MiaoWoo on 2017/2/9 0009.
*/
const JavaClass = Java.type('java.lang.Class')
const JavaClass = Java.type('java.lang.Class');
const JavaObject = Java.type('java.lang.Object')
const NoSuchFieldException = Java.type('java.lang.NoSuchFieldException')
const methodCache = []
const NoSuchFieldException = Java.type('java.lang.NoSuchFieldException');
const methodCache = [];
class Reflect {
private obj: java.lang.Object
private class: java.lang.Class
private obj: any;
private class: any
constructor(obj: any) {
// if (obj === undefined || obj === null) { throw Error(`reflect object can't be ${obj}!`) }
if (obj instanceof JavaClass) {
this.obj = null
this.class = obj
this.obj = null;
this.class = obj;
} else {
this.obj = obj
this.obj = obj;
if (obj !== null && obj !== undefined && obj.class) {
this.class = obj.class
this.class = obj.class;
}
}
}
method(name: string, ...args: any[]) {
return declaredMethod(this.class, name, args)
method(...args: any[]) {
return declaredMethod(this.class, args[0], types(args.slice(1)));
}
methods() {
return Java.from(declaredMethods(this.class))
return Java.from(declaredMethods(this.class));
}
field(name: string | java.lang.String): Reflect {
field(name): Reflect {
try {
// Try getting a public field
let field = this.class.getField(name)
return on(field.get(this.obj))
let field = this.class.field(name);
return on(field.get(this.obj));
} catch (ex) {
// Try again, getting a non-public field
return on(accessible(declaredField(this.class, name)).get(this.obj))
return on(accessible(declaredField(this.class, name)).get(this.obj));
}
}
};
fields(declared = false): java.lang.reflect.Field[] {
return Java.from(declared ? this.class.getDeclaredFields() : this.class.getFields())
fields(declared = false) {
return Java.from(declared ? this.class.declaredFields : this.class.fields);
}
values(declared = false) {
return this.fields(declared).reduce((cache, field) => { return cache[field.getName()] = this.field(field.getName()).get() }, {}) as any
let cache = {};
this.fields(declared).forEach(fed => cache[fed.name] = this.field(fed.name).get())
return cache;
}
call(...args: any[]): Reflect {
let params = args.slice(1)
let method = accessible(declaredMethod(this.class, args[0], ...types(params)))
let result = method.invoke(this.get(), params)
return result && on(result)
}
call(...args): Reflect {
let params = args.slice(1);
let method = accessible(declaredMethod(this.class, args[0], types(params)));
let result = method.invoke(this.get(), params);
return result && on(result);
};
get(): any
get(index: number, declared?: boolean): Reflect
get(prop: string): Reflect
get(param?: string | number, declared: boolean = true): Reflect | any {
if (param == undefined || param == null) return this.obj
if (typeof param == "number") {
return on(accessible(this.fields(declared)[param]).get(this.obj))
}
if (typeof param == "string") {
return this.field(param)
}
}
get(...args): Reflect | any {
return args.length === 1 ? this.field(args[0]) : this.obj;
};
set(name: any, value: any): Reflect {
accessible(declaredField(this.class, name)).set(this.obj, value)
return this
}
// noinspection JSUnusedGlobalSymbols
set(name, value): Reflect {
accessible(declaredField(this.class, name)).set(this.obj, value);
return this;
};
create(...args): Reflect {
return on(declaredConstructor(this.class, args).newInstance(args))
}
return on(declaredConstructor(this.class, args).newInstance(args));
};
}
/**
* Get an array of types for an array of objects
*/
function types(values: any[], def?: any) {
function types(values, def?) {
if (values === null) {
return []
return [];
}
let result: java.lang.Class[] = []
values.forEach(t => result.push((t || def) ? JavaObject.class : t instanceof JavaClass ? t : t.class))
return result
let result: any[] = [];
values.forEach(t => result.push((t || def) ? JavaObject.class : t instanceof JavaClass ? t : t.class));
return result;
}
function accessible<T extends java.lang.reflect.AccessibleObject>(accessible: T): T {
function accessible(accessible) {
if (accessible === null) {
return null
return null;
}
if (!accessible.isAccessible()) {
accessible.setAccessible(true)
accessible.setAccessible(true);
}
return accessible
return accessible;
}
function declaredConstructor(clazz, param) {
let constructor
let constructor;
try {
constructor = clazz.getDeclaredConstructor(types(param))
constructor = clazz.getDeclaredConstructor(types(param));
} catch (ex) {
try {
constructor = clazz.getDeclaredConstructor(types(param, true))
constructor = clazz.getDeclaredConstructor(types(param, true));
} catch (ex) {
constructor = clazz.getDeclaredConstructors()[0]
constructor = clazz.getDeclaredConstructors()[0];
}
}
return accessible(constructor)
return accessible(constructor);
}
function declaredField(clazz: java.lang.Class, name: string | java.lang.String) {
function declaredField(clazz, name) {
if (!clazz) { throw Error(`target class can't be ${clazz}!`) }
let target = clazz
let field = null
let target = clazz;
let field = null;
// noinspection JSUnresolvedVariable
while (target !== JavaObject.class) {
try {
field = target.getDeclaredField(name)
if (field !== null) { break }
field = target.getDeclaredField(name);
if (field !== null) { break; }
} catch (e) {
if (target === undefined) { break }
target = target.getSuperclass()
if (target === undefined) { break; }
target = target.getSuperclass();
}
}
if (field === null) {
throw new NoSuchFieldException(name + " is not found in " + clazz.getName())
throw new NoSuchFieldException(name + " is not found in " + clazz.name);
}
return field
return field;
}
function declaredMethod(clazz: java.lang.Class, name: string, ...clazzs: any[]): java.lang.reflect.Method {
let key = clazz.getName() + '.' + name + ':' + (clazzs || []).join(':')
function declaredMethod(clazz, name, clazzs) {
let key = clazz.name + '.' + name + ':' + (clazzs || []).join(':');
if (!methodCache[key]) {
try {
methodCache[key] = clazz.getMethod(name, clazzs as any)
methodCache[key] = clazz.getMethod(name, clazzs);
} catch (ex) {
try {
methodCache[key] = clazz.getDeclaredMethod(name, clazzs as any)
methodCache[key] = clazz.getDeclaredMethod(name, clazzs);
} catch (ex) {
for (const m of Java.from(declaredMethods(clazz))) {
if (m.name == name) {
methodCache[key] = m
break
methodCache[key] = m;
break;
}
}
}
}
}
return methodCache[key]
return methodCache[key];
}
function declaredMethods(clazz) {
return clazz.declaredMethods
return clazz.declaredMethods;
}
let classMethodsCache: any[] = []
let classMethodsCache: any[] = [];
function mapToObject(javaObj) {
if (!javaObj || !javaObj.class) { throw new TypeError(`参数 ${javaObj} 不是一个Java对象!`) }
let target = {}
getJavaObjectMethods(javaObj).forEach(t => mapMethod(target, javaObj, t))
return target
let target = {};
getJavaObjectMethods(javaObj).forEach(t => mapMethod(target, javaObj, t));
return target;
}
function getJavaObjectMethods(javaObj) {
let className = javaObj.class.name
let className = javaObj.class.name;
if (!classMethodsCache[className]) {
let names: any[] = []
let methods = javaObj.class.methods
let names: any[] = [];
let methods = javaObj.class.methods;
for (let i in methods) {
names.push(methods[i].name)
names.push(methods[i].name);
}
classMethodsCache[className] = names
classMethodsCache[className] = names;
}
return classMethodsCache[className]
return classMethodsCache[className];
}
function mapMethod(target, source, name) {
target[name] = function __SimpleDynamicMethod__(...args) {
if (args.length > 0) {
return source[name](args)
return source[name](args);
} else {
return source[name]()
return source[name]();
}
}
};
}
function on(obj) {
// if (!obj || !obj.class) { throw new TypeError(`参数 ${obj} 不是一个Java对象!`) }
return new Reflect(obj)
return new Reflect(obj);
}
export = {

View File

@@ -1,32 +0,0 @@
const Thread = Java.type('java.lang.Thread')
const ThreadGroup = Java.type("java.lang.ThreadGroup")
const AtomicInteger = Java.type("java.util.concurrent.atomic.AtomicInteger")
const ThreadPoolExecutor = Java.type('java.util.concurrent.ThreadPoolExecutor')
const LinkedBlockingQueue = Java.type("java.util.concurrent.LinkedBlockingQueue")
interface ThreadPoolConfig {
corePoolSize?: number
maximumPoolSize?: number
keepAliveTime?: number
workQueueSize?: number
groupName: string
}
export default {
create(config: ThreadPoolConfig): java.util.concurrent.ThreadPoolExecutor {
let threadCount = new AtomicInteger(0)
config = {
corePoolSize: 10,
maximumPoolSize: 100,
keepAliveTime: 60,
workQueueSize: 500,
...config
}
return new ThreadPoolExecutor(
config.corePoolSize, config.maximumPoolSize, config.keepAliveTime, Packages.java.util.concurrent.TimeUnit.SECONDS,
new LinkedBlockingQueue(config.workQueueSize),
(run: any) => new Thread(new ThreadGroup(config.groupName), run, config.groupName + "-" + threadCount.incrementAndGet()),
new ThreadPoolExecutor.CallerRunsPolicy()
)
}
}

View File

@@ -25,7 +25,6 @@
},
"dependencies": {
"inversify": "^5.0.1",
"inversify-binding-decorators": "^4.0.0",
"@ccms/nashorn": "^0.7.0"
"inversify-binding-decorators": "^4.0.0"
}
}

View File

@@ -1,7 +0,0 @@
export namespace ioc {
export const Autowired = Symbol('Autowired')
export const Resource = Symbol('Resource')
export const JavaClass = Symbol('JavaClass')
export const JavaInstance = Symbol('JavaInstance')
export const JavaStaticClass = Symbol('JavaStaticClass')
}

View File

@@ -1,9 +1,9 @@
import { interfaces, Container } from "inversify"
import { interfaces, Container } from "inversify";
let _container: Container
let _container: Container;
const ContainerInstance = Symbol.for("@ccms/ioc:Container")
const INJECTION = Symbol.for("INJECTION")
const ContainerInstance = Symbol.for("@ccms/ioc:Container");
const INJECTION = Symbol.for("INJECTION");
function _proxyGetter(
proto: any,
@@ -13,17 +13,17 @@ function _proxyGetter(
) {
function getter(this: object) {
if (doCache && !Reflect.hasMetadata(INJECTION, this, key)) {
Reflect.defineMetadata(INJECTION, resolve(), this, key)
Reflect.defineMetadata(INJECTION, resolve(), this, key);
}
if (Reflect.hasMetadata(INJECTION, this, key)) {
return Reflect.getMetadata(INJECTION, this, key)
return Reflect.getMetadata(INJECTION, this, key);
} else {
return resolve()
return resolve();
}
}
function setter(this: object, newVal: any) {
Reflect.defineMetadata(INJECTION, newVal, this, key)
Reflect.defineMetadata(INJECTION, newVal, this, key);
}
Object.defineProperty(proto, key, {
@@ -31,63 +31,63 @@ function _proxyGetter(
enumerable: true,
get: getter,
set: setter
})
});
}
function initContainer(container: Container) {
Reflect.defineMetadata(ContainerInstance, container, Reflect)
return _container = container
Reflect.defineMetadata(ContainerInstance, container, Reflect);
_container = container;
}
function getContainer(): Container {
return _container || initContainer(new Container())
return _container || Reflect.getMetadata(ContainerInstance, Reflect)
}
function makePropertyInjectDecorator(doCache: boolean) {
return function (serviceIdentifier: interfaces.ServiceIdentifier<any>) {
return function (proto: any, key: string): void {
return function(serviceIdentifier: interfaces.ServiceIdentifier<any>) {
return function(proto: any, key: string): void {
let resolve = () => {
return getContainer().get(serviceIdentifier)
}
_proxyGetter(proto, key, resolve, doCache)
}
}
return getContainer().get(serviceIdentifier);
};
_proxyGetter(proto, key, resolve, doCache);
};
};
}
function makePropertyInjectNamedDecorator(doCache: boolean) {
return function (serviceIdentifier: interfaces.ServiceIdentifier<any>, named: string) {
return function (proto: any, key: string): void {
return function(serviceIdentifier: interfaces.ServiceIdentifier<any>, named: string) {
return function(proto: any, key: string): void {
let resolve = () => {
return getContainer().getNamed(serviceIdentifier, named)
}
_proxyGetter(proto, key, resolve, doCache)
}
}
return getContainer().getNamed(serviceIdentifier, named);
};
_proxyGetter(proto, key, resolve, doCache);
};
};
}
function makePropertyInjectTaggedDecorator(doCache: boolean) {
return function (serviceIdentifier: interfaces.ServiceIdentifier<any>, key: string, value: any) {
return function (proto: any, propertyName: string): void {
return function(serviceIdentifier: interfaces.ServiceIdentifier<any>, key: string, value: any) {
return function(proto: any, propertyName: string): void {
let resolve = () => {
return getContainer().getTagged(serviceIdentifier, key, value)
}
_proxyGetter(proto, propertyName, resolve, doCache)
}
}
return getContainer().getTagged(serviceIdentifier, key, value);
};
_proxyGetter(proto, propertyName, resolve, doCache);
};
};
}
function makePropertyMultiInjectDecorator(doCache: boolean) {
return function (serviceIdentifier: interfaces.ServiceIdentifier<any>) {
return function (proto: any, key: string): void {
return function(serviceIdentifier: interfaces.ServiceIdentifier<any>) {
return function(proto: any, key: string): void {
let resolve = () => {
return getContainer().getAll(serviceIdentifier)
}
_proxyGetter(proto, key, resolve, doCache)
}
}
return getContainer().getAll(serviceIdentifier);
};
_proxyGetter(proto, key, resolve, doCache);
};
};
}
let doCache = true
let doCache = true;
let lazyInject = makePropertyInjectDecorator(doCache)
let lazyInjectNamed = makePropertyInjectNamedDecorator(doCache)
@@ -102,4 +102,4 @@ export {
lazyInjectNamed,
lazyInjectTagged,
lazyMultiInject
}
};

View File

@@ -1,91 +1,25 @@
/// <reference types="@ccms/nashorn" />
import "reflect-metadata";
import { initContainer } from './decorators'
import { interfaces, Container } from 'inversify';
import { fluentProvide } from 'inversify-binding-decorators';
import "reflect-metadata"
import { initContainer, getContainer } from './decorators'
import { interfaces, Container } from 'inversify'
import { fluentProvide } from 'inversify-binding-decorators'
import { ioc } from "./constants"
const provideNamed = (identifier: interfaces.ServiceIdentifier<any>, name: string) => {
return fluentProvide(identifier).whenTargetNamed(name).done();
};
/**
* 注册一个命名对象
* @param identifier 标识符
* @param name 名称
*/
export const provideNamed = (identifier: interfaces.ServiceIdentifier<any>, name: string) => {
return fluentProvide(identifier).whenTargetNamed(name).done()
}
const provideSingleton = (identifier: interfaces.ServiceIdentifier<any>) => {
return fluentProvide(identifier).inSingletonScope().done();
};
/**
* 注册一个单例对象
* @param identifier 标识符
*/
export const provideSingleton = (identifier: interfaces.ServiceIdentifier<any>) => {
return fluentProvide(identifier).inSingletonScope().done()
}
/**
* 注册一个单例对象
* @param identifier 标识符
*/
export const provideSingletonNamed = (identifier: interfaces.ServiceIdentifier<any>, name: string) => {
return fluentProvide(identifier).inSingletonScope().whenTargetNamed(name).done()
}
/**
* 获得一个 java.lang.Class
* @param className Java全类名
*/
export const JavaClass = (className: string) => {
return function (target: any, propertyKey: string, index?: number) {
try { target[propertyKey] = Java.type(className).class; return } catch (error) { }
try { target[propertyKey] = base.getClass(className); return } catch (error) { }
console.warn('JavaClass Inject target', target, 'propertyKey', propertyKey, 'failed!')
}
}
/**
* 获得一个JS的Java类
* @param className Java 全类名
*/
export const JSClass = (className: string) => {
return function (target: any, propertyKey: string, index?: number) {
try { target[propertyKey] = Java.type(className); return } catch (error) { }
try { target[propertyKey] = base.getClass(className).static; return } catch (error) { }
console.warn('JSClass Inject target', target, 'propertyKey', propertyKey, 'failed!')
}
}
/**
* 自动注入实例由平台实现
* @param className 类名
*/
export const Autowired = (className?: string | any) => {
return function (target: any, propertyKey: string) {
target[propertyKey] = getContainer().getNamed(ioc.Autowired, className || propertyKey)
}
}
/**
* 自动注入资源由平台实现
* @param className 类名
*/
export const Resource = (resourceName?: string | any) => {
return function (target: any, propertyKey: string) {
target[propertyKey] = getContainer().getNamed(ioc.Resource, resourceName || propertyKey)
}
}
export const reduceMetadata = (ctx: interfaces.Context): any => {
return ctx.currentRequest.target.metadata.reduce((result, entry, index) => {
result[entry.key] = entry.value
return result
}, {})
}
export const DefaultContainer = new Container()
initContainer(DefaultContainer)
const DefaultContainer = new Container();
initContainer(DefaultContainer);
export * from 'inversify'
export * from './constants'
export * from './decorators'
export * from 'inversify-binding-decorators'
export {
fluentProvide,
provideNamed,
provideSingleton,
DefaultContainer
};

View File

@@ -26,16 +26,17 @@ class MiaoScriptCore {
}
loadServerConsole() {
global.setGlobal('eventCenter', new EventEmitter(), { writable: false, configurable: false });
//@ts-ignore
global.setGlobal('console', new this.Console(), { writable: false, configurable: false })
}
loadTaskFunction() {
global.setGlobal('setTimeout', (func: Function, tick: number, ...args: any[]) => {
return this.taskManager.create(func).later(tick).submit(...args)
global.setGlobal('setTimeout', (func: Function, tick: number, async: boolean = false) => {
this.taskManager.create(func).later(tick).async(async).submit()
}, { writable: false, configurable: false })
global.setGlobal('setInterval', (func: Function, tick: number, ...args: any[]) => {
return this.taskManager.create(func).timer(tick).submit(...args)
global.setGlobal('setInterval', (func: Function, tick: number, async: boolean = false) => {
this.taskManager.create(func).timer(tick).async(async).submit()
}, { writable: false, configurable: false })
}
@@ -53,8 +54,8 @@ class MiaoScriptCore {
console.i18n("ms.core.engine.disable")
this.pluginManager.disable(this.pluginManager.getPlugins())
this.taskManager.disable()
process.emit('exit', 0)
process.exit(0)
//@ts-ignore
require.disable()
}
}

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,30 +0,0 @@
{
"name": "@ccms/database",
"version": "0.7.0",
"description": "MiaoScript database package",
"keywords": [
"miaoscript",
"minecraft",
"bukkit",
"sponge"
],
"author": "MiaoWoo <admin@yumc.pw>",
"homepage": "https://github.com/circlecloud/ms.git",
"license": "ISC",
"main": "dist/index.js",
"scripts": {
"clean": "rimraf dist",
"watch": "tsc --watch",
"build": "yarn clean && tsc",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.2"
},
"dependencies": {
"@ccms/api": "^0.7.0",
"@ccms/container": "^0.7.0"
}
}

View File

@@ -1,3 +0,0 @@
export const METADATA_KEY = {
}

View File

@@ -1,92 +0,0 @@
/// <reference types="@ccms/types/dist/typings/spring" />
import { Model } from './model'
const HikariDataSource = Java.type('com.zaxxer.hikari.HikariDataSource')
const HikariConfig = Java.type('com.zaxxer.hikari.HikariConfig')
const JdbcTemplate = Java.type('org.springframework.jdbc.core.JdbcTemplate')
/**
* 数据库配置
*/
export interface DataBaseConfig {
/**
* 数据库连接串
*/
url: string | javax.sql.DataSource
/**
* 数据库驱动
*/
driverClassName?: string
/**
* 用户名
*/
username?: string
/**
* 密码
*/
password?: string
}
/**
* 数据库封装类
*/
export class DataBase {
private dataSource: javax.sql.DataSource
private jdbcTemplate: org.springframework.jdbc.core.JdbcTemplate
constructor(dbConfig: DataBaseConfig) {
if (!dbConfig.url) { throw new Error('DataBase url can\'t be null!') }
this.createDataSource(dbConfig)
this.initialize()
}
private createDataSource(dbConfig: DataBaseConfig) {
if (typeof dbConfig.url === "string") {
if (!dbConfig.username || !dbConfig.password) {
throw new Error('DataBase username or password can\'t be null!')
}
let config = new HikariConfig()
if (dbConfig.driverClassName) {
config.setDriverClassName(dbConfig.driverClassName)
}
config.setUsername(dbConfig.username)
config.setPassword(dbConfig.password)
config.setJdbcUrl(dbConfig.url)
this.dataSource = new HikariDataSource(config)
} else {
this.dataSource = dbConfig.url
}
}
private initialize() {
this.jdbcTemplate = new JdbcTemplate(this.dataSource)
}
/**
* 执行SQL查询
* @param sql SQL语句
*/
query<T>(sql: string, ...args: any[]): Array<T> {
let startTime = Date.now()
let result = Java.from(this.jdbcTemplate.queryForList(sql, args))
console.debug(java.lang.String.format(`\n[DB] query \nSQL : ${sql.replace(/\?/ig, '%s')} \nCOST : ${Date.now() - startTime}ms`, args))
return result
}
/**
* 执行SQL更新
* @param sql SQL语句
*/
update(sql: string, ...args: any[]): number {
let startTime = Date.now()
let result = this.jdbcTemplate.update(sql, args)
console.debug(java.lang.String.format(`\n[DB] update \nSQL : ${sql.replace(/\?/ig, '%s')} \nCOST : ${Date.now() - startTime}ms`, args))
return result
}
close() {
//@ts-ignore
this.dataSource.close()
}
}

View File

@@ -1,7 +0,0 @@
import 'reflect-metadata'
export function id() {
return (target: Object, propertyKey: string | symbol) => void {
}
}

View File

@@ -1,5 +0,0 @@
/// <reference types="@ccms/nashorn" />
/// <reference types="@ccms/types/dist/typings/jdk/index" />
export * from './database'
export * from './manager'

View File

@@ -1,53 +0,0 @@
import { plugin, database } from '@ccms/api'
import { provideSingleton, inject, postConstruct } from '@ccms/container'
import { DataBase, DataBaseConfig } from './database'
@provideSingleton(database.DataBaseManager)
export class DataBaseManager {
@inject(plugin.PluginInstance)
private instance: any
private beanFactory: any
private mainDatabase: DataBase
private databases: { [key: string]: DataBase } = {}
@postConstruct()
initialize() {
try {
this.beanFactory = this.instance.getAutowireCapableBeanFactory()
let mainDatasource = this.beanFactory.getBean(Packages.javax.sql.DataSource.class)
this.mainDatabase = new DataBase({ url: mainDatasource })
} catch (error) {
console.ex(error)
}
}
/**
* 获得主数据库
* Get MainDatabase
*/
getMainDatabase() {
return this.mainDatabase
}
/**
* 创建数据库
* Create A Database Instance
* @param name 数据库名称 用于代码 database Name use at code
* @param config 数据库配置
*/
createDatabase(name: string, config: DataBaseConfig) {
Java.synchronized(() => {
if (this.databases[name]) return this.databases[name]
return this.databases[name] = new DataBase(config)
}, this.databases)()
}
getDatabase(name: string) {
return this.databases[name]
}
disable() {
Object.values(this.databases).forEach((ds) => ds?.close())
}
}

View File

@@ -1,11 +0,0 @@
import { DataBase } from "./database"
export class Model<T> {
constructor(private database: DataBase) {
}
queryForList(): Array<T> {
return []
}
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "src",
"outDir": "dist"
}
}

12
packages/nashorn/build.sh Executable file
View File

@@ -0,0 +1,12 @@
# sponge bukkit jdk bungee nukkit
TYPE=nukkit
TARGET=../types/dist/typings
npx tsc src/build.ts --outDir dist
cd dist
rm -rf temp
mkdir -p temp
node build.js ${TYPE}
cd ../
rm -rf ${TARGET}/${TYPE}
mkdir -p ${TARGET}/${TYPE}
cp dist/temp/* ${TARGET}/${TYPE}/ -R

View File

@@ -0,0 +1,200 @@
import * as fs from "fs";
function convertJson2TypeDefiend(infile: string, outDir: string) {
const file = infile.split(".json")[0];
const json = fs.readFileSync(`${inDir}/${file}.json`).toString();
const obj = JSON.parse(json);
const qnas: string[] = obj.qualifiedName.split(".");
let closeBuk = 0;
let temp = `declare namespace ${qnas[0]} {\n`;
closeBuk++;
const nms = qnas.slice(1, qnas.length - 1);
for (const nm of nms) {
temp += `${' '.repeat(closeBuk)}namespace ${nm.replace('function', 'function$')} {\n`;
closeBuk++;
}
let classModifier = formatClassModifier(obj.modifiers)
temp += `${' '.repeat(closeBuk)}// @ts-ignore\n`
temp += `${' '.repeat(closeBuk)}${classModifier}${qnas[qnas.length - 1]}`
let isInterface = classModifier.includes('interface')
let safeInterface = [];
for (const ifs of obj.interfaces) {
if (!ifs.qualifiedName.startsWith('java')) {
safeInterface.push(ifs)
}
}
if (isInterface) {
if (safeInterface.length > 0) {
temp += ' extends '
for (const ifs of safeInterface) {
temp += ifs.qualifiedName;
temp += ', '
}
temp = temp.substr(0, temp.length - 2);
}
} else {
temp += `${(obj.superclass) ? (' extends ' + (obj.superclass.qualifiedName == "<any>" ? "object" : obj.superclass.qualifiedName)) : ''}`;
if (safeInterface.length > 0) {
temp += ' implements '
for (const ifs of safeInterface) {
temp += ifs.qualifiedName;
temp += ', '
}
temp = temp.substr(0, temp.length - 2);
}
}
temp += ' {\n'
closeBuk++;
for (const constructor of obj.constructors) {
temp += `${formatDoc(constructor.docString, closeBuk)}${' '.repeat(closeBuk)}// @ts-ignore\n${' '.repeat(closeBuk)}constructor(${formatParameters(constructor.parameters)})\n`;
}
let members = [];
let methods = '';
for (const method of obj.methods) {
let methodModifier = isInterface ? '' : replaceModifiers(method.modifiers, classModifier.includes('abstract'))
if (!whiteKey.includes(method.name)) {
if (members[method.name] && methodModifier.includes('abstract')) {
continue;
}
members[method.name] = methodModifier;
}
methods += `${formatDoc(method.docString, closeBuk)}${' '.repeat(closeBuk)}// @ts-ignore\n${' '.repeat(closeBuk)}${methodModifier} ${method.name}(${formatParameters(method.parameters)}): ${mappingType(method.returnType.type)};\n`;
}
let fields = '';
for (const field of obj.fields) {
if (members[field.name]) {
continue;
}
fields += `${' '.repeat(closeBuk)}// @ts-ignore\n${' '.repeat(closeBuk)}${isInterface ? '' : replaceModifiers(field.modifiers)} ${field.name}: ${mappingType(field.type ? field.type.type : "any")};\n`;
}
temp += fields + methods;
for (let index = 0; index < closeBuk; index++) {
temp += `${' '.repeat(closeBuk - index - 1)}}\n`;
}
fs.writeFileSync(`${outDir}/${file}.${suffix}`, temp);
return `${file}.${suffix}`;
}
function formatClassModifier(modifiers: string) {
let tempm = modifiers.replace('public', '').replace('static', '').replace('final', '').trim();
if (!modifiers.includes('interface')) { tempm += ' class' }
return tempm.length > 0 ? (tempm + ' ') : '';
}
function formatDoc(doc: string, closeBuk: number) {
let middleDoc = '';
for (const line of doc.split('\n')) {
if (line.trim().length != 0) {
middleDoc += `${' '.repeat(closeBuk)} * ${line.trim()}\n`
}
}
return middleDoc.length > 0 ? `${' '.repeat(closeBuk)}/**\n${middleDoc}${' '.repeat(closeBuk)} */\n` : '';
}
function replaceModifiers(modifiers: string, absClass = false): string {
// modifiers = modifiers.replace(' final', ' readonly');
modifiers = modifiers.split(" final")[0];
modifiers = modifiers.split(" native")[0];
modifiers = modifiers.split(" volatile")[0];
modifiers = modifiers.split(" transient")[0];
modifiers = modifiers.split(" synchronized")[0];
if (!absClass) {
modifiers = modifiers.split(" abstract")[0];
}
return modifiers;
}
function formatParameters(params: any[]) {
let tempParam = '';
for (const p of params) {
tempParam += `${mappingName(p.name)}: ${mappingType(p.type ? p.type.qualifiedName : 'any')}, `
}
return tempParam.substr(0, tempParam.length - 2);
}
const nameMap = [];
nameMap['function'] = 'func'
nameMap['in'] = 'input'
nameMap['var'] = 'variable'
function mappingName(name: string) {
if (whiteKey.includes(name)) { return name }
let outName = nameMap[name] || name || '';
return outName;
}
let whiteKey = ['shift', "map", 'filter', 'values', 'valueOf', 'toString', 'length', 'includes', 'entries', 'keys', 'join', 'fill']
const typeMap = [];
typeMap['int'] = 'number';
typeMap['int[]'] = 'number[]';
typeMap['int[][]'] = 'number[][]';
typeMap['byte'] = 'number';
typeMap['byte[]'] = 'number[]';
typeMap['double'] = 'number';
typeMap['double[]'] = 'number[]';
typeMap['short'] = 'number';
typeMap['short[]'] = 'number[]';
typeMap['float'] = 'number';
typeMap['float[]'] = 'number[]';
typeMap['long'] = 'number';
typeMap['long[]'] = 'number[]';
typeMap['<any>'] = 'any';
typeMap['char'] = 'string';
typeMap['char[]'] = 'string[]';
typeMap['java.lang.String'] = "string";
// typeMap['java.util.Date'] = 'any /*java.util.Date*/'
// typeMap['java.util.List'] = 'any[] /*java.util.List*/'
// typeMap['java.util.Set'] = 'any[] /*java.util.Set*/'
// typeMap['java.util.Collection'] = 'any[] /*java.util.Collection*/'
// typeMap['java.util.Map'] = 'Map<any, any> /*java.util.Map*/'
// Sponge
typeMap['Vectori'] = 'any /*Vector3i*/'
typeMap['Vectord'] = 'any /*Vector3d*/'
typeMap['Vectorf'] = 'any /*Vector3f*/'
typeMap['Vector2i'] = 'any /*Vector2i*/'
typeMap['Vector2d'] = 'any /*Vector2d*/'
typeMap['Vector2f'] = 'any /*Vector2f*/'
typeMap['Vector3i'] = 'any /*Vector3i*/'
typeMap['Vector3d'] = 'any /*Vector3d*/'
typeMap['Vector3f'] = 'any /*Vector3f*/'
typeMap['Type'] = 'any /*Type*/'
typeMap['Gson'] = 'any /*Gson*/'
typeMap['Logger'] = 'any /*Logger*/'
typeMap['MethodVisitor'] = 'any /*MethodVisitor*/'
typeMap['ConfigurationNode'] = 'any /*ConfigurationNode*/'
typeMap['TypeSerializerCollection'] = 'any /*TypeSerializerCollection*/'
typeMap['Quaterniond'] = 'any /*Quaterniond*/'
typeMap['Matrix2d'] = 'any /*Matrix2d*/'
typeMap['Matrix3d'] = 'any /*Matrix3d*/'
typeMap['Matrix4d'] = 'any /*Matrix4d*/'
function mappingType(type: string): string {
let outType = typeMap[type] || type || 'any';
if (outType.indexOf('.') != -1) {
if (outType.startsWith('java.') || outType.startsWith('org.') || outType.startsWith('net.') || outType.startsWith('cn.')) {
} else {
outType = `any /*${outType}*/`
}
}
return outType.replace('function', 'function$');
}
var args = process.argv.splice(2)
const suffix = 'd.ts'
const inDir = `../docs/${args[0]}`
const outDir = "./temp";
const files = fs.readdirSync(inDir);
let index = '';
for (const file of files) {
index += `/// <reference path="./${convertJson2TypeDefiend(file, outDir)}" />\n`;
}
fs.writeFileSync(`${outDir}/index.${suffix}`, index);

View File

@@ -1,85 +1,79 @@
declare global {
const __FILE__: string
const __LINE__: number
const __DIR__: string
const Packages: any
const __FILE__: string;
const __LINE__: number;
const __DIR__: string;
let Packages: any;
function print(...message: any[]): void
function load(script: string | object)
function loadWithNewGlobal(script: string | object)
function exit(code?: number)
function quit(code?: number)
function JavaImporter(...className: string[])
function print(...message: any[]): void;
function load(script: string | object);
function loadWithNewGlobal(script: string | object);
function exit(code?: number);
function quit(code?: number);
function JavaImporter(...className: string[]);
namespace Java {
function type<T = any>(clazz: string): T
function from<T>(javaObj: T[]): T[]
function to<T>(array: T[], type?: T): T[]
function extend(...parentTypes: any[]): any
function synchronized(func: () => void, lock: any): Function
function asJSONCompatible<T = any>(obj: T): T
function type(clazz: string): any;
function from(javaObj: any): any[];
function to(array: any[]): any;
function extend(...parentTypes: any[]);
//@ts-ignore
// function super(type: any);
}
interface Error {
readonly class?: any
readonly lineNumber?: number
readonly columnNumber?: number
readonly fileName?: string
dumpStack?: Function
printStackTrace?: Function
getStackTrace?: () => any[]
readonly lineNumber?: number;
readonly columnNumber?: number;
readonly fileName?: string;
dumpStack?: Function;
printStackTrace?: Function;
getStackTrace?: () => any[];
}
interface String {
trimLeft(): string
trimRight(): string
trimLeft(): string;
trimRight(): string;
}
interface Object {
setPrototypeOf(obj: object, prototype: object): void
bindProperties(to: object, from: object): void
setPrototypeOf(obj: object, prototype: object): void;
bindProperties(to: object, from: object): void;
}
namespace NodeJS {
interface Global {
scope: string
logger: any
debug: boolean
level: string
NashornEngineStartTime: number
setGlobal: (key: string, value: any, config?: PropertyDescriptor & ThisType<any>) => void
noop: () => void
console: Console
}
interface Process {
on(event: string, listener: any): this
emit(event: string, ...message: any): this
scope: string;
logger: any;
debug: boolean;
level: string;
eventCenter: EventEmitter;
NashornEngineStartTime: number;
setGlobal: (key: string, value: any, config?: PropertyDescriptor & ThisType<any>) => void;
noop: () => void;
console: Console;
}
}
const root: string
const base: Core
const ScriptEngineContextHolder: any
function engineLoad(str: string | { script: string, name: string }): any
var root: string;
var base: Core;
var ScriptEngineContextHolder: any;
function engineLoad(str: string): any;
interface Core {
getClass(name: String): any
getProxyClass(): any
getInstance(): any
read(path: string): string
save(path: string, content: string): void
delete(path: string): void
getClass(name: String): any;
getProxyClass(): any;
getInstance(): any;
read(path: string): string;
save(path: string, content: string): void;
delete(path: string): void;
}
interface Console {
ex(err: Error): void
stack(err: Error, color?: boolean): string[]
sender(...args: any): void
console(...args: any): void
i18n(name: string, ...params: any[]): void
ex(err: Error): void;
stack(err: Error): string[];
sender(...args: any): void;
console(...args: any): void;
i18n(name: string, ...params: any[]): void;
}
interface ProxyConstructor {
newProxy<T extends object>(target: T, handler: ProxyHandler<T>): T
newProxy<T extends object>(target: T, handler: ProxyHandler<T>): T;
}
}
export { }
export { };

View File

@@ -21,8 +21,10 @@ export class NukkitTaskManager implements task.TaskManager {
}
export class NukkitTask extends task.Task {
submit(...args: any[]): task.Cancelable {
let run = new NukkitRunnable({ run: () => this.run(...args) })
submit(): task.Cancelable {
let run = new NukkitRunnable({
run: () => this.run()
})
let funcName = `runTask${this.interval ? 'Timer' : 'Later'}${this.isAsync ? 'Asynchronously' : ''}`
if (this.interval) {
run[funcName](this.plugin, this.laterTime, this.interval);

View File

@@ -1,15 +1,13 @@
/// <reference types="@ccms/nashorn" />
import i18n from '@ccms/i18n'
let ployfillStartTime = new Date().getTime()
i18n.initialize()
console.i18n("ms.ployfill.initialize")
require('./es5-ext')
require('./node-shim')
require('core-js')
//@ts-ignore
process.on('exit', () => require.disable())
let ployfillStartTime = new Date().getTime();
i18n.initialize();
console.i18n("ms.ployfill.initialize");
require('./es5-ext');
require('core-js');
require('./node-shim');
global.setGlobal('Proxy', require('./proxy').Proxy)
global.setGlobal('XMLHttpRequest', require('./xml-http-request').XMLHttpRequest)
global.setGlobal('Blob', require('blob-polyfill').Blob)
console.i18n("ms.ployfill.completed", { time: (new Date().getTime() - ployfillStartTime) / 1000 })
console.i18n("ms.ployfill.completed", { time: (new Date().getTime() - ployfillStartTime) / 1000 });

View File

@@ -1,36 +1,8 @@
import { EventEmitter } from 'events'
const Thread = Java.type('java.lang.Thread')
const ThreadGroup = Java.type("java.lang.ThreadGroup")
const AtomicInteger = Java.type("java.util.concurrent.atomic.AtomicInteger")
const ThreadPoolExecutor = Java.type('java.util.concurrent.ThreadPoolExecutor')
const LinkedBlockingQueue = Java.type("java.util.concurrent.LinkedBlockingQueue")
const threadCount = new AtomicInteger(0)
const threadGroup = new ThreadGroup("@ccms/ployfill-micro-task")
const microTaskPool = new ThreadPoolExecutor(
10, 100, 60, Packages.java.util.concurrent.TimeUnit.SECONDS,
new LinkedBlockingQueue(500),
(run: any) => new Thread(threadGroup, run, "@ccms/micro-task-" + threadCount.incrementAndGet()),
new ThreadPoolExecutor.CallerRunsPolicy()
)
class Process extends EventEmitter {
env = {
global.setGlobal('process', {
env: {
__noSuchProperty__: (prop) => {
return Packages.java.lang.System.getenv(prop)
}
}
platform = Packages.java.lang.System.getProperty("os.name")
nextTick(func: Function) {
microTaskPool.execute(func)
}
queueMicrotask(func: Function) {
microTaskPool.execute(func)
}
exit() {
microTaskPool.shutdown();
}
}
global.setGlobal('process', new Process(), {})
global.setGlobal('queueMicrotask', (func: any) => microTaskPool.execute(func), {})
},
platform: Packages.java.lang.System.getProperty("os.name")
}, {})

View File

@@ -1,4 +1,3 @@
import { plugin as pluginApi } from "@ccms/api"
import { injectable, decorate } from "@ccms/container"
import { interfaces } from './interfaces'
import { METADATA_KEY } from './constants'
@@ -8,16 +7,16 @@ import { getPluginMetadatas, getPluginCommandMetadata, getPluginListenerMetadata
* MiaoScript plugin
* @param metadata PluginMetadata
*/
export function plugin(metadata: pluginApi.PluginMetadata) {
export function plugin(metadata: interfaces.PluginMetadata) {
return function (target: any) {
metadata.target = target
metadata.type = "ioc"
decorate(injectable(), target)
Reflect.defineMetadata(METADATA_KEY.plugin, metadata, target)
const previousMetadata: Map<string, pluginApi.PluginMetadata> = getPluginMetadatas()
const previousMetadata: Map<string, interfaces.PluginMetadata> = getPluginMetadatas()
previousMetadata.set(metadata.name, metadata)
Reflect.defineMetadata(METADATA_KEY.plugin, previousMetadata, Reflect)
const previousSources: Map<string, pluginApi.PluginMetadata> = getPluginSources()
const previousSources: Map<string, interfaces.PluginMetadata> = getPluginSources()
previousSources.set(metadata.source.toString(), metadata)
Reflect.defineMetadata(METADATA_KEY.souece, previousSources, Reflect)
}

View File

@@ -1,15 +1,3 @@
import './scanner/file-scanner'
import './loader/ioc-loader'
import './loader/basic-loader'
export * from './manager'
export * from './decorators'
export * from './interfaces'
export {
plugin as JSPlugin,
cmd as Cmd,
tab as Tab,
listener as Listener,
config as Config
} from './decorators'

View File

@@ -1,14 +1,14 @@
import { server, MiaoScriptConsole, event, plugin } from "@ccms/api"
import { injectable, inject, postConstruct } from "@ccms/container"
import { getPluginMetadata } from "./utils"
import { server, MiaoScriptConsole, event } from "@ccms/api";
import { injectable, inject, postConstruct } from "@ccms/container";
import { getPluginMetadata } from "./utils";
export namespace interfaces {
@injectable()
export abstract class Plugin implements plugin.Plugin {
public description: plugin.PluginMetadata
public logger: Console
export abstract class Plugin {
public description: PluginMetadata;
public logger: Console;
@inject(server.Console)
private Console: MiaoScriptConsole
private Console: MiaoScriptConsole;
constructor() {
this.description = getPluginMetadata(this)
@@ -24,49 +24,86 @@ export namespace interfaces {
public enable() { }
public disable() { }
}
export interface ExecMetadata extends plugin.BaseMetadata {
interface BaseMetadata {
/**
* 名称 为空则为对象名称
*/
name?: string;
/**
* 支持的服务器列表 为空则代表所有
*/
servers?: string[];
}
export interface PluginMetadata extends BaseMetadata {
/**
* 插件名称
*/
name: string;
/**
* 前缀
*/
prefix?: string;
/**
* 插件版本
*/
version: string;
/**
* 插件版本
*/
author: string | string[];
/**
* 插件源文件 必须指定为 __filename
*/
source: string;
/**
* 插件类型 默认为 ioc 执行 MiaoScript 加载逻辑
*/
type?: string;
/**
* 插件本体
*/
target?: any;
}
export interface ExecMetadata extends BaseMetadata {
/**
* 执行器
*/
executor?: string
executor?: string;
}
export interface CommandMetadata extends ExecMetadata {
/**
* 命令描述
*/
description?: string
/**
* 参数列表
*/
paramtypes?: string[]
paramtypes?: string[];
}
export interface ListenerMetadata extends ExecMetadata {
/**
* 监听优先级
*/
priority?: event.EventPriority
priority?: event.EventPriority;
/**
* 是否忽略已取消的事件
*/
ignoreCancel?: boolean
ignoreCancel?: boolean;
}
export interface ConfigMetadata extends plugin.BaseMetadata {
export interface ConfigMetadata extends BaseMetadata {
/**
* 配置文件版本号
*/
version?: number
version?: number;
/**
* 实体变量名称
*/
variable?: string
variable?: string;
/**
* 配置文件格式 默认 yml
*/
format?: string
format?: string;
/**
* 是否为只读(关闭时将不会自动保存)
*/
readonly?: boolean
readonly?: boolean;
}
export type PluginLike = Plugin | string
export type PluginLike = Plugin | string;
}

View File

@@ -1,24 +0,0 @@
import { plugin } from "@ccms/api"
import { provideSingleton } from "@ccms/container"
@provideSingleton(plugin.PluginLoader)
export class BasicLoader implements plugin.PluginLoader {
type: string = 'basic'
private pluginRequireMap: Map<string, any>
constructor() {
this.pluginRequireMap = new Map()
}
require(target: any, result: any) {
this.pluginRequireMap.set(target.toString(), result)
return result
}
build(metadata: plugin.PluginMetadata) {
return this.pluginRequireMap.get(metadata.source.toString())
}
load(plugin: plugin.Plugin): void { }
enable(plugin: plugin.Plugin): void { }
disable(plugin: plugin.Plugin): void { }
reload(plugin: plugin.Plugin): void { }
}

View File

@@ -1,97 +0,0 @@
import { plugin, server } from "@ccms/api"
import { inject, ContainerInstance, Container, provideSingleton } from "@ccms/container"
import { interfaces } from "../interfaces"
import { getPluginStageMetadata, getPluginSources } from "../utils"
@provideSingleton(plugin.PluginLoader)
export class IocLoader implements plugin.PluginLoader {
type: string = 'ioc'
@inject(ContainerInstance)
private container: Container
@inject(server.ServerType)
private serverType: string
private pluginMetadataMap: Map<string, plugin.PluginMetadata>
constructor() {
this.pluginMetadataMap = getPluginSources()
}
require(target: any, result: any) {
return this.pluginMetadataMap.get(target.toString())
}
build(metadata: plugin.PluginMetadata) {
if (!this.allowProcess(metadata.servers)) { return }
let pluginInstance: plugin.Plugin
try {
this.bindPlugin(metadata)
pluginInstance = this.container.getNamed<plugin.Plugin>(plugin.Plugin, metadata.name)
if (!(pluginInstance instanceof interfaces.Plugin)) {
console.i18n('ms.plugin.manager.build.not.extends', { source: metadata.source })
return
}
} catch (ex) {
console.i18n("ms.plugin.manager.initialize.error", { name: metadata.name, ex })
console.ex(ex)
}
return pluginInstance
}
load(plugin: plugin.Plugin): void {
this.stage(plugin, 'load')
}
enable(plugin: plugin.Plugin): void {
this.stage(plugin, 'enable')
}
disable(plugin: plugin.Plugin): void {
this.stage(plugin, 'disable')
}
reload(plugin: plugin.Plugin): void {
this.disable(plugin)
//@ts-ignore
require(plugin.description.source, { cache: false })
this.load(plugin)
this.enable(plugin)
}
private bindPlugin(metadata: plugin.PluginMetadata) {
try {
let pluginInstance = this.container.getNamed<plugin.Plugin>(plugin.Plugin, metadata.name)
if (pluginInstance.description.source + '' !== metadata.source + '') {
console.i18n('ms.plugin.manager.build.duplicate', { exists: pluginInstance.description.source, source: metadata.source })
}
this.container.rebind(plugin.Plugin).to(metadata.target).inSingletonScope().whenTargetNamed(metadata.name)
} catch{
this.container.bind(plugin.Plugin).to(metadata.target).inSingletonScope().whenTargetNamed(metadata.name)
}
}
private allowProcess(servers: string[]) {
// Not set servers -> allow
if (!servers || !servers.length) return true
// include !type -> deny
let denyServers = servers.filter(svr => svr.startsWith("!"))
if (denyServers.length !== 0) {
return !denyServers.includes(`!${this.serverType}`)
} else {
// only include -> allow
return servers.includes(this.serverType)
}
}
private stage(pluginInstance: plugin.Plugin, stageName: string) {
let stages = getPluginStageMetadata(pluginInstance, stageName)
for (const stage of stages) {
if (!this.allowProcess(stage.servers)) { continue }
console.i18n("ms.plugin.manager.stage.exec", { plugin: pluginInstance.description.name, name: stage.executor, stage: stageName, servers: stage.servers })
try {
pluginInstance[stage.executor].apply(pluginInstance)
} catch (error) {
console.i18n("ms.plugin.manager.stage.exec.error", { plugin: pluginInstance.description.name, executor: stage.executor, error })
console.ex(error)
}
}
}
}

View File

@@ -3,9 +3,9 @@ import { plugin, server, command, event } from '@ccms/api'
import { inject, provideSingleton, Container, ContainerInstance } from '@ccms/container'
import * as fs from '@ccms/common/dist/fs'
import { getPluginMetadatas, getPluginCommandMetadata, getPluginListenerMetadata, getPlugin, getPluginTabCompleterMetadata, getPluginConfigMetadata, getPluginStageMetadata, getPluginSources } from './utils'
import { interfaces } from './interfaces'
import { getConfigLoader } from './config'
import { getPluginCommandMetadata, getPluginListenerMetadata, getPluginTabCompleterMetadata, getPluginConfigMetadata } from './utils'
const Thread = Java.type('java.lang.Thread')
@@ -25,110 +25,59 @@ export class PluginManagerImpl implements plugin.PluginManager {
private EventManager: event.Event
private initialized: boolean = false
private sacnnerMap: Map<string, plugin.PluginScanner>
private loaderMap: Map<string, plugin.PluginLoader>
private instanceMap: Map<string, plugin.Plugin>
private metadataMap: Map<string, plugin.PluginMetadata>
constructor() {
this.sacnnerMap = new Map()
this.loaderMap = new Map()
this.instanceMap = new Map()
this.metadataMap = new Map()
}
private pluginRequireMap: Map<string, any>
private pluginInstanceMap: Map<string, interfaces.Plugin>
private pluginMetadataMap: Map<string, interfaces.PluginMetadata>
initialize() {
if (this.pluginInstance === undefined) { throw new Error("Can't found Plugin Instance!") }
if (this.initialized !== true) {
console.i18n('ms.plugin.initialize', { plugin: this.pluginInstance, loader: Thread.currentThread().contextClassLoader })
console.i18n('ms.plugin.event.map', { count: this.EventManager.mapEventName().toFixed(0), type: this.serverType })
let pluginScanner = this.container.getAll<plugin.PluginScanner>(plugin.PluginScanner)
pluginScanner.forEach((scanner) => {
console.debug(`loading plugin sacnner ${scanner.type}...`)
this.sacnnerMap.set(scanner.type, scanner)
})
let pluginLoaders = this.container.getAll<plugin.PluginLoader>(plugin.PluginLoader)
pluginLoaders.forEach((loader) => {
console.debug(`loading plugin loader ${loader.type}...`)
this.loaderMap.set(loader.type, loader)
})
this.pluginRequireMap = new Map()
this.pluginInstanceMap = new Map()
this.pluginMetadataMap = getPluginSources()
this.initialized = true
}
}
scan(folder: string): void {
if (!folder) { throw new Error('plugin scan folder can\'t be empty!') }
this.initialize()
for (const [, scanner] of this.sacnnerMap) {
try {
scanner.scan(folder).forEach(file => {
this.loadPlugin(file, scanner)
})
} catch (error) {
console.error(`plugin scanner ${scanner.type} occurred error ${error}`)
console.ex(error)
}
}
var plugin = fs.file(root, folder)
var files = this.scanFolder(plugin)
this.loadPlugins(files)
}
build(): void {
this.buildPlugins()
}
private logStage(plugin: plugin.Plugin, stage: string) {
private logStage(plugin: interfaces.Plugin, stage: string) {
console.i18n("ms.plugin.manager.stage", { stage, plugin: plugin.description.name, version: plugin.description.version, author: plugin.description.author })
}
private runPluginStage(plugin: plugin.Plugin, stage: string, ext: Function) {
if (!plugin) { throw new Error(`can't run runPluginStage ${stage} because plugin is ${plugin}`) }
try {
this.logStage(plugin, i18n.translate(`ms.plugin.manager.stage.${stage}`))
ext()
this.runCatch(plugin, stage)
this.runCatch(plugin, `${this.serverType}${stage}`)
plugin.description.loader[stage](plugin)
} catch (ex) {
console.i18n("ms.plugin.manager.stage.exec.error", { plugin: plugin.description.name, executor: stage, error: ex })
}
}
private loadPlugin(file: string, scanner: plugin.PluginScanner) {
try {
let requireInstance = scanner.load(file)
for (const [, loader] of this.loaderMap) {
let metadata = loader.require(file, requireInstance)
if (metadata && metadata.source && metadata.name) {
metadata.loader = loader
this.metadataMap.set(metadata.name, metadata)
return metadata
}
}
} catch (error) {
console.i18n("ms.plugin.manager.initialize.error", { name: file, ex: error })
console.ex(error)
}
console.console(`§efile §b${file} §ccan't load metadata. §eskip load!`)
private runPluginStage(plugin: interfaces.Plugin, stage: string, ext: Function) {
this.logStage(plugin, i18n.translate(`ms.plugin.manager.stage.${stage}`))
ext()
this.runCatch(plugin, stage)
this.runCatch(plugin, `${this.serverType}${stage}`)
this.execPluginStage(plugin, stage)
}
/**
* 从文件加载插件
* @param file java.io.File
*/
loadFromFile(file: string, scanner = this.sacnnerMap.get('file')): plugin.Plugin {
if (!file) { throw new Error('plugin file can\'t be null!') }
if (!scanner) { throw new Error('plugin scanner can\'t be null!') }
let metadata = this.loadPlugin(file, scanner)
let plugin = metadata.loader.build(metadata)
loadFromFile(file: string): interfaces.Plugin {
let metadata = this.loadPlugin(file)
let plugin = this.buildPlugin(metadata && metadata.description ? metadata.description : this.pluginMetadataMap.get(file.toString()))
this.load(plugin)
this.enable(plugin)
return plugin
}
load(...args: any[]): void {
this.checkAndGet(args[0]).forEach((plugin: plugin.Plugin) => {
this.checkAndGet(args[0]).forEach((plugin: interfaces.Plugin) => {
this.runPluginStage(plugin, 'load', () => {
this.loadConfig(plugin)
})
@@ -136,7 +85,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
}
enable(...args: any[]): void {
this.checkAndGet(args[0]).forEach((plugin: plugin.Plugin) => {
this.checkAndGet(args[0]).forEach((plugin: interfaces.Plugin) => {
this.runPluginStage(plugin, 'enable', () => {
this.registryCommand(plugin)
this.registryListener(plugin)
@@ -145,7 +94,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
}
disable(...args: any[]): void {
this.checkAndGet(args[0]).forEach((plugin: plugin.Plugin) => {
this.checkAndGet(args[0]).forEach((plugin: interfaces.Plugin) => {
this.runPluginStage(plugin, 'disable', () => {
this.saveConfig(plugin)
this.unregistryCommand(plugin)
@@ -155,18 +104,14 @@ export class PluginManagerImpl implements plugin.PluginManager {
}
reload(...args: any[]): void {
this.checkAndGet(args[0]).forEach((pl: plugin.Plugin) => {
this.checkAndGet(args[0]).forEach((pl: interfaces.Plugin) => {
this.disable(pl)
this.loadFromFile(pl.description.source, pl.description.scanner)
this.loadFromFile(pl.description.source)
})
}
getPlugin(name: string) {
return this.instanceMap.get(name)
}
getPlugins() {
return this.instanceMap
return this.pluginInstanceMap
}
private runCatch(pl: any, func: string) {
@@ -178,14 +123,65 @@ export class PluginManagerImpl implements plugin.PluginManager {
}
}
private checkAndGet(name: string | plugin.Plugin | undefined | any): Map<string, plugin.Plugin> | plugin.Plugin[] {
if (name == this.instanceMap) { return this.instanceMap }
if (typeof name == 'string' && this.instanceMap.has(name)) { return [this.instanceMap.get(name)] }
if (name instanceof interfaces.Plugin) { return [name as plugin.Plugin] }
if (name.description || name.description.name) { return [name as plugin.Plugin] }
private checkAndGet(name: string | interfaces.Plugin | undefined | any): Map<string, interfaces.Plugin> | interfaces.Plugin[] {
if (name == this.pluginInstanceMap) { return this.pluginInstanceMap }
if (typeof name == 'string' && this.pluginInstanceMap.has(name)) { return [this.pluginInstanceMap.get(name)] }
if (name instanceof interfaces.Plugin) { return [name as interfaces.Plugin] }
if (name.description || name.description.name) { return [name as interfaces.Plugin] }
throw new Error(`Plugin ${JSON.stringify(name)} not exist!`)
}
private scanFolder(folder: any): string[] {
var files = []
console.i18n('ms.plugin.manager.scan', { folder })
this.checkUpdateFolder(folder)
// must check file is exist maybe is a illegal symbolic link file
fs.list(folder).forEach((file: any) => file.toFile().exists() ? files.push(file.toFile()) : void 0)
return files
}
/**
* 更新插件
* @param path
*/
private checkUpdateFolder(path: any) {
var update = fs.file(path, "update")
if (!update.exists()) {
update.mkdirs()
}
}
private loadPlugins(files: any[]): void {
this.loadJsPlugins(files)
}
/**
* JS类型插件预加载
*/
private loadJsPlugins(files: any[]) {
files.filter(file => file.name.endsWith(".js")).forEach(file => {
try {
this.loadPlugin(file)
} catch (ex) {
console.i18n("ms.plugin.manager.initialize.error", { name: file.name, ex })
console.ex(ex)
}
})
}
private loadPlugin(file: any) {
this.updatePlugin(file)
return this.createPlugin(file.toString())
}
private updatePlugin(file: any) {
var update = fs.file(fs.file(file.parentFile, 'update'), file.name)
if (update.exists()) {
console.i18n("ms.plugin.manager.build.update", { name: file.name })
fs.move(update, file, true)
}
}
private allowProcess(servers: string[]) {
// Not set servers -> allow
if (!servers || !servers.length) return true
@@ -199,18 +195,63 @@ export class PluginManagerImpl implements plugin.PluginManager {
}
}
private createPlugin(file: string) {
//@ts-ignore
let instance = require(file, { cache: false })
this.pluginRequireMap.set(file, instance)
return instance
}
private buildPlugins() {
for (const [, metadata] of this.metadataMap) {
let pluginInstance: plugin.Plugin
if (!this.loaderMap.has(metadata.type)) {
console.error(`§4无法加载插件 §c${metadata.name} §4请检查 §c${metadata.type} §4加载器是否正常启用!`)
continue
}
(pluginInstance = this.loaderMap.get(metadata.type).build(metadata)) && this.instanceMap.set(metadata.name, pluginInstance)
let metadatas = []
let pluginMetadatas = getPluginMetadatas()
for (const [_, metadata] of pluginMetadatas) { metadatas.push(metadata) }
for (const [_, instance] of this.pluginRequireMap) { if (instance.description) { this.buildPlugin(instance.description) } }
for (const metadata of metadatas) {
if (!this.allowProcess(metadata.servers)) { continue }
this.buildPlugin(metadata)
}
}
private loadConfig(plugin: plugin.Plugin) {
private buildPlugin(metadata: interfaces.PluginMetadata) {
let pluginInstance: interfaces.Plugin
switch (metadata.type) {
case "ioc":
try {
this.bindPlugin(metadata)
pluginInstance = this.container.getNamed<interfaces.Plugin>(plugin.Plugin, metadata.name)
if (!(pluginInstance instanceof interfaces.Plugin)) {
console.i18n('ms.plugin.manager.build.not.extends', { source: metadata.source })
return
}
} catch (ex) {
console.i18n("ms.plugin.manager.initialize.error", { name: metadata.name, ex })
console.ex(ex)
}
break
case "basic":
pluginInstance = this.pluginRequireMap.get(metadata.source.toString())
break
default:
throw new Error('§4不支持的插件类型 请检查加载器是否正常启用!')
}
this.pluginInstanceMap.set(metadata.name, pluginInstance)
return pluginInstance
}
private bindPlugin(metadata: interfaces.PluginMetadata) {
try {
let pluginInstance = this.container.getNamed<interfaces.Plugin>(plugin.Plugin, metadata.name)
if (pluginInstance.description.source + '' !== metadata.source + '') {
console.i18n('ms.plugin.manager.build.duplicate', { exists: pluginInstance.description.source, source: metadata.source })
}
this.container.rebind(plugin.Plugin).to(metadata.target).inSingletonScope().whenTargetNamed(metadata.name)
} catch{
this.container.bind(plugin.Plugin).to(metadata.target).inSingletonScope().whenTargetNamed(metadata.name)
}
}
private loadConfig(plugin: interfaces.Plugin) {
let configs = getPluginConfigMetadata(plugin)
for (let [_, config] of configs) {
try {
@@ -235,7 +276,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
}
}
private saveConfig(plugin: plugin.Plugin) {
private saveConfig(plugin: interfaces.Plugin) {
let configs = getPluginConfigMetadata(plugin)
for (let [_, config] of configs) {
try {
@@ -249,7 +290,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
}
}
private registryCommand(pluginInstance: plugin.Plugin) {
private registryCommand(pluginInstance: interfaces.Plugin) {
let cmds = getPluginCommandMetadata(pluginInstance)
let tabs = getPluginTabCompleterMetadata(pluginInstance)
for (const [_, cmd] of cmds) {
@@ -262,7 +303,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
}
}
private registryListener(pluginInstance: plugin.Plugin) {
private registryListener(pluginInstance: interfaces.Plugin) {
let events = getPluginListenerMetadata(pluginInstance)
for (const event of events) {
// ignore space listener
@@ -272,14 +313,28 @@ export class PluginManagerImpl implements plugin.PluginManager {
}
}
private unregistryCommand(pluginInstance: plugin.Plugin) {
private unregistryCommand(pluginInstance: interfaces.Plugin) {
let cmds = getPluginCommandMetadata(pluginInstance)
cmds.forEach(cmd => {
this.CommandManager.off(pluginInstance, cmd.name)
})
}
private unregistryListener(pluginInstance: plugin.Plugin) {
private unregistryListener(pluginInstance: interfaces.Plugin) {
this.EventManager.disable(pluginInstance)
}
private execPluginStage(pluginInstance: interfaces.Plugin, stageName: string) {
let stages = getPluginStageMetadata(pluginInstance, stageName)
for (const stage of stages) {
if (!this.allowProcess(stage.servers)) { continue }
console.i18n("ms.plugin.manager.stage.exec", { plugin: pluginInstance.description.name, name: stage.executor, stage: stageName, servers: stage.servers })
try {
pluginInstance[stage.executor].apply(pluginInstance)
} catch (error) {
console.i18n("ms.plugin.manager.stage.exec.error", { plugin: pluginInstance.description.name, executor: stage.executor, error })
console.ex(error)
}
}
}
}

View File

@@ -1,49 +0,0 @@
import { plugin } from "@ccms/api"
import * as fs from '@ccms/common/dist/fs'
import { provideSingletonNamed } from "@ccms/container"
@provideSingletonNamed(plugin.PluginScanner, 'file')
export class JSFileScanner implements plugin.PluginScanner {
type: string = 'file'
scan(target: any): string[] {
return this.scanFolder(fs.concat(root, target))
}
load(file: string) {
if (typeof file === "string") { return }
this.updatePlugin(file)
//@ts-ignore
return require(file.toString(), { cache: false })
}
private scanFolder(folder: any): string[] {
var files = []
console.i18n('ms.plugin.manager.scan', { folder })
this.checkUpdateFolder(folder)
// must check file is exist maybe is a illegal symbolic link file
fs.list(folder).forEach((path: any) => {
let file = path.toFile()
if (file.exists() && file.getName().endsWith(".js")) {
files.push(file)
}
})
return files
}
private checkUpdateFolder(path: any) {
var update = fs.file(path, "update")
if (!update.exists()) {
update.mkdirs()
}
}
private updatePlugin(file: any) {
var update = fs.file(fs.file(file.parentFile, 'update'), file.name)
if (update.exists()) {
console.i18n("ms.plugin.manager.build.update", { name: file.name })
fs.move(update, file, true)
}
}
}

View File

@@ -1,79 +1,78 @@
import { plugin } from '@ccms/api'
import { interfaces } from './interfaces'
import { METADATA_KEY } from './constants'
const pluginSourceCache = new Map<string, plugin.PluginMetadata>()
const pluginSourceCache = new Map<string, interfaces.PluginMetadata>();
function getPlugins() {
return [...getPluginMetadatas().values()].map((target) => target.target)
return [...getPluginMetadatas().values()].map((target) => target.target);
}
function getPlugin(name: string) {
return getPluginMetadatas().get(name)
return getPluginMetadatas().get(name);
}
function getPluginSources() {
let pluginSources: Map<string, plugin.PluginMetadata> = Reflect.getMetadata(
let pluginSources: Map<string, interfaces.PluginMetadata> = Reflect.getMetadata(
METADATA_KEY.souece,
Reflect
) || pluginSourceCache
return pluginSources
) || pluginSourceCache;
return pluginSources;
}
function getPluginMetadatas() {
let pluginMetadatas: Map<string, plugin.PluginMetadata> = Reflect.getMetadata(
let pluginMetadatas: Map<string, interfaces.PluginMetadata> = Reflect.getMetadata(
METADATA_KEY.plugin,
Reflect
) || new Map<string, plugin.PluginMetadata>()
return pluginMetadatas
) || new Map<string, interfaces.PluginMetadata>();
return pluginMetadatas;
}
function getPluginMetadata(target: any) {
let pluginMetadata: plugin.PluginMetadata = Reflect.getMetadata(
let pluginMetadata: interfaces.PluginMetadata = Reflect.getMetadata(
METADATA_KEY.plugin,
target.constructor
) || {}
return pluginMetadata
) || {};
return pluginMetadata;
}
function getPluginCommandMetadata(target: any) {
let commandMetadata: Map<string, interfaces.CommandMetadata> = Reflect.getMetadata(
METADATA_KEY.cmd,
target.constructor
) || new Map<string, interfaces.CommandMetadata>()
return commandMetadata
) || new Map<string, interfaces.CommandMetadata>();
return commandMetadata;
}
function getPluginTabCompleterMetadata(target: any) {
let tabcompleterMetadata: Map<string, interfaces.CommandMetadata> = Reflect.getMetadata(
METADATA_KEY.tab,
target.constructor
) || new Map<string, interfaces.CommandMetadata>()
return tabcompleterMetadata
) || new Map<string, interfaces.CommandMetadata>();
return tabcompleterMetadata;
}
function getPluginListenerMetadata(target: any) {
let listnerMetadata: interfaces.ListenerMetadata[] = Reflect.getMetadata(
METADATA_KEY.listener,
target.constructor
) || []
return listnerMetadata
) || [];
return listnerMetadata;
}
function getPluginConfigMetadata(target: any) {
let configMetadata: Map<string, interfaces.ConfigMetadata> = Reflect.getMetadata(
METADATA_KEY.config,
target.constructor
) || new Map<string, interfaces.ConfigMetadata>()
return configMetadata
) || new Map<string, interfaces.ConfigMetadata>();
return configMetadata;
}
function getPluginStageMetadata(target: any, stage: string) {
let stageMetadata: interfaces.ExecMetadata[] = Reflect.getMetadata(
METADATA_KEY.stage[stage],
target.constructor
) || []
return stageMetadata
) || [];
return stageMetadata;
}
export {

View File

@@ -1,4 +1,3 @@
/// <reference types="@ccms/nashorn" />
/// <reference types="@ccms/types/dist/typings/bukkit" />
/// <reference types="@ccms/types/dist/typings/sponge" />
/// <reference types="@ccms/types/dist/typings/bungee" />
@@ -44,8 +43,6 @@ export class MiaoConsole extends interfaces.Plugin {
private appender: any
private handler: any
private logCache: string[] = []
@config()
private secret = { token: undefined }
@@ -57,12 +54,6 @@ export class MiaoConsole extends interfaces.Plugin {
this.token = Java.type('java.util.UUID').randomUUID().toString()
this.logger.console(`§6已生成随机Token: §3${this.token} §c重启后或重新生成后失效!`)
}
process.on('message', (msg) => {
this.logCache.push(msg)
if (this.logCache.length > 30) {
this.logCache = this.logCache.slice(this.logCache.length - 30, this.logCache.length)
}
})
}
@cmd()
@@ -112,14 +103,13 @@ export class MiaoConsole extends interfaces.Plugin {
wait?.cancel()
this.createSocketIOServer()
this.startSocketIOServer()
return
}
if (count++ > 5) {
if (count++ > 30) {
wait?.cancel()
this.logger.console('§cNetty通道注入失败 §4所有功能将无法使用')
return
}
}).later(20).timer(20).submit()
}).later(20).timer(40).submit()
this.rootLogger = this.server.getRootLogger()
}
@@ -127,13 +117,8 @@ export class MiaoConsole extends interfaces.Plugin {
addLog4jForward() {
if (this.rootLogger) {
let AbstractAppender = Java.type('org.apache.logging.log4j.core.appender.AbstractAppender')
let Level = Java.type('org.apache.logging.log4j.Level')
let ProxyAppender = Java.extend(AbstractAppender, {
append: (logEvent) => {
if (logEvent.level.intLevel() <= Level.INFO.intLevel()) {
process.emit('message', logEvent.getMessage().getFormattedMessage())
}
}
append: (logEvent) => global.eventCenter.emit('log', logEvent.getMessage().getFormattedMessage())
})
this.appender = new ProxyAppender("ProxyLogger", null, null)
this.appender.start()
@@ -147,7 +132,7 @@ export class MiaoConsole extends interfaces.Plugin {
if (this.rootLogger) {
let AbstractHandler = Java.type('java.util.logging.Handler')
let ProxyHandler = Java.extend(AbstractHandler, {
publish: (record) => process.emit('message', record.getMessage()),
publish: (record) => global.eventCenter.emit('log', record.getMessage()),
flush: () => { },
close: () => { }
})
@@ -156,18 +141,15 @@ export class MiaoConsole extends interfaces.Plugin {
}
}
private LOGBACK_APPENDER_NAME = "NashornProxyAppender"
@enable({ servers: [constants.ServerType.Spring] })
addLogbackForward() {
if (this.rootLogger) {
let AppenderBase = Java.type('ch.qos.logback.core.AppenderBase')
let ProxyAppender = Java.extend(AppenderBase, {
append: (logEvent) => process.emit('message', logEvent.getFormattedMessage())
append: (logEvent) => global.eventCenter.emit('log', logEvent.getFormattedMessage())
})
this.appender = new ProxyAppender()
this.appender.start()
this.appender.setName(this.LOGBACK_APPENDER_NAME)
this.appender.setName("NashornProxyAppender")
this.appender.setContext(this.rootLogger.getLoggerContext())
this.rootLogger.addAppender(this.appender)
}
@@ -176,7 +158,7 @@ export class MiaoConsole extends interfaces.Plugin {
disable() {
if (this.socketIOServer) {
this.socketIOServer.close()
process.removeAllListeners('message')
global.eventCenter.removeAllListeners('log')
}
if (this.container.isBound(io.Instance)) {
this.container.unbind(io.Instance)
@@ -205,7 +187,7 @@ export class MiaoConsole extends interfaces.Plugin {
@disable({ servers: [constants.ServerType.Spring] })
removeLogbackForward() {
try {
this.rootLogger.detachAppender(this.LOGBACK_APPENDER_NAME)
this.rootLogger.detachAppender("NashornProxyAppender")
} catch (error) {
console.ex(error)
}
@@ -221,7 +203,7 @@ export class MiaoConsole extends interfaces.Plugin {
startSocketIOServer() {
let namespace = this.socketIOServer.of('/MiaoConsole')
process.on('message', (msg) => namespace.emit('log', msg))
global.eventCenter.on('log', (msg) => namespace.emit('log', msg))
namespace.on('connect', (client: SocketIOSocket) => {
if (!this.token) {
this.logger.console(`§6客户端 §b${client.id} §a请求连接 §4服务器尚未设置 Token 无法连接!`)
@@ -229,93 +211,72 @@ export class MiaoConsole extends interfaces.Plugin {
client.disconnect(true)
return
}
this.logger.console(`§6客户端 §b${client.id} §a请求连接 §4Token: §c********`)
if (this.token != client.handshake.query.token) {
this.logger.console(`§6客户端 §b${client.id} §c无效请求 §4请提供正确Token后再次连接!`)
this.logger.console(`§6客户端 §b${client.id} §4无效请求 请提供正确Token后再次连接!`)
client.emit('unauthorized')
client.disconnect(true)
return
}
this.initWebSocketClient(client)
this.logCache.forEach(msg => client.emit('log', msg))
this.logger.console(`§6客户端 §b${client.id} §a新建连接 ${this.rootLogger ? '启动日志转发' : '§4转发日志启动失败'}...`)
})
}
private initWebSocketClient(client: SocketIOSocket) {
client.on('type', (fn) => {
fn && fn(this.serverType)
client.emit('log', `Currect Server Version is ${this.server.getVersion()}`)
})
client.on('command', (cmd) => {
setTimeout(() => this.server.dispatchConsoleCommand(cmd), 0)
client.emit('log', `§6命令: §b${cmd} §a执行成功!`)
})
client.on('tabComplate', (input, index, callback) => {
callback && callback(this.server.tabComplete(this.server.getConsoleSender(), input, index))
})
client.on('exec', (code) => {
try {
client.emit('log', this.runCode(code, client.nsp, client))
} catch (ex) {
client.emit('log', `§4代码执行异常 错误: ${ex}\n${console.stack(ex).join('\n')}`)
}
})
client.on('edit', (file: string, fn) => {
fn && fn(base.read(file), suffixMap[file.split('.', 2)[1]])
})
client.on('save', (name: string, content: string, fn) => {
this.logger.console(`§6客户端 §b${client.id} §6请求更新插件 §a${name} §6...`)
let file = fs.concat(root, this.pluginFolder, name + '.js')
if (!fs.exists(file)) { return fn('§6插件 §a' + name + ' §6尚未安装 §c请先创建空文件 或安装插件!') }
try {
base.save(file, content)
this.pluginManager.reload(name)
fn('§6插件 §a' + name + ' §6更新成功!')
} catch (error) {
client.on('type', (fn) => {
fn && fn(this.serverType)
client.emit('log', `Currect Server Version is ${this.server.getVersion()}`)
})
client.on('command', (cmd) => {
setTimeout(() => this.server.dispatchConsoleCommand(cmd), 0)
client.emit('log', `§6命令: §b${cmd} §a执行成功!`)
})
client.on('exec', (code) => {
try {
client.emit('log', this.runCode(code, namespace, client))
} catch (ex) {
client.emit('log', `§4代码执行异常 错误: ${ex}\n${console.stack(ex).join('\n')}`)
}
})
client.on('edit', (file: string, fn) => {
fn && fn(base.read(file), suffixMap[file.split('.', 2)[1]])
})
client.on('save', (name: string, content: string, fn) => {
this.logger.console(`§6客户端 §b${client.id} §6请求更新插件 §a${name} §6...`)
let file = fs.concat(root, this.pluginFolder, name + '.js')
if (!fs.exists(file)) { return fn('§6插件 §a' + name + ' §6尚未安装 §c请先创建空文件 或安装插件!') }
try {
base.save(file, content)
this.pluginManager.reload(name)
fn('§6插件 §a' + name + ' §6更新成功!')
} catch (error) {
this.logger.error(error)
fn('§6插件 §a' + name + ' §4更新异常 错误: ' + error)
}
})
client.on('ls', (file: string, fn) => {
let dir = fs.file(file);
if (!dir.isDirectory()) {
return fn(undefined, `${file} 不是一个目录!`)
}
fn(fs.list(dir))
})
client.on('error', (error) => {
this.logger.console(`§6客户端 §b${client.id} §c触发异常: ${error}`)
this.logger.error(error)
fn('§6插件 §a' + name + ' §4更新异常 错误: ' + error)
}
})
client.on('ls', (file: string, fn) => {
let dir = fs.file(file)
if (!dir.isDirectory()) {
return fn(undefined, `${file} 不是一个目录!`)
}
fn(fs.list(dir))
})
client.on('error', (error) => {
this.logger.console(`§6客户端 §b${client.id} §c触发异常: ${error}`)
this.logger.error(error)
})
client.on('disconnect', () => {
this.logger.console(`§6客户端 §b${client.id} §c断开连接...`)
})
client.on('disconnect', () => {
this.logger.console(`§6客户端 §b${client.id} §c断开连接...`)
})
})
}
private runCode(code: string, namespace: any, client: any) {
let paramNames = [
'namespace',
'client',
'reflect',
'container',
'pluginManager'
]
let params = [
namespace,
client,
reflect,
this.container,
this.pluginManager
]
let tfunc = new Function(
...paramNames,
`var api = require('@ccms/api');
if (this.serverType == "spring") {
var dbm = container.get(api.database.DataBaseManager)
var db = dbm.getMainDatabase()
var bf = base.getInstance().getAutowireCapableBeanFactory()
}
return '§a返回结果: §r'+ eval(${JSON.stringify(code)});`)
return this.task.callSyncMethod(() => tfunc.apply(this, params)) + ''
let tfunc = new Function('namespace', 'client', `
var reflect = require('@ccms/common/dist/reflect');
var tempconcent = '';
function print(text) {
tempconcent += text + "\\n"
}
var result = eval(${JSON.stringify(code)});
return tempconcent + '§a返回结果: §r'+ result
`)
return this.task.callSyncMethod(() => tfunc.apply(this, [namespace, client])) + ''
}
}

View File

@@ -1,32 +0,0 @@
/// <reference types="@ccms/types" />
import { task, server, constants } from "@ccms/api";
import { inject } from "@ccms/container";
import { plugin, interfaces, cmd } from "@ccms/plugin";
import http from '@ccms/common/dist/http'
import * as fs from '@ccms/common/dist/fs'
@plugin({ name: 'MiaoProtocol', prefix: 'MPTL', version: '1.0.0', author: 'MiaoWoo', servers: [constants.ServerType.Bukkit], source: __filename })
export class MiaoProtocol extends interfaces.Plugin {
@inject(server.Server)
private server: server.Server;
@inject(task.TaskManager)
private taskManager: task.TaskManager;
private pipeline: any
enable() {
let count = 0
let wait = this.taskManager.create(() => {
this.pipeline = this.server.getNettyPipeline()
if (this.pipeline) {
wait.cancel()
} else if (count++ > 30) {
wait.cancel()
this.logger.console('§cNetty通道注入失败 §4所有功能将无法使用')
}
}).later(20).timer(40).submit()
}
}

View File

@@ -1,11 +1,10 @@
import { plugin as pluginApi, task, server } from '@ccms/api'
import { Translate } from '@ccms/i18n'
import { inject, DefaultContainer as container } from '@ccms/container'
import { inject } from '@ccms/container';
import { interfaces, plugin, cmd, tab } from '@ccms/plugin'
import * as fs from '@ccms/common/dist/fs'
import * as reflect from '@ccms/common/dist/reflect'
import http from '@ccms/common/dist/http'
let help = [
@@ -20,7 +19,7 @@ let help = [
'§6/mpm §arun §e<JS代码> §6- §3运行JS代码',
'§6/mpm §adeploy §e<插件名称> §6- §3发布插件',
'§6/mpm §crestart §6- §4重启MiaoScript脚本引擎'
]
];
let langMap = {
'main.command.not.exists': '§4未知的子命令: §c{command}',
@@ -54,20 +53,20 @@ let fallbackMap = langMap
@plugin({ name: 'MiaoScriptPackageManager', prefix: 'PM', version: '1.0.1', author: 'MiaoWoo', source: __filename })
export class MiaoScriptPackageManager extends interfaces.Plugin {
@inject(pluginApi.PluginManager)
private pluginManager: pluginApi.PluginManager
private pluginManager: pluginApi.PluginManager;
@inject(task.TaskManager)
private taskManager: task.TaskManager
private taskManager: task.TaskManager;
@inject(server.ServerType)
private serverType: string
private serverType: string;
@inject(server.Server)
private server: server.Server
@inject(pluginApi.PluginFolder)
private pluginFolder: string
private pluginFolder: string;
private packageCache: any[] = [];
private packageNameCache: string[] = [];
private translate: Translate
private translate: Translate;
load() {
this.translate = new Translate({
@@ -79,7 +78,7 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
@cmd()
mpm(sender: any, command: string, args: string[]) {
this.taskManager.create(() => this.main(sender, command, args)).async().submit()
this.taskManager.create(() => this.main(sender, command, args)).async().submit();
}
i18n(sender: any, name: string, params?: any) {
@@ -91,64 +90,64 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
if (!this[cmdKey]) {
this.i18n(sender, 'main.command.not.exists', { command: args[0] })
this.i18n(sender, 'main.command.help.tip', { command })
return
return;
}
args.shift()
this[cmdKey](sender, ...args)
this[cmdKey](sender, ...args);
}
cmdhelp(sender: any) {
this.logger.sender(sender, help)
this.logger.sender(sender, help);
}
cmdload(sender: any, name: string) {
let pluginFile = fs.concat(__dirname + '', name)
let pluginFile = fs.concat(__dirname + '', name);
if (!fs.exists(pluginFile)) {
this.i18n(sender, 'plugin.not.exists', { name: `${name}(${pluginFile})` })
return
return;
}
this.pluginManager.loadFromFile(fs.file(pluginFile))
this.pluginManager.loadFromFile(fs.file(pluginFile));
}
cmdlist(sender: any, type: string = 'cloud') {
if (type == "i" || type == "install") {
this.i18n(sender, 'list.install.header')
this.pluginManager.getPlugins().forEach((plugin) => {
this.i18n(sender, 'list.install.body', plugin.description)
this.i18n(sender, 'list.install.body', plugin.description);
})
} else {
this.i18n(sender, 'list.header')
for (var pkgName in this.packageCache) {
this.i18n(sender, 'list.body', this.packageCache[pkgName])
this.i18n(sender, 'list.body', this.packageCache[pkgName]);
}
}
}
cmdinstall(sender: any, name: string) {
if (!name) { return this.i18n(sender, 'plugin.name.empty') }
this.download(sender, name)
this.download(sender, name);
}
cmdupdate(sender: any, name: string) {
if (name) {
this.update(sender, name)
this.update(sender, name);
} else {
this.updateRepo(sender)
}
}
cmdupgrade(sender: any, name: string) {
if (!name) { return this.i18n(sender, 'upgrade.confirm') }
if (!name) { return this.i18n(sender, 'upgrade.confirm'); }
if (name == "comfirm") {
let enginePath = fs.path(fs.file(fs.concat(root, 'node_modules', '@ccms')))
if (enginePath.startsWith(root)) {
base.delete(enginePath)
this.cmdrestart(sender)
base.delete(enginePath);
this.cmdrestart(sender);
}
}
if (this.checkPlugin(sender, name)) {
this.update(sender, name)
this.pluginManager.reload(name)
this.update(sender, name);
this.pluginManager.reload(name);
}
}
@@ -162,7 +161,7 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
cmdreload(sender: any, name: string) {
name = name || this.description.name
if (this.checkPlugin(sender, name)) {
this.pluginManager.reload(name)
this.pluginManager.reload(name);
this.i18n(sender, 'plugin.reload.finish', { name })
}
}
@@ -185,58 +184,33 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
return
}
try {
this.logger.sender(sender, '§6Reloading §3MiaoScript Engine...')
ScriptEngineContextHolder.disableEngine()
Packages.java.lang.System.gc()
ScriptEngineContextHolder.enableEngine()
this.logger.sender(sender, '§3MiaoScript Engine §6Reload §aSuccessful...')
this.logger.sender(sender, '§6Reloading §3MiaoScript Engine...');
ScriptEngineContextHolder.disableEngine();
Packages.java.lang.System.gc();
ScriptEngineContextHolder.enableEngine();
this.logger.sender(sender, '§3MiaoScript Engine §6Reload §aSuccessful...');
} catch (ex) {
this.logger.sender(sender, "§3MiaoScript Engine §6Reload §cError! ERR: " + ex)
this.logger.sender(sender, this.logger.stack(ex))
this.logger.sender(sender, "§3MiaoScript Engine §6Reload §cError! ERR: " + ex);
this.logger.sender(sender, this.logger.stack(ex));
}
}
cmdrun(sender: any, ...args: any[]) {
try {
let script = args.join(' ')
let script = args.join(' ');
this.i18n(sender, 'run.script', { script })
let result = this.runCode(script, sender)
let result = eval(script);
this.i18n(sender, 'run.result', { result: result == undefined ? this.translate.translate('run.noresult') : result + '' })
} catch (ex) {
this.logger.sender(sender, this.logger.stack(ex))
this.logger.sender(sender, this.logger.stack(ex));
}
}
private runCode(code: string, sender: any) {
let paramNames = [
'sender',
'reflect',
'container',
'pluginManager'
]
let params = [
sender,
reflect,
container,
this.pluginManager
]
let tfunc = new Function(
...paramNames,
`var api = require('@ccms/api');
if (this.serverType == "spring") {
var dbm = container.get(api.database.DataBaseManager)
var db = dbm.getMainDatabase()
var df = base.getInstance().getAutowireCapableBeanFactory()
}
return '§a返回结果: §r'+ eval(${JSON.stringify(code)});`)
return tfunc.apply(this, params) + ''
}
cmddeploy(sender: any, name: any) {
if (!process.env.AccessToken) { return this.i18n(sender, 'deploy.token.not.exists') }
this.taskManager.create(() => {
if (this.checkPlugin(sender, name)) {
let plugin: pluginApi.Plugin = this.pluginManager.getPlugins().get(name)
let plugin: interfaces.Plugin = this.pluginManager.getPlugins().get(name);
let result = http.post("http://ms.yumc.pw/api/plugin/deploy?access_token=" + process.env.AccessToken, {
name,
author: plugin.description.author,
@@ -250,7 +224,7 @@ return '§a返回结果: §r'+ eval(${JSON.stringify(code)});`)
update(sender: any, name: string) {
if (this.checkCloudPlugin(sender, name)) {
this.download(sender, name, true)
this.download(sender, name, true);
}
}
@@ -262,25 +236,25 @@ return '§a返回结果: §r'+ eval(${JSON.stringify(code)});`)
case "list":
return ["install", "cloud"]
case "install":
return this.packageNameCache
return this.packageNameCache;
case "update":
case "upgrade":
case "load":
case "unload":
case "reload":
case "deploy":
return [...this.pluginManager.getPlugins().keys()]
return [...this.pluginManager.getPlugins().keys()];
}
}
}
updateRepo(sender: any) {
this.taskManager.create(() => {
let result = http.get('http://ms.yumc.pw/api/plugin/list')
for (const pl of result.data) { this.packageCache[pl.name] = pl }
this.packageNameCache = Object.keys(this.packageCache)
let result = http.get('http://ms.yumc.pw/api/plugin/list');
for (const pl of result.data) { this.packageCache[pl.name] = pl; }
this.packageNameCache = Object.keys(this.packageCache);
this.i18n(sender, 'cloud.update.finish', { length: this.packageNameCache.length })
}).async().submit()
}).async().submit();
}
download(sender: any, name: string, update: boolean = false) {

View File

@@ -1,197 +0,0 @@
/// <reference types="@ccms/types" />
/// <reference types="@ccms/types/dist/typings/tomcat/index" />
/// <reference types="@ccms/types/dist/typings/spring/index" />
import { constants, database, plugin, web } from "@ccms/api"
import { inject, ContainerInstance, Container } from "@ccms/container"
import { JSPlugin, interfaces, cmd } from "@ccms/plugin"
import { DataBase, DataBaseManager } from '@ccms/database'
import { Server, Context, RequestHandler } from '@ccms/web'
import * as fs from '@ccms/common/dist/fs'
import * as reflect from '@ccms/common/dist/reflect'
@JSPlugin({ name: 'MiaoSpring', prefix: 'MSpring', version: '1.0.1', author: 'MiaoWoo', servers: [constants.ServerType.Spring], source: __filename })
export class MiaoSpring extends interfaces.Plugin {
@inject(ContainerInstance)
private container: Container
@inject(plugin.PluginManager)
private pluginManager: plugin.PluginManager
@inject(database.DataBaseManager)
private databaseManager: DataBaseManager
@inject(web.Server)
private webServer: Server
private ResponseEntity = org.springframework.http.ResponseEntity
private mainDatabase: DataBase
private mappings: Set<string>
@cmd()
mspring(sender: any) {
this.pluginManager.reload(this)
this.logger.sender(sender, "§a插件重载完成!")
}
load() {
this.mainDatabase = this.databaseManager.getMainDatabase()
this.mappings = new Set()
}
enable() {
this.registryDefault()
this.registryPages()
this.registryDatabase()
}
registryMapping(path: string, handler: RequestHandler) {
this.mappings.add(path)
this.webServer.registryMapping(path, handler)
}
registryDefault() {
const foundMap = ["/node_modules/amis/sdk/sdk.js", 'https://houtai.baidu.com/v2/jssdk', "/node_modules/amis/sdk/sdk.css", 'https://houtai.baidu.com/v2/csssdk']
this.webServer.registryInterceptor({
name: 'RedirectHandle',
preHandle: (ctx: Context) => {
const index = foundMap.indexOf(ctx.request.getRequestURI())
if (index != -1) {
return this.ResponseEntity.status(org.springframework.http.HttpStatus.FOUND).header('Location', foundMap[index + 1]).build()
}
}
})
this.webServer.registryInterceptor({
name: 'StaticHandle',
preHandle: (ctx: Context) => {
let type = ctx.header['Accept'] || ''
if (type == '*/*' || type.includes('text/css') || type.includes('text/html')) {
let filePath = fs.concat(root, 'wwwroot', (ctx.request.getRequestURI() == '/' ? 'index.html' : ctx.request.getRequestURI()))
let fileType = 'text/html;charset=utf-8'
if (!fs.exists(filePath)) { filePath = filePath + '.html' }
if (fs.exists(filePath)) {
if (filePath.endsWith('.js')) { fileType = 'application/javascript' }
if (filePath.endsWith('.css')) { fileType = 'text/css' }
// @ts-ignore
return this.ResponseEntity.ok().header('Content-Type', fileType).body(base.read(filePath))
}
}
}
})
this.webServer.registryMapping('/api/eval', (ctx: Context) => {
try {
return { status: 200, data: this.runCode(ctx.body + ''), msg: '代码执行成功!' }
} catch (error) {
return { status: 500, data: console.stack(error, false), msg: '代码执行异常!' }
}
})
this.webServer.registryMapping('/api/plugin/list', () => {
return { status: 200, data: [...this.pluginManager.getPlugins().values()].map((plugin) => plugin.description), msg: '插件列表获取成功!' }
})
this.webServer.registryMapping('/api/plugin/update', (ctx: Context) => {
if (!ctx.params.name) { return { status: 400, msg: '插件名称不得为空!' } }
})
}
private registryPages() {
this.webServer.registryMapping('/api/page/list', () => {
return { status: 0, data: { rows: this.mainDatabase.query('SELECT `id`, `type`, `name`, `content` FROM `pages` WHERE `deleted` = 0') } }
})
this.webServer.registryMapping('/api/page/get', (ctx: Context) => {
let name = decodeURIComponent(`${ctx.params.name}`)
let varable = undefined
if (!name) { return { status: 400, msg: '名称不能为空!' } }
if (name.includes('|')) {
const temp = `${name}`.split('|')
name = temp[0]
varable = temp[1].replace(/'/ig, '"')
}
let result = this.mainDatabase.query<any>('SELECT content FROM `pages` WHERE name = ?', name)
if (!result.length) { return { status: 404, msg: `'页面配置 ${name} 不存在!` } }
let content = result[0].content
if (varable) {
let varObj = JSON.parse(varable)
for (const key in varObj) {
content = content.replace(new RegExp(`{{${key}}}`, 'ig'), varObj[key])
}
}
return { status: 0, data: JSON.parse(content) }
})
this.webServer.registryMapping('/api/page/add', (ctx: Context) => {
let body = ctx.body
if (typeof body.content !== "string") { body.content = JSON.stringify(body.content) }
this.mainDatabase.update("INSERT INTO `pages`(`type`, `name`, `content`) VALUES (?, ?, ?)", body.type || 1, body.name, body.content)
return { status: 0, msg: `${body.name} 新增成功!` }
})
this.webServer.registryMapping('/api/page/update', (ctx: Context) => {
if (!ctx.params.id) { return { status: 400, msg: 'ID 不能为空!' } }
const body = ctx.body
if (typeof body.content !== "string") { body.content = JSON.stringify(body.content) }
this.mainDatabase.update("UPDATE `pages` SET `name` = ?, `content` = ? WHERE id = ?", body.name, body.content, ctx.params.id)
return { status: 0, msg: `${body.name} 更新成功!` }
})
this.webServer.registryMapping('/api/page/delete', (ctx: Context) => {
if (!ctx.params.name) { return { status: 400, msg: '页面 名称 不能为空!' } }
this.mainDatabase.update("UPDATE `pages` SET `name` = CONCAT(name, '_deleted'), deleted = 1 WHERE name = ?", ctx.params.name)
return { status: 0, msg: `${ctx.params.name} 删除成功!` }
})
}
private configTable = "config"
private registryDatabase() {
this.webServer.registryMapping('/api/config/list', (ctx: Context) => {
return { status: 0, data: this.mainDatabase.query('SELECT id, name, label, url, driver, username, password FROM `' + this.configTable + '` WHERE deleted = 0 AND type = ?', ctx.params.type || 0) }
})
this.webServer.registryMapping('/api/config/get', (ctx: Context) => {
let name = ctx.params.name
if (!name) { return { status: 400, msg: '名称不能为空!' } }
let result = this.mainDatabase.query('SELECT id, name, label, url, driver, username, password FROM `' + this.configTable + '` WHERE `name` = ?', name)
if (!result.length) { return { status: 404, msg: `配置 ${name} 不存在!` } }
return { status: 0, data: result[0] }
})
this.webServer.registryMapping('/api/config/add', (ctx: Context) => {
let body = ctx.body
if (!body.name) { return { status: 400, msg: '名称不能为空!' } }
this.mainDatabase.update(
'INSERT INTO `' + this.configTable + '`(`type`, `name`, `label`, `url`, `driver`, `username`, `password`) VALUES (?, ?, ?, ?, ?, ?, ?)',
ctx.params.type || 0, body.name, body.label || '', body.url, body.driver || '', body.username || '', body.password || ''
)
return { status: 0, msg: `配置 ${body.name} 新增成功!` }
})
this.webServer.registryMapping('/api/config/update', (ctx: Context) => {
if (!ctx.params.id) { return { status: 400, msg: 'ID 不能为空!' } }
let body = ctx.body
this.mainDatabase.update(
'UPDATE `' + this.configTable + '` SET `name` = ?, `label` = ?, `url` = ?, `driver` = ?, `username` = ?, `password` = ? WHERE `id` = ?',
body.name, body.label || '', body.url, body.driver || '', body.username || '', body.password || '', ctx.params.id
)
return { status: 0, msg: `配置 ${body.name} 更新成功!` }
})
}
private runCode(code: string) {
let paramNames = [
'beanFactory',
'mainDatabase',
'reflect',
'container',
'pluginManager'
]
let params = [
this.mainDatabase,
reflect,
this.container,
this.pluginManager
]
let tfunc = new Function(
...paramNames,
`var api = require('@ccms/api');
return eval(${JSON.stringify(code)});`)
return tfunc.apply(this, params)
}
disable() {
Object.keys(this.mappings).forEach((r) => this.webServer.unregistryMapping(r))
}
}

View File

@@ -1,181 +0,0 @@
/// <reference types="@ccms/types/dist/typings/rabbitmq" />
/// <reference types="@ccms/types/dist/typings/spring/amqp" />
import { constants, plugin as pluginApi, amqp, server, web } from '@ccms/api'
import { plugin, interfaces, cmd } from '@ccms/plugin'
import { AmqpAdmin, ConnectionFactoryAdapter, AmqpManager } from '@ccms/amqp'
import { inject, Autowired } from '@ccms/container'
import { Server } from '@ccms/web'
@plugin({ name: SearchRanking.name, version: SearchRanking.version, author: SearchRanking.author, servers: SearchRanking.servers, source: __filename })
export class SearchRanking extends interfaces.Plugin {
public static version = '1.0.0'
public static author = 'MiaoWoo'
public static servers = [constants.ServerType.Spring]
@inject(pluginApi.PluginManager)
private pluginManager: pluginApi.PluginManager
@inject(amqp.Manager)
private amqpManager: AmqpManager
@inject(server.Server)
private Server: server.Server
@inject(web.Server)
private webServer: Server
@Autowired()
private mongoTemplate: any
@Autowired()
private redisTemplate: any
private amqpAdmin: AmqpAdmin
private listener: org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
private readonly exchangeName = 'search.ranking'
private readonly queueName = 'search.ranking'
private readonly routerKey = 'search.ranking'
load() {
let connection = new ConnectionFactoryAdapter({
url: 'amqp://rabbitmq.c.sixi.com:5672',
username: 'root',
password: 'SixiMQ2018@'
})
let template = this.amqpManager.createTemplate(connection)
this.amqpAdmin = this.amqpManager.createAdmin(template)
}
enable() {
this.webServer.registryMapping('/api/search', (ctx) => {
if (!ctx.params.keyword) { return { status: 400, msg: '查询关键词不得为空!' } }
let keyword = ctx.params.keyword + ''
let type = ctx.params.type == 'sale' ? 'sale' : 'normal'
let time = parseInt(ctx.params.time + '') || 60 * 60 * 24 * 15
return this.cacheAndSearch(keyword, type as any, time * 1000)
})
this.webServer.registryMapping('/api/search/ranking', (ctx) => {
if (!ctx.params.keyword || !ctx.params.shopName) { return { status: 400, msg: '查询关键词不得为空!' } }
let keyword = ctx.params.keyword + ''
let shopName = ctx.params.shopName + ''
let type = ctx.params.type == 'sale' ? 'sale' : 'normal'
let time = parseInt(ctx.params.time + '') || 60 * 60 * 24 * 15
return this.sendSearchRankingCmd(keyword, shopName, type as any, time * 1000)
})
this.amqpAdmin.declareQueueAndBindExchange(this.queueName, this.exchangeName, this.routerKey)
this.amqpAdmin.declareBinding(this.queueName, 'client.topic.exchange', `cmd_res.${this.routerKey}`)
this.listener = this.amqpAdmin.createContainer<string>(this.queueName, (content, message, channel) => {
let searchResult = JSON.parse(content)
this.redisTemplate.opsForValue().set(searchResult.reqData.cacheKey, searchResult)
this.logger.sender(this.Server.getConsoleSender(), `§6查询任务完成! §b关键词: §r${searchResult.reqData.keywords}`)
})
this.listener.start()
}
disable() {
this.listener.stop()
}
@cmd()
sr(sender: any, cmd: string, args: string[]) {
let cmdKey = 'cmd' + (args[0] || 'help')
if (!this[cmdKey]) {
this.logger.sender(sender, `§4子命令 ${args[0]} 不存在!`)
return
}
args.shift()
this[cmdKey](sender, ...args)
}
cmdrun(sender: any, ...args: string[]) {
sender.sendMessage(eval(args.join(' ')))
}
cmdreload() {
this.pluginManager.reload(this)
}
cmdsend(sender: any, ...args: string[]) {
}
cmdsearch(sender: any, keyword: string, type: "sale" | "normal" = "sale", time: number) {
this.logger.sender(sender, this.cacheAndSearch(keyword, type, time)?.msg)
}
private cacheAndSearch(keyword: string, type: string = "sale", time: number = 15 * 24 * 60 * 60 * 1000) {
let cacheKey = this.getCacheKey(keyword, type)
if (this.redisTemplate.hasKey(cacheKey)) {
let lastSearchTime = this.redisTemplate.opsForValue().get(cacheKey)
if (Date.now() - lastSearchTime > time) {
return this.createKeyworkSearch(keyword, type)
}
let lastSearchKey = this.getResultCacheKey(keyword, type, lastSearchTime)
if (!this.redisTemplate.hasKey(lastSearchKey)) {
return { status: 202, msg: `关键词: ${keyword} 排名类型: ${type} 缓存Key: ${lastSearchKey} 查询任务尚未完成...` }
}
return {
status: 200,
msg: `关键词: ${keyword} 排名类型: ${type} 查询时间: ${new Date(lastSearchTime).toLocaleString()} 查询已完成!`,
data: this.redisTemplate.opsForValue().get(lastSearchKey)
}
}
return this.createKeyworkSearch(keyword, type)
}
private createKeyworkSearch(keyword: string, type: string) {
let cacheDate = Date.now()
this.redisTemplate.opsForValue().set(this.getCacheKey(keyword, type), cacheDate)
this.sendSearchCmd(keyword, type, cacheDate)
return { status: 201, msg: `关键词: ${keyword} 排名类型: ${type} 查询任务以创建...`, createTime: cacheDate }
}
private createRankingSearch(keyword: string, shopName: string, type: string) {
let cacheDate = Date.now()
this.redisTemplate.opsForValue().set(this.getCacheKey(keyword, type), cacheDate)
this.sendSearchRankingCmd(keyword, shopName, type, cacheDate)
return { status: 201, msg: `关键词: ${keyword} 店铺名称: ${shopName} 排名类型: ${type} 查询任务以创建...`, createTime: cacheDate }
}
private sendSearchCmd(keywords: string, type: string, dateCache: number) {
this.amqpAdmin.getTemplate().convertAndSend('client.topic.exchange', 'cmd_req', {
cmd: 'scout._1688Search',
data: {
keywords: keywords,
parameter: type == "sale" ? {
descendOrder: true,
sortType: 'va_rmdarkgmv30rt',
button_click: 'top'
} : {},
cacheKey: this.getResultCacheKey(keywords, type, dateCache)
},
resRouteSuffix: this.routerKey,
target: {}
})
}
private sendSearchRankingCmd(keywords: string, shopName: string, type: string, cacheTime: number) {
this.amqpAdmin.getTemplate().convertAndSend('client.topic.exchange', 'cmd_req', {
cmd: 'scout._1688Ranking',
data: {
keywords: keywords,
selector: {
shopName
},
cacheKey: this.getResultCacheKey(keywords, type, cacheTime),
cacheTime
},
resRouteSuffix: this.routerKey,
target: {}
})
}
/**
* 获得关键词+类型的上次查询时间
* @param keywords 关键词
* @param type 类型
*/
private getCacheKey(keywords: string, type: string) {
return `SearchRanking:${keywords}:${type}`
}
private getResultCacheKey(keywords: string, type: string, date: number) {
return `SearchRanking:${keywords}:${type}:${date}`
}
}

View File

@@ -1,80 +1,80 @@
import { command, plugin } from "@ccms/api"
import { inject, provideSingleton } from "@ccms/container"
import { command, plugin } from "@ccms/api";
import { inject, provideSingleton } from "@ccms/container";
let Sponge = Java.type('org.spongepowered.api.Sponge')
let Text = Java.type('org.spongepowered.api.text.Text')
var CommandCallable = Java.type('org.spongepowered.api.command.CommandCallable')
var CommandResult = Java.type('org.spongepowered.api.command.CommandResult')
var Optional = Java.type('java.util.Optional')
let Sponge = Java.type('org.spongepowered.api.Sponge');
let Text = Java.type('org.spongepowered.api.text.Text');
var CommandCallable = Java.type('org.spongepowered.api.command.CommandCallable');
var CommandResult = Java.type('org.spongepowered.api.command.CommandResult');
var Optional = Java.type('java.util.Optional');
@provideSingleton(command.Command)
export class SpongeCommand extends command.Command {
@inject(plugin.PluginInstance)
private pluginInstance: any
private commandMapping: any[] = []
private commandMapping: any[] = [];
create(plugin: any, command: string) {
let commandKey = this.getCommandKey(plugin, command)
let commandCallable = new SimpleCommandCallable(command)
this.commandMapping[commandKey] = Sponge.getCommandManager().register(this.pluginInstance, commandCallable.callable, command, commandKey).orElse(null)
return commandCallable
let commandKey = this.getCommandKey(plugin, command);
let commandCallable = new SimpleCommandCallable(command);
this.commandMapping[commandKey] = Sponge.getCommandManager().register(this.pluginInstance, commandCallable.callable, command, commandKey).orElse(null);
return commandCallable;
}
remove(plugin: any, command: string) {
var commandKey = this.getCommandKey(plugin, command)
var commandKey = this.getCommandKey(plugin, command);
if (this.commandMapping[commandKey]) {
Sponge.getCommandManager().removeMapping(this.commandMapping[commandKey])
delete this.commandMapping[commandKey]
Sponge.getCommandManager().removeMapping(this.commandMapping[commandKey]);
delete this.commandMapping[commandKey];
}
}
onCommand(plugin: plugin.Plugin, command: any, executor: Function) {
command.setExecutor(super.setExecutor(plugin, command, executor))
onCommand(plugin: any, command: any, executor: Function) {
command.setExecutor(super.setExecutor(plugin, command, executor));
}
onTabComplete(plugin: plugin.Plugin, command: any, tabCompleter: Function) {
command.setTabCompleter(super.setTabCompleter(plugin, command, tabCompleter))
onTabComplete(plugin: any, command: any, tabCompleter: Function) {
command.setTabCompleter(super.setTabCompleter(plugin, command, tabCompleter));
}
private getCommandKey(plugin: any, command: string) {
return plugin.description.name.toLowerCase() + ":" + command
return plugin.description.name.toLowerCase() + ":" + command;
}
}
class SimpleCommandCallable {
public callable: any
private name: string
private executor: Function
private tabCompleter: Function
public callable: any;
private name: string;
private executor: Function;
private tabCompleter: Function;
constructor(command: string, description: string = '暂无描述!') {
this.name = command
this.name = command;
this.callable = new CommandCallable({
//CommandResult process(CommandSource source, String arguments) throws CommandException
//CommandResult process(CommandSource source, String arguments) throws CommandException;
process: (sender: any, args) => {
return this.executor(sender, '', command, Java.to(args.split(" ").filter(e => e))) ? CommandResult.success() : CommandResult.empty()
return this.executor(sender, '', command, Java.to(args.split(" ").filter(e => e))) ? CommandResult.success() : CommandResult.empty();
},
//List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) throws CommandException
//List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) throws CommandException;
getSuggestions: (sender: any, args, target) => {
return this.tabCompleter(sender, '', command, Java.to(args.split(" ").filter(e => e)))
return this.tabCompleter(sender, '', command, Java.to(args.split(" ").filter(e => e)));
},
//boolean testPermission(CommandSource source)
//boolean testPermission(CommandSource source);
testPermission: () => {
return true
return true;
},
//Optional<Text> getShortDescription(CommandSource source)
//Optional<Text> getShortDescription(CommandSource source);
getShortDescription: () => {
return Optional.of(Text.of(description))
return Optional.of(Text.of(description));
},
//Optional<Text> getHelp(CommandSource source)
//Optional<Text> getHelp(CommandSource source);
getHelp: () => {
return Optional.of(Text.of(""))
return Optional.of(Text.of(""));
},
//Text getUsage(CommandSource source)
//Text getUsage(CommandSource source);
getUsage: () => {
return Text.of('')
return Text.of('');
}
})
}
setExecutor = (executor: Function) => this.executor = executor
setTabCompleter = (tabCompleter: Function) => this.tabCompleter = tabCompleter
setExecutor = (executor: Function) => this.executor = executor;
setTabCompleter = (tabCompleter: Function) => this.tabCompleter = tabCompleter;
toString = () => `Sponge SimpleCommandCallable(${this.name})`
}

View File

@@ -8,12 +8,14 @@ const TextSerializers = org.spongepowered.api.text.serializer.TextSerializers;
const File = Java.type("java.io.File");
@provideSingleton(server.Server)
export class SpongeServer extends server.ReflectServer {
export class SpongeServer implements server.Server {
private pluginsFolder: string;
private pipeline: any;
private rootLogger: any;
constructor() {
super();
this.pluginsFolder = new File(base.getInstance().getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getCanonicalPath()
this.reflect()
}
getPlayer(name: string) {
@@ -35,10 +37,10 @@ export class SpongeServer extends server.ReflectServer {
if (typeof sender === 'string') {
sender = this.getPlayer(sender)
}
return Sponge.getCommandManager().process(sender, command).getQueryResult().get()
return Sponge.getCommandManager().process(sender, command).getQueryResult()
}
dispatchConsoleCommand(command: string): boolean {
return Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command).getQueryResult().get()
return Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command).getQueryResult()
}
getPluginsFolder(): string {
return this.pluginsFolder;
@@ -46,9 +48,6 @@ export class SpongeServer extends server.ReflectServer {
getNativePluginManager() {
return Sponge.getPluginManager() as any;
}
getDedicatedServer() {
return reflect.on(Sponge.getServer()).get()
}
getNettyPipeline() {
return this.pipeline;
}
@@ -61,4 +60,37 @@ export class SpongeServer extends server.ReflectServer {
}
sender.sendMessage(TextSerializers.JSON.deserialize(json))
}
private reflect() {
let consoleServer = reflect.on(Sponge.getServer()).get()
this.reflectPipeline(consoleServer)
this.reflectRootLogger(consoleServer)
}
private reflectPipeline(consoleServer: any) {
let connection: any;
let promise: any;
for (const method of constants.Reflect.Method.getServerConnection) {
try {
connection = reflect.on(consoleServer).call(method).get()
if (connection.class.name.indexOf('NetworkSystem') !== -1) { break; }
connection = undefined;
} catch (error) { }
}
if (!connection) { console.error("Can't found ServerConnection!"); return }
for (const field of constants.Reflect.Field.listeningChannels) {
try {
promise = reflect.on(connection).get(field).get().get(0);
if (promise.class.name.indexOf('Promise') !== -1) { break; }
promise = undefined;
} catch (error) { }
}
if (!promise) { console.error("Can't found listeningChannels!"); return }
this.pipeline = reflect.on(promise).get('channel').get().pipeline()
}
private reflectRootLogger(consoleServer: any) {
try {
this.rootLogger = reflect.on(consoleServer).get('LOGGER').get().parent
} catch (error) {
console.error("Can't found rootLogger!")
}
}
}

View File

@@ -1,17 +1,17 @@
import { task, plugin } from '@ccms/api'
import { inject, provideSingleton, postConstruct } from '@ccms/container'
import { inject, provideSingleton, postConstruct } from '@ccms/container';
const Sponge = Java.type("org.spongepowered.api.Sponge")
const Task = Java.type("org.spongepowered.api.scheduler.Task")
const Consumer = Java.type('java.util.function.Consumer')
const Callable = Java.type('java.util.concurrent.Callable')
const TimeUnit = Java.type('java.util.concurrent.TimeUnit')
const Sponge = Java.type("org.spongepowered.api.Sponge");
const Task = Java.type("org.spongepowered.api.scheduler.Task");
const Consumer = Java.type('java.util.function.Consumer');
const Callable = Java.type('java.util.concurrent.Callable');
const TimeUnit = Java.type('java.util.concurrent.TimeUnit');
@provideSingleton(task.TaskManager)
export class SpongeTaskManager implements task.TaskManager {
@inject(plugin.PluginInstance)
private pluginInstance: any
private syncExecutor: any
private pluginInstance: any;
private syncExecutor: any;
@postConstruct()
initialize() {
@@ -19,8 +19,8 @@ export class SpongeTaskManager implements task.TaskManager {
}
create(func: Function): task.Task {
if (Object.prototype.toString.call(func) !== "[object Function]") { throw TypeError('第一个参数 Task 必须为 function !') }
return new SpongeTask(this.pluginInstance, func)
if (Object.prototype.toString.call(func) !== "[object Function]") { throw TypeError('第一个参数 Task 必须为 function !'); };
return new SpongeTask(this.pluginInstance, func);
}
callSyncMethod(func: Function): any {
// @ts-ignore
@@ -32,8 +32,10 @@ export class SpongeTaskManager implements task.TaskManager {
}
export class SpongeTask extends task.Task {
submit(...args: any[]): task.Cancelable {
let run = Task.builder().execute(new Consumer({ accept: () => this.run(...args) }))
submit(): task.Cancelable {
let run = Task.builder().execute(new Consumer({
accept: () => this.run()
}));
if (this.isAsync) { run.async() }
if (this.laterTime) { run.delayTicks(this.laterTime) }
if (this.interval) { run.intervalTicks(this.interval) }

View File

@@ -26,7 +26,6 @@
"dependencies": {
"@ccms/api": "^0.7.0",
"@ccms/common": "^0.7.0",
"@ccms/container": "^0.7.0",
"@ccms/database": "^0.7.0"
"@ccms/container": "^0.7.0"
}
}

View File

@@ -3,25 +3,21 @@ import '@ccms/nashorn'
import { command, plugin } from '@ccms/api'
import { inject, provideSingleton, postConstruct } from '@ccms/container'
import { CommandMap } from './internal/command'
@provideSingleton(command.Command)
export class SpringCommand extends command.Command {
@inject(plugin.PluginInstance)
private pluginInstance: any
@inject(CommandMap)
private commandMap: CommandMap = new CommandMap()
protected create(plugin: any, command: string) {
return this.commandMap.register(plugin, command)
console.console('§4Spring暂不支持create命令!')
}
protected remove(plugin: any, command: string) {
this.commandMap.unregister(plugin, command)
console.console('§4Spring暂不支持remove命令!')
}
protected onCommand(plugin: any, command: any, executor: Function) {
command.setExecutor(super.setExecutor(plugin, command, executor))
console.console('§4Spring暂不支持onCommand!')
}
protected onTabComplete(plugin: any, command: any, tabCompleter: Function) {
command.setTabCompleter(super.setExecutor(plugin, command, tabCompleter))
console.console('§4Spring暂不支持onTabComplete!')
}
}

View File

@@ -28,29 +28,12 @@ function mcColor2ANSI(str: string) {
for (const regex in regexMap) {
str = str.replace(regexMap[regex], `\u001b[${regex}m`)
}
return str
return str;
}
export class SpringConsole extends MiaoScriptConsole {
error(...args: any[]) {
this.logger.error(args.join(' '))
}
warn(...args: any[]) {
this.logger.warn(args.join(' '))
}
sender(sender: any, ...args: any[]) {
sender = sender || {
sendMessage: (message: string) => console.console(message)
}
if (!sender.sendMessage) {
this.error('第一个参数未实现 sendMessage 无法发送消息!')
return
}
if (Object.prototype.toString.call(args[0]) === '[object Array]') {
args[0].forEach(line => sender.sendMessage(this.prefix + line))
} else {
sender.sendMessage(this.prefix + args.join(' '))
}
this.console(args.join(' '))
}
console(...args: string[]): void {
this.logger.info(mcColor2ANSI(args.join(' ') + '§r'))

View File

@@ -1,29 +1,14 @@
import { server } from '@ccms/api'
import { ioc, Container, reduceMetadata } from '@ccms/container'
import { server, plugin } from '@ccms/api'
import { Container } from '@ccms/container'
import { SpringConsole } from './console'
import './event'
import './server'
import './command'
import './task'
import { SpringConsole } from './console';
import './event';
import './server';
import './command';
import './task';
const toString = {}.toString
const BeanKit = Java.type('com.sixi.micro.common.kits.BeanKit')
export default function SpringImpl(container: Container) {
try {
require('@ccms/web')
require('@ccms/amqp')
require('@ccms/database')
require('./internal/scanner/mysql-scanner')
} catch (error) {
console.ex(error)
}
const beanFactory = base.getInstance().getAutowireCapableBeanFactory()
container.bind(server.Console).toConstantValue(SpringConsole)
container.bind(ioc.Autowired).toDynamicValue((ctx) => {
var metadata: any = reduceMetadata(ctx)
if (toString.call(metadata.named) === "[object Symbol]") { return container.get(metadata.named) }
if (toString.call(metadata.named) === '[object jdk.internal.dynalink.beans.StaticClass]') { metadata.named = metadata.named.class }
return beanFactory.getBean(metadata.named)
})
}

View File

@@ -1,79 +0,0 @@
import { provideSingleton } from "@ccms/container"
import { plugin } from "@ccms/api"
type CommandExec = (sender: any, _: any, command: string, args: string[]) => boolean
type TabCompleter = (sender: any, _: any, command: string, args: string[]) => string[]
type CommandStore = { [key: string]: SpringCommand }
@provideSingleton(CommandMap)
export class CommandMap {
private commands: CommandStore = {}
private pluginCommands: { [key: string]: CommandStore } = {}
register(plugin: plugin.Plugin, command: string) {
let springCommand = new SpringCommand(plugin, command)
this.commands[command] = springCommand
if (!this.pluginCommands[plugin.description.name]) { this.pluginCommands[plugin.description.name] = {} }
this.pluginCommands[plugin.description.name][command] = springCommand
return springCommand
}
unregister(plugin: plugin.Plugin, command: string) {
delete this.commands[command]
delete this.pluginCommands[plugin.description.name][command]
}
dispatch(sender: any, command: string, args: string[]): boolean {
if (command === "help") {
sender.sendMessage('§e--------- §rHelp: Index §e---------------------------')
sender.sendMessage('Use /help [n] to get page n of help.')
for (const cmdName of Object.getOwnPropertyNames(this.commands)) {
sender.sendMessage(`§6/${cmdName}: §rA command provided by plugin §b${this.commands[cmdName].plugin.description.name}§r.`)
}
return
}
let exists = this.commands[command]
if (exists) {
try {
return exists.executor(sender, '', command, Java.to(args))
} catch (error) {
console.ex(error)
}
return true
} else {
sender.sendMessage && sender.sendMessage(`Unknown command. Type "/help" for help.`)
return false
}
}
tabComplate(sender: any, input: string, index?: number): string[] {
if (index == 0) { return Object.keys(this.commands) }
let [command, ...args] = input.split(' ')
let exists = this.commands[command]
if (exists && exists.tabCompleter) {
try {
if (args.length !== index) { args.push('') }
return exists.tabCompleter(sender, '', command, Java.to(args))
} catch (error) {
console.ex(error)
}
}
return []
}
}
export class SpringCommand {
public plugin: plugin.Plugin
public name: string
public executor: CommandExec
public tabCompleter: TabCompleter
constructor(plugin: plugin.Plugin, command: string, description: string = '暂无描述!') {
this.plugin = plugin
this.name = command
}
setExecutor = (executor: CommandExec) => this.executor = executor
setTabCompleter = (tabCompleter: TabCompleter) => this.tabCompleter = tabCompleter
toString = () => `SpringCommand(${this.name})`
}

View File

@@ -1,32 +0,0 @@
import { plugin, database } from '@ccms/api'
import { DataBaseManager } from '@ccms/database'
import { provideSingleton, inject } from '@ccms/container'
import * as fs from '@ccms/common/dist/fs'
@provideSingleton(plugin.PluginScanner)
export class MySQLScanner implements plugin.PluginScanner {
type: string = "mysql"
private target: string
@inject(database.DataBaseManager)
private databaseManager: DataBaseManager
scan(target: any): string[] {
this.target = target
let plugins = this.databaseManager.getMainDatabase().query<{ name: string }>(`SELECT name FROM ${this.target} WHERE LENGTH(source) != 0 AND deleted = 0`)
return plugins.map(p => `mysql:${p.name}`)
}
load(target: any) {
if (typeof target !== "string" || !target.startsWith('mysql:')) { return }
let name = target.split("mysql:")[1]
if (!name) { console.warn(`[PluginScanner][mysql] plugin name can't be null!`); return }
var plugin: any = this.databaseManager.getMainDatabase().query<{ source: string }>(`SELECT source FROM ${this.target} WHERE name = ? AND deleted = 0`, name)
if (plugin.length == 0) { console.warn(`[PluginScanner][mysql] plugin ${target} not found at mysql database...`); return }
let temp = fs.concat(root, 'mysql-plugin-cache', target, `${plugin[0]}.js`)
base.save(temp, plugin[0].source)
//@ts-ignore
return require(temp, { cache: false })
}
}

View File

@@ -1,56 +1,50 @@
import { server } from '@ccms/api'
import { provideSingleton, inject } from '@ccms/container'
import { NativePluginManager } from '@ccms/api/dist/interfaces/server/native_plugin'
import { CommandMap } from './internal/command'
import { provideSingleton } from '@ccms/container';
import { NativePluginManager } from '@ccms/api/dist/interfaces/server/native_plugin';
@provideSingleton(server.Server)
export class SpringServer implements server.Server {
@inject(CommandMap)
private commandMap: CommandMap
constructor() {
}
getVersion(): string {
return "SpringFramework"
}
getPlayer(name: string) {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
getOnlinePlayers(): any[] {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
getConsoleSender() {
return {
name: 'CONSOLE',
sendMessage: (message: string) => console.console(message)
}
return undefined;
}
getService(service: string) {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
dispatchCommand(sender: any, command: string): boolean {
let cmd_args = command.split(" ")
return this.commandMap.dispatch(sender, cmd_args.shift(), cmd_args || [])
console.console('§4Spring暂不支持dispatchCommand!')
return false;
}
dispatchConsoleCommand(command: string): boolean {
return this.dispatchCommand(this.getConsoleSender(), command)
console.console('§4Spring暂不支持dispatchConsoleCommand!')
return false;
}
getPluginsFolder(): string {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
getNativePluginManager(): NativePluginManager {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
getNettyPipeline() {
return base.getInstance().getAutowireCapableBeanFactory()
}
getRootLogger() {
return Packages.org.slf4j.LoggerFactory.getLogger("root") || global.logger
return global.logger
}
sendJson(sender: any, json: string | object): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
tabComplete(sender: any, input: string, index?: number) {
return this.commandMap.tabComplate(sender, input, index)
throw new Error("Method not implemented.");
}
}

View File

@@ -1,30 +1,29 @@
import { task, plugin } from '@ccms/api'
import { inject, provideSingleton } from '@ccms/container'
import thread_pool from '@ccms/common/dist/thread-pool'
const AtomicInteger = Java.type("java.util.concurrent.atomic.AtomicInteger")
const AtomicBoolean = Java.type("java.util.concurrent.atomic.AtomicBoolean")
const Thread = Java.type('java.lang.Thread')
const ThreadPoolExecutor = Java.type('java.util.concurrent.ThreadPoolExecutor')
const ThreadPoolTaskExecutor = Java.type('org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor')
const taskId = new AtomicInteger(0)
const tasks: { [key: number]: task.Cancelable } = {}
const executor = thread_pool.create({
groupName: '@ccms/spring'
})
let executor: any
let tasks: { [key: number]: task.Cancelable } = {}
let taskId = 0
@provideSingleton(task.TaskManager)
export class SpringTaskManager implements task.TaskManager {
@inject(plugin.PluginInstance)
private pluginInstance: any
private innerTaskId: any
private innerTasks: { [s: string]: task.Cancelable }
private innerExecutor: java.util.concurrent.ThreadPoolExecutor
constructor() {
this.innerTaskId = taskId
this.innerTasks = tasks
this.innerExecutor = executor
executor = new ThreadPoolTaskExecutor()
executor.setCorePoolSize(10)
executor.setMaxPoolSize(100)
executor.setQueueCapacity(500)
executor.setKeepAliveSeconds(60)
executor.setThreadNamePrefix("@ccms/spring-")
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy())
executor.initialize()
}
create(func: Function): task.Task {
@@ -35,16 +34,16 @@ export class SpringTaskManager implements task.TaskManager {
return func()
}
disable() {
Object.values(this.innerTasks).forEach((task) => task?.cancel())
this.innerExecutor.shutdown()
Object.values(tasks).forEach((task) => task.cancel())
executor.shutdown();
}
}
export class SpringTask extends task.Task {
public id = taskId.incrementAndGet()
public id = taskId++
private running = new AtomicBoolean(true)
run(...args: any[]) {
run() {
if (this.laterTime > 0) {
try {
Thread.sleep(this.laterTime)
@@ -54,7 +53,7 @@ export class SpringTask extends task.Task {
}
while (this.running.get()) {
try {
this.func(...args)
this.func()
} catch (t) {
console.error("Task exec error:", t)
console.ex(t)
@@ -73,13 +72,13 @@ export class SpringTask extends task.Task {
cancel(): any {
var wasRunning = this.running.getAndSet(false)
if (wasRunning) {
delete tasks[this.id]
tasks[this.id] = undefined
}
}
submit(...args: any[]): task.Cancelable {
submit(): task.Cancelable {
tasks[this.id] = this
executor.execute((() => this.run(...args)) as any)
executor.execute(this.run.bind(this))
return {
cancel: () => {
return this.cancel()

22
packages/types/.npmignore Normal file
View File

@@ -0,0 +1,22 @@
test
bundled
build
coverage
docs
wiki
gulpfile.js
bower.json
karma.conf.js
tsconfig.json
typings.json
CONTRIBUTING.md
ISSUE_TEMPLATE.md
PULL_REQUEST_TEMPLATE.md
tslint.json
wallaby.js
.travis.yml
.gitignore
.vscode
.theia
type_definitions
tsconfig.tsbuildinfo

4
packages/types/dist/index.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
/// <reference path="./typings/bukkit/index.d.ts" />
/// <reference path="./typings/bungee/index.d.ts" />
/// <reference path="./typings/nukkit/index.d.ts" />
/// <reference path="./typings/sponge/index.d.ts" />

View File

@@ -0,0 +1,958 @@
/// <reference path="./org.bukkit.Achievement.d.ts" />
/// <reference path="./org.bukkit.Art.d.ts" />
/// <reference path="./org.bukkit.Axis.d.ts" />
/// <reference path="./org.bukkit.BanEntry.d.ts" />
/// <reference path="./org.bukkit.BanList.Type.d.ts" />
/// <reference path="./org.bukkit.BanList.d.ts" />
/// <reference path="./org.bukkit.BlockChangeDelegate.d.ts" />
/// <reference path="./org.bukkit.Bukkit.d.ts" />
/// <reference path="./org.bukkit.ChatColor.d.ts" />
/// <reference path="./org.bukkit.Chunk.d.ts" />
/// <reference path="./org.bukkit.ChunkSnapshot.d.ts" />
/// <reference path="./org.bukkit.CoalType.d.ts" />
/// <reference path="./org.bukkit.Color.d.ts" />
/// <reference path="./org.bukkit.CropState.d.ts" />
/// <reference path="./org.bukkit.Difficulty.d.ts" />
/// <reference path="./org.bukkit.DyeColor.d.ts" />
/// <reference path="./org.bukkit.Effect.Type.d.ts" />
/// <reference path="./org.bukkit.Effect.d.ts" />
/// <reference path="./org.bukkit.EntityEffect.d.ts" />
/// <reference path="./org.bukkit.FireworkEffect.Builder.d.ts" />
/// <reference path="./org.bukkit.FireworkEffect.Type.d.ts" />
/// <reference path="./org.bukkit.FireworkEffect.d.ts" />
/// <reference path="./org.bukkit.FluidCollisionMode.d.ts" />
/// <reference path="./org.bukkit.GameMode.d.ts" />
/// <reference path="./org.bukkit.GameRule.d.ts" />
/// <reference path="./org.bukkit.GrassSpecies.d.ts" />
/// <reference path="./org.bukkit.Instrument.d.ts" />
/// <reference path="./org.bukkit.Keyed.d.ts" />
/// <reference path="./org.bukkit.Location.d.ts" />
/// <reference path="./org.bukkit.Material.d.ts" />
/// <reference path="./org.bukkit.Nameable.d.ts" />
/// <reference path="./org.bukkit.NamespacedKey.d.ts" />
/// <reference path="./org.bukkit.NetherWartsState.d.ts" />
/// <reference path="./org.bukkit.Note.Tone.d.ts" />
/// <reference path="./org.bukkit.Note.d.ts" />
/// <reference path="./org.bukkit.OfflinePlayer.d.ts" />
/// <reference path="./org.bukkit.Particle.DustOptions.d.ts" />
/// <reference path="./org.bukkit.Particle.d.ts" />
/// <reference path="./org.bukkit.PortalType.d.ts" />
/// <reference path="./org.bukkit.Registry.SimpleRegistry.d.ts" />
/// <reference path="./org.bukkit.Registry.d.ts" />
/// <reference path="./org.bukkit.Rotation.d.ts" />
/// <reference path="./org.bukkit.SandstoneType.d.ts" />
/// <reference path="./org.bukkit.Server.d.ts" />
/// <reference path="./org.bukkit.SkullType.d.ts" />
/// <reference path="./org.bukkit.Sound.d.ts" />
/// <reference path="./org.bukkit.SoundCategory.d.ts" />
/// <reference path="./org.bukkit.Statistic.Type.d.ts" />
/// <reference path="./org.bukkit.Statistic.d.ts" />
/// <reference path="./org.bukkit.StructureType.d.ts" />
/// <reference path="./org.bukkit.Tag.d.ts" />
/// <reference path="./org.bukkit.TreeSpecies.d.ts" />
/// <reference path="./org.bukkit.TreeType.d.ts" />
/// <reference path="./org.bukkit.UndefinedNullability.d.ts" />
/// <reference path="./org.bukkit.UnsafeValues.d.ts" />
/// <reference path="./org.bukkit.Utility.d.ts" />
/// <reference path="./org.bukkit.Warning.WarningState.d.ts" />
/// <reference path="./org.bukkit.Warning.d.ts" />
/// <reference path="./org.bukkit.WeatherType.d.ts" />
/// <reference path="./org.bukkit.World.Environment.d.ts" />
/// <reference path="./org.bukkit.World.d.ts" />
/// <reference path="./org.bukkit.WorldBorder.d.ts" />
/// <reference path="./org.bukkit.WorldCreator.d.ts" />
/// <reference path="./org.bukkit.WorldType.d.ts" />
/// <reference path="./org.bukkit.advancement.Advancement.d.ts" />
/// <reference path="./org.bukkit.advancement.AdvancementProgress.d.ts" />
/// <reference path="./org.bukkit.attribute.Attributable.d.ts" />
/// <reference path="./org.bukkit.attribute.Attribute.d.ts" />
/// <reference path="./org.bukkit.attribute.AttributeInstance.d.ts" />
/// <reference path="./org.bukkit.attribute.AttributeModifier.Operation.d.ts" />
/// <reference path="./org.bukkit.attribute.AttributeModifier.d.ts" />
/// <reference path="./org.bukkit.block.Banner.d.ts" />
/// <reference path="./org.bukkit.block.Barrel.d.ts" />
/// <reference path="./org.bukkit.block.Beacon.d.ts" />
/// <reference path="./org.bukkit.block.Bed.d.ts" />
/// <reference path="./org.bukkit.block.Bell.d.ts" />
/// <reference path="./org.bukkit.block.Biome.d.ts" />
/// <reference path="./org.bukkit.block.BlastFurnace.d.ts" />
/// <reference path="./org.bukkit.block.Block.d.ts" />
/// <reference path="./org.bukkit.block.BlockFace.d.ts" />
/// <reference path="./org.bukkit.block.BlockState.d.ts" />
/// <reference path="./org.bukkit.block.BrewingStand.d.ts" />
/// <reference path="./org.bukkit.block.Campfire.d.ts" />
/// <reference path="./org.bukkit.block.Chest.d.ts" />
/// <reference path="./org.bukkit.block.CommandBlock.d.ts" />
/// <reference path="./org.bukkit.block.Comparator.d.ts" />
/// <reference path="./org.bukkit.block.Conduit.d.ts" />
/// <reference path="./org.bukkit.block.Container.d.ts" />
/// <reference path="./org.bukkit.block.CreatureSpawner.d.ts" />
/// <reference path="./org.bukkit.block.DaylightDetector.d.ts" />
/// <reference path="./org.bukkit.block.Dispenser.d.ts" />
/// <reference path="./org.bukkit.block.DoubleChest.d.ts" />
/// <reference path="./org.bukkit.block.Dropper.d.ts" />
/// <reference path="./org.bukkit.block.EnchantingTable.d.ts" />
/// <reference path="./org.bukkit.block.EndGateway.d.ts" />
/// <reference path="./org.bukkit.block.EnderChest.d.ts" />
/// <reference path="./org.bukkit.block.FlowerPot.d.ts" />
/// <reference path="./org.bukkit.block.Furnace.d.ts" />
/// <reference path="./org.bukkit.block.Hopper.d.ts" />
/// <reference path="./org.bukkit.block.Jigsaw.d.ts" />
/// <reference path="./org.bukkit.block.Jukebox.d.ts" />
/// <reference path="./org.bukkit.block.Lectern.d.ts" />
/// <reference path="./org.bukkit.block.Lockable.d.ts" />
/// <reference path="./org.bukkit.block.NoteBlock.d.ts" />
/// <reference path="./org.bukkit.block.PistonMoveReaction.d.ts" />
/// <reference path="./org.bukkit.block.ShulkerBox.d.ts" />
/// <reference path="./org.bukkit.block.Sign.d.ts" />
/// <reference path="./org.bukkit.block.Skull.d.ts" />
/// <reference path="./org.bukkit.block.Smoker.d.ts" />
/// <reference path="./org.bukkit.block.Structure.d.ts" />
/// <reference path="./org.bukkit.block.TileState.d.ts" />
/// <reference path="./org.bukkit.block.banner.Pattern.d.ts" />
/// <reference path="./org.bukkit.block.banner.PatternType.d.ts" />
/// <reference path="./org.bukkit.block.data.Ageable.d.ts" />
/// <reference path="./org.bukkit.block.data.AnaloguePowerable.d.ts" />
/// <reference path="./org.bukkit.block.data.Attachable.d.ts" />
/// <reference path="./org.bukkit.block.data.Bisected.Half.d.ts" />
/// <reference path="./org.bukkit.block.data.Bisected.d.ts" />
/// <reference path="./org.bukkit.block.data.BlockData.d.ts" />
/// <reference path="./org.bukkit.block.data.Directional.d.ts" />
/// <reference path="./org.bukkit.block.data.Levelled.d.ts" />
/// <reference path="./org.bukkit.block.data.Lightable.d.ts" />
/// <reference path="./org.bukkit.block.data.MultipleFacing.d.ts" />
/// <reference path="./org.bukkit.block.data.Openable.d.ts" />
/// <reference path="./org.bukkit.block.data.Orientable.d.ts" />
/// <reference path="./org.bukkit.block.data.Powerable.d.ts" />
/// <reference path="./org.bukkit.block.data.Rail.Shape.d.ts" />
/// <reference path="./org.bukkit.block.data.Rail.d.ts" />
/// <reference path="./org.bukkit.block.data.Rotatable.d.ts" />
/// <reference path="./org.bukkit.block.data.Snowable.d.ts" />
/// <reference path="./org.bukkit.block.data.Waterlogged.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Bamboo.Leaves.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Bamboo.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Bed.Part.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Bed.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Bell.Attachment.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Bell.d.ts" />
/// <reference path="./org.bukkit.block.data.type.BrewingStand.d.ts" />
/// <reference path="./org.bukkit.block.data.type.BubbleColumn.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Cake.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Campfire.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Chest.Type.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Chest.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Cocoa.d.ts" />
/// <reference path="./org.bukkit.block.data.type.CommandBlock.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Comparator.Mode.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Comparator.d.ts" />
/// <reference path="./org.bukkit.block.data.type.CoralWallFan.d.ts" />
/// <reference path="./org.bukkit.block.data.type.DaylightDetector.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Dispenser.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Door.Hinge.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Door.d.ts" />
/// <reference path="./org.bukkit.block.data.type.EndPortalFrame.d.ts" />
/// <reference path="./org.bukkit.block.data.type.EnderChest.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Farmland.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Fence.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Fire.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Furnace.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Gate.d.ts" />
/// <reference path="./org.bukkit.block.data.type.GlassPane.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Hopper.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Jukebox.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Ladder.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Lantern.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Leaves.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Lectern.d.ts" />
/// <reference path="./org.bukkit.block.data.type.NoteBlock.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Observer.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Piston.d.ts" />
/// <reference path="./org.bukkit.block.data.type.PistonHead.d.ts" />
/// <reference path="./org.bukkit.block.data.type.RedstoneRail.d.ts" />
/// <reference path="./org.bukkit.block.data.type.RedstoneWallTorch.d.ts" />
/// <reference path="./org.bukkit.block.data.type.RedstoneWire.Connection.d.ts" />
/// <reference path="./org.bukkit.block.data.type.RedstoneWire.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Repeater.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Sapling.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Scaffolding.d.ts" />
/// <reference path="./org.bukkit.block.data.type.SeaPickle.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Sign.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Slab.Type.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Slab.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Snow.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Stairs.Shape.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Stairs.d.ts" />
/// <reference path="./org.bukkit.block.data.type.StructureBlock.Mode.d.ts" />
/// <reference path="./org.bukkit.block.data.type.StructureBlock.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Switch.Face.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Switch.d.ts" />
/// <reference path="./org.bukkit.block.data.type.TNT.d.ts" />
/// <reference path="./org.bukkit.block.data.type.TechnicalPiston.Type.d.ts" />
/// <reference path="./org.bukkit.block.data.type.TechnicalPiston.d.ts" />
/// <reference path="./org.bukkit.block.data.type.TrapDoor.d.ts" />
/// <reference path="./org.bukkit.block.data.type.Tripwire.d.ts" />
/// <reference path="./org.bukkit.block.data.type.TripwireHook.d.ts" />
/// <reference path="./org.bukkit.block.data.type.TurtleEgg.d.ts" />
/// <reference path="./org.bukkit.block.data.type.WallSign.d.ts" />
/// <reference path="./org.bukkit.block.structure.Mirror.d.ts" />
/// <reference path="./org.bukkit.block.structure.StructureRotation.d.ts" />
/// <reference path="./org.bukkit.block.structure.UsageMode.d.ts" />
/// <reference path="./org.bukkit.boss.BarColor.d.ts" />
/// <reference path="./org.bukkit.boss.BarFlag.d.ts" />
/// <reference path="./org.bukkit.boss.BarStyle.d.ts" />
/// <reference path="./org.bukkit.boss.BossBar.d.ts" />
/// <reference path="./org.bukkit.boss.KeyedBossBar.d.ts" />
/// <reference path="./org.bukkit.command.BlockCommandSender.d.ts" />
/// <reference path="./org.bukkit.command.Command.d.ts" />
/// <reference path="./org.bukkit.command.CommandException.d.ts" />
/// <reference path="./org.bukkit.command.CommandExecutor.d.ts" />
/// <reference path="./org.bukkit.command.CommandMap.d.ts" />
/// <reference path="./org.bukkit.command.CommandSender.d.ts" />
/// <reference path="./org.bukkit.command.ConsoleCommandSender.d.ts" />
/// <reference path="./org.bukkit.command.FormattedCommandAlias.d.ts" />
/// <reference path="./org.bukkit.command.MultipleCommandAlias.d.ts" />
/// <reference path="./org.bukkit.command.PluginCommand.d.ts" />
/// <reference path="./org.bukkit.command.PluginCommandYamlParser.d.ts" />
/// <reference path="./org.bukkit.command.PluginIdentifiableCommand.d.ts" />
/// <reference path="./org.bukkit.command.ProxiedCommandSender.d.ts" />
/// <reference path="./org.bukkit.command.RemoteConsoleCommandSender.d.ts" />
/// <reference path="./org.bukkit.command.SimpleCommandMap.d.ts" />
/// <reference path="./org.bukkit.command.TabCompleter.d.ts" />
/// <reference path="./org.bukkit.command.TabExecutor.d.ts" />
/// <reference path="./org.bukkit.command.defaults.BukkitCommand.d.ts" />
/// <reference path="./org.bukkit.command.defaults.HelpCommand.d.ts" />
/// <reference path="./org.bukkit.command.defaults.PluginsCommand.d.ts" />
/// <reference path="./org.bukkit.command.defaults.ReloadCommand.d.ts" />
/// <reference path="./org.bukkit.command.defaults.TimingsCommand.d.ts" />
/// <reference path="./org.bukkit.command.defaults.VersionCommand.d.ts" />
/// <reference path="./org.bukkit.configuration.Configuration.d.ts" />
/// <reference path="./org.bukkit.configuration.ConfigurationOptions.d.ts" />
/// <reference path="./org.bukkit.configuration.ConfigurationSection.d.ts" />
/// <reference path="./org.bukkit.configuration.InvalidConfigurationException.d.ts" />
/// <reference path="./org.bukkit.configuration.MemoryConfiguration.d.ts" />
/// <reference path="./org.bukkit.configuration.MemoryConfigurationOptions.d.ts" />
/// <reference path="./org.bukkit.configuration.MemorySection.d.ts" />
/// <reference path="./org.bukkit.configuration.file.FileConfiguration.d.ts" />
/// <reference path="./org.bukkit.configuration.file.FileConfigurationOptions.d.ts" />
/// <reference path="./org.bukkit.configuration.file.YamlConfiguration.d.ts" />
/// <reference path="./org.bukkit.configuration.file.YamlConfigurationOptions.d.ts" />
/// <reference path="./org.bukkit.configuration.file.YamlConstructor.d.ts" />
/// <reference path="./org.bukkit.configuration.file.YamlRepresenter.d.ts" />
/// <reference path="./org.bukkit.configuration.serialization.ConfigurationSerializable.d.ts" />
/// <reference path="./org.bukkit.configuration.serialization.ConfigurationSerialization.d.ts" />
/// <reference path="./org.bukkit.configuration.serialization.DelegateDeserialization.d.ts" />
/// <reference path="./org.bukkit.configuration.serialization.SerializableAs.d.ts" />
/// <reference path="./org.bukkit.conversations.BooleanPrompt.d.ts" />
/// <reference path="./org.bukkit.conversations.Conversable.d.ts" />
/// <reference path="./org.bukkit.conversations.Conversation.ConversationState.d.ts" />
/// <reference path="./org.bukkit.conversations.Conversation.d.ts" />
/// <reference path="./org.bukkit.conversations.ConversationAbandonedEvent.d.ts" />
/// <reference path="./org.bukkit.conversations.ConversationAbandonedListener.d.ts" />
/// <reference path="./org.bukkit.conversations.ConversationCanceller.d.ts" />
/// <reference path="./org.bukkit.conversations.ConversationContext.d.ts" />
/// <reference path="./org.bukkit.conversations.ConversationFactory.d.ts" />
/// <reference path="./org.bukkit.conversations.ConversationPrefix.d.ts" />
/// <reference path="./org.bukkit.conversations.ExactMatchConversationCanceller.d.ts" />
/// <reference path="./org.bukkit.conversations.FixedSetPrompt.d.ts" />
/// <reference path="./org.bukkit.conversations.InactivityConversationCanceller.d.ts" />
/// <reference path="./org.bukkit.conversations.ManuallyAbandonedConversationCanceller.d.ts" />
/// <reference path="./org.bukkit.conversations.MessagePrompt.d.ts" />
/// <reference path="./org.bukkit.conversations.NullConversationPrefix.d.ts" />
/// <reference path="./org.bukkit.conversations.NumericPrompt.d.ts" />
/// <reference path="./org.bukkit.conversations.PlayerNamePrompt.d.ts" />
/// <reference path="./org.bukkit.conversations.PluginNameConversationPrefix.d.ts" />
/// <reference path="./org.bukkit.conversations.Prompt.d.ts" />
/// <reference path="./org.bukkit.conversations.RegexPrompt.d.ts" />
/// <reference path="./org.bukkit.conversations.StringPrompt.d.ts" />
/// <reference path="./org.bukkit.conversations.ValidatingPrompt.d.ts" />
/// <reference path="./org.bukkit.enchantments.Enchantment.d.ts" />
/// <reference path="./org.bukkit.enchantments.EnchantmentOffer.d.ts" />
/// <reference path="./org.bukkit.enchantments.EnchantmentTarget.d.ts" />
/// <reference path="./org.bukkit.enchantments.EnchantmentWrapper.d.ts" />
/// <reference path="./org.bukkit.entity.AbstractArrow.PickupStatus.d.ts" />
/// <reference path="./org.bukkit.entity.AbstractArrow.d.ts" />
/// <reference path="./org.bukkit.entity.AbstractHorse.d.ts" />
/// <reference path="./org.bukkit.entity.AbstractVillager.d.ts" />
/// <reference path="./org.bukkit.entity.Ageable.d.ts" />
/// <reference path="./org.bukkit.entity.Ambient.d.ts" />
/// <reference path="./org.bukkit.entity.AnimalTamer.d.ts" />
/// <reference path="./org.bukkit.entity.Animals.d.ts" />
/// <reference path="./org.bukkit.entity.AreaEffectCloud.d.ts" />
/// <reference path="./org.bukkit.entity.ArmorStand.d.ts" />
/// <reference path="./org.bukkit.entity.Arrow.d.ts" />
/// <reference path="./org.bukkit.entity.Bat.d.ts" />
/// <reference path="./org.bukkit.entity.Blaze.d.ts" />
/// <reference path="./org.bukkit.entity.Boat.d.ts" />
/// <reference path="./org.bukkit.entity.Boss.d.ts" />
/// <reference path="./org.bukkit.entity.Cat.Type.d.ts" />
/// <reference path="./org.bukkit.entity.Cat.d.ts" />
/// <reference path="./org.bukkit.entity.CaveSpider.d.ts" />
/// <reference path="./org.bukkit.entity.ChestedHorse.d.ts" />
/// <reference path="./org.bukkit.entity.Chicken.d.ts" />
/// <reference path="./org.bukkit.entity.Cod.d.ts" />
/// <reference path="./org.bukkit.entity.ComplexEntityPart.d.ts" />
/// <reference path="./org.bukkit.entity.ComplexLivingEntity.d.ts" />
/// <reference path="./org.bukkit.entity.Cow.d.ts" />
/// <reference path="./org.bukkit.entity.Creature.d.ts" />
/// <reference path="./org.bukkit.entity.Creeper.d.ts" />
/// <reference path="./org.bukkit.entity.Damageable.d.ts" />
/// <reference path="./org.bukkit.entity.Dolphin.d.ts" />
/// <reference path="./org.bukkit.entity.Donkey.d.ts" />
/// <reference path="./org.bukkit.entity.DragonFireball.d.ts" />
/// <reference path="./org.bukkit.entity.Drowned.d.ts" />
/// <reference path="./org.bukkit.entity.Egg.d.ts" />
/// <reference path="./org.bukkit.entity.ElderGuardian.d.ts" />
/// <reference path="./org.bukkit.entity.EnderCrystal.d.ts" />
/// <reference path="./org.bukkit.entity.EnderDragon.Phase.d.ts" />
/// <reference path="./org.bukkit.entity.EnderDragon.d.ts" />
/// <reference path="./org.bukkit.entity.EnderDragonPart.d.ts" />
/// <reference path="./org.bukkit.entity.EnderPearl.d.ts" />
/// <reference path="./org.bukkit.entity.EnderSignal.d.ts" />
/// <reference path="./org.bukkit.entity.Enderman.d.ts" />
/// <reference path="./org.bukkit.entity.Endermite.d.ts" />
/// <reference path="./org.bukkit.entity.Entity.d.ts" />
/// <reference path="./org.bukkit.entity.EntityType.d.ts" />
/// <reference path="./org.bukkit.entity.Evoker.Spell.d.ts" />
/// <reference path="./org.bukkit.entity.Evoker.d.ts" />
/// <reference path="./org.bukkit.entity.EvokerFangs.d.ts" />
/// <reference path="./org.bukkit.entity.ExperienceOrb.d.ts" />
/// <reference path="./org.bukkit.entity.Explosive.d.ts" />
/// <reference path="./org.bukkit.entity.FallingBlock.d.ts" />
/// <reference path="./org.bukkit.entity.Fireball.d.ts" />
/// <reference path="./org.bukkit.entity.Firework.d.ts" />
/// <reference path="./org.bukkit.entity.Fish.d.ts" />
/// <reference path="./org.bukkit.entity.FishHook.d.ts" />
/// <reference path="./org.bukkit.entity.Flying.d.ts" />
/// <reference path="./org.bukkit.entity.Fox.Type.d.ts" />
/// <reference path="./org.bukkit.entity.Fox.d.ts" />
/// <reference path="./org.bukkit.entity.Ghast.d.ts" />
/// <reference path="./org.bukkit.entity.Giant.d.ts" />
/// <reference path="./org.bukkit.entity.Golem.d.ts" />
/// <reference path="./org.bukkit.entity.Guardian.d.ts" />
/// <reference path="./org.bukkit.entity.Hanging.d.ts" />
/// <reference path="./org.bukkit.entity.Horse.Color.d.ts" />
/// <reference path="./org.bukkit.entity.Horse.Style.d.ts" />
/// <reference path="./org.bukkit.entity.Horse.Variant.d.ts" />
/// <reference path="./org.bukkit.entity.Horse.d.ts" />
/// <reference path="./org.bukkit.entity.HumanEntity.d.ts" />
/// <reference path="./org.bukkit.entity.Husk.d.ts" />
/// <reference path="./org.bukkit.entity.Illager.d.ts" />
/// <reference path="./org.bukkit.entity.Illusioner.d.ts" />
/// <reference path="./org.bukkit.entity.IronGolem.d.ts" />
/// <reference path="./org.bukkit.entity.Item.d.ts" />
/// <reference path="./org.bukkit.entity.ItemFrame.d.ts" />
/// <reference path="./org.bukkit.entity.LargeFireball.d.ts" />
/// <reference path="./org.bukkit.entity.LeashHitch.d.ts" />
/// <reference path="./org.bukkit.entity.LightningStrike.d.ts" />
/// <reference path="./org.bukkit.entity.LingeringPotion.d.ts" />
/// <reference path="./org.bukkit.entity.LivingEntity.d.ts" />
/// <reference path="./org.bukkit.entity.Llama.Color.d.ts" />
/// <reference path="./org.bukkit.entity.Llama.d.ts" />
/// <reference path="./org.bukkit.entity.LlamaSpit.d.ts" />
/// <reference path="./org.bukkit.entity.MagmaCube.d.ts" />
/// <reference path="./org.bukkit.entity.Minecart.d.ts" />
/// <reference path="./org.bukkit.entity.Mob.d.ts" />
/// <reference path="./org.bukkit.entity.Monster.d.ts" />
/// <reference path="./org.bukkit.entity.Mule.d.ts" />
/// <reference path="./org.bukkit.entity.MushroomCow.Variant.d.ts" />
/// <reference path="./org.bukkit.entity.MushroomCow.d.ts" />
/// <reference path="./org.bukkit.entity.NPC.d.ts" />
/// <reference path="./org.bukkit.entity.Ocelot.Type.d.ts" />
/// <reference path="./org.bukkit.entity.Ocelot.d.ts" />
/// <reference path="./org.bukkit.entity.Painting.d.ts" />
/// <reference path="./org.bukkit.entity.Panda.Gene.d.ts" />
/// <reference path="./org.bukkit.entity.Panda.d.ts" />
/// <reference path="./org.bukkit.entity.Parrot.Variant.d.ts" />
/// <reference path="./org.bukkit.entity.Parrot.d.ts" />
/// <reference path="./org.bukkit.entity.Phantom.d.ts" />
/// <reference path="./org.bukkit.entity.Pig.d.ts" />
/// <reference path="./org.bukkit.entity.PigZombie.d.ts" />
/// <reference path="./org.bukkit.entity.Pillager.d.ts" />
/// <reference path="./org.bukkit.entity.Player.d.ts" />
/// <reference path="./org.bukkit.entity.PolarBear.d.ts" />
/// <reference path="./org.bukkit.entity.Pose.d.ts" />
/// <reference path="./org.bukkit.entity.Projectile.d.ts" />
/// <reference path="./org.bukkit.entity.PufferFish.d.ts" />
/// <reference path="./org.bukkit.entity.Rabbit.Type.d.ts" />
/// <reference path="./org.bukkit.entity.Rabbit.d.ts" />
/// <reference path="./org.bukkit.entity.Raider.d.ts" />
/// <reference path="./org.bukkit.entity.Ravager.d.ts" />
/// <reference path="./org.bukkit.entity.Salmon.d.ts" />
/// <reference path="./org.bukkit.entity.Sheep.d.ts" />
/// <reference path="./org.bukkit.entity.Shulker.d.ts" />
/// <reference path="./org.bukkit.entity.ShulkerBullet.d.ts" />
/// <reference path="./org.bukkit.entity.Silverfish.d.ts" />
/// <reference path="./org.bukkit.entity.Sittable.d.ts" />
/// <reference path="./org.bukkit.entity.Skeleton.SkeletonType.d.ts" />
/// <reference path="./org.bukkit.entity.Skeleton.d.ts" />
/// <reference path="./org.bukkit.entity.SkeletonHorse.d.ts" />
/// <reference path="./org.bukkit.entity.Slime.d.ts" />
/// <reference path="./org.bukkit.entity.SmallFireball.d.ts" />
/// <reference path="./org.bukkit.entity.Snowball.d.ts" />
/// <reference path="./org.bukkit.entity.Snowman.d.ts" />
/// <reference path="./org.bukkit.entity.SpectralArrow.d.ts" />
/// <reference path="./org.bukkit.entity.Spellcaster.Spell.d.ts" />
/// <reference path="./org.bukkit.entity.Spellcaster.d.ts" />
/// <reference path="./org.bukkit.entity.Spider.d.ts" />
/// <reference path="./org.bukkit.entity.SplashPotion.d.ts" />
/// <reference path="./org.bukkit.entity.Squid.d.ts" />
/// <reference path="./org.bukkit.entity.Stray.d.ts" />
/// <reference path="./org.bukkit.entity.TNTPrimed.d.ts" />
/// <reference path="./org.bukkit.entity.Tameable.d.ts" />
/// <reference path="./org.bukkit.entity.ThrownExpBottle.d.ts" />
/// <reference path="./org.bukkit.entity.ThrownPotion.d.ts" />
/// <reference path="./org.bukkit.entity.TippedArrow.d.ts" />
/// <reference path="./org.bukkit.entity.TraderLlama.d.ts" />
/// <reference path="./org.bukkit.entity.Trident.d.ts" />
/// <reference path="./org.bukkit.entity.TropicalFish.Pattern.d.ts" />
/// <reference path="./org.bukkit.entity.TropicalFish.d.ts" />
/// <reference path="./org.bukkit.entity.Turtle.d.ts" />
/// <reference path="./org.bukkit.entity.Vehicle.d.ts" />
/// <reference path="./org.bukkit.entity.Vex.d.ts" />
/// <reference path="./org.bukkit.entity.Villager.Profession.d.ts" />
/// <reference path="./org.bukkit.entity.Villager.Type.d.ts" />
/// <reference path="./org.bukkit.entity.Villager.d.ts" />
/// <reference path="./org.bukkit.entity.Vindicator.d.ts" />
/// <reference path="./org.bukkit.entity.WanderingTrader.d.ts" />
/// <reference path="./org.bukkit.entity.WaterMob.d.ts" />
/// <reference path="./org.bukkit.entity.Witch.d.ts" />
/// <reference path="./org.bukkit.entity.Wither.d.ts" />
/// <reference path="./org.bukkit.entity.WitherSkeleton.d.ts" />
/// <reference path="./org.bukkit.entity.WitherSkull.d.ts" />
/// <reference path="./org.bukkit.entity.Wolf.d.ts" />
/// <reference path="./org.bukkit.entity.Zombie.d.ts" />
/// <reference path="./org.bukkit.entity.ZombieHorse.d.ts" />
/// <reference path="./org.bukkit.entity.ZombieVillager.d.ts" />
/// <reference path="./org.bukkit.entity.memory.MemoryKey.d.ts" />
/// <reference path="./org.bukkit.entity.minecart.CommandMinecart.d.ts" />
/// <reference path="./org.bukkit.entity.minecart.ExplosiveMinecart.d.ts" />
/// <reference path="./org.bukkit.entity.minecart.HopperMinecart.d.ts" />
/// <reference path="./org.bukkit.entity.minecart.PoweredMinecart.d.ts" />
/// <reference path="./org.bukkit.entity.minecart.RideableMinecart.d.ts" />
/// <reference path="./org.bukkit.entity.minecart.SpawnerMinecart.d.ts" />
/// <reference path="./org.bukkit.entity.minecart.StorageMinecart.d.ts" />
/// <reference path="./org.bukkit.event.Cancellable.d.ts" />
/// <reference path="./org.bukkit.event.Event.Result.d.ts" />
/// <reference path="./org.bukkit.event.Event.d.ts" />
/// <reference path="./org.bukkit.event.EventException.d.ts" />
/// <reference path="./org.bukkit.event.EventHandler.d.ts" />
/// <reference path="./org.bukkit.event.EventPriority.d.ts" />
/// <reference path="./org.bukkit.event.HandlerList.d.ts" />
/// <reference path="./org.bukkit.event.Listener.d.ts" />
/// <reference path="./org.bukkit.event.block.Action.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockBreakEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockBurnEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockCanBuildEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockCookEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockDamageEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockDispenseArmorEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockDispenseEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockDropItemEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockExpEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockExplodeEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockFadeEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockFertilizeEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockFormEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockFromToEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockGrowEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockIgniteEvent.IgniteCause.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockIgniteEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockMultiPlaceEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockPhysicsEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockPistonEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockPistonExtendEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockPistonRetractEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockPlaceEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockRedstoneEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockShearEntityEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.BlockSpreadEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.d.ts" />
/// <reference path="./org.bukkit.event.block.CauldronLevelChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.EntityBlockFormEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.FluidLevelChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.LeavesDecayEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.MoistureChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.NotePlayEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.SignChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.block.SpongeAbsorbEvent.d.ts" />
/// <reference path="./org.bukkit.event.enchantment.EnchantItemEvent.d.ts" />
/// <reference path="./org.bukkit.event.enchantment.PrepareItemEnchantEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.AreaEffectCloudApplyEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.BatToggleSleepEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.d.ts" />
/// <reference path="./org.bukkit.event.entity.CreatureSpawnEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.CreeperPowerEvent.PowerCause.d.ts" />
/// <reference path="./org.bukkit.event.entity.CreeperPowerEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EnderDragonChangePhaseEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityAirChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityBreakDoorEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityBreedEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityChangeBlockEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityCombustByBlockEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityCombustByEntityEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityCombustEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityCreatePortalEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityDamageByBlockEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityDamageByEntityEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityDamageEvent.DamageCause.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityDamageEvent.DamageModifier.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityDamageEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityDeathEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityDropItemEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityExplodeEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityInteractEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityPickupItemEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityPlaceEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityPortalEnterEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityPortalEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityPortalExitEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityPoseChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityPotionEffectEvent.Action.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityPotionEffectEvent.Cause.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityPotionEffectEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityRegainHealthEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityResurrectEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityShootBowEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntitySpawnEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityTameEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityTargetEvent.TargetReason.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityTargetEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityTargetLivingEntityEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityTeleportEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityToggleGlideEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityToggleSwimEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityTransformEvent.TransformReason.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityTransformEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.d.ts" />
/// <reference path="./org.bukkit.event.entity.EntityUnleashEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.ExpBottleEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.ExplosionPrimeEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.FireworkExplodeEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.FoodLevelChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.HorseJumpEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.ItemDespawnEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.ItemMergeEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.ItemSpawnEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.LingeringPotionSplashEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.PigZapEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.PigZombieAngerEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.PlayerDeathEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.PlayerLeashEntityEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.PotionSplashEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.ProjectileHitEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.ProjectileLaunchEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.SheepDyeWoolEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.SheepRegrowWoolEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.SlimeSplitEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.VillagerAcquireTradeEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.VillagerCareerChangeEvent.ChangeReason.d.ts" />
/// <reference path="./org.bukkit.event.entity.VillagerCareerChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.entity.VillagerReplenishTradeEvent.d.ts" />
/// <reference path="./org.bukkit.event.hanging.HangingBreakByEntityEvent.d.ts" />
/// <reference path="./org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.d.ts" />
/// <reference path="./org.bukkit.event.hanging.HangingBreakEvent.d.ts" />
/// <reference path="./org.bukkit.event.hanging.HangingEvent.d.ts" />
/// <reference path="./org.bukkit.event.hanging.HangingPlaceEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.BrewEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.BrewingStandFuelEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.ClickType.d.ts" />
/// <reference path="./org.bukkit.event.inventory.CraftItemEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.DragType.d.ts" />
/// <reference path="./org.bukkit.event.inventory.FurnaceBurnEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.FurnaceExtractEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.FurnaceSmeltEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryAction.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryClickEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryCloseEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryCreativeEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryDragEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryInteractEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryMoveItemEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryOpenEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryPickupItemEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryType.SlotType.d.ts" />
/// <reference path="./org.bukkit.event.inventory.InventoryType.d.ts" />
/// <reference path="./org.bukkit.event.inventory.PrepareAnvilEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.PrepareItemCraftEvent.d.ts" />
/// <reference path="./org.bukkit.event.inventory.TradeSelectEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.AsyncPlayerChatEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result.d.ts" />
/// <reference path="./org.bukkit.event.player.AsyncPlayerPreLoginEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerAchievementAwardedEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerAdvancementDoneEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerAnimationEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerAnimationType.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerArmorStandManipulateEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerBedEnterEvent.BedEnterResult.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerBedEnterEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerBedLeaveEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerBucketEmptyEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerBucketEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerBucketFillEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerChangedMainHandEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerChangedWorldEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerChannelEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerChatEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerChatTabCompleteEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerCommandPreprocessEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerCommandSendEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerDropItemEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerEditBookEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerEggThrowEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerExpChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerFishEvent.State.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerFishEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerGameModeChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerInteractAtEntityEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerInteractEntityEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerInteractEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerItemBreakEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerItemConsumeEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerItemDamageEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerItemHeldEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerItemMendEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerJoinEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerKickEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerLevelChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerLocaleChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerLoginEvent.Result.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerLoginEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerMoveEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerPickupArrowEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerPickupItemEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerPortalEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerPreLoginEvent.Result.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerPreLoginEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerQuitEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerRecipeDiscoverEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerRegisterChannelEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerResourcePackStatusEvent.Status.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerResourcePackStatusEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerRespawnEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerRiptideEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerShearEntityEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerStatisticIncrementEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerSwapHandItemsEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerTakeLecternBookEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerTeleportEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerToggleFlightEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerToggleSneakEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerToggleSprintEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerUnleashEntityEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerUnregisterChannelEvent.d.ts" />
/// <reference path="./org.bukkit.event.player.PlayerVelocityEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.BroadcastMessageEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.MapInitializeEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.PluginDisableEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.PluginEnableEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.PluginEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.RemoteServerCommandEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.ServerCommandEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.ServerEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.ServerListPingEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.ServerLoadEvent.LoadType.d.ts" />
/// <reference path="./org.bukkit.event.server.ServerLoadEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.ServiceEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.ServiceRegisterEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.ServiceUnregisterEvent.d.ts" />
/// <reference path="./org.bukkit.event.server.TabCompleteEvent.d.ts" />
/// <reference path="./org.bukkit.event.vehicle.VehicleBlockCollisionEvent.d.ts" />
/// <reference path="./org.bukkit.event.vehicle.VehicleCollisionEvent.d.ts" />
/// <reference path="./org.bukkit.event.vehicle.VehicleCreateEvent.d.ts" />
/// <reference path="./org.bukkit.event.vehicle.VehicleDamageEvent.d.ts" />
/// <reference path="./org.bukkit.event.vehicle.VehicleDestroyEvent.d.ts" />
/// <reference path="./org.bukkit.event.vehicle.VehicleEnterEvent.d.ts" />
/// <reference path="./org.bukkit.event.vehicle.VehicleEntityCollisionEvent.d.ts" />
/// <reference path="./org.bukkit.event.vehicle.VehicleEvent.d.ts" />
/// <reference path="./org.bukkit.event.vehicle.VehicleExitEvent.d.ts" />
/// <reference path="./org.bukkit.event.vehicle.VehicleMoveEvent.d.ts" />
/// <reference path="./org.bukkit.event.vehicle.VehicleUpdateEvent.d.ts" />
/// <reference path="./org.bukkit.event.weather.LightningStrikeEvent.Cause.d.ts" />
/// <reference path="./org.bukkit.event.weather.LightningStrikeEvent.d.ts" />
/// <reference path="./org.bukkit.event.weather.ThunderChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.weather.WeatherChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.weather.WeatherEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.ChunkEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.ChunkLoadEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.ChunkPopulateEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.ChunkUnloadEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.PortalCreateEvent.CreateReason.d.ts" />
/// <reference path="./org.bukkit.event.world.PortalCreateEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.SpawnChangeEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.StructureGrowEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.WorldEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.WorldInitEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.WorldLoadEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.WorldSaveEvent.d.ts" />
/// <reference path="./org.bukkit.event.world.WorldUnloadEvent.d.ts" />
/// <reference path="./org.bukkit.generator.BlockPopulator.d.ts" />
/// <reference path="./org.bukkit.generator.ChunkGenerator.BiomeGrid.d.ts" />
/// <reference path="./org.bukkit.generator.ChunkGenerator.ChunkData.d.ts" />
/// <reference path="./org.bukkit.generator.ChunkGenerator.d.ts" />
/// <reference path="./org.bukkit.help.GenericCommandHelpTopic.d.ts" />
/// <reference path="./org.bukkit.help.HelpMap.d.ts" />
/// <reference path="./org.bukkit.help.HelpTopic.d.ts" />
/// <reference path="./org.bukkit.help.HelpTopicComparator.TopicNameComparator.d.ts" />
/// <reference path="./org.bukkit.help.HelpTopicComparator.d.ts" />
/// <reference path="./org.bukkit.help.HelpTopicFactory.d.ts" />
/// <reference path="./org.bukkit.help.IndexHelpTopic.d.ts" />
/// <reference path="./org.bukkit.inventory.AbstractHorseInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.AnvilInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.BeaconInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.BlastingRecipe.d.ts" />
/// <reference path="./org.bukkit.inventory.BlockInventoryHolder.d.ts" />
/// <reference path="./org.bukkit.inventory.BrewerInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.CampfireRecipe.d.ts" />
/// <reference path="./org.bukkit.inventory.CartographyInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.CookingRecipe.d.ts" />
/// <reference path="./org.bukkit.inventory.CraftingInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.DoubleChestInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.EnchantingInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.EntityEquipment.d.ts" />
/// <reference path="./org.bukkit.inventory.EquipmentSlot.d.ts" />
/// <reference path="./org.bukkit.inventory.FurnaceInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.FurnaceRecipe.d.ts" />
/// <reference path="./org.bukkit.inventory.GrindstoneInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.HorseInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.Inventory.d.ts" />
/// <reference path="./org.bukkit.inventory.InventoryHolder.d.ts" />
/// <reference path="./org.bukkit.inventory.InventoryView.Property.d.ts" />
/// <reference path="./org.bukkit.inventory.InventoryView.d.ts" />
/// <reference path="./org.bukkit.inventory.ItemFactory.d.ts" />
/// <reference path="./org.bukkit.inventory.ItemFlag.d.ts" />
/// <reference path="./org.bukkit.inventory.ItemStack.d.ts" />
/// <reference path="./org.bukkit.inventory.LecternInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.LlamaInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.LoomInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.MainHand.d.ts" />
/// <reference path="./org.bukkit.inventory.Merchant.d.ts" />
/// <reference path="./org.bukkit.inventory.MerchantInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.MerchantRecipe.d.ts" />
/// <reference path="./org.bukkit.inventory.PlayerInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.Recipe.d.ts" />
/// <reference path="./org.bukkit.inventory.RecipeChoice.ExactChoice.d.ts" />
/// <reference path="./org.bukkit.inventory.RecipeChoice.MaterialChoice.d.ts" />
/// <reference path="./org.bukkit.inventory.RecipeChoice.d.ts" />
/// <reference path="./org.bukkit.inventory.ShapedRecipe.d.ts" />
/// <reference path="./org.bukkit.inventory.ShapelessRecipe.d.ts" />
/// <reference path="./org.bukkit.inventory.SmokingRecipe.d.ts" />
/// <reference path="./org.bukkit.inventory.StonecutterInventory.d.ts" />
/// <reference path="./org.bukkit.inventory.StonecuttingRecipe.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.BannerMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.BlockDataMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.BlockStateMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.BookMeta.Generation.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.BookMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.CrossbowMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.Damageable.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.EnchantmentStorageMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.FireworkEffectMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.FireworkMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.ItemMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.KnowledgeBookMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.LeatherArmorMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.MapMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.PotionMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.Repairable.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.SkullMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.SpawnEggMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.TropicalFishBucketMeta.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.tags.CustomItemTagContainer.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.tags.ItemTagAdapterContext.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.tags.ItemTagType.PrimitiveTagType.d.ts" />
/// <reference path="./org.bukkit.inventory.meta.tags.ItemTagType.d.ts" />
/// <reference path="./org.bukkit.loot.LootContext.Builder.d.ts" />
/// <reference path="./org.bukkit.loot.LootContext.d.ts" />
/// <reference path="./org.bukkit.loot.LootTable.d.ts" />
/// <reference path="./org.bukkit.loot.LootTables.d.ts" />
/// <reference path="./org.bukkit.loot.Lootable.d.ts" />
/// <reference path="./org.bukkit.map.MapCanvas.d.ts" />
/// <reference path="./org.bukkit.map.MapCursor.Type.d.ts" />
/// <reference path="./org.bukkit.map.MapCursor.d.ts" />
/// <reference path="./org.bukkit.map.MapCursorCollection.d.ts" />
/// <reference path="./org.bukkit.map.MapFont.CharacterSprite.d.ts" />
/// <reference path="./org.bukkit.map.MapFont.d.ts" />
/// <reference path="./org.bukkit.map.MapPalette.d.ts" />
/// <reference path="./org.bukkit.map.MapRenderer.d.ts" />
/// <reference path="./org.bukkit.map.MapView.Scale.d.ts" />
/// <reference path="./org.bukkit.map.MapView.d.ts" />
/// <reference path="./org.bukkit.map.MinecraftFont.d.ts" />
/// <reference path="./org.bukkit.material.Attachable.d.ts" />
/// <reference path="./org.bukkit.material.Banner.d.ts" />
/// <reference path="./org.bukkit.material.Bed.d.ts" />
/// <reference path="./org.bukkit.material.Button.d.ts" />
/// <reference path="./org.bukkit.material.Cake.d.ts" />
/// <reference path="./org.bukkit.material.Cauldron.d.ts" />
/// <reference path="./org.bukkit.material.Chest.d.ts" />
/// <reference path="./org.bukkit.material.Coal.d.ts" />
/// <reference path="./org.bukkit.material.CocoaPlant.CocoaPlantSize.d.ts" />
/// <reference path="./org.bukkit.material.CocoaPlant.d.ts" />
/// <reference path="./org.bukkit.material.Colorable.d.ts" />
/// <reference path="./org.bukkit.material.Command.d.ts" />
/// <reference path="./org.bukkit.material.Comparator.d.ts" />
/// <reference path="./org.bukkit.material.Crops.d.ts" />
/// <reference path="./org.bukkit.material.DetectorRail.d.ts" />
/// <reference path="./org.bukkit.material.Diode.d.ts" />
/// <reference path="./org.bukkit.material.Directional.d.ts" />
/// <reference path="./org.bukkit.material.DirectionalContainer.d.ts" />
/// <reference path="./org.bukkit.material.Dispenser.d.ts" />
/// <reference path="./org.bukkit.material.Door.d.ts" />
/// <reference path="./org.bukkit.material.Dye.d.ts" />
/// <reference path="./org.bukkit.material.EnderChest.d.ts" />
/// <reference path="./org.bukkit.material.ExtendedRails.d.ts" />
/// <reference path="./org.bukkit.material.FlowerPot.d.ts" />
/// <reference path="./org.bukkit.material.Furnace.d.ts" />
/// <reference path="./org.bukkit.material.FurnaceAndDispenser.d.ts" />
/// <reference path="./org.bukkit.material.Gate.d.ts" />
/// <reference path="./org.bukkit.material.Hopper.d.ts" />
/// <reference path="./org.bukkit.material.Ladder.d.ts" />
/// <reference path="./org.bukkit.material.Leaves.d.ts" />
/// <reference path="./org.bukkit.material.Lever.d.ts" />
/// <reference path="./org.bukkit.material.LongGrass.d.ts" />
/// <reference path="./org.bukkit.material.MaterialData.d.ts" />
/// <reference path="./org.bukkit.material.MonsterEggs.d.ts" />
/// <reference path="./org.bukkit.material.Mushroom.d.ts" />
/// <reference path="./org.bukkit.material.NetherWarts.d.ts" />
/// <reference path="./org.bukkit.material.Observer.d.ts" />
/// <reference path="./org.bukkit.material.Openable.d.ts" />
/// <reference path="./org.bukkit.material.PistonBaseMaterial.d.ts" />
/// <reference path="./org.bukkit.material.PistonExtensionMaterial.d.ts" />
/// <reference path="./org.bukkit.material.PoweredRail.d.ts" />
/// <reference path="./org.bukkit.material.PressurePlate.d.ts" />
/// <reference path="./org.bukkit.material.PressureSensor.d.ts" />
/// <reference path="./org.bukkit.material.Pumpkin.d.ts" />
/// <reference path="./org.bukkit.material.Rails.d.ts" />
/// <reference path="./org.bukkit.material.Redstone.d.ts" />
/// <reference path="./org.bukkit.material.RedstoneTorch.d.ts" />
/// <reference path="./org.bukkit.material.RedstoneWire.d.ts" />
/// <reference path="./org.bukkit.material.Sandstone.d.ts" />
/// <reference path="./org.bukkit.material.Sapling.d.ts" />
/// <reference path="./org.bukkit.material.Sign.d.ts" />
/// <reference path="./org.bukkit.material.SimpleAttachableMaterialData.d.ts" />
/// <reference path="./org.bukkit.material.Skull.d.ts" />
/// <reference path="./org.bukkit.material.SmoothBrick.d.ts" />
/// <reference path="./org.bukkit.material.SpawnEgg.d.ts" />
/// <reference path="./org.bukkit.material.Stairs.d.ts" />
/// <reference path="./org.bukkit.material.Step.d.ts" />
/// <reference path="./org.bukkit.material.TexturedMaterial.d.ts" />
/// <reference path="./org.bukkit.material.Torch.d.ts" />
/// <reference path="./org.bukkit.material.TrapDoor.d.ts" />
/// <reference path="./org.bukkit.material.Tree.d.ts" />
/// <reference path="./org.bukkit.material.Tripwire.d.ts" />
/// <reference path="./org.bukkit.material.TripwireHook.d.ts" />
/// <reference path="./org.bukkit.material.Vine.d.ts" />
/// <reference path="./org.bukkit.material.Wood.d.ts" />
/// <reference path="./org.bukkit.material.WoodenStep.d.ts" />
/// <reference path="./org.bukkit.material.Wool.d.ts" />
/// <reference path="./org.bukkit.material.types.MushroomBlockTexture.d.ts" />
/// <reference path="./org.bukkit.metadata.FixedMetadataValue.d.ts" />
/// <reference path="./org.bukkit.metadata.LazyMetadataValue.CacheStrategy.d.ts" />
/// <reference path="./org.bukkit.metadata.LazyMetadataValue.d.ts" />
/// <reference path="./org.bukkit.metadata.MetadataConversionException.d.ts" />
/// <reference path="./org.bukkit.metadata.MetadataEvaluationException.d.ts" />
/// <reference path="./org.bukkit.metadata.MetadataStore.d.ts" />
/// <reference path="./org.bukkit.metadata.MetadataStoreBase.d.ts" />
/// <reference path="./org.bukkit.metadata.MetadataValue.d.ts" />
/// <reference path="./org.bukkit.metadata.MetadataValueAdapter.d.ts" />
/// <reference path="./org.bukkit.metadata.Metadatable.d.ts" />
/// <reference path="./org.bukkit.permissions.Permissible.d.ts" />
/// <reference path="./org.bukkit.permissions.PermissibleBase.d.ts" />
/// <reference path="./org.bukkit.permissions.Permission.d.ts" />
/// <reference path="./org.bukkit.permissions.PermissionAttachment.d.ts" />
/// <reference path="./org.bukkit.permissions.PermissionAttachmentInfo.d.ts" />
/// <reference path="./org.bukkit.permissions.PermissionDefault.d.ts" />
/// <reference path="./org.bukkit.permissions.PermissionRemovedExecutor.d.ts" />
/// <reference path="./org.bukkit.permissions.ServerOperator.d.ts" />
/// <reference path="./org.bukkit.persistence.PersistentDataAdapterContext.d.ts" />
/// <reference path="./org.bukkit.persistence.PersistentDataContainer.d.ts" />
/// <reference path="./org.bukkit.persistence.PersistentDataHolder.d.ts" />
/// <reference path="./org.bukkit.persistence.PersistentDataType.PrimitivePersistentDataType.d.ts" />
/// <reference path="./org.bukkit.persistence.PersistentDataType.d.ts" />
/// <reference path="./org.bukkit.plugin.AuthorNagException.d.ts" />
/// <reference path="./org.bukkit.plugin.EventExecutor.d.ts" />
/// <reference path="./org.bukkit.plugin.IllegalPluginAccessException.d.ts" />
/// <reference path="./org.bukkit.plugin.InvalidDescriptionException.d.ts" />
/// <reference path="./org.bukkit.plugin.InvalidPluginException.d.ts" />
/// <reference path="./org.bukkit.plugin.Plugin.d.ts" />
/// <reference path="./org.bukkit.plugin.PluginAwareness.Flags.d.ts" />
/// <reference path="./org.bukkit.plugin.PluginAwareness.d.ts" />
/// <reference path="./org.bukkit.plugin.PluginBase.d.ts" />
/// <reference path="./org.bukkit.plugin.PluginDescriptionFile.d.ts" />
/// <reference path="./org.bukkit.plugin.PluginLoadOrder.d.ts" />
/// <reference path="./org.bukkit.plugin.PluginLoader.d.ts" />
/// <reference path="./org.bukkit.plugin.PluginLogger.d.ts" />
/// <reference path="./org.bukkit.plugin.PluginManager.d.ts" />
/// <reference path="./org.bukkit.plugin.RegisteredListener.d.ts" />
/// <reference path="./org.bukkit.plugin.RegisteredServiceProvider.d.ts" />
/// <reference path="./org.bukkit.plugin.ServicePriority.d.ts" />
/// <reference path="./org.bukkit.plugin.ServicesManager.d.ts" />
/// <reference path="./org.bukkit.plugin.SimplePluginManager.d.ts" />
/// <reference path="./org.bukkit.plugin.SimpleServicesManager.d.ts" />
/// <reference path="./org.bukkit.plugin.TimedRegisteredListener.d.ts" />
/// <reference path="./org.bukkit.plugin.UnknownDependencyException.d.ts" />
/// <reference path="./org.bukkit.plugin.java.JavaPlugin.d.ts" />
/// <reference path="./org.bukkit.plugin.java.JavaPluginLoader.d.ts" />
/// <reference path="./org.bukkit.plugin.messaging.ChannelNameTooLongException.d.ts" />
/// <reference path="./org.bukkit.plugin.messaging.ChannelNotRegisteredException.d.ts" />
/// <reference path="./org.bukkit.plugin.messaging.MessageTooLargeException.d.ts" />
/// <reference path="./org.bukkit.plugin.messaging.Messenger.d.ts" />
/// <reference path="./org.bukkit.plugin.messaging.PluginChannelDirection.d.ts" />
/// <reference path="./org.bukkit.plugin.messaging.PluginMessageListener.d.ts" />
/// <reference path="./org.bukkit.plugin.messaging.PluginMessageListenerRegistration.d.ts" />
/// <reference path="./org.bukkit.plugin.messaging.PluginMessageRecipient.d.ts" />
/// <reference path="./org.bukkit.plugin.messaging.ReservedChannelException.d.ts" />
/// <reference path="./org.bukkit.plugin.messaging.StandardMessenger.d.ts" />
/// <reference path="./org.bukkit.potion.Potion.d.ts" />
/// <reference path="./org.bukkit.potion.PotionBrewer.d.ts" />
/// <reference path="./org.bukkit.potion.PotionData.d.ts" />
/// <reference path="./org.bukkit.potion.PotionEffect.d.ts" />
/// <reference path="./org.bukkit.potion.PotionEffectType.d.ts" />
/// <reference path="./org.bukkit.potion.PotionEffectTypeWrapper.d.ts" />
/// <reference path="./org.bukkit.potion.PotionType.d.ts" />
/// <reference path="./org.bukkit.projectiles.BlockProjectileSource.d.ts" />
/// <reference path="./org.bukkit.projectiles.ProjectileSource.d.ts" />
/// <reference path="./org.bukkit.scheduler.BukkitRunnable.d.ts" />
/// <reference path="./org.bukkit.scheduler.BukkitScheduler.d.ts" />
/// <reference path="./org.bukkit.scheduler.BukkitTask.d.ts" />
/// <reference path="./org.bukkit.scheduler.BukkitWorker.d.ts" />
/// <reference path="./org.bukkit.scoreboard.Criterias.d.ts" />
/// <reference path="./org.bukkit.scoreboard.DisplaySlot.d.ts" />
/// <reference path="./org.bukkit.scoreboard.NameTagVisibility.d.ts" />
/// <reference path="./org.bukkit.scoreboard.Objective.d.ts" />
/// <reference path="./org.bukkit.scoreboard.RenderType.d.ts" />
/// <reference path="./org.bukkit.scoreboard.Score.d.ts" />
/// <reference path="./org.bukkit.scoreboard.Scoreboard.d.ts" />
/// <reference path="./org.bukkit.scoreboard.ScoreboardManager.d.ts" />
/// <reference path="./org.bukkit.scoreboard.Team.Option.d.ts" />
/// <reference path="./org.bukkit.scoreboard.Team.OptionStatus.d.ts" />
/// <reference path="./org.bukkit.scoreboard.Team.d.ts" />
/// <reference path="./org.bukkit.util.BlockIterator.d.ts" />
/// <reference path="./org.bukkit.util.BlockVector.d.ts" />
/// <reference path="./org.bukkit.util.BoundingBox.d.ts" />
/// <reference path="./org.bukkit.util.CachedServerIcon.d.ts" />
/// <reference path="./org.bukkit.util.ChatPaginator.ChatPage.d.ts" />
/// <reference path="./org.bukkit.util.ChatPaginator.d.ts" />
/// <reference path="./org.bukkit.util.Consumer.d.ts" />
/// <reference path="./org.bukkit.util.EulerAngle.d.ts" />
/// <reference path="./org.bukkit.util.FileUtil.d.ts" />
/// <reference path="./org.bukkit.util.NumberConversions.d.ts" />
/// <reference path="./org.bukkit.util.RayTraceResult.d.ts" />
/// <reference path="./org.bukkit.util.StringUtil.d.ts" />
/// <reference path="./org.bukkit.util.Vector.d.ts" />
/// <reference path="./org.bukkit.util.io.BukkitObjectInputStream.d.ts" />
/// <reference path="./org.bukkit.util.io.BukkitObjectOutputStream.d.ts" />
/// <reference path="./org.bukkit.util.noise.NoiseGenerator.d.ts" />
/// <reference path="./org.bukkit.util.noise.OctaveGenerator.d.ts" />
/// <reference path="./org.bukkit.util.noise.PerlinNoiseGenerator.d.ts" />
/// <reference path="./org.bukkit.util.noise.PerlinOctaveGenerator.d.ts" />
/// <reference path="./org.bukkit.util.noise.SimplexNoiseGenerator.d.ts" />
/// <reference path="./org.bukkit.util.noise.SimplexOctaveGenerator.d.ts" />
/// <reference path="./org.bukkit.util.permissions.BroadcastPermissions.d.ts" />
/// <reference path="./org.bukkit.util.permissions.CommandPermissions.d.ts" />
/// <reference path="./org.bukkit.util.permissions.DefaultPermissions.d.ts" />

View File

@@ -0,0 +1,89 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class Achievement extends java.lang.Enum {
// @ts-ignore
public static OPEN_INVENTORY: org.bukkit.Achievement;
// @ts-ignore
public static MINE_WOOD: org.bukkit.Achievement;
// @ts-ignore
public static BUILD_WORKBENCH: org.bukkit.Achievement;
// @ts-ignore
public static BUILD_PICKAXE: org.bukkit.Achievement;
// @ts-ignore
public static BUILD_FURNACE: org.bukkit.Achievement;
// @ts-ignore
public static ACQUIRE_IRON: org.bukkit.Achievement;
// @ts-ignore
public static BUILD_HOE: org.bukkit.Achievement;
// @ts-ignore
public static MAKE_BREAD: org.bukkit.Achievement;
// @ts-ignore
public static BAKE_CAKE: org.bukkit.Achievement;
// @ts-ignore
public static BUILD_BETTER_PICKAXE: org.bukkit.Achievement;
// @ts-ignore
public static COOK_FISH: org.bukkit.Achievement;
// @ts-ignore
public static ON_A_RAIL: org.bukkit.Achievement;
// @ts-ignore
public static BUILD_SWORD: org.bukkit.Achievement;
// @ts-ignore
public static KILL_ENEMY: org.bukkit.Achievement;
// @ts-ignore
public static KILL_COW: org.bukkit.Achievement;
// @ts-ignore
public static FLY_PIG: org.bukkit.Achievement;
// @ts-ignore
public static SNIPE_SKELETON: org.bukkit.Achievement;
// @ts-ignore
public static GET_DIAMONDS: org.bukkit.Achievement;
// @ts-ignore
public static NETHER_PORTAL: org.bukkit.Achievement;
// @ts-ignore
public static GHAST_RETURN: org.bukkit.Achievement;
// @ts-ignore
public static GET_BLAZE_ROD: org.bukkit.Achievement;
// @ts-ignore
public static BREW_POTION: org.bukkit.Achievement;
// @ts-ignore
public static END_PORTAL: org.bukkit.Achievement;
// @ts-ignore
public static THE_END: org.bukkit.Achievement;
// @ts-ignore
public static ENCHANTMENTS: org.bukkit.Achievement;
// @ts-ignore
public static OVERKILL: org.bukkit.Achievement;
// @ts-ignore
public static BOOKCASE: org.bukkit.Achievement;
// @ts-ignore
public static EXPLORE_ALL_BIOMES: org.bukkit.Achievement;
// @ts-ignore
public static SPAWN_WITHER: org.bukkit.Achievement;
// @ts-ignore
public static KILL_WITHER: org.bukkit.Achievement;
// @ts-ignore
public static FULL_BEACON: org.bukkit.Achievement;
// @ts-ignore
public static BREED_COW: org.bukkit.Achievement;
// @ts-ignore
public static DIAMONDS_TO_YOU: org.bukkit.Achievement;
// @ts-ignore
public static OVERPOWERED: org.bukkit.Achievement;
// @ts-ignore
public static values(): org.bukkit.Achievement[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.Achievement;
/**
* Returns whether or not this achievement has a parent achievement.
*/
// @ts-ignore
public hasParent(): boolean;
/**
* Returns the parent achievement of this achievement, or null if none.
*/
// @ts-ignore
public getParent(): org.bukkit.Achievement;
}
}
}

View File

@@ -0,0 +1,92 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class Art extends java.lang.Enum implements org.bukkit.Keyed {
// @ts-ignore
public static KEBAB: org.bukkit.Art;
// @ts-ignore
public static AZTEC: org.bukkit.Art;
// @ts-ignore
public static ALBAN: org.bukkit.Art;
// @ts-ignore
public static AZTEC2: org.bukkit.Art;
// @ts-ignore
public static BOMB: org.bukkit.Art;
// @ts-ignore
public static PLANT: org.bukkit.Art;
// @ts-ignore
public static WASTELAND: org.bukkit.Art;
// @ts-ignore
public static POOL: org.bukkit.Art;
// @ts-ignore
public static COURBET: org.bukkit.Art;
// @ts-ignore
public static SEA: org.bukkit.Art;
// @ts-ignore
public static SUNSET: org.bukkit.Art;
// @ts-ignore
public static CREEBET: org.bukkit.Art;
// @ts-ignore
public static WANDERER: org.bukkit.Art;
// @ts-ignore
public static GRAHAM: org.bukkit.Art;
// @ts-ignore
public static MATCH: org.bukkit.Art;
// @ts-ignore
public static BUST: org.bukkit.Art;
// @ts-ignore
public static STAGE: org.bukkit.Art;
// @ts-ignore
public static VOID: org.bukkit.Art;
// @ts-ignore
public static SKULL_AND_ROSES: org.bukkit.Art;
// @ts-ignore
public static WITHER: org.bukkit.Art;
// @ts-ignore
public static FIGHTERS: org.bukkit.Art;
// @ts-ignore
public static POINTER: org.bukkit.Art;
// @ts-ignore
public static PIGSCENE: org.bukkit.Art;
// @ts-ignore
public static BURNING_SKULL: org.bukkit.Art;
// @ts-ignore
public static SKELETON: org.bukkit.Art;
// @ts-ignore
public static DONKEY_KONG: org.bukkit.Art;
// @ts-ignore
public static values(): org.bukkit.Art[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.Art;
/**
* Gets the width of the painting, in blocks
*/
// @ts-ignore
public getBlockWidth(): number;
/**
* Gets the height of the painting, in blocks
*/
// @ts-ignore
public getBlockHeight(): number;
/**
* Get the ID of this painting.
*/
// @ts-ignore
public getId(): number;
// @ts-ignore
public getKey(): org.bukkit.NamespacedKey;
/**
* Get a painting by its numeric ID
*/
// @ts-ignore
public static getById(id: number): org.bukkit.Art;
/**
* Get a painting by its unique name
* <p>
* This ignores underscores and capitalization
*/
// @ts-ignore
public static getByName(name: string): org.bukkit.Art;
}
}
}

View File

@@ -0,0 +1,17 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class Axis extends java.lang.Enum {
// @ts-ignore
public static X: org.bukkit.Axis;
// @ts-ignore
public static Y: org.bukkit.Axis;
// @ts-ignore
public static Z: org.bukkit.Axis;
// @ts-ignore
public static values(): org.bukkit.Axis[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.Axis;
}
}
}

View File

@@ -0,0 +1,68 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
interface BanEntry {
/**
* Gets the target involved. This may be in the form of an IP or a player
* name.
*/
// @ts-ignore
getTarget(): string;
/**
* Gets the date this ban entry was created.
*/
// @ts-ignore
getCreated(): java.util.Date;
/**
* Sets the date this ban entry was created.
*/
// @ts-ignore
setCreated(created: java.util.Date): void;
/**
* Gets the source of this ban.
* <p>
* Note: A source is considered any String, although this is generally a
* player name.
*/
// @ts-ignore
getSource(): string;
/**
* Sets the source of this ban.
* <p>
* Note: A source is considered any String, although this is generally a
* player name.
*/
// @ts-ignore
setSource(source: string): void;
/**
* Gets the date this ban expires on, or null for no defined end date.
*/
// @ts-ignore
getExpiration(): java.util.Date;
/**
* Sets the date this ban expires on. Null values are considered
* "infinite" bans.
*/
// @ts-ignore
setExpiration(expiration: java.util.Date): void;
/**
* Gets the reason for this ban.
*/
// @ts-ignore
getReason(): string;
/**
* Sets the reason for this ban. Reasons must not be null.
*/
// @ts-ignore
setReason(reason: string): void;
/**
* Saves the ban entry, overwriting any previous data in the ban list.
* <p>
* Saving the ban entry of an unbanned player will cause the player to be
* banned once again.
*/
// @ts-ignore
save(): void;
}
}
}

View File

@@ -0,0 +1,17 @@
declare namespace org {
namespace bukkit {
namespace BanList {
// @ts-ignore
class Type extends java.lang.Enum {
// @ts-ignore
public static NAME: org.bukkit.BanList.Type;
// @ts-ignore
public static IP: org.bukkit.BanList.Type;
// @ts-ignore
public static values(): org.bukkit.BanList.Type[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.BanList.Type;
}
}
}
}

View File

@@ -0,0 +1,35 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
interface BanList {
/**
* Gets a {@link BanEntry} by target.
*/
// @ts-ignore
getBanEntry(target: string): org.bukkit.BanEntry;
/**
* Adds a ban to the this list. If a previous ban exists, this will
* update the previous entry.
*/
// @ts-ignore
addBan(target: string, reason: string, expires: java.util.Date, source: string): org.bukkit.BanEntry;
/**
* Gets a set containing every {@link BanEntry} in this list.
*/
// @ts-ignore
getBanEntries(): java.util.Set;
/**
* Gets if a {@link BanEntry} exists for the target, indicating an active
* ban status.
*/
// @ts-ignore
isBanned(target: string): boolean;
/**
* Removes the specified target from this list, therefore indicating a
* "not banned" status.
*/
// @ts-ignore
pardon(target: string): void;
}
}
}

View File

@@ -0,0 +1,27 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
interface BlockChangeDelegate {
/**
* Set a block data at the specified coordinates.
*/
// @ts-ignore
setBlockData(x: number, y: number, z: number, blockData: org.bukkit.block.data.BlockData): boolean;
/**
* Get the block data at the location.
*/
// @ts-ignore
getBlockData(x: number, y: number, z: number): org.bukkit.block.data.BlockData;
/**
* Gets the height of the world.
*/
// @ts-ignore
getHeight(): number;
/**
* Checks if the specified block is empty (air) or not.
*/
// @ts-ignore
isEmpty(x: number, y: number, z: number): boolean;
}
}
}

View File

@@ -0,0 +1,771 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class Bukkit extends java.lang.Object {
/**
* Gets the current {@link Server} singleton
*/
// @ts-ignore
public static getServer(): org.bukkit.Server;
/**
* Attempts to set the {@link Server} singleton.
* <p>
* This cannot be done if the Server is already set.
*/
// @ts-ignore
public static setServer(server: org.bukkit.Server): void;
/**
* Gets the name of this server implementation.
*/
// @ts-ignore
public static getName(): string;
/**
* Gets the version string of this server implementation.
*/
// @ts-ignore
public static getVersion(): string;
/**
* Gets the Bukkit version that this server is running.
*/
// @ts-ignore
public static getBukkitVersion(): string;
/**
* Gets a view of all currently logged in players. This {@linkplain
* Collections#unmodifiableCollection(Collection) view} is a reused
* object, making some operations like {@link Collection#size()}
* zero-allocation.
* <p>
* The collection is a view backed by the internal representation, such
* that, changes to the internal state of the server will be reflected
* immediately. However, the reuse of the returned collection (identity)
* is not strictly guaranteed for future or all implementations. Casting
* the collection, or relying on interface implementations (like {@link
* Serializable} or {@link List}), is deprecated.
* <p>
* Iteration behavior is undefined outside of self-contained main-thread
* uses. Normal and immediate iterator use without consequences that
* affect the collection are fully supported. The effects following
* (non-exhaustive) {@link Entity#teleport(Location) teleportation},
* {@link Player#setHealth(double) death}, and {@link Player#kickPlayer(
* String) kicking} are undefined. Any use of this collection from
* asynchronous threads is unsafe.
* <p>
* For safe consequential iteration or mimicking the old array behavior,
* using {@link Collection#toArray(Object[])} is recommended. For making
* snapshots, {@link ImmutableList#copyOf(Collection)} is recommended.
*/
// @ts-ignore
public static getOnlinePlayers(): java.util.Collection;
/**
* Get the maximum amount of players which can login to this server.
*/
// @ts-ignore
public static getMaxPlayers(): number;
/**
* Get the game port that the server runs on.
*/
// @ts-ignore
public static getPort(): number;
/**
* Get the view distance from this server.
*/
// @ts-ignore
public static getViewDistance(): number;
/**
* Get the IP that this server is bound to, or empty string if not
* specified.
*/
// @ts-ignore
public static getIp(): string;
/**
* Get world type (level-type setting) for default world.
*/
// @ts-ignore
public static getWorldType(): string;
/**
* Get generate-structures setting.
*/
// @ts-ignore
public static getGenerateStructures(): boolean;
/**
* Gets whether this server allows the End or not.
*/
// @ts-ignore
public static getAllowEnd(): boolean;
/**
* Gets whether this server allows the Nether or not.
*/
// @ts-ignore
public static getAllowNether(): boolean;
/**
* Gets whether this server has a whitelist or not.
*/
// @ts-ignore
public static hasWhitelist(): boolean;
/**
* Sets if the server is whitelisted.
*/
// @ts-ignore
public static setWhitelist(value: boolean): void;
/**
* Gets a list of whitelisted players.
*/
// @ts-ignore
public static getWhitelistedPlayers(): java.util.Set;
/**
* Reloads the whitelist from disk.
*/
// @ts-ignore
public static reloadWhitelist(): void;
/**
* Broadcast a message to all players.
* <p>
* This is the same as calling {@link #broadcast(java.lang.String,
* java.lang.String)} to {@link Server#BROADCAST_CHANNEL_USERS}
*/
// @ts-ignore
public static broadcastMessage(message: string): number;
/**
* Gets the name of the update folder. The update folder is used to safely
* update plugins at the right moment on a plugin load.
* <p>
* The update folder name is relative to the plugins folder.
*/
// @ts-ignore
public static getUpdateFolder(): string;
/**
* Gets the update folder. The update folder is used to safely update
* plugins at the right moment on a plugin load.
*/
// @ts-ignore
public static getUpdateFolderFile(): java.io.File;
/**
* Gets the value of the connection throttle setting.
*/
// @ts-ignore
public static getConnectionThrottle(): number;
/**
* Gets default ticks per animal spawns value.
* <p>
* <b>Example Usage:</b>
* <ul>
* <li>A value of 1 will mean the server will attempt to spawn monsters
* every tick.
* <li>A value of 400 will mean the server will attempt to spawn monsters
* every 400th tick.
* <li>A value below 0 will be reset back to Minecraft's default.
* </ul>
* <p>
* <b>Note:</b> If set to 0, animal spawning will be disabled. We
* recommend using spawn-animals to control this instead.
* <p>
* Minecraft default: 400.
*/
// @ts-ignore
public static getTicksPerAnimalSpawns(): number;
/**
* Gets the default ticks per monster spawns value.
* <p>
* <b>Example Usage:</b>
* <ul>
* <li>A value of 1 will mean the server will attempt to spawn monsters
* every tick.
* <li>A value of 400 will mean the server will attempt to spawn monsters
* every 400th tick.
* <li>A value below 0 will be reset back to Minecraft's default.
* </ul>
* <p>
* <b>Note:</b> If set to 0, monsters spawning will be disabled. We
* recommend using spawn-monsters to control this instead.
* <p>
* Minecraft default: 1.
*/
// @ts-ignore
public static getTicksPerMonsterSpawns(): number;
/**
* Gets a player object by the given username.
* <p>
* This method may not return objects for offline players.
*/
// @ts-ignore
public static getPlayer(name: string): org.bukkit.entity.Player;
/**
* Gets the player with the exact given name, case insensitive.
*/
// @ts-ignore
public static getPlayerExact(name: string): org.bukkit.entity.Player;
/**
* Attempts to match any players with the given name, and returns a list
* of all possibly matches.
* <p>
* This list is not sorted in any particular order. If an exact match is
* found, the returned list will only contain a single result.
*/
// @ts-ignore
public static matchPlayer(name: string): java.util.List;
/**
* Gets the player with the given UUID.
*/
// @ts-ignore
public static getPlayer(id: java.util.UUID): org.bukkit.entity.Player;
/**
* Gets the plugin manager for interfacing with plugins.
*/
// @ts-ignore
public static getPluginManager(): org.bukkit.plugin.PluginManager;
/**
* Gets the scheduler for managing scheduled events.
*/
// @ts-ignore
public static getScheduler(): org.bukkit.scheduler.BukkitScheduler;
/**
* Gets a services manager.
*/
// @ts-ignore
public static getServicesManager(): org.bukkit.plugin.ServicesManager;
/**
* Gets a list of all worlds on this server.
*/
// @ts-ignore
public static getWorlds(): java.util.List;
/**
* Creates or loads a world with the given name using the specified
* options.
* <p>
* If the world is already loaded, it will just return the equivalent of
* getWorld(creator.name()).
*/
// @ts-ignore
public static createWorld(creator: org.bukkit.WorldCreator): org.bukkit.World;
/**
* Unloads a world with the given name.
*/
// @ts-ignore
public static unloadWorld(name: string, save: boolean): boolean;
/**
* Unloads the given world.
*/
// @ts-ignore
public static unloadWorld(world: org.bukkit.World, save: boolean): boolean;
/**
* Gets the world with the given name.
*/
// @ts-ignore
public static getWorld(name: string): org.bukkit.World;
/**
* Gets the world from the given Unique ID.
*/
// @ts-ignore
public static getWorld(uid: java.util.UUID): org.bukkit.World;
/**
* Gets the map from the given item ID.
*/
// @ts-ignore
public static getMap(id: number): org.bukkit.map.MapView;
/**
* Create a new map with an automatically assigned ID.
*/
// @ts-ignore
public static createMap(world: org.bukkit.World): org.bukkit.map.MapView;
/**
* Create a new explorer map targeting the closest nearby structure of a
* given {@link StructureType}.
* <br>
* This method uses implementation default values for radius and
* findUnexplored (usually 100, true).
*/
// @ts-ignore
public static createExplorerMap(world: org.bukkit.World, location: org.bukkit.Location, structureType: org.bukkit.StructureType): org.bukkit.inventory.ItemStack;
/**
* Create a new explorer map targeting the closest nearby structure of a
* given {@link StructureType}.
* <br>
* This method uses implementation default values for radius and
* findUnexplored (usually 100, true).
*/
// @ts-ignore
public static createExplorerMap(world: org.bukkit.World, location: org.bukkit.Location, structureType: org.bukkit.StructureType, radius: number, findUnexplored: boolean): org.bukkit.inventory.ItemStack;
/**
* Reloads the server, refreshing settings and plugin information.
*/
// @ts-ignore
public static reload(): void;
/**
* Reload only the Minecraft data for the server. This includes custom
* advancements and loot tables.
*/
// @ts-ignore
public static reloadData(): void;
/**
* Returns the primary logger associated with this server instance.
*/
// @ts-ignore
public static getLogger(): java.util.logging.Logger;
/**
* Gets a {@link PluginCommand} with the given name or alias.
*/
// @ts-ignore
public static getPluginCommand(name: string): org.bukkit.command.PluginCommand;
/**
* Writes loaded players to disk.
*/
// @ts-ignore
public static savePlayers(): void;
/**
* Dispatches a command on this server, and executes it if found.
*/
// @ts-ignore
public static dispatchCommand(sender: org.bukkit.command.CommandSender, commandLine: string): boolean;
/**
* Adds a recipe to the crafting manager.
*/
// @ts-ignore
public static addRecipe(recipe: org.bukkit.inventory.Recipe): boolean;
/**
* Get a list of all recipes for a given item. The stack size is ignored
* in comparisons. If the durability is -1, it will match any data value.
*/
// @ts-ignore
public static getRecipesFor(result: org.bukkit.inventory.ItemStack): java.util.List;
/**
* Get an iterator through the list of crafting recipes.
*/
// @ts-ignore
public static recipeIterator(): java.util.Iterator;
/**
* Clears the list of crafting recipes.
*/
// @ts-ignore
public static clearRecipes(): void;
/**
* Resets the list of crafting recipes to the default.
*/
// @ts-ignore
public static resetRecipes(): void;
/**
* Gets a list of command aliases defined in the server properties.
*/
// @ts-ignore
public static getCommandAliases(): java.util.Map;
/**
* Gets the radius, in blocks, around each worlds spawn point to protect.
*/
// @ts-ignore
public static getSpawnRadius(): number;
/**
* Sets the radius, in blocks, around each worlds spawn point to protect.
*/
// @ts-ignore
public static setSpawnRadius(value: number): void;
/**
* Gets whether the Server is in online mode or not.
*/
// @ts-ignore
public static getOnlineMode(): boolean;
/**
* Gets whether this server allows flying or not.
*/
// @ts-ignore
public static getAllowFlight(): boolean;
/**
* Gets whether the server is in hardcore mode or not.
*/
// @ts-ignore
public static isHardcore(): boolean;
/**
* Shutdowns the server, stopping everything.
*/
// @ts-ignore
public static shutdown(): void;
/**
* Broadcasts the specified message to every user with the given
* permission name.
*/
// @ts-ignore
public static broadcast(message: string, permission: string): number;
/**
* Gets the player by the given name, regardless if they are offline or
* online.
* <p>
* This method may involve a blocking web request to get the UUID for the
* given name.
* <p>
* This will return an object even if the player does not exist. To this
* method, all players will exist.
*/
// @ts-ignore
public static getOfflinePlayer(name: string): org.bukkit.OfflinePlayer;
/**
* Gets the player by the given UUID, regardless if they are offline or
* online.
* <p>
* This will return an object even if the player does not exist. To this
* method, all players will exist.
*/
// @ts-ignore
public static getOfflinePlayer(id: java.util.UUID): org.bukkit.OfflinePlayer;
/**
* Gets a set containing all current IPs that are banned.
*/
// @ts-ignore
public static getIPBans(): java.util.Set;
/**
* Bans the specified address from the server.
*/
// @ts-ignore
public static banIP(address: string): void;
/**
* Unbans the specified address from the server.
*/
// @ts-ignore
public static unbanIP(address: string): void;
/**
* Gets a set containing all banned players.
*/
// @ts-ignore
public static getBannedPlayers(): java.util.Set;
/**
* Gets a ban list for the supplied type.
* <p>
* Bans by name are no longer supported and this method will return
* null when trying to request them. The replacement is bans by UUID.
*/
// @ts-ignore
public static getBanList(type: org.bukkit.BanList.Type): org.bukkit.BanList;
/**
* Gets a set containing all player operators.
*/
// @ts-ignore
public static getOperators(): java.util.Set;
/**
* Gets the default {@link GameMode} for new players.
*/
// @ts-ignore
public static getDefaultGameMode(): org.bukkit.GameMode;
/**
* Sets the default {@link GameMode} for new players.
*/
// @ts-ignore
public static setDefaultGameMode(mode: org.bukkit.GameMode): void;
/**
* Gets a {@link ConsoleCommandSender} that may be used as an input source
* for this server.
*/
// @ts-ignore
public static getConsoleSender(): org.bukkit.command.ConsoleCommandSender;
/**
* Gets the folder that contains all of the various {@link World}s.
*/
// @ts-ignore
public static getWorldContainer(): java.io.File;
/**
* Gets every player that has ever played on this server.
*/
// @ts-ignore
public static getOfflinePlayers(): org.bukkit.OfflinePlayer[];
/**
* Gets the {@link Messenger} responsible for this server.
*/
// @ts-ignore
public static getMessenger(): org.bukkit.plugin.messaging.Messenger;
/**
* Gets the {@link HelpMap} providing help topics for this server.
*/
// @ts-ignore
public static getHelpMap(): org.bukkit.help.HelpMap;
/**
* Creates an empty inventory with the specified type. If the type
* is {@link InventoryType#CHEST}, the new inventory has a size of 27;
* otherwise the new inventory has the normal size for its type.
* <br>
* {@link InventoryType#WORKBENCH} will not process crafting recipes if
* created with this method. Use
* {@link Player#openWorkbench(Location, boolean)} instead.
* <br>
* {@link InventoryType#ENCHANTING} will not process {@link ItemStack}s
* for possible enchanting results. Use
* {@link Player#openEnchanting(Location, boolean)} instead.
*/
// @ts-ignore
public static createInventory(owner: org.bukkit.inventory.InventoryHolder, type: org.bukkit.event.inventory.InventoryType): org.bukkit.inventory.Inventory;
/**
* Creates an empty inventory with the specified type and title. If the type
* is {@link InventoryType#CHEST}, the new inventory has a size of 27;
* otherwise the new inventory has the normal size for its type.<br>
* It should be noted that some inventory types do not support titles and
* may not render with said titles on the Minecraft client.
* <br>
* {@link InventoryType#WORKBENCH} will not process crafting recipes if
* created with this method. Use
* {@link Player#openWorkbench(Location, boolean)} instead.
* <br>
* {@link InventoryType#ENCHANTING} will not process {@link ItemStack}s
* for possible enchanting results. Use
* {@link Player#openEnchanting(Location, boolean)} instead.
*/
// @ts-ignore
public static createInventory(owner: org.bukkit.inventory.InventoryHolder, type: org.bukkit.event.inventory.InventoryType, title: string): org.bukkit.inventory.Inventory;
/**
* Creates an empty inventory of type {@link InventoryType#CHEST} with the
* specified size.
*/
// @ts-ignore
public static createInventory(owner: org.bukkit.inventory.InventoryHolder, size: number): org.bukkit.inventory.Inventory;
/**
* Creates an empty inventory of type {@link InventoryType#CHEST} with the
* specified size and title.
*/
// @ts-ignore
public static createInventory(owner: org.bukkit.inventory.InventoryHolder, size: number, title: string): org.bukkit.inventory.Inventory;
/**
* Creates an empty merchant.
*/
// @ts-ignore
public static createMerchant(title: string): org.bukkit.inventory.Merchant;
/**
* Gets user-specified limit for number of monsters that can spawn in a
* chunk.
*/
// @ts-ignore
public static getMonsterSpawnLimit(): number;
/**
* Gets user-specified limit for number of animals that can spawn in a
* chunk.
*/
// @ts-ignore
public static getAnimalSpawnLimit(): number;
/**
* Gets user-specified limit for number of water animals that can spawn in
* a chunk.
*/
// @ts-ignore
public static getWaterAnimalSpawnLimit(): number;
/**
* Gets user-specified limit for number of ambient mobs that can spawn in
* a chunk.
*/
// @ts-ignore
public static getAmbientSpawnLimit(): number;
/**
* Checks the current thread against the expected primary thread for the
* server.
* <p>
* <b>Note:</b> this method should not be used to indicate the current
* synchronized state of the runtime. A current thread matching the main
* thread indicates that it is synchronized, but a mismatch <b>does not
* preclude</b> the same assumption.
*/
// @ts-ignore
public static isPrimaryThread(): boolean;
/**
* Gets the message that is displayed on the server list.
*/
// @ts-ignore
public static getMotd(): string;
/**
* Gets the default message that is displayed when the server is stopped.
*/
// @ts-ignore
public static getShutdownMessage(): string;
/**
* Gets the current warning state for the server.
*/
// @ts-ignore
public static getWarningState(): org.bukkit.Warning.WarningState;
/**
* Gets the instance of the item factory (for {@link ItemMeta}).
*/
// @ts-ignore
public static getItemFactory(): org.bukkit.inventory.ItemFactory;
/**
* Gets the instance of the scoreboard manager.
* <p>
* This will only exist after the first world has loaded.
*/
// @ts-ignore
public static getScoreboardManager(): org.bukkit.scoreboard.ScoreboardManager;
/**
* Gets an instance of the server's default server-icon.
*/
// @ts-ignore
public static getServerIcon(): org.bukkit.util.CachedServerIcon;
/**
* Loads an image from a file, and returns a cached image for the specific
* server-icon.
* <p>
* Size and type are implementation defined. An incompatible file is
* guaranteed to throw an implementation-defined {@link Exception}.
*/
// @ts-ignore
public static loadServerIcon(file: java.io.File): org.bukkit.util.CachedServerIcon;
/**
* Creates a cached server-icon for the specific image.
* <p>
* Size and type are implementation defined. An incompatible file is
* guaranteed to throw an implementation-defined {@link Exception}.
*/
// @ts-ignore
public static loadServerIcon(image: java.awt.image.BufferedImage): org.bukkit.util.CachedServerIcon;
/**
* Set the idle kick timeout. Any players idle for the specified amount of
* time will be automatically kicked.
* <p>
* A value of 0 will disable the idle kick timeout.
*/
// @ts-ignore
public static setIdleTimeout(threshold: number): void;
/**
* Gets the idle kick timeout.
*/
// @ts-ignore
public static getIdleTimeout(): number;
/**
* Create a ChunkData for use in a generator.
* See {@link ChunkGenerator#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}
*/
// @ts-ignore
public static createChunkData(world: org.bukkit.World): org.bukkit.generator.ChunkGenerator.ChunkData;
/**
* Creates a boss bar instance to display to players. The progress
* defaults to 1.0
*/
// @ts-ignore
public static createBossBar(title: string, color: org.bukkit.boss.BarColor, style: org.bukkit.boss.BarStyle, flags: org.bukkit.boss.BarFlag): org.bukkit.boss.BossBar;
/**
* Creates a boss bar instance to display to players. The progress defaults
* to 1.0.
* <br>
* This instance is added to the persistent storage of the server and will
* be editable by commands and restored after restart.
*/
// @ts-ignore
public static createBossBar(key: org.bukkit.NamespacedKey, title: string, color: org.bukkit.boss.BarColor, style: org.bukkit.boss.BarStyle, flags: org.bukkit.boss.BarFlag): org.bukkit.boss.KeyedBossBar;
/**
* Gets an unmodifiable iterator through all persistent bossbars.
* <ul>
* <li><b>not</b> bound to a {@link org.bukkit.entity.Boss}</li>
* <li>
* <b>not</b> created using
* {@link #createBossBar(String, BarColor, BarStyle, BarFlag...)}
* </li>
* </ul>
* e.g. bossbars created using the bossbar command
*/
// @ts-ignore
public static getBossBars(): java.util.Iterator;
/**
* Gets the {@link KeyedBossBar} specified by this key.
* <ul>
* <li><b>not</b> bound to a {@link org.bukkit.entity.Boss}</li>
* <li>
* <b>not</b> created using
* {@link #createBossBar(String, BarColor, BarStyle, BarFlag...)}
* </li>
* </ul>
* e.g. bossbars created using the bossbar command
*/
// @ts-ignore
public static getBossBar(key: org.bukkit.NamespacedKey): org.bukkit.boss.KeyedBossBar;
/**
* Removes a {@link KeyedBossBar} specified by this key.
* <ul>
* <li><b>not</b> bound to a {@link org.bukkit.entity.Boss}</li>
* <li>
* <b>not</b> created using
* {@link #createBossBar(String, BarColor, BarStyle, BarFlag...)}
* </li>
* </ul>
* e.g. bossbars created using the bossbar command
*/
// @ts-ignore
public static removeBossBar(key: org.bukkit.NamespacedKey): boolean;
/**
* Gets an entity on the server by its UUID
*/
// @ts-ignore
public static getEntity(uuid: java.util.UUID): org.bukkit.entity.Entity;
/**
* Get the advancement specified by this key.
*/
// @ts-ignore
public static getAdvancement(key: org.bukkit.NamespacedKey): org.bukkit.advancement.Advancement;
/**
* Get an iterator through all advancements. Advancements cannot be removed
* from this iterator,
*/
// @ts-ignore
public static advancementIterator(): java.util.Iterator;
/**
* Creates a new {@link BlockData} instance for the specified Material, with
* all properties initialized to unspecified defaults.
*/
// @ts-ignore
public static createBlockData(material: org.bukkit.Material): org.bukkit.block.data.BlockData;
/**
* Creates a new {@link BlockData} instance for the specified Material, with
* all properties initialized to unspecified defaults.
*/
// @ts-ignore
public static createBlockData(material: org.bukkit.Material, consumer: java.util.function$.Consumer): org.bukkit.block.data.BlockData;
/**
* Creates a new {@link BlockData} instance with material and properties
* parsed from provided data.
*/
// @ts-ignore
public static createBlockData(data: string): org.bukkit.block.data.BlockData;
/**
* Creates a new {@link BlockData} instance for the specified Material, with
* all properties initialized to unspecified defaults, except for those
* provided in data.
*/
// @ts-ignore
public static createBlockData(material: org.bukkit.Material, data: string): org.bukkit.block.data.BlockData;
/**
* Gets a tag which has already been defined within the server. Plugins are
* suggested to use the concrete tags in {@link Tag} rather than this method
* which makes no guarantees about which tags are available, and may also be
* less performant due to lack of caching.
* <br>
* Tags will be searched for in an implementation specific manner, but a
* path consisting of namespace/tags/registry/key is expected.
* <br>
* Server implementations are allowed to handle only the registries
* indicated in {@link Tag}.
*/
// @ts-ignore
public static getTag(registry: string, tag: org.bukkit.NamespacedKey, clazz: java.lang.Class): org.bukkit.Tag;
/**
* Gets a all tags which have been defined within the server.
* <br>
* Server implementations are allowed to handle only the registries
* indicated in {@link Tag}.
* <br>
* No guarantees are made about the mutability of the returned iterator.
*/
// @ts-ignore
public static getTags(registry: string, clazz: java.lang.Class): java.lang.Iterable;
/**
* Gets the specified {@link LootTable}.
*/
// @ts-ignore
public static getLootTable(key: org.bukkit.NamespacedKey): org.bukkit.loot.LootTable;
/**
* Selects entities using the given Vanilla selector.
* <br>
* No guarantees are made about the selector format, other than they match
* the Vanilla format for the active Minecraft version.
* <br>
* Usually a selector will start with '@', unless selecting a Player in
* which case it may simply be the Player's name or UUID.
* <br>
* Note that in Vanilla, elevated permissions are usually required to use
* '@' selectors, but this method should not check such permissions from the
* sender.
*/
// @ts-ignore
public static selectEntities(sender: org.bukkit.command.CommandSender, selector: string): java.util.List;
// @ts-ignore
public static getUnsafe(): org.bukkit.UnsafeValues;
}
}
}

View File

@@ -0,0 +1,102 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class ChatColor extends java.lang.Enum {
// @ts-ignore
public static BLACK: org.bukkit.ChatColor;
// @ts-ignore
public static DARK_BLUE: org.bukkit.ChatColor;
// @ts-ignore
public static DARK_GREEN: org.bukkit.ChatColor;
// @ts-ignore
public static DARK_AQUA: org.bukkit.ChatColor;
// @ts-ignore
public static DARK_RED: org.bukkit.ChatColor;
// @ts-ignore
public static DARK_PURPLE: org.bukkit.ChatColor;
// @ts-ignore
public static GOLD: org.bukkit.ChatColor;
// @ts-ignore
public static GRAY: org.bukkit.ChatColor;
// @ts-ignore
public static DARK_GRAY: org.bukkit.ChatColor;
// @ts-ignore
public static BLUE: org.bukkit.ChatColor;
// @ts-ignore
public static GREEN: org.bukkit.ChatColor;
// @ts-ignore
public static AQUA: org.bukkit.ChatColor;
// @ts-ignore
public static RED: org.bukkit.ChatColor;
// @ts-ignore
public static LIGHT_PURPLE: org.bukkit.ChatColor;
// @ts-ignore
public static YELLOW: org.bukkit.ChatColor;
// @ts-ignore
public static WHITE: org.bukkit.ChatColor;
// @ts-ignore
public static MAGIC: org.bukkit.ChatColor;
// @ts-ignore
public static BOLD: org.bukkit.ChatColor;
// @ts-ignore
public static STRIKETHROUGH: org.bukkit.ChatColor;
// @ts-ignore
public static UNDERLINE: org.bukkit.ChatColor;
// @ts-ignore
public static ITALIC: org.bukkit.ChatColor;
// @ts-ignore
public static RESET: org.bukkit.ChatColor;
// @ts-ignore
public static COLOR_CHAR: string;
// @ts-ignore
public static values(): org.bukkit.ChatColor[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.ChatColor;
/**
* Gets the char value associated with this color
*/
// @ts-ignore
public getChar(): string;
// @ts-ignore
public toString(): string;
/**
* Checks if this code is a format code as opposed to a color code.
*/
// @ts-ignore
public isFormat(): boolean;
/**
* Checks if this code is a color code as opposed to a format code.
*/
// @ts-ignore
public isColor(): boolean;
/**
* Gets the color represented by the specified color code
*/
// @ts-ignore
public static getByChar(code: string): org.bukkit.ChatColor;
/**
* Gets the color represented by the specified color code
*/
// @ts-ignore
public static getByChar(code: string): org.bukkit.ChatColor;
/**
* Strips the given message of all color codes
*/
// @ts-ignore
public static stripColor(input: string): string;
/**
* Translates a string using an alternate color code character into a
* string that uses the internal ChatColor.COLOR_CODE color code
* character. The alternate color code character will only be replaced if
* it is immediately followed by 0-9, A-F, a-f, K-O, k-o, R or r.
*/
// @ts-ignore
public static translateAlternateColorCodes(altColorChar: string, textToTranslate: string): string;
/**
* Gets the ChatColors used at the end of the given input string.
*/
// @ts-ignore
public static getLastColors(input: string): string;
}
}
}

View File

@@ -0,0 +1,126 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
interface Chunk {
/**
* Gets the X-coordinate of this chunk
*/
// @ts-ignore
getX(): number;
/**
* Gets the Z-coordinate of this chunk
*/
// @ts-ignore
getZ(): number;
/**
* Gets the world containing this chunk
*/
// @ts-ignore
getWorld(): org.bukkit.World;
/**
* Gets a block from this chunk
*/
// @ts-ignore
getBlock(x: number, y: number, z: number): org.bukkit.block.Block;
/**
* Capture thread-safe read-only snapshot of chunk data
*/
// @ts-ignore
getChunkSnapshot(): org.bukkit.ChunkSnapshot;
/**
* Capture thread-safe read-only snapshot of chunk data
*/
// @ts-ignore
getChunkSnapshot(includeMaxblocky: boolean, includeBiome: boolean, includeBiomeTempRain: boolean): org.bukkit.ChunkSnapshot;
/**
* Get a list of all entities in the chunk.
*/
// @ts-ignore
getEntities(): org.bukkit.entity.Entity[];
/**
* Get a list of all tile entities in the chunk.
*/
// @ts-ignore
getTileEntities(): org.bukkit.block.BlockState[];
/**
* Checks if the chunk is loaded.
*/
// @ts-ignore
isLoaded(): boolean;
/**
* Loads the chunk.
*/
// @ts-ignore
load(generate: boolean): boolean;
/**
* Loads the chunk.
*/
// @ts-ignore
load(): boolean;
/**
* Unloads and optionally saves the Chunk
*/
// @ts-ignore
unload(save: boolean): boolean;
/**
* Unloads and optionally saves the Chunk
*/
// @ts-ignore
unload(): boolean;
/**
* Checks if this chunk can spawn slimes without being a swamp biome.
*/
// @ts-ignore
isSlimeChunk(): boolean;
/**
* Gets whether the chunk at the specified chunk coordinates is force
* loaded.
* <p>
* A force loaded chunk will not be unloaded due to lack of player activity.
*/
// @ts-ignore
isForceLoaded(): boolean;
/**
* Sets whether the chunk at the specified chunk coordinates is force
* loaded.
* <p>
* A force loaded chunk will not be unloaded due to lack of player activity.
*/
// @ts-ignore
setForceLoaded(forced: boolean): void;
/**
* Adds a plugin ticket for this chunk, loading this chunk if it is not
* already loaded.
* <p>
* A plugin ticket will prevent a chunk from unloading until it is
* explicitly removed. A plugin instance may only have one ticket per chunk,
* but each chunk can have multiple plugin tickets.
* </p>
*/
// @ts-ignore
addPluginChunkTicket(plugin: org.bukkit.plugin.Plugin): boolean;
/**
* Removes the specified plugin's ticket for this chunk
* <p>
* A plugin ticket will prevent a chunk from unloading until it is
* explicitly removed. A plugin instance may only have one ticket per chunk,
* but each chunk can have multiple plugin tickets.
* </p>
*/
// @ts-ignore
removePluginChunkTicket(plugin: org.bukkit.plugin.Plugin): boolean;
/**
* Retrieves a collection specifying which plugins have tickets for this
* chunk. This collection is not updated when plugin tickets are added or
* removed to this chunk.
* <p>
* A plugin ticket will prevent a chunk from unloading until it is
* explicitly removed. A plugin instance may only have one ticket per chunk,
* but each chunk can have multiple plugin tickets.
* </p>
*/
// @ts-ignore
getPluginChunkTickets(): java.util.Collection;
}
}
}

View File

@@ -0,0 +1,73 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
interface ChunkSnapshot {
/**
* Gets the X-coordinate of this chunk
*/
// @ts-ignore
getX(): number;
/**
* Gets the Z-coordinate of this chunk
*/
// @ts-ignore
getZ(): number;
/**
* Gets name of the world containing this chunk
*/
// @ts-ignore
getWorldName(): string;
/**
* Get block type for block at corresponding coordinate in the chunk
*/
// @ts-ignore
getBlockType(x: number, y: number, z: number): org.bukkit.Material;
/**
* Get block data for block at corresponding coordinate in the chunk
*/
// @ts-ignore
getBlockData(x: number, y: number, z: number): org.bukkit.block.data.BlockData;
/**
* Get block data for block at corresponding coordinate in the chunk
*/
// @ts-ignore
getData(x: number, y: number, z: number): number;
/**
* Get sky light level for block at corresponding coordinate in the chunk
*/
// @ts-ignore
getBlockSkyLight(x: number, y: number, z: number): number;
/**
* Get light level emitted by block at corresponding coordinate in the
* chunk
*/
// @ts-ignore
getBlockEmittedLight(x: number, y: number, z: number): number;
/**
* Gets the highest non-air coordinate at the given coordinates
*/
// @ts-ignore
getHighestBlockYAt(x: number, z: number): number;
/**
* Get biome at given coordinates
*/
// @ts-ignore
getBiome(x: number, z: number): org.bukkit.block.Biome;
/**
* Get raw biome temperature (0.0-1.0) at given coordinate
*/
// @ts-ignore
getRawBiomeTemperature(x: number, z: number): number;
/**
* Get world full time when chunk snapshot was captured
*/
// @ts-ignore
getCaptureFullTime(): number;
/**
* Test if section is empty
*/
// @ts-ignore
isSectionEmpty(sy: number): boolean;
}
}
}

View File

@@ -0,0 +1,25 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class CoalType extends java.lang.Enum {
// @ts-ignore
public static COAL: org.bukkit.CoalType;
// @ts-ignore
public static CHARCOAL: org.bukkit.CoalType;
// @ts-ignore
public static values(): org.bukkit.CoalType[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.CoalType;
/**
* Gets the associated data value representing this type of coal
*/
// @ts-ignore
public getData(): number;
/**
* Gets the type of coal with the given data value
*/
// @ts-ignore
public static getByData(data: number): org.bukkit.CoalType;
}
}
}

View File

@@ -0,0 +1,119 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class Color extends java.lang.Object implements org.bukkit.configuration.serialization.ConfigurationSerializable {
// @ts-ignore
public static WHITE: org.bukkit.Color;
// @ts-ignore
public static SILVER: org.bukkit.Color;
// @ts-ignore
public static GRAY: org.bukkit.Color;
// @ts-ignore
public static BLACK: org.bukkit.Color;
// @ts-ignore
public static RED: org.bukkit.Color;
// @ts-ignore
public static MAROON: org.bukkit.Color;
// @ts-ignore
public static YELLOW: org.bukkit.Color;
// @ts-ignore
public static OLIVE: org.bukkit.Color;
// @ts-ignore
public static LIME: org.bukkit.Color;
// @ts-ignore
public static GREEN: org.bukkit.Color;
// @ts-ignore
public static AQUA: org.bukkit.Color;
// @ts-ignore
public static TEAL: org.bukkit.Color;
// @ts-ignore
public static BLUE: org.bukkit.Color;
// @ts-ignore
public static NAVY: org.bukkit.Color;
// @ts-ignore
public static FUCHSIA: org.bukkit.Color;
// @ts-ignore
public static PURPLE: org.bukkit.Color;
// @ts-ignore
public static ORANGE: org.bukkit.Color;
/**
* Creates a new Color object from a red, green, and blue
*/
// @ts-ignore
public static fromRGB(red: number, green: number, blue: number): org.bukkit.Color;
/**
* Creates a new Color object from a blue, green, and red
*/
// @ts-ignore
public static fromBGR(blue: number, green: number, red: number): org.bukkit.Color;
/**
* Creates a new color object from an integer that contains the red,
* green, and blue bytes in the lowest order 24 bits.
*/
// @ts-ignore
public static fromRGB(rgb: number): org.bukkit.Color;
/**
* Creates a new color object from an integer that contains the blue,
* green, and red bytes in the lowest order 24 bits.
*/
// @ts-ignore
public static fromBGR(bgr: number): org.bukkit.Color;
/**
* Gets the red component
*/
// @ts-ignore
public getRed(): number;
/**
* Creates a new Color object with specified component
*/
// @ts-ignore
public setRed(red: number): org.bukkit.Color;
/**
* Gets the green component
*/
// @ts-ignore
public getGreen(): number;
/**
* Creates a new Color object with specified component
*/
// @ts-ignore
public setGreen(green: number): org.bukkit.Color;
/**
* Gets the blue component
*/
// @ts-ignore
public getBlue(): number;
/**
* Creates a new Color object with specified component
*/
// @ts-ignore
public setBlue(blue: number): org.bukkit.Color;
// @ts-ignore
public asRGB(): number;
// @ts-ignore
public asBGR(): number;
/**
* Creates a new color with its RGB components changed as if it was dyed
* with the colors passed in, replicating vanilla workbench dyeing
*/
// @ts-ignore
public mixDyes(colors: org.bukkit.DyeColor): org.bukkit.Color;
/**
* Creates a new color with its RGB components changed as if it was dyed
* with the colors passed in, replicating vanilla workbench dyeing
*/
// @ts-ignore
public mixColors(colors: org.bukkit.Color): org.bukkit.Color;
// @ts-ignore
public equals(o: java.lang.Object): boolean;
// @ts-ignore
public hashCode(): number;
// @ts-ignore
public serialize(): java.util.Map;
// @ts-ignore
public static deserialize(map: java.util.Map): org.bukkit.Color;
// @ts-ignore
public toString(): string;
}
}
}

View File

@@ -0,0 +1,37 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class CropState extends java.lang.Enum {
// @ts-ignore
public static SEEDED: org.bukkit.CropState;
// @ts-ignore
public static GERMINATED: org.bukkit.CropState;
// @ts-ignore
public static VERY_SMALL: org.bukkit.CropState;
// @ts-ignore
public static SMALL: org.bukkit.CropState;
// @ts-ignore
public static MEDIUM: org.bukkit.CropState;
// @ts-ignore
public static TALL: org.bukkit.CropState;
// @ts-ignore
public static VERY_TALL: org.bukkit.CropState;
// @ts-ignore
public static RIPE: org.bukkit.CropState;
// @ts-ignore
public static values(): org.bukkit.CropState[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.CropState;
/**
* Gets the associated data value representing this growth state
*/
// @ts-ignore
public getData(): number;
/**
* Gets the CropState with the given data value
*/
// @ts-ignore
public static getByData(data: number): org.bukkit.CropState;
}
}
}

View File

@@ -0,0 +1,29 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class Difficulty extends java.lang.Enum {
// @ts-ignore
public static PEACEFUL: org.bukkit.Difficulty;
// @ts-ignore
public static EASY: org.bukkit.Difficulty;
// @ts-ignore
public static NORMAL: org.bukkit.Difficulty;
// @ts-ignore
public static HARD: org.bukkit.Difficulty;
// @ts-ignore
public static values(): org.bukkit.Difficulty[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.Difficulty;
/**
* Gets the difficulty value associated with this Difficulty.
*/
// @ts-ignore
public getValue(): number;
/**
* Gets the Difficulty represented by the specified value
*/
// @ts-ignore
public static getByValue(value: number): org.bukkit.Difficulty;
}
}
}

View File

@@ -0,0 +1,88 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class DyeColor extends java.lang.Enum {
// @ts-ignore
public static WHITE: org.bukkit.DyeColor;
// @ts-ignore
public static ORANGE: org.bukkit.DyeColor;
// @ts-ignore
public static MAGENTA: org.bukkit.DyeColor;
// @ts-ignore
public static LIGHT_BLUE: org.bukkit.DyeColor;
// @ts-ignore
public static YELLOW: org.bukkit.DyeColor;
// @ts-ignore
public static LIME: org.bukkit.DyeColor;
// @ts-ignore
public static PINK: org.bukkit.DyeColor;
// @ts-ignore
public static GRAY: org.bukkit.DyeColor;
// @ts-ignore
public static LIGHT_GRAY: org.bukkit.DyeColor;
// @ts-ignore
public static CYAN: org.bukkit.DyeColor;
// @ts-ignore
public static PURPLE: org.bukkit.DyeColor;
// @ts-ignore
public static BLUE: org.bukkit.DyeColor;
// @ts-ignore
public static BROWN: org.bukkit.DyeColor;
// @ts-ignore
public static GREEN: org.bukkit.DyeColor;
// @ts-ignore
public static RED: org.bukkit.DyeColor;
// @ts-ignore
public static BLACK: org.bukkit.DyeColor;
// @ts-ignore
public static values(): org.bukkit.DyeColor[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.DyeColor;
/**
* Gets the associated wool data value representing this color.
*/
// @ts-ignore
public getWoolData(): number;
/**
* Gets the associated dye data value representing this color.
*/
// @ts-ignore
public getDyeData(): number;
/**
* Gets the color that this dye represents.
*/
// @ts-ignore
public getColor(): org.bukkit.Color;
/**
* Gets the firework color that this dye represents.
*/
// @ts-ignore
public getFireworkColor(): org.bukkit.Color;
/**
* Gets the DyeColor with the given wool data value.
*/
// @ts-ignore
public static getByWoolData(data: number): org.bukkit.DyeColor;
/**
* Gets the DyeColor with the given dye data value.
*/
// @ts-ignore
public static getByDyeData(data: number): org.bukkit.DyeColor;
/**
* Gets the DyeColor with the given color value.
*/
// @ts-ignore
public static getByColor(color: org.bukkit.Color): org.bukkit.DyeColor;
/**
* Gets the DyeColor with the given firework color value.
*/
// @ts-ignore
public static getByFireworkColor(color: org.bukkit.Color): org.bukkit.DyeColor;
/**
* Gets the DyeColor for the given name, possibly doing legacy transformations.
*/
// @ts-ignore
public static legacyValueOf(name: string): org.bukkit.DyeColor;
}
}
}

View File

@@ -0,0 +1,17 @@
declare namespace org {
namespace bukkit {
namespace Effect {
// @ts-ignore
class Type extends java.lang.Enum {
// @ts-ignore
public static SOUND: org.bukkit.Effect.Type;
// @ts-ignore
public static VISUAL: org.bukkit.Effect.Type;
// @ts-ignore
public static values(): org.bukkit.Effect.Type[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.Effect.Type;
}
}
}
}

View File

@@ -0,0 +1,115 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class Effect extends java.lang.Enum {
// @ts-ignore
public static CLICK2: org.bukkit.Effect;
// @ts-ignore
public static CLICK1: org.bukkit.Effect;
// @ts-ignore
public static BOW_FIRE: org.bukkit.Effect;
// @ts-ignore
public static DOOR_TOGGLE: org.bukkit.Effect;
// @ts-ignore
public static IRON_DOOR_TOGGLE: org.bukkit.Effect;
// @ts-ignore
public static TRAPDOOR_TOGGLE: org.bukkit.Effect;
// @ts-ignore
public static IRON_TRAPDOOR_TOGGLE: org.bukkit.Effect;
// @ts-ignore
public static FENCE_GATE_TOGGLE: org.bukkit.Effect;
// @ts-ignore
public static DOOR_CLOSE: org.bukkit.Effect;
// @ts-ignore
public static IRON_DOOR_CLOSE: org.bukkit.Effect;
// @ts-ignore
public static TRAPDOOR_CLOSE: org.bukkit.Effect;
// @ts-ignore
public static IRON_TRAPDOOR_CLOSE: org.bukkit.Effect;
// @ts-ignore
public static FENCE_GATE_CLOSE: org.bukkit.Effect;
// @ts-ignore
public static EXTINGUISH: org.bukkit.Effect;
// @ts-ignore
public static RECORD_PLAY: org.bukkit.Effect;
// @ts-ignore
public static GHAST_SHRIEK: org.bukkit.Effect;
// @ts-ignore
public static GHAST_SHOOT: org.bukkit.Effect;
// @ts-ignore
public static BLAZE_SHOOT: org.bukkit.Effect;
// @ts-ignore
public static ZOMBIE_CHEW_WOODEN_DOOR: org.bukkit.Effect;
// @ts-ignore
public static ZOMBIE_CHEW_IRON_DOOR: org.bukkit.Effect;
// @ts-ignore
public static ZOMBIE_DESTROY_DOOR: org.bukkit.Effect;
// @ts-ignore
public static SMOKE: org.bukkit.Effect;
// @ts-ignore
public static STEP_SOUND: org.bukkit.Effect;
// @ts-ignore
public static POTION_BREAK: org.bukkit.Effect;
// @ts-ignore
public static ENDER_SIGNAL: org.bukkit.Effect;
// @ts-ignore
public static MOBSPAWNER_FLAMES: org.bukkit.Effect;
// @ts-ignore
public static BREWING_STAND_BREW: org.bukkit.Effect;
// @ts-ignore
public static CHORUS_FLOWER_GROW: org.bukkit.Effect;
// @ts-ignore
public static CHORUS_FLOWER_DEATH: org.bukkit.Effect;
// @ts-ignore
public static PORTAL_TRAVEL: org.bukkit.Effect;
// @ts-ignore
public static ENDEREYE_LAUNCH: org.bukkit.Effect;
// @ts-ignore
public static FIREWORK_SHOOT: org.bukkit.Effect;
// @ts-ignore
public static VILLAGER_PLANT_GROW: org.bukkit.Effect;
// @ts-ignore
public static DRAGON_BREATH: org.bukkit.Effect;
// @ts-ignore
public static ANVIL_BREAK: org.bukkit.Effect;
// @ts-ignore
public static ANVIL_USE: org.bukkit.Effect;
// @ts-ignore
public static ANVIL_LAND: org.bukkit.Effect;
// @ts-ignore
public static ENDERDRAGON_SHOOT: org.bukkit.Effect;
// @ts-ignore
public static WITHER_BREAK_BLOCK: org.bukkit.Effect;
// @ts-ignore
public static WITHER_SHOOT: org.bukkit.Effect;
// @ts-ignore
public static ZOMBIE_INFECT: org.bukkit.Effect;
// @ts-ignore
public static ZOMBIE_CONVERTED_VILLAGER: org.bukkit.Effect;
// @ts-ignore
public static BAT_TAKEOFF: org.bukkit.Effect;
// @ts-ignore
public static END_GATEWAY_SPAWN: org.bukkit.Effect;
// @ts-ignore
public static ENDERDRAGON_GROWL: org.bukkit.Effect;
// @ts-ignore
public static values(): org.bukkit.Effect[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.Effect;
/**
* Gets the ID for this effect.
*/
// @ts-ignore
public getId(): number;
// @ts-ignore
public getType(): org.bukkit.Effect.Type;
// @ts-ignore
public getData(): java.lang.Class;
/**
* Gets the Effect associated with the given ID.
*/
// @ts-ignore
public static getById(id: number): org.bukkit.Effect;
}
}
}

View File

@@ -0,0 +1,80 @@
declare namespace org {
namespace bukkit {
// @ts-ignore
class EntityEffect extends java.lang.Enum {
// @ts-ignore
public static ARROW_PARTICLES: org.bukkit.EntityEffect;
// @ts-ignore
public static RABBIT_JUMP: org.bukkit.EntityEffect;
// @ts-ignore
public static HURT: org.bukkit.EntityEffect;
// @ts-ignore
public static DEATH: org.bukkit.EntityEffect;
// @ts-ignore
public static WOLF_SMOKE: org.bukkit.EntityEffect;
// @ts-ignore
public static WOLF_HEARTS: org.bukkit.EntityEffect;
// @ts-ignore
public static WOLF_SHAKE: org.bukkit.EntityEffect;
// @ts-ignore
public static SHEEP_EAT: org.bukkit.EntityEffect;
// @ts-ignore
public static IRON_GOLEM_ROSE: org.bukkit.EntityEffect;
// @ts-ignore
public static VILLAGER_HEART: org.bukkit.EntityEffect;
// @ts-ignore
public static VILLAGER_ANGRY: org.bukkit.EntityEffect;
// @ts-ignore
public static VILLAGER_HAPPY: org.bukkit.EntityEffect;
// @ts-ignore
public static WITCH_MAGIC: org.bukkit.EntityEffect;
// @ts-ignore
public static ZOMBIE_TRANSFORM: org.bukkit.EntityEffect;
// @ts-ignore
public static FIREWORK_EXPLODE: org.bukkit.EntityEffect;
// @ts-ignore
public static LOVE_HEARTS: org.bukkit.EntityEffect;
// @ts-ignore
public static SQUID_ROTATE: org.bukkit.EntityEffect;
// @ts-ignore
public static ENTITY_POOF: org.bukkit.EntityEffect;
// @ts-ignore
public static GUARDIAN_TARGET: org.bukkit.EntityEffect;
// @ts-ignore
public static SHIELD_BLOCK: org.bukkit.EntityEffect;
// @ts-ignore
public static SHIELD_BREAK: org.bukkit.EntityEffect;
// @ts-ignore
public static ARMOR_STAND_HIT: org.bukkit.EntityEffect;
// @ts-ignore
public static THORNS_HURT: org.bukkit.EntityEffect;
// @ts-ignore
public static IRON_GOLEM_SHEATH: org.bukkit.EntityEffect;
// @ts-ignore
public static TOTEM_RESURRECT: org.bukkit.EntityEffect;
// @ts-ignore
public static HURT_DROWN: org.bukkit.EntityEffect;
// @ts-ignore
public static HURT_EXPLOSION: org.bukkit.EntityEffect;
// @ts-ignore
public static values(): org.bukkit.EntityEffect[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.EntityEffect;
/**
* Gets the data value of this EntityEffect
*/
// @ts-ignore
public getData(): number;
/**
* Gets entity superclass which this affect is applicable to.
*/
// @ts-ignore
public getApplicable(): java.lang.Class;
/**
* Gets the EntityEffect with the given data value
*/
// @ts-ignore
public static getByData(data: number): org.bukkit.EntityEffect;
}
}
}

View File

@@ -0,0 +1,72 @@
declare namespace org {
namespace bukkit {
namespace FireworkEffect {
// @ts-ignore
class Builder extends java.lang.Object {
/**
* Specify the type of the firework effect.
*/
// @ts-ignore
public with(type: org.bukkit.FireworkEffect.Type): org.bukkit.FireworkEffect.Builder;
/**
* Add a flicker to the firework effect.
*/
// @ts-ignore
public withFlicker(): org.bukkit.FireworkEffect.Builder;
/**
* Set whether the firework effect should flicker.
*/
// @ts-ignore
public flicker(flicker: boolean): org.bukkit.FireworkEffect.Builder;
/**
* Add a trail to the firework effect.
*/
// @ts-ignore
public withTrail(): org.bukkit.FireworkEffect.Builder;
/**
* Set whether the firework effect should have a trail.
*/
// @ts-ignore
public trail(trail: boolean): org.bukkit.FireworkEffect.Builder;
/**
* Add a primary color to the firework effect.
*/
// @ts-ignore
public withColor(color: org.bukkit.Color): org.bukkit.FireworkEffect.Builder;
/**
* Add several primary colors to the firework effect.
*/
// @ts-ignore
public withColor(colors: org.bukkit.Color): org.bukkit.FireworkEffect.Builder;
/**
* Add several primary colors to the firework effect.
*/
// @ts-ignore
public withColor(colors: java.lang.Iterable): org.bukkit.FireworkEffect.Builder;
/**
* Add a fade color to the firework effect.
*/
// @ts-ignore
public withFade(color: org.bukkit.Color): org.bukkit.FireworkEffect.Builder;
/**
* Add several fade colors to the firework effect.
*/
// @ts-ignore
public withFade(colors: org.bukkit.Color): org.bukkit.FireworkEffect.Builder;
/**
* Add several fade colors to the firework effect.
*/
// @ts-ignore
public withFade(colors: java.lang.Iterable): org.bukkit.FireworkEffect.Builder;
/**
* Create a {@link FireworkEffect} from the current contents of this
* builder.
* <p>
* To successfully build, you must have specified at least one color.
*/
// @ts-ignore
public build(): org.bukkit.FireworkEffect;
}
}
}
}

View File

@@ -0,0 +1,23 @@
declare namespace org {
namespace bukkit {
namespace FireworkEffect {
// @ts-ignore
class Type extends java.lang.Enum {
// @ts-ignore
public static BALL: org.bukkit.FireworkEffect.Type;
// @ts-ignore
public static BALL_LARGE: org.bukkit.FireworkEffect.Type;
// @ts-ignore
public static STAR: org.bukkit.FireworkEffect.Type;
// @ts-ignore
public static BURST: org.bukkit.FireworkEffect.Type;
// @ts-ignore
public static CREEPER: org.bukkit.FireworkEffect.Type;
// @ts-ignore
public static values(): org.bukkit.FireworkEffect.Type[];
// @ts-ignore
public static valueOf(name: string): org.bukkit.FireworkEffect.Type;
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More