FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SimpleAPI/src/test/java/EngineTest.java at master · InfinityStudio/SimpleAPI · GitHub
InfinityStudio
SimpleAPI
Repository navigation
Code
Issues
1
(1)
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
SimpleAPI
/
src
/
test
/
java
/
EngineTest.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (46 loc) · 1.69 KB
Breadcrumbs
SimpleAPI
/
src
/
test
/
java
/
EngineTest.java
Copy path
File metadata and controls
52 lines (46 loc) · 1.69 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import
net
.
simpleAPI
.
item
.
ItemCreate
;
import
net
.
simpleAPI
.
item
.
ItemUpdate
;
import
javax
.
script
.
ScriptEngine
;
import
javax
.
script
.
ScriptEngineManager
;
import
javax
.
script
.
ScriptException
;
/**
* @author ci010
*/
public
class
EngineTest
{
String
pre
=
"var ItemBlockDestroy = Java.type('ItemBlockDestroy');
\n
"
+
"var ItemBlockInteract = Java.type('ItemBlockInteract');
\n
"
+
"var ItemCreate = Java.type('ItemCreate');
\n
"
+
"var ItemEntityHandler = Java.type('ItemEntityHandler');
\n
"
+
"var ItemUpdate = Java.type('ItemUpdate');
\n
"
+
"var ItemUsing = Java.type('ItemUsing');"
;
public
void
test
()
throws
ScriptException
,
NoSuchMethodException
{
ScriptEngine
engine
=
new
ScriptEngineManager
().
getEngineByName
(
"nashorn"
);
engine
.
eval
(
pre
);
Object
eval
=
engine
.
eval
(
" type = Java.extend(ItemUpdate, ItemCreate);"
+
" inst = new type() {
\n
"
+
" onUpdate: function(stack, world, entity, slot, isSelect) {print('update');},
\n
"
+
" onCreated: function(stack, world, player){print('create');}"
+
"};"
);
System
.
out
.
println
(
eval
);
System
.
out
.
println
(
eval
.
getClass
());
ItemCreate
eval1
= (
ItemCreate
)
eval
;
eval1
.
onCreated
(
null
,
null
,
null
);
ItemUpdate
eval2
= (
ItemUpdate
)
eval
;
eval2
.
onUpdate
(
null
,
null
,
null
,
0
,
false
);
Object
sec
=
engine
.
eval
(
" type = Java.extend(ItemUpdate, ItemCreate);"
+
" inst = new type() {
\n
"
+
" onUpdate: function(stack, world, entity, slot, isSelect) {print('update2');},
\n
"
+
" onCreated: function(stack, world, player){print('create2');}"
+
"};"
);
eval1
= (
ItemCreate
)
sec
;
eval1
.
onCreated
(
null
,
null
,
null
);
eval2
= (
ItemUpdate
)
sec
;
eval2
.
onUpdate
(
null
,
null
,
null
,
0
,
false
);
}
}
Back
|
FazBrowse Home
|
New Git URL