mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-26 02:29:14 +00:00
Compare commits
1054 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecaa388bbe | ||
|
|
4cfdc5bf30 | ||
|
|
ed1090430a | ||
|
|
3322cd73ea | ||
|
|
824f6ac4aa | ||
|
|
d5dfa89fdd | ||
|
|
9628a98568 | ||
|
|
cc3428d24b | ||
|
|
fe684e9bbd | ||
|
|
f31ea9b7cf | ||
|
|
7eeebb66ab | ||
|
|
e4f53c1daf | ||
|
|
98bd58a92c | ||
|
|
f9a7c12620 | ||
|
|
d04223e174 | ||
|
|
e71c514ef6 | ||
|
|
57b089ac89 | ||
|
|
b97ff6fe14 | ||
|
|
c57ac4c9fe | ||
|
|
9cf60ca227 | ||
|
|
8c9684e35c | ||
|
|
00854e2ea7 | ||
|
|
dcae312d2c | ||
|
|
963a851382 | ||
|
|
1d233c5250 | ||
|
|
34919ec961 | ||
|
|
d15228656f | ||
|
|
dd20a06f80 | ||
|
|
a4bbad3243 | ||
|
|
343ae99b54 | ||
|
|
41d1714d28 | ||
|
|
c20a2ecd9a | ||
|
|
b609daf89d | ||
|
|
f1cdcdaf3e | ||
|
|
01da323ddb | ||
|
|
9675a608a8 | ||
|
|
8231f28ded | ||
|
|
772ecea71a | ||
|
|
63a74f2dc9 | ||
|
|
4f3286f520 | ||
|
|
26ca025070 | ||
|
|
49b1c553ba | ||
|
|
55948d5b79 | ||
|
|
3aeee71873 | ||
|
|
d669e733cd | ||
|
|
d9af34ee81 | ||
|
|
8649dbda35 | ||
|
|
c7d05fbdb1 | ||
|
|
f2cfd50a44 | ||
|
|
a8146a2e81 | ||
|
|
d166cc2a4a | ||
|
|
4558cb4846 | ||
|
|
143349be3a | ||
|
|
82ac92dfed | ||
|
|
2643eb2e37 | ||
|
|
ac03b9f539 | ||
|
|
a4370ba55a | ||
|
|
7aa4a01355 | ||
|
|
349a9de592 | ||
|
|
58c0b45ac8 | ||
|
|
af0a923210 | ||
|
|
9bcaeee794 | ||
|
|
b6d8771792 | ||
|
|
f5fed50e4d | ||
|
|
5a00f56a39 | ||
|
|
0bb48f8af0 | ||
|
|
f3ceda1b3d | ||
|
|
24c4cbe901 | ||
|
|
26e2b2507d | ||
|
|
d3378c638a | ||
|
|
aa90274cc2 | ||
|
|
d0a281c116 | ||
|
|
4cbf192e74 | ||
|
|
1edafc40d0 | ||
|
|
6a4a25db40 | ||
|
|
e5ca66305c | ||
|
|
3250566949 | ||
|
|
4ced362dd0 | ||
|
|
4b87ac2907 | ||
|
|
44e1b8f159 | ||
|
|
81b1f06eec | ||
|
|
441d36e2e3 | ||
|
|
7cba76b1e8 | ||
|
|
c3304a78fb | ||
|
|
e6113b4aa1 | ||
|
|
044c7f997d | ||
|
|
abfba739a8 | ||
|
|
cec67484e5 | ||
|
|
aafed9b1b7 | ||
|
|
552a87462a | ||
|
|
4c8013e6d2 | ||
|
|
4f5efba173 | ||
|
|
e0c94af535 | ||
|
|
a8ff0b5e62 | ||
|
|
21a6a19caf | ||
|
|
b1d25ec35c | ||
|
|
685de56fbb | ||
|
|
e8adb7d533 | ||
|
|
c2af0e8b48 | ||
|
|
8ea7b09482 | ||
|
|
5180d1a17a | ||
|
|
d7e3493a59 | ||
|
|
5ea0a53995 | ||
|
|
dd4c66dbd8 | ||
|
|
0e8c2476b2 | ||
|
|
53fdcce361 | ||
|
|
a4a8d78b1f | ||
|
|
8b7bb7faa2 | ||
|
|
28430cc1c3 | ||
|
|
672f2d717d | ||
|
|
8362800a54 | ||
|
|
731908c265 | ||
|
|
3eb864deb9 | ||
|
|
cb27043d12 | ||
|
|
5b90fce1f5 | ||
|
|
7f49ee3db6 | ||
|
|
72b645916f | ||
|
|
4700c3711c | ||
|
|
feaf21c702 | ||
|
|
4fa8fff3db | ||
|
|
4e670f85f5 | ||
|
|
11a484714a | ||
|
|
6c425947bf | ||
|
|
e06d34f546 | ||
|
|
9ffd0dcdbe | ||
|
|
0ce51709da | ||
|
|
073944dd96 | ||
|
|
874589c772 | ||
|
|
4a05031a0f | ||
|
|
38185ef2f1 | ||
|
|
66dde6c215 | ||
|
|
a438817d00 | ||
|
|
a92e651b43 | ||
|
|
618da86b44 | ||
|
|
46d810eddf | ||
|
|
031601bfa6 | ||
|
|
bb5f777cea | ||
|
|
fa6c2fb63e | ||
|
|
d561348c4f | ||
|
|
c290dba3bb | ||
|
|
1477180fa5 | ||
|
|
6cd4b7c433 | ||
|
|
36f56c2040 | ||
|
|
f763cc4020 | ||
|
|
180d2addd0 | ||
|
|
8fe21d6d05 | ||
|
|
3274fb9615 | ||
|
|
1c5863e6de | ||
|
|
60b424c101 | ||
|
|
2a51454682 | ||
|
|
1d052231f0 | ||
|
|
f120c41518 | ||
|
|
30b8619dd1 | ||
|
|
1e832ed0eb | ||
|
|
6260c07cd6 | ||
|
|
241d8fd321 | ||
|
|
5ddbddf5cc | ||
|
|
38854b7d6a | ||
|
|
958c5ea195 | ||
|
|
4329623341 | ||
|
|
658b0595ff | ||
|
|
2869a2157b | ||
|
|
11d5d74c11 | ||
|
|
54dd379cf5 | ||
|
|
7eef4ed876 | ||
|
|
dd7a8bae16 | ||
|
|
93508d7514 | ||
|
|
1493beb79b | ||
|
|
b7b15a8f7b | ||
|
|
6cb15d004e | ||
|
|
22220b1b95 | ||
|
|
7fe418d529 | ||
|
|
ed8b0a078d | ||
|
|
71affb0a70 | ||
|
|
52f829f5d1 | ||
|
|
518d10fc8f | ||
|
|
62bbeb9471 | ||
|
|
36986d7ddd | ||
|
|
b266b8b341 | ||
|
|
c95c4b5f7d | ||
|
|
68c55086cf | ||
|
|
6b77bba46d | ||
|
|
675c7f8572 | ||
|
|
7fff705897 | ||
|
|
45a7e6a6ea | ||
|
|
1db0f3f536 | ||
|
|
2f086a335d | ||
|
|
9fe9c2a9dd | ||
|
|
2cd9a25791 | ||
|
|
45cef6a752 | ||
|
|
3811dd3554 | ||
|
|
b2c944af43 | ||
|
|
76ca4f2183 | ||
|
|
72d7154a96 | ||
|
|
ee6e9b059a | ||
|
|
2afb468ae4 | ||
|
|
125f705a6a | ||
|
|
3884af64a7 | ||
|
|
6bf65c7c74 | ||
|
|
7ddaa3ce65 | ||
|
|
5786fe78b2 | ||
|
|
f50a2fd0ad | ||
|
|
3f5b799728 | ||
|
|
0cd4997174 | ||
|
|
f70046bc73 | ||
|
|
feb246c559 | ||
|
|
1dd18c3c0a | ||
|
|
36b3521b2a | ||
|
|
c0df132c93 | ||
|
|
0a08b4b0b9 | ||
|
|
8a4208ab18 | ||
|
|
2b8d5541af | ||
|
|
b81765adda | ||
|
|
f7bd48cc9a | ||
|
|
db7681676e | ||
|
|
7d9cfb6ff9 | ||
|
|
14f0a3ce05 | ||
|
|
3c650a7c50 | ||
|
|
a9a964cc75 | ||
|
|
5085c89c22 | ||
|
|
9720ada87f | ||
|
|
9adbbcee93 | ||
|
|
160eee04ff | ||
|
|
8353c5105b | ||
|
|
6fd53d6e95 | ||
|
|
7530c586f7 | ||
|
|
8deb326ea1 | ||
|
|
4b76b592d3 | ||
|
|
3f9288c60f | ||
|
|
91e1b614f3 | ||
|
|
b6f3e3a62f | ||
|
|
4a30b6d264 | ||
|
|
73bfa9beb8 | ||
|
|
18e203f007 | ||
|
|
c6aad25ef2 | ||
|
|
bc8f25ff4b | ||
|
|
4627303008 | ||
|
|
e46a36d1c4 | ||
|
|
62325d9784 | ||
|
|
38d0894c36 | ||
|
|
f7e379c83f | ||
|
|
185cc994f7 | ||
|
|
8815518af9 | ||
|
|
233144eede | ||
|
|
1028ebccbb | ||
|
|
791fd4bc55 | ||
|
|
5a557e6f00 | ||
|
|
948f823744 | ||
|
|
c05d22b550 | ||
|
|
f062d5b894 | ||
|
|
1af7ee8e8d | ||
|
|
53e8c9141c | ||
|
|
64f27e7d39 | ||
|
|
a77c99d050 | ||
|
|
9c4ccc51c7 | ||
|
|
7937d8d041 | ||
|
|
cca66f1f32 | ||
|
|
dc4f0c1159 | ||
|
|
fb07b280be | ||
|
|
2915ef885e | ||
|
|
152a4af549 | ||
|
|
c7508441ec | ||
|
|
3073d3aa9d | ||
|
|
78eebc255e | ||
|
|
5e6ec3b217 | ||
|
|
a6d6814f27 | ||
|
|
9d634ba4d7 | ||
|
|
fcf8a80b0a | ||
|
|
dfaf361bf2 | ||
|
|
6c791c034b | ||
|
|
8935c51cc9 | ||
|
|
b148fa94c3 | ||
|
|
70fef94d15 | ||
|
|
a921845ae3 | ||
|
|
8dd858e813 | ||
|
|
634e7ad7ee | ||
|
|
e926a08def | ||
|
|
f4eb0cfbcb | ||
|
|
ee557d8191 | ||
|
|
7d37954495 | ||
|
|
3dc7bd74fe | ||
|
|
56ae387f7b | ||
|
|
5878128746 | ||
|
|
5994cc66b4 | ||
|
|
a9410d92a2 | ||
|
|
89da5fe08a | ||
|
|
bb69ae887f | ||
|
|
540656870a | ||
|
|
4f3b6e4029 | ||
|
|
cec56c8406 | ||
|
|
7bbae51c7d | ||
|
|
3d00e96f89 | ||
|
|
6f29da1926 | ||
|
|
6f028eae6e | ||
|
|
b44501566c | ||
|
|
5f50fa4202 | ||
|
|
5487cd7858 | ||
|
|
89e1af456f | ||
|
|
439838abd2 | ||
|
|
1cf60544e1 | ||
|
|
70ae1cce4b | ||
|
|
b5fa41cdc1 | ||
|
|
0cce35908d | ||
|
|
5a1d8348d8 | ||
|
|
63cd793407 | ||
|
|
f5abee1f92 | ||
|
|
1b0ed90a54 | ||
|
|
5003f69e8e | ||
|
|
68214cf16f | ||
|
|
1365d442e9 | ||
|
|
2f29953ccb | ||
|
|
9929479bf0 | ||
|
|
b52c71c0f3 | ||
|
|
712be51888 | ||
|
|
3e4cc8841d | ||
|
|
3742d5ef81 | ||
|
|
310b12c81d | ||
|
|
ab64a8f8e2 | ||
|
|
9d18a1297b | ||
|
|
e73534ba2f | ||
|
|
73360bb66c | ||
|
|
5b74f8f836 | ||
|
|
0b87cd9aef | ||
|
|
c5c971eeae | ||
|
|
b554e2ee6c | ||
|
|
436a8c4d8e | ||
|
|
a5725439ee | ||
|
|
30bc725631 | ||
|
|
d261347b06 | ||
|
|
9bc65601c0 | ||
|
|
4a82def974 | ||
|
|
0755e8f618 | ||
|
|
44ef039321 | ||
|
|
a7f5451ea4 | ||
|
|
4902e5b9bb | ||
|
|
f3eb1bb45e | ||
|
|
01a9a13402 | ||
|
|
ff6f76e018 | ||
|
|
01110d0835 | ||
|
|
b6fdde403a | ||
|
|
ad01a157ce | ||
|
|
ac04ef34d7 | ||
|
|
58845ae79f | ||
|
|
d6b7a4bdba | ||
|
|
34040abc8f | ||
|
|
03f535e85e | ||
|
|
6ea0bb30e0 | ||
|
|
dd083f73f7 | ||
|
|
8dee20295e | ||
|
|
6e47e4bcd2 | ||
|
|
ff825b85aa | ||
|
|
802bc50102 | ||
|
|
6d08faa30f | ||
|
|
116ab72f4e | ||
|
|
44d86bc350 | ||
|
|
e0fc4b9443 | ||
|
|
d9e18e0f3b | ||
|
|
6b8610b72d | ||
|
|
468448ff6e | ||
|
|
b85efcd85a | ||
|
|
657f581a3d | ||
|
|
0dbff85bd8 | ||
|
|
bf9c4c602b | ||
|
|
4c44957764 | ||
|
|
ec39d7146c | ||
|
|
c60a772e84 | ||
|
|
9ba47c1b6a | ||
|
|
4fc8a5ad0c | ||
|
|
50ffcceaf4 | ||
|
|
05060e76cb | ||
|
|
5139b587f6 | ||
|
|
63870b75a7 | ||
|
|
cf0a8b3e95 | ||
|
|
8006482c22 | ||
|
|
cda15170bd | ||
|
|
9ececd80d6 | ||
|
|
5ea938a20b | ||
|
|
f4056a3fca | ||
|
|
23188c3898 | ||
|
|
7322f1a9fb | ||
|
|
4f6a676c32 | ||
|
|
f2e3914ad8 | ||
|
|
25f2189a08 | ||
|
|
448c406e3e | ||
|
|
d7c9640dc9 | ||
|
|
08949ab25f | ||
|
|
24ae8d1679 | ||
|
|
adb7b13599 | ||
|
|
eddf94a340 | ||
|
|
3df741c4fc | ||
|
|
12e7c51c39 | ||
|
|
c8e2bcd6e4 | ||
|
|
14d5286eb0 | ||
|
|
397a2b0d82 | ||
|
|
35cf439592 | ||
|
|
2f6d69efac | ||
|
|
d00ab3f8d6 | ||
|
|
05d3adff36 | ||
|
|
4c24c570a8 | ||
|
|
19f78f769b | ||
|
|
44358c122f | ||
|
|
8b720e103f | ||
|
|
bd5ca76ef4 | ||
|
|
5e4136d9a1 | ||
|
|
14029aa60f | ||
|
|
fa99b967ed | ||
|
|
a9120edb70 | ||
|
|
cfc8458841 | ||
|
|
7a7fee1d8a | ||
|
|
b87153a445 | ||
|
|
f97cd10bf6 | ||
|
|
736deca1fc | ||
|
|
7f3b9ec89a | ||
|
|
f2339f26ca | ||
|
|
b74a00de22 | ||
|
|
d71297a114 | ||
|
|
fb006a3032 | ||
|
|
536ed2b967 | ||
|
|
1173c3d053 | ||
|
|
c7c1b2b8c1 | ||
|
|
6c8db56474 | ||
|
|
3292dc47ab | ||
|
|
98889780b9 | ||
|
|
11703afd6b | ||
|
|
3c1597f42f | ||
|
|
9d828ad291 | ||
|
|
84506c65ad | ||
|
|
c5bd594798 | ||
|
|
13805edba9 | ||
|
|
79bd586def | ||
|
|
0e86e942ce | ||
|
|
708959a0c5 | ||
|
|
3bf3e2605b | ||
|
|
39b539aaed | ||
|
|
c9648a5ec4 | ||
|
|
acaa93367f | ||
|
|
2c830eacdd | ||
|
|
4c0e918559 | ||
|
|
f79a3d15d1 | ||
|
|
f2b44d8f99 | ||
|
|
a319314d04 | ||
|
|
2c8c23522b | ||
|
|
c05696df8c | ||
|
|
97019f1a2a | ||
|
|
aa7a1ddd4e | ||
|
|
6bbe1c8518 | ||
|
|
0cf0d68026 | ||
|
|
6ff583a916 | ||
|
|
f1856afa77 | ||
|
|
6a03b4b125 | ||
|
|
9e062acafb | ||
|
|
aff7e49024 | ||
|
|
39b4649a04 | ||
|
|
ca8c7229ce | ||
|
|
4634284e77 | ||
|
|
e92fa789e9 | ||
|
|
d29b4e486d | ||
|
|
56eb0b8ef1 | ||
|
|
dcda5741f1 | ||
|
|
46dd19c326 | ||
|
|
5ef9ccb466 | ||
|
|
5fef1b3f30 | ||
|
|
5606da3449 | ||
|
|
844d500037 | ||
|
|
672a66695e | ||
|
|
125a89b5f9 | ||
|
|
c65c197fbe | ||
|
|
98b1302b77 | ||
|
|
e75afe6c41 | ||
|
|
361d02e075 | ||
|
|
1b20d3b6ac | ||
|
|
c4536d789b | ||
|
|
a7f8d9126e | ||
|
|
84e39add27 | ||
|
|
4d352b231c | ||
|
|
59eda04949 | ||
|
|
695cf24861 | ||
|
|
85d4dd9491 | ||
|
|
3a0fcd1517 | ||
|
|
e7e649ad66 | ||
|
|
b875a4898b | ||
|
|
a33cd35ae8 | ||
|
|
6e294d1363 | ||
|
|
7d7269bfe6 | ||
|
|
1306a5bca1 | ||
|
|
0dd45cdfa2 | ||
|
|
4a11ac917b | ||
|
|
460be03a20 | ||
|
|
9f3e5fea38 | ||
|
|
49b494ed02 | ||
|
|
c72559c31a | ||
|
|
2b8e189966 | ||
|
|
09e37f3951 | ||
|
|
c90359716b | ||
|
|
4a1ad1c625 | ||
|
|
27694036a5 | ||
|
|
ed40dc34cf | ||
|
|
af29b2833f | ||
|
|
0ee1f5c47f | ||
|
|
018eb2fdcd | ||
|
|
368a74dfc9 | ||
|
|
1a0475433c | ||
|
|
e841bfad68 | ||
|
|
5d3faba762 | ||
|
|
87cce116af | ||
|
|
356c97a4b2 | ||
|
|
dd6c20ce74 | ||
|
|
e939ffaf2d | ||
|
|
5a6f6fba2e | ||
|
|
99022055cf | ||
|
|
68030a4ae7 | ||
|
|
75ca9240a9 | ||
|
|
6d917b31e0 | ||
|
|
75e508bfd0 | ||
|
|
23136be280 | ||
|
|
527a0f5c70 | ||
|
|
9fbf9539ee | ||
|
|
dab69b2ffe | ||
|
|
7fdbebfb70 | ||
|
|
06ffe5cd06 | ||
|
|
56203c3ee2 | ||
|
|
4f5b562e04 | ||
|
|
e247753f96 | ||
|
|
575b5482b6 | ||
|
|
aa5a72b788 | ||
|
|
d8cb9f2c03 | ||
|
|
5241182520 | ||
|
|
61d8f2e1d4 | ||
|
|
a8031a510f | ||
|
|
c191060b73 | ||
|
|
bfe7cf0ed7 | ||
|
|
a4d72eefbc | ||
|
|
7b98105a0f | ||
|
|
e741dd6f65 | ||
|
|
9ef1c1935d | ||
|
|
43562580d6 | ||
|
|
986250543e | ||
|
|
90ed2f084d | ||
|
|
d353e186a5 | ||
|
|
a8b684d966 | ||
|
|
3ec70f9fb3 | ||
|
|
6199256058 | ||
|
|
265936a791 | ||
|
|
2422013ddf | ||
|
|
2641220fb0 | ||
|
|
68e1830d8e | ||
|
|
fd3f20ed52 | ||
|
|
ccdb136b9a | ||
|
|
0a0617c5fc | ||
|
|
b3e1c48f97 | ||
|
|
88d589bae5 | ||
|
|
0fb5cbdb06 | ||
|
|
d47da11ce8 | ||
|
|
743a4f97ba | ||
|
|
eac1247f36 | ||
|
|
57f60326f3 | ||
|
|
3235f6e388 | ||
|
|
a607a6a137 | ||
|
|
2348d4a855 | ||
|
|
e16f6c87c2 | ||
|
|
598962f5f3 | ||
|
|
8a241bb671 | ||
|
|
8bcb3d9e0e | ||
|
|
2317220666 | ||
|
|
47c1b58aa5 | ||
|
|
0039582f28 | ||
|
|
60a529375c | ||
|
|
d42bcb0ab9 | ||
|
|
4b11bcb77b | ||
|
|
6775edddab | ||
|
|
039a732148 | ||
|
|
9aac70c734 | ||
|
|
dc6c38cf24 | ||
|
|
a2b09cb2aa | ||
|
|
6e6453f897 | ||
|
|
f16de65934 | ||
|
|
fa0a5efb25 | ||
|
|
1ffb6b9395 | ||
|
|
16d746fb8d | ||
|
|
e8629fab66 | ||
|
|
9cb9719461 | ||
|
|
564f02b188 | ||
|
|
d67596117f | ||
|
|
ffecbb2298 | ||
|
|
b5fe2bcc60 | ||
|
|
7641d6dbdf | ||
|
|
54c5e3a8e3 | ||
|
|
d8427cdbcd | ||
|
|
fe03a12bec | ||
|
|
37fca3fc3e | ||
|
|
4dcdbdec3a | ||
|
|
564c79c411 | ||
|
|
ea46c78a15 | ||
|
|
93529cda60 | ||
|
|
13bf6a89cb | ||
|
|
468c69d2dd | ||
|
|
4ccfa8c3b6 | ||
|
|
b9a447453f | ||
|
|
3daf03d89a | ||
|
|
1a7d4c2c37 | ||
|
|
c7f612dac0 | ||
|
|
1a7aa1218a | ||
|
|
e530e30878 | ||
|
|
c5ef4df15a | ||
|
|
dba07c1832 | ||
|
|
d9d0f426e4 | ||
|
|
1b88d3d785 | ||
|
|
1e188fe737 | ||
|
|
335d4abbe1 | ||
|
|
1087d27523 | ||
|
|
f8f8b884bc | ||
|
|
c84c462aeb | ||
|
|
3ba4384c84 | ||
|
|
d4c72c34c3 | ||
|
|
60e950abcb | ||
|
|
6cb48e76a8 | ||
|
|
5e811b188b | ||
|
|
31320b4ab7 | ||
|
|
38e62a9c98 | ||
|
|
74e59fa47b | ||
|
|
80b1374a61 | ||
|
|
bd3e9d01ec | ||
|
|
f3e7d188f9 | ||
|
|
c45044b5c2 | ||
|
|
ac2dcee6c3 | ||
|
|
e72ea21b6b | ||
|
|
a46f57eaab | ||
|
|
843b5d7154 | ||
|
|
4f7d659700 | ||
|
|
0a195e0c11 | ||
|
|
9a9a21350e | ||
|
|
5a4cbc74f7 | ||
|
|
27e06ceb2c | ||
|
|
68f2640ceb | ||
|
|
cd9cf902bf | ||
|
|
03f3b4f8d3 | ||
|
|
6e430861d7 | ||
|
|
b7d658cff3 | ||
|
|
b1b85e7135 | ||
|
|
f28bdccd0f | ||
|
|
d2ea288009 | ||
|
|
e0a60e3ef3 | ||
|
|
563bf12de0 | ||
|
|
ef4037274d | ||
|
|
639294af2d | ||
|
|
9e51a1617f | ||
|
|
d317ac5236 | ||
|
|
42907b5a5d | ||
|
|
5d35fc80d5 | ||
|
|
11cab800e3 | ||
|
|
9272765f3c | ||
|
|
30e1d9552c | ||
|
|
1bafdf0feb | ||
|
|
1618d54b70 | ||
|
|
be6739ecb8 | ||
|
|
200e576ba8 | ||
|
|
ed6fe5631a | ||
|
|
b0ee9b27a1 | ||
|
|
eb0de84ce3 | ||
|
|
c52b3d27bc | ||
|
|
352adbc9cb | ||
|
|
c418683b3d | ||
|
|
5bd22f25b8 | ||
|
|
087ab3815f | ||
|
|
6af2055fd2 | ||
|
|
05e351be9c | ||
|
|
9bdcd6aace | ||
|
|
265807941a | ||
|
|
88b60ea945 | ||
|
|
f5854f9342 | ||
|
|
8ffe6fa8fb | ||
|
|
1d11585fcd | ||
|
|
b0d8b9a078 | ||
|
|
9f1b66fb91 | ||
|
|
55fde2d3fb | ||
|
|
649becb98e | ||
|
|
0b9ea265f0 | ||
|
|
3e92154e27 | ||
|
|
bdb86808a5 | ||
|
|
1993639bf6 | ||
|
|
90a5398e98 | ||
|
|
c5ab77b8ac | ||
|
|
7cd268bb4c | ||
|
|
036dc289d5 | ||
|
|
035f2a0236 | ||
|
|
86669fb6e8 | ||
|
|
5a2bb741a7 | ||
|
|
28e8a234e9 | ||
|
|
bd48e77e7c | ||
|
|
5b6f1182fe | ||
|
|
44d800de1e | ||
|
|
fc55622cc8 | ||
|
|
0e217e431b | ||
|
|
e4cbfcfedc | ||
|
|
ccd59278e5 | ||
|
|
a27bb66fef | ||
|
|
ef6036a7d0 | ||
|
|
b158ea9e78 | ||
|
|
fbc02881d7 | ||
|
|
4340d584c1 | ||
|
|
a4a8678116 | ||
|
|
ab4bee5d69 | ||
|
|
fad17c9cd2 | ||
|
|
e7f0ba1982 | ||
|
|
92bee965f0 | ||
|
|
dd4edb8ba5 | ||
|
|
b8f58b9cc7 | ||
|
|
f334b0137e | ||
|
|
e732c8ff6a | ||
|
|
60bb232d2a | ||
|
|
4f18f26935 | ||
|
|
7dc095b87a | ||
|
|
759780f10e | ||
|
|
77ff87a9c4 | ||
|
|
82d6719681 | ||
|
|
073998789c | ||
|
|
3f4347289c | ||
|
|
dc2a3cde47 | ||
|
|
252eebe5d8 | ||
|
|
bdd0da82e7 | ||
|
|
d144b9ba0b | ||
|
|
b201cf1990 | ||
|
|
286c4da2f3 | ||
|
|
959a5b5c70 | ||
|
|
607a7be337 | ||
|
|
3663b9f957 | ||
|
|
9aa6d1c0fc | ||
|
|
e6b59bc16d | ||
|
|
a478428721 | ||
|
|
8bb01a2412 | ||
|
|
4a98fb6c9d | ||
|
|
ea5dd69719 | ||
|
|
6d3a35517b | ||
|
|
9be6e12a5c | ||
|
|
e8addbc954 | ||
|
|
683becabda | ||
|
|
8c0cbfe93a | ||
|
|
57cb8d5bda | ||
|
|
0b583bcf80 | ||
|
|
9880248e49 | ||
|
|
20b715f7cb | ||
|
|
ed9ddc0825 | ||
|
|
5ab2bae5d7 | ||
|
|
8a2b69464f | ||
|
|
ff78830ead | ||
|
|
01fd89f60c | ||
|
|
44b6396b78 | ||
|
|
998e1b62a5 | ||
|
|
273f7c7a73 | ||
|
|
e9544bb610 | ||
|
|
fecf7f987d | ||
|
|
308395aa86 | ||
|
|
69218b6710 | ||
|
|
8bf7fcff28 | ||
|
|
416fbc093f | ||
|
|
2500fa54e4 | ||
|
|
ccc7a947cd | ||
|
|
83772bed42 | ||
|
|
7f3b7df710 | ||
|
|
39b7563d3a | ||
|
|
7b94d753b8 | ||
|
|
ab89d6a22f | ||
|
|
bff242dc99 | ||
|
|
ec452125e2 | ||
|
|
faa4ca33ad | ||
|
|
0b2284f163 | ||
|
|
b8c4d66160 | ||
|
|
4dfd033435 | ||
|
|
9ca8739514 | ||
|
|
1d8691fed8 | ||
|
|
522aec1d3a | ||
|
|
6153b25bc7 | ||
|
|
bb7e277f19 | ||
|
|
8a7bc3c17d | ||
|
|
af22751210 | ||
|
|
81f6ce26d4 | ||
|
|
633fea8c68 | ||
|
|
0c5855a82d | ||
|
|
c07b4e9f98 | ||
|
|
2407c3f2f8 | ||
|
|
d89371a279 | ||
|
|
86be84b015 | ||
|
|
da79b4e2ea | ||
|
|
e54f7d9c06 | ||
|
|
c0991e46ec | ||
|
|
ddd29529ea | ||
|
|
a1d6431348 | ||
|
|
31bd6a0c0d | ||
|
|
7f98aff531 | ||
|
|
948317c27a | ||
|
|
7406da66a7 | ||
|
|
8586ec67b6 | ||
|
|
991aaa8677 | ||
|
|
a4d1b5b972 | ||
|
|
887d355dea | ||
|
|
93866dc466 | ||
|
|
6c014e25b5 | ||
|
|
b1663c040f | ||
|
|
1f63b47500 | ||
|
|
ce0249f28e | ||
|
|
5d096092b9 | ||
|
|
a6b65c8d76 | ||
|
|
d3a4b0451d | ||
|
|
e0714637ff | ||
|
|
e777566339 | ||
|
|
185d0d8817 | ||
|
|
4132c0552f | ||
|
|
c158e74fb5 | ||
|
|
e5384509cf | ||
|
|
60324c041c | ||
|
|
5be89f3f31 | ||
|
|
4207330dcf | ||
|
|
05ab44d50b | ||
|
|
2a849c417f | ||
|
|
d5d7e9a952 | ||
|
|
f1e3210c7a | ||
|
|
cd07f29038 | ||
|
|
a7428838b3 | ||
|
|
58b00b6ed5 | ||
|
|
9d2544f8cb | ||
|
|
4f99743db7 | ||
|
|
e5d622780e | ||
|
|
905625d18e | ||
|
|
b529cc5691 | ||
|
|
aca279c951 | ||
|
|
086bb764a5 | ||
|
|
4304cad029 | ||
|
|
79e2bdb587 | ||
|
|
51d55eed05 | ||
|
|
ef5115b76c | ||
|
|
58a5aaed30 | ||
|
|
b6592582b3 | ||
|
|
7863660a47 | ||
|
|
ea3e7f9ace | ||
|
|
92e7ac7f20 | ||
|
|
75f6a93024 | ||
|
|
d679660e8a | ||
|
|
f3d87f09d7 | ||
|
|
71c90c6d31 | ||
|
|
3b76bb64a9 | ||
|
|
e5cdd9a7f1 | ||
|
|
121653a8f2 | ||
|
|
9d326d240a | ||
|
|
d92c96ecc2 | ||
|
|
aec5486144 | ||
|
|
773dd2fd1a | ||
|
|
36e5fec284 | ||
|
|
84e81e9ce0 | ||
|
|
0ecde9531e | ||
|
|
7d4b980e59 | ||
|
|
bccb4e154d | ||
|
|
45dd039c53 | ||
|
|
108499706a | ||
|
|
1ae1cebab6 | ||
|
|
77786af4d7 | ||
|
|
809959fde8 | ||
|
|
a47ea13a9b | ||
|
|
dddbcdf088 | ||
|
|
e1067aeb83 | ||
|
|
e5e46f3239 | ||
|
|
a28c08be99 | ||
|
|
279fcad10a | ||
|
|
7505d645eb | ||
|
|
5af98c5683 | ||
|
|
f8cb0caa80 | ||
|
|
e3747d3cfd | ||
|
|
ebe96c0dad | ||
|
|
bbd394b95e | ||
|
|
e1824ffda1 | ||
|
|
d42be730c3 | ||
|
|
a75817dde1 | ||
|
|
066fb7fba0 | ||
|
|
30dc6e865f | ||
|
|
ae5d0b282c | ||
|
|
a9ce316d28 | ||
|
|
6c28e270d2 | ||
|
|
72d4c7eb40 | ||
|
|
921e5912b3 | ||
|
|
aa168fab8c | ||
|
|
dffa357c0a | ||
|
|
7c6442d51f | ||
|
|
f995f6568c | ||
|
|
5b8d812fc8 | ||
|
|
27ce6ad5ba | ||
|
|
58dcb72adc | ||
|
|
202a7106a7 | ||
|
|
b8f79f6559 | ||
|
|
e491401ca0 | ||
|
|
89b236ae9e | ||
|
|
0566b30406 | ||
|
|
14e63bd47d | ||
|
|
1b2ce750ca | ||
|
|
17df8f23c5 | ||
|
|
eca3174214 | ||
|
|
5d7126f772 | ||
|
|
a82ba6503f | ||
|
|
cecbad2eb9 | ||
|
|
a97cb3df4f | ||
|
|
59f29eb6b4 | ||
|
|
ba9cb41d47 | ||
|
|
67a2ad708f | ||
|
|
e385e3cec8 | ||
|
|
6373478d13 | ||
|
|
7cc6dd03ff | ||
|
|
30ffc8cd11 | ||
|
|
b61a71b3b4 | ||
|
|
1c7a7f6edf | ||
|
|
5d410764e1 | ||
|
|
f645589cda | ||
|
|
b49c1e6e47 | ||
|
|
58558732be | ||
|
|
784ef277fc | ||
|
|
eb359f79cb | ||
|
|
31bf39d2e5 | ||
|
|
08159923d6 | ||
|
|
7b8b8d6b75 | ||
|
|
e52f5571a7 | ||
|
|
ea458935f0 | ||
|
|
64674026a6 | ||
|
|
ea71474b62 | ||
|
|
5d6348b83c | ||
|
|
199a26afbc | ||
|
|
c1971bffa8 | ||
|
|
51832005de | ||
|
|
9d5ae41c49 | ||
|
|
fa1d2416e0 | ||
|
|
c212bc294b | ||
|
|
ca21758889 | ||
|
|
75da6d4df1 | ||
|
|
0483bc0afe | ||
|
|
0e12c6906f | ||
|
|
1e633278dd | ||
|
|
554756851f | ||
|
|
ac8ac06c8a | ||
|
|
f6780fcb76 | ||
|
|
31c2ea888b | ||
|
|
2702c0f2e4 | ||
|
|
2aef5f94c0 | ||
|
|
a4b571ccbc | ||
|
|
fd561cd45d | ||
|
|
1357d817e6 | ||
|
|
ba2613d3c7 | ||
|
|
b2e1717dc3 | ||
|
|
ace5abea23 | ||
|
|
2ea1bd5e67 | ||
|
|
8ced379e44 | ||
|
|
f5ab7f3102 | ||
|
|
445ce46357 | ||
|
|
1b9c7d48e4 | ||
|
|
596c3368e0 | ||
|
|
3a699d34eb | ||
|
|
451eca0aa9 | ||
|
|
165517608d | ||
|
|
05eb0b20be | ||
|
|
c47526ce8e | ||
|
|
75d9bf458a | ||
|
|
3b90a58418 | ||
|
|
84e49a266d | ||
|
|
446430be4f | ||
|
|
e0a5ecc156 | ||
|
|
59e8ba2297 | ||
|
|
9f8caff571 | ||
|
|
f68c206a17 | ||
|
|
8c5fdd4673 | ||
|
|
c62be9573d | ||
|
|
c4d2e16433 | ||
|
|
ccf36f23c3 | ||
|
|
495dcd94d8 | ||
|
|
417a759c40 | ||
|
|
90846401a5 | ||
|
|
8e28c59163 | ||
|
|
a3eb0bb9fc | ||
|
|
9aac129aad | ||
|
|
9a6e3a80c7 | ||
|
|
7e45835424 | ||
|
|
58632b8da3 | ||
|
|
acaf95c017 | ||
|
|
1c3ad6a925 | ||
|
|
9bf49d8732 | ||
|
|
6895390f2b | ||
|
|
116831f6d9 | ||
|
|
51c401d6db | ||
|
|
b13bc0060b | ||
|
|
e68d573209 | ||
|
|
2d6f3db8fe | ||
|
|
1a68a60479 | ||
|
|
da55612726 | ||
|
|
1b88e132cc | ||
|
|
6179dbda8a | ||
|
|
2a7b2343b2 | ||
|
|
f7de416070 | ||
|
|
ead4b9e695 | ||
|
|
362adedae6 | ||
|
|
4d88c1f798 | ||
|
|
f664142094 | ||
|
|
0d533a71b6 | ||
|
|
d88a6c5db8 | ||
|
|
4379deaca2 | ||
|
|
67325fdb79 | ||
|
|
77b6239b16 | ||
|
|
248f2ca3c4 | ||
|
|
8b672a68e6 | ||
|
|
ce8127456c | ||
|
|
30185626a6 | ||
|
|
431eea9152 | ||
|
|
d53ec07857 | ||
|
|
2670a41545 | ||
|
|
4825b21951 | ||
|
|
ac2974d290 | ||
|
|
ad7a4503e0 | ||
|
|
4094034aaf | ||
|
|
11e74ef6cc | ||
|
|
1930b911b3 | ||
|
|
7e9417b186 | ||
|
|
c620a9388f | ||
|
|
0d55247dd9 | ||
|
|
9940e61fec | ||
|
|
feb4f77e39 | ||
|
|
d1925201ef | ||
|
|
7e9cea94f3 | ||
|
|
152b1bd24e | ||
|
|
5d6da6034d | ||
|
|
6ea203f6b9 | ||
|
|
79aabc6feb | ||
|
|
0ef5b017df | ||
|
|
8ab969688e | ||
|
|
7e5b94cc5f | ||
|
|
8cd02543bc | ||
|
|
6f68e8b2c7 | ||
|
|
e7baa90792 | ||
|
|
4199824275 | ||
|
|
fc2abb0f3c | ||
|
|
5b275e4170 | ||
|
|
a7e58b715b | ||
|
|
8b8d59065f | ||
|
|
ed0efec628 | ||
|
|
f8a40b8fb3 | ||
|
|
ef8d48846c | ||
|
|
8f973c8dc1 | ||
|
|
e1e47caf72 | ||
|
|
c2d7fe8612 | ||
|
|
93e02093be | ||
|
|
7934be70ee | ||
|
|
ec43d2012e | ||
|
|
e2c8b6ae02 | ||
|
|
4ce37da17e | ||
|
|
92ce6e5a8d | ||
|
|
fd16fd2890 | ||
|
|
9f66725b4a | ||
|
|
373d75609a | ||
|
|
00d4f7640e | ||
|
|
98a26a40b1 | ||
|
|
ba84ac56e9 | ||
|
|
05f501a66a |
32
.classpath
32
.classpath
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
34
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
34
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: Bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots or Video Recordings**
|
||||
If applicable, add screenshots or video recordings to help explain your problem.
|
||||
|
||||
**Server and Plugin Informations**
|
||||
- Installed plugins:
|
||||
- Iris Version:
|
||||
- Server Platform and Version [eg: PaperSpigot 1.16.3 #240]:
|
||||
- Operating System (if applicable):
|
||||
- Server Logs:
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here, server timings reports, Iris dump information, complete console log etc. Please do not make Pastebin dumps or screenshot expire.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: Enhancement, Addition
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
126
.gitignore
vendored
126
.gitignore
vendored
@@ -1,3 +1,125 @@
|
||||
/target/
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
|
||||
lib/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Package Files #
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
target/
|
||||
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
.flattened-pom.xml
|
||||
|
||||
# Common working directory
|
||||
run/
|
||||
|
||||
.gradle
|
||||
**/build/
|
||||
!src/**/build/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
# Custom folders
|
||||
release/
|
||||
23
.project
23
.project
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Iris</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,4 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
@@ -1,8 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -1,4 +0,0 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
97
Iris.iml
Normal file
97
Iris.iml
Normal file
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
<platformType>BUKKIT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: io.timeandspace:smoothie-map:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.timeandspace:jpsg-core:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.11.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.papermc:paperlib:1.0.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit.craftbukkit:1.16.3:1.16.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit.craftbukkit:1.16.4:1.16.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.bergerkiller.bukkit:BKCommonLib:1.16.4-v2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.2.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.2.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-default_2.13:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.13.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-http:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-spec:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-annotations:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:3.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-cio:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-io:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-services:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-logging:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.inject:javax.inject:1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.5.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.4.12" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.11" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:jcl-over-slf4j:1.7.28" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-odf:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zipdriver:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zip:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bouncycastle:bcprov-jdk15on:1.63" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-tardriver:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-bzip2:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-gzip:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-xz:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.tukaani:xz:1.8" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip-raes:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-base_2.13:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access-swing:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-file:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-jar:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-ibm437:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-impl_2.13:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-console:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-default:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-swing:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-macosx:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-spec:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-shed:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.dev.jna:jna:4.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mozilla:rhino-runtime:1.7.12" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:bukkit:7.2.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.8.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.lumine.xikage:MythicMobs:4.9.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.ben-manes.caffeine:caffeine:2.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.4.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.zeroturnaround:zt-zip:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.6.6" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
35
LICENSE.md
Normal file
35
LICENSE.md
Normal file
@@ -0,0 +1,35 @@
|
||||
VOLMIT SOFTWARE PUBLIC LICENSE
|
||||
|
||||
Version 1.2, 13 March 2021
|
||||
|
||||
Copyright :copyright: 2021 Andrew Baker
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions
|
||||
|
||||
"License" refers to this file. An updated version is available at <https://github.com/VolmitSoftware/Licenses>. The version at <https://github.com/VolmitSoftware/Licenses> is always correct and up-to-date.
|
||||
|
||||
"Author" refers to the person Andrew Baker <andrew@andrewcbaker.net>.
|
||||
|
||||
"Repository" refers to the location at which the software protected under this License is stored.
|
||||
|
||||
"Content" refers to the files and folders inside of the Repository.
|
||||
|
||||
"Copyright" refers to the laws on intellectual property and the legal rights automatically granted to the Author during the creation of the Content.
|
||||
|
||||
"Modify" refers to editing the Content as well as creating programs or code which depends on the Content to run.
|
||||
|
||||
"Compile" refers to the act of building the Content into an executable file such as a JAR file.
|
||||
|
||||
1. You may freely copy, Modify, distribute, create derivative works, or distribute derivative works of the Content as long as you obey the unmodified License that is supplied with the Content.
|
||||
|
||||
2. You may not copy, Modify, or distribute the Content in such a way that it will, directly or indirectly, generate revenue without explicit, written permission from the Author.
|
||||
|
||||
3. You may not host publicly available download links to Compiled versions of the Content unless you are using less than 5% of the original Content in a Repository of your own.
|
||||
|
||||
4. For any conditions not outlined in the License, refer to your country or state laws for Copyright.
|
||||
|
||||
5. If you do not agree to any of the above conditions you must delete the Content in its entirety as well as all copies of the Content and derivative works of the Content that you have made.
|
||||
|
||||
END TERMS AND CONDITIONS
|
||||
@@ -1,2 +1,3 @@
|
||||
# Iris
|
||||
World Generator
|
||||
# [Support](https://discord.gg/3xxPTpT) **|** [Documentation](https://docs.volmit.com/iris/) **|** [Git](https://github.com/IrisDimensions)
|
||||

|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>bytecode.ninja</groupId>
|
||||
<artifactId>Iris</artifactId>
|
||||
<name>Iris</name>
|
||||
<version>1.0</version>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.yml</include>
|
||||
<include>**/*.txt</include>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.html</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>runbatchfile</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<skip>${skip.copy}</skip>
|
||||
<executable>${project.basedir}/scripts/copy.bat</executable>
|
||||
<arguments>
|
||||
<argument>${project.basedir}\target\${project.name}-${project.version}.jar</argument>
|
||||
<argument>${development.location}</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>pub</id>
|
||||
<url>http://nexus.mpm.care/content/repositories/pub</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>volmit</id>
|
||||
<url>http://nexus.volmit.com/content/repositories/volmit</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.14.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<groupId>net.md-5</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cb</groupId>
|
||||
<artifactId>craftbukkit-1.14.4</artifactId>
|
||||
<version>1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/craftbukkit-1.14.4.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<development.location>${user.home}\Documents\development\server\plugins\${project.name}.jar</development.location>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
201
json/HTTP.java
Normal file
201
json/HTTP.java
Normal file
@@ -0,0 +1,201 @@
|
||||
package ninja.bytecode.shuriken.json;
|
||||
|
||||
|
||||
/*
|
||||
Copyright (c) 2002 JSON.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The Software shall be used for Good, not Evil.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Convert an HTTP header to a JSONObject and back.
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2014-05-03
|
||||
*/
|
||||
public class HTTP
|
||||
{
|
||||
|
||||
/** Carriage return/line feed. */
|
||||
public static final String CRLF = "\r\n";
|
||||
|
||||
/**
|
||||
* Convert an HTTP header string into a JSONObject. It can be a request
|
||||
* header or a response header. A request header will contain
|
||||
*
|
||||
* <pre>
|
||||
* {
|
||||
* Method: "POST" (for example),
|
||||
* "Request-URI": "/" (for example),
|
||||
* "HTTP-Version": "HTTP/1.1" (for example)
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* A response header will contain
|
||||
*
|
||||
* <pre>
|
||||
* {
|
||||
* "HTTP-Version": "HTTP/1.1" (for example),
|
||||
* "Status-Code": "200" (for example),
|
||||
* "Reason-Phrase": "OK" (for example)
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* In addition, the other parameters in the header will be captured, using
|
||||
* the HTTP field names as JSON names, so that
|
||||
*
|
||||
* <pre>
|
||||
* Date: Sun, 26 May 2002 18:06:04 GMT
|
||||
* Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
|
||||
* Cache-Control: no-cache
|
||||
* </pre>
|
||||
*
|
||||
* become
|
||||
*
|
||||
* <pre>
|
||||
* {...
|
||||
* Date: "Sun, 26 May 2002 18:06:04 GMT",
|
||||
* Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s",
|
||||
* "Cache-Control": "no-cache",
|
||||
* ...}
|
||||
* </pre>
|
||||
*
|
||||
* It does no further checking or conversion. It does not parse dates. It
|
||||
* does not do '%' transforms on URLs.
|
||||
*
|
||||
* @param string
|
||||
* An HTTP header string.
|
||||
* @return A JSONObject containing the elements and attributes of the XML
|
||||
* string.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static JSONObject toJSONObject(String string) throws JSONException
|
||||
{
|
||||
JSONObject jo = new JSONObject();
|
||||
HTTPTokener x = new HTTPTokener(string);
|
||||
String token;
|
||||
|
||||
token = x.nextToken();
|
||||
if(token.toUpperCase().startsWith("HTTP"))
|
||||
{
|
||||
|
||||
// Response
|
||||
|
||||
jo.put("HTTP-Version", token);
|
||||
jo.put("Status-Code", x.nextToken());
|
||||
jo.put("Reason-Phrase", x.nextTo('\0'));
|
||||
x.next();
|
||||
|
||||
} else
|
||||
{
|
||||
|
||||
// Request
|
||||
|
||||
jo.put("Method", token);
|
||||
jo.put("Request-URI", x.nextToken());
|
||||
jo.put("HTTP-Version", x.nextToken());
|
||||
}
|
||||
|
||||
// Fields
|
||||
|
||||
while(x.more())
|
||||
{
|
||||
String name = x.nextTo(':');
|
||||
x.next(':');
|
||||
jo.put(name, x.nextTo('\0'));
|
||||
x.next();
|
||||
}
|
||||
return jo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a JSONObject into an HTTP header. A request header must contain
|
||||
*
|
||||
* <pre>
|
||||
* {
|
||||
* Method: "POST" (for example),
|
||||
* "Request-URI": "/" (for example),
|
||||
* "HTTP-Version": "HTTP/1.1" (for example)
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* A response header must contain
|
||||
*
|
||||
* <pre>
|
||||
* {
|
||||
* "HTTP-Version": "HTTP/1.1" (for example),
|
||||
* "Status-Code": "200" (for example),
|
||||
* "Reason-Phrase": "OK" (for example)
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Any other members of the JSONObject will be output as HTTP fields. The
|
||||
* result will end with two CRLF pairs.
|
||||
*
|
||||
* @param jo
|
||||
* A JSONObject
|
||||
* @return An HTTP header string.
|
||||
* @throws JSONException
|
||||
* if the object does not contain enough information.
|
||||
*/
|
||||
public static String toString(JSONObject jo) throws JSONException
|
||||
{
|
||||
Iterator<String> keys = jo.keys();
|
||||
String string;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(jo.has("Status-Code") && jo.has("Reason-Phrase"))
|
||||
{
|
||||
sb.append(jo.getString("HTTP-Version"));
|
||||
sb.append(' ');
|
||||
sb.append(jo.getString("Status-Code"));
|
||||
sb.append(' ');
|
||||
sb.append(jo.getString("Reason-Phrase"));
|
||||
} else if(jo.has("Method") && jo.has("Request-URI"))
|
||||
{
|
||||
sb.append(jo.getString("Method"));
|
||||
sb.append(' ');
|
||||
sb.append('"');
|
||||
sb.append(jo.getString("Request-URI"));
|
||||
sb.append('"');
|
||||
sb.append(' ');
|
||||
sb.append(jo.getString("HTTP-Version"));
|
||||
} else
|
||||
{
|
||||
throw new JSONException("Not enough material for an HTTP header.");
|
||||
}
|
||||
sb.append(CRLF);
|
||||
while(keys.hasNext())
|
||||
{
|
||||
string = keys.next();
|
||||
if(!"HTTP-Version".equals(string) && !"Status-Code".equals(string) && !"Reason-Phrase".equals(string) && !"Method".equals(string) && !"Request-URI".equals(string) && !jo.isNull(string))
|
||||
{
|
||||
sb.append(string);
|
||||
sb.append(": ");
|
||||
sb.append(jo.getString(string));
|
||||
sb.append(CRLF);
|
||||
}
|
||||
}
|
||||
sb.append(CRLF);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
91
json/HTTPTokener.java
Normal file
91
json/HTTPTokener.java
Normal file
@@ -0,0 +1,91 @@
|
||||
package ninja.bytecode.shuriken.json;
|
||||
|
||||
|
||||
/*
|
||||
Copyright (c) 2002 JSON.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The Software shall be used for Good, not Evil.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The HTTPTokener extends the JSONTokener to provide additional methods for the
|
||||
* parsing of HTTP headers.
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2014-05-03
|
||||
*/
|
||||
public class HTTPTokener extends JSONTokener
|
||||
{
|
||||
|
||||
/**
|
||||
* Construct an HTTPTokener from a string.
|
||||
*
|
||||
* @param string
|
||||
* A source string.
|
||||
*/
|
||||
public HTTPTokener(String string)
|
||||
{
|
||||
super(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next token or string. This is used in parsing HTTP headers.
|
||||
*
|
||||
* @throws JSONException
|
||||
* @return A String.
|
||||
*/
|
||||
public String nextToken() throws JSONException
|
||||
{
|
||||
char c;
|
||||
char q;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
do
|
||||
{
|
||||
c = next();
|
||||
} while(Character.isWhitespace(c));
|
||||
if(c == '"' || c == '\'')
|
||||
{
|
||||
q = c;
|
||||
for(;;)
|
||||
{
|
||||
c = next();
|
||||
if(c < ' ')
|
||||
{
|
||||
throw syntaxError("Unterminated string.");
|
||||
}
|
||||
if(c == q)
|
||||
{
|
||||
return sb.toString();
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
for(;;)
|
||||
{
|
||||
if(c == 0 || Character.isWhitespace(c))
|
||||
{
|
||||
return sb.toString();
|
||||
}
|
||||
sb.append(c);
|
||||
c = next();
|
||||
}
|
||||
}
|
||||
}
|
||||
1252
json/JSONArray.java
Normal file
1252
json/JSONArray.java
Normal file
File diff suppressed because it is too large
Load Diff
50
json/JSONException.java
Normal file
50
json/JSONException.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package ninja.bytecode.shuriken.json;
|
||||
|
||||
|
||||
/**
|
||||
* The JSONException is thrown by the JSON.org classes when things are amiss.
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2014-05-03
|
||||
*/
|
||||
public class JSONException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 0;
|
||||
private Throwable cause;
|
||||
|
||||
/**
|
||||
* Constructs a JSONException with an explanatory message.
|
||||
*
|
||||
* @param message
|
||||
* Detail about the reason for the exception.
|
||||
*/
|
||||
public JSONException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new JSONException with the specified cause.
|
||||
*
|
||||
* @param cause
|
||||
* The cause.
|
||||
*/
|
||||
public JSONException(Throwable cause)
|
||||
{
|
||||
super(cause.getMessage());
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cause of this exception or null if the cause is nonexistent
|
||||
* or unknown.
|
||||
*
|
||||
* @return the cause of this exception or null if the cause is nonexistent
|
||||
* or unknown.
|
||||
*/
|
||||
@Override
|
||||
public Throwable getCause()
|
||||
{
|
||||
return this.cause;
|
||||
}
|
||||
}
|
||||
555
json/JSONML.java
Normal file
555
json/JSONML.java
Normal file
@@ -0,0 +1,555 @@
|
||||
package ninja.bytecode.shuriken.json;
|
||||
|
||||
|
||||
/*
|
||||
Copyright (c) 2008 JSON.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The Software shall be used for Good, not Evil.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* This provides static methods to convert an XML text into a JSONArray or
|
||||
* JSONObject, and to covert a JSONArray or JSONObject into an XML text using
|
||||
* the JsonML transform.
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2014-05-03
|
||||
*/
|
||||
public class JSONML
|
||||
{
|
||||
|
||||
/**
|
||||
* Parse XML values and store them in a JSONArray.
|
||||
*
|
||||
* @param x
|
||||
* The XMLTokener containing the source string.
|
||||
* @param arrayForm
|
||||
* true if array form, false if object form.
|
||||
* @param ja
|
||||
* The JSONArray that is containing the current tag or null if we
|
||||
* are at the outermost level.
|
||||
* @return A JSONArray if the value is the outermost tag, otherwise null.
|
||||
* @throws JSONException
|
||||
*/
|
||||
private static Object parse(XMLTokener x, boolean arrayForm, JSONArray ja) throws JSONException
|
||||
{
|
||||
String attribute;
|
||||
char c;
|
||||
String closeTag = null;
|
||||
int i;
|
||||
JSONArray newja = null;
|
||||
JSONObject newjo = null;
|
||||
Object token;
|
||||
String tagName = null;
|
||||
|
||||
// Test for and skip past these forms:
|
||||
// <!-- ... -->
|
||||
// <![ ... ]]>
|
||||
// <! ... >
|
||||
// <? ... ?>
|
||||
|
||||
while(true)
|
||||
{
|
||||
if(!x.more())
|
||||
{
|
||||
throw x.syntaxError("Bad XML");
|
||||
}
|
||||
token = x.nextContent();
|
||||
if(token == XML.LT)
|
||||
{
|
||||
token = x.nextToken();
|
||||
if(token instanceof Character)
|
||||
{
|
||||
if(token == XML.SLASH)
|
||||
{
|
||||
|
||||
// Close tag </
|
||||
|
||||
token = x.nextToken();
|
||||
if(!(token instanceof String))
|
||||
{
|
||||
throw new JSONException("Expected a closing name instead of '" + token + "'.");
|
||||
}
|
||||
if(x.nextToken() != XML.GT)
|
||||
{
|
||||
throw x.syntaxError("Misshaped close tag");
|
||||
}
|
||||
return token;
|
||||
} else if(token == XML.BANG)
|
||||
{
|
||||
|
||||
// <!
|
||||
|
||||
c = x.next();
|
||||
if(c == '-')
|
||||
{
|
||||
if(x.next() == '-')
|
||||
{
|
||||
x.skipPast("-->");
|
||||
} else
|
||||
{
|
||||
x.back();
|
||||
}
|
||||
} else if(c == '[')
|
||||
{
|
||||
token = x.nextToken();
|
||||
if(token.equals("CDATA") && x.next() == '[')
|
||||
{
|
||||
if(ja != null)
|
||||
{
|
||||
ja.put(x.nextCDATA());
|
||||
}
|
||||
} else
|
||||
{
|
||||
throw x.syntaxError("Expected 'CDATA['");
|
||||
}
|
||||
} else
|
||||
{
|
||||
i = 1;
|
||||
do
|
||||
{
|
||||
token = x.nextMeta();
|
||||
if(token == null)
|
||||
{
|
||||
throw x.syntaxError("Missing '>' after '<!'.");
|
||||
} else if(token == XML.LT)
|
||||
{
|
||||
i += 1;
|
||||
} else if(token == XML.GT)
|
||||
{
|
||||
i -= 1;
|
||||
}
|
||||
} while(i > 0);
|
||||
}
|
||||
} else if(token == XML.QUEST)
|
||||
{
|
||||
|
||||
// <?
|
||||
|
||||
x.skipPast("?>");
|
||||
} else
|
||||
{
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
|
||||
// Open tag <
|
||||
|
||||
} else
|
||||
{
|
||||
if(!(token instanceof String))
|
||||
{
|
||||
throw x.syntaxError("Bad tagName '" + token + "'.");
|
||||
}
|
||||
tagName = (String) token;
|
||||
newja = new JSONArray();
|
||||
newjo = new JSONObject();
|
||||
if(arrayForm)
|
||||
{
|
||||
newja.put(tagName);
|
||||
if(ja != null)
|
||||
{
|
||||
ja.put(newja);
|
||||
}
|
||||
} else
|
||||
{
|
||||
newjo.put("tagName", tagName);
|
||||
if(ja != null)
|
||||
{
|
||||
ja.put(newjo);
|
||||
}
|
||||
}
|
||||
token = null;
|
||||
for(;;)
|
||||
{
|
||||
if(token == null)
|
||||
{
|
||||
token = x.nextToken();
|
||||
}
|
||||
if(token == null)
|
||||
{
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
if(!(token instanceof String))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// attribute = value
|
||||
|
||||
attribute = (String) token;
|
||||
if(!arrayForm && ("tagName".equals(attribute) || "childNode".equals(attribute)))
|
||||
{
|
||||
throw x.syntaxError("Reserved attribute.");
|
||||
}
|
||||
token = x.nextToken();
|
||||
if(token == XML.EQ)
|
||||
{
|
||||
token = x.nextToken();
|
||||
if(!(token instanceof String))
|
||||
{
|
||||
throw x.syntaxError("Missing value");
|
||||
}
|
||||
newjo.accumulate(attribute, XML.stringToValue((String) token));
|
||||
token = null;
|
||||
} else
|
||||
{
|
||||
newjo.accumulate(attribute, "");
|
||||
}
|
||||
}
|
||||
if(arrayForm && newjo.length() > 0)
|
||||
{
|
||||
newja.put(newjo);
|
||||
}
|
||||
|
||||
// Empty tag <.../>
|
||||
|
||||
if(token == XML.SLASH)
|
||||
{
|
||||
if(x.nextToken() != XML.GT)
|
||||
{
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
if(ja == null)
|
||||
{
|
||||
if(arrayForm)
|
||||
{
|
||||
return newja;
|
||||
} else
|
||||
{
|
||||
return newjo;
|
||||
}
|
||||
}
|
||||
|
||||
// Content, between <...> and </...>
|
||||
|
||||
} else
|
||||
{
|
||||
if(token != XML.GT)
|
||||
{
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
closeTag = (String) parse(x, arrayForm, newja);
|
||||
if(closeTag != null)
|
||||
{
|
||||
if(!closeTag.equals(tagName))
|
||||
{
|
||||
throw x.syntaxError("Mismatched '" + tagName + "' and '" + closeTag + "'");
|
||||
}
|
||||
tagName = null;
|
||||
if(!arrayForm && newja.length() > 0)
|
||||
{
|
||||
newjo.put("childNodes", newja);
|
||||
}
|
||||
if(ja == null)
|
||||
{
|
||||
if(arrayForm)
|
||||
{
|
||||
return newja;
|
||||
} else
|
||||
{
|
||||
return newjo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if(ja != null)
|
||||
{
|
||||
ja.put(token instanceof String ? XML.stringToValue((String) token) : token);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a well-formed (but not necessarily valid) XML string into a
|
||||
* JSONArray using the JsonML transform. Each XML tag is represented as a
|
||||
* JSONArray in which the first element is the tag name. If the tag has
|
||||
* attributes, then the second element will be JSONObject containing the
|
||||
* name/value pairs. If the tag contains children, then strings and
|
||||
* JSONArrays will represent the child tags. Comments, prologs, DTDs, and
|
||||
* <code><[ [ ]]></code> are ignored.
|
||||
*
|
||||
* @param string
|
||||
* The source string.
|
||||
* @return A JSONArray containing the structured data from the XML string.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static JSONArray toJSONArray(String string) throws JSONException
|
||||
{
|
||||
return toJSONArray(new XMLTokener(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a well-formed (but not necessarily valid) XML string into a
|
||||
* JSONArray using the JsonML transform. Each XML tag is represented as a
|
||||
* JSONArray in which the first element is the tag name. If the tag has
|
||||
* attributes, then the second element will be JSONObject containing the
|
||||
* name/value pairs. If the tag contains children, then strings and
|
||||
* JSONArrays will represent the child content and tags. Comments, prologs,
|
||||
* DTDs, and <code><[ [ ]]></code> are ignored.
|
||||
*
|
||||
* @param x
|
||||
* An XMLTokener.
|
||||
* @return A JSONArray containing the structured data from the XML string.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static JSONArray toJSONArray(XMLTokener x) throws JSONException
|
||||
{
|
||||
return (JSONArray) parse(x, true, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a well-formed (but not necessarily valid) XML string into a
|
||||
* JSONObject using the JsonML transform. Each XML tag is represented as a
|
||||
* JSONObject with a "tagName" property. If the tag has attributes, then the
|
||||
* attributes will be in the JSONObject as properties. If the tag contains
|
||||
* children, the object will have a "childNodes" property which will be an
|
||||
* array of strings and JsonML JSONObjects.
|
||||
*
|
||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||
*
|
||||
* @param x
|
||||
* An XMLTokener of the XML source text.
|
||||
* @return A JSONObject containing the structured data from the XML string.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static JSONObject toJSONObject(XMLTokener x) throws JSONException
|
||||
{
|
||||
return (JSONObject) parse(x, false, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a well-formed (but not necessarily valid) XML string into a
|
||||
* JSONObject using the JsonML transform. Each XML tag is represented as a
|
||||
* JSONObject with a "tagName" property. If the tag has attributes, then the
|
||||
* attributes will be in the JSONObject as properties. If the tag contains
|
||||
* children, the object will have a "childNodes" property which will be an
|
||||
* array of strings and JsonML JSONObjects.
|
||||
*
|
||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||
*
|
||||
* @param string
|
||||
* The XML source text.
|
||||
* @return A JSONObject containing the structured data from the XML string.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static JSONObject toJSONObject(String string) throws JSONException
|
||||
{
|
||||
return toJSONObject(new XMLTokener(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the JSONML transformation, making an XML text from a JSONArray.
|
||||
*
|
||||
* @param ja
|
||||
* A JSONArray.
|
||||
* @return An XML string.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static String toString(JSONArray ja) throws JSONException
|
||||
{
|
||||
int i;
|
||||
JSONObject jo;
|
||||
String key;
|
||||
Iterator<String> keys;
|
||||
int length;
|
||||
Object object;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String tagName;
|
||||
String value;
|
||||
|
||||
// Emit <tagName
|
||||
|
||||
tagName = ja.getString(0);
|
||||
XML.noSpace(tagName);
|
||||
tagName = XML.escape(tagName);
|
||||
sb.append('<');
|
||||
sb.append(tagName);
|
||||
|
||||
object = ja.opt(1);
|
||||
if(object instanceof JSONObject)
|
||||
{
|
||||
i = 2;
|
||||
jo = (JSONObject) object;
|
||||
|
||||
// Emit the attributes
|
||||
|
||||
keys = jo.keys();
|
||||
while(keys.hasNext())
|
||||
{
|
||||
key = keys.next();
|
||||
XML.noSpace(key);
|
||||
value = jo.optString(key);
|
||||
if(value != null)
|
||||
{
|
||||
sb.append(' ');
|
||||
sb.append(XML.escape(key));
|
||||
sb.append('=');
|
||||
sb.append('"');
|
||||
sb.append(XML.escape(value));
|
||||
sb.append('"');
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
|
||||
// Emit content in body
|
||||
|
||||
length = ja.length();
|
||||
if(i >= length)
|
||||
{
|
||||
sb.append('/');
|
||||
sb.append('>');
|
||||
} else
|
||||
{
|
||||
sb.append('>');
|
||||
do
|
||||
{
|
||||
object = ja.get(i);
|
||||
i += 1;
|
||||
if(object != null)
|
||||
{
|
||||
if(object instanceof String)
|
||||
{
|
||||
sb.append(XML.escape(object.toString()));
|
||||
} else if(object instanceof JSONObject)
|
||||
{
|
||||
sb.append(toString((JSONObject) object));
|
||||
} else if(object instanceof JSONArray)
|
||||
{
|
||||
sb.append(toString((JSONArray) object));
|
||||
} else
|
||||
{
|
||||
sb.append(object.toString());
|
||||
}
|
||||
}
|
||||
} while(i < length);
|
||||
sb.append('<');
|
||||
sb.append('/');
|
||||
sb.append(tagName);
|
||||
sb.append('>');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the JSONML transformation, making an XML text from a JSONObject.
|
||||
* The JSONObject must contain a "tagName" property. If it has children,
|
||||
* then it must have a "childNodes" property containing an array of objects.
|
||||
* The other properties are attributes with string values.
|
||||
*
|
||||
* @param jo
|
||||
* A JSONObject.
|
||||
* @return An XML string.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static String toString(JSONObject jo) throws JSONException
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int i;
|
||||
JSONArray ja;
|
||||
String key;
|
||||
Iterator<String> keys;
|
||||
int length;
|
||||
Object object;
|
||||
String tagName;
|
||||
String value;
|
||||
|
||||
// Emit <tagName
|
||||
|
||||
tagName = jo.optString("tagName");
|
||||
if(tagName == null)
|
||||
{
|
||||
return XML.escape(jo.toString());
|
||||
}
|
||||
XML.noSpace(tagName);
|
||||
tagName = XML.escape(tagName);
|
||||
sb.append('<');
|
||||
sb.append(tagName);
|
||||
|
||||
// Emit the attributes
|
||||
|
||||
keys = jo.keys();
|
||||
while(keys.hasNext())
|
||||
{
|
||||
key = keys.next();
|
||||
if(!"tagName".equals(key) && !"childNodes".equals(key))
|
||||
{
|
||||
XML.noSpace(key);
|
||||
value = jo.optString(key);
|
||||
if(value != null)
|
||||
{
|
||||
sb.append(' ');
|
||||
sb.append(XML.escape(key));
|
||||
sb.append('=');
|
||||
sb.append('"');
|
||||
sb.append(XML.escape(value));
|
||||
sb.append('"');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Emit content in body
|
||||
|
||||
ja = jo.optJSONArray("childNodes");
|
||||
if(ja == null)
|
||||
{
|
||||
sb.append('/');
|
||||
sb.append('>');
|
||||
} else
|
||||
{
|
||||
sb.append('>');
|
||||
length = ja.length();
|
||||
for(i = 0; i < length; i += 1)
|
||||
{
|
||||
object = ja.get(i);
|
||||
if(object != null)
|
||||
{
|
||||
if(object instanceof String)
|
||||
{
|
||||
sb.append(XML.escape(object.toString()));
|
||||
} else if(object instanceof JSONObject)
|
||||
{
|
||||
sb.append(toString((JSONObject) object));
|
||||
} else if(object instanceof JSONArray)
|
||||
{
|
||||
sb.append(toString((JSONArray) object));
|
||||
} else
|
||||
{
|
||||
sb.append(object.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.append('<');
|
||||
sb.append('/');
|
||||
sb.append(tagName);
|
||||
sb.append('>');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
2072
json/JSONObject.java
Normal file
2072
json/JSONObject.java
Normal file
File diff suppressed because it is too large
Load Diff
21
json/JSONString.java
Normal file
21
json/JSONString.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package ninja.bytecode.shuriken.json;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>JSONString</code> interface allows a <code>toJSONString()</code>
|
||||
* method so that a class can change the behavior of
|
||||
* <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>, and
|
||||
* <code>JSONWriter.value(</code>Object<code>)</code>. The
|
||||
* <code>toJSONString</code> method will be used instead of the default behavior
|
||||
* of using the Object's <code>toString()</code> method and quoting the result.
|
||||
*/
|
||||
public interface JSONString
|
||||
{
|
||||
/**
|
||||
* The <code>toJSONString</code> method allows a class to produce its own
|
||||
* JSON serialization.
|
||||
*
|
||||
* @return A strictly syntactically correct JSON text.
|
||||
*/
|
||||
public String toJSONString();
|
||||
}
|
||||
86
json/JSONStringer.java
Normal file
86
json/JSONStringer.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package ninja.bytecode.shuriken.json;
|
||||
|
||||
|
||||
/*
|
||||
Copyright (c) 2006 JSON.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The Software shall be used for Good, not Evil.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* JSONStringer provides a quick and convenient way of producing JSON text. The
|
||||
* texts produced strictly conform to JSON syntax rules. No whitespace is added,
|
||||
* so the results are ready for transmission or storage. Each instance of
|
||||
* JSONStringer can produce one JSON text.
|
||||
* <p>
|
||||
* A JSONStringer instance provides a <code>value</code> method for appending
|
||||
* values to the text, and a <code>key</code> method for adding keys before
|
||||
* values in objects. There are <code>array</code> and <code>endArray</code>
|
||||
* methods that make and bound array values, and <code>object</code> and
|
||||
* <code>endObject</code> methods which make and bound object values. All of
|
||||
* these methods return the JSONWriter instance, permitting cascade style. For
|
||||
* example,
|
||||
*
|
||||
* <pre>
|
||||
* myString = new JSONStringer().object().key("JSON").value("Hello, World!").endObject().toString();
|
||||
* </pre>
|
||||
*
|
||||
* which produces the string
|
||||
*
|
||||
* <pre>
|
||||
* {"JSON":"Hello, World!"}
|
||||
* </pre>
|
||||
* <p>
|
||||
* The first method called must be <code>array</code> or <code>object</code>.
|
||||
* There are no methods for adding commas or colons. JSONStringer adds them for
|
||||
* you. Objects and arrays can be nested up to 20 levels deep.
|
||||
* <p>
|
||||
* This can sometimes be easier than using a JSONObject to build a string.
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2008-09-18
|
||||
*/
|
||||
public class JSONStringer extends JSONWriter
|
||||
{
|
||||
/**
|
||||
* Make a fresh JSONStringer. It can be used to build one JSON text.
|
||||
*/
|
||||
public JSONStringer()
|
||||
{
|
||||
super(new StringWriter());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the JSON text. This method is used to obtain the product of the
|
||||
* JSONStringer instance. It will return <code>null</code> if there was a
|
||||
* problem in the construction of the JSON text (such as the calls to
|
||||
* <code>array</code> were not properly balanced with calls to
|
||||
* <code>endArray</code>).
|
||||
*
|
||||
* @return The JSON text.
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return this.mode == 'd' ? this.writer.toString() : null;
|
||||
}
|
||||
}
|
||||
504
json/JSONTokener.java
Normal file
504
json/JSONTokener.java
Normal file
@@ -0,0 +1,504 @@
|
||||
package ninja.bytecode.shuriken.json;
|
||||
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
|
||||
/*
|
||||
Copyright (c) 2002 JSON.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The Software shall be used for Good, not Evil.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A JSONTokener takes a source string and extracts characters and tokens from
|
||||
* it. It is used by the JSONObject and JSONArray constructors to parse JSON
|
||||
* source strings.
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2014-05-03
|
||||
*/
|
||||
public class JSONTokener
|
||||
{
|
||||
|
||||
private long character;
|
||||
private boolean eof;
|
||||
private long index;
|
||||
private long line;
|
||||
private char previous;
|
||||
private Reader reader;
|
||||
private boolean usePrevious;
|
||||
|
||||
/**
|
||||
* Construct a JSONTokener from a Reader.
|
||||
*
|
||||
* @param reader
|
||||
* A reader.
|
||||
*/
|
||||
public JSONTokener(Reader reader)
|
||||
{
|
||||
this.reader = reader.markSupported() ? reader : new BufferedReader(reader);
|
||||
this.eof = false;
|
||||
this.usePrevious = false;
|
||||
this.previous = 0;
|
||||
this.index = 0;
|
||||
this.character = 1;
|
||||
this.line = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a JSONTokener from an InputStream.
|
||||
*
|
||||
* @param inputStream
|
||||
* The source.
|
||||
*/
|
||||
public JSONTokener(InputStream inputStream) throws JSONException
|
||||
{
|
||||
this(new InputStreamReader(inputStream));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a JSONTokener from a string.
|
||||
*
|
||||
* @param s
|
||||
* A source string.
|
||||
*/
|
||||
public JSONTokener(String s)
|
||||
{
|
||||
this(new StringReader(s));
|
||||
}
|
||||
|
||||
/**
|
||||
* Back up one character. This provides a sort of lookahead capability, so
|
||||
* that you can test for a digit or letter before attempting to parse the
|
||||
* next number or identifier.
|
||||
*/
|
||||
public void back() throws JSONException
|
||||
{
|
||||
if(this.usePrevious || this.index <= 0)
|
||||
{
|
||||
throw new JSONException("Stepping back two steps is not supported");
|
||||
}
|
||||
this.index -= 1;
|
||||
this.character -= 1;
|
||||
this.usePrevious = true;
|
||||
this.eof = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hex value of a character (base16).
|
||||
*
|
||||
* @param c
|
||||
* A character between '0' and '9' or between 'A' and 'F' or
|
||||
* between 'a' and 'f'.
|
||||
* @return An int between 0 and 15, or -1 if c was not a hex digit.
|
||||
*/
|
||||
public static int dehexchar(char c)
|
||||
{
|
||||
if(c >= '0' && c <= '9')
|
||||
{
|
||||
return c - '0';
|
||||
}
|
||||
if(c >= 'A' && c <= 'F')
|
||||
{
|
||||
return c - ('A' - 10);
|
||||
}
|
||||
if(c >= 'a' && c <= 'f')
|
||||
{
|
||||
return c - ('a' - 10);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean end()
|
||||
{
|
||||
return this.eof && !this.usePrevious;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the source string still contains characters that next() can
|
||||
* consume.
|
||||
*
|
||||
* @return true if not yet at the end of the source.
|
||||
*/
|
||||
public boolean more() throws JSONException
|
||||
{
|
||||
this.next();
|
||||
if(this.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.back();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next character in the source string.
|
||||
*
|
||||
* @return The next character, or 0 if past the end of the source string.
|
||||
*/
|
||||
public char next() throws JSONException
|
||||
{
|
||||
int c;
|
||||
if(this.usePrevious)
|
||||
{
|
||||
this.usePrevious = false;
|
||||
c = this.previous;
|
||||
} else
|
||||
{
|
||||
try
|
||||
{
|
||||
c = this.reader.read();
|
||||
} catch(IOException exception)
|
||||
{
|
||||
throw new JSONException(exception);
|
||||
}
|
||||
|
||||
if(c <= 0)
|
||||
{ // End of stream
|
||||
this.eof = true;
|
||||
c = 0;
|
||||
}
|
||||
}
|
||||
this.index += 1;
|
||||
if(this.previous == '\r')
|
||||
{
|
||||
this.line += 1;
|
||||
this.character = c == '\n' ? 0 : 1;
|
||||
} else if(c == '\n')
|
||||
{
|
||||
this.line += 1;
|
||||
this.character = 0;
|
||||
} else
|
||||
{
|
||||
this.character += 1;
|
||||
}
|
||||
this.previous = (char) c;
|
||||
return this.previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consume the next character, and check that it matches a specified
|
||||
* character.
|
||||
*
|
||||
* @param c
|
||||
* The character to match.
|
||||
* @return The character.
|
||||
* @throws JSONException
|
||||
* if the character does not match.
|
||||
*/
|
||||
public char next(char c) throws JSONException
|
||||
{
|
||||
char n = this.next();
|
||||
if(n != c)
|
||||
{
|
||||
throw this.syntaxError("Expected '" + c + "' and instead saw '" + n + "'");
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next n characters.
|
||||
*
|
||||
* @param n
|
||||
* The number of characters to take.
|
||||
* @return A string of n characters.
|
||||
* @throws JSONException
|
||||
* Substring bounds error if there are not n characters
|
||||
* remaining in the source string.
|
||||
*/
|
||||
public String next(int n) throws JSONException
|
||||
{
|
||||
if(n == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
char[] chars = new char[n];
|
||||
int pos = 0;
|
||||
|
||||
while(pos < n)
|
||||
{
|
||||
chars[pos] = this.next();
|
||||
if(this.end())
|
||||
{
|
||||
throw this.syntaxError("Substring bounds error");
|
||||
}
|
||||
pos += 1;
|
||||
}
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next char in the string, skipping whitespace.
|
||||
*
|
||||
* @throws JSONException
|
||||
* @return A character, or 0 if there are no more characters.
|
||||
*/
|
||||
public char nextClean() throws JSONException
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
char c = this.next();
|
||||
if(c == 0 || c > ' ')
|
||||
{
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the characters up to the next close quote character. Backslash
|
||||
* processing is done. The formal JSON format does not allow strings in
|
||||
* single quotes, but an implementation is allowed to accept them.
|
||||
*
|
||||
* @param quote
|
||||
* The quoting character, either <code>"</code>
|
||||
* <small>(double quote)</small> or <code>'</code>
|
||||
* <small>(single quote)</small>.
|
||||
* @return A String.
|
||||
* @throws JSONException
|
||||
* Unterminated string.
|
||||
*/
|
||||
public String nextString(char quote) throws JSONException
|
||||
{
|
||||
char c;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(;;)
|
||||
{
|
||||
c = this.next();
|
||||
switch(c)
|
||||
{
|
||||
case 0:
|
||||
case '\n':
|
||||
case '\r':
|
||||
throw this.syntaxError("Unterminated string");
|
||||
case '\\':
|
||||
c = this.next();
|
||||
switch(c)
|
||||
{
|
||||
case 'b':
|
||||
sb.append('\b');
|
||||
break;
|
||||
case 't':
|
||||
sb.append('\t');
|
||||
break;
|
||||
case 'n':
|
||||
sb.append('\n');
|
||||
break;
|
||||
case 'f':
|
||||
sb.append('\f');
|
||||
break;
|
||||
case 'r':
|
||||
sb.append('\r');
|
||||
break;
|
||||
case 'u':
|
||||
sb.append((char) Integer.parseInt(this.next(4), 16));
|
||||
break;
|
||||
case '"':
|
||||
case '\'':
|
||||
case '\\':
|
||||
case '/':
|
||||
sb.append(c);
|
||||
break;
|
||||
default:
|
||||
throw this.syntaxError("Illegal escape.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(c == quote)
|
||||
{
|
||||
return sb.toString();
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text up but not including the specified character or the end of
|
||||
* line, whichever comes first.
|
||||
*
|
||||
* @param delimiter
|
||||
* A delimiter character.
|
||||
* @return A string.
|
||||
*/
|
||||
public String nextTo(char delimiter) throws JSONException
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(;;)
|
||||
{
|
||||
char c = this.next();
|
||||
if(c == delimiter || c == 0 || c == '\n' || c == '\r')
|
||||
{
|
||||
if(c != 0)
|
||||
{
|
||||
this.back();
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text up but not including one of the specified delimiter
|
||||
* characters or the end of line, whichever comes first.
|
||||
*
|
||||
* @param delimiters
|
||||
* A set of delimiter characters.
|
||||
* @return A string, trimmed.
|
||||
*/
|
||||
public String nextTo(String delimiters) throws JSONException
|
||||
{
|
||||
char c;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(;;)
|
||||
{
|
||||
c = this.next();
|
||||
if(delimiters.indexOf(c) >= 0 || c == 0 || c == '\n' || c == '\r')
|
||||
{
|
||||
if(c != 0)
|
||||
{
|
||||
this.back();
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next value. The value can be a Boolean, Double, Integer,
|
||||
* JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
|
||||
*
|
||||
* @throws JSONException
|
||||
* If syntax error.
|
||||
*
|
||||
* @return An object.
|
||||
*/
|
||||
public Object nextValue() throws JSONException
|
||||
{
|
||||
char c = this.nextClean();
|
||||
String string;
|
||||
|
||||
switch(c)
|
||||
{
|
||||
case '"':
|
||||
case '\'':
|
||||
return this.nextString(c);
|
||||
case '{':
|
||||
this.back();
|
||||
return new JSONObject(this);
|
||||
case '[':
|
||||
this.back();
|
||||
return new JSONArray(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle unquoted text. This could be the values true, false, or null,
|
||||
* or it can be a number. An implementation (such as this one) is
|
||||
* allowed to also accept non-standard forms.
|
||||
*
|
||||
* Accumulate characters until we reach the end of the text or a
|
||||
* formatting character.
|
||||
*/
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while(c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0)
|
||||
{
|
||||
sb.append(c);
|
||||
c = this.next();
|
||||
}
|
||||
this.back();
|
||||
|
||||
string = sb.toString().trim();
|
||||
if("".equals(string))
|
||||
{
|
||||
throw this.syntaxError("Missing value");
|
||||
}
|
||||
return JSONObject.stringToValue(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip characters until the next character is the requested character. If
|
||||
* the requested character is not found, no characters are skipped.
|
||||
*
|
||||
* @param to
|
||||
* A character to skip to.
|
||||
* @return The requested character, or zero if the requested character is
|
||||
* not found.
|
||||
*/
|
||||
public char skipTo(char to) throws JSONException
|
||||
{
|
||||
char c;
|
||||
try
|
||||
{
|
||||
long startIndex = this.index;
|
||||
long startCharacter = this.character;
|
||||
long startLine = this.line;
|
||||
this.reader.mark(1000000);
|
||||
do
|
||||
{
|
||||
c = this.next();
|
||||
if(c == 0)
|
||||
{
|
||||
this.reader.reset();
|
||||
this.index = startIndex;
|
||||
this.character = startCharacter;
|
||||
this.line = startLine;
|
||||
return c;
|
||||
}
|
||||
} while(c != to);
|
||||
} catch(IOException exception)
|
||||
{
|
||||
throw new JSONException(exception);
|
||||
}
|
||||
this.back();
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a JSONException to signal a syntax error.
|
||||
*
|
||||
* @param message
|
||||
* The error message.
|
||||
* @return A JSONException object, suitable for throwing
|
||||
*/
|
||||
public JSONException syntaxError(String message)
|
||||
{
|
||||
return new JSONException(message + this.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a printable string of this JSONTokener.
|
||||
*
|
||||
* @return " at {index} [character {character} line {line}]"
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return " at " + this.index + " [character " + this.character + " line " + this.line + "]";
|
||||
}
|
||||
}
|
||||
388
json/JSONWriter.java
Normal file
388
json/JSONWriter.java
Normal file
@@ -0,0 +1,388 @@
|
||||
package ninja.bytecode.shuriken.json;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/*
|
||||
Copyright (c) 2006 JSON.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The Software shall be used for Good, not Evil.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JSONWriter provides a quick and convenient way of producing JSON text. The
|
||||
* texts produced strictly conform to JSON syntax rules. No whitespace is added,
|
||||
* so the results are ready for transmission or storage. Each instance of
|
||||
* JSONWriter can produce one JSON text.
|
||||
* <p>
|
||||
* A JSONWriter instance provides a <code>value</code> method for appending
|
||||
* values to the text, and a <code>key</code> method for adding keys before
|
||||
* values in objects. There are <code>array</code> and <code>endArray</code>
|
||||
* methods that make and bound array values, and <code>object</code> and
|
||||
* <code>endObject</code> methods which make and bound object values. All of
|
||||
* these methods return the JSONWriter instance, permitting a cascade style. For
|
||||
* example,
|
||||
*
|
||||
* <pre>
|
||||
* new JSONWriter(myWriter).object().key("JSON").value("Hello, World!").endObject();
|
||||
* </pre>
|
||||
*
|
||||
* which writes
|
||||
*
|
||||
* <pre>
|
||||
* {"JSON":"Hello, World!"}
|
||||
* </pre>
|
||||
* <p>
|
||||
* The first method called must be <code>array</code> or <code>object</code>.
|
||||
* There are no methods for adding commas or colons. JSONWriter adds them for
|
||||
* you. Objects and arrays can be nested up to 20 levels deep.
|
||||
* <p>
|
||||
* This can sometimes be easier than using a JSONObject to build a string.
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2011-11-24
|
||||
*/
|
||||
public class JSONWriter
|
||||
{
|
||||
private static final int maxdepth = 200;
|
||||
|
||||
/**
|
||||
* The comma flag determines if a comma should be output before the next
|
||||
* value.
|
||||
*/
|
||||
private boolean comma;
|
||||
|
||||
/**
|
||||
* The current mode. Values: 'a' (array), 'd' (done), 'i' (initial), 'k'
|
||||
* (key), 'o' (object).
|
||||
*/
|
||||
protected char mode;
|
||||
|
||||
/**
|
||||
* The object/array stack.
|
||||
*/
|
||||
private final JSONObject stack[];
|
||||
|
||||
/**
|
||||
* The stack top index. A value of 0 indicates that the stack is empty.
|
||||
*/
|
||||
private int top;
|
||||
|
||||
/**
|
||||
* The writer that will receive the output.
|
||||
*/
|
||||
protected Writer writer;
|
||||
|
||||
/**
|
||||
* Make a fresh JSONWriter. It can be used to build one JSON text.
|
||||
*/
|
||||
public JSONWriter(Writer w)
|
||||
{
|
||||
this.comma = false;
|
||||
this.mode = 'i';
|
||||
this.stack = new JSONObject[maxdepth];
|
||||
this.top = 0;
|
||||
this.writer = w;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a value.
|
||||
*
|
||||
* @param string
|
||||
* A string value.
|
||||
* @return this
|
||||
* @throws JSONException
|
||||
* If the value is out of sequence.
|
||||
*/
|
||||
private JSONWriter append(String string) throws JSONException
|
||||
{
|
||||
if(string == null)
|
||||
{
|
||||
throw new JSONException("Null pointer");
|
||||
}
|
||||
if(this.mode == 'o' || this.mode == 'a')
|
||||
{
|
||||
try
|
||||
{
|
||||
if(this.comma && this.mode == 'a')
|
||||
{
|
||||
this.writer.write(',');
|
||||
}
|
||||
this.writer.write(string);
|
||||
} catch(IOException e)
|
||||
{
|
||||
throw new JSONException(e);
|
||||
}
|
||||
if(this.mode == 'o')
|
||||
{
|
||||
this.mode = 'k';
|
||||
}
|
||||
this.comma = true;
|
||||
return this;
|
||||
}
|
||||
throw new JSONException("Value out of sequence.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin appending a new array. All values until the balancing
|
||||
* <code>endArray</code> will be appended to this array. The
|
||||
* <code>endArray</code> method must be called to mark the array's end.
|
||||
*
|
||||
* @return this
|
||||
* @throws JSONException
|
||||
* If the nesting is too deep, or if the object is started in
|
||||
* the wrong place (for example as a key or after the end of the
|
||||
* outermost array or object).
|
||||
*/
|
||||
public JSONWriter array() throws JSONException
|
||||
{
|
||||
if(this.mode == 'i' || this.mode == 'o' || this.mode == 'a')
|
||||
{
|
||||
this.push(null);
|
||||
this.append("[");
|
||||
this.comma = false;
|
||||
return this;
|
||||
}
|
||||
throw new JSONException("Misplaced array.");
|
||||
}
|
||||
|
||||
/**
|
||||
* End something.
|
||||
*
|
||||
* @param mode
|
||||
* Mode
|
||||
* @param c
|
||||
* Closing character
|
||||
* @return this
|
||||
* @throws JSONException
|
||||
* If unbalanced.
|
||||
*/
|
||||
private JSONWriter end(char mode, char c) throws JSONException
|
||||
{
|
||||
if(this.mode != mode)
|
||||
{
|
||||
throw new JSONException(mode == 'a' ? "Misplaced endArray." : "Misplaced endObject.");
|
||||
}
|
||||
this.pop(mode);
|
||||
try
|
||||
{
|
||||
this.writer.write(c);
|
||||
} catch(IOException e)
|
||||
{
|
||||
throw new JSONException(e);
|
||||
}
|
||||
this.comma = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* End an array. This method most be called to balance calls to
|
||||
* <code>array</code>.
|
||||
*
|
||||
* @return this
|
||||
* @throws JSONException
|
||||
* If incorrectly nested.
|
||||
*/
|
||||
public JSONWriter endArray() throws JSONException
|
||||
{
|
||||
return this.end('a', ']');
|
||||
}
|
||||
|
||||
/**
|
||||
* End an object. This method most be called to balance calls to
|
||||
* <code>object</code>.
|
||||
*
|
||||
* @return this
|
||||
* @throws JSONException
|
||||
* If incorrectly nested.
|
||||
*/
|
||||
public JSONWriter endObject() throws JSONException
|
||||
{
|
||||
return this.end('k', '}');
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a key. The key will be associated with the next value. In an
|
||||
* object, every value must be preceded by a key.
|
||||
*
|
||||
* @param string
|
||||
* A key string.
|
||||
* @return this
|
||||
* @throws JSONException
|
||||
* If the key is out of place. For example, keys do not belong
|
||||
* in arrays or if the key is null.
|
||||
*/
|
||||
public JSONWriter key(String string) throws JSONException
|
||||
{
|
||||
if(string == null)
|
||||
{
|
||||
throw new JSONException("Null key.");
|
||||
}
|
||||
if(this.mode == 'k')
|
||||
{
|
||||
try
|
||||
{
|
||||
this.stack[this.top - 1].putOnce(string, Boolean.TRUE);
|
||||
if(this.comma)
|
||||
{
|
||||
this.writer.write(',');
|
||||
}
|
||||
this.writer.write(JSONObject.quote(string));
|
||||
this.writer.write(':');
|
||||
this.comma = false;
|
||||
this.mode = 'o';
|
||||
return this;
|
||||
} catch(IOException e)
|
||||
{
|
||||
throw new JSONException(e);
|
||||
}
|
||||
}
|
||||
throw new JSONException("Misplaced key.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin appending a new object. All keys and values until the balancing
|
||||
* <code>endObject</code> will be appended to this object. The
|
||||
* <code>endObject</code> method must be called to mark the object's end.
|
||||
*
|
||||
* @return this
|
||||
* @throws JSONException
|
||||
* If the nesting is too deep, or if the object is started in
|
||||
* the wrong place (for example as a key or after the end of the
|
||||
* outermost array or object).
|
||||
*/
|
||||
public JSONWriter object() throws JSONException
|
||||
{
|
||||
if(this.mode == 'i')
|
||||
{
|
||||
this.mode = 'o';
|
||||
}
|
||||
if(this.mode == 'o' || this.mode == 'a')
|
||||
{
|
||||
this.append("{");
|
||||
this.push(new JSONObject());
|
||||
this.comma = false;
|
||||
return this;
|
||||
}
|
||||
throw new JSONException("Misplaced object.");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop an array or object scope.
|
||||
*
|
||||
* @param c
|
||||
* The scope to close.
|
||||
* @throws JSONException
|
||||
* If nesting is wrong.
|
||||
*/
|
||||
private void pop(char c) throws JSONException
|
||||
{
|
||||
if(this.top <= 0)
|
||||
{
|
||||
throw new JSONException("Nesting error.");
|
||||
}
|
||||
char m = this.stack[this.top - 1] == null ? 'a' : 'k';
|
||||
if(m != c)
|
||||
{
|
||||
throw new JSONException("Nesting error.");
|
||||
}
|
||||
this.top -= 1;
|
||||
this.mode = this.top == 0 ? 'd' : this.stack[this.top - 1] == null ? 'a' : 'k';
|
||||
}
|
||||
|
||||
/**
|
||||
* Push an array or object scope.
|
||||
*
|
||||
* @param jo
|
||||
* The scope to open.
|
||||
* @throws JSONException
|
||||
* If nesting is too deep.
|
||||
*/
|
||||
private void push(JSONObject jo) throws JSONException
|
||||
{
|
||||
if(this.top >= maxdepth)
|
||||
{
|
||||
throw new JSONException("Nesting too deep.");
|
||||
}
|
||||
this.stack[this.top] = jo;
|
||||
this.mode = jo == null ? 'a' : 'k';
|
||||
this.top += 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append either the value <code>true</code> or the value <code>false</code>
|
||||
* .
|
||||
*
|
||||
* @param b
|
||||
* A boolean.
|
||||
* @return this
|
||||
* @throws JSONException
|
||||
*/
|
||||
public JSONWriter value(boolean b) throws JSONException
|
||||
{
|
||||
return this.append(b ? "true" : "false");
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a double value.
|
||||
*
|
||||
* @param d
|
||||
* A double.
|
||||
* @return this
|
||||
* @throws JSONException
|
||||
* If the number is not finite.
|
||||
*/
|
||||
public JSONWriter value(double d) throws JSONException
|
||||
{
|
||||
return this.value(new Double(d));
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a long value.
|
||||
*
|
||||
* @param l
|
||||
* A long.
|
||||
* @return this
|
||||
* @throws JSONException
|
||||
*/
|
||||
public JSONWriter value(long l) throws JSONException
|
||||
{
|
||||
return this.append(Long.toString(l));
|
||||
}
|
||||
|
||||
/**
|
||||
* Append an object value.
|
||||
*
|
||||
* @param object
|
||||
* The object to append. It can be null, or a Boolean, Number,
|
||||
* String, JSONObject, or JSONArray, or an object that implements
|
||||
* JSONString.
|
||||
* @return this
|
||||
* @throws JSONException
|
||||
* If the value is out of sequence.
|
||||
*/
|
||||
public JSONWriter value(Object object) throws JSONException
|
||||
{
|
||||
return this.append(JSONObject.valueToString(object));
|
||||
}
|
||||
}
|
||||
584
json/XML.java
Normal file
584
json/XML.java
Normal file
@@ -0,0 +1,584 @@
|
||||
package ninja.bytecode.shuriken.json;
|
||||
|
||||
|
||||
/*
|
||||
Copyright (c) 2002 JSON.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The Software shall be used for Good, not Evil.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* This provides static methods to convert an XML text into a JSONObject, and to
|
||||
* covert a JSONObject into an XML text.
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2014-05-03
|
||||
*/
|
||||
public class XML
|
||||
{
|
||||
|
||||
/** The Character '&'. */
|
||||
public static final Character AMP = '&';
|
||||
|
||||
/** The Character '''. */
|
||||
public static final Character APOS = '\'';
|
||||
|
||||
/** The Character '!'. */
|
||||
public static final Character BANG = '!';
|
||||
|
||||
/** The Character '='. */
|
||||
public static final Character EQ = '=';
|
||||
|
||||
/** The Character '>'. */
|
||||
public static final Character GT = '>';
|
||||
|
||||
/** The Character '<'. */
|
||||
public static final Character LT = '<';
|
||||
|
||||
/** The Character '?'. */
|
||||
public static final Character QUEST = '?';
|
||||
|
||||
/** The Character '"'. */
|
||||
public static final Character QUOT = '"';
|
||||
|
||||
/** The Character '/'. */
|
||||
public static final Character SLASH = '/';
|
||||
|
||||
/**
|
||||
* Replace special characters with XML escapes:
|
||||
*
|
||||
* <pre>
|
||||
* & <small>(ampersand)</small> is replaced by &amp;
|
||||
* < <small>(less than)</small> is replaced by &lt;
|
||||
* > <small>(greater than)</small> is replaced by &gt;
|
||||
* " <small>(double quote)</small> is replaced by &quot;
|
||||
* </pre>
|
||||
*
|
||||
* @param string
|
||||
* The string to be escaped.
|
||||
* @return The escaped string.
|
||||
*/
|
||||
public static String escape(String string)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(string.length());
|
||||
for(int i = 0, length = string.length(); i < length; i++)
|
||||
{
|
||||
char c = string.charAt(i);
|
||||
switch(c)
|
||||
{
|
||||
case '&':
|
||||
sb.append("&");
|
||||
break;
|
||||
case '<':
|
||||
sb.append("<");
|
||||
break;
|
||||
case '>':
|
||||
sb.append(">");
|
||||
break;
|
||||
case '"':
|
||||
sb.append(""");
|
||||
break;
|
||||
case '\'':
|
||||
sb.append("'");
|
||||
break;
|
||||
default:
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an exception if the string contains whitespace. Whitespace is not
|
||||
* allowed in tagNames and attributes.
|
||||
*
|
||||
* @param string
|
||||
* A string.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static void noSpace(String string) throws JSONException
|
||||
{
|
||||
int i, length = string.length();
|
||||
if(length == 0)
|
||||
{
|
||||
throw new JSONException("Empty string.");
|
||||
}
|
||||
for(i = 0; i < length; i += 1)
|
||||
{
|
||||
if(Character.isWhitespace(string.charAt(i)))
|
||||
{
|
||||
throw new JSONException("'" + string + "' contains a space character.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan the content following the named tag, attaching it to the context.
|
||||
*
|
||||
* @param x
|
||||
* The XMLTokener containing the source string.
|
||||
* @param context
|
||||
* The JSONObject that will include the new material.
|
||||
* @param name
|
||||
* The tag name.
|
||||
* @return true if the close tag is processed.
|
||||
* @throws JSONException
|
||||
*/
|
||||
private static boolean parse(XMLTokener x, JSONObject context, String name) throws JSONException
|
||||
{
|
||||
char c;
|
||||
int i;
|
||||
JSONObject jsonobject = null;
|
||||
String string;
|
||||
String tagName;
|
||||
Object token;
|
||||
|
||||
// Test for and skip past these forms:
|
||||
// <!-- ... -->
|
||||
// <! ... >
|
||||
// <![ ... ]]>
|
||||
// <? ... ?>
|
||||
// Report errors for these forms:
|
||||
// <>
|
||||
// <=
|
||||
// <<
|
||||
|
||||
token = x.nextToken();
|
||||
|
||||
// <!
|
||||
|
||||
if(token == BANG)
|
||||
{
|
||||
c = x.next();
|
||||
if(c == '-')
|
||||
{
|
||||
if(x.next() == '-')
|
||||
{
|
||||
x.skipPast("-->");
|
||||
return false;
|
||||
}
|
||||
x.back();
|
||||
} else if(c == '[')
|
||||
{
|
||||
token = x.nextToken();
|
||||
if("CDATA".equals(token))
|
||||
{
|
||||
if(x.next() == '[')
|
||||
{
|
||||
string = x.nextCDATA();
|
||||
if(string.length() > 0)
|
||||
{
|
||||
context.accumulate("content", string);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
throw x.syntaxError("Expected 'CDATA['");
|
||||
}
|
||||
i = 1;
|
||||
do
|
||||
{
|
||||
token = x.nextMeta();
|
||||
if(token == null)
|
||||
{
|
||||
throw x.syntaxError("Missing '>' after '<!'.");
|
||||
} else if(token == LT)
|
||||
{
|
||||
i += 1;
|
||||
} else if(token == GT)
|
||||
{
|
||||
i -= 1;
|
||||
}
|
||||
} while(i > 0);
|
||||
return false;
|
||||
} else if(token == QUEST)
|
||||
{
|
||||
|
||||
// <?
|
||||
|
||||
x.skipPast("?>");
|
||||
return false;
|
||||
} else if(token == SLASH)
|
||||
{
|
||||
|
||||
// Close tag </
|
||||
|
||||
token = x.nextToken();
|
||||
if(name == null)
|
||||
{
|
||||
throw x.syntaxError("Mismatched close tag " + token);
|
||||
}
|
||||
if(!token.equals(name))
|
||||
{
|
||||
throw x.syntaxError("Mismatched " + name + " and " + token);
|
||||
}
|
||||
if(x.nextToken() != GT)
|
||||
{
|
||||
throw x.syntaxError("Misshaped close tag");
|
||||
}
|
||||
return true;
|
||||
|
||||
} else if(token instanceof Character)
|
||||
{
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
|
||||
// Open tag <
|
||||
|
||||
} else
|
||||
{
|
||||
tagName = (String) token;
|
||||
token = null;
|
||||
jsonobject = new JSONObject();
|
||||
for(;;)
|
||||
{
|
||||
if(token == null)
|
||||
{
|
||||
token = x.nextToken();
|
||||
}
|
||||
|
||||
// attribute = value
|
||||
|
||||
if(token instanceof String)
|
||||
{
|
||||
string = (String) token;
|
||||
token = x.nextToken();
|
||||
if(token == EQ)
|
||||
{
|
||||
token = x.nextToken();
|
||||
if(!(token instanceof String))
|
||||
{
|
||||
throw x.syntaxError("Missing value");
|
||||
}
|
||||
jsonobject.accumulate(string, XML.stringToValue((String) token));
|
||||
token = null;
|
||||
} else
|
||||
{
|
||||
jsonobject.accumulate(string, "");
|
||||
}
|
||||
|
||||
// Empty tag <.../>
|
||||
|
||||
} else if(token == SLASH)
|
||||
{
|
||||
if(x.nextToken() != GT)
|
||||
{
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
if(jsonobject.length() > 0)
|
||||
{
|
||||
context.accumulate(tagName, jsonobject);
|
||||
} else
|
||||
{
|
||||
context.accumulate(tagName, "");
|
||||
}
|
||||
return false;
|
||||
|
||||
// Content, between <...> and </...>
|
||||
|
||||
} else if(token == GT)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
token = x.nextContent();
|
||||
if(token == null)
|
||||
{
|
||||
if(tagName != null)
|
||||
{
|
||||
throw x.syntaxError("Unclosed tag " + tagName);
|
||||
}
|
||||
return false;
|
||||
} else if(token instanceof String)
|
||||
{
|
||||
string = (String) token;
|
||||
if(string.length() > 0)
|
||||
{
|
||||
jsonobject.accumulate("content", XML.stringToValue(string));
|
||||
}
|
||||
|
||||
// Nested element
|
||||
|
||||
} else if(token == LT)
|
||||
{
|
||||
if(parse(x, jsonobject, tagName))
|
||||
{
|
||||
if(jsonobject.length() == 0)
|
||||
{
|
||||
context.accumulate(tagName, "");
|
||||
} else if(jsonobject.length() == 1 && jsonobject.opt("content") != null)
|
||||
{
|
||||
context.accumulate(tagName, jsonobject.opt("content"));
|
||||
} else
|
||||
{
|
||||
context.accumulate(tagName, jsonobject);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to convert a string into a number, boolean, or null. If the string
|
||||
* can't be converted, return the string. This is much less ambitious than
|
||||
* JSONObject.stringToValue, especially because it does not attempt to
|
||||
* convert plus forms, octal forms, hex forms, or E forms lacking decimal
|
||||
* points.
|
||||
*
|
||||
* @param string
|
||||
* A String.
|
||||
* @return A simple JSON value.
|
||||
*/
|
||||
public static Object stringToValue(String string)
|
||||
{
|
||||
if("true".equalsIgnoreCase(string))
|
||||
{
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
if("false".equalsIgnoreCase(string))
|
||||
{
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
if("null".equalsIgnoreCase(string))
|
||||
{
|
||||
return JSONObject.NULL;
|
||||
}
|
||||
|
||||
// If it might be a number, try converting it, first as a Long, and then
|
||||
// as a
|
||||
// Double. If that doesn't work, return the string.
|
||||
|
||||
try
|
||||
{
|
||||
char initial = string.charAt(0);
|
||||
if(initial == '-' || (initial >= '0' && initial <= '9'))
|
||||
{
|
||||
Long value = new Long(string);
|
||||
if(value.toString().equals(string))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
} catch(Exception ignore)
|
||||
{
|
||||
try
|
||||
{
|
||||
Double value = new Double(string);
|
||||
if(value.toString().equals(string))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
} catch(Exception ignoreAlso)
|
||||
{
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a well-formed (but not necessarily valid) XML string into a
|
||||
* JSONObject. Some information may be lost in this transformation because
|
||||
* JSON is a data format and XML is a document format. XML uses elements,
|
||||
* attributes, and content text, while JSON uses unordered collections of
|
||||
* name/value pairs and arrays of values. JSON does not does not like to
|
||||
* distinguish between elements and attributes. Sequences of similar
|
||||
* elements are represented as JSONArrays. Content text may be placed in a
|
||||
* "content" member. Comments, prologs, DTDs, and <code><[ [ ]]></code>
|
||||
* are ignored.
|
||||
*
|
||||
* @param string
|
||||
* The source string.
|
||||
* @return A JSONObject containing the structured data from the XML string.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static JSONObject toJSONObject(String string) throws JSONException
|
||||
{
|
||||
JSONObject jo = new JSONObject();
|
||||
XMLTokener x = new XMLTokener(string);
|
||||
while(x.more() && x.skipPast("<"))
|
||||
{
|
||||
parse(x, jo, null);
|
||||
}
|
||||
return jo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a JSONObject into a well-formed, element-normal XML string.
|
||||
*
|
||||
* @param object
|
||||
* A JSONObject.
|
||||
* @return A string.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static String toString(Object object) throws JSONException
|
||||
{
|
||||
return toString(object, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a JSONObject into a well-formed, element-normal XML string.
|
||||
*
|
||||
* @param object
|
||||
* A JSONObject.
|
||||
* @param tagName
|
||||
* The optional name of the enclosing tag.
|
||||
* @return A string.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public static String toString(Object object, String tagName) throws JSONException
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int i;
|
||||
JSONArray ja;
|
||||
JSONObject jo;
|
||||
String key;
|
||||
Iterator<String> keys;
|
||||
int length;
|
||||
String string;
|
||||
Object value;
|
||||
if(object instanceof JSONObject)
|
||||
{
|
||||
|
||||
// Emit <tagName>
|
||||
|
||||
if(tagName != null)
|
||||
{
|
||||
sb.append('<');
|
||||
sb.append(tagName);
|
||||
sb.append('>');
|
||||
}
|
||||
|
||||
// Loop thru the keys.
|
||||
|
||||
jo = (JSONObject) object;
|
||||
keys = jo.keys();
|
||||
while(keys.hasNext())
|
||||
{
|
||||
key = keys.next();
|
||||
value = jo.opt(key);
|
||||
if(value == null)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
string = value instanceof String ? (String) value : null;
|
||||
|
||||
// Emit content in body
|
||||
|
||||
if("content".equals(key))
|
||||
{
|
||||
if(value instanceof JSONArray)
|
||||
{
|
||||
ja = (JSONArray) value;
|
||||
length = ja.length();
|
||||
for(i = 0; i < length; i += 1)
|
||||
{
|
||||
if(i > 0)
|
||||
{
|
||||
sb.append('\n');
|
||||
}
|
||||
sb.append(escape(ja.get(i).toString()));
|
||||
}
|
||||
} else
|
||||
{
|
||||
sb.append(escape(value.toString()));
|
||||
}
|
||||
|
||||
// Emit an array of similar keys
|
||||
|
||||
} else if(value instanceof JSONArray)
|
||||
{
|
||||
ja = (JSONArray) value;
|
||||
length = ja.length();
|
||||
for(i = 0; i < length; i += 1)
|
||||
{
|
||||
value = ja.get(i);
|
||||
if(value instanceof JSONArray)
|
||||
{
|
||||
sb.append('<');
|
||||
sb.append(key);
|
||||
sb.append('>');
|
||||
sb.append(toString(value));
|
||||
sb.append("</");
|
||||
sb.append(key);
|
||||
sb.append('>');
|
||||
} else
|
||||
{
|
||||
sb.append(toString(value, key));
|
||||
}
|
||||
}
|
||||
} else if("".equals(value))
|
||||
{
|
||||
sb.append('<');
|
||||
sb.append(key);
|
||||
sb.append("/>");
|
||||
|
||||
// Emit a new tag <k>
|
||||
|
||||
} else
|
||||
{
|
||||
sb.append(toString(value, key));
|
||||
}
|
||||
}
|
||||
if(tagName != null)
|
||||
{
|
||||
|
||||
// Emit the </tagname> close tag
|
||||
|
||||
sb.append("</");
|
||||
sb.append(tagName);
|
||||
sb.append('>');
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
// XML does not have good support for arrays. If an array appears in
|
||||
// a place
|
||||
// where XML is lacking, synthesize an <array> element.
|
||||
|
||||
} else
|
||||
{
|
||||
if(object.getClass().isArray())
|
||||
{
|
||||
object = new JSONArray(object);
|
||||
}
|
||||
if(object instanceof JSONArray)
|
||||
{
|
||||
ja = (JSONArray) object;
|
||||
length = ja.length();
|
||||
for(i = 0; i < length; i += 1)
|
||||
{
|
||||
sb.append(toString(ja.opt(i), tagName == null ? "array" : tagName));
|
||||
}
|
||||
return sb.toString();
|
||||
} else
|
||||
{
|
||||
string = (object == null) ? "null" : escape(object.toString());
|
||||
return (tagName == null) ? "\"" + string + "\"" : (string.length() == 0) ? "<" + tagName + "/>" : "<" + tagName + ">" + string + "</" + tagName + ">";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
425
json/XMLTokener.java
Normal file
425
json/XMLTokener.java
Normal file
@@ -0,0 +1,425 @@
|
||||
package ninja.bytecode.shuriken.json;
|
||||
|
||||
|
||||
/*
|
||||
Copyright (c) 2002 JSON.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The Software shall be used for Good, not Evil.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The XMLTokener extends the JSONTokener to provide additional methods for the
|
||||
* parsing of XML texts.
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2014-05-03
|
||||
*/
|
||||
public class XMLTokener extends JSONTokener
|
||||
{
|
||||
|
||||
/**
|
||||
* The table of entity values. It initially contains Character values for
|
||||
* amp, apos, gt, lt, quot.
|
||||
*/
|
||||
public static final java.util.HashMap<String, Character> entity;
|
||||
|
||||
static
|
||||
{
|
||||
entity = new java.util.HashMap<String, Character>(8);
|
||||
entity.put("amp", XML.AMP);
|
||||
entity.put("apos", XML.APOS);
|
||||
entity.put("gt", XML.GT);
|
||||
entity.put("lt", XML.LT);
|
||||
entity.put("quot", XML.QUOT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an XMLTokener from a string.
|
||||
*
|
||||
* @param s
|
||||
* A source string.
|
||||
*/
|
||||
public XMLTokener(String s)
|
||||
{
|
||||
super(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text in the CDATA block.
|
||||
*
|
||||
* @return The string up to the <code>]]></code>.
|
||||
* @throws JSONException
|
||||
* If the <code>]]></code> is not found.
|
||||
*/
|
||||
public String nextCDATA() throws JSONException
|
||||
{
|
||||
char c;
|
||||
int i;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(;;)
|
||||
{
|
||||
c = next();
|
||||
if(end())
|
||||
{
|
||||
throw syntaxError("Unclosed CDATA");
|
||||
}
|
||||
sb.append(c);
|
||||
i = sb.length() - 3;
|
||||
if(i >= 0 && sb.charAt(i) == ']' && sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>')
|
||||
{
|
||||
sb.setLength(i);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next XML outer token, trimming whitespace. There are two kinds of
|
||||
* tokens: the '<' character which begins a markup tag, and the content text
|
||||
* between markup tags.
|
||||
*
|
||||
* @return A string, or a '<' Character, or null if there is no more source
|
||||
* text.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public Object nextContent() throws JSONException
|
||||
{
|
||||
char c;
|
||||
StringBuilder sb;
|
||||
do
|
||||
{
|
||||
c = next();
|
||||
} while(Character.isWhitespace(c));
|
||||
if(c == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(c == '<')
|
||||
{
|
||||
return XML.LT;
|
||||
}
|
||||
sb = new StringBuilder();
|
||||
for(;;)
|
||||
{
|
||||
if(c == '<' || c == 0)
|
||||
{
|
||||
back();
|
||||
return sb.toString().trim();
|
||||
}
|
||||
if(c == '&')
|
||||
{
|
||||
sb.append(nextEntity(c));
|
||||
} else
|
||||
{
|
||||
sb.append(c);
|
||||
}
|
||||
c = next();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next entity. These entities are translated to Characters:
|
||||
* <code>& ' > < "</code>.
|
||||
*
|
||||
* @param ampersand
|
||||
* An ampersand character.
|
||||
* @return A Character or an entity String if the entity is not recognized.
|
||||
* @throws JSONException
|
||||
* If missing ';' in XML entity.
|
||||
*/
|
||||
public Object nextEntity(char ampersand) throws JSONException
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(;;)
|
||||
{
|
||||
char c = next();
|
||||
if(Character.isLetterOrDigit(c) || c == '#')
|
||||
{
|
||||
sb.append(Character.toLowerCase(c));
|
||||
} else if(c == ';')
|
||||
{
|
||||
break;
|
||||
} else
|
||||
{
|
||||
throw syntaxError("Missing ';' in XML entity: &" + sb);
|
||||
}
|
||||
}
|
||||
String string = sb.toString();
|
||||
Object object = entity.get(string);
|
||||
return object != null ? object : ampersand + string + ";";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next XML meta token. This is used for skipping over
|
||||
* <!...> and <?...?> structures.
|
||||
*
|
||||
* @return Syntax characters (<code>< > / = ! ?</code>) are returned as
|
||||
* Character, and strings and names are returned as Boolean. We
|
||||
* don't care what the values actually are.
|
||||
* @throws JSONException
|
||||
* If a string is not properly closed or if the XML is badly
|
||||
* structured.
|
||||
*/
|
||||
public Object nextMeta() throws JSONException
|
||||
{
|
||||
char c;
|
||||
char q;
|
||||
do
|
||||
{
|
||||
c = next();
|
||||
} while(Character.isWhitespace(c));
|
||||
switch(c)
|
||||
{
|
||||
case 0:
|
||||
throw syntaxError("Misshaped meta tag");
|
||||
case '<':
|
||||
return XML.LT;
|
||||
case '>':
|
||||
return XML.GT;
|
||||
case '/':
|
||||
return XML.SLASH;
|
||||
case '=':
|
||||
return XML.EQ;
|
||||
case '!':
|
||||
return XML.BANG;
|
||||
case '?':
|
||||
return XML.QUEST;
|
||||
case '"':
|
||||
case '\'':
|
||||
q = c;
|
||||
for(;;)
|
||||
{
|
||||
c = next();
|
||||
if(c == 0)
|
||||
{
|
||||
throw syntaxError("Unterminated string");
|
||||
}
|
||||
if(c == q)
|
||||
{
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
default:
|
||||
for(;;)
|
||||
{
|
||||
c = next();
|
||||
if(Character.isWhitespace(c))
|
||||
{
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
switch(c)
|
||||
{
|
||||
case 0:
|
||||
case '<':
|
||||
case '>':
|
||||
case '/':
|
||||
case '=':
|
||||
case '!':
|
||||
case '?':
|
||||
case '"':
|
||||
case '\'':
|
||||
back();
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next XML Token. These tokens are found inside of angle brackets.
|
||||
* It may be one of these characters: <code>/ > = ! ?</code> or it may be a
|
||||
* string wrapped in single quotes or double quotes, or it may be a name.
|
||||
*
|
||||
* @return a String or a Character.
|
||||
* @throws JSONException
|
||||
* If the XML is not well formed.
|
||||
*/
|
||||
public Object nextToken() throws JSONException
|
||||
{
|
||||
char c;
|
||||
char q;
|
||||
StringBuilder sb;
|
||||
do
|
||||
{
|
||||
c = next();
|
||||
} while(Character.isWhitespace(c));
|
||||
switch(c)
|
||||
{
|
||||
case 0:
|
||||
throw syntaxError("Misshaped element");
|
||||
case '<':
|
||||
throw syntaxError("Misplaced '<'");
|
||||
case '>':
|
||||
return XML.GT;
|
||||
case '/':
|
||||
return XML.SLASH;
|
||||
case '=':
|
||||
return XML.EQ;
|
||||
case '!':
|
||||
return XML.BANG;
|
||||
case '?':
|
||||
return XML.QUEST;
|
||||
|
||||
// Quoted string
|
||||
|
||||
case '"':
|
||||
case '\'':
|
||||
q = c;
|
||||
sb = new StringBuilder();
|
||||
for(;;)
|
||||
{
|
||||
c = next();
|
||||
if(c == 0)
|
||||
{
|
||||
throw syntaxError("Unterminated string");
|
||||
}
|
||||
if(c == q)
|
||||
{
|
||||
return sb.toString();
|
||||
}
|
||||
if(c == '&')
|
||||
{
|
||||
sb.append(nextEntity(c));
|
||||
} else
|
||||
{
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
||||
// Name
|
||||
|
||||
sb = new StringBuilder();
|
||||
for(;;)
|
||||
{
|
||||
sb.append(c);
|
||||
c = next();
|
||||
if(Character.isWhitespace(c))
|
||||
{
|
||||
return sb.toString();
|
||||
}
|
||||
switch(c)
|
||||
{
|
||||
case 0:
|
||||
return sb.toString();
|
||||
case '>':
|
||||
case '/':
|
||||
case '=':
|
||||
case '!':
|
||||
case '?':
|
||||
case '[':
|
||||
case ']':
|
||||
back();
|
||||
return sb.toString();
|
||||
case '<':
|
||||
case '"':
|
||||
case '\'':
|
||||
throw syntaxError("Bad character in a name");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip characters until past the requested string. If it is not found, we
|
||||
* are left at the end of the source with a result of false.
|
||||
*
|
||||
* @param to
|
||||
* A string to skip past.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public boolean skipPast(String to) throws JSONException
|
||||
{
|
||||
boolean b;
|
||||
char c;
|
||||
int i;
|
||||
int j;
|
||||
int offset = 0;
|
||||
int length = to.length();
|
||||
char[] circle = new char[length];
|
||||
|
||||
/*
|
||||
* First fill the circle buffer with as many characters as are in the to
|
||||
* string. If we reach an early end, bail.
|
||||
*/
|
||||
|
||||
for(i = 0; i < length; i += 1)
|
||||
{
|
||||
c = next();
|
||||
if(c == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
circle[i] = c;
|
||||
}
|
||||
|
||||
/* We will loop, possibly for all of the remaining characters. */
|
||||
|
||||
for(;;)
|
||||
{
|
||||
j = offset;
|
||||
b = true;
|
||||
|
||||
/* Compare the circle buffer with the to string. */
|
||||
|
||||
for(i = 0; i < length; i += 1)
|
||||
{
|
||||
if(circle[j] != to.charAt(i))
|
||||
{
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
j += 1;
|
||||
if(j >= length)
|
||||
{
|
||||
j -= length;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we exit the loop with b intact, then victory is ours. */
|
||||
|
||||
if(b)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the next character. If there isn't one, then defeat is ours.
|
||||
*/
|
||||
|
||||
c = next();
|
||||
if(c == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* Shove the character in the circle buffer and advance the circle
|
||||
* offset. The offset is mod n.
|
||||
*/
|
||||
circle[offset] = c;
|
||||
offset += 1;
|
||||
if(offset >= length)
|
||||
{
|
||||
offset -= length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
listing.json
Normal file
8
listing.json
Normal file
@@ -0,0 +1,8 @@
|
||||
[
|
||||
"overworld IrisDimensions/overworld",
|
||||
"vanilla IrisDimensions/vanilla",
|
||||
"flat IrisDimensions/flat",
|
||||
"redstone IrisDimensions/redstone",
|
||||
"mars IrisDimensions/mars",
|
||||
"example IrisDimensions/example"
|
||||
]
|
||||
3
packignore.ignore
Normal file
3
packignore.ignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.DS_Store
|
||||
*.code-workspace
|
||||
*.txt
|
||||
69
plains.json
Normal file
69
plains.json
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"children": [],
|
||||
"decorators": [],
|
||||
"objects": [],
|
||||
"name": "Plains",
|
||||
"layers": [
|
||||
{
|
||||
"minHeight": 1,
|
||||
"terrainZoom": 5,
|
||||
"maxHeight": 3,
|
||||
"palette": [
|
||||
"GRASS_BLOCK"
|
||||
],
|
||||
"dispersion": "SCATTER"
|
||||
},
|
||||
{
|
||||
"minHeight": 1,
|
||||
"terrainZoom": 5,
|
||||
"maxHeight": 1,
|
||||
"palette": [
|
||||
"DIRT"
|
||||
],
|
||||
"dispersion": "SCATTER"
|
||||
},
|
||||
{
|
||||
"minHeight": 1,
|
||||
"terrainZoom": 5,
|
||||
"maxHeight": 3,
|
||||
"palette": [
|
||||
"DIRT",
|
||||
"COARSE_DIRT"
|
||||
],
|
||||
"dispersion": "SCATTER"
|
||||
},
|
||||
{
|
||||
"minHeight": 6,
|
||||
"terrainZoom": 5,
|
||||
"maxHeight": 2341,
|
||||
"palette": [
|
||||
"STONE",
|
||||
"ANDESITE",
|
||||
"STONE"
|
||||
],
|
||||
"dispersion": "SCATTER"
|
||||
}
|
||||
],
|
||||
"childShrinkFactor": 1.55,
|
||||
"derivative": "THE_VOID",
|
||||
"auxiliaryGenerators": [
|
||||
{
|
||||
"offsetX": 0,
|
||||
"offsetZ": 0.01,
|
||||
"min": 1,
|
||||
"seed": 1336,
|
||||
"max": 5,
|
||||
"zoom": 3.065
|
||||
},
|
||||
{
|
||||
"offsetX": 0,
|
||||
"offsetZ": 0,
|
||||
"min": 1.01,
|
||||
"seed": 1339,
|
||||
"max": 2,
|
||||
"zoom": 1.6
|
||||
}
|
||||
],
|
||||
"highHeight": 3.66669,
|
||||
"lowHeight": 31.5
|
||||
}
|
||||
118
pom.xml
118
pom.xml
@@ -2,15 +2,16 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>bytecode.ninja</groupId>
|
||||
<groupId>com.volmit</groupId>
|
||||
<artifactId>Iris</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.3.3</version>
|
||||
<name>Iris</name>
|
||||
<properties>
|
||||
<skip.copy>false</skip.copy>
|
||||
<secretary.build>package</secretary.build>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<development.location>${user.home}\Documents\development\server\plugins\${project.name}.jar</development.location>
|
||||
</properties>
|
||||
<build>
|
||||
<resources>
|
||||
@@ -22,7 +23,7 @@
|
||||
<include>**/*.yml</include>
|
||||
<include>**/*.txt</include>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.html</include>
|
||||
<include>**/*.json</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
@@ -38,67 +39,102 @@
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>runbatchfile</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>${skip.copy}</skip>
|
||||
<executable>${project.basedir}/scripts/copy.bat</executable>
|
||||
<arguments>
|
||||
<argument>${project.basedir}\target\${project.name}-${project.version}.jar</argument>
|
||||
<argument>${development.location}</argument>
|
||||
</arguments>
|
||||
<compilerVersion>1.8</compilerVersion>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>pub</id>
|
||||
<url>http://nexus.mpm.care/content/repositories/pub</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>volmit</id>
|
||||
<url>http://nexus.volmit.com/content/repositories/volmit</url>
|
||||
<url>http://repo.volmit.com/repository/volmit/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ninja.bytecode</groupId>
|
||||
<artifactId>Shuriken</artifactId>
|
||||
<version>1.0</version>
|
||||
<groupId>io.timeandspace</groupId>
|
||||
<artifactId>smoothie-map</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
<!-- Spigot API -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.14.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Paper API -->
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- NMS -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit.craftbukkit</groupId>
|
||||
<artifactId>1.16.3</artifactId>
|
||||
<version>1.16.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>craftbukkit-1.14.4</artifactId>
|
||||
<groupId>cb</groupId>
|
||||
<version>1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/craftbukkit-1.14.4.jar</systemPath>
|
||||
<groupId>org.bukkit.craftbukkit</groupId>
|
||||
<artifactId>1.16.4</artifactId>
|
||||
<version>1.16.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Hooks -->
|
||||
<dependency>
|
||||
<groupId>com.bergerkiller.bukkit</groupId>
|
||||
<artifactId>BKCommonLib</artifactId>
|
||||
<version>1.16.4-v2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.lumine.xikage</groupId>
|
||||
<artifactId>MythicMobs</artifactId>
|
||||
<version>4.9.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Utilities -->
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>2.8.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.10</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.zeroturnaround</groupId>
|
||||
<artifactId>zt-zip</artifactId>
|
||||
<version>1.14</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,3 +0,0 @@
|
||||
@Echo off
|
||||
echo Apply Script: COPY
|
||||
echo F|xcopy /y /s /f /q "%1" "%2"
|
||||
@@ -0,0 +1,153 @@
|
||||
package com.minelazz.epicworldgenerator.structures;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.object.IrisObject;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.EnumSet;
|
||||
|
||||
@DontObfuscate
|
||||
public class StructureObject implements Serializable
|
||||
{
|
||||
@DontObfuscate
|
||||
public static final String MESSAGE0 = "This was created from .ewg serialization files";
|
||||
|
||||
@DontObfuscate
|
||||
public static final String MESSAGE1 = "This is not copied code, it is intended to ";
|
||||
|
||||
@DontObfuscate
|
||||
public static final String MESSAGE2 = "be used so that people can convert EWG files";
|
||||
|
||||
@DontObfuscate
|
||||
public static final String MESSAGE3 = "into .IOB files (iris objects)";
|
||||
|
||||
@DontObfuscate
|
||||
public static IrisObject convert(File so) throws IOException, ClassNotFoundException
|
||||
{
|
||||
FileInputStream fin = new FileInputStream(so);
|
||||
ObjectInputStream in = new ObjectInputStream(fin);
|
||||
StructureObject o = (StructureObject) in.readObject();
|
||||
in.close();
|
||||
int maxX = 0;
|
||||
int maxY = 0;
|
||||
int maxZ = 0;
|
||||
int minX = 0;
|
||||
int minY = 0;
|
||||
int minZ = 0;
|
||||
|
||||
for(SOBlock i : o.blocks)
|
||||
{
|
||||
maxX = maxX < i.x ? i.x : maxX;
|
||||
maxY = maxY < i.y ? i.y : maxY;
|
||||
maxZ = maxZ < i.z ? i.z : maxZ;
|
||||
minX = minX > i.x ? i.x : minX;
|
||||
minY = minY > i.y ? i.y : minY;
|
||||
minZ = minZ > i.z ? i.z : minZ;
|
||||
}
|
||||
|
||||
IrisObject iob = new IrisObject(maxX - minX, maxY - minY, maxZ - minZ);
|
||||
|
||||
for(SOBlock i : o.blocks)
|
||||
{
|
||||
BlockData bdx = null;
|
||||
|
||||
if(i.blockData == null)
|
||||
{
|
||||
BlockData f = map(i.id, i.data);
|
||||
bdx = f == null ? null : f;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
bdx = B.get(i.blockData);
|
||||
}
|
||||
|
||||
if(bdx != null)
|
||||
{
|
||||
iob.getBlocks().put(new BlockVector(i.x, -i.y, i.z), bdx);
|
||||
}
|
||||
}
|
||||
|
||||
return iob;
|
||||
}
|
||||
|
||||
@DontObfuscate
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final BlockData map(int id, int dat)
|
||||
{
|
||||
for(Material i : EnumSet.allOf(Material.class))
|
||||
{
|
||||
if(!i.isLegacy())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i.getId() == id)
|
||||
{
|
||||
return Bukkit.getUnsafe().fromLegacy(i, (byte) dat);
|
||||
}
|
||||
}
|
||||
|
||||
Iris.warn("Unknown Type " + id + ":" + dat);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@DontObfuscate
|
||||
private static final long serialVersionUID = -905274143366977303L;
|
||||
|
||||
@DontObfuscate
|
||||
public SOBlock[] blocks;
|
||||
@DontObfuscate
|
||||
public String name;
|
||||
|
||||
@DontObfuscate
|
||||
public final class SOBlock implements Serializable
|
||||
{
|
||||
@DontObfuscate
|
||||
private static final long serialVersionUID = 2610063934261982315L;
|
||||
|
||||
@DontObfuscate
|
||||
public final int x;
|
||||
|
||||
@DontObfuscate
|
||||
public final int y;
|
||||
|
||||
@DontObfuscate
|
||||
public final int z;
|
||||
|
||||
@DontObfuscate
|
||||
public final int id;
|
||||
|
||||
@DontObfuscate
|
||||
public final int data;
|
||||
|
||||
@DontObfuscate
|
||||
public String meta;
|
||||
|
||||
@DontObfuscate
|
||||
public String blockData;
|
||||
|
||||
@DontObfuscate
|
||||
final StructureObject ref;
|
||||
|
||||
@DontObfuscate
|
||||
public SOBlock(StructureObject structureObject, int x, int y, int z, String string)
|
||||
{
|
||||
this.ref = structureObject;
|
||||
meta = null;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
id = -1;
|
||||
data = 0;
|
||||
blockData = string;
|
||||
}
|
||||
}
|
||||
}
|
||||
545
src/main/java/com/volmit/iris/Iris.java
Normal file
545
src/main/java/com/volmit/iris/Iris.java
Normal file
@@ -0,0 +1,545 @@
|
||||
package com.volmit.iris;
|
||||
|
||||
import com.volmit.iris.manager.*;
|
||||
import com.volmit.iris.manager.command.CommandIris;
|
||||
import com.volmit.iris.manager.command.world.CommandLocate;
|
||||
import com.volmit.iris.manager.command.PermissionIris;
|
||||
import com.volmit.iris.manager.link.BKLink;
|
||||
import com.volmit.iris.manager.link.CitizensLink;
|
||||
import com.volmit.iris.manager.link.MultiverseCoreLink;
|
||||
import com.volmit.iris.manager.link.MythicMobsLink;
|
||||
import com.volmit.iris.nms.INMS;
|
||||
import com.volmit.iris.object.IrisCompat;
|
||||
import com.volmit.iris.scaffold.IrisWorlds;
|
||||
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
|
||||
import com.volmit.iris.util.*;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class Iris extends VolmitPlugin
|
||||
{
|
||||
public static KList<GroupedExecutor> executors = new KList<>();
|
||||
public static Iris instance;
|
||||
public static ProjectManager proj;
|
||||
public static ConversionManager convert;
|
||||
public static WandManager wand;
|
||||
public static EditManager edit;
|
||||
public static IrisBoardManager board;
|
||||
public static BKLink linkBK;
|
||||
public static MultiverseCoreLink linkMultiverseCore;
|
||||
public static MythicMobsLink linkMythicMobs;
|
||||
public static CitizensLink linkCitizens;
|
||||
private static final Queue<Runnable> syncJobs = new ShurikenQueue<>();
|
||||
public static boolean customModels = doesSupportCustomModels();
|
||||
public static boolean awareEntities = doesSupportAwareness();
|
||||
public static boolean biome3d = doesSupport3DBiomes();
|
||||
public static boolean lowMemoryMode = false;
|
||||
public static IrisCompat compat;
|
||||
public static FileWatcher configWatcher;
|
||||
public static boolean warnsmoothie = true;
|
||||
|
||||
@Permission
|
||||
public static PermissionIris perm;
|
||||
|
||||
@com.volmit.iris.util.Command
|
||||
public CommandIris commandIris;
|
||||
|
||||
public Iris()
|
||||
{
|
||||
instance = this;
|
||||
INMS.get();
|
||||
IO.delete(new File("iris"));
|
||||
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4g
|
||||
}
|
||||
|
||||
public static int getThreadCount()
|
||||
{
|
||||
int tc = IrisSettings.get().getConcurrency().getThreadCount();
|
||||
|
||||
if(tc <= 0)
|
||||
{
|
||||
int p = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
return p > 16 ? 16 : p < 4 ? 4 : p;
|
||||
}
|
||||
|
||||
return tc;
|
||||
}
|
||||
|
||||
private static boolean doesSupport3DBiomes()
|
||||
{
|
||||
try
|
||||
{
|
||||
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
|
||||
|
||||
return v >= 15;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean doesSupportCustomModels()
|
||||
{
|
||||
try
|
||||
{
|
||||
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
|
||||
|
||||
return v >= 14;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean doesSupportAwareness()
|
||||
{
|
||||
try
|
||||
{
|
||||
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
|
||||
|
||||
return v >= 15;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void warnsmoothie(){
|
||||
if (warnsmoothie){
|
||||
warn("The smoothieMap 'illegal reflective access operation' is required and can be safely ignored");
|
||||
warnsmoothie = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag(String subTag)
|
||||
{
|
||||
return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.GREEN + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": ";
|
||||
}
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
instance = this;
|
||||
try {
|
||||
compat = IrisCompat.configured(getDataFile("compat.json"));
|
||||
} catch (IOException e){
|
||||
// Do nothing. Everything continues properly but the exception is still there.
|
||||
}
|
||||
proj = new ProjectManager();
|
||||
convert = new ConversionManager();
|
||||
wand = new WandManager();
|
||||
board = new IrisBoardManager();
|
||||
linkMultiverseCore = new MultiverseCoreLink();
|
||||
linkBK = new BKLink();
|
||||
linkMythicMobs = new MythicMobsLink();
|
||||
edit = new EditManager();
|
||||
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
||||
J.a(() -> IO.delete(getTemp()));
|
||||
J.a(this::bstats);
|
||||
J.s(this::splash, 20);
|
||||
J.sr(this::tickQueue, 0);
|
||||
J.ar(this::checkConfigHotload, 50);
|
||||
PaperLib.suggestPaper(this);
|
||||
getServer().getPluginManager().registerEvents(new CommandLocate(), this);
|
||||
super.onEnable();
|
||||
}
|
||||
|
||||
private void checkConfigHotload() {
|
||||
if(configWatcher.checkModified())
|
||||
{
|
||||
IrisSettings.invalidate();
|
||||
IrisSettings.get();
|
||||
configWatcher.checkModified();
|
||||
Iris.info("Hotloaded settings.json");
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
if(IrisSettings.get().isStudio())
|
||||
{
|
||||
proj.close();
|
||||
|
||||
for(World i : Bukkit.getWorlds())
|
||||
{
|
||||
if(IrisWorlds.isIrisWorld(i))
|
||||
{
|
||||
IrisWorlds.access(i).close();
|
||||
}
|
||||
}
|
||||
|
||||
for(GroupedExecutor i : executors)
|
||||
{
|
||||
i.close();
|
||||
}
|
||||
}
|
||||
|
||||
executors.clear();
|
||||
board.disable();
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
HandlerList.unregisterAll((Plugin) this);
|
||||
super.onDisable();
|
||||
}
|
||||
|
||||
public static void sq(Runnable r)
|
||||
{
|
||||
synchronized(syncJobs)
|
||||
{
|
||||
syncJobs.queue(r);
|
||||
}
|
||||
}
|
||||
|
||||
private void tickQueue()
|
||||
{
|
||||
synchronized(Iris.syncJobs)
|
||||
{
|
||||
if(!Iris.syncJobs.hasNext())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
long ms = M.ms();
|
||||
|
||||
while(Iris.syncJobs.hasNext() && M.ms() - ms < 25)
|
||||
{
|
||||
try
|
||||
{
|
||||
Iris.syncJobs.next().run();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void bstats()
|
||||
{
|
||||
if(IrisSettings.get().getGeneral().isPluginMetrics())
|
||||
{
|
||||
J.s(() -> {
|
||||
Metrics m = new Metrics(Iris.instance, 8757);
|
||||
|
||||
m.addCustomChart(new Metrics.SingleLineChart("custom_dimensions", new Callable<Integer>() {
|
||||
@Override
|
||||
public Integer call() throws Exception {
|
||||
return ProjectManager.countUniqueDimensions();
|
||||
}
|
||||
}));
|
||||
|
||||
m.addCustomChart(new Metrics.SimplePie("using_custom_dimensions", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return ProjectManager.countUniqueDimensions() > 0 ? "Active Projects" : "No Projects";
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static File getTemp()
|
||||
{
|
||||
return instance.getDataFolder("cache", "temp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
return super.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
public void imsg(CommandSender s, String msg)
|
||||
{
|
||||
s.sendMessage(C.GREEN + "[" + C.DARK_GRAY + "Iris" + C.GREEN + "]" + C.GRAY + ": " + msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
|
||||
{
|
||||
String dimension = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||
|
||||
if(id != null && !id.isEmpty())
|
||||
{
|
||||
dimension = id;
|
||||
Iris.info("Generator ID: " + id + " requested by bukkit/plugin. Assuming IrisDimension: " + id);
|
||||
}
|
||||
|
||||
return new EngineCompositeGenerator(dimension, true);
|
||||
}
|
||||
|
||||
public static void msg(String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(instance == null)
|
||||
{
|
||||
System.out.println("[Iris]: " + string);
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = C.GRAY + "[" + C.GREEN + "Iris" + C.GRAY + "]: " + string;
|
||||
Bukkit.getConsoleSender().sendMessage(msg);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
System.out.println("[Iris]: " + string);
|
||||
}
|
||||
}
|
||||
|
||||
public static File getCached(String name, String url)
|
||||
{
|
||||
String h = IO.hash(name + "@" + url);
|
||||
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
|
||||
|
||||
if(!f.exists())
|
||||
{
|
||||
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f))
|
||||
{
|
||||
byte[] dataBuffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1)
|
||||
{
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
Iris.verbose("Aquiring " + name);
|
||||
}
|
||||
}
|
||||
|
||||
catch(IOException ignored)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return f.exists() ? f : null;
|
||||
}
|
||||
|
||||
public static String getNonCached(String name, String url)
|
||||
{
|
||||
String h = IO.hash(name + "*" + url);
|
||||
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
|
||||
|
||||
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f))
|
||||
{
|
||||
byte[] dataBuffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1)
|
||||
{
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
|
||||
catch(IOException ignored)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return IO.readAll(f);
|
||||
}
|
||||
|
||||
catch(IOException ignored)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static File getNonCachedFile(String name, String url)
|
||||
{
|
||||
String h = IO.hash(name + "*" + url);
|
||||
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
|
||||
|
||||
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f))
|
||||
{
|
||||
byte[] dataBuffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1)
|
||||
{
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
|
||||
catch(IOException ignored)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
public static void warn(String string)
|
||||
{
|
||||
msg(C.YELLOW + string);
|
||||
}
|
||||
|
||||
public static void error(String string)
|
||||
{
|
||||
msg(C.RED + string);
|
||||
}
|
||||
|
||||
public static void verbose(String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(IrisSettings.get().getGeneral().isVerbose())
|
||||
{
|
||||
msg(C.GRAY + string);
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
msg(C.GRAY + string);
|
||||
}
|
||||
}
|
||||
|
||||
public static void success(String string)
|
||||
{
|
||||
msg(C.GREEN + string);
|
||||
}
|
||||
|
||||
public static void info(String string)
|
||||
{
|
||||
msg(C.WHITE + string);
|
||||
}
|
||||
|
||||
public void hit(long hits2)
|
||||
{
|
||||
board.hits.put(hits2);
|
||||
}
|
||||
|
||||
public void splash()
|
||||
{
|
||||
if(!IrisSettings.get().getGeneral().isSplashLogoStartup())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// @NoArgsConstructor
|
||||
String padd = Form.repeat(" ", 8);
|
||||
String padd2 = Form.repeat(" ", 4);
|
||||
String[] info = {"", "", "", "", "", padd2 + C.GREEN + " Iris", padd2 + C.GRAY + " by " + C.randomColor() + "V" + C.randomColor() + "o" + C.randomColor() + "l" + C.randomColor() + "m" + C.randomColor() + "i" + C.randomColor() + "t" + C.randomColor() + "S" + C.randomColor() + "o" + C.randomColor() + "f" + C.randomColor() + "t" + C.randomColor() + "w" + C.randomColor() + "a" + C.randomColor() + "r" + C.randomColor() + "e", padd2 + C.GRAY + " v" + getDescription().getVersion(),
|
||||
};
|
||||
String[] splash = {padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@", padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + C.GREEN + " .(((()))). ", padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + C.GREEN + " .((((((())))))). ", padd + C.GRAY + "@@@&&&&&" + C.DARK_GRAY + "&&&&&&&" + C.GREEN + " ((((((((())))))))) " + C.GRAY + " @", padd + C.GRAY + "@@@&&&&" + C.DARK_GRAY + "@@@@@&" + C.GREEN + " ((((((((-))))))))) " + C.GRAY + " @@", padd + C.GRAY + "@@@&&" + C.GREEN + " ((((((({ })))))))) " + C.GRAY + " &&@@@", padd + C.GRAY + "@@" + C.GREEN + " ((((((((-))))))))) " + C.DARK_GRAY + "&@@@@@" + C.GRAY + "&&&&@@@", padd + C.GRAY + "@" + C.GREEN + " ((((((((())))))))) " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&@@@", padd + C.GRAY + "" + C.GREEN + " '((((((()))))))' " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&&@@@", padd + C.GRAY + "" + C.GREEN + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@", padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@"
|
||||
};
|
||||
//@done
|
||||
Iris.info("Server type & version: " + Bukkit.getVersion());
|
||||
Iris.info("Bukkit version: " + Bukkit.getBukkitVersion());
|
||||
Iris.info("Java version: " + getJavaVersion());
|
||||
for(int i = 0; i < info.length; i++)
|
||||
{
|
||||
splash[i] += info[i];
|
||||
}
|
||||
|
||||
Iris.info("\n\n " + new KList<>(splash).toString("\n") + "\n");
|
||||
|
||||
if(lowMemoryMode)
|
||||
{
|
||||
Iris.verbose("* Low Memory mode Activated! For better performance, allocate 4gb or more to this server.");
|
||||
}
|
||||
|
||||
if(!biome3d)
|
||||
{
|
||||
Iris.verbose("* This version of minecraft does not support 3D biomes (1.15 and up). Iris will generate as normal, but biome colors will not vary underground & in the sky.");
|
||||
}
|
||||
|
||||
if(!customModels)
|
||||
{
|
||||
Iris.verbose("* This version of minecraft does not support custom model data in loot items (1.14 and up). Iris will generate as normal, but loot will not have custom models.");
|
||||
}
|
||||
|
||||
if(!doesSupportAwareness())
|
||||
{
|
||||
Iris.verbose("* This version of minecraft does not support entity awareness.");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void later(NastyRunnable object)
|
||||
{
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () ->
|
||||
{
|
||||
try
|
||||
{
|
||||
object.run();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, RNG.r.i(100, 1200));
|
||||
}
|
||||
|
||||
public static int jobCount()
|
||||
{
|
||||
return syncJobs.size();
|
||||
}
|
||||
|
||||
public static void clearQueues()
|
||||
{
|
||||
synchronized(syncJobs)
|
||||
{
|
||||
syncJobs.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private static int getJavaVersion() {
|
||||
String version = System.getProperty("java.version");
|
||||
if(version.startsWith("1.")) {
|
||||
version = version.substring(2, 3);
|
||||
} else {
|
||||
int dot = version.indexOf(".");
|
||||
if(dot != -1) { version = version.substring(0, dot); }
|
||||
} return Integer.parseInt(version);
|
||||
}
|
||||
|
||||
public boolean isMCA() {
|
||||
return IrisSettings.get().getGenerator().isMcaPregenerator();
|
||||
}
|
||||
}
|
||||
262
src/main/java/com/volmit/iris/IrisSettings.java
Normal file
262
src/main/java/com/volmit/iris/IrisSettings.java
Normal file
@@ -0,0 +1,262 @@
|
||||
package com.volmit.iris;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.util.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@Data
|
||||
public class IrisSettings
|
||||
{
|
||||
public static transient IrisSettings settings;
|
||||
private IrisSettingsCache cache = new IrisSettingsCache();
|
||||
private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency();
|
||||
private IrisSettingsParallax parallax = new IrisSettingsParallax();
|
||||
private IrisSettingsGeneral general = new IrisSettingsGeneral();
|
||||
private IrisSettingsGUI gui = new IrisSettingsGUI();
|
||||
private IrisSettingsGenerator generator = new IrisSettingsGenerator();
|
||||
private IrisSettingsStudio studio = new IrisSettingsStudio();
|
||||
|
||||
@DontObfuscate
|
||||
public int configurationVersion = 3;
|
||||
|
||||
public boolean isStudio() {
|
||||
return getStudio().isStudio();
|
||||
}
|
||||
|
||||
public boolean isUseServerLaunchedGuis() {
|
||||
return getGui().isUseServerLaunchedGuis();
|
||||
}
|
||||
|
||||
public long getParallaxRegionEvictionMS() {
|
||||
return getParallax().getParallaxRegionEvictionMS();
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsCache
|
||||
{
|
||||
@DontObfuscate
|
||||
public int streamingCacheSize = 8192;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsConcurrency
|
||||
{
|
||||
@DontObfuscate
|
||||
public int threadCount = -1;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsParallax
|
||||
{
|
||||
@DontObfuscate
|
||||
public int parallaxRegionEvictionMS = 15000;
|
||||
|
||||
@DontObfuscate
|
||||
public int parallaxChunkEvictionMS = 5000;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsGeneral
|
||||
{
|
||||
|
||||
@DontObfuscate
|
||||
public boolean commandSounds = true;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean verbose = false;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean ignoreWorldEdit = false;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean disableNMS = false;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean pluginMetrics = true;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean splashLogoStartup = true;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsGUI
|
||||
{
|
||||
@DontObfuscate
|
||||
public boolean useServerLaunchedGuis = true;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean maximumPregenGuiFPS = false;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean localPregenGui = true;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsGenerator
|
||||
{
|
||||
@DontObfuscate
|
||||
public String defaultWorldType = "overworld";
|
||||
|
||||
@DontObfuscate
|
||||
public boolean mcaPregenerator = false;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean systemEffects = true;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean systemEntitySpawnOverrides = true;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean systemEntityInitialSpawns = true;
|
||||
|
||||
@DontObfuscate
|
||||
public int maxBiomeChildDepth = 5;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsStudio
|
||||
{
|
||||
|
||||
@DontObfuscate
|
||||
public boolean studio = true;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean openVSCode = true;
|
||||
}
|
||||
|
||||
public static IrisSettings get()
|
||||
{
|
||||
if(settings != null)
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
|
||||
IrisSettings defaults = new IrisSettings();
|
||||
JSONObject def = new JSONObject(new Gson().toJson(defaults));
|
||||
if(settings == null)
|
||||
{
|
||||
settings = new IrisSettings();
|
||||
|
||||
File s = Iris.instance.getDataFile("settings.json");
|
||||
|
||||
if(!s.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
String ss = IO.readAll(s);
|
||||
settings = new Gson().fromJson(ss, IrisSettings.class);
|
||||
|
||||
J.a(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
JSONObject j = new JSONObject(ss);
|
||||
boolean u = false;
|
||||
for(String i : def.keySet())
|
||||
{
|
||||
if(!j.has(i))
|
||||
{
|
||||
u = true;
|
||||
j.put(i, def.get(i));
|
||||
Iris.warn("Adding new config key: " + i);
|
||||
}
|
||||
}
|
||||
|
||||
for(String i : new KSet<>(j.keySet()))
|
||||
{
|
||||
if(!def.has(i))
|
||||
{
|
||||
u = true;
|
||||
j.remove(i);
|
||||
Iris.warn("Removing unused config key: " + i);
|
||||
}
|
||||
}
|
||||
|
||||
if(u)
|
||||
{
|
||||
try
|
||||
{
|
||||
IO.writeAll(s, j.toString(4));
|
||||
Iris.info("Updated Configuration Files");
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ee)
|
||||
{
|
||||
Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage());
|
||||
Iris.warn("Attempting to fix configuration while retaining valid in-memory settings...");
|
||||
|
||||
try {
|
||||
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
|
||||
Iris.info("Configuration Fixed!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Iris.error("ERROR! CONFIGURATION IMPOSSIBLE TO READ! Using an unmodifiable configuration from memory. Please delete the settings.json at some point to try to restore configurability!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
catch(Throwable ee)
|
||||
{
|
||||
Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage());
|
||||
Iris.warn("Attempting to fix configuration while retaining valid in-memory settings...");
|
||||
|
||||
try {
|
||||
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
|
||||
Iris.info("Configuration Fixed!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Iris.error("ERROR! CONFIGURATION IMPOSSIBLE TO READ! Using an unmodifiable configuration from memory. Please delete the settings.json at some point to try to restore configurability!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!s.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static void invalidate()
|
||||
{
|
||||
synchronized(settings)
|
||||
{
|
||||
settings = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
364
src/main/java/com/volmit/iris/generator/IrisComplex.java
Normal file
364
src/main/java/com/volmit/iris/generator/IrisComplex.java
Normal file
@@ -0,0 +1,364 @@
|
||||
package com.volmit.iris.generator;
|
||||
|
||||
import com.google.common.util.concurrent.AtomicDouble;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.generator.actuator.IrisTerrainActuator;
|
||||
import com.volmit.iris.generator.modifier.IrisCaveModifier;
|
||||
import com.volmit.iris.generator.noise.CNG;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.object.*;
|
||||
import com.volmit.iris.scaffold.data.DataProvider;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.scaffold.stream.interpolation.Interpolated;
|
||||
import com.volmit.iris.util.CaveResult;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@Data
|
||||
public class IrisComplex implements DataProvider
|
||||
{
|
||||
private RNG rng;
|
||||
private double fluidHeight;
|
||||
private IrisDataManager data;
|
||||
private KList<IrisGenerator> generators;
|
||||
private static final BlockData AIR = Material.AIR.createBlockData();
|
||||
private ProceduralStream<IrisRegion> regionStream;
|
||||
private ProceduralStream<InferredType> bridgeStream;
|
||||
private ProceduralStream<IrisBiome> landBiomeStream;
|
||||
private ProceduralStream<IrisBiome> caveBiomeStream;
|
||||
private ProceduralStream<IrisBiome> seaBiomeStream;
|
||||
private ProceduralStream<IrisBiome> shoreBiomeStream;
|
||||
private ProceduralStream<IrisBiome> baseBiomeStream;
|
||||
private ProceduralStream<IrisBiome> trueBiomeStream;
|
||||
private ProceduralStream<Biome> trueBiomeDerivativeStream;
|
||||
private ProceduralStream<Double> heightStream;
|
||||
private ProceduralStream<Double> objectChanceStream;
|
||||
private ProceduralStream<Double> maxHeightStream;
|
||||
private ProceduralStream<Double> overlayStream;
|
||||
private ProceduralStream<Double> heightFluidStream;
|
||||
private ProceduralStream<Integer> trueHeightStream;
|
||||
private ProceduralStream<Double> slopeStream;
|
||||
private ProceduralStream<RNG> rngStream;
|
||||
private ProceduralStream<RNG> chunkRngStream;
|
||||
private ProceduralStream<IrisDecorator> terrainSurfaceDecoration;
|
||||
private ProceduralStream<IrisDecorator> terrainCeilingDecoration;
|
||||
private ProceduralStream<IrisDecorator> terrainCaveSurfaceDecoration;
|
||||
private ProceduralStream<IrisDecorator> terrainCaveCeilingDecoration;
|
||||
private ProceduralStream<IrisDecorator> seaSurfaceDecoration;
|
||||
private ProceduralStream<IrisDecorator> shoreSurfaceDecoration;
|
||||
private ProceduralStream<BlockData> rockStream;
|
||||
private ProceduralStream<BlockData> fluidStream;
|
||||
|
||||
public ProceduralStream<IrisBiome> getBiomeStream(InferredType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case CAVE:
|
||||
return caveBiomeStream;
|
||||
case LAND:
|
||||
return landBiomeStream;
|
||||
case SEA:
|
||||
return seaBiomeStream;
|
||||
case SHORE:
|
||||
return shoreBiomeStream;
|
||||
case DEFER:
|
||||
case LAKE:
|
||||
case RIVER:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public IrisComplex(Engine engine)
|
||||
{
|
||||
int cacheSize = IrisSettings.get().getCache().getStreamingCacheSize();
|
||||
this.rng = new RNG(engine.getWorld().getSeed());
|
||||
this.data = engine.getData();
|
||||
double height = engine.getHeight();
|
||||
fluidHeight = engine.getDimension().getFluidHeight();
|
||||
generators = new KList<>();
|
||||
RNG rng = new RNG(engine.getWorld().getSeed());
|
||||
//@builder
|
||||
engine.getDimension().getRegions().forEach((i) -> data.getRegionLoader().load(i)
|
||||
.getAllBiomes(this).forEach((b) -> b
|
||||
.getGenerators()
|
||||
.forEach((c) -> registerGenerator(c.getCachedGenerator(this)))));
|
||||
overlayStream = ProceduralStream.ofDouble((x, z) -> 0D);
|
||||
engine.getDimension().getOverlayNoise().forEach((i) -> overlayStream.add((x, z) -> i.get(rng, x, z)));
|
||||
rngStream = ProceduralStream.of((x, z) -> new RNG(((x.longValue()) << 32) | (z.longValue() & 0xffffffffL))
|
||||
.nextParallelRNG(engine.getWorld().getSeed()), Interpolated.RNG);
|
||||
chunkRngStream = rngStream.blockToChunkCoords();
|
||||
rockStream = engine.getDimension().getRockPalette().getLayerGenerator(rng.nextParallelRNG(45), data).stream()
|
||||
.select(engine.getDimension().getRockPalette().getBlockData(data));
|
||||
fluidStream = engine.getDimension().getFluidPalette().getLayerGenerator(rng.nextParallelRNG(78), data).stream()
|
||||
.select(engine.getDimension().getFluidPalette().getBlockData(data));
|
||||
regionStream = engine.getDimension().getRegionStyle().create(rng.nextParallelRNG(883)).stream()
|
||||
.zoom(engine.getDimension().getRegionZoom())
|
||||
.selectRarity(engine.getDimension().getRegions())
|
||||
.convertCached((s) -> data.getRegionLoader().load(s)).cache2D(cacheSize);
|
||||
caveBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(1221)).stream()
|
||||
.zoom(r.getCaveBiomeZoom())
|
||||
.selectRarity(r.getCaveBiomes())
|
||||
.onNull("")
|
||||
.convertCached((s) -> {
|
||||
if(s.isEmpty())
|
||||
{
|
||||
return new IrisBiome();
|
||||
}
|
||||
|
||||
return data.getBiomeLoader().load(s)
|
||||
.setInferredType(InferredType.CAVE);
|
||||
})
|
||||
).convertAware2D(ProceduralStream::get).cache2D(cacheSize);
|
||||
landBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(234234234)).stream()
|
||||
.zoom(r.getLandBiomeZoom())
|
||||
.selectRarity(r.getLandBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s)
|
||||
.setInferredType(InferredType.LAND))
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
.cache2D(cacheSize);
|
||||
seaBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(11232323)).stream()
|
||||
.zoom(r.getSeaBiomeZoom())
|
||||
.selectRarity(r.getSeaBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s)
|
||||
.setInferredType(InferredType.SEA))
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
.cache2D(cacheSize);
|
||||
shoreBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(7787845)).stream()
|
||||
.zoom(r.getShoreBiomeZoom())
|
||||
.selectRarity(r.getShoreBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s)
|
||||
.setInferredType(InferredType.SHORE))
|
||||
).convertAware2D(ProceduralStream::get).cache2D(cacheSize);
|
||||
bridgeStream = engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565)).bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream()
|
||||
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND);
|
||||
baseBiomeStream = bridgeStream.convertAware2D((t, x, z) -> t.equals(InferredType.SEA)
|
||||
? seaBiomeStream.get(x, z) : landBiomeStream.get(x, z))
|
||||
.convertAware2D(this::implode).cache2D(cacheSize);
|
||||
heightStream = ProceduralStream.of((x, z) -> {
|
||||
IrisBiome b = baseBiomeStream.get(x, z);
|
||||
return getHeight(engine, b, x, z, engine.getWorld().getSeed());
|
||||
}, Interpolated.DOUBLE).cache2D(cacheSize);
|
||||
slopeStream = heightStream.slope(3).interpolate().bilinear(3, 3).cache2D(cacheSize);
|
||||
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
|
||||
AtomicDouble str = new AtomicDouble(1D);
|
||||
engine.getFramework().getEngineParallax().forEachFeature(x, z, (i)
|
||||
-> str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z))));
|
||||
return str.get();
|
||||
});
|
||||
trueBiomeStream = heightStream
|
||||
.convertAware2D((h, x, z) ->
|
||||
fixBiomeType(h, baseBiomeStream.get(x, z),
|
||||
regionStream.get(x, z), x, z, fluidHeight)).cache2D(cacheSize);
|
||||
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D(cacheSize);
|
||||
heightFluidStream = heightStream.max(fluidHeight).cache2D(cacheSize);
|
||||
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height);
|
||||
terrainSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.NONE));
|
||||
terrainCeilingDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.CEILING));
|
||||
terrainCaveSurfaceDecoration = caveBiomeStream
|
||||
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.NONE));
|
||||
terrainCaveCeilingDecoration = caveBiomeStream
|
||||
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.CEILING));
|
||||
shoreSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SHORE_LINE));
|
||||
seaSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SEA_SURFACE));
|
||||
trueHeightStream = ProceduralStream.of((x, z) -> {
|
||||
int rx = (int) Math.round(engine.modifyX(x));
|
||||
int rz = (int) Math.round(engine.modifyZ(z));
|
||||
int heightf = (int) Math.round(getHeightStream().get(rx, rz));
|
||||
int m = heightf;
|
||||
|
||||
if(engine.getDimension().isCarving())
|
||||
{
|
||||
if(engine.getDimension().isCarved(rx, m, rz, ((IrisTerrainActuator)engine.getFramework().getTerrainActuator()).getRng(), heightf))
|
||||
{
|
||||
m--;
|
||||
|
||||
while(engine.getDimension().isCarved(rx, m, rz, ((IrisTerrainActuator)engine.getFramework().getTerrainActuator()).getRng(), heightf))
|
||||
{
|
||||
m--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(engine.getDimension().isCaves())
|
||||
{
|
||||
KList<CaveResult> caves = ((IrisCaveModifier)engine.getFramework().getCaveModifier()).genCaves(rx, rz, 0, 0, null);
|
||||
boolean again = true;
|
||||
|
||||
while(again)
|
||||
{
|
||||
again = false;
|
||||
for(CaveResult i : caves)
|
||||
{
|
||||
if(i.getCeiling() > m && i.getFloor() < m)
|
||||
{
|
||||
m = i.getFloor();
|
||||
again = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}, Interpolated.INT).cache2D(cacheSize);
|
||||
//@done
|
||||
}
|
||||
|
||||
private IrisDecorator decorateFor(IrisBiome b, double x, double z, DecorationPart part)
|
||||
{
|
||||
RNG rngc = chunkRngStream.get(x, z);
|
||||
|
||||
for(IrisDecorator i : b.getDecorators())
|
||||
{
|
||||
if(!i.getPartOf().equals(part))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData block = i.getBlockData(b, rngc, x, z, data);
|
||||
|
||||
if(block != null)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z)
|
||||
{
|
||||
if(b.getChildren().isEmpty())
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
return implode(b, x, z, 3);
|
||||
}
|
||||
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z, int max)
|
||||
{
|
||||
if(max < 0)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
if(b.getChildren().isEmpty())
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
CNG childCell = b.getChildrenGenerator(rng, 123, b.getChildShrinkFactor());
|
||||
KList<IrisBiome> chx = b.getRealChildren(this).copy();
|
||||
chx.add(b);
|
||||
IrisBiome biome = childCell.fitRarity(chx, x, z);
|
||||
biome.setInferredType(b.getInferredType());
|
||||
return implode(biome, x, z, max - 1);
|
||||
}
|
||||
|
||||
private IrisBiome fixBiomeType(Double height, IrisBiome biome, IrisRegion region, Double x, Double z, double fluidHeight)
|
||||
{
|
||||
double sh = region.getShoreHeight(x, z);
|
||||
|
||||
if(height >= fluidHeight-1 && height <= fluidHeight + sh && !biome.isShore())
|
||||
{
|
||||
return shoreBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
if(height > fluidHeight + sh && !biome.isLand())
|
||||
{
|
||||
return landBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
if(height < fluidHeight && !biome.isAquatic())
|
||||
{
|
||||
return seaBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
if(height == fluidHeight && !biome.isShore())
|
||||
{
|
||||
return shoreBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
return biome;
|
||||
}
|
||||
|
||||
private double getHeight(Engine engine, IrisBiome b, double x, double z, long seed)
|
||||
{
|
||||
double h = 0;
|
||||
|
||||
for(IrisGenerator gen : generators)
|
||||
{
|
||||
double hi = gen.getInterpolator().interpolate(x, z, (xx, zz) ->
|
||||
{
|
||||
try
|
||||
{
|
||||
IrisBiome bx = baseBiomeStream.get(xx, zz);
|
||||
|
||||
return bx.getGenLinkMax(gen.getLoadKey());
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
Iris.warn("Failed to sample hi biome at " + xx + " " + zz + " using the generator " + gen.getLoadKey());
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
double lo = gen.getInterpolator().interpolate(x, z, (xx, zz) ->
|
||||
{
|
||||
try
|
||||
{
|
||||
IrisBiome bx = baseBiomeStream.get(xx, zz);
|
||||
|
||||
return bx.getGenLinkMin(gen.getLoadKey());
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
Iris.warn("Failed to sample lo biome at " + xx + " " + zz + " using the generator " + gen.getLoadKey());
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
h += M.lerp(lo, hi, gen.getHeight(x, z, seed + 239945));
|
||||
}
|
||||
|
||||
AtomicDouble noise = new AtomicDouble(h + fluidHeight + overlayStream.get(x,z));
|
||||
engine.getFramework().getEngineParallax().forEachFeature(x, z, (i)
|
||||
-> noise.set(i.filter(x, z, noise.get())));
|
||||
return Math.min(engine.getHeight(), Math.max(noise.get(), 0));
|
||||
}
|
||||
|
||||
private void registerGenerator(IrisGenerator cachedGenerator)
|
||||
{
|
||||
for(IrisGenerator i : generators)
|
||||
{
|
||||
if(i.getLoadKey().equals(cachedGenerator.getLoadKey()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
generators.add(cachedGenerator);
|
||||
}
|
||||
}
|
||||
154
src/main/java/com/volmit/iris/generator/IrisEngine.java
Normal file
154
src/main/java/com/volmit/iris/generator/IrisEngine.java
Normal file
@@ -0,0 +1,154 @@
|
||||
package com.volmit.iris.generator;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.scaffold.engine.*;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class IrisEngine extends BlockPopulator implements Engine
|
||||
{
|
||||
@Getter
|
||||
private final EngineCompound compound;
|
||||
|
||||
@Getter
|
||||
private final EngineTarget target;
|
||||
|
||||
@Getter
|
||||
private final EngineFramework framework;
|
||||
|
||||
@Getter
|
||||
private final EngineEffects effects;
|
||||
|
||||
@Getter
|
||||
private final EngineWorldManager worldManager;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private volatile int parallelism;
|
||||
|
||||
@Getter
|
||||
private final int index;
|
||||
|
||||
@Getter
|
||||
private final EngineMetrics metrics;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private volatile int minHeight;
|
||||
private boolean failing;
|
||||
private boolean closed;
|
||||
private int cacheId;
|
||||
private final int art;
|
||||
|
||||
public IrisEngine(EngineTarget target, EngineCompound compound, int index)
|
||||
{
|
||||
Iris.info("Initializing Engine: " + target.getWorld().getName() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)");
|
||||
metrics = new EngineMetrics(32);
|
||||
this.target = target;
|
||||
this.framework = new IrisEngineFramework(this);
|
||||
worldManager = new IrisWorldManager(this);
|
||||
this.compound = compound;
|
||||
minHeight = 0;
|
||||
failing = false;
|
||||
closed = false;
|
||||
this.index = index;
|
||||
cacheId = RNG.r.nextInt();
|
||||
effects = new IrisEngineEffects(this);
|
||||
art = J.ar(effects::tickRandomPlayer, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
J.car(art);
|
||||
closed = true;
|
||||
getWorldManager().close();
|
||||
getFramework().close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return closed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
getFramework().recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double modifyX(double x) {
|
||||
return x / getDimension().getTerrainZoom();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double modifyZ(double z) {
|
||||
return z / getDimension().getTerrainZoom();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<Biome> vbiomes) {
|
||||
try
|
||||
{
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Hunk<BlockData> blocks = vblocks.synchronize().listen((xx,y,zz,t) -> catchBlockUpdates(x+xx,y+getMinHeight(),z+zz, t));
|
||||
getFramework().getEngineParallax().generateParallaxArea(x>>4, z>>4);
|
||||
getFramework().getBiomeActuator().actuate(x, z, vbiomes);
|
||||
getFramework().getTerrainActuator().actuate(x, z, blocks);
|
||||
getFramework().getCaveModifier().modify(x, z, blocks);
|
||||
getFramework().getRavineModifier().modify(x, z, blocks);
|
||||
getFramework().getPostModifier().modify(x, z, blocks);
|
||||
getFramework().getDecorantActuator().actuate(x, z, blocks);
|
||||
getFramework().getEngineParallax().insertParallax(x, z, blocks);
|
||||
getFramework().getDepositModifier().modify(x, z, blocks);
|
||||
getMetrics().getTotal().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
fail("Failed to generate " + x + ", " + z, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk c)
|
||||
{
|
||||
getWorldManager().spawnInitialEntities(c);
|
||||
updateChunk(c);
|
||||
placeTiles(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String error, Throwable e) {
|
||||
failing = true;
|
||||
Iris.error(error);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFailed() {
|
||||
return failing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCacheID() {
|
||||
return cacheId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hotload() {
|
||||
cacheId = RNG.r.nextInt();
|
||||
}
|
||||
}
|
||||
366
src/main/java/com/volmit/iris/generator/IrisEngineCompound.java
Normal file
366
src/main/java/com/volmit/iris/generator/IrisEngineCompound.java
Normal file
@@ -0,0 +1,366 @@
|
||||
package com.volmit.iris.generator;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.nms.INMS;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
import com.volmit.iris.object.IrisDimensionIndex;
|
||||
import com.volmit.iris.object.IrisPosition;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineCompound;
|
||||
import com.volmit.iris.scaffold.engine.EngineData;
|
||||
import com.volmit.iris.scaffold.engine.EngineTarget;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class IrisEngineCompound implements EngineCompound {
|
||||
@Getter
|
||||
private final World world;
|
||||
|
||||
private final AtomicRollingSequence wallClock;
|
||||
|
||||
private Engine defaultEngine;
|
||||
|
||||
@Getter
|
||||
private final EngineData engineMetadata;
|
||||
|
||||
private final Engine[] engines;
|
||||
|
||||
@Getter
|
||||
private final MultiBurst burster;
|
||||
|
||||
@Getter
|
||||
private final KList<BlockPopulator> populators;
|
||||
|
||||
@Getter
|
||||
private final IrisDimension rootDimension;
|
||||
|
||||
@Getter
|
||||
private final int threadCount = -1;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean studio;
|
||||
|
||||
public IrisEngineCompound(World world, IrisDimension rootDimension, IrisDataManager data, int maximumThreads)
|
||||
{
|
||||
wallClock = new AtomicRollingSequence(32);
|
||||
this.rootDimension = rootDimension;
|
||||
Iris.info("Initializing Engine Composite for " + world.getName());
|
||||
this.world = world;
|
||||
engineMetadata = EngineData.load(getEngineMetadataFile());
|
||||
engineMetadata.setDimension(rootDimension.getLoadKey());
|
||||
engineMetadata.setLastVersion(Iris.instance.getDescription().getVersion());
|
||||
|
||||
|
||||
if(engineMetadata.getStrongholdPositions() == null || engineMetadata.getStrongholdPositions().size() == 0)
|
||||
{
|
||||
if(!(world instanceof FakeWorld || world instanceof HeightedFakeWorld))
|
||||
{
|
||||
List<IrisPosition> strongholds = new ArrayList<>();
|
||||
Object nmsWorld = new V(world).invoke("getHandle");
|
||||
Object chunkProvider = new V(nmsWorld).invoke("getChunkProvider");
|
||||
Object chunkGenerator = new V(chunkProvider).invoke("getChunkGenerator");
|
||||
try {
|
||||
Class<?> clazz = Class.forName("net.minecraft.server." + INMS.getNMSTag() + ".ChunkGenerator");
|
||||
Class<?> clazzSG = Class.forName("net.minecraft.server." + INMS.getNMSTag() + ".StructureGenerator");
|
||||
Class<?> clazzBP = Class.forName("net.minecraft.server." + INMS.getNMSTag() + ".BlockPosition");
|
||||
getBPSafe(clazz, clazzSG, clazzBP, nmsWorld, chunkGenerator).thenAccept(bp -> {
|
||||
if (bp == null){
|
||||
throw new NullPointerException();
|
||||
}
|
||||
strongholds.add(new IrisPosition((int) new V(bp, false).invoke("getX"), (int) new V(bp, false).invoke("getY"), (int) new V(bp, false).invoke("getZ")));
|
||||
StringBuilder positions = new StringBuilder();
|
||||
for (IrisPosition pos : strongholds){
|
||||
positions.append("(").append(pos.getX()).append(",").append(pos.getY()).append(",").append(pos.getZ()).append(") ");
|
||||
}
|
||||
Iris.info("Strongholds (" + engineMetadata.getStrongholdPositions().size() + ") found at [" + positions + "]");
|
||||
});
|
||||
|
||||
engineMetadata.setStrongholdPositions(strongholds);
|
||||
} catch (Throwable e) {
|
||||
strongholds.add( new IrisPosition(1337, 32, -1337) );
|
||||
engineMetadata.setStrongholdPositions(strongholds);
|
||||
Iris.warn("Couldn't properly find the stronghold position for this world. Is this headless mode? Are you not using 1.16 or higher?");
|
||||
Iris.warn(" -> Setting default stronghold position");
|
||||
e.printStackTrace();
|
||||
Iris.info("Got this far (3)");
|
||||
StringBuilder positions = new StringBuilder();
|
||||
for (IrisPosition pos : strongholds){
|
||||
positions.append("(").append(pos.getX()).append(",").append(pos.getY()).append(",").append(pos.getZ()).append(") ");
|
||||
}
|
||||
Iris.info("Strongholds (" + engineMetadata.getStrongholdPositions().size() + ") found at [" + positions + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
saveEngineMetadata();
|
||||
populators = new KList<>();
|
||||
|
||||
if(rootDimension.getDimensionalComposite().isEmpty())
|
||||
{
|
||||
burster = null;
|
||||
engines = new Engine[]{new IrisEngine(new EngineTarget(world, rootDimension, data, 256, maximumThreads), this, 0)};
|
||||
defaultEngine = engines[0];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
double totalWeight = 0D;
|
||||
engines = new Engine[rootDimension.getDimensionalComposite().size()];
|
||||
burster = engines.length > 1 ? new MultiBurst(engines.length) : null;
|
||||
int threadDist = (Math.max(2, maximumThreads - engines.length)) / engines.length;
|
||||
|
||||
if((threadDist * engines.length) + engines.length > maximumThreads)
|
||||
{
|
||||
Iris.warn("Using " + ((threadDist * engines.length) + engines.length) + " threads instead of the configured " + maximumThreads + " maximum thread count due to the requirements of this dimension!");
|
||||
}
|
||||
|
||||
for(IrisDimensionIndex i : rootDimension.getDimensionalComposite())
|
||||
{
|
||||
totalWeight += i.getWeight();
|
||||
}
|
||||
|
||||
int buf = 0;
|
||||
|
||||
for(int i = 0; i < engines.length; i++)
|
||||
{
|
||||
IrisDimensionIndex index = rootDimension.getDimensionalComposite().get(i);
|
||||
IrisDimension dimension = data.getDimensionLoader().load(index.getDimension());
|
||||
engines[i] = new IrisEngine(new EngineTarget(world, dimension, data.copy(), (int)Math.floor(256D * (index.getWeight() / totalWeight)), index.isInverted(), threadDist), this, i);
|
||||
engines[i].setMinHeight(buf);
|
||||
buf += engines[i].getHeight();
|
||||
|
||||
if(index.isPrimary())
|
||||
{
|
||||
defaultEngine = engines[i];
|
||||
}
|
||||
}
|
||||
|
||||
if(defaultEngine == null)
|
||||
{
|
||||
defaultEngine = engines[0];
|
||||
}
|
||||
}
|
||||
|
||||
for(Engine i : engines)
|
||||
{
|
||||
if(i instanceof BlockPopulator)
|
||||
{
|
||||
populators.add((BlockPopulator) i);
|
||||
}
|
||||
}
|
||||
|
||||
Iris.instance.registerListener(this);
|
||||
}
|
||||
|
||||
private Object getBP(Class clazz, Class clazzSG, Class clazzBP, Object nmsWorld, Object chunkGenerator) throws NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||||
return clazz.getDeclaredMethod("findNearestMapFeature",
|
||||
nmsWorld.getClass(),
|
||||
clazzSG,
|
||||
clazzBP,
|
||||
int.class,
|
||||
boolean.class
|
||||
).invoke(chunkGenerator,
|
||||
nmsWorld,
|
||||
clazzSG.getDeclaredField("STRONGHOLD").get(null),
|
||||
clazzBP.getDeclaredField("ZERO").get(null),
|
||||
100,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
public CompletableFuture<Object> getBPSafe(Class clazz, Class clazzSG, Class clazzBP, Object nmsWorld, Object chunkGenerator) {
|
||||
CompletableFuture<Object> cf = new CompletableFuture<>();
|
||||
Bukkit.getScheduler().runTask(Iris.instance, () -> {
|
||||
try {
|
||||
cf.complete(getBP(clazz, clazzSG, clazzBP, nmsWorld, chunkGenerator));
|
||||
} catch (Throwable e){
|
||||
cf.complete(null);
|
||||
}
|
||||
});
|
||||
return cf;
|
||||
}
|
||||
|
||||
public List<IrisPosition> getStrongholdPositions()
|
||||
{
|
||||
return engineMetadata.getStrongholdPositions();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(WorldSaveEvent e)
|
||||
{
|
||||
if(world != null &&e.getWorld().equals(world))
|
||||
{
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
public void printMetrics(CommandSender sender)
|
||||
{
|
||||
KMap<String, Double> totals = new KMap<>();
|
||||
KMap<String, Double> weights = new KMap<>();
|
||||
double masterWallClock = wallClock.getAverage();
|
||||
|
||||
for(int i = 0; i < getSize(); i++)
|
||||
{
|
||||
Engine e = getEngine(i);
|
||||
KMap<String, Double> timings = e.getMetrics().pull();
|
||||
double totalWeight = 0;
|
||||
double wallClock = e.getMetrics().getTotal().getAverage();
|
||||
|
||||
for(double j : timings.values())
|
||||
{
|
||||
totalWeight += j;
|
||||
}
|
||||
|
||||
for(String j : timings.k())
|
||||
{
|
||||
weights.put(e.getName() + "[" + e.getIndex() + "]." + j, (wallClock / totalWeight) * timings.get(j));
|
||||
}
|
||||
|
||||
totals.put(e.getName() + "[" + e.getIndex() + "]", wallClock);
|
||||
}
|
||||
|
||||
double mtotals = 0;
|
||||
|
||||
for(double i : totals.values())
|
||||
{
|
||||
mtotals+=i;
|
||||
}
|
||||
|
||||
for(String i : totals.k())
|
||||
{
|
||||
totals.put(i, (masterWallClock / mtotals) * totals.get(i));
|
||||
}
|
||||
|
||||
double v = 0;
|
||||
|
||||
for(double i : weights.values())
|
||||
{
|
||||
v+=i;
|
||||
}
|
||||
|
||||
for(String i : weights.k())
|
||||
{
|
||||
weights.put(i, weights.get(i) / v);
|
||||
}
|
||||
|
||||
sender.sendMessage("Total: " + C.BOLD + C.WHITE + Form.duration(masterWallClock, 0));
|
||||
|
||||
for(String i : totals.k())
|
||||
{
|
||||
sender.sendMessage(" Engine " + C.UNDERLINE + C.GREEN + i + C.RESET + ": " + C.BOLD + C.WHITE + Form.duration(totals.get(i), 0));
|
||||
}
|
||||
|
||||
sender.sendMessage("Details: ");
|
||||
|
||||
for(String i : weights.sortKNumber().reverse())
|
||||
{
|
||||
String befb = C.UNDERLINE +""+ C.GREEN + "" + i.split("\\Q[\\E")[0] + C.RESET + C.GRAY + "[";
|
||||
String num = C.GOLD + i.split("\\Q[\\E")[1].split("]")[0] + C.RESET + C.GRAY + "].";
|
||||
String afb = C.ITALIC +""+ C.AQUA + i.split("\\Q]\\E")[1].substring(1) + C.RESET + C.GRAY;
|
||||
|
||||
sender.sendMessage(" " + befb + num + afb + ": " + C.BOLD + C.WHITE + Form.pc(weights.get(i), 0));
|
||||
}
|
||||
}
|
||||
|
||||
private File getEngineMetadataFile() {
|
||||
return new File(world.getWorldFolder(), "iris/engine-metadata.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(int x, int z, Hunk<BlockData> blocks, Hunk<BlockData> postblocks, Hunk<Biome> biomes)
|
||||
{
|
||||
recycle();
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
if(engines.length == 1 && !getEngine(0).getTarget().isInverted())
|
||||
{
|
||||
engines[0].generate(x, z, blocks, biomes);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
int i;
|
||||
int offset = 0;
|
||||
|
||||
for(i = 0; i < engines.length; i++)
|
||||
{
|
||||
Engine engine = engines[i];
|
||||
int doffset = offset;
|
||||
int height = engine.getTarget().getHeight();
|
||||
Hunk<BlockData> cblock = Hunk.newArrayHunk(16, height, 16);
|
||||
Hunk<Biome> cbiome = Hunk.newArrayHunk(16, height, 16);
|
||||
|
||||
if(engine.getTarget().isInverted())
|
||||
{
|
||||
cblock = cblock.invertY();
|
||||
cbiome = cbiome.invertY();
|
||||
}
|
||||
|
||||
engine.generate(x, z, cblock, cbiome);
|
||||
blocks.insert(0, doffset, 0, cblock);
|
||||
biomes.insert(0, doffset, 0, cbiome);
|
||||
offset += height;
|
||||
}
|
||||
}
|
||||
|
||||
wallClock.put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return engines.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Engine getEngine(int index) {
|
||||
return engines[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveEngineMetadata() {
|
||||
engineMetadata.save(getEngineMetadataFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisDataManager getData(int height) {
|
||||
return getEngineForHeight(height).getData();
|
||||
}
|
||||
|
||||
//TODO: FAIL
|
||||
@Override
|
||||
public boolean isFailing() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Engine getDefaultEngine() {
|
||||
return defaultEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hotload() {
|
||||
for(int i = 0; i < getSize(); i++)
|
||||
{
|
||||
getEngine(i).hotload();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.volmit.iris.generator;
|
||||
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedComponent;
|
||||
import com.volmit.iris.scaffold.engine.EngineEffects;
|
||||
import com.volmit.iris.scaffold.engine.EnginePlayer;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
public class IrisEngineEffects extends EngineAssignedComponent implements EngineEffects {
|
||||
private KMap<UUID, EnginePlayer> players;
|
||||
private Semaphore limit;
|
||||
|
||||
public IrisEngineEffects(Engine engine) {
|
||||
super(engine, "FX");
|
||||
players = new KMap<>();
|
||||
limit = new Semaphore(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePlayerMap() {
|
||||
List<Player> pr = getEngine().getWorld().getPlayers();
|
||||
for(Player i : pr)
|
||||
{
|
||||
Location l = i.getLocation();
|
||||
boolean pcc = players.containsKey(i.getUniqueId());
|
||||
if(getEngine().contains(l))
|
||||
{
|
||||
if(!pcc)
|
||||
{
|
||||
players.put(i.getUniqueId(), new EnginePlayer(getEngine(), i));
|
||||
}
|
||||
}
|
||||
|
||||
else if(pcc)
|
||||
{
|
||||
players.remove(i.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
for(UUID i : players.k())
|
||||
{
|
||||
if(!pr.contains(players.get(i).getPlayer()))
|
||||
{
|
||||
players.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickRandomPlayer() {
|
||||
if(limit.tryAcquire())
|
||||
{
|
||||
if(M.r(0.02))
|
||||
{
|
||||
updatePlayerMap();
|
||||
limit.release();
|
||||
return;
|
||||
}
|
||||
|
||||
if(players.isEmpty())
|
||||
{
|
||||
limit.release();
|
||||
return;
|
||||
}
|
||||
|
||||
double limitms = 1.5;
|
||||
int max = players.size();
|
||||
PrecisionStopwatch p = new PrecisionStopwatch();
|
||||
|
||||
while(max-- > 0 && M.ms() - p.getMilliseconds() < limitms)
|
||||
{
|
||||
players.v().getRandom().tick();
|
||||
}
|
||||
|
||||
limit.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
113
src/main/java/com/volmit/iris/generator/IrisEngineFramework.java
Normal file
113
src/main/java/com/volmit/iris/generator/IrisEngineFramework.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package com.volmit.iris.generator;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.generator.actuator.IrisBiomeActuator;
|
||||
import com.volmit.iris.generator.actuator.IrisDecorantActuator;
|
||||
import com.volmit.iris.generator.actuator.IrisTerrainActuator;
|
||||
import com.volmit.iris.generator.modifier.IrisCaveModifier;
|
||||
import com.volmit.iris.generator.modifier.IrisDepositModifier;
|
||||
import com.volmit.iris.generator.modifier.IrisPostModifier;
|
||||
import com.volmit.iris.generator.modifier.IrisRavineModifier;
|
||||
import com.volmit.iris.scaffold.engine.*;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class IrisEngineFramework implements EngineFramework {
|
||||
|
||||
@Getter
|
||||
private final Engine engine;
|
||||
|
||||
@Getter
|
||||
private final IrisComplex complex;
|
||||
|
||||
@Getter
|
||||
final EngineParallaxManager engineParallax;
|
||||
|
||||
@Getter
|
||||
private final EngineActuator<BlockData> terrainActuator;
|
||||
|
||||
@Getter
|
||||
private final EngineActuator<BlockData> decorantActuator;
|
||||
|
||||
@Getter
|
||||
private final EngineActuator<Biome> biomeActuator;
|
||||
|
||||
@Getter
|
||||
private final EngineModifier<BlockData> depositModifier;
|
||||
|
||||
@Getter
|
||||
private final EngineModifier<BlockData> caveModifier;
|
||||
|
||||
@Getter
|
||||
private final EngineModifier<BlockData> ravineModifier;
|
||||
|
||||
@Getter
|
||||
private final EngineModifier<BlockData> postModifier;
|
||||
|
||||
private final AtomicBoolean cleaning;
|
||||
private final ChronoLatch cleanLatch;
|
||||
|
||||
public IrisEngineFramework(Engine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.complex = new IrisComplex(getEngine());
|
||||
this.engineParallax = new IrisEngineParallax(getEngine());
|
||||
this.terrainActuator = new IrisTerrainActuator(getEngine());
|
||||
this.decorantActuator = new IrisDecorantActuator(getEngine());
|
||||
this.biomeActuator = new IrisBiomeActuator(getEngine());
|
||||
this.depositModifier = new IrisDepositModifier(getEngine());
|
||||
this.ravineModifier = new IrisRavineModifier(getEngine());
|
||||
this.caveModifier = new IrisCaveModifier(engine);
|
||||
this.postModifier = new IrisPostModifier(engine);
|
||||
cleaning = new AtomicBoolean(false);
|
||||
cleanLatch = new ChronoLatch(Math.max(10000, Math.min(IrisSettings.get().getParallax().getParallaxChunkEvictionMS(), IrisSettings.get().getParallax().getParallaxRegionEvictionMS())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void recycle() {
|
||||
if(!cleanLatch.flip())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (cleaning.get())
|
||||
{
|
||||
cleanLatch.flipDown();
|
||||
return;
|
||||
}
|
||||
|
||||
cleaning.set(true);
|
||||
|
||||
try
|
||||
{
|
||||
getEngine().getParallax().cleanup();
|
||||
getData().getObjectLoader().clean();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
Iris.error("Cleanup failed!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
cleaning.lazySet(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
getEngineParallax().close();
|
||||
getTerrainActuator().close();
|
||||
getDecorantActuator().close();
|
||||
getBiomeActuator().close();
|
||||
getDepositModifier().close();
|
||||
getRavineModifier().close();
|
||||
getCaveModifier().close();
|
||||
getPostModifier().close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.volmit.iris.generator;
|
||||
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineParallaxManager;
|
||||
import lombok.Getter;
|
||||
|
||||
public class IrisEngineParallax implements EngineParallaxManager {
|
||||
@Getter
|
||||
private final Engine engine;
|
||||
|
||||
@Getter
|
||||
private final int parallaxSize;
|
||||
|
||||
public IrisEngineParallax(Engine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
parallaxSize = computeParallaxSize();
|
||||
}
|
||||
}
|
||||
171
src/main/java/com/volmit/iris/generator/IrisWorldManager.java
Normal file
171
src/main/java/com/volmit/iris/generator/IrisWorldManager.java
Normal file
@@ -0,0 +1,171 @@
|
||||
package com.volmit.iris.generator;
|
||||
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.object.*;
|
||||
import com.volmit.iris.scaffold.cache.Cache;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedWorldManager;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
||||
public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
private boolean spawnable;
|
||||
|
||||
public IrisWorldManager(Engine engine) {
|
||||
super(engine);
|
||||
spawnable = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSave() {
|
||||
getEngine().getParallax().saveAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnInitialEntities(Chunk c) {
|
||||
RNG rng = new RNG(Cache.key(c));
|
||||
|
||||
getEngine().getParallaxAccess().getEntitiesR(c.getX(), c.getZ()).iterateSync((x,y,z,e) -> {
|
||||
if(e != null)
|
||||
{
|
||||
IrisEntity en = getData().getEntityLoader().load(e);
|
||||
|
||||
if(en != null){
|
||||
en.spawn(getEngine(), new Location(c.getWorld(), x+(c.getX()<<4),y,z+(c.getZ()<<4)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
int x = (c.getX() * 16) + rng.nextInt(15);
|
||||
int z = (c.getZ() * 16) + rng.nextInt(15);
|
||||
int y = getEngine().getHeight(x, z) + 1;
|
||||
IrisDimension dim = getDimension();
|
||||
IrisRegion region = getEngine().getRegion(x, z);
|
||||
IrisBiome above = getEngine().getSurfaceBiome(x, z);
|
||||
trySpawn(above.getEntityInitialSpawns(), c, rng);
|
||||
trySpawn(region.getEntityInitialSpawns(), c, rng);
|
||||
trySpawn(dim.getEntityInitialSpawns(), c, rng);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntitySpawn(EntitySpawnEvent e)
|
||||
{
|
||||
if(getTarget().getWorld() == null || !getTarget().getWorld().equals(e.getEntity().getWorld()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if(!IrisSettings.get().getGenerator().isSystemEntitySpawnOverrides())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int x = e.getEntity().getLocation().getBlockX();
|
||||
int y = e.getEntity().getLocation().getBlockY();
|
||||
int z = e.getEntity().getLocation().getBlockZ();
|
||||
|
||||
J.a(() ->
|
||||
{
|
||||
if(spawnable)
|
||||
{
|
||||
IrisDimension dim = getDimension();
|
||||
IrisRegion region = getEngine().getRegion(x, z);
|
||||
IrisBiome above = getEngine().getSurfaceBiome(x, z);
|
||||
IrisBiome bbelow = getEngine().getBiome(x, y, z);
|
||||
if(above.getLoadKey().equals(bbelow.getLoadKey()))
|
||||
{
|
||||
bbelow = null;
|
||||
}
|
||||
|
||||
IrisBiome below = bbelow;
|
||||
|
||||
J.s(() ->
|
||||
{
|
||||
if(below != null)
|
||||
{
|
||||
if(trySpawn(below.getEntitySpawnOverrides(), e))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(trySpawn(above.getEntitySpawnOverrides(), e))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(trySpawn(region.getEntitySpawnOverrides(), e))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(trySpawn(dim.getEntitySpawnOverrides(), e))
|
||||
{
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
catch(Throwable xe)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private boolean trySpawn(KList<IrisEntitySpawnOverride> s, EntitySpawnEvent e)
|
||||
{
|
||||
for(IrisEntitySpawnOverride i : s)
|
||||
{
|
||||
spawnable = false;
|
||||
|
||||
if(i.on(getEngine(), e.getLocation(), e.getEntityType(), e) != null)
|
||||
{
|
||||
e.setCancelled(true);
|
||||
e.getEntity().remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
spawnable = true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void trySpawn(KList<IrisEntityInitialSpawn> s, Chunk c, RNG rng)
|
||||
{
|
||||
for(IrisEntityInitialSpawn i : s)
|
||||
{
|
||||
i.spawn(getEngine(), c, rng);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.volmit.iris.generator.actuator;
|
||||
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedActuator;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
||||
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
public class IrisBiomeActuator extends EngineAssignedActuator<Biome>
|
||||
{
|
||||
public IrisBiomeActuator(Engine engine) {
|
||||
super(engine, "Biome");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActuate(int x, int z, Hunk<Biome> h) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
int zf,hh;
|
||||
BurstExecutor burst = MultiBurst.burst.burst(h.getWidth() * h.getDepth());
|
||||
|
||||
for(int xf = 0; xf < h.getWidth(); xf++)
|
||||
{
|
||||
for(zf = 0; zf < h.getDepth(); zf++)
|
||||
{
|
||||
int xxf = xf;
|
||||
int zzf = zf;
|
||||
|
||||
burst.queue(() -> {
|
||||
Biome v = getComplex().getTrueBiomeStream().get(modX(xxf+x), modZ(zzf+z)).getSkyBiome(RNG.r, x, 0, z);
|
||||
for(int i = 0; i < h.getHeight(); i++)
|
||||
{
|
||||
h.set(xxf, i, zzf, v);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
burst.complete();
|
||||
|
||||
getEngine().getMetrics().getBiome().put(p.getMilliseconds());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.volmit.iris.generator.actuator;
|
||||
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import com.volmit.iris.generator.decorator.IrisCeilingDecorator;
|
||||
import com.volmit.iris.generator.decorator.IrisSeaSurfaceDecorator;
|
||||
import com.volmit.iris.generator.decorator.IrisShoreLineDecorator;
|
||||
import com.volmit.iris.generator.decorator.IrisSurfaceDecorator;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedActuator;
|
||||
import com.volmit.iris.scaffold.engine.EngineDecorator;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
|
||||
{
|
||||
private static final Predicate<BlockData> PREDICATE_SOLID = (b) -> b != null && !b.getMaterial().isAir() && !b.getMaterial().equals(Material.WATER) && !b.getMaterial().equals(Material.LAVA);
|
||||
private final RNG rng;
|
||||
@Getter
|
||||
private final EngineDecorator surfaceDecorator;
|
||||
@Getter
|
||||
private final EngineDecorator ceilingDecorator;
|
||||
@Getter
|
||||
private final EngineDecorator seaSurfaceDecorator;
|
||||
@Getter
|
||||
private final EngineDecorator shoreLineDecorator;
|
||||
private final boolean shouldRay;
|
||||
|
||||
public IrisDecorantActuator(Engine engine) {
|
||||
super(engine, "Decorant");
|
||||
shouldRay = shouldRayDecorate();
|
||||
this.rng = new RNG(engine.getTarget().getWorld().getSeed());
|
||||
surfaceDecorator = new IrisSurfaceDecorator(getEngine());
|
||||
ceilingDecorator = new IrisCeilingDecorator(getEngine());
|
||||
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(getEngine());
|
||||
shoreLineDecorator = new IrisShoreLineDecorator(getEngine());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActuate(int x, int z, Hunk<BlockData> output) {
|
||||
if(!getEngine().getDimension().isDecorate())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
boolean solid;
|
||||
int emptyFor = 0;
|
||||
int lastSolid = 0;
|
||||
int j, realX, realZ, height;
|
||||
IrisBiome biome, cave;
|
||||
|
||||
for(int i = 0; i < output.getWidth(); i++)
|
||||
{
|
||||
for(j = 0; j < output.getDepth(); j++)
|
||||
{
|
||||
realX = (int) Math.round(modX(x + i));
|
||||
realZ = (int) Math.round(modZ(z + j));
|
||||
height = (int) Math.round(getComplex().getHeightStream().get(realX, realZ));
|
||||
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
|
||||
cave = shouldRay ? getComplex().getCaveBiomeStream().get(realX, realZ) : null;
|
||||
|
||||
if(biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(height == getDimension().getFluidHeight())
|
||||
{
|
||||
getShoreLineDecorator().decorate(i, j,
|
||||
realX, (int) Math.round(modX(x + i+1)), (int) Math.round(modX(x + i-1)),
|
||||
realZ, (int) Math.round(modZ(z + j+1)), (int) Math.round(modZ(z + j-1)),
|
||||
output, biome, height, getEngine().getHeight() - height);
|
||||
}
|
||||
|
||||
else if(height < getDimension().getFluidHeight())
|
||||
{
|
||||
getSeaSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, getDimension().getFluidHeight(), getEngine().getHeight() - getDimension().getFluidHeight());
|
||||
}
|
||||
|
||||
getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height);
|
||||
|
||||
if(cave != null && cave.getDecorators().isNotEmpty())
|
||||
{
|
||||
for(int k = height; k > 0; k--)
|
||||
{
|
||||
solid = PREDICATE_SOLID.test(output.get(i, k, j));
|
||||
|
||||
if(solid)
|
||||
{
|
||||
lastSolid = k;
|
||||
}
|
||||
|
||||
else {
|
||||
emptyFor++;
|
||||
}
|
||||
|
||||
if(solid && emptyFor > 0)
|
||||
{
|
||||
getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid, emptyFor);
|
||||
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor);
|
||||
emptyFor = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getEngine().getMetrics().getDecoration().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
private boolean shouldRayDecorate()
|
||||
{
|
||||
return getEngine().getDimension().isCarving() || getEngine().getDimension().isCaves() || getEngine().getDimension().isRavines();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.volmit.iris.generator.actuator;
|
||||
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedActuator;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class IrisTerrainActuator extends EngineAssignedActuator<BlockData>
|
||||
{
|
||||
private static final BlockData AIR = Material.AIR.createBlockData();
|
||||
private static final BlockData BEDROCK = Material.BEDROCK.createBlockData();
|
||||
private static final BlockData CAVE_AIR = Material.CAVE_AIR.createBlockData();
|
||||
@Getter
|
||||
private final RNG rng;
|
||||
private final boolean hasUnder;
|
||||
|
||||
public IrisTerrainActuator(Engine engine) {
|
||||
super(engine, "Terrain");
|
||||
rng = new RNG(engine.getWorld().getSeed());
|
||||
hasUnder = getDimension().getUndercarriage() != null && !getDimension().getUndercarriage().getGenerator().isFlat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActuate(int x, int z, Hunk<BlockData> h) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
int i, zf, depth, realX, realZ, hf, he, b, fdepth;
|
||||
IrisBiome biome;
|
||||
KList<BlockData> blocks, fblocks;
|
||||
|
||||
for(int xf = 0; xf < h.getWidth(); xf++)
|
||||
{
|
||||
for(zf = 0; zf < h.getDepth(); zf++)
|
||||
{
|
||||
realX = (int) modX(xf + x);
|
||||
realZ = (int) modZ(zf + z);
|
||||
b = hasUnder ? (int) Math.round(getDimension().getUndercarriage().get(rng, realX, realZ)) : 0;
|
||||
he = (int) Math.round(Math.min(h.getHeight(), getComplex().getHeightStream().get(realX, realZ)));
|
||||
hf = (int) Math.round(Math.max(Math.min(h.getHeight(), getDimension().getFluidHeight()), he));
|
||||
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
|
||||
blocks = null;
|
||||
fblocks = null;
|
||||
|
||||
if(hf < b)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for(i = hf; i >= b; i--) {
|
||||
if (i >= h.getHeight())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i == b)
|
||||
{
|
||||
if(getDimension().isBedrock())
|
||||
{
|
||||
h.set(xf, i, zf, BEDROCK);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(getDimension().isCarved(realX, i, realZ, rng, he))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i > he && i <= hf)
|
||||
{
|
||||
fdepth = hf - i;
|
||||
|
||||
if(fblocks == null)
|
||||
{
|
||||
fblocks = biome.generateSeaLayers(realX, realZ, rng, hf - he, getData());
|
||||
}
|
||||
|
||||
if(fblocks.hasIndex(fdepth))
|
||||
{
|
||||
h.set(xf, i, zf, fblocks.get(fdepth));
|
||||
continue;
|
||||
}
|
||||
|
||||
h.set(xf, i, zf, getComplex().getFluidStream().get(realX, +realZ));
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i <= he)
|
||||
{
|
||||
depth = he - i;
|
||||
if(blocks == null)
|
||||
{
|
||||
blocks = biome.generateLayers(realX, realZ, rng, (int)he, (int)he, getData(), getComplex());
|
||||
}
|
||||
|
||||
if(blocks.hasIndex(depth))
|
||||
{
|
||||
h.set(xf, i, zf, blocks.get(depth));
|
||||
continue;
|
||||
}
|
||||
|
||||
h.set(xf, i, zf, getComplex().getRockStream().get(realX, realZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getEngine().getMetrics().getTerrain().put(p.getMilliseconds());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.volmit.iris.generator.decorator;
|
||||
|
||||
import com.volmit.iris.object.DecorationPart;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisDecorator;
|
||||
import com.volmit.iris.scaffold.cache.Cache;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class IrisCeilingDecorator extends IrisEngineDecorator
|
||||
{
|
||||
public IrisCeilingDecorator(Engine engine) {
|
||||
super(engine, "Ceiling", DecorationPart.CEILING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
if(decorator != null)
|
||||
{
|
||||
if(!decorator.isStacking())
|
||||
{
|
||||
data.set(x, height-1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max);
|
||||
|
||||
for(int i = 0; i < stack; i++)
|
||||
{
|
||||
data.set(x, height-1-i, z, i == stack-1 ? decorator.getBlockDataForTop(biome, getRng(), realX+i, realZ-i, getData()) : decorator.getBlockData100(biome, getRng(), realX+i, realZ-i, getData()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.volmit.iris.generator.decorator;
|
||||
|
||||
import com.volmit.iris.object.DecorationPart;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisDecorator;
|
||||
import com.volmit.iris.scaffold.cache.Cache;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedComponent;
|
||||
import com.volmit.iris.scaffold.engine.EngineDecorator;
|
||||
import lombok.Getter;
|
||||
|
||||
public abstract class IrisEngineDecorator extends EngineAssignedComponent implements EngineDecorator {
|
||||
|
||||
@Getter
|
||||
private final RNG rng;
|
||||
|
||||
@Getter
|
||||
private final DecorationPart part;
|
||||
|
||||
public IrisEngineDecorator(Engine engine, String name, DecorationPart part) {
|
||||
super(engine, name + " Decorator");
|
||||
this.part = part;
|
||||
this.rng = new RNG(getSeed() + 29356788 - (part.ordinal() * 10439677));
|
||||
}
|
||||
|
||||
protected IrisDecorator getDecorator(IrisBiome biome, double realX, double realZ)
|
||||
{
|
||||
KList<IrisDecorator> v = new KList<>();
|
||||
RNG rng = new RNG(Cache.key((int)realX, (int)realZ));
|
||||
|
||||
for(IrisDecorator i : biome.getDecorators())
|
||||
{
|
||||
if(i.getPartOf().equals(part) && i.getBlockData(biome, this.rng, realX, realZ, getData()) != null)
|
||||
{
|
||||
v.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(v.isNotEmpty()) {
|
||||
return v.get(rng.nextInt(v.size()));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.volmit.iris.generator.decorator;
|
||||
|
||||
import com.volmit.iris.object.DecorationPart;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisDecorator;
|
||||
import com.volmit.iris.scaffold.cache.Cache;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class IrisSeaSurfaceDecorator extends IrisEngineDecorator
|
||||
{
|
||||
public IrisSeaSurfaceDecorator(Engine engine) {
|
||||
super(engine, "Sea Surface", DecorationPart.SEA_SURFACE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
|
||||
if(height < getDimension().getFluidHeight()) {
|
||||
{
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
if(decorator != null)
|
||||
{
|
||||
if(!decorator.isStacking())
|
||||
{
|
||||
data.set(x, getDimension().getFluidHeight()+1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max);
|
||||
|
||||
for(int i = 0; i < stack; i++)
|
||||
{
|
||||
data.set(x, getDimension().getFluidHeight()+1+i, z, i == stack-1 ? decorator.getBlockDataForTop(biome, getRng(), realX+i, realZ-i, getData()) : decorator.getBlockData100(biome, getRng(), realX+i, realZ-i, getData()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.volmit.iris.generator.decorator;
|
||||
|
||||
import com.volmit.iris.object.DecorationPart;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisDecorator;
|
||||
import com.volmit.iris.scaffold.cache.Cache;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class IrisShoreLineDecorator extends IrisEngineDecorator
|
||||
{
|
||||
public IrisShoreLineDecorator(Engine engine) {
|
||||
super(engine, "Shore Line", DecorationPart.SHORE_LINE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
|
||||
|
||||
if(height == getDimension().getFluidHeight()) {
|
||||
if (Math.round(getComplex().getHeightStream().get(realX1, realZ)) < getComplex().getFluidHeight() ||
|
||||
Math.round(getComplex().getHeightStream().get(realX_1, realZ)) < getComplex().getFluidHeight() ||
|
||||
Math.round(getComplex().getHeightStream().get(realX, realZ1)) < getComplex().getFluidHeight() ||
|
||||
Math.round(getComplex().getHeightStream().get(realX, realZ_1)) < getComplex().getFluidHeight()
|
||||
)
|
||||
{
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
if(decorator != null)
|
||||
{
|
||||
if(!decorator.isStacking())
|
||||
{
|
||||
data.set(x, height+1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max);
|
||||
|
||||
for(int i = 0; i < stack; i++)
|
||||
{
|
||||
data.set(x, height+1+i, z, i == stack-1 ? decorator.getBlockDataForTop(biome, getRng(), realX+i, realZ-i, getData()) : decorator.getBlockData100(biome, getRng(), realX+i, realZ-i, getData()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.volmit.iris.generator.decorator;
|
||||
|
||||
import com.volmit.iris.object.DecorationPart;
|
||||
import com.volmit.iris.object.InferredType;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisDecorator;
|
||||
import com.volmit.iris.scaffold.cache.Cache;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import org.bukkit.block.data.Bisected;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class IrisSurfaceDecorator extends IrisEngineDecorator
|
||||
{
|
||||
public IrisSurfaceDecorator(Engine engine) {
|
||||
super(engine, "Surface", DecorationPart.NONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
|
||||
if(biome.getInferredType().equals(InferredType.SHORE) && height < getDimension().getFluidHeight())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BlockData bd, bdx;
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
bdx = data.get(x, height, z);
|
||||
boolean underwater = height < getDimension().getFluidHeight();
|
||||
|
||||
if(decorator != null)
|
||||
{
|
||||
if(!decorator.isStacking())
|
||||
{
|
||||
bd = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
|
||||
|
||||
if(!underwater)
|
||||
{
|
||||
if(!canGoOn(bd, bdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(bd instanceof Bisected)
|
||||
{
|
||||
bd = bd.clone();
|
||||
((Bisected)bd).setHalf(Bisected.Half.TOP);
|
||||
try
|
||||
{
|
||||
data.set(x, height+2, z, bd);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
bd = bd.clone();
|
||||
((Bisected)bd).setHalf(Bisected.Half.BOTTOM);
|
||||
}
|
||||
|
||||
data.set(x, height+1, z, bd);
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
if (height < getDimension().getFluidHeight())
|
||||
{
|
||||
max = getDimension().getFluidHeight() - height;
|
||||
}
|
||||
|
||||
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max);
|
||||
|
||||
for(int i = 0; i < stack; i++)
|
||||
{
|
||||
bd = i == stack-1 ? decorator.getBlockDataForTop(biome, getRng(), realX+i, realZ-i, getData()) : decorator.getBlockData100(biome, getRng(), realX+i, realZ-i, getData());
|
||||
|
||||
if(bd == null && i == stack-1)
|
||||
{
|
||||
bd = decorator.getBlockData100(biome, getRng(), realX+i, realZ-i, getData());
|
||||
}
|
||||
|
||||
if(bd == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(i == 0 && !underwater && !canGoOn(bd, bdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
data.set(x, height+1+i, z, bd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
package com.volmit.iris.generator.modifier;
|
||||
|
||||
import com.volmit.iris.generator.noise.FastNoiseDouble;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisCaveLayer;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedModifier;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.*;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
|
||||
{
|
||||
public static final BlockData CAVE_AIR = B.get("CAVE_AIR");
|
||||
public static final BlockData AIR = B.get("AIR");
|
||||
private static final KList<CaveResult> EMPTY = new KList<>();
|
||||
private final FastNoiseDouble gg;
|
||||
private final RNG rng;
|
||||
|
||||
public IrisCaveModifier(Engine engine) {
|
||||
super(engine, "Cave");
|
||||
rng = new RNG(engine.getWorld().getSeed() + 28934555);
|
||||
gg = new FastNoiseDouble(324895L * rng.nextParallelRNG(49678).imax());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> a) {
|
||||
if(!getDimension().isCaves())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
for(int i = 0; i < a.getWidth(); i++)
|
||||
{
|
||||
for(int j = 0; j < a.getDepth(); j++)
|
||||
{
|
||||
KList<CaveResult> caves = genCaves(x + i, z + j, i, j, a);
|
||||
int he = (int) Math.round(getComplex().getHeightStream().get(x+i, z+j));
|
||||
if(caves != null && caves.isNotEmpty())
|
||||
{
|
||||
IrisBiome cave = getComplex().getCaveBiomeStream().get(x + i, z + j);
|
||||
|
||||
if(cave == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for(CaveResult cl : caves)
|
||||
{
|
||||
if(cl.getFloor() < 0 || cl.getFloor() > getEngine().getHeight() || cl.getCeiling() > getEngine().getHeight() || cl.getCeiling() < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
KList<BlockData> floor = cave.generateLayers(x + i, z + j, rng, cl.getFloor(), cl.getFloor(), getData(), getComplex());
|
||||
KList<BlockData> ceiling = cave.generateLayers(x + i + 656, z + j - 656, rng,
|
||||
he - cl.getCeiling(),
|
||||
he - cl.getCeiling(), getData(), getComplex());
|
||||
|
||||
for(int g = 0; g < floor.size(); g++)
|
||||
{
|
||||
a.set(i, cl.getFloor() - g, j, floor.get(g));
|
||||
}
|
||||
|
||||
for(int g = ceiling.size() - 1; g > 0; g--)
|
||||
{
|
||||
a.set(i, cl.getCeiling() + g, j, ceiling.get(g));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getEngine().getMetrics().getCave().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, Hunk<BlockData> data)
|
||||
{
|
||||
if(!getDimension().isCaves())
|
||||
{
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
KList<CaveResult> result = new KList<>();
|
||||
gg.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
|
||||
gg.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
|
||||
gg.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
|
||||
|
||||
for(int i = 0; i < getDimension().getCaveLayers().size(); i++)
|
||||
{
|
||||
IrisCaveLayer layer = getDimension().getCaveLayers().get(i);
|
||||
generateCave(result, wxx, wzz, x, z, data, layer, i);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void generateCave(KList<CaveResult> result, double wxx, double wzz, int x, int z, Hunk<BlockData> data, IrisCaveLayer layer, int seed)
|
||||
{
|
||||
double scale = layer.getCaveZoom();
|
||||
Function<Integer, BlockData> fluid = (height) ->
|
||||
{
|
||||
if(!layer.getFluid().hasFluid(getData()))
|
||||
{
|
||||
return CAVE_AIR;
|
||||
}
|
||||
|
||||
if(layer.getFluid().isInverseHeight() && height >= layer.getFluid().getFluidHeight())
|
||||
{
|
||||
return layer.getFluid().getFluid(getData());
|
||||
}
|
||||
|
||||
else if(!layer.getFluid().isInverseHeight() && height <= layer.getFluid().getFluidHeight())
|
||||
{
|
||||
return layer.getFluid().getFluid(getData());
|
||||
}
|
||||
|
||||
return CAVE_AIR;
|
||||
};
|
||||
|
||||
int surface = (int) Math.round(getComplex().getHeightStream().get(wxx, wzz));
|
||||
double wx = wxx + layer.getHorizontalSlope().get(rng, wxx, wzz);
|
||||
double wz = wzz + layer.getHorizontalSlope().get(rng, -wzz, -wxx);
|
||||
double baseWidth = (14 * scale);
|
||||
double distanceCheck = 0.0132 * baseWidth;
|
||||
double distanceTake = 0.0022 * baseWidth;
|
||||
double caveHeightNoise = layer.getVerticalSlope().get(rng, wxx, wzz);
|
||||
|
||||
if(caveHeightNoise > 259 || caveHeightNoise < -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int ceiling = -256;
|
||||
int floor = 512;
|
||||
|
||||
for(double tunnelHeight = 1; tunnelHeight <= baseWidth; tunnelHeight++)
|
||||
{
|
||||
double distance = (gg.GetCellular(((wx + (10000 * seed)) / layer.getCaveZoom()), ((wz - (10000 * seed)) / layer.getCaveZoom())) + 1D) / 2D;
|
||||
if(distance < distanceCheck - (tunnelHeight * distanceTake))
|
||||
{
|
||||
int caveHeight = (int) Math.round(caveHeightNoise);
|
||||
int pu = (int) (caveHeight + tunnelHeight);
|
||||
int pd = (int) (caveHeight - tunnelHeight);
|
||||
|
||||
if(pd > surface + 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!layer.isCanBreakSurface() && pu > surface - 3)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if((pu > 255 && pd > 255) || (pu < 0 && pd < 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(data == null)
|
||||
{
|
||||
ceiling = Math.max(pu, ceiling);
|
||||
floor = Math.min(pu, floor);
|
||||
ceiling = Math.max(pd, ceiling);
|
||||
floor = Math.min(pd, floor);
|
||||
|
||||
if(tunnelHeight == 1)
|
||||
{
|
||||
ceiling = Math.max(caveHeight, ceiling);
|
||||
floor = Math.min(caveHeight, floor);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if(dig(x, pu, z, data, fluid))
|
||||
{
|
||||
ceiling = Math.max(pu, ceiling);
|
||||
floor = Math.min(pu, floor);
|
||||
}
|
||||
|
||||
if(dig(x, pd, z, data, fluid))
|
||||
{
|
||||
ceiling = Math.max(pd, ceiling);
|
||||
floor = Math.min(pd, floor);
|
||||
}
|
||||
|
||||
if(tunnelHeight == 1)
|
||||
{
|
||||
if(dig(x, caveHeight, z, data, fluid))
|
||||
{
|
||||
ceiling = Math.max(caveHeight, ceiling);
|
||||
floor = Math.min(caveHeight, floor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(floor >= 0 && ceiling <= 255)
|
||||
{
|
||||
result.add(new CaveResult(floor, ceiling));
|
||||
}
|
||||
}
|
||||
|
||||
private Material mat(int x, int y, int z, Hunk<BlockData> data)
|
||||
{
|
||||
BlockData d = data.get(Math.max(x, 0),Math.max(y, 0),Math.max(z,0));
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
return d.getMaterial();
|
||||
}
|
||||
|
||||
return Material.CAVE_AIR;
|
||||
}
|
||||
|
||||
public boolean dig(int x, int y, int z, Hunk<BlockData> data, Function<Integer, BlockData> caveFluid)
|
||||
{
|
||||
Material a = mat(x,y,z, data);
|
||||
Material c = mat(x, y + 1, z, data);
|
||||
Material d = mat(x, y + 2, z, data);
|
||||
Material e = mat(x, y + 3, z, data);
|
||||
Material f = mat(x, y - 1, z, data);
|
||||
BlockData b = caveFluid.apply(y);
|
||||
BlockData b2 = caveFluid.apply(y + 1);
|
||||
|
||||
if(can(a) && canAir(c, b) && canAir(f, b) && canWater(d) && canWater(e))
|
||||
{
|
||||
data.set(x, y, z, b);
|
||||
data.set(x, y + 1, z, b2);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canAir(Material m, BlockData caveFluid)
|
||||
{
|
||||
return (B.isSolid(m) ||
|
||||
(B.isDecorant(m.createBlockData())) || m.equals(Material.AIR)
|
||||
|| m.equals(caveFluid.getMaterial()) ||
|
||||
m.equals(B.getMaterial("CAVE_AIR")))
|
||||
&& !m.equals(Material.BEDROCK);
|
||||
}
|
||||
|
||||
public boolean canWater(Material m)
|
||||
{
|
||||
return !m.equals(Material.WATER);
|
||||
}
|
||||
|
||||
public boolean can(Material m)
|
||||
{
|
||||
return B.isSolid(m) && !m.equals(Material.BEDROCK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.volmit.iris.generator.modifier;
|
||||
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisDepositGenerator;
|
||||
import com.volmit.iris.object.IrisObject;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedModifier;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.HeightMap;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
private final RNG rng;
|
||||
public IrisDepositModifier(Engine engine) {
|
||||
super(engine, "Deposit");
|
||||
rng = new RNG(getEngine().getWorld().getSeed()+12938).nextParallelRNG(28348777);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> output) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
generateDeposits(rng, output, Math.floorDiv(x, 16), Math.floorDiv(z, 16));
|
||||
getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
public void generateDeposits(RNG rx, Hunk<BlockData> terrain, int x, int z)
|
||||
{
|
||||
RNG ro = rx.nextParallelRNG(x * x).nextParallelRNG(z * z);
|
||||
IrisRegion region = getComplex().getRegionStream().get((x * 16) + 7, (z * 16) + 7);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStream().get((x * 16) + 7, (z * 16) + 7);
|
||||
|
||||
for(IrisDepositGenerator k : getDimension().getDeposits())
|
||||
{
|
||||
generate(k, terrain, ro, x, z, false);
|
||||
}
|
||||
|
||||
for(IrisDepositGenerator k : region.getDeposits())
|
||||
{
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
|
||||
{
|
||||
generate(k, terrain, ro, x, z, false);
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisDepositGenerator k : biome.getDeposits())
|
||||
{
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
|
||||
{
|
||||
generate(k, terrain, ro, x, z, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe)
|
||||
{
|
||||
generate(k, data, rng, cx, cz, safe, null);
|
||||
}
|
||||
|
||||
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, HeightMap he)
|
||||
{
|
||||
for(int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
|
||||
{
|
||||
IrisObject clump = k.getClump(rng, getData());
|
||||
|
||||
int af = (int) Math.ceil(clump.getW() / 2D);
|
||||
int bf = (int) Math.floor(16D - (clump.getW() / 2D));
|
||||
|
||||
if(af > bf || af < 0 || bf > 15 || af > 15 || bf < 0)
|
||||
{
|
||||
af = 6;
|
||||
bf = 9;
|
||||
}
|
||||
|
||||
int x = rng.i(af, bf);
|
||||
int z = rng.i(af, bf);
|
||||
int height = (he != null ? he.getHeight((cx << 4) + x, (cz << 4) + z) : (int) (Math.round(
|
||||
getComplex().getHeightStream().get((cx << 4) + x, (cz << 4) + z)
|
||||
))) - 7;
|
||||
|
||||
if(height <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int i = Math.max(0, k.getMinHeight());
|
||||
int a = Math.min(height, Math.min(256, k.getMaxHeight()));
|
||||
|
||||
if(i >= a)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int h = rng.i(i, a);
|
||||
|
||||
if(h > k.getMaxHeight() || h < k.getMinHeight() || h > height - 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(BlockVector j : clump.getBlocks().keySet())
|
||||
{
|
||||
int nx = j.getBlockX() + x;
|
||||
int ny = j.getBlockY() + h;
|
||||
int nz = j.getBlockZ() + z;
|
||||
|
||||
if(ny > height || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean allow = false;
|
||||
|
||||
BlockData b = data.get(nx, ny, nz);
|
||||
if(b != null) {
|
||||
for (BlockData f : getDimension().getRockPalette().getBlockData(getData())) {
|
||||
if (f.getMaterial().equals(b.getMaterial())) {
|
||||
allow = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(allow)
|
||||
{
|
||||
data.set(nx, ny, nz, clump.getBlocks().get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,551 @@
|
||||
package com.volmit.iris.generator.modifier;
|
||||
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedModifier;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.scaffold.parallel.BurstExecutor;
|
||||
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.CaveResult;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Levelled;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.block.data.type.Slab;
|
||||
|
||||
public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
private static final BlockData AIR = B.get("CAVE_AIR");
|
||||
private static final BlockData WATER = B.get("WATER");
|
||||
private final RNG rng;
|
||||
|
||||
public IrisPostModifier(Engine engine) {
|
||||
super(engine, "Post");
|
||||
rng = new RNG(getEngine().getWorld().getSeed()+12938).nextParallelRNG(28348777);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> output) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
BurstExecutor b = MultiBurst.burst.burst(output.getWidth() * output.getDepth());
|
||||
int i, j;
|
||||
for(i = 0; i < output.getWidth(); i++)
|
||||
{
|
||||
int ii = i;
|
||||
for(j = 0; j < output.getDepth(); j++)
|
||||
{
|
||||
int jj = j;
|
||||
b.queue(() -> post(ii, jj, output, ii+x, jj+z));
|
||||
}
|
||||
}
|
||||
b.complete();
|
||||
getEngine().getMetrics().getPost().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
private void post(int currentPostX, int currentPostZ, Hunk<BlockData> currentData, int x, int z) {
|
||||
|
||||
int h = getFramework().getEngineParallax().trueHeight(x, z);
|
||||
int ha = getFramework().getEngineParallax().trueHeight(x + 1, z);
|
||||
int hb = getFramework().getEngineParallax().trueHeight(x, z + 1);
|
||||
int hc = getFramework().getEngineParallax().trueHeight(x - 1, z);
|
||||
int hd = getFramework().getEngineParallax().trueHeight(x, z - 1);
|
||||
|
||||
// Floating Nibs
|
||||
int g = 0;
|
||||
|
||||
if(h < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g += ha < h - 1 ? 1 : 0;
|
||||
g += hb < h - 1 ? 1 : 0;
|
||||
g += hc < h - 1 ? 1 : 0;
|
||||
g += hd < h - 1 ? 1 : 0;
|
||||
|
||||
if(g == 4 && isAir(x, h - 1, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
setPostBlock(x, h, z, AIR, currentPostX, currentPostZ, currentData);
|
||||
|
||||
for(int i = h - 1; i > 0; i--)
|
||||
{
|
||||
if(!isAir(x, i, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
h = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nibs
|
||||
g = 0;
|
||||
g += ha == h - 1 ? 1 : 0;
|
||||
g += hb == h - 1 ? 1 : 0;
|
||||
g += hc == h - 1 ? 1 : 0;
|
||||
g += hd == h - 1 ? 1 : 0;
|
||||
|
||||
if(g >= 4)
|
||||
{
|
||||
BlockData bc = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData);
|
||||
Material m = bc.getMaterial();
|
||||
|
||||
if((b.getMaterial().isOccluding() && b.getMaterial().isSolid()))
|
||||
{
|
||||
if(m.isSolid())
|
||||
{
|
||||
setPostBlock(x, h, z, b, currentPostX, currentPostZ, currentData);
|
||||
h--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Potholes
|
||||
g = 0;
|
||||
g += ha == h + 1 ? 1 : 0;
|
||||
g += hb == h + 1 ? 1 : 0;
|
||||
g += hc == h + 1 ? 1 : 0;
|
||||
g += hd == h + 1 ? 1 : 0;
|
||||
|
||||
if(g >= 4)
|
||||
{
|
||||
BlockData ba = getPostBlock(x, ha, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData bb = getPostBlock(x, hb, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData bc = getPostBlock(x, hc, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData bd = getPostBlock(x, hd, z, currentPostX, currentPostZ, currentData);
|
||||
g = 0;
|
||||
g = B.isSolid(ba) ? g + 1 : g;
|
||||
g = B.isSolid(bb) ? g + 1 : g;
|
||||
g = B.isSolid(bc) ? g + 1 : g;
|
||||
g = B.isSolid(bd) ? g + 1 : g;
|
||||
|
||||
if(g >= 3)
|
||||
{
|
||||
setPostBlock(x, h + 1, z, getPostBlock(x, h, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData);
|
||||
h++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wall Patcher
|
||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(x,z);
|
||||
|
||||
if(getDimension().isPostProcessingWalls())
|
||||
{
|
||||
if(!biome.getWall().getPalette().isEmpty())
|
||||
{
|
||||
if(ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2)
|
||||
{
|
||||
boolean brokeGround = false;
|
||||
int max = Math.abs(Math.max(h - ha, Math.max(h - hb, Math.max(h - hc, h - hd))));
|
||||
|
||||
for(int i = h; i > h - max; i--)
|
||||
{
|
||||
BlockData d = biome.getWall().get(rng, x + i, i + h, z + i, getData());
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
if(isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
if(brokeGround)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
setPostBlock(x, i, z, d, currentPostX, currentPostZ, currentData);
|
||||
brokeGround = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Slab
|
||||
if(getDimension().isPostProcessingSlabs())
|
||||
{
|
||||
//@builder
|
||||
if((ha == h + 1 && isSolidNonSlab(x + 1, ha, z, currentPostX, currentPostZ, currentData))
|
||||
|| (hb == h + 1 && isSolidNonSlab(x, hb, z + 1, currentPostX, currentPostZ, currentData))
|
||||
|| (hc == h + 1 && isSolidNonSlab(x - 1, hc, z, currentPostX, currentPostZ, currentData))
|
||||
|| (hd == h + 1 && isSolidNonSlab(x, hd, z - 1, currentPostX, currentPostZ, currentData)))
|
||||
//@done
|
||||
{
|
||||
BlockData d = biome.getSlab().get(rng, x, h, z, getData());
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
boolean cancel = false;
|
||||
|
||||
if(B.isAir(d))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(d.getMaterial().equals(Material.SNOW) && h + 1 <= getDimension().getFluidHeight())
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(!cancel && isAirOrWater(x, h + 1, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
setPostBlock(x, h + 1, z, d, currentPostX, currentPostZ, currentData);
|
||||
h++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Waterlogging
|
||||
BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
|
||||
|
||||
if(b instanceof Waterlogged)
|
||||
{
|
||||
Waterlogged ww = (Waterlogged) b.clone();
|
||||
boolean w = false;
|
||||
|
||||
if (h <= getDimension().getFluidHeight()+1) {
|
||||
if(isWaterOrWaterlogged(x, h + 1, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
w = true;
|
||||
}
|
||||
|
||||
else if((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
w = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(w != ww.isWaterlogged())
|
||||
{
|
||||
ww.setWaterlogged(w);
|
||||
setPostBlock(x, h, z, ww, currentPostX, currentPostZ, currentData);
|
||||
}
|
||||
}
|
||||
|
||||
else if(b.getMaterial().equals(Material.AIR) && h <= getDimension().getFluidHeight())
|
||||
{
|
||||
if((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
setPostBlock(x, h, z, WATER, currentPostX, currentPostZ, currentData);
|
||||
}
|
||||
}
|
||||
|
||||
// Foliage
|
||||
b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData);
|
||||
|
||||
if(B.isFoliage(b) || b.getMaterial().equals(Material.DEAD_BUSH))
|
||||
{
|
||||
Material onto = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData).getMaterial();
|
||||
|
||||
if(!B.canPlaceOnto(b.getMaterial(), onto))
|
||||
{
|
||||
setPostBlock(x, h + 1, z, AIR, currentPostX, currentPostZ, currentData);
|
||||
}
|
||||
}
|
||||
|
||||
if(getDimension().isPostProcessCaves())
|
||||
{
|
||||
IrisBiome cave = getComplex().getCaveBiomeStream().get(x, z);
|
||||
|
||||
if(cave != null)
|
||||
{
|
||||
for(CaveResult i : ((IrisCaveModifier)getFramework().getCaveModifier()).genCaves(x, z, 0, 0, null))
|
||||
{
|
||||
if(i.getCeiling() >= currentData.getMax2DParallelism() || i.getFloor() < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int f = i.getFloor();
|
||||
int fa = nearestCaveFloor(f, x + 1, z, currentPostX, currentPostZ, currentData);
|
||||
int fb = nearestCaveFloor(f, x, z + 1, currentPostX, currentPostZ, currentData);
|
||||
int fc = nearestCaveFloor(f, x - 1, z, currentPostX, currentPostZ, currentData);
|
||||
int fd = nearestCaveFloor(f, x, z - 1, currentPostX, currentPostZ, currentData);
|
||||
int c = i.getCeiling();
|
||||
int ca = nearestCaveCeiling(c, x + 1, z, currentPostX, currentPostZ, currentData);
|
||||
int cb = nearestCaveCeiling(c, x, z + 1, currentPostX, currentPostZ, currentData);
|
||||
int cc = nearestCaveCeiling(c, x - 1, z, currentPostX, currentPostZ, currentData);
|
||||
int cd = nearestCaveCeiling(c, x, z - 1, currentPostX, currentPostZ, currentData);
|
||||
|
||||
// Cave Nibs
|
||||
g = 0;
|
||||
g += fa == f - 1 ? 1 : 0;
|
||||
g += fb == f - 1 ? 1 : 0;
|
||||
g += fc == f - 1 ? 1 : 0;
|
||||
g += fd == f - 1 ? 1 : 0;
|
||||
|
||||
if(g >= 4)
|
||||
{
|
||||
BlockData bc = getPostBlock(x, f, z, currentPostX, currentPostZ, currentData);
|
||||
b = getPostBlock(x, f + 1, z, currentPostX, currentPostZ, currentData);
|
||||
Material m = bc.getMaterial();
|
||||
|
||||
if(m.isSolid())
|
||||
{
|
||||
setPostBlock(x, f, z, b, currentPostX, currentPostZ, currentData);
|
||||
h--;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Cave Potholes
|
||||
g = 0;
|
||||
g += fa == f + 1 ? 1 : 0;
|
||||
g += fb == f + 1 ? 1 : 0;
|
||||
g += fc == f + 1 ? 1 : 0;
|
||||
g += fd == f + 1 ? 1 : 0;
|
||||
|
||||
if(g >= 4)
|
||||
{
|
||||
BlockData ba = getPostBlock(x, fa, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData bb = getPostBlock(x, fb, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData bc = getPostBlock(x, fc, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData bd = getPostBlock(x, fd, z, currentPostX, currentPostZ, currentData);
|
||||
g = 0;
|
||||
g = B.isSolid(ba) ? g + 1 : g;
|
||||
g = B.isSolid(bb) ? g + 1 : g;
|
||||
g = B.isSolid(bc) ? g + 1 : g;
|
||||
g = B.isSolid(bd) ? g + 1 : g;
|
||||
|
||||
if(g >= 4)
|
||||
{
|
||||
setPostBlock(x, f + 1, z, getPostBlock(x, f, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData);
|
||||
h++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(getDimension().isPostProcessingSlabs())
|
||||
{
|
||||
//@builder
|
||||
if((fa == f + 1 && isSolidNonSlab(x + 1, fa, z, currentPostX, currentPostZ, currentData))
|
||||
|| (fb == f + 1 && isSolidNonSlab(x, fb, z + 1, currentPostX, currentPostZ, currentData))
|
||||
|| (fc == f + 1 && isSolidNonSlab(x - 1, fc, z, currentPostX, currentPostZ, currentData))
|
||||
|| (fd == f + 1 && isSolidNonSlab(x, fd, z - 1, currentPostX, currentPostZ, currentData)))
|
||||
//@done
|
||||
{
|
||||
BlockData d = cave.getSlab().get(rng, x, f, z, getData());
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
boolean cancel = false;
|
||||
|
||||
if(B.isAir(d))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(d.getMaterial().equals(Material.SNOW) && f + 1 <= getDimension().getFluidHeight())
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(isSnowLayer(x, f, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(!cancel && isAirOrWater(x, f + 1, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
setPostBlock(x, f + 1, z, d, currentPostX, currentPostZ, currentData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//@builder
|
||||
if((ca == c - 1 && isSolidNonSlab(x + 1, ca, z, currentPostX, currentPostZ, currentData))
|
||||
|| (cb == c - 1 && isSolidNonSlab(x, cb, z + 1, currentPostX, currentPostZ, currentData))
|
||||
|| (cc == c - 1 && isSolidNonSlab(x - 1, cc, z, currentPostX, currentPostZ, currentData))
|
||||
|| (cd == c - 1 && isSolidNonSlab(x, cd, z - 1, currentPostX, currentPostZ, currentData)))
|
||||
//@done
|
||||
{
|
||||
BlockData d = cave.getSlab().get(rng, x, c, z, getData());
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
boolean cancel = false;
|
||||
|
||||
if(B.isAir(d))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(!(d instanceof Slab))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(isSnowLayer(x, c, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if(!cancel && isAirOrWater(x, c, z, currentPostX, currentPostZ, currentData))
|
||||
{
|
||||
Slab slab = (Slab) d.clone();
|
||||
slab.setType(Slab.Type.TOP);
|
||||
setPostBlock(x, c, z, slab, currentPostX, currentPostZ, currentData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int nearestCaveFloor(int floor, int x, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
if(floor >= currentData.getHeight())
|
||||
{
|
||||
return currentData.getHeight()-1;
|
||||
}
|
||||
|
||||
if(B.isAir(getPostBlock(x, floor, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
if(B.isAir(getPostBlock(x, floor - 1, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
return floor - 2;
|
||||
}
|
||||
|
||||
return floor - 1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if(!B.isAir(getPostBlock(x, floor + 1, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
if(!B.isAir(getPostBlock(x, floor + 2, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
return floor + 2;
|
||||
}
|
||||
|
||||
return floor + 1;
|
||||
}
|
||||
|
||||
return floor;
|
||||
}
|
||||
}
|
||||
|
||||
private int nearestCaveCeiling(int ceiling, int x, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
if(ceiling >= currentData.getHeight())
|
||||
{
|
||||
return currentData.getHeight()-1;
|
||||
}
|
||||
|
||||
if(B.isAir(getPostBlock(x, ceiling, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
if(B.isAir(getPostBlock(x, ceiling + 1, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
return ceiling + 2;
|
||||
}
|
||||
|
||||
return ceiling + 1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if(!B.isAir(getPostBlock(x, ceiling - 1, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
if(!B.isAir(getPostBlock(x, ceiling - 2, z, currentPostX, currentPostZ, currentData)))
|
||||
{
|
||||
return ceiling - 2;
|
||||
}
|
||||
|
||||
return ceiling - 1;
|
||||
}
|
||||
|
||||
return ceiling;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAir(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
|
||||
return d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR);
|
||||
}
|
||||
|
||||
public boolean hasGravity(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
|
||||
return d.getMaterial().equals(Material.SAND) || d.getMaterial().equals(Material.RED_SAND) || d.getMaterial().equals(Material.BLACK_CONCRETE_POWDER) || d.getMaterial().equals(Material.BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.BROWN_CONCRETE_POWDER) || d.getMaterial().equals(Material.CYAN_CONCRETE_POWDER) || d.getMaterial().equals(Material.GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.GREEN_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_BLUE_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIGHT_GRAY_CONCRETE_POWDER) || d.getMaterial().equals(Material.LIME_CONCRETE_POWDER) || d.getMaterial().equals(Material.MAGENTA_CONCRETE_POWDER) || d.getMaterial().equals(Material.ORANGE_CONCRETE_POWDER) || d.getMaterial().equals(Material.PINK_CONCRETE_POWDER) || d.getMaterial().equals(Material.PURPLE_CONCRETE_POWDER) || d.getMaterial().equals(Material.RED_CONCRETE_POWDER) || d.getMaterial().equals(Material.WHITE_CONCRETE_POWDER) || d.getMaterial().equals(Material.YELLOW_CONCRETE_POWDER);
|
||||
}
|
||||
|
||||
public boolean isSolid(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
|
||||
return d.getMaterial().isSolid();
|
||||
}
|
||||
|
||||
public boolean isSolidNonSlab(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
|
||||
return d.getMaterial().isSolid() && !(d instanceof Slab);
|
||||
}
|
||||
|
||||
public boolean isAirOrWater(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
|
||||
return d.getMaterial().equals(Material.WATER) || d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR);
|
||||
}
|
||||
|
||||
public boolean isSlab(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
|
||||
return d instanceof Slab;
|
||||
}
|
||||
|
||||
public boolean isSnowLayer(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
|
||||
return d.getMaterial().equals(Material.SNOW);
|
||||
}
|
||||
|
||||
public boolean isWater(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
|
||||
return d.getMaterial().equals(Material.WATER);
|
||||
}
|
||||
|
||||
public boolean isWaterOrWaterlogged(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
|
||||
return d.getMaterial().equals(Material.WATER) || (d instanceof Waterlogged && ((Waterlogged) d).isWaterlogged());
|
||||
}
|
||||
|
||||
public boolean isLiquid(int x, int y, int z, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
|
||||
return d instanceof Levelled;
|
||||
}
|
||||
|
||||
|
||||
public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, Hunk<BlockData> currentData)
|
||||
{
|
||||
if(y < currentData.getHeight())
|
||||
{
|
||||
currentData.set(x & 15, y, z & 15, d);
|
||||
}
|
||||
}
|
||||
|
||||
public BlockData getPostBlock(int x, int y, int z, int cpx, int cpz, Hunk<BlockData> h)
|
||||
{
|
||||
BlockData b = h.getClosest(x & 15, y, z & 15);
|
||||
|
||||
return b == null ? AIR : b;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
package com.volmit.iris.generator.modifier;
|
||||
|
||||
import com.volmit.iris.generator.noise.CNG;
|
||||
import com.volmit.iris.object.NoiseStyle;
|
||||
import com.volmit.iris.util.*;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedModifier;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
||||
private static final BlockData CAVE_AIR = B.get("CAVE_AIR");
|
||||
private static final BlockData LAVA = B.get("LAVA");
|
||||
private CNG cng;
|
||||
private RNG rng;
|
||||
|
||||
public IrisRavineModifier(Engine engine) {
|
||||
super(engine, "Ravine");
|
||||
rng = new RNG(getEngine().getWorld().getSeed()).nextParallelRNG(29596878);
|
||||
cng = NoiseStyle.IRIS_THICK.create(rng);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> output) {
|
||||
if(!getDimension().isRavines())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
generateRavines(rng, Math.floorDiv(x, 16), Math.floorDiv(z, 16), output);
|
||||
getEngine().getMetrics().getRavine().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
private void set(Hunk<BlockData> pos, int x, int y, int z, BlockData b)
|
||||
{
|
||||
pos.set(x, y, z, b);
|
||||
}
|
||||
|
||||
private BlockData get(Hunk<BlockData> pos, int x, int y, int z)
|
||||
{
|
||||
BlockData bb = pos.get(x, y, z);
|
||||
|
||||
if(bb == null)
|
||||
{
|
||||
bb = CAVE_AIR;
|
||||
}
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
private BlockData getSurfaceBlock(int n6, int i, RNG rmg)
|
||||
{
|
||||
return getComplex().getTrueBiomeStream().get(n6,i).getSurfaceBlock(n6, i, rmg, getData());
|
||||
}
|
||||
|
||||
private float[] ravineCache = new float[1024];
|
||||
|
||||
private void doRavine(long seed, int tx, int tz, ChunkPosition pos, double sx, double sy, double sz, float f, float f2, float f3, int n3, int n4, double d4, RNG bbx, Hunk<BlockData> terrain)
|
||||
{
|
||||
int n5;
|
||||
RNG random = new RNG(seed);
|
||||
double x = tx * 16 + 8;
|
||||
double z = tz * 16 + 8;
|
||||
float f4 = 0.0f;
|
||||
float f5 = 0.0f;
|
||||
if(n4 <= 0)
|
||||
{
|
||||
n5 = 8 * 16 - 16;
|
||||
n4 = n5 - random.nextInt(n5 / 4);
|
||||
}
|
||||
n5 = 0;
|
||||
if(n3 == -1)
|
||||
{
|
||||
n3 = n4 / 2;
|
||||
n5 = 1;
|
||||
}
|
||||
float f6 = 1.0f;
|
||||
for(int i = 0; i < 256; ++i)
|
||||
{
|
||||
if(i == 0 || random.nextInt(getDimension().getRavineRibRarity()) == 0)
|
||||
{
|
||||
f6 = 1.0f + random.nextFloat() * random.nextFloat() * 1.0f;
|
||||
}
|
||||
this.ravineCache[i] = f6 * f6;
|
||||
}
|
||||
while(n3 < n4)
|
||||
{
|
||||
double d7 = 1.5 + (double) (MathHelper.sin((float) n3 * 3.1415927f / (float) n4) * f * 1.0f);
|
||||
double d8 = d7 * d4;
|
||||
d7 *= (double) random.nextFloat() * 0.25 + 0.75;
|
||||
d8 *= (double) random.nextFloat() * 0.25 + 0.75;
|
||||
float f7 = MathHelper.cos(f3);
|
||||
float f8 = MathHelper.sin(f3);
|
||||
sx = sx + (double) (MathHelper.cos(f2) * f7);
|
||||
sy += f8;
|
||||
sz += MathHelper.sin(f2) * f7;
|
||||
f3 *= 0.7f;
|
||||
f3 += f5 * 0.05f;
|
||||
f2 += f4 * 0.05f;
|
||||
f5 *= 0.8f;
|
||||
f4 *= 0.5f;
|
||||
f5 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0f;
|
||||
f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0f;
|
||||
if(n5 != 0 || random.nextInt(4) != 0)
|
||||
{
|
||||
double d9 = sx - x;
|
||||
double d10 = sz - z;
|
||||
double d11 = n4 - n3;
|
||||
double d12 = f + 2.0f + 16.0f;
|
||||
if(d9 * d9 + d10 * d10 - d11 * d11 > d12 * d12)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(sx >= x - 16.0 - d7 * 2.0 && sz >= z - 16.0 - d7 * 2.0 && sx <= x + 16.0 + d7 * 2.0 && sz <= z + 16.0 + d7 * 2.0)
|
||||
{
|
||||
int n6;
|
||||
int n7 = MathHelper.floor(sx - d7) - tx * 16 - 1;
|
||||
int n8 = MathHelper.floor(sx + d7) - tx * 16 + 1;
|
||||
int n9 = MathHelper.floor(sy - d8) - 1;
|
||||
int n10 = MathHelper.floor(sy + d8) + 1;
|
||||
int n11 = MathHelper.floor(sz - d7) - tz * 16 - 1;
|
||||
int n12 = MathHelper.floor(sz + d7) - tz * 16 + 1;
|
||||
if(n7 < 0)
|
||||
{
|
||||
n7 = 0;
|
||||
}
|
||||
if(n8 > 16)
|
||||
{
|
||||
n8 = 16;
|
||||
}
|
||||
if(n9 < 1)
|
||||
{
|
||||
n9 = 1;
|
||||
}
|
||||
if(n10 > 248)
|
||||
{
|
||||
n10 = 248;
|
||||
}
|
||||
if(n11 < 0)
|
||||
{
|
||||
n11 = 0;
|
||||
}
|
||||
if(n12 > 16)
|
||||
{
|
||||
n12 = 16;
|
||||
}
|
||||
boolean bl = false;
|
||||
for(int i = n7; !bl && i < n8; ++i)
|
||||
{
|
||||
for(n6 = n11; !bl && n6 < n12; ++n6)
|
||||
{
|
||||
for(int j = n10 + 1; !bl && j >= n9 - 1; --j)
|
||||
{
|
||||
if(j < 0 || j >= 256)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData bb = get(terrain, i, j, n6);
|
||||
|
||||
if(B.isWater(bb))
|
||||
{
|
||||
bl = true;
|
||||
}
|
||||
|
||||
if(j == n9 - 1 || i == n7 || i == n8 - 1 || n6 == n11 || n6 == n12 - 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
j = n9;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!bl) {
|
||||
BlockPosition bps = new BlockPosition(0, 0, 0);
|
||||
for (n6 = n7; n6 < n8; ++n6) {
|
||||
double d13 = ((double) (n6 + tx * 16) + 0.5 - sx) / d7;
|
||||
for (int i = n11; i < n12; ++i) {
|
||||
double d14 = ((double) (i + tz * 16) + 0.5 - sz) / d7;
|
||||
boolean bl2 = false;
|
||||
if (d13 * d13 + d14 * d14 >= 1.0) {
|
||||
continue;
|
||||
}
|
||||
for (int j = n10; j > n9; --j) {
|
||||
double d15 = ((double) (j - 1) + 0.5 - sy) / d8;
|
||||
if ((d13 * d13 + d14 * d14) * (double) this.ravineCache[j - 1] + d15 * d15 / 6.0 >= 1.0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData blockData = get(terrain, n6, j, i);
|
||||
|
||||
if (isSurface(blockData)) {
|
||||
bl2 = true;
|
||||
}
|
||||
|
||||
if (j - 1 < 10) {
|
||||
set(terrain, n6, j, i, LAVA);
|
||||
continue;
|
||||
}
|
||||
|
||||
set(terrain, n6, j, i, CAVE_AIR);
|
||||
if (!bl2 || !isDirt(get(terrain, n6, j - 1, i))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
cSet(bps, n6 + tx * 16, 0, i + tz * 16);
|
||||
set(terrain, n6, j - 1, i, getSurfaceBlock(n6, i, rng));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (n5 != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
++n3;
|
||||
}
|
||||
}
|
||||
|
||||
private BlockPosition cSet(BlockPosition bb, double var0, double var2, double var4)
|
||||
{
|
||||
bb.setX(MathHelper.floor((double) var0));
|
||||
bb.setY(MathHelper.floor((double) var2));
|
||||
bb.setZ(MathHelper.floor((double) var4));
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
private boolean isDirt(BlockData d)
|
||||
{
|
||||
//@builder
|
||||
Material m = d.getMaterial();
|
||||
return m.equals(Material.DIRT) ||
|
||||
m.equals(Material.COARSE_DIRT) ||
|
||||
m.equals(Material.SAND);
|
||||
//@done
|
||||
}
|
||||
|
||||
private boolean isSurface(BlockData d)
|
||||
{
|
||||
//@builder
|
||||
Material m = d.getMaterial();
|
||||
return m.equals(Material.GRASS_BLOCK) ||
|
||||
m.equals(Material.DIRT) ||
|
||||
m.equals(Material.COARSE_DIRT) ||
|
||||
m.equals(Material.PODZOL) ||
|
||||
m.equals(Material.SAND);
|
||||
//@done
|
||||
}
|
||||
|
||||
public void genRavines(int n, int n2, ChunkPosition chunkSnapshot, RNG bbb, Hunk<BlockData> terrain)
|
||||
{
|
||||
RNG b = this.rng.nextParallelRNG(21949666);
|
||||
RNG bx = this.rng.nextParallelRNG(6676121);
|
||||
long l = b.nextLong();
|
||||
long l2 = b.nextLong();
|
||||
for(int i = n - 8; i <= n + 8; ++i)
|
||||
{
|
||||
for(int j = n2 - 8; j <= n2 + 8; ++j)
|
||||
{
|
||||
long l3 = (long) i * l;
|
||||
long l4 = (long) j * l2;
|
||||
bx = this.rng.nextParallelRNG((int) (l3 ^ l4 ^ 6676121));
|
||||
doRavines(i, j, n, n2, chunkSnapshot, bx, terrain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doRavines(int tx, int tz, int sx, int sz, ChunkPosition chunkSnapshot, RNG b, Hunk<BlockData> terrain)
|
||||
{
|
||||
if(b.nextInt(getDimension().getRavineRarity()) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double x = tx * 16 + b.nextInt(16);
|
||||
double d2 = b.nextInt(b.nextInt(40) + 8) + 20;
|
||||
double z = tz * 16 + b.nextInt(16);
|
||||
int n5 = 1;
|
||||
for(int i = 0; i < n5; ++i)
|
||||
{
|
||||
float f = b.nextFloat() * 3.1415927f * 2.0f;
|
||||
float f2 = (b.nextFloat() - 0.5f) * 2.0f / 8.0f;
|
||||
float f3 = (b.nextFloat() * 2.0f + b.nextFloat()) * 2.0f;
|
||||
this.doRavine(b.nextLong(), sx, sz, chunkSnapshot, x, d2, z, f3, f, f2, 0, 0, 3.0, b, terrain);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateRavines(RNG nextParallelRNG, int x, int z, Hunk<BlockData> terrain)
|
||||
{
|
||||
genRavines(x, z, new ChunkPosition(x, z), nextParallelRNG.nextParallelRNG(x).nextParallelRNG(z), terrain);
|
||||
}
|
||||
}
|
||||
410
src/main/java/com/volmit/iris/generator/noise/CNG.java
Normal file
410
src/main/java/com/volmit/iris/generator/noise/CNG.java
Normal file
@@ -0,0 +1,410 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.scaffold.stream.ProceduralStream;
|
||||
import com.volmit.iris.scaffold.stream.arithmetic.FittedStream;
|
||||
import com.volmit.iris.scaffold.stream.sources.CNGStream;
|
||||
import com.volmit.iris.util.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CNG
|
||||
{
|
||||
public static long hits = 0;
|
||||
public static long creates = 0;
|
||||
public static final NoiseInjector ADD = (s, v) -> new double[] {s + v, 1};
|
||||
public static final NoiseInjector SRC_SUBTRACT = (s, v) -> new double[] {s - v < 0 ? 0 : s - v, -1};
|
||||
public static final NoiseInjector DST_SUBTRACT = (s, v) -> new double[] {v - s < 0 ? 0 : s - v, -1};
|
||||
public static final NoiseInjector MULTIPLY = (s, v) -> new double[] {s * v, 0};
|
||||
public static final NoiseInjector MAX = (s, v) -> new double[] {Math.max(s, v), 0};
|
||||
public static final NoiseInjector MIN = (s, v) -> new double[] {Math.min(s, v), 0};
|
||||
public static final NoiseInjector SRC_MOD = (s, v) -> new double[] {s % v, 0};
|
||||
public static final NoiseInjector SRC_POW = (s, v) -> new double[] {Math.pow(s, v), 0};
|
||||
public static final NoiseInjector DST_MOD = (s, v) -> new double[] {v % s, 0};
|
||||
public static final NoiseInjector DST_POW = (s, v) -> new double[] {Math.pow(v, s), 0};
|
||||
private double scale;
|
||||
private double bakedScale;
|
||||
private double fscale;
|
||||
private boolean trueFracturing = false;
|
||||
private KList<CNG> children;
|
||||
private CNG fracture;
|
||||
private NoiseGenerator generator;
|
||||
private final double opacity;
|
||||
private NoiseInjector injector;
|
||||
private RNG rng;
|
||||
private boolean noscale;
|
||||
private int oct;
|
||||
private double patch;
|
||||
private double up;
|
||||
private double down;
|
||||
private double power;
|
||||
|
||||
public NoiseGenerator getGen()
|
||||
{
|
||||
return generator;
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> stream()
|
||||
{
|
||||
return new CNGStream(this);
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> stream(double min, double max)
|
||||
{
|
||||
return new FittedStream<Double>(stream(), min, max);
|
||||
}
|
||||
|
||||
public static CNG signature(RNG rng)
|
||||
{
|
||||
return signature(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signatureHalf(RNG rng)
|
||||
{
|
||||
return signatureHalf(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signatureThick(RNG rng)
|
||||
{
|
||||
return signatureThick(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signatureDouble(RNG rng)
|
||||
{
|
||||
return signatureDouble(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
||||
public static CNG signatureDouble(RNG rng, NoiseType t)
|
||||
{
|
||||
return signatureThick(rng, t).fractureWith(signature(rng.nextParallelRNG(4956)), 93);
|
||||
}
|
||||
|
||||
public static CNG signature(RNG rng, NoiseType t)
|
||||
{
|
||||
// @NoArgsConstructor
|
||||
return new CNG(rng.nextParallelRNG(17), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.9).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.21).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.9), 620), 145), 44).bake();
|
||||
// @done
|
||||
}
|
||||
|
||||
public static CNG signatureThick(RNG rng, NoiseType t)
|
||||
{
|
||||
// @NoArgsConstructor
|
||||
return new CNG(rng.nextParallelRNG(133), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.5).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.11).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.4), 620), 145), 44).bake();
|
||||
// @done
|
||||
}
|
||||
|
||||
public static CNG signatureHalf(RNG rng, NoiseType t)
|
||||
{
|
||||
// @NoArgsConstructor
|
||||
return new CNG(rng.nextParallelRNG(127), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.9).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.21).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.9), 420), 99), 22).bake();
|
||||
// @done
|
||||
}
|
||||
|
||||
public CNG(RNG random)
|
||||
{
|
||||
this(random, 1);
|
||||
}
|
||||
|
||||
public CNG(RNG random, int octaves)
|
||||
{
|
||||
this(random, 1D, octaves);
|
||||
}
|
||||
|
||||
public CNG(RNG random, double opacity, int octaves)
|
||||
{
|
||||
this(random, NoiseType.SIMPLEX, opacity, octaves);
|
||||
}
|
||||
|
||||
public CNG(RNG random, NoiseType t, double opacity, int octaves)
|
||||
{
|
||||
creates++;
|
||||
noscale = t.equals(NoiseType.WHITE);
|
||||
this.oct = octaves;
|
||||
this.rng = random;
|
||||
power = 1;
|
||||
scale = 1;
|
||||
patch = 1;
|
||||
bakedScale = 1;
|
||||
fscale = 1;
|
||||
down = 0;
|
||||
up = 0;
|
||||
fracture = null;
|
||||
generator = t.create(random.nextParallelRNG(33).lmax());
|
||||
this.opacity = opacity;
|
||||
this.injector = ADD;
|
||||
|
||||
if(generator instanceof OctaveNoise)
|
||||
{
|
||||
((OctaveNoise) generator).setOctaves(octaves);
|
||||
}
|
||||
}
|
||||
|
||||
public CNG bake()
|
||||
{
|
||||
bakedScale *= scale;
|
||||
scale = 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG child(CNG c)
|
||||
{
|
||||
if(children == null)
|
||||
{
|
||||
children = new KList<>();
|
||||
}
|
||||
|
||||
children.add(c);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RNG getRNG()
|
||||
{
|
||||
return rng;
|
||||
}
|
||||
|
||||
public CNG fractureWith(CNG c, double scale)
|
||||
{
|
||||
fracture = c;
|
||||
fscale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG scale(double c)
|
||||
{
|
||||
scale = c;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG patch(double c)
|
||||
{
|
||||
patch = c;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG up(double c)
|
||||
{
|
||||
up = c;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG down(double c)
|
||||
{
|
||||
down = c;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG injectWith(NoiseInjector i)
|
||||
{
|
||||
injector = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T extends IRare> T fitRarity(KList<T> b, double... dim)
|
||||
{
|
||||
if(b.size() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(b.size() == 1)
|
||||
{
|
||||
return b.get(0);
|
||||
}
|
||||
|
||||
KList<T> rarityMapped = new KList<>();
|
||||
boolean o = false;
|
||||
int max = 1;
|
||||
for(T i : b)
|
||||
{
|
||||
if(i.getRarity() > max)
|
||||
{
|
||||
max = i.getRarity();
|
||||
}
|
||||
}
|
||||
|
||||
max++;
|
||||
|
||||
for(T i : b)
|
||||
{
|
||||
for(int j = 0; j < max - i.getRarity(); j++)
|
||||
{
|
||||
if(o = !o)
|
||||
{
|
||||
rarityMapped.add(i);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
rarityMapped.add(0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rarityMapped.size() == 1)
|
||||
{
|
||||
return rarityMapped.get(0);
|
||||
}
|
||||
|
||||
if(rarityMapped.isEmpty())
|
||||
{
|
||||
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
|
||||
}
|
||||
|
||||
return fit(rarityMapped, dim);
|
||||
}
|
||||
|
||||
public <T> T fit(T[] v, double... dim)
|
||||
{
|
||||
if(v.length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(v.length == 1)
|
||||
{
|
||||
return v[0];
|
||||
}
|
||||
|
||||
return v[fit(0, v.length - 1, dim)];
|
||||
}
|
||||
|
||||
public <T> T fit(List<T> v, double... dim)
|
||||
{
|
||||
if(v.size() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(v.size() == 1)
|
||||
{
|
||||
return v.get(0);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return v.get(fit(0, v.size() - 1, dim));
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return v.get(0);
|
||||
}
|
||||
|
||||
public int fit(int min, int max, double... dim)
|
||||
{
|
||||
if(min == max)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
|
||||
double noise = noise(dim);
|
||||
|
||||
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
||||
}
|
||||
|
||||
public int fit(double min, double max, double... dim)
|
||||
{
|
||||
if(min == max)
|
||||
{
|
||||
return (int) Math.round(min);
|
||||
}
|
||||
|
||||
double noise = noise(dim);
|
||||
|
||||
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
||||
}
|
||||
|
||||
public double fitDouble(double min, double max, double... dim)
|
||||
{
|
||||
if(min == max)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
|
||||
double noise = noise(dim);
|
||||
|
||||
return IrisInterpolation.lerp(min, max, noise);
|
||||
}
|
||||
|
||||
private double getNoise(double... dim)
|
||||
{
|
||||
if(isTrueFracturing())
|
||||
{
|
||||
if(dim.length == 2)
|
||||
{
|
||||
double scale = noscale ? 1 : this.bakedScale * this.scale;
|
||||
double f1 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[0], dim[1]) - 0.5) * fscale : 0D);
|
||||
double f2 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[1], dim[0]) - 0.5) * fscale : 0D);
|
||||
double x = dim[0] + f1;
|
||||
double y = dim[1] + -f1;
|
||||
double z = 0D;
|
||||
return generator.noise(x * scale, y * scale, z * scale) * opacity;
|
||||
}
|
||||
|
||||
else if(dim.length == 3)
|
||||
{
|
||||
double scale = noscale ? 1 : this.bakedScale * this.scale;
|
||||
double f1 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[0], dim[2], dim[1]) - 0.5) * fscale : 0D);
|
||||
double f2 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[1], dim[0], dim[2]) - 0.5) * fscale : 0D);
|
||||
double f3 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[2], dim[1], dim[0]) - 0.5) * fscale : 0D);
|
||||
double x = dim[0] + f1;
|
||||
double y = dim[1] + f3;
|
||||
double z = dim[2] + f2;
|
||||
return generator.noise(x * scale, y * scale, z * scale) * opacity;
|
||||
}
|
||||
}
|
||||
|
||||
double scale = noscale ? 1 : this.bakedScale * this.scale;
|
||||
double f = noscale ? 0 : (fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D);
|
||||
double x = dim.length > 0 ? dim[0] + f : 0D;
|
||||
double y = dim.length > 1 ? dim[1] + -f : 0D;
|
||||
double z = dim.length > 2 ? dim[2] + -f : 0D;
|
||||
return generator.noise(x * scale, y * scale, z * scale) * opacity;
|
||||
}
|
||||
|
||||
public double noise(double... dim)
|
||||
{
|
||||
double n = getNoise(dim);
|
||||
n = power != 1D ? (n < 0 ? -Math.pow(Math.abs(n), power) : Math.pow(n, power)) : n;
|
||||
double m = 1;
|
||||
hits += oct;
|
||||
if(children == null)
|
||||
{
|
||||
return (n - down + up) * patch;
|
||||
}
|
||||
|
||||
for(CNG i : children)
|
||||
{
|
||||
double[] r = injector.combine(n, i.noise(dim));
|
||||
n = r[0];
|
||||
m += r[1];
|
||||
}
|
||||
|
||||
return ((n / m) - down + up) * patch;
|
||||
}
|
||||
|
||||
public CNG pow(double power)
|
||||
{
|
||||
this.power = power;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG oct(int octaves)
|
||||
{
|
||||
oct = octaves;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getScale()
|
||||
{
|
||||
return scale;
|
||||
}
|
||||
|
||||
public boolean isStatic() {
|
||||
return generator != null && generator.isStatic();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface CNGFactory
|
||||
{
|
||||
CNG create(RNG seed);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class CellGenerator
|
||||
{
|
||||
private FastNoiseDouble fn;
|
||||
private FastNoiseDouble fd;
|
||||
private CNG cng;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private double cellScale;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private double shuffle;
|
||||
|
||||
public CellGenerator(RNG rng)
|
||||
{
|
||||
shuffle = 128;
|
||||
cellScale = 0.73;
|
||||
cng = CNG.signature(rng.nextParallelRNG(3204));
|
||||
RNG rx = rng.nextParallelRNG(8735652);
|
||||
long s = rx.lmax();
|
||||
fn = new FastNoiseDouble(s);
|
||||
fn.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
|
||||
fn.setCellularReturnType(FastNoiseDouble.CellularReturnType.CellValue);
|
||||
fn.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
|
||||
fd = new FastNoiseDouble(s);
|
||||
fd.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
|
||||
fd.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
|
||||
fd.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
|
||||
}
|
||||
|
||||
public double getDistance(double x, double z)
|
||||
{
|
||||
return ((fd.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle)))) + 1f) / 2f;
|
||||
}
|
||||
|
||||
public double getDistance(double x, double y, double z)
|
||||
{
|
||||
return ((fd.GetCellular(((x * cellScale) + (cng.noise(x, y, z) * shuffle)), ((y * cellScale) + (cng.noise(x, y, z) * shuffle)), ((z * cellScale) + (cng.noise(z, y, x) * shuffle)))) + 1f) / 2f;
|
||||
}
|
||||
|
||||
public double getValue(double x, double z, int possibilities)
|
||||
{
|
||||
if(possibilities == 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ((fn.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle))) + 1f) / 2f) * (possibilities - 1);
|
||||
}
|
||||
|
||||
public double getValue(double x, double y, double z, int possibilities)
|
||||
{
|
||||
if(possibilities == 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ((fn.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((y * 8 * cellScale) + (cng.noise(x, y * 8) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle))) + 1f) / 2f) * (possibilities - 1);
|
||||
}
|
||||
|
||||
public int getIndex(double x, double z, int possibilities)
|
||||
{
|
||||
if(possibilities == 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) Math.round(getValue(x, z, possibilities));
|
||||
}
|
||||
|
||||
public int getIndex(double x, double y, double z, int possibilities)
|
||||
{
|
||||
if(possibilities == 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) Math.round(getValue(x, y, z, possibilities));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class CellHeightNoise implements NoiseGenerator
|
||||
{
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public CellHeightNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
|
||||
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
|
||||
n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
|
||||
}
|
||||
|
||||
private double filter(double noise)
|
||||
{
|
||||
return M.clip(1D - ((noise / 2D) + 0.5D), 0D, 1D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return filter(n.GetCellular(x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return filter(n.GetCellular(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return filter(n.GetCellular(x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class CellularNoise implements NoiseGenerator
|
||||
{
|
||||
private final FastNoise n;
|
||||
|
||||
public CellularNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoise(new RNG(seed).imax());
|
||||
n.SetNoiseType(FastNoise.NoiseType.Cellular);
|
||||
n.SetCellularReturnType(FastNoise.CellularReturnType.CellValue);
|
||||
n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return (n.GetCellular((float) x, 0) / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return (n.GetCellular((float)x, (float)z) / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return (n.GetCellular((float)x, (float)y, (float)z) / 2D) + 0.5D;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class CubicNoise implements NoiseGenerator
|
||||
{
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public CubicNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
}
|
||||
|
||||
private double f(double n)
|
||||
{
|
||||
return (n / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return f(n.GetCubic(x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return f(n.GetCubic(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return f(n.GetCubic(x, y, z));
|
||||
}
|
||||
}
|
||||
2369
src/main/java/com/volmit/iris/generator/noise/FastNoise.java
Normal file
2369
src/main/java/com/volmit/iris/generator/noise/FastNoise.java
Normal file
File diff suppressed because one or more lines are too long
2364
src/main/java/com/volmit/iris/generator/noise/FastNoiseDouble.java
Normal file
2364
src/main/java/com/volmit/iris/generator/noise/FastNoiseDouble.java
Normal file
File diff suppressed because one or more lines are too long
27
src/main/java/com/volmit/iris/generator/noise/FlatNoise.java
Normal file
27
src/main/java/com/volmit/iris/generator/noise/FlatNoise.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
public class FlatNoise implements NoiseGenerator
|
||||
{
|
||||
public FlatNoise(long seed)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return 1D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return 1D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return 1D;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class FractalBillowPerlinNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public FractalBillowPerlinNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setFractalOctaves(1);
|
||||
n.setFractalType(FractalType.Billow);
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return f(n.GetPerlinFractal(x, 0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return f(n.GetPerlinFractal(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return f(n.GetPerlinFractal(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
n.setFractalOctaves(o);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class FractalBillowSimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public FractalBillowSimplexNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setFractalOctaves(1);
|
||||
n.setFractalType(FractalType.Billow);
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return f(n.GetSimplexFractal(x, 0d));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return f(n.GetSimplexFractal(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return f(n.GetSimplexFractal(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
n.setFractalOctaves(o);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class FractalCubicNoise implements NoiseGenerator
|
||||
{
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public FractalCubicNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setFractalType(FractalType.Billow);
|
||||
}
|
||||
|
||||
private double f(double n)
|
||||
{
|
||||
return (n / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return f(n.GetCubicFractal(x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return f(n.GetCubicFractal(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return f(n.GetCubicFractal(x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class FractalFBMSimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public FractalFBMSimplexNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setFractalOctaves(1);
|
||||
n.setFractalType(FractalType.FBM);
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return f(n.GetSimplexFractal(x, 0d));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return f(n.GetSimplexFractal(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return f(n.GetSimplexFractal(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
n.setFractalOctaves(o);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.generator.noise.FastNoiseDouble.FractalType;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class FractalRigidMultiSimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public FractalRigidMultiSimplexNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setFractalOctaves(1);
|
||||
n.setFractalType(FractalType.RigidMulti);
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return f(n.GetSimplexFractal(x, 0d));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return f(n.GetSimplexFractal(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return f(n.GetSimplexFractal(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
n.setFractalOctaves(o);
|
||||
}
|
||||
}
|
||||
39
src/main/java/com/volmit/iris/generator/noise/GlobNoise.java
Normal file
39
src/main/java/com/volmit/iris/generator/noise/GlobNoise.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class GlobNoise implements NoiseGenerator
|
||||
{
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public GlobNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
|
||||
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Div);
|
||||
n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
|
||||
}
|
||||
|
||||
private double f(double n)
|
||||
{
|
||||
return n + 1D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return f(n.GetCellular(x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return f(n.GetCellular(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return f(n.GetCellular(x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface NoiseFactory
|
||||
{
|
||||
NoiseGenerator create(long seed);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
public interface NoiseGenerator
|
||||
{
|
||||
public double noise(double x);
|
||||
|
||||
public double noise(double x, double z);
|
||||
|
||||
public double noise(double x, double y, double z);
|
||||
|
||||
public default boolean isStatic()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
28
src/main/java/com/volmit/iris/generator/noise/NoiseType.java
Normal file
28
src/main/java/com/volmit/iris/generator/noise/NoiseType.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
public enum NoiseType {
|
||||
WHITE(seed -> new WhiteNoise(seed)),
|
||||
SIMPLEX(seed -> new SimplexNoise(seed)),
|
||||
PERLIN(seed -> new PerlinNoise(seed)),
|
||||
FRACTAL_BILLOW_SIMPLEX(seed -> new FractalBillowSimplexNoise(seed)),
|
||||
FRACTAL_BILLOW_PERLIN(seed -> new FractalBillowPerlinNoise(seed)),
|
||||
FRACTAL_FBM_SIMPLEX(seed -> new FractalFBMSimplexNoise(seed)),
|
||||
FRACTAL_RIGID_MULTI_SIMPLEX(seed -> new FractalRigidMultiSimplexNoise(seed)),
|
||||
FLAT(seed -> new FlatNoise(seed)),
|
||||
CELLULAR(seed -> new CellularNoise(seed)),
|
||||
GLOB(seed -> new GlobNoise(seed)),
|
||||
CUBIC(seed -> new CubicNoise(seed)),
|
||||
FRACTAL_CUBIC(seed -> new FractalCubicNoise(seed)),
|
||||
CELLULAR_HEIGHT(seed -> new CellHeightNoise(seed)),
|
||||
VASCULAR(seed -> new VascularNoise(seed));
|
||||
|
||||
private NoiseFactory f;
|
||||
|
||||
private NoiseType(NoiseFactory f) {
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
public NoiseGenerator create(long seed) {
|
||||
return f.create(seed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
public interface OctaveNoise
|
||||
{
|
||||
public void setOctaves(int o);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class PerlinNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
private final FastNoiseDouble n;
|
||||
private int octaves;
|
||||
|
||||
public PerlinNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
octaves = 1;
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
return f(n.GetPerlin(x, 0));
|
||||
}
|
||||
|
||||
double f = 1;
|
||||
double m = 0;
|
||||
double v = 0;
|
||||
|
||||
for(int i = 0; i < octaves; i++)
|
||||
{
|
||||
v += n.GetPerlin((x * (f == 1 ? f++ : (f *= 2))), 0) * f;
|
||||
m += f;
|
||||
}
|
||||
|
||||
return f(v / m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
return f(n.GetPerlin(x, z));
|
||||
}
|
||||
double f = 1;
|
||||
double m = 0;
|
||||
double v = 0;
|
||||
|
||||
for(int i = 0; i < octaves; i++)
|
||||
{
|
||||
f = f == 1 ? f + 1 : f * 2;
|
||||
v += n.GetPerlin((x * f), (z * f)) * f;
|
||||
m += f;
|
||||
}
|
||||
|
||||
return f(v / m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
return f(n.GetPerlin(x, y, z));
|
||||
}
|
||||
double f = 1;
|
||||
double m = 0;
|
||||
double v = 0;
|
||||
|
||||
for(int i = 0; i < octaves; i++)
|
||||
{
|
||||
f = f == 1 ? f + 1 : f * 2;
|
||||
v += n.GetPerlin((x * f), (y * f), (z * f)) * f;
|
||||
m += f;
|
||||
}
|
||||
|
||||
return f(v / m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
octaves = o;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.IRare;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class RarityCellGenerator<T extends IRare> extends CellGenerator
|
||||
{
|
||||
public RarityCellGenerator(RNG rng)
|
||||
{
|
||||
super(rng);
|
||||
}
|
||||
|
||||
public T get(double x, double z, KList<T> b)
|
||||
{
|
||||
if(b.size() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(b.size() == 1)
|
||||
{
|
||||
return b.get(0);
|
||||
}
|
||||
|
||||
KList<T> rarityMapped = new KList<>();
|
||||
boolean o = false;
|
||||
int max = 1;
|
||||
for(T i : b)
|
||||
{
|
||||
if(i.getRarity() > max)
|
||||
{
|
||||
max = i.getRarity();
|
||||
}
|
||||
}
|
||||
|
||||
max++;
|
||||
|
||||
for(T i : b)
|
||||
{
|
||||
for(int j = 0; j < max - i.getRarity(); j++)
|
||||
{
|
||||
if(o = !o)
|
||||
{
|
||||
rarityMapped.add(i);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
rarityMapped.add(0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rarityMapped.size() == 1)
|
||||
{
|
||||
return rarityMapped.get(0);
|
||||
}
|
||||
|
||||
if(rarityMapped.isEmpty())
|
||||
{
|
||||
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
|
||||
}
|
||||
|
||||
return rarityMapped.get(getIndex(x, z, rarityMapped.size()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class SimplexNoise implements NoiseGenerator, OctaveNoise
|
||||
{
|
||||
private final FastNoiseDouble n;
|
||||
private int octaves;
|
||||
|
||||
public SimplexNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
octaves = 1;
|
||||
}
|
||||
|
||||
public double f(double v)
|
||||
{
|
||||
return (v / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
return f(n.GetSimplex(x, 0d));
|
||||
}
|
||||
|
||||
double f = 1;
|
||||
double m = 0;
|
||||
double v = 0;
|
||||
|
||||
for(int i = 0; i < octaves; i++)
|
||||
{
|
||||
v += n.GetSimplex((x * (f == 1 ? f++ : (f *= 2))), 0d) * f;
|
||||
m += f;
|
||||
}
|
||||
|
||||
return f(v / m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
return f(n.GetSimplex(x, z));
|
||||
}
|
||||
double f = 1;
|
||||
double m = 0;
|
||||
double v = 0;
|
||||
|
||||
for(int i = 0; i < octaves; i++)
|
||||
{
|
||||
f = f == 1 ? f + 1 : f * 2;
|
||||
v += n.GetSimplex((x * f), (z * f)) * f;
|
||||
m += f;
|
||||
}
|
||||
|
||||
return f(v / m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
if(octaves <= 1)
|
||||
{
|
||||
return f(n.GetSimplex(x, y, z));
|
||||
}
|
||||
double f = 1;
|
||||
double m = 0;
|
||||
double v = 0;
|
||||
|
||||
for(int i = 0; i < octaves; i++)
|
||||
{
|
||||
f = f == 1 ? f + 1 : f * 2;
|
||||
v += n.GetSimplex((x * f), (y * f), (z * f)) * f;
|
||||
m += f;
|
||||
}
|
||||
|
||||
return f(v / m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOctaves(int o)
|
||||
{
|
||||
octaves = o;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class VascularNoise implements NoiseGenerator
|
||||
{
|
||||
private final FastNoiseDouble n;
|
||||
|
||||
public VascularNoise(long seed)
|
||||
{
|
||||
this.n = new FastNoiseDouble(new RNG(seed).lmax());
|
||||
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
|
||||
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
|
||||
n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
|
||||
}
|
||||
|
||||
private double filter(double noise)
|
||||
{
|
||||
return M.clip((noise / 2D) + 0.5D, 0D, 1D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return filter(n.GetCellular(x, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return filter(n.GetCellular(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return filter(n.GetCellular(x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.volmit.iris.generator.noise;
|
||||
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class WhiteNoise implements NoiseGenerator
|
||||
{
|
||||
private final FastNoise n;
|
||||
|
||||
public WhiteNoise(long seed)
|
||||
{
|
||||
n = new FastNoise(new RNG(seed).imax());
|
||||
}
|
||||
|
||||
public boolean isStatic()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private double f(double m)
|
||||
{
|
||||
return (m % 8192) * 1024;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x)
|
||||
{
|
||||
return (n.GetWhiteNoise(f(x), 0d) / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z)
|
||||
{
|
||||
return (n.GetWhiteNoise(f(x), f(z)) / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z)
|
||||
{
|
||||
return (n.GetWhiteNoise(f(x), f(y), f(z)) / 2D) + 0.5D;
|
||||
}
|
||||
}
|
||||
311
src/main/java/com/volmit/iris/manager/ConversionManager.java
Normal file
311
src/main/java/com/volmit/iris/manager/ConversionManager.java
Normal file
@@ -0,0 +1,311 @@
|
||||
package com.volmit.iris.manager;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.minelazz.epicworldgenerator.structures.StructureObject;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.object.*;
|
||||
import com.volmit.iris.pregen.DirectWorldWriter;
|
||||
import com.volmit.iris.util.*;
|
||||
import net.querz.nbt.io.NBTUtil;
|
||||
import net.querz.nbt.io.NamedTag;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import net.querz.nbt.tag.IntTag;
|
||||
import net.querz.nbt.tag.ListTag;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Jigsaw;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ConversionManager
|
||||
{
|
||||
private KList<Converter> converters;
|
||||
private File folder;
|
||||
|
||||
public ConversionManager()
|
||||
{
|
||||
folder = Iris.instance.getDataFolder("convert");
|
||||
converters = new KList<>();
|
||||
|
||||
J.s(() ->
|
||||
{
|
||||
J.attemptAsync(() ->
|
||||
{
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("WorldEdit"))
|
||||
{
|
||||
converters.add(new Converter()
|
||||
{
|
||||
@Override
|
||||
public String getOutExtension()
|
||||
{
|
||||
return "iob";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInExtension()
|
||||
{
|
||||
return "schem";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(File in, File out)
|
||||
{
|
||||
SKConversion.convertSchematic(in, out);
|
||||
}
|
||||
});
|
||||
|
||||
converters.add(new Converter()
|
||||
{
|
||||
@Override
|
||||
public String getOutExtension()
|
||||
{
|
||||
return "iob";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInExtension()
|
||||
{
|
||||
return "schematic";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(File in, File out)
|
||||
{
|
||||
SKConversion.convertSchematic(in, out);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 5);
|
||||
|
||||
converters.add(new Converter()
|
||||
{
|
||||
@Override
|
||||
public String getOutExtension()
|
||||
{
|
||||
return "iob";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInExtension()
|
||||
{
|
||||
return "ewg";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(File in, File out)
|
||||
{
|
||||
try
|
||||
{
|
||||
StructureObject.convert(in).write(out);
|
||||
}
|
||||
|
||||
catch(ClassNotFoundException | IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String toPoolName(String poolReference)
|
||||
{
|
||||
return poolReference.split("\\Q:\\E")[1];
|
||||
}
|
||||
|
||||
public void convertStructures(File in, File out, MortarSender s)
|
||||
{
|
||||
KMap<String, IrisJigsawPool> pools = new KMap<>();
|
||||
KList<File> roots = new KList<>();
|
||||
AtomicInteger total = new AtomicInteger(0);
|
||||
AtomicInteger at = new AtomicInteger(0);
|
||||
File destPools = new File(out.getAbsolutePath() + "/jigsaw-pools");
|
||||
destPools.mkdirs();
|
||||
findAllNBT(in, (folder, file) -> {
|
||||
total.getAndIncrement();
|
||||
if(roots.addIfMissing(folder))
|
||||
{
|
||||
String b = in.toURI().relativize(folder.toURI()).getPath();
|
||||
if(b.startsWith("/"))
|
||||
{
|
||||
b = b.substring(1);
|
||||
}
|
||||
|
||||
if(b.endsWith("/"))
|
||||
{
|
||||
b = b.substring(0, b.length() - 1);
|
||||
}
|
||||
|
||||
pools.put(b, new IrisJigsawPool());
|
||||
}
|
||||
});
|
||||
findAllNBT(in, (folder, file) -> {
|
||||
at.getAndIncrement();
|
||||
String b = in.toURI().relativize(folder.toURI()).getPath();
|
||||
if(b.startsWith("/"))
|
||||
{
|
||||
b = b.substring(1);
|
||||
}
|
||||
|
||||
if(b.endsWith("/"))
|
||||
{
|
||||
b = b.substring(0, b.length() - 1);
|
||||
}
|
||||
IrisJigsawPool jpool = pools.get(b);
|
||||
File destObjects = new File(out.getAbsolutePath() + "/objects/" + in.toURI().relativize(folder.toURI()).getPath());
|
||||
File destPieces = new File(out.getAbsolutePath() + "/jigsaw-pieces/" + in.toURI().relativize(folder.toURI()).getPath());
|
||||
destObjects.mkdirs();
|
||||
destPieces.mkdirs();
|
||||
|
||||
try {
|
||||
NamedTag tag = NBTUtil.read(file);
|
||||
CompoundTag compound = (CompoundTag) tag.getTag();
|
||||
|
||||
if (compound.containsKey("blocks") && compound.containsKey("palette") && compound.containsKey("size"))
|
||||
{
|
||||
String id = in.toURI().relativize(folder.toURI()).getPath() + file.getName().split("\\Q.\\E")[0];
|
||||
ListTag<IntTag> size = (ListTag<IntTag>) compound.getListTag("size");
|
||||
int w = size.get(0).asInt();
|
||||
int h = size.get(1).asInt();
|
||||
int d = size.get(2).asInt();
|
||||
KList<BlockData> palette = new KList<>();
|
||||
ListTag<CompoundTag> paletteList = (ListTag<CompoundTag>) compound.getListTag("palette");
|
||||
for(int i = 0; i < paletteList.size(); i++)
|
||||
{
|
||||
CompoundTag cp = paletteList.get(i);
|
||||
palette.add(DirectWorldWriter.getBlockData(cp));
|
||||
}
|
||||
IrisJigsawPiece piece = new IrisJigsawPiece();
|
||||
IrisObject object = new IrisObject(w,h,d);
|
||||
ListTag<CompoundTag> blockList = (ListTag<CompoundTag>) compound.getListTag("blocks");
|
||||
for(int i = 0; i < blockList.size(); i++)
|
||||
{
|
||||
CompoundTag cp = blockList.get(i);
|
||||
ListTag<IntTag> pos = (ListTag<IntTag>) cp.getListTag("pos");
|
||||
int x = pos.get(0).asInt();
|
||||
int y = pos.get(1).asInt();
|
||||
int z = pos.get(2).asInt();
|
||||
BlockData bd = palette.get(cp.getInt("state")).clone();
|
||||
|
||||
if(bd.getMaterial().equals(Material.JIGSAW) && cp.containsKey("nbt"))
|
||||
{
|
||||
piece.setObject(in.toURI().relativize(folder.toURI()).getPath() + file.getName().split("\\Q.\\E")[0]);
|
||||
IrisPosition spos = new IrisPosition(object.getSigned(x,y,z));
|
||||
CompoundTag nbt = cp.getCompoundTag("nbt");
|
||||
CompoundTag finalState = new CompoundTag();
|
||||
finalState.putString("Name", nbt.getString("final_state"));
|
||||
BlockData jd = bd.clone();
|
||||
bd = DirectWorldWriter.getBlockData(finalState);
|
||||
String joint = nbt.getString("joint");
|
||||
String pool = nbt.getString("pool");
|
||||
String poolId = toPoolName(pool);
|
||||
String name = nbt.getString("name");
|
||||
String target = nbt.getString("target");
|
||||
pools.computeIfAbsent(poolId, (k) -> new IrisJigsawPool());
|
||||
IrisJigsawPieceConnector connector = new IrisJigsawPieceConnector();
|
||||
connector.setName(name);
|
||||
connector.setTargetName(target);
|
||||
connector.setRotateConnector(false);
|
||||
connector.setPosition(spos);
|
||||
connector.getPools().add(poolId);
|
||||
connector.setDirection(IrisDirection.getDirection(((Jigsaw)jd).getOrientation()));
|
||||
|
||||
if(target.equals("minecraft:building_entrance"))
|
||||
{
|
||||
connector.setInnerConnector(true);
|
||||
}
|
||||
|
||||
piece.getConnectors().add(connector);
|
||||
}
|
||||
|
||||
if(!bd.getMaterial().equals(Material.STRUCTURE_VOID) && !bd.getMaterial().equals(Material.AIR))
|
||||
{
|
||||
object.setUnsigned(x,y,z, bd);
|
||||
}
|
||||
}
|
||||
|
||||
jpool.getPieces().addIfMissing(id);
|
||||
object.write(new File(destObjects, file.getName().split("\\Q.\\E")[0] + ".iob"));
|
||||
IO.writeAll(new File(destPieces,file.getName().split("\\Q.\\E")[0] + ".json"), new JSONObject(new Gson().toJson(piece)).toString(4));
|
||||
Iris.info("[Jigsaw]: (" + Form.pc((double)at.get() / (double)total.get(), 0) + ") Exported Piece: " + id);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
for(String i : pools.k())
|
||||
{
|
||||
try {
|
||||
IO.writeAll(new File(destPools, i + ".json"), new JSONObject(new Gson().toJson(pools.get(i))).toString(4));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Iris.info("Done! Exported " + Form.f((total.get() * 2) + pools.size()) + " Files!");
|
||||
}
|
||||
|
||||
public void findAllNBT(File path, Consumer2<File, File> inFile)
|
||||
{
|
||||
if(path == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(path.isFile() && path.getName().endsWith(".nbt"))
|
||||
{
|
||||
inFile.accept(path.getParentFile(), path);
|
||||
return;
|
||||
}
|
||||
|
||||
for(File i : path.listFiles())
|
||||
{
|
||||
if(i.isDirectory())
|
||||
{
|
||||
findAllNBT(i, inFile);
|
||||
}
|
||||
|
||||
else if(i.isFile() && i.getName().endsWith(".nbt"))
|
||||
{
|
||||
inFile.accept(path, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void check(MortarSender s)
|
||||
{
|
||||
int m = 0;
|
||||
Iris.instance.getDataFolder("convert");
|
||||
|
||||
for(File i : folder.listFiles())
|
||||
{
|
||||
for(Converter j : converters)
|
||||
{
|
||||
if(i.getName().endsWith("." + j.getInExtension()))
|
||||
{
|
||||
File out = new File(folder, i.getName().replaceAll("\\Q." + j.getInExtension() + "\\E", "." + j.getOutExtension()));
|
||||
m++;
|
||||
j.convert(i, out);
|
||||
s.sendMessage("Converted " + i.getName() + " -> " + out.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if(i.isDirectory() && i.getName().equals("structures")) {
|
||||
File f = new File(folder, "jigsaw");
|
||||
|
||||
if (!f.exists())
|
||||
{
|
||||
s.sendMessage("Converting NBT Structures into Iris Jigsaw Structures...");
|
||||
f.mkdirs();
|
||||
J.a(() -> convertStructures(i, f, s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s.sendMessage("Converted " + m + " File" + (m == 1 ? "" : "s"));
|
||||
}
|
||||
}
|
||||
121
src/main/java/com/volmit/iris/manager/EditManager.java
Normal file
121
src/main/java/com/volmit/iris/manager/EditManager.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package com.volmit.iris.manager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.edit.BlockEditor;
|
||||
import com.volmit.iris.manager.edit.BukkitBlockEditor;
|
||||
import com.volmit.iris.manager.edit.WEBlockEditor;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import com.volmit.iris.util.M;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
||||
public class EditManager implements Listener
|
||||
{
|
||||
private KMap<World, BlockEditor> editors;
|
||||
|
||||
public EditManager()
|
||||
{
|
||||
this.editors = new KMap<>();
|
||||
Iris.instance.registerListener(this);
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::update, 0, 0);
|
||||
}
|
||||
|
||||
public BlockData get(World world, int x, int y, int z)
|
||||
{
|
||||
return open(world).get(x, y, z);
|
||||
}
|
||||
|
||||
public void set(World world, int x, int y, int z, BlockData d)
|
||||
{
|
||||
open(world).set(x, y, z, d);
|
||||
}
|
||||
|
||||
public void setBiome(World world, int x, int y, int z, Biome d)
|
||||
{
|
||||
open(world).setBiome(x, y, z, d);
|
||||
}
|
||||
|
||||
public void setBiome(World world, int x, int z, Biome d)
|
||||
{
|
||||
open(world).setBiome(x, z, d);
|
||||
}
|
||||
|
||||
public Biome getBiome(World world, int x, int y, int z)
|
||||
{
|
||||
return open(world).getBiome(x, y, z);
|
||||
}
|
||||
|
||||
public Biome getBiome(World world, int x, int z)
|
||||
{
|
||||
return open(world).getBiome(x, z);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(WorldUnloadEvent e)
|
||||
{
|
||||
if(editors.containsKey(e.getWorld()))
|
||||
{
|
||||
editors.remove(e.getWorld()).close();
|
||||
}
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
for(World i : editors.k())
|
||||
{
|
||||
if(M.ms() - editors.get(i).last() > 1000)
|
||||
{
|
||||
editors.remove(i).close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void flushNow()
|
||||
{
|
||||
for(World i : editors.k())
|
||||
{
|
||||
editors.remove(i).close();
|
||||
}
|
||||
}
|
||||
|
||||
public BlockEditor open(World world)
|
||||
{
|
||||
if(editors.containsKey(world))
|
||||
{
|
||||
return editors.get(world);
|
||||
}
|
||||
|
||||
BlockEditor e = null;
|
||||
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("WorldEdit") && !PaperLib.isPaper() && !IrisSettings.get().getGeneral().isIgnoreWorldEdit())
|
||||
{
|
||||
try
|
||||
{
|
||||
e = new WEBlockEditor(world);
|
||||
}
|
||||
|
||||
catch(Throwable ex)
|
||||
{
|
||||
e = new BukkitBlockEditor(world);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
e = new BukkitBlockEditor(world);
|
||||
}
|
||||
|
||||
editors.put(world, e);
|
||||
|
||||
return e;
|
||||
}
|
||||
}
|
||||
143
src/main/java/com/volmit/iris/manager/IrisBoardManager.java
Normal file
143
src/main/java/com/volmit/iris/manager/IrisBoardManager.java
Normal file
@@ -0,0 +1,143 @@
|
||||
package com.volmit.iris.manager;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.scaffold.IrisWorlds;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.IrisAccess;
|
||||
import com.volmit.iris.util.*;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IrisBoardManager implements BoardProvider, Listener
|
||||
{
|
||||
@DontObfuscate
|
||||
private BoardManager manager;
|
||||
private String mem = "...";
|
||||
public RollingSequence hits = new RollingSequence(20);
|
||||
public RollingSequence tp = new RollingSequence(100);
|
||||
private ChronoLatch cl = new ChronoLatch(1000);
|
||||
|
||||
@DontObfuscate
|
||||
public IrisBoardManager()
|
||||
{
|
||||
Iris.instance.registerListener(this);
|
||||
//@builder
|
||||
manager = new BoardManager(Iris.instance, BoardSettings.builder()
|
||||
.boardProvider(this)
|
||||
.scoreDirection(ScoreDirection.DOWN)
|
||||
.build());
|
||||
//@done
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(PlayerChangedWorldEvent e)
|
||||
{
|
||||
J.s(() -> updatePlayer(e.getPlayer()));
|
||||
}
|
||||
|
||||
@DontObfuscate
|
||||
private boolean isIrisWorld(World w)
|
||||
{
|
||||
return IrisWorlds.isIrisWorld(w) && IrisWorlds.access(w).isStudio();
|
||||
}
|
||||
|
||||
public void updatePlayer(Player p)
|
||||
{
|
||||
if(isIrisWorld(p.getWorld()))
|
||||
{
|
||||
manager.remove(p);
|
||||
manager.setup(p);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
manager.remove(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(Player player)
|
||||
{
|
||||
return C.GREEN + "Iris";
|
||||
}
|
||||
|
||||
@DontObfuscate
|
||||
@Override
|
||||
public List<String> getLines(Player player)
|
||||
{
|
||||
KList<String> v = new KList<>();
|
||||
|
||||
if(!isIrisWorld(player.getWorld()))
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
IrisAccess g = IrisWorlds.access(player.getWorld());
|
||||
|
||||
if(cl.flip())
|
||||
{
|
||||
// TODO MEMORY
|
||||
mem = Form.memSize(0, 2);
|
||||
}
|
||||
|
||||
int x = player.getLocation().getBlockX();
|
||||
int y = player.getLocation().getBlockY();
|
||||
int z = player.getLocation().getBlockZ();
|
||||
|
||||
Engine engine = g.getCompound().getEngineForHeight(y);
|
||||
|
||||
int parallaxChunks=0;
|
||||
int parallaxRegions=0;
|
||||
long memoryGuess=0;
|
||||
int loadedObjects=0;
|
||||
|
||||
for(int i = 0; i < g.getCompound().getSize(); i++)
|
||||
{
|
||||
parallaxRegions += g.getCompound().getEngine(i).getParallax().getRegionCount();
|
||||
parallaxChunks += g.getCompound().getEngine(i).getParallax().getChunkCount();
|
||||
loadedObjects+= g.getCompound().getData().getObjectLoader().getSize();
|
||||
memoryGuess += g.getCompound().getData().getObjectLoader().getTotalStorage() * 225;
|
||||
memoryGuess+= parallaxChunks * 3500;
|
||||
memoryGuess += parallaxRegions * 1700000;
|
||||
}
|
||||
|
||||
tp.put(0); // TODO: CHUNK SPEED
|
||||
|
||||
|
||||
|
||||
v.add("&7&m------------------");
|
||||
v.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(g.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / g.getGeneratedPerSecond(), 0));
|
||||
v.add(C.GREEN + "Memory Use" + C.GRAY + ": ~" + Form.memSize(memoryGuess, 0));
|
||||
|
||||
if(engine != null)
|
||||
{
|
||||
v.add("&7&m------------------");
|
||||
v.add(C.AQUA + "Engine" + C.GRAY + ": " + engine.getName() + " " + engine.getMinHeight() + "-" + engine.getMaxHeight());
|
||||
v.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
|
||||
v.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiome(x, y, z).getName());
|
||||
v.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z)));
|
||||
v.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getFramework().getComplex().getSlopeStream().get(x, z), 2));
|
||||
}
|
||||
|
||||
if(Iris.jobCount() > 0)
|
||||
{
|
||||
v.add("&7&m------------------");
|
||||
v.add(C.LIGHT_PURPLE + "Tasks" + C.GRAY + ": " + Iris.jobCount());
|
||||
}
|
||||
|
||||
v.add("&7&m------------------");
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@DontObfuscate
|
||||
public void disable()
|
||||
{
|
||||
manager.onDisable();
|
||||
}
|
||||
}
|
||||
212
src/main/java/com/volmit/iris/manager/IrisDataManager.java
Normal file
212
src/main/java/com/volmit/iris/manager/IrisDataManager.java
Normal file
@@ -0,0 +1,212 @@
|
||||
package com.volmit.iris.manager;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.object.*;
|
||||
import com.volmit.iris.util.ObjectResourceLoader;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import com.volmit.iris.util.ResourceLoader;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Data
|
||||
public class IrisDataManager
|
||||
{
|
||||
private ResourceLoader<IrisBiome> biomeLoader;
|
||||
private ResourceLoader<IrisLootTable> lootLoader;
|
||||
private ResourceLoader<IrisRegion> regionLoader;
|
||||
private ResourceLoader<IrisDimension> dimensionLoader;
|
||||
private ResourceLoader<IrisGenerator> generatorLoader;
|
||||
private ResourceLoader<IrisJigsawPiece> jigsawPieceLoader;
|
||||
private ResourceLoader<IrisJigsawPool> jigsawPoolLoader;
|
||||
private ResourceLoader<IrisJigsawStructure> jigsawStructureLoader;
|
||||
private ResourceLoader<IrisEntity> entityLoader;
|
||||
private ResourceLoader<IrisBlockData> blockLoader;
|
||||
private ObjectResourceLoader objectLoader;
|
||||
private boolean closed;
|
||||
private final File dataFolder;
|
||||
private final int id;
|
||||
|
||||
public IrisDataManager(File dataFolder)
|
||||
{
|
||||
this(dataFolder, false);
|
||||
}
|
||||
|
||||
public IrisDataManager(File dataFolder, boolean oneshot)
|
||||
{
|
||||
this.dataFolder = dataFolder;
|
||||
this.id = RNG.r.imax();
|
||||
closed = false;
|
||||
hotloaded();
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
closed = true;
|
||||
dump();
|
||||
this.lootLoader = null;
|
||||
this.entityLoader = null;
|
||||
this.regionLoader = null;
|
||||
this.biomeLoader = null;
|
||||
this.dimensionLoader = null;
|
||||
this.jigsawPoolLoader = null;
|
||||
this.jigsawPieceLoader = null;
|
||||
this.generatorLoader = null;
|
||||
this.jigsawStructureLoader = null;
|
||||
this.blockLoader = null;
|
||||
this.objectLoader = null;
|
||||
}
|
||||
|
||||
private static void printData(ResourceLoader<?> rl)
|
||||
{
|
||||
Iris.warn(" " + rl.getResourceTypeName() + " @ /" + rl.getFolderName() + ": Cache=" + rl.getLoadCache().size() + " Folders=" + rl.getFolders().size());
|
||||
}
|
||||
|
||||
public IrisDataManager copy() {
|
||||
return new IrisDataManager(dataFolder);
|
||||
}
|
||||
|
||||
public void hotloaded()
|
||||
{
|
||||
if(closed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
File packs = dataFolder;
|
||||
packs.mkdirs();
|
||||
this.lootLoader = new ResourceLoader<>(packs, this, "loot", "Loot", IrisLootTable.class);
|
||||
this.entityLoader = new ResourceLoader<>(packs,this, "entities", "Entity", IrisEntity.class);
|
||||
this.regionLoader = new ResourceLoader<>(packs, this, "regions", "Region", IrisRegion.class);
|
||||
this.biomeLoader = new ResourceLoader<>(packs, this, "biomes", "Biome", IrisBiome.class);
|
||||
this.dimensionLoader = new ResourceLoader<>(packs, this, "dimensions", "Dimension", IrisDimension.class);
|
||||
this.jigsawPoolLoader = new ResourceLoader<>(packs, this, "jigsaw-pools", "Jigsaw Pool", IrisJigsawPool.class);
|
||||
this.jigsawStructureLoader = new ResourceLoader<>(packs, this, "jigsaw-structures", "Jigsaw Structure", IrisJigsawStructure.class);
|
||||
this.jigsawPieceLoader = new ResourceLoader<>(packs, this, "jigsaw-pieces", "Jigsaw Piece", IrisJigsawPiece.class);
|
||||
this.generatorLoader = new ResourceLoader<>(packs, this, "generators", "Generator", IrisGenerator.class);
|
||||
this.blockLoader = new ResourceLoader<>(packs,this, "blocks", "Block", IrisBlockData.class);
|
||||
this.objectLoader = new ObjectResourceLoader(packs, this, "objects", "Object");
|
||||
}
|
||||
|
||||
public void dump()
|
||||
{
|
||||
if(closed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
biomeLoader.clearCache();
|
||||
blockLoader.clearCache();
|
||||
lootLoader.clearCache();
|
||||
objectLoader.clearCache();
|
||||
jigsawPieceLoader.clearCache();
|
||||
jigsawPoolLoader.clearCache();
|
||||
jigsawStructureLoader.clearCache();
|
||||
regionLoader.clearCache();
|
||||
dimensionLoader.clearCache();
|
||||
entityLoader.clearCache();
|
||||
generatorLoader.clearCache();
|
||||
}
|
||||
|
||||
public void clearLists()
|
||||
{
|
||||
if(closed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lootLoader.clearList();
|
||||
blockLoader.clearList();
|
||||
entityLoader.clearList();
|
||||
biomeLoader.clearList();
|
||||
regionLoader.clearList();
|
||||
dimensionLoader.clearList();
|
||||
generatorLoader.clearList();
|
||||
jigsawStructureLoader.clearList();
|
||||
jigsawPoolLoader.clearList();
|
||||
jigsawPieceLoader.clearList();
|
||||
objectLoader.clearList();
|
||||
}
|
||||
|
||||
public static IrisObject loadAnyObject(String key)
|
||||
{
|
||||
return loadAny(key, (dm) -> dm.getObjectLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static IrisBiome loadAnyBiome(String key)
|
||||
{
|
||||
return loadAny(key, (dm) -> dm.getBiomeLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static IrisJigsawPiece loadAnyJigsawPiece(String key)
|
||||
{
|
||||
return loadAny(key, (dm) -> dm.getJigsawPieceLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static IrisJigsawPool loadAnyJigsawPool(String key)
|
||||
{
|
||||
return loadAny(key, (dm) -> dm.getJigsawPoolLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static IrisEntity loadAnyEntity(String key)
|
||||
{
|
||||
return loadAny(key, (dm) -> dm.getEntityLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static IrisLootTable loadAnyLootTable(String key)
|
||||
{
|
||||
return loadAny(key, (dm) -> dm.getLootLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static IrisBlockData loadAnyBlock(String key)
|
||||
{
|
||||
return loadAny(key, (dm) -> dm.getBlockLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static IrisRegion loadAnyRegion(String key)
|
||||
{
|
||||
return loadAny(key, (dm) -> dm.getRegionLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static IrisDimension loadAnyDimension(String key)
|
||||
{
|
||||
return loadAny(key, (dm) -> dm.getDimensionLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static IrisJigsawStructure loadAnyJigsawStructure(String key)
|
||||
{
|
||||
return loadAny(key, (dm) -> dm.getJigsawStructureLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static IrisGenerator loadAnyGenerator(String key)
|
||||
{
|
||||
return loadAny(key, (dm) -> dm.getGeneratorLoader().load(key, false));
|
||||
}
|
||||
|
||||
public static <T extends IrisRegistrant> T loadAny(String key, Function<IrisDataManager, T> v) {
|
||||
try
|
||||
{
|
||||
for(File i : Objects.requireNonNull(Iris.instance.getDataFolder("packs").listFiles()))
|
||||
{
|
||||
if(i.isDirectory())
|
||||
{
|
||||
IrisDataManager dm = new IrisDataManager(i, true);
|
||||
T t = v.apply(dm);
|
||||
|
||||
if(t != null)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
545
src/main/java/com/volmit/iris/manager/IrisProject.java
Normal file
545
src/main/java/com/volmit/iris/manager/IrisProject.java
Normal file
@@ -0,0 +1,545 @@
|
||||
package com.volmit.iris.manager;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.object.*;
|
||||
import com.volmit.iris.scaffold.IrisWorldCreator;
|
||||
import com.volmit.iris.scaffold.engine.IrisAccess;
|
||||
import com.volmit.iris.util.*;
|
||||
import lombok.Data;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class IrisProject
|
||||
{
|
||||
private File path;
|
||||
private String name;
|
||||
private IrisAccess activeProvider;
|
||||
|
||||
public IrisProject(File path)
|
||||
{
|
||||
this.path = path;
|
||||
this.name = path.getName();
|
||||
}
|
||||
|
||||
public boolean isOpen()
|
||||
{
|
||||
return activeProvider != null;
|
||||
}
|
||||
|
||||
public void open(MortarSender sender)
|
||||
{
|
||||
open(sender, () ->
|
||||
{
|
||||
});
|
||||
}
|
||||
|
||||
public void open(MortarSender sender, Runnable onDone)
|
||||
{
|
||||
if(isOpen())
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
IrisDimension d = IrisDataManager.loadAnyDimension(getName());
|
||||
if(d == null)
|
||||
{
|
||||
sender.sendMessage("Can't find dimension: " + getName());
|
||||
return;
|
||||
} else if(sender.isPlayer()){
|
||||
sender.player().setGameMode(GameMode.SPECTATOR);
|
||||
sender.player().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 500, 10));
|
||||
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.BLUE + "Creating studio world. Please wait..."));
|
||||
}
|
||||
|
||||
J.attemptAsync(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
if (d.getLoader() == null){
|
||||
sender.sendMessage("Could not get dimension loader");
|
||||
return;
|
||||
}
|
||||
File f = d.getLoader().getDataFolder();
|
||||
boolean foundWork = false;
|
||||
for(File i : Objects.requireNonNull(f.listFiles()))
|
||||
{
|
||||
if(i.getName().endsWith(".code-workspace"))
|
||||
{
|
||||
foundWork = true;
|
||||
sender.sendMessage("Updating Workspace...");
|
||||
J.a(() ->
|
||||
{
|
||||
updateWorkspace();
|
||||
sender.sendMessage("Workspace Updated");
|
||||
});
|
||||
|
||||
if(IrisSettings.get().getStudio().isOpenVSCode())
|
||||
{
|
||||
if (!GraphicsEnvironment.isHeadless()) {
|
||||
Iris.msg("Opening VSCode. You may see the output from VSCode.");
|
||||
Iris.msg("VSCode output always starts with: '(node:#####) electron'");
|
||||
Desktop.getDesktop().open(i);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!foundWork)
|
||||
{
|
||||
File ff = new File(d.getLoader().getDataFolder(), d.getLoadKey() + ".code-workspace");
|
||||
Iris.warn("Project missing code-workspace: " + ff.getAbsolutePath() + " Re-creating code workspace.");
|
||||
|
||||
try
|
||||
{
|
||||
IO.writeAll(ff, createCodeWorkspaceConfig());
|
||||
}
|
||||
|
||||
catch(IOException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
sender.sendMessage("Updating Workspace...");
|
||||
updateWorkspace();
|
||||
sender.sendMessage("Workspace Updated");
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
String wfp = "iris/" + UUID.randomUUID();
|
||||
|
||||
WorldCreator c = new IrisWorldCreator().dimension(getName())
|
||||
.seed(1337)
|
||||
.name(wfp)
|
||||
.studioMode()
|
||||
.create();
|
||||
IrisAccess gx = ((IrisAccess)c.generator());
|
||||
sender.sendMessage("Generating with " + Iris.getThreadCount() + " threads per chunk");
|
||||
O<Boolean> done = new O<>();
|
||||
done.set(false);
|
||||
activeProvider = gx;
|
||||
|
||||
J.a(() ->
|
||||
{
|
||||
double last = 0;
|
||||
int req = 300;
|
||||
double lpc = 0;
|
||||
boolean fc;
|
||||
|
||||
while(!done.get())
|
||||
{
|
||||
boolean derp = false;
|
||||
|
||||
assert gx != null;
|
||||
double v = (double) gx.getGenerated() / (double) req;
|
||||
fc = lpc != v;
|
||||
lpc = v;
|
||||
|
||||
if(last > v || v > 1)
|
||||
{
|
||||
derp = true;
|
||||
v = last;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
last = v;
|
||||
}
|
||||
|
||||
if(fc)
|
||||
{
|
||||
sender.sendMessage(C.WHITE + "Generating " + Form.pc(v) + (derp ? (C.GRAY + " (Waiting on Server...)") : (C.GRAY + " (" + (req - gx.getGenerated()) + " Left)")));
|
||||
}
|
||||
|
||||
if (sender.isPlayer()){
|
||||
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.BLUE + "Creating studio world. Please wait..."));
|
||||
}
|
||||
|
||||
J.sleep(1500);
|
||||
|
||||
if(gx.isFailing())
|
||||
{
|
||||
|
||||
sender.sendMessage("Generation Failed!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//@builder
|
||||
World world = c.createWorld();
|
||||
Iris.linkMultiverseCore.removeFromConfig(world);
|
||||
|
||||
done.set(true);
|
||||
sender.sendMessage(C.WHITE + "Generating Complete!");
|
||||
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
assert world != null;
|
||||
sender.player().teleport(world.getSpawnLocation());
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () ->
|
||||
{
|
||||
sender.sendMessage("Hotloading Active! Change any files and watch your changes appear as you load new chunks!");
|
||||
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
sender.player().setGameMode(GameMode.SPECTATOR);
|
||||
}
|
||||
|
||||
onDone.run();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
activeProvider.close();
|
||||
File folder = activeProvider.getTarget().getWorld().getWorldFolder();
|
||||
Iris.linkMultiverseCore.removeFromConfig(activeProvider.getTarget().getWorld().getName());
|
||||
Bukkit.unloadWorld(activeProvider.getTarget().getWorld().getName(), false);
|
||||
J.attemptAsync(() -> IO.delete(folder));
|
||||
activeProvider = null;
|
||||
}
|
||||
|
||||
public File getCodeWorkspaceFile()
|
||||
{
|
||||
return new File(path, getName() + ".code-workspace");
|
||||
}
|
||||
|
||||
public boolean updateWorkspace()
|
||||
{
|
||||
getPath().mkdirs();
|
||||
File ws = getCodeWorkspaceFile();
|
||||
|
||||
try
|
||||
{
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Iris.info("Building Workspace: " + ws.getPath());
|
||||
JSONObject j = createCodeWorkspaceConfig();
|
||||
IO.writeAll(ws, j.toString(4));
|
||||
p.end();
|
||||
Iris.info("Building Workspace: " + ws.getPath() + " took " + Form.duration(p.getMilliseconds(), 2));
|
||||
return true;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
Iris.warn("Project invalid: " + ws.getAbsolutePath() + " Re-creating. You may loose some vs-code workspace settings! But not your actual project!");
|
||||
ws.delete();
|
||||
try
|
||||
{
|
||||
IO.writeAll(ws, createCodeWorkspaceConfig());
|
||||
}
|
||||
|
||||
catch(IOException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public JSONObject createCodeWorkspaceConfig()
|
||||
{
|
||||
JSONObject ws = new JSONObject();
|
||||
JSONArray folders = new JSONArray();
|
||||
JSONObject folder = new JSONObject();
|
||||
folder.put("path", ".");
|
||||
folders.put(folder);
|
||||
ws.put("folders", folders);
|
||||
JSONObject settings = new JSONObject();
|
||||
settings.put("workbench.colorTheme", "Monokai");
|
||||
settings.put("workbench.preferredDarkColorTheme", "Solarized Dark");
|
||||
settings.put("workbench.tips.enabled", false);
|
||||
settings.put("workbench.tree.indent", 24);
|
||||
settings.put("files.autoSave", "onFocusChange");
|
||||
JSONObject jc = new JSONObject();
|
||||
jc.put("editor.autoIndent", "brackets");
|
||||
jc.put("editor.acceptSuggestionOnEnter", "smart");
|
||||
jc.put("editor.cursorSmoothCaretAnimation", true);
|
||||
jc.put("editor.dragAndDrop", false);
|
||||
jc.put("files.trimTrailingWhitespace", true);
|
||||
jc.put("diffEditor.ignoreTrimWhitespace", true);
|
||||
jc.put("files.trimFinalNewlines", true);
|
||||
jc.put("editor.suggest.showKeywords", false);
|
||||
jc.put("editor.suggest.showSnippets", false);
|
||||
jc.put("editor.suggest.showWords", false);
|
||||
JSONObject st = new JSONObject();
|
||||
st.put("strings", true);
|
||||
jc.put("editor.quickSuggestions", st);
|
||||
jc.put("editor.suggest.insertMode", "replace");
|
||||
settings.put("[json]", jc);
|
||||
settings.put("json.maxItemsComputed", 30000);
|
||||
JSONArray schemas = new JSONArray();
|
||||
IrisDataManager dm = new IrisDataManager(getPath());
|
||||
schemas.put(getSchemaEntry(IrisDimension.class, dm, "/dimensions/*.json"));
|
||||
schemas.put(getSchemaEntry(IrisEntity.class, dm, "/entities/*.json"));
|
||||
schemas.put(getSchemaEntry(IrisBiome.class, dm, "/biomes/*.json"));
|
||||
schemas.put(getSchemaEntry(IrisRegion.class, dm, "/regions/*.json"));
|
||||
schemas.put(getSchemaEntry(IrisGenerator.class,dm, "/generators/*.json"));
|
||||
schemas.put(getSchemaEntry(IrisJigsawPiece.class, dm, "/jigsaw-pieces/*.json"));
|
||||
schemas.put(getSchemaEntry(IrisJigsawPool.class, dm, "/jigsaw-pools/*.json"));
|
||||
schemas.put(getSchemaEntry(IrisJigsawStructure.class, dm, "/jigsaw-structures/*.json"));
|
||||
schemas.put(getSchemaEntry(IrisBlockData.class, dm, "/blocks/*.json"));
|
||||
schemas.put(getSchemaEntry(IrisLootTable.class, dm, "/loot/*.json"));
|
||||
settings.put("json.schemas", schemas);
|
||||
ws.put("settings", settings);
|
||||
|
||||
return ws;
|
||||
}
|
||||
|
||||
public JSONObject getSchemaEntry(Class<?> i, IrisDataManager dat, String... fileMatch)
|
||||
{
|
||||
Iris.verbose("Processing Folder " + i.getSimpleName() + " " + fileMatch[0]);
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("fileMatch", new JSONArray(fileMatch));
|
||||
o.put("schema", new SchemaBuilder(i, dat).compute());
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
public File compilePackage(MortarSender sender, boolean obfuscate, boolean minify)
|
||||
{
|
||||
String dimm = getName();
|
||||
IrisDataManager dm = new IrisDataManager(path);
|
||||
IrisDimension dimension = dm.getDimensionLoader().load(dimm);
|
||||
File folder = new File(Iris.instance.getDataFolder(), "exports/" + dimension.getLoadKey());
|
||||
folder.mkdirs();
|
||||
Iris.info("Packaging Dimension " + dimension.getName() + " " + (obfuscate ? "(Obfuscated)" : ""));
|
||||
KSet<IrisRegion> regions = new KSet<>();
|
||||
KSet<IrisBiome> biomes = new KSet<>();
|
||||
KSet<IrisEntity> entities = new KSet<>();
|
||||
KSet<IrisGenerator> generators = new KSet<>();
|
||||
KSet<IrisLootTable> loot = new KSet<>();
|
||||
KSet<IrisBlockData> blocks = new KSet<>();
|
||||
|
||||
for(String i : dm.getDimensionLoader().getPossibleKeys())
|
||||
{
|
||||
blocks.add(dm.getBlockLoader().load(i));
|
||||
}
|
||||
|
||||
//TODO: EXPORT JIGSAW PIECES FROM STRUCTURES
|
||||
dimension.getRegions().forEach((i) -> regions.add(dm.getRegionLoader().load(i)));
|
||||
dimension.getLoot().getTables().forEach((i) -> loot.add(dm.getLootLoader().load(i)));
|
||||
regions.forEach((i) -> biomes.addAll(i.getAllBiomes(null)));
|
||||
biomes.forEach((i) -> i.getGenerators().forEach((j) -> generators.add(j.getCachedGenerator(null))));
|
||||
regions.forEach((r) -> r.getLoot().getTables().forEach((i) -> loot.add(dm.getLootLoader().load(i))));
|
||||
biomes.forEach((r) -> r.getLoot().getTables().forEach((i) -> loot.add(dm.getLootLoader().load(i))));
|
||||
biomes.forEach((r) -> r.getEntitySpawnOverrides().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity()))));
|
||||
regions.forEach((r) -> r.getEntitySpawnOverrides().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity()))));
|
||||
dimension.getEntitySpawnOverrides().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity())));
|
||||
biomes.forEach((r) -> r.getEntityInitialSpawns().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity()))));
|
||||
regions.forEach((r) -> r.getEntityInitialSpawns().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity()))));
|
||||
dimension.getEntityInitialSpawns().forEach((sp) -> entities.add(dm.getEntityLoader().load(sp.getEntity())));
|
||||
KMap<String, String> renameObjects = new KMap<>();
|
||||
String a;
|
||||
StringBuilder b = new StringBuilder();
|
||||
StringBuilder c = new StringBuilder();
|
||||
sender.sendMessage("Serializing Objects");
|
||||
|
||||
for(IrisBiome i : biomes)
|
||||
{
|
||||
for(IrisObjectPlacement j : i.getObjects())
|
||||
{
|
||||
b.append(j.hashCode());
|
||||
KList<String> newNames = new KList<>();
|
||||
|
||||
for(String k : j.getPlace())
|
||||
{
|
||||
if(renameObjects.containsKey(k))
|
||||
{
|
||||
newNames.add(renameObjects.get(k));
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = !obfuscate ? k : UUID.randomUUID().toString().replaceAll("-", "");
|
||||
b.append(name);
|
||||
newNames.add(name);
|
||||
renameObjects.put(k, name);
|
||||
}
|
||||
|
||||
j.setPlace(newNames);
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisBiomeMutation i : dimension.getMutations())
|
||||
{
|
||||
for(IrisObjectPlacement j : i.getObjects())
|
||||
{
|
||||
b.append(j.hashCode());
|
||||
KList<String> newNames = new KList<>();
|
||||
|
||||
for(String k : j.getPlace())
|
||||
{
|
||||
if(renameObjects.containsKey(k))
|
||||
{
|
||||
newNames.add(renameObjects.get(k));
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = !obfuscate ? k : UUID.randomUUID().toString().replaceAll("-", "");
|
||||
b.append(name);
|
||||
newNames.add(name);
|
||||
renameObjects.put(k, name);
|
||||
}
|
||||
|
||||
j.setPlace(newNames);
|
||||
}
|
||||
}
|
||||
|
||||
KMap<String, KList<String>> lookupObjects = renameObjects.flip();
|
||||
StringBuilder gb = new StringBuilder();
|
||||
ChronoLatch cl = new ChronoLatch(1000);
|
||||
O<Integer> ggg = new O<>();
|
||||
ggg.set(0);
|
||||
biomes.forEach((i) -> i.getObjects().forEach((j) -> j.getPlace().forEach((k) ->
|
||||
{
|
||||
try
|
||||
{
|
||||
File f = dm.getObjectLoader().findFile(lookupObjects.get(k).get(0));
|
||||
IO.copyFile(f, new File(folder, "objects/" + k + ".iob"));
|
||||
gb.append(IO.hash(f));
|
||||
ggg.set(ggg.get() + 1);
|
||||
|
||||
if(cl.flip())
|
||||
{
|
||||
int g = ggg.get();
|
||||
ggg.set(0);
|
||||
sender.sendMessage("Wrote another " + g + " Objects");
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
|
||||
}
|
||||
})));
|
||||
|
||||
dimension.getMutations().forEach((i) -> i.getObjects().forEach((j) -> j.getPlace().forEach((k) ->
|
||||
{
|
||||
try
|
||||
{
|
||||
File f = dm.getObjectLoader().findFile(lookupObjects.get(k).get(0));
|
||||
IO.copyFile(f, new File(folder, "objects/" + k + ".iob"));
|
||||
gb.append(IO.hash(f));
|
||||
ggg.set(ggg.get() + 1);
|
||||
|
||||
if(cl.flip())
|
||||
{
|
||||
int g = ggg.get();
|
||||
ggg.set(0);
|
||||
sender.sendMessage("Wrote another " + g + " Objects");
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
|
||||
}
|
||||
})));
|
||||
|
||||
b.append(IO.hash(gb.toString()));
|
||||
c.append(IO.hash(b.toString()));
|
||||
b = new StringBuilder();
|
||||
|
||||
Iris.info("Writing Dimensional Scaffold");
|
||||
|
||||
try
|
||||
{
|
||||
a = new JSONObject(new Gson().toJson(dimension)).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "dimensions/" + dimension.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
|
||||
for(IrisGenerator i : generators)
|
||||
{
|
||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "generators/" + i.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
}
|
||||
|
||||
c.append(IO.hash(b.toString()));
|
||||
b = new StringBuilder();
|
||||
|
||||
for(IrisRegion i : regions)
|
||||
{
|
||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "regions/" + i.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
}
|
||||
|
||||
for(IrisBlockData i : blocks)
|
||||
{
|
||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "blocks/" + i.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
}
|
||||
|
||||
for(IrisBiome i : biomes)
|
||||
{
|
||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "biomes/" + i.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
}
|
||||
|
||||
for(IrisEntity i : entities)
|
||||
{
|
||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "entities/" + i.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
}
|
||||
|
||||
for(IrisLootTable i : loot)
|
||||
{
|
||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
||||
IO.writeAll(new File(folder, "loot/" + i.getLoadKey() + ".json"), a);
|
||||
b.append(IO.hash(a));
|
||||
}
|
||||
|
||||
c.append(IO.hash(b.toString()));
|
||||
String finalHash = IO.hash(c.toString());
|
||||
JSONObject meta = new JSONObject();
|
||||
meta.put("hash", finalHash);
|
||||
meta.put("time", M.ms());
|
||||
meta.put("version", dimension.getVersion());
|
||||
IO.writeAll(new File(folder, "package.json"), meta.toString(minify ? 0 : 4));
|
||||
File p = new File(Iris.instance.getDataFolder(), "exports/" + dimension.getLoadKey() + ".iris");
|
||||
Iris.info("Compressing Package");
|
||||
ZipUtil.pack(folder, p, 9);
|
||||
IO.delete(folder);
|
||||
|
||||
sender.sendMessage("Package Compiled!");
|
||||
return p;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
sender.sendMessage("Failed!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
523
src/main/java/com/volmit/iris/manager/ProjectManager.java
Normal file
523
src/main/java/com/volmit/iris/manager/ProjectManager.java
Normal file
@@ -0,0 +1,523 @@
|
||||
package com.volmit.iris.manager;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
import com.volmit.iris.scaffold.cache.AtomicCache;
|
||||
import com.volmit.iris.util.*;
|
||||
import lombok.Data;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
import org.zeroturnaround.zip.commons.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class ProjectManager
|
||||
{
|
||||
public static final String LISTING = "https://raw.githubusercontent.com/IrisDimensions/_listing/main/listing.json";
|
||||
public static final String WORKSPACE_NAME = "packs";
|
||||
private KMap<String, String> cacheListing = null;
|
||||
private IrisProject activeProject;
|
||||
private static final AtomicCache<Integer> counter = new AtomicCache<>();
|
||||
|
||||
public ProjectManager()
|
||||
{
|
||||
if(IrisSettings.get().isStudio())
|
||||
{
|
||||
J.a(() ->
|
||||
{
|
||||
File ignore = getWorkspaceFile(".gitignore");
|
||||
|
||||
if(!ignore.exists())
|
||||
{
|
||||
File m = Iris.getCached("Pack Ignore (.gitignore)", "https://raw.githubusercontent.com/VolmitSoftware/Iris/master/packignore.ignore");
|
||||
if(m != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
IO.copyFile(m, ignore);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static int countUniqueDimensions() {
|
||||
int vv = counter.aquire(() -> {
|
||||
int v = 0;
|
||||
|
||||
try
|
||||
{
|
||||
for(File i : Iris.instance.getDataFolder(WORKSPACE_NAME).listFiles())
|
||||
{
|
||||
try
|
||||
{
|
||||
if(i.isDirectory() && i.list().length > 0 && !Iris.proj.getListing(true).keySet().contains(i.getName()))
|
||||
{
|
||||
v++;
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return v;
|
||||
});
|
||||
|
||||
return vv;
|
||||
}
|
||||
|
||||
public IrisDimension installIntoWorld(MortarSender sender, String type, File folder)
|
||||
{
|
||||
sender.sendMessage("Looking for Package: " + type);
|
||||
File iris = new File(folder, "iris");
|
||||
File irispack = new File(folder, "iris/pack");
|
||||
IrisDimension dim = IrisDataManager.loadAnyDimension(type);
|
||||
|
||||
if(dim == null)
|
||||
{
|
||||
for(File i : Iris.proj.getWorkspaceFolder().listFiles())
|
||||
{
|
||||
if(i.isFile() && i.getName().equals(type + ".iris"))
|
||||
{
|
||||
sender.sendMessage("Found " + type + ".iris in " + ProjectManager.WORKSPACE_NAME + " folder");
|
||||
ZipUtil.unpack(i, irispack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
sender.sendMessage("Found " + type + " dimension in " + ProjectManager.WORKSPACE_NAME + " folder. Repackaging");
|
||||
File f = new IrisProject(new File(getWorkspaceFolder(), type)).getPath();
|
||||
|
||||
try
|
||||
{
|
||||
FileUtils.copyDirectory(f, irispack);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File dimf = new File(irispack, "dimensions/" + type + ".json");
|
||||
|
||||
if(!dimf.exists() || !dimf.isFile())
|
||||
{
|
||||
Iris.proj.downloadSearch(sender, type, false);
|
||||
File downloaded = Iris.proj.getWorkspaceFolder(type);
|
||||
|
||||
for(File i : downloaded.listFiles())
|
||||
{
|
||||
if(i.isFile())
|
||||
{
|
||||
try
|
||||
{
|
||||
FileUtils.copyFile(i, new File(irispack, i.getName()));
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
FileUtils.copyDirectory(i, new File(irispack, i.getName()));
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IO.delete(downloaded);
|
||||
}
|
||||
|
||||
if(!dimf.exists() || !dimf.isFile())
|
||||
{
|
||||
sender.sendMessage("Can't find the " + dimf.getName() + " in the dimensions folder of this pack! Failed!");
|
||||
return null;
|
||||
}
|
||||
|
||||
IrisDataManager dm = new IrisDataManager(irispack);
|
||||
dim = dm.getDimensionLoader().load(type);
|
||||
|
||||
if(dim == null)
|
||||
{
|
||||
sender.sendMessage("Can't load the dimension! Failed!");
|
||||
return null;
|
||||
}
|
||||
|
||||
sender.sendMessage(folder.getName() + " type installed. ");
|
||||
return dim;
|
||||
}
|
||||
|
||||
public void downloadSearch(MortarSender sender, String key, boolean trim)
|
||||
{
|
||||
downloadSearch(sender, key, trim, false);
|
||||
}
|
||||
|
||||
public void downloadSearch(MortarSender sender, String key, boolean trim, boolean forceOverwrite)
|
||||
{
|
||||
String repo = getListing(false).get(key);
|
||||
|
||||
if(repo == null)
|
||||
{
|
||||
sender.sendMessage("Couldn't find the pack '" + key + "' in the iris repo listing.");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage("Found '" + key + "' in the Iris Listing as " + repo);
|
||||
try
|
||||
{
|
||||
download(sender, repo, trim, forceOverwrite);
|
||||
}
|
||||
catch(JsonSyntaxException | IOException e)
|
||||
{
|
||||
sender.sendMessage("Failed to download '" + key + "'.");
|
||||
}
|
||||
}
|
||||
|
||||
public void download(MortarSender sender, String repo, boolean trim) throws JsonSyntaxException, IOException
|
||||
{
|
||||
download(sender, repo, trim, false);
|
||||
}
|
||||
|
||||
public void download(MortarSender sender, String repo, boolean trim, boolean forceOverwrite) throws JsonSyntaxException, IOException
|
||||
{
|
||||
String url = "https://codeload.github.com/" + repo + "/zip/master";
|
||||
sender.sendMessage("Downloading " + url);
|
||||
File zip = Iris.getNonCachedFile("pack-" + trim + "-" + repo, url);
|
||||
File temp = Iris.getTemp();
|
||||
File work = new File(temp, "dl-" + UUID.randomUUID());
|
||||
File packs = getWorkspaceFolder();
|
||||
sender.sendMessage("Unpacking " + repo);
|
||||
try {
|
||||
ZipUtil.unpack(zip, work);
|
||||
} catch (Exception e){
|
||||
sender.sendMessage(
|
||||
"Issue when unpacking. Please check/do the following:" +
|
||||
"\n1. Do you have a functioning internet connection?" +
|
||||
"\n2. Did the download corrupt?" +
|
||||
"\n3. Try deleting the */plugins/iris/packs folder and re-download." +
|
||||
"\n4. Download the pack from the GitHub repo: https://github.com/IrisDimensions/overworld" +
|
||||
"\n5. Contact support (if all other options do not help)"
|
||||
);
|
||||
}
|
||||
File dir = work.listFiles().length == 1 && work.listFiles()[0].isDirectory() ? work.listFiles()[0] : null;
|
||||
|
||||
if(dir == null)
|
||||
{
|
||||
sender.sendMessage("Invalid Format. Missing root folder or too many folders!");
|
||||
return;
|
||||
}
|
||||
|
||||
File dimensions = new File(dir, "dimensions");
|
||||
|
||||
if(!(dimensions.exists() && dimensions.isDirectory()))
|
||||
{
|
||||
sender.sendMessage("Invalid Format. Missing dimensions folder");
|
||||
return;
|
||||
}
|
||||
|
||||
if(dimensions.listFiles().length != 1)
|
||||
{
|
||||
sender.sendMessage("Dimensions folder must have 1 file in it");
|
||||
return;
|
||||
}
|
||||
|
||||
File dim = dimensions.listFiles()[0];
|
||||
|
||||
if(!dim.isFile())
|
||||
{
|
||||
sender.sendMessage("Invalid dimension (folder) in dimensions folder");
|
||||
return;
|
||||
}
|
||||
|
||||
String key = dim.getName().split("\\Q.\\E")[0];
|
||||
IrisDimension d = new Gson().fromJson(IO.readAll(dim), IrisDimension.class);
|
||||
sender.sendMessage("Importing " + d.getName() + " (" + key + ")");
|
||||
File packEntry = new File(packs, key);
|
||||
|
||||
if(forceOverwrite)
|
||||
{
|
||||
IO.delete(packEntry);
|
||||
}
|
||||
|
||||
if(IrisDataManager.loadAnyDimension(key) != null)
|
||||
{
|
||||
sender.sendMessage("Another dimension in the packs folder is already using the key " + key + " IMPORT FAILED!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(packEntry.exists() && packEntry.listFiles().length > 0)
|
||||
{
|
||||
sender.sendMessage("Another pack is using the key " + key + ". IMPORT FAILED!");
|
||||
return;
|
||||
}
|
||||
|
||||
FileUtils.copyDirectory(dir, packEntry);
|
||||
|
||||
if(trim)
|
||||
{
|
||||
sender.sendMessage("Trimming " + key);
|
||||
File cp = compilePackage(sender, key, false, false);
|
||||
IO.delete(packEntry);
|
||||
packEntry.mkdirs();
|
||||
ZipUtil.unpack(cp, packEntry);
|
||||
}
|
||||
|
||||
sender.sendMessage("Successfully Aquired " + d.getName());
|
||||
}
|
||||
|
||||
public KMap<String, String> getListing(boolean cached)
|
||||
{
|
||||
if(cached && cacheListing != null)
|
||||
{
|
||||
return cacheListing;
|
||||
}
|
||||
|
||||
JSONArray a;
|
||||
|
||||
if(cached)
|
||||
{
|
||||
a = new JSONArray(Objects.requireNonNull(Iris.getCached("cachedlisting", LISTING)));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
a = new JSONArray(Iris.getNonCached(true + "listing", LISTING));
|
||||
}
|
||||
|
||||
KMap<String, String> l = new KMap<>();
|
||||
|
||||
for(int i = 0; i < a.length(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
String m = a.getString(i).trim();
|
||||
String[] v = m.split("\\Q \\E");
|
||||
l.put(v[0], v[1]);
|
||||
}
|
||||
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
public boolean isProjectOpen()
|
||||
{
|
||||
return activeProject != null && activeProject.isOpen();
|
||||
}
|
||||
|
||||
public void open(MortarSender sender, String dimm)
|
||||
{
|
||||
try {
|
||||
open(sender, dimm, () ->
|
||||
{
|
||||
if (sender.isPlayer()) {
|
||||
sender.player().removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
}
|
||||
});
|
||||
} catch (Exception e){
|
||||
sender.player().removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
sender.sendMessage("Error when creating studio world:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void open(MortarSender sender, String dimm, Runnable onDone)
|
||||
{
|
||||
if(isProjectOpen())
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
IrisProject project = new IrisProject(new File(getWorkspaceFolder(), dimm));
|
||||
activeProject = project;
|
||||
project.open(sender, onDone);
|
||||
}
|
||||
|
||||
public File getWorkspaceFolder(String... sub)
|
||||
{
|
||||
return Iris.instance.getDataFolderList(WORKSPACE_NAME, sub);
|
||||
}
|
||||
|
||||
public File getWorkspaceFile(String... sub)
|
||||
{
|
||||
return Iris.instance.getDataFileList(WORKSPACE_NAME, sub);
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
if(isProjectOpen())
|
||||
{
|
||||
activeProject.close();
|
||||
activeProject = null;
|
||||
}
|
||||
}
|
||||
|
||||
public File compilePackage(MortarSender sender, String d, boolean obfuscate, boolean minify)
|
||||
{
|
||||
return new IrisProject(new File(getWorkspaceFolder(), d)).compilePackage(sender, obfuscate, minify);
|
||||
}
|
||||
|
||||
public void createFrom(String existingPack, String newName)
|
||||
{
|
||||
File importPack = getWorkspaceFolder(existingPack);
|
||||
File newPack = getWorkspaceFolder(newName);
|
||||
|
||||
if(importPack.listFiles().length == 0)
|
||||
{
|
||||
Iris.warn("Couldn't find the pack to create a new dimension from.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
FileUtils.copyDirectory(importPack, newPack, new FileFilter()
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File pathname)
|
||||
{
|
||||
return !pathname.getAbsolutePath().contains(".git");
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
new File(importPack, existingPack + ".code-workspace").delete();
|
||||
File dimFile = new File(importPack, "dimensions/" + existingPack + ".json");
|
||||
File newDimFile = new File(newPack, "dimensions/" + newName + ".json");
|
||||
|
||||
try
|
||||
{
|
||||
FileUtils.copyFile(dimFile, newDimFile);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
new File(newPack, "dimensions/" + existingPack + ".json").delete();
|
||||
|
||||
try
|
||||
{
|
||||
JSONObject json = new JSONObject(IO.readAll(newDimFile));
|
||||
|
||||
if(json.has("name"))
|
||||
{
|
||||
json.put("name", Form.capitalizeWords(newName.replaceAll("\\Q-\\E", " ")));
|
||||
IO.writeAll(newDimFile, json.toString(4));
|
||||
}
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IrisProject p = new IrisProject(getWorkspaceFolder(newName));
|
||||
JSONObject ws = p.createCodeWorkspaceConfig();
|
||||
IO.writeAll(getWorkspaceFile(newName, newName + ".code-workspace"), ws.toString(0));
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void create(MortarSender sender, String s, String downloadable)
|
||||
{
|
||||
boolean shouldDelete = false;
|
||||
File importPack = getWorkspaceFolder(downloadable);
|
||||
|
||||
if(importPack.listFiles().length == 0)
|
||||
{
|
||||
downloadSearch(sender, downloadable, false);
|
||||
|
||||
if(importPack.listFiles().length > 0)
|
||||
{
|
||||
shouldDelete = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(importPack.listFiles().length == 0)
|
||||
{
|
||||
sender.sendMessage("Couldn't find the pack to create a new dimension from.");
|
||||
return;
|
||||
}
|
||||
|
||||
File importDimensionFile = new File(importPack, "dimensions/" + downloadable + ".json");
|
||||
|
||||
if(!importDimensionFile.exists())
|
||||
{
|
||||
sender.sendMessage("Missing Imported Dimension File");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage("Importing " + downloadable + " into new Project " + s);
|
||||
createFrom(downloadable, s);
|
||||
if(shouldDelete)
|
||||
{
|
||||
importPack.delete();
|
||||
}
|
||||
open(sender, s);
|
||||
}
|
||||
|
||||
public void create(MortarSender sender, String s)
|
||||
{
|
||||
create(sender, s, "example");
|
||||
}
|
||||
|
||||
public void updateWorkspace()
|
||||
{
|
||||
if(isProjectOpen())
|
||||
{
|
||||
activeProject.updateWorkspace();
|
||||
}
|
||||
}
|
||||
}
|
||||
1062
src/main/java/com/volmit/iris/manager/SchemaBuilder.java
Normal file
1062
src/main/java/com/volmit/iris/manager/SchemaBuilder.java
Normal file
File diff suppressed because it is too large
Load Diff
354
src/main/java/com/volmit/iris/manager/WandManager.java
Normal file
354
src/main/java/com/volmit/iris/manager/WandManager.java
Normal file
@@ -0,0 +1,354 @@
|
||||
package com.volmit.iris.manager;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.manager.edit.DustRevealer;
|
||||
import com.volmit.iris.object.IrisObject;
|
||||
import com.volmit.iris.util.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
|
||||
public class WandManager implements Listener
|
||||
{
|
||||
public WandManager()
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () ->
|
||||
{
|
||||
for(Player i : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
tick(i);
|
||||
}
|
||||
}, 0, 5);
|
||||
Bukkit.getPluginManager().registerEvents(this, Iris.instance);
|
||||
}
|
||||
|
||||
public void tick(Player p)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(isWand(p.getInventory().getItemInMainHand()))
|
||||
{
|
||||
Location[] d = getCuboid(p.getInventory().getItemInMainHand());
|
||||
draw(d, p);
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(Cuboid d, Player p)
|
||||
{
|
||||
draw(new Location[] {d.getLowerNE(), d.getUpperSW()}, p);
|
||||
}
|
||||
|
||||
public void draw(Location[] d, Player p)
|
||||
{
|
||||
Vector gx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65);
|
||||
d[0].getWorld().spawnParticle(Particle.CRIT_MAGIC, d[0], 1, 0.5 + gx.getX(), 0.5 + gx.getY(), 0.5 + gx.getZ(), 0, null, false);
|
||||
Vector gxx = Vector.getRandom().subtract(Vector.getRandom()).normalize().clone().multiply(0.65);
|
||||
d[1].getWorld().spawnParticle(Particle.CRIT, d[1], 1, 0.5 + gxx.getX(), 0.5 + gxx.getY(), 0.5 + gxx.getZ(), 0, null, false);
|
||||
|
||||
if(!d[0].getWorld().equals(d[1].getWorld()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(d[0].distanceSquared(d[1]) > 64 * 64)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int minx = Math.min(d[0].getBlockX(), d[1].getBlockX());
|
||||
int miny = Math.min(d[0].getBlockY(), d[1].getBlockY());
|
||||
int minz = Math.min(d[0].getBlockZ(), d[1].getBlockZ());
|
||||
int maxx = Math.max(d[0].getBlockX(), d[1].getBlockX());
|
||||
int maxy = Math.max(d[0].getBlockY(), d[1].getBlockY());
|
||||
int maxz = Math.max(d[0].getBlockZ(), d[1].getBlockZ());
|
||||
|
||||
for(double j = minx - 1; j < maxx + 1; j += 0.25)
|
||||
{
|
||||
for(double k = miny - 1; k < maxy + 1; k += 0.25)
|
||||
{
|
||||
for(double l = minz - 1; l < maxz + 1; l += 0.25)
|
||||
{
|
||||
if(M.r(0.2))
|
||||
{
|
||||
boolean jj = j == minx || j == maxx;
|
||||
boolean kk = k == miny || k == maxy;
|
||||
boolean ll = l == minz || l == maxz;
|
||||
double aa = j;
|
||||
double bb = k;
|
||||
double cc = l;
|
||||
|
||||
if((jj && kk) || (jj && ll) || (ll && kk))
|
||||
{
|
||||
Vector push = new Vector(0, 0, 0);
|
||||
|
||||
if(j == minx)
|
||||
{
|
||||
push.add(new Vector(-0.55, 0, 0));
|
||||
}
|
||||
|
||||
if(k == miny)
|
||||
{
|
||||
push.add(new Vector(0, -0.55, 0));
|
||||
}
|
||||
|
||||
if(l == minz)
|
||||
{
|
||||
push.add(new Vector(0, 0, -0.55));
|
||||
}
|
||||
|
||||
if(j == maxx)
|
||||
{
|
||||
push.add(new Vector(0.55, 0, 0));
|
||||
}
|
||||
|
||||
if(k == maxy)
|
||||
{
|
||||
push.add(new Vector(0, 0.55, 0));
|
||||
}
|
||||
|
||||
if(l == maxz)
|
||||
{
|
||||
push.add(new Vector(0, 0, 0.55));
|
||||
}
|
||||
|
||||
Location lv = new Location(d[0].getWorld(), aa, bb, cc).clone().add(0.5, 0.5, 0.5).clone().add(push);
|
||||
Color color = Color.getHSBColor((float) (0.5f + (Math.sin((aa + bb + cc + (p.getTicksLived() / 2)) / 20f) / 2)), 1, 1);
|
||||
int r = color.getRed();
|
||||
int g = color.getGreen();
|
||||
int b = color.getBlue();
|
||||
p.spawnParticle(Particle.REDSTONE, lv.getX(), lv.getY(), lv.getZ(), 1, 0, 0, 0, 0, new Particle.DustOptions(org.bukkit.Color.fromRGB(r, g, b), 0.75f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(PlayerInteractEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Objects.equals(e.getHand(), EquipmentSlot.HAND) && isWand(e.getPlayer().getInventory().getItemInMainHand()))
|
||||
{
|
||||
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().getInventory().setItemInMainHand(update(true, Objects.requireNonNull(e.getClickedBlock()).getLocation(), e.getPlayer().getInventory().getItemInMainHand()));
|
||||
e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 0.67f);
|
||||
e.getPlayer().updateInventory();
|
||||
}
|
||||
|
||||
else if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().getInventory().setItemInMainHand(update(false, Objects.requireNonNull(e.getClickedBlock()).getLocation(), e.getPlayer().getInventory().getItemInMainHand()));
|
||||
e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 1.17f);
|
||||
e.getPlayer().updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
if(e.getHand().equals(EquipmentSlot.HAND) && isDust(e.getPlayer().getInventory().getItemInMainHand()))
|
||||
{
|
||||
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().playSound(Objects.requireNonNull(e.getClickedBlock()).getLocation(), Sound.ENTITY_ENDER_EYE_DEATH, 2f, 1.97f);
|
||||
DustRevealer.spawn(e.getClickedBlock(), new MortarSender(e.getPlayer(), Iris.instance.getTag()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void pasteSchematic(IrisObject s, Location at)
|
||||
{
|
||||
s.place(at);
|
||||
}
|
||||
|
||||
public static IrisObject createSchematic(ItemStack wand)
|
||||
{
|
||||
if(!isWand(wand))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Location[] f = getCuboid(wand);
|
||||
Cuboid c = new Cuboid(f[0], f[1]);
|
||||
IrisObject s = new IrisObject(c.getSizeX(), c.getSizeY(), c.getSizeZ());
|
||||
Iterator<Block> bb = c.iterator();
|
||||
while(bb.hasNext())
|
||||
{
|
||||
Block b = bb.next();
|
||||
|
||||
if(b.getType().equals(Material.AIR))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockVector bv = b.getLocation().subtract(c.getLowerNE().toVector()).toVector().toBlockVector();
|
||||
s.setUnsigned(bv.getBlockX(), bv.getBlockY(), bv.getBlockZ(), b);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Location stringToLocation(String s)
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] f = s.split("\\Q in \\E");
|
||||
String[] g = f[0].split("\\Q,\\E");
|
||||
return new Location(Bukkit.getWorld(f[1]), Integer.valueOf(g[0]), Integer.valueOf(g[1]), Integer.valueOf(g[2]));
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String locationToString(Location s)
|
||||
{
|
||||
if(s == null)
|
||||
{
|
||||
return "<#>";
|
||||
}
|
||||
|
||||
return s.getBlockX() + "," + s.getBlockY() + "," + s.getBlockZ() + " in " + s.getWorld().getName();
|
||||
}
|
||||
|
||||
public static ItemStack createWand()
|
||||
{
|
||||
return createWand(null, null);
|
||||
}
|
||||
|
||||
public static ItemStack createDust()
|
||||
{
|
||||
ItemStack is = new ItemStack(Material.GLOWSTONE_DUST);
|
||||
is.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(C.BOLD + "" + C.YELLOW + "Dust of Revealing");
|
||||
im.setUnbreakable(true);
|
||||
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ENCHANTS);
|
||||
im.setLore(new KList<String>().qadd("Right click on a block to reveal it's placement structure!"));
|
||||
is.setItemMeta(im);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
public boolean isDust(ItemStack is)
|
||||
{
|
||||
if(is == null || is.getType().equals(Material.AIR))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(is.getType().equals(Material.GLOWSTONE_DUST))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack update(boolean left, Location a, ItemStack item)
|
||||
{
|
||||
if(!isWand(item))
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
Location[] f = getCuboid(item);
|
||||
Location other = left ? f[1] : f[0];
|
||||
|
||||
if(other != null && !other.getWorld().getName().equals(a.getWorld().getName()))
|
||||
{
|
||||
other = null;
|
||||
}
|
||||
|
||||
return createWand(left ? a : other, left ? other : a);
|
||||
}
|
||||
|
||||
public static ItemStack createWand(Location a, Location b)
|
||||
{
|
||||
ItemStack is = new ItemStack(Material.BLAZE_ROD);
|
||||
is.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(C.BOLD + "" + C.GOLD + "Wand of Iris");
|
||||
im.setUnbreakable(true);
|
||||
im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ENCHANTS);
|
||||
im.setLore(new KList<String>().add(locationToString(a), locationToString(b)));
|
||||
is.setItemMeta(im);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
public static boolean isWand(Player p)
|
||||
{
|
||||
ItemStack is = p.getInventory().getItemInMainHand();
|
||||
return !(is == null || !isWand(is));
|
||||
}
|
||||
|
||||
public static Location[] getCuboid(ItemStack is)
|
||||
{
|
||||
ItemMeta im = is.getItemMeta();
|
||||
return new Location[] {stringToLocation(im.getLore().get(0)), stringToLocation(im.getLore().get(1))};
|
||||
}
|
||||
|
||||
public static boolean isWand(ItemStack item)
|
||||
{
|
||||
if(!item.getType().equals(createWand().getType()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!item.getItemMeta().getEnchants().equals(createWand().getItemMeta().getEnchants()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!item.getItemMeta().getDisplayName().equals(createWand().getItemMeta().getDisplayName()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.volmit.iris.manager.command;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.manager.command.jigsaw.CommandIrisJigsaw;
|
||||
import com.volmit.iris.manager.command.object.CommandIrisObject;
|
||||
import com.volmit.iris.manager.command.studio.CommandIrisStudio;
|
||||
import com.volmit.iris.manager.command.what.CommandIrisWhat;
|
||||
import com.volmit.iris.manager.command.world.*;
|
||||
import com.volmit.iris.util.Command;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIris extends MortarCommand
|
||||
{
|
||||
@Command
|
||||
private CommandIrisCreate create;
|
||||
|
||||
@Command
|
||||
private CommandIrisFix fix;
|
||||
|
||||
@Command
|
||||
private CommandIrisStudio studio;
|
||||
|
||||
@Command
|
||||
private CommandIrisJigsaw jigsaw;
|
||||
|
||||
@Command
|
||||
private CommandIrisObject object;
|
||||
|
||||
@Command
|
||||
private CommandIrisRegen regen;
|
||||
|
||||
@Command
|
||||
private CommandIrisDownload download;
|
||||
|
||||
@Command
|
||||
private CommandIrisUpdateProject updateProject;
|
||||
|
||||
@Command
|
||||
private CommandIrisUpdateWorld updateWorld;
|
||||
|
||||
@Command
|
||||
private CommandIrisWhat what;
|
||||
|
||||
@Command
|
||||
private CommandIrisMetrics metrics;
|
||||
|
||||
@Command
|
||||
private CommandIrisPregen pregen;
|
||||
|
||||
@Command
|
||||
private CommandIrisReload reload;
|
||||
|
||||
public CommandIris()
|
||||
{
|
||||
super("iris", "ir", "irs");
|
||||
requiresPermission(Iris.perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
sender.sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
|
||||
printHelp(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.volmit.iris.manager.command;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.*;
|
||||
|
||||
public class CommandIrisDownload extends MortarCommand
|
||||
{
|
||||
public CommandIrisDownload()
|
||||
{
|
||||
super("download", "down", "dl");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Download a project.");
|
||||
setCategory("Studio");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(args.length < 1)
|
||||
{
|
||||
sender.sendMessage("/iris dl " + C.BOLD + "<NAME>");
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean trim = false;
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equals("-t") || i.equals("--trim"))
|
||||
{
|
||||
trim = true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean btrim = trim;
|
||||
|
||||
J.a(() -> Iris.proj.downloadSearch(sender, args[0], btrim));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "<name> [-t/--trim]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.volmit.iris.manager.command;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.scaffold.IrisWorlds;
|
||||
import com.volmit.iris.scaffold.engine.IrisAccess;
|
||||
import com.volmit.iris.util.*;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandIrisMetrics extends MortarCommand
|
||||
{
|
||||
public CommandIrisMetrics()
|
||||
{
|
||||
super("metrics", "stats", "mt");
|
||||
setDescription("Get timings for this world");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setCategory("Metrics");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(sender.isPlayer())
|
||||
{
|
||||
Player p = sender.player();
|
||||
World world = p.getWorld();
|
||||
if(!IrisWorlds.isIrisWorld(world))
|
||||
{
|
||||
sender.sendMessage("You must be in an iris world.");
|
||||
return true;
|
||||
}
|
||||
|
||||
IrisAccess g = IrisWorlds.access(world);
|
||||
|
||||
try
|
||||
{
|
||||
g.printMetrics(sender);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
sender.sendMessage("You must be in an iris world.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
sender.sendMessage("Players only.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.volmit.iris.manager.command;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisReload extends MortarCommand
|
||||
{
|
||||
public CommandIrisReload()
|
||||
{
|
||||
super("reload", "rld");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Reload configs");
|
||||
setCategory("Studio");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
IrisSettings.invalidate();
|
||||
IrisSettings.get();
|
||||
sender.sendMessage("settings.json Reloaded");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "<name> [-t/--trim]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.volmit.iris.manager.command;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.*;
|
||||
|
||||
public class CommandIrisUpdateProject extends MortarCommand
|
||||
{
|
||||
public CommandIrisUpdateProject()
|
||||
{
|
||||
super("update-project", "^project");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
setDescription("Update a project from git.");
|
||||
setCategory("Studio");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(args.length < 1)
|
||||
{
|
||||
sender.sendMessage("/iris update-project " + C.BOLD + "<PROJECT>");
|
||||
return true;
|
||||
}
|
||||
|
||||
J.a(() -> Iris.proj.downloadSearch(sender, args[0], false, true));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "<project>";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.volmit.iris.manager.command;
|
||||
|
||||
import com.volmit.iris.util.MortarPermission;
|
||||
import com.volmit.iris.util.Permission;
|
||||
|
||||
public class PermissionIris extends MortarPermission
|
||||
{
|
||||
@Permission
|
||||
public PermissionIrisStudio studio;
|
||||
|
||||
public PermissionIris()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNode()
|
||||
{
|
||||
return "iris";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return "Iris Permissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.volmit.iris.manager.command;
|
||||
|
||||
import com.volmit.iris.util.MortarPermission;
|
||||
|
||||
public class PermissionIrisStudio extends MortarPermission
|
||||
{
|
||||
public PermissionIrisStudio()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNode()
|
||||
{
|
||||
return "studio";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return "Iris Studio Permissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.volmit.iris.manager.command.jigsaw;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.util.Command;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisJigsaw extends MortarCommand
|
||||
{
|
||||
@Command
|
||||
private CommandIrisJigsawNew create;
|
||||
|
||||
@Command
|
||||
private CommandIrisJigsawEdit edit;
|
||||
|
||||
@Command
|
||||
private CommandIrisJigsawSave save;
|
||||
|
||||
@Command
|
||||
private CommandIrisJigsawPlace place;
|
||||
|
||||
public CommandIrisJigsaw()
|
||||
{
|
||||
super("jigsaw", "jig", "jsw");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Jigsaw");
|
||||
setDescription("Iris jigsaw commands");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
sender.sendMessage("Ingame only");
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage("Iris Jigsaw Commands:");
|
||||
printHelp(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.volmit.iris.manager.command.jigsaw;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.manager.edit.JigsawEditor;
|
||||
import com.volmit.iris.object.IrisJigsawPiece;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CommandIrisJigsawEdit extends MortarCommand
|
||||
{
|
||||
public CommandIrisJigsawEdit()
|
||||
{
|
||||
super("edit", "e", "*");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Jigsaw");
|
||||
setDescription("Edit an existing Jigsaw piece");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
sender.sendMessage("Ingame only");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length < 1)
|
||||
{
|
||||
sender.sendMessage(getArgsUsage());
|
||||
return true;
|
||||
}
|
||||
|
||||
IrisJigsawPiece piece = IrisDataManager.loadAnyJigsawPiece(args[0]);
|
||||
|
||||
if(piece != null)
|
||||
{
|
||||
File dest = piece.getLoadFile();
|
||||
new JigsawEditor(sender.player(), piece, IrisDataManager.loadAnyObject(piece.getObject()), dest);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "<name>";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.volmit.iris.manager.command.jigsaw;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.manager.edit.JigsawEditor;
|
||||
import com.volmit.iris.object.IrisObject;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CommandIrisJigsawNew extends MortarCommand
|
||||
{
|
||||
public CommandIrisJigsawNew()
|
||||
{
|
||||
super("create", "new", "+");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Jigsaw");
|
||||
setDescription("Create a new jigsaw piece");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
sender.sendMessage("Ingame only");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length != 3)
|
||||
{
|
||||
sender.sendMessage(getArgsUsage());
|
||||
return true;
|
||||
}
|
||||
|
||||
IrisObject object = IrisDataManager.loadAnyObject(args[2]);
|
||||
File dest = Iris.instance.getDataFile("packs", args[1], "jigsaw-pieces", args[0] + ".json");
|
||||
new JigsawEditor(sender.player(), null, object, dest);
|
||||
sender.sendMessage("* Right Click blocks to make them connectors");
|
||||
sender.sendMessage("* Right Click connectors to orient them");
|
||||
sender.sendMessage("* Shift + Right Click connectors to remove them");
|
||||
sender.sendMessage("Remember to use /iris jigsaw save");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "<name> <project> <object>";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.volmit.iris.manager.command.jigsaw;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.object.IrisJigsawStructure;
|
||||
import com.volmit.iris.object.IrisPosition;
|
||||
import com.volmit.iris.scaffold.jigsaw.PlannedStructure;
|
||||
import com.volmit.iris.util.*;
|
||||
|
||||
public class CommandIrisJigsawPlace extends MortarCommand
|
||||
{
|
||||
public CommandIrisJigsawPlace()
|
||||
{
|
||||
super("place", "paste");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Jigsaw");
|
||||
setDescription("Place a jigsaw structure");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
sender.sendMessage("Ingame only");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args.length == 0){
|
||||
sender.sendMessage("You have to specify a jigsaw structure!");
|
||||
return true;
|
||||
}
|
||||
|
||||
IrisJigsawStructure str = IrisDataManager.loadAnyJigsawStructure(args[0]);
|
||||
|
||||
if(str != null)
|
||||
{
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
PlannedStructure ps = new PlannedStructure(str, new IrisPosition(sender.player().getLocation()), new RNG());
|
||||
sender.sendMessage("Generated " + ps.getPieces().size() + " pieces in " + Form.duration(p.getMilliseconds(), 2));
|
||||
ps.place(sender.player().getWorld());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "<name>";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.volmit.iris.manager.command.jigsaw;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.edit.JigsawEditor;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisJigsawSave extends MortarCommand
|
||||
{
|
||||
public CommandIrisJigsawSave()
|
||||
{
|
||||
super("save");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Jigsaw");
|
||||
setDescription("Save a currently open piece");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
sender.sendMessage("To use Iris Studio Jigsaw, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
sender.sendMessage("Ingame only");
|
||||
return true;
|
||||
}
|
||||
|
||||
JigsawEditor editor = JigsawEditor.editors.get(sender.player());
|
||||
|
||||
if(editor == null)
|
||||
{
|
||||
sender.sendMessage("You don't have any pieces open to save!");
|
||||
return true;
|
||||
}
|
||||
|
||||
editor.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.volmit.iris.manager.command.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.util.Command;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisObject extends MortarCommand
|
||||
{
|
||||
@Command
|
||||
private CommandIrisObjectWand wand;
|
||||
|
||||
@Command
|
||||
private CommandIrisObjectDust dust;
|
||||
|
||||
@Command
|
||||
private CommandIrisObjectXPY xpy;
|
||||
|
||||
@Command
|
||||
private CommandIrisObjectXAY xay;
|
||||
|
||||
@Command
|
||||
private CommandIrisObjectShift shift;
|
||||
|
||||
@Command
|
||||
private CommandIrisObjectExpand expand;
|
||||
|
||||
@Command
|
||||
private CommandIrisObjectContract contract;
|
||||
|
||||
@Command
|
||||
private CommandIrisObjectP1 p1;
|
||||
|
||||
@Command
|
||||
private CommandIrisObjectP2 p2;
|
||||
|
||||
@Command
|
||||
private CommandIrisObjectSave save;
|
||||
|
||||
@Command
|
||||
private CommandIrisObjectPaste paste;
|
||||
|
||||
public CommandIrisObject()
|
||||
{
|
||||
super("object", "iob", "o", "obj");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
setDescription("Object Commands");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage("Iris Object Commands:");
|
||||
printHelp(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "[subcommand]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.volmit.iris.manager.command.object;
|
||||
|
||||
import com.volmit.iris.util.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.WandManager;
|
||||
|
||||
public class CommandIrisObjectContract extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectContract()
|
||||
{
|
||||
super("-");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
setDescription("Contract a selection based on your lookign direction");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
sender.sendMessage("You don't have a wand");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p = sender.player();
|
||||
|
||||
if(!WandManager.isWand(p))
|
||||
{
|
||||
sender.sendMessage("Ready your Wand.");
|
||||
return true;
|
||||
}
|
||||
|
||||
int amt = args.length == 1 ? Integer.valueOf(args[0]) : 1;
|
||||
Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand());
|
||||
Location a1 = b[0].clone();
|
||||
Location a2 = b[1].clone();
|
||||
Cuboid cursor = new Cuboid(a1, a2);
|
||||
Direction d = Direction.closest(p.getLocation().getDirection()).reverse();
|
||||
cursor = cursor.expand(d, -amt);
|
||||
b[0] = cursor.getLowerNE();
|
||||
b[1] = cursor.getUpperSW();
|
||||
p.getInventory().setItemInMainHand(WandManager.createWand(b[0], b[1]));
|
||||
p.updateInventory();
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "[amt]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.volmit.iris.manager.command.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.manager.WandManager;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
public class CommandIrisObjectDust extends MortarCommand
|
||||
{
|
||||
public CommandIrisObjectDust()
|
||||
{
|
||||
super("dust", "dst", "d");
|
||||
requiresPermission(Iris.perm);
|
||||
setCategory("Object");
|
||||
setDescription("Get a powder that reveals placed objects");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(MortarSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
if(!IrisSettings.get().isStudio())
|
||||
{
|
||||
sender.sendMessage("To use Iris Studio Objects, please enable studio in Iris/settings.json");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!sender.isPlayer())
|
||||
{
|
||||
sender.sendMessage("You don't have an inventory");
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.player().getInventory().addItem(WandManager.createDust());
|
||||
sender.player().playSound(sender.player().getLocation(), Sound.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS, 1f, 1.5f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "[subcommand]";
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user